11#include <promeki/config.h>
12#if PROMEKI_ENABLE_PROAV
24PROMEKI_NAMESPACE_BEGIN
124 PROMEKI_DATATYPE(Cea708Cdp, DataTypeCea708Cdp, 1)
127 static constexpr uint16_t Identifier = 0x9669;
130 static constexpr uint8_t FooterId = 0x74;
133 static constexpr uint8_t TimeCodeSectionId = 0x71;
136 static constexpr uint8_t CcDataSectionId = 0x72;
139 static constexpr uint8_t CcSvcInfoSectionId = 0x73;
155 bool operator==(
const CcData &o)
const {
156 return valid == o.valid && type == o.type && b1 == o.b1 && b2 == o.b2;
158 bool operator!=(
const CcData &o)
const {
return !(*
this == o); }
162 using CcDataList = ::promeki::List<CcData>;
208 struct CcSvcInfoEntry {
209 bool csnSize5Bit =
false;
210 uint8_t captionServiceNumber = 0;
214 uint8_t languageCode[3] = {0, 0, 0};
215 bool digitalCc =
false;
216 bool line21Field =
false;
217 bool easyReader =
false;
218 bool wideAspect =
false;
220 bool operator==(
const CcSvcInfoEntry &o)
const {
221 return csnSize5Bit == o.csnSize5Bit
222 && captionServiceNumber == o.captionServiceNumber
223 && languageCode[0] == o.languageCode[0]
224 && languageCode[1] == o.languageCode[1]
225 && languageCode[2] == o.languageCode[2]
226 && digitalCc == o.digitalCc
227 && line21Field == o.line21Field
228 && easyReader == o.easyReader
229 && wideAspect == o.wideAspect;
231 bool operator!=(
const CcSvcInfoEntry &o)
const {
return !(*
this == o); }
235 using CcSvcInfoEntryList = ::promeki::List<CcSvcInfoEntry>;
240 uint8_t frameRateCode = 0;
243 bool timeCodePresent =
false;
246 bool ccDataPresent =
false;
250 bool svcInfoPresent =
false;
253 bool svcInfoStart =
false;
256 bool svcInfoChange =
false;
259 bool svcInfoComplete =
false;
262 bool captionServiceActive =
false;
266 uint16_t sequenceCounter = 0;
288 bool tcFieldFlag =
false;
306 CcSvcInfoEntryList ccSvcInfo;
331 uint32_t svcInfoMismatches = 0;
335 Cea708Cdp() =
default;
351 Cea708Cdp(uint8_t frameRateCode, CcDataList ccData, uint16_t sequenceCounter = 0)
352 : frameRateCode(frameRateCode)
353 , ccDataPresent(!ccData.isEmpty())
354 , captionServiceActive(!ccData.isEmpty())
355 , sequenceCounter(sequenceCounter)
356 , ccData(std::move(ccData)) {}
370 Buffer toBuffer()
const;
384 static Result<Cea708Cdp> fromBuffer(
const void *data,
size_t size);
387 static Result<Cea708Cdp> fromBuffer(
const Buffer &buf);
400 static uint8_t frameRateCodeFor(
const FrameRate &frameRate);
413 JsonObject toJson()
const;
426 bool operator==(
const Cea708Cdp &o)
const;
429 bool operator!=(
const Cea708Cdp &o)
const {
return !(*
this == o); }
440 String toString()
const;
450 Error writeToStream(DataStream &s)
const;
456 template <u
int32_t V>
static Result<Cea708Cdp> readFromStream(DataStream &s);