libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
ltcencoder.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/framerate.h>
14#include <promeki/list.h>
15#include <promeki/namespace.h>
16#include <promeki/timecode.h>
17#include <promeki/uniqueptr.h>
18#include <vtc/ltc_audio.h>
19
20PROMEKI_NAMESPACE_BEGIN
21
45class LtcEncoder {
46 public:
48 using UPtr = UniquePtr<LtcEncoder>;
49
73 LtcEncoder(int sampleRate, const FrameRate &frameRate, float level = 0.5f);
74
76 ~LtcEncoder() = default;
77
78 LtcEncoder(const LtcEncoder &) = delete;
79 LtcEncoder &operator=(const LtcEncoder &) = delete;
80 LtcEncoder(LtcEncoder &&) = default;
81 LtcEncoder &operator=(LtcEncoder &&) = default;
82
87 int sampleRate() const { return _encoder.sample_rate; }
88
99 FrameRate frameRate() const { return _frameRate; }
100
105 float level() const { return _encoder.level; }
106
111 void setLevel(float level);
112
146 List<int8_t> encode(const Timecode &tc);
147
155 void resetSlicing();
156
165 size_t frameSizeApprox(const VtcFormat *format) const;
166
167 private:
168 VtcLTCEncoder _encoder;
169 FrameRate _frameRate;
170
171 // Chunked-emission state (active only when _frameRate.isValid()).
172 // _codewordBuf holds the most recent full libvtc codeword's audio;
173 // _codewordCursor counts samples already emitted from it. The
174 // sample-count counters track exact long-term emission to avoid
175 // rounding drift at NTSC fractional rates.
176 List<int8_t> _codewordBuf;
177 size_t _codewordCursor = 0;
178 int64_t _videoFramesEmitted = 0;
179 int64_t _samplesEmittedTotal = 0;
180};
181
182PROMEKI_NAMESPACE_END
183
184#endif // PROMEKI_ENABLE_PROAV