libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
tpgmediaio.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>
14#include <promeki/ancdesc.h>
17#include <promeki/cea708cdp.h>
19#include <promeki/enums_tpg.h>
21#include <promeki/map.h>
23#include <promeki/scc.h>
28#include <promeki/imagedesc.h>
29#include <promeki/list.h>
30#include <promeki/audiodesc.h>
31#include <promeki/mediadesc.h>
32#include <promeki/subtitle.h>
33#include <promeki/uniqueptr.h>
34#include <promeki/videoformat.h>
35
36PROMEKI_NAMESPACE_BEGIN
37
124class TpgMediaIO : public SharedThreadMediaIO {
125 PROMEKI_OBJECT(TpgMediaIO, SharedThreadMediaIO)
126 public:
127 // All config keys for this backend live in MediaConfig —
128 // use @c MediaConfig::FrameRate / @c MediaConfig::VideoSize
129 // / @c MediaConfig::VideoPattern / etc. directly. See
130 // @ref MediaConfig for the full catalog.
131
132 TpgMediaIO(ObjectBase *parent = nullptr);
133
135 ~TpgMediaIO() override;
136
137 Error describe(MediaIODescription *out) const override;
138 Error proposeOutput(const MediaDesc &requested, MediaDesc *achievable,
139 MediaConfig *configDelta = nullptr) const override;
140
141 protected:
142 Error executeCmd(MediaIOCommandOpen &cmd) override;
143 Error executeCmd(MediaIOCommandClose &cmd) override;
144 Error executeCmd(MediaIOCommandRead &cmd) override;
145
146 private:
147 // Helper that derives the MediaDesc the generator would
148 // emit given its current MediaConfig — used by both
149 // describe() and proposeOutput so the planner sees a
150 // consistent view of "what TPG produces".
151 MediaDesc producedFromConfig(const MediaIO::Config &cfg) const;
152
153 // Video state
154 VideoTestPattern _videoPattern;
155 ImageDesc _imageDesc;
156 double _motion = 0.0;
157 double _motionOffset = 0.0;
158 bool _videoEnabled = false;
159 bool _burnEnabled = false;
160 String _burnTextTemplate;
161 bool _motionBandEnabled = false;
162
163 // Binary data encoder pass (VITC-style frame stamp).
164 ImageDataEncoder _dataEncoder;
165 bool _dataEncoderEnabled = false;
166 uint32_t _dataEncoderRepeat = 16;
167 uint32_t _streamId = 0;
168
169 // Audio state
170 AudioTestPattern::UPtr _audioPattern;
171 AudioDesc _audioDesc;
172 bool _audioEnabled = false;
173
174 // Timecode state
175 TimecodeGenerator _tcGen;
176 bool _timecodeEnabled = false;
177
178 // CEA-708 caption ANC state
179 bool _ancCaptionsEnabled = false;
180 String _ancCaptionsFile;
181 Duration _ancCaptionsOffset;
182 uint16_t _ancCaptionsLine = 11;
183 uint16_t _ancSequenceCounter = 0;
184 uint8_t _ancFrameRateCode = 0;
185 AncTranslator _ancTranslator;
186 AncDesc _ancDesc;
191 SubtitleList _ancCaptions;
201 List<UniquePtr<CaptionEncoder>> _ancCaptionEncoders;
202
207 CaptionCodec _ancCaptionsCodec = CaptionCodec::Cea608;
208
219 Map<int64_t, Cea708Cdp::CcDataList> _ancSccByFrame;
220 bool _ancSccBypassActive = false;
221
222 // General state
223 FrameRate _frameRate;
224 FrameCount _frameCount{0};
225};
226
231class TpgFactory : public MediaIOFactory {
232 public:
233 TpgFactory() = default;
234
235 String name() const override { return String("TPG"); }
236 String displayName() const override { return String("Test Pattern Generator"); }
237 String description() const override {
238 return String("Video/audio/timecode test pattern generator");
239 }
240 bool canBeSource() const override { return true; }
241
242 Config::SpecMap configSpecs() const override;
243 Metadata defaultMetadata() const override;
244 MediaIO *create(const Config &config, ObjectBase *parent = nullptr) const override;
245};
246
247PROMEKI_NAMESPACE_END
248
249#endif // PROMEKI_ENABLE_PROAV