libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
cea708cdp.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
13#include <cstdint>
14#include <promeki/buffer.h>
15#include <promeki/error.h>
16#include <promeki/json.h>
17#include <promeki/list.h>
18#include <promeki/namespace.h>
19#include <promeki/result.h>
20#include <promeki/string.h>
21#include <promeki/timecode.h>
22
23PROMEKI_NAMESPACE_BEGIN
24
25class DataStream;
26
111class Cea708Cdp {
112 public:
113 PROMEKI_DATATYPE(Cea708Cdp, DataTypeCea708Cdp, 1)
114
115
116 static constexpr uint16_t Identifier = 0x9669;
117
119 static constexpr uint8_t FooterId = 0x74;
120
122 static constexpr uint8_t TimeCodeSectionId = 0x71;
123
125 static constexpr uint8_t CcDataSectionId = 0x72;
126
128 static constexpr uint8_t CcSvcInfoSectionId = 0x73;
129
138 struct CcData {
139 bool valid = true;
140 uint8_t type = 0;
141 uint8_t b1 = 0;
142 uint8_t b2 = 0;
143
144 bool operator==(const CcData &o) const {
145 return valid == o.valid && type == o.type && b1 == o.b1 && b2 == o.b2;
146 }
147 bool operator!=(const CcData &o) const { return !(*this == o); }
148 };
149
151 using CcDataList = ::promeki::List<CcData>;
152
153 // -- Header fields ----------------------------------------
154
156 uint8_t frameRateCode = 0;
157
159 bool timeCodePresent = false;
160
162 bool ccDataPresent = false;
163
166 bool svcInfoPresent = false;
167
169 bool svcInfoStart = false;
170
172 bool svcInfoChange = false;
173
175 bool svcInfoComplete = false;
176
178 bool captionServiceActive = false;
179
182 uint16_t sequenceCounter = 0;
183
184 // -- Sections ---------------------------------------------
185
192 Timecode timeCode;
193
204 bool tcFieldFlag = false;
205
209 CcDataList ccData;
210
217 Buffer extraBytes;
218
219 // -- Construction -----------------------------------------
220
221 Cea708Cdp() = default;
222
237 Cea708Cdp(uint8_t frameRateCode, CcDataList ccData, uint16_t sequenceCounter = 0)
238 : frameRateCode(frameRateCode)
239 , ccDataPresent(!ccData.isEmpty())
240 , captionServiceActive(!ccData.isEmpty())
241 , sequenceCounter(sequenceCounter)
242 , ccData(std::move(ccData)) {}
243
244 // -- Wire round-trip --------------------------------------
245
256 Buffer toBuffer() const;
257
270 static Result<Cea708Cdp> fromBuffer(const void *data, size_t size);
271
273 static Result<Cea708Cdp> fromBuffer(const Buffer &buf);
274
275 // -- JSON dump --------------------------------------------
276
286 JsonObject toJson() const;
287
288 // -- Comparison -------------------------------------------
289
299 bool operator==(const Cea708Cdp &o) const;
300
302 bool operator!=(const Cea708Cdp &o) const { return !(*this == o); }
303
304 // -- Diagnostics ------------------------------------------
305
313 String toString() const;
314
323 Error writeToStream(DataStream &s) const;
324
329 template <uint32_t V> static Result<Cea708Cdp> readFromStream(DataStream &s);
330};
331
332PROMEKI_NAMESPACE_END
333
334#endif // PROMEKI_ENABLE_PROAV