libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
anctranslateconfig.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 <promeki/namespace.h>
15#include <promeki/duration.h>
16#include <promeki/enums_anc.h>
17#include <promeki/string.h>
18#include <promeki/error.h>
19#include <promeki/metadata.h>
20
21PROMEKI_NAMESPACE_BEGIN
22
93class AncTranslateConfig : public VariantDatabase<"AncTranslateConfig"> {
94 public:
96 using Base = VariantDatabase<"AncTranslateConfig">;
97
98 using Base::Base;
99
100 // ============================================================
101 // Universal knobs
102 // ============================================================
103
111 PROMEKI_DECLARE_ID(Fidelity,
112 VariantSpec()
113 .setType(DataTypeEnum)
114 .setEnumType(AncFidelity::Type)
115 .setDefault(AncFidelity(AncFidelity::Default))
116 .setDescription("Output verbosity for translators that have multiple valid output forms."));
117
120 PROMEKI_DECLARE_ID(Checksum,
121 VariantSpec()
122 .setType(DataTypeEnum)
123 .setEnumType(AncChecksumPolicy::Type)
124 .setDefault(AncChecksumPolicy(AncChecksumPolicy::PreserveOrRecompute))
125 .setDescription("ST 291 checksum policy for builder / translator outputs."));
126
133 PROMEKI_DECLARE_ID(OnUnsupported,
134 VariantSpec()
135 .setType(DataTypeEnum)
136 .setEnumType(AncOnUnsupported::Type)
137 .setDefault(AncOnUnsupported(AncOnUnsupported::BestEffort))
138 .setDescription("Behaviour when the input cannot be represented on the target transport."));
139
149 PROMEKI_DECLARE_ID(AllowLossy,
150 VariantSpec()
151 .setType(DataTypeBool)
152 .setDefault(false)
153 .setDescription("Permit lossy translations (truncation / downsampling) when no lossless path exists."));
154
155 // ============================================================
156 // Per-transport build-time inputs
157 // ============================================================
158 //
159 // Naming pattern: <Transport><Field>. The dotted-namespace
160 // form the devplan sketches (`St291::BuildLine`) is not
161 // representable as a single C++ identifier in a database
162 // that takes a flat name list; we keep the wire name
163 // dotted (`St291.BuildLine`) for nice JSON output while
164 // the C++ identifier collapses the dot.
165
178 PROMEKI_DECLARE_ID(St291BuildLine,
179 VariantSpec()
180 .setType(DataTypeUInt16)
181 .setDefault(uint16_t(0x7FE))
182 .setDescription("VANC line number for built ST 291 packets (0x7FE = "
183 "RP 168 sentinel: anywhere after the switching point)."));
184
187 PROMEKI_DECLARE_ID(St291FieldB,
188 VariantSpec()
189 .setType(DataTypeBool)
190 .setDefault(false)
191 .setDescription("F-bit for built ST 291 packets (field-2 indicator)."));
192
203 PROMEKI_DECLARE_ID(St291BuildCBit,
204 VariantSpec()
205 .setType(DataTypeBool)
206 .setDefault(false)
207 .setDescription("C-bit (Y=false / C=true) for built ST 291 packets."));
208
221 PROMEKI_DECLARE_ID(St291KeepAliveField,
222 VariantSpec()
223 .setType(DataTypeUInt8)
224 .setDefault(uint8_t(0))
225 .setDescription("F-bit for the ST 2110-40 §5.5 ANC_Count=0 keep-alive RTP packet."));
226
232 PROMEKI_DECLARE_ID(NdiXmlNamespace,
233 VariantSpec()
234 .setType(DataTypeString)
235 .setDefault(String())
236 .setDescription("XML namespace prefix preference for built NDI metadata frames."));
237
243 PROMEKI_DECLARE_ID(HdmiInfoFrameOui,
244 VariantSpec()
245 .setType(DataTypeUInt32)
246 .setDefault(uint32_t(0))
247 .setDescription("OUI to stamp into built vendor-specific HDMI InfoFrames (0 = codec default)."));
248
257 PROMEKI_DECLARE_ID(RtmpAmfObjectName,
258 VariantSpec()
259 .setType(DataTypeString)
260 .setDefault(String())
261 .setDescription("AMF0 script-tag name override for built RTMP outputs (empty = codec default)."));
262
271 PROMEKI_DECLARE_ID(HdrDynamicImageWidth,
272 VariantSpec()
273 .setType(DataTypeUInt32)
274 .setDefault(uint32_t(0))
275 .setDescription("Image width (pixels) for ST 2094-40 §9.2 Window 0 (0 = unknown, emits sentinel)."));
276
280 PROMEKI_DECLARE_ID(HdrDynamicImageHeight,
281 VariantSpec()
282 .setType(DataTypeUInt32)
283 .setDefault(uint32_t(0))
284 .setDescription("Image height (pixels) for ST 2094-40 §9.2 Window 0 (0 = unknown, emits sentinel)."));
285
296 PROMEKI_DECLARE_ID(AtcParseRateHint,
297 VariantSpec()
298 .setType(DataTypeUInt32)
299 .setDefault(uint32_t(0))
300 .setDescription("ATC parse-time frame-rate hint (24/25/30; 0 = no hint)."));
301
313 PROMEKI_DECLARE_ID(AtcHfrtcBitstreamNumber,
314 VariantSpec()
315 .setType(DataTypeUInt8)
316 .setDefault(uint8_t(0))
317 .setDescription("Bitstream number (DBB1 low nibble, 0..15) for built ATC_HFRTC packets."));
318
334 PROMEKI_DECLARE_ID(AtcHfrtcParseFormatHint,
335 VariantSpec()
336 .setType(DataTypeUInt32)
337 .setDefault(uint32_t(0))
338 .setDescription("ATC_HFRTC parse-time format-rate fallback (72/96/100/120; 0 = none)."));
339
350 PROMEKI_DECLARE_ID(RtpJitterWarnThreshold,
351 VariantSpec()
352 .setType(DataTypeDuration)
353 .setDefault(Duration::zero())
354 .setDescription("RTP interarrival-jitter warning threshold (e.g. 10ms; 0 = off)."));
355
356 // ============================================================
357 // String round-trip (JSON)
358 // ============================================================
359
370 AncChecksumPolicy checksumPolicy() const {
371 if (!contains(Checksum)) {
372 return AncChecksumPolicy(AncChecksumPolicy::PreserveOrRecompute);
373 }
374 Enum e = getAs<Enum>(Checksum);
375 return AncChecksumPolicy(e.value());
376 }
377
389 uint8_t keepAliveFieldByte() const {
390 return getAs<uint8_t>(St291KeepAliveField, uint8_t(0));
391 }
392
404 String toString(unsigned int indent = 0) const {
405 return toJson().toString(indent);
406 }
407
420 static AncTranslateConfig fromString(const String &str, Error *err = nullptr) {
421 Error parseErr;
422 JsonObject json = JsonObject::parse(str, &parseErr);
423 if (parseErr.isError()) {
424 if (err) *err = parseErr;
425 return AncTranslateConfig();
426 }
427 // Mirror Metadata::fromJson: walk the object and feed
428 // each entry through the spec-aware coercion path so
429 // string-encoded rich types (Enum, Url, …) land back
430 // as their proper Variant kind.
431 AncTranslateConfig cfg;
432 bool good = true;
433 json.forEach([&cfg, &good](const String &key, const Variant &val) {
434 if (!val.isValid()) {
435 good = false;
436 return;
437 }
438 Error e = cfg.setFromJson(ID(key), val);
439 if (e.isError()) good = false;
440 });
441 if (err) *err = good ? Error::Ok : Error::Invalid;
442 return cfg;
443 }
444};
445
446PROMEKI_NAMESPACE_END
447
448#endif // PROMEKI_ENABLE_PROAV