libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
rtpaudiopacketizerthread.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK
13#include <cstddef>
14#include <cstdint>
15#include <promeki/audiobuffer.h>
16#include <promeki/audiodesc.h>
17#include <promeki/buffer.h>
18#include <promeki/list.h>
19#include <promeki/namespace.h>
20#include <promeki/queue.h>
22#include <promeki/string.h>
23
24PROMEKI_NAMESPACE_BEGIN
25
45struct RtpAudioPacketizerContext {
50 AudioDesc storageDesc;
51
54 size_t packetSamples = 0;
55
58 size_t packetBytes = 0;
59
66 size_t prerollSamples = 0;
67
73 size_t streamIdx = 0;
74
83 Queue<Buffer> *txPacketQueue = nullptr;
84};
85
131class RtpAudioPacketizerThread : public RtpPacketizerThread {
132 public:
145 RtpAudioPacketizerThread(
146 RtpAudioPacketizerContext ctx,
147 const String &name = String("RtpAudPkt"),
148 size_t depth = DefaultPayloadQueueDepth);
149
150 ~RtpAudioPacketizerThread() override;
151
152 RtpAudioPacketizerThread(const RtpAudioPacketizerThread &) = delete;
153 RtpAudioPacketizerThread &operator=(const RtpAudioPacketizerThread &) = delete;
154
161 void packetizeForTest(const RtpFrameWork &work) { packetize(work); }
162
167 void openForTest() { onStart(); }
168
172 const AudioBuffer &fifo() const { return _fifo; }
173
175 bool isPrerollDone() const { return _prerollDone; }
176
177 protected:
178 void onStart() override;
179 void packetize(const RtpFrameWork &work) override;
180
181 private:
182 RtpAudioPacketizerContext _ctx;
183 AudioBuffer _fifo;
184 List<uint8_t> _drained;
185 bool _prerollDone = false;
186};
187
188PROMEKI_NAMESPACE_END
189
190#endif // PROMEKI_ENABLE_NETWORK