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