libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
st2110trafficcalc.h
Go to the documentation of this file.
1
8#pragma once
9
10
11#include <promeki/config.h>
12#if PROMEKI_ENABLE_NETWORK && PROMEKI_ENABLE_PROAV
13#include <cstdint>
14#include <promeki/namespace.h>
15#include <promeki/duration.h>
16#include <promeki/enums_rtp.h>
18#include <promeki/error.h>
19#include <promeki/framerate.h>
20#include <promeki/pixelformat.h>
21#include <promeki/st2110tx.h>
22#include <promeki/st2110video.h>
23#include <promeki/string.h>
24#include <promeki/videoformat.h>
25
26PROMEKI_NAMESPACE_BEGIN
27
105class St2110TrafficCalc {
106 public:
115 struct PacketModel {
117 St2110PackingMode packingMode = St2110PackingMode::Gpm;
121 int mtu = 1500;
123 int ipHeaderBytes = 20;
125 int udpHeaderBytes = 8;
127 int rtpHeaderBytes = 12;
128 };
129
138 struct Result {
140 Error error = Error::Invalid;
141
142 // ---- Resolved inputs --------------------------------
143 VideoFormat videoFormat;
144 St2110Sampling sampling;
145 St2110Depth depth;
146 RtpSenderType senderType;
147 PacketModel packetModel;
148
149 // ---- Raster + timing --------------------------------
150 uint32_t width = 0;
151 uint32_t height = 0;
152 VideoScanMode scanMode;
153 bool progressive = false;
154 int activeLines = 0;
155 int totalLines = 0;
156 double activeRatio = 0.0;
157 FrameRate frameRate;
158 Duration frameInterval;
159
160 // ---- Packetization ----------------------------------
161 St2110Video::Pgroup pgroup;
162 int rowsPerSrd = 1;
163 int64_t octetsPerLine = 0;
164 int64_t activeOctetsPerFrame = 0;
165 int payloadDataPerPacket = 0;
166 int packetsPerLine = 0;
167 int packetsPerFrame = 0;
168 int packetSizeBytes = 0;
169
170 // ---- Rates ------------------------------------------
171 double packetRate = 0.0;
172 double mediaRateBps = 0.0;
173 double wireRateBps = 0.0;
174 double beta = St2110Tx::Beta;
175 Duration tDrain;
176
177 // ---- Packet Read Schedule ---------------------------
178 Duration trsGapped;
179 Duration trsLinear;
180 Duration trs;
181 Duration troDefault;
182
183 // ---- Virtual Receiver Buffer / burst ----------------
184 int64_t vrxFull = 0;
185 int cmax = 0;
196 Duration vrxTimingWindow;
200 Duration cmaxBurstWindow;
201
202 // ---- SDP signalling ---------------------------------
203 String tpParam;
204 int64_t troffMicroseconds = 0;
205
207 bool isValid() const { return error.isOk(); }
208
213 String toString() const;
214 };
215
217 St2110TrafficCalc() = default;
218
228 static PacketModel defaultModel();
229
239 St2110TrafficCalc(const VideoFormat &format, const St2110Sampling &sampling,
240 const St2110Depth &depth, const RtpSenderType &senderType,
241 const PacketModel &model = defaultModel());
242
257 St2110TrafficCalc(const VideoFormat &format, const PixelFormat &pixelFormat,
258 const RtpSenderType &senderType,
259 const PacketModel &model = defaultModel());
260
262 const Result &result() const { return _result; }
263
265 bool isValid() const { return _result.isValid(); }
266
268 const Error &error() const { return _result.error; }
269
275 static Result compute(const VideoFormat &format, const St2110Sampling &sampling,
276 const St2110Depth &depth, const RtpSenderType &senderType,
277 const PacketModel &model = defaultModel());
278
283 static Result compute(const VideoFormat &format, const PixelFormat &pixelFormat,
284 const RtpSenderType &senderType,
285 const PacketModel &model = defaultModel());
286
287 private:
288 Result _result;
289};
290
291inline St2110TrafficCalc::St2110TrafficCalc(const VideoFormat &format,
292 const St2110Sampling &sampling,
293 const St2110Depth &depth,
294 const RtpSenderType &senderType,
295 const PacketModel &model)
296 : _result(compute(format, sampling, depth, senderType, model)) {}
297
298inline St2110TrafficCalc::St2110TrafficCalc(const VideoFormat &format,
299 const PixelFormat &pixelFormat,
300 const RtpSenderType &senderType,
301 const PacketModel &model)
302 : _result(compute(format, pixelFormat, senderType, model)) {}
303
304PROMEKI_NAMESPACE_END
305
306#endif // PROMEKI_ENABLE_NETWORK && PROMEKI_ENABLE_PROAV