libpromeki 1.0.0-alpha
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
rtcppacket.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 <cstdint>
14#include <promeki/buffer.h>
15#include <promeki/list.h>
16#include <promeki/namespace.h>
17#include <promeki/ntptime.h>
18#include <promeki/string.h>
19
20PROMEKI_NAMESPACE_BEGIN
21
61class RtcpPacket {
62 public:
64 enum Type : uint8_t {
65 SenderReport = 200,
66 ReceiverReport = 201,
67 SourceDescription = 202,
68 Goodbye = 203,
69 Application = 204,
70 };
71
73 enum SdesItemType : uint8_t {
74 SdesEnd = 0,
75 SdesCname = 1,
76 SdesName = 2,
77 SdesEmail = 3,
78 SdesPhone = 4,
79 SdesLoc = 5,
80 SdesTool = 6,
81 SdesNote = 7,
82 SdesPriv = 8,
83 };
84
107 static Buffer buildSenderReport(uint32_t ssrc, const NtpTime &ntp, uint32_t rtpTimestamp,
108 uint32_t senderPacketCount, uint32_t senderOctetCount);
109
130 struct ReportBlock {
131 uint32_t ssrc = 0;
132 uint8_t fractionLost = 0;
133 int32_t cumulativeLost = 0;
134 uint32_t extendedHighestSeq = 0;
135 uint32_t interarrivalJitter = 0;
136 uint32_t lsr = 0;
137 uint32_t dlsr = 0;
138 };
139
158 static Buffer buildReceiverReport(uint32_t ssrc, const List<ReportBlock> &blocks);
159
173 static Buffer buildBye(uint32_t ssrc);
174
192 static Buffer buildSourceDescriptionCname(uint32_t ssrc, const String &cname);
193
207 static Buffer compound(const List<Buffer> &packets);
208
218 struct Header {
219 uint8_t version = 0;
220 bool padding = false;
221 uint8_t rc = 0;
222 uint8_t pt = 0;
223 size_t lengthBytes = 0;
224
227 bool isValid() const { return version == 2 && lengthBytes >= 4; }
228 };
229
243 static Header parseHeader(const uint8_t *data, size_t size);
244
256 struct SenderReportInfo {
257 uint32_t ssrc = 0;
258 NtpTime ntp;
259 uint32_t rtpTimestamp = 0;
260 uint32_t senderPacketCount = 0;
261 uint32_t senderOctetCount = 0;
262 };
263
282 static bool parseSenderReport(const uint8_t *data, size_t size, SenderReportInfo *out);
283
307 static List<SenderReportInfo> findSenderReports(const uint8_t *data, size_t size);
308
325 static List<uint32_t> findByeSources(const uint8_t *data, size_t size);
326};
327
328PROMEKI_NAMESPACE_END
329
330#endif // PROMEKI_ENABLE_NETWORK