mediasoup 3.13.4 → 3.13.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/worker/include/RTC/RTCP/CompoundPacket.hpp +13 -4
- package/worker/include/RTC/RTCP/Sdes.hpp +1 -1
- package/worker/include/RTC/RTCP/XrDelaySinceLastRr.hpp +13 -0
- package/worker/include/RTC/RtpStreamSend.hpp +1 -1
- package/worker/src/RTC/PipeConsumer.cpp +5 -8
- package/worker/src/RTC/RTCP/CompoundPacket.cpp +28 -26
- package/worker/src/RTC/RtpStreamSend.cpp +1 -1
- package/worker/src/RTC/SimpleConsumer.cpp +2 -10
- package/worker/src/RTC/SimulcastConsumer.cpp +2 -10
- package/worker/src/RTC/SvcConsumer.cpp +2 -10
- package/worker/test/src/RTC/Codecs/TestVP8.cpp +1 -1
- package/worker/test/src/RTC/RTCP/TestSdes.cpp +88 -8
- package/worker/test/src/RTC/RTCP/TestXr.cpp +37 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mediasoup",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.5",
|
|
4
4
|
"description": "Cutting Edge WebRTC Video Conferencing",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
|
|
@@ -105,8 +105,8 @@
|
|
|
105
105
|
"devDependencies": {
|
|
106
106
|
"@octokit/rest": "^20.0.2",
|
|
107
107
|
"@types/debug": "^4.1.12",
|
|
108
|
-
"@types/jest": "^29.5.
|
|
109
|
-
"@types/node": "^20.9.
|
|
108
|
+
"@types/jest": "^29.5.10",
|
|
109
|
+
"@types/node": "^20.9.4",
|
|
110
110
|
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
111
111
|
"@typescript-eslint/parser": "^6.12.0",
|
|
112
112
|
"eslint": "^8.54.0",
|
|
@@ -48,14 +48,16 @@ namespace RTC
|
|
|
48
48
|
// Adds the given data and returns true if there is enough space to hold it,
|
|
49
49
|
// false otherwise.
|
|
50
50
|
bool Add(
|
|
51
|
-
SenderReport* senderReport,
|
|
51
|
+
SenderReport* senderReport,
|
|
52
|
+
SdesChunk* sdesChunk,
|
|
53
|
+
DelaySinceLastRr::SsrcInfo* delaySinceLastRrSsrcInfo);
|
|
52
54
|
// RTCP additions per Consumer (pipe).
|
|
53
55
|
// Adds the given data and returns true if there is enough space to hold it,
|
|
54
56
|
// false otherwise.
|
|
55
57
|
bool Add(
|
|
56
58
|
std::vector<SenderReport*>& senderReports,
|
|
57
59
|
std::vector<SdesChunk*>& sdesChunks,
|
|
58
|
-
std::vector<DelaySinceLastRr*>&
|
|
60
|
+
std::vector<DelaySinceLastRr::SsrcInfo*>& delaySinceLastRrSsrcInfos);
|
|
59
61
|
// RTCP additions per Producer.
|
|
60
62
|
// Adds the given data and returns true if there is enough space to hold it,
|
|
61
63
|
// false otherwise.
|
|
@@ -63,8 +65,6 @@ namespace RTC
|
|
|
63
65
|
void AddSenderReport(SenderReport* report);
|
|
64
66
|
void AddReceiverReport(ReceiverReport* report);
|
|
65
67
|
void AddSdesChunk(SdesChunk* chunk);
|
|
66
|
-
void AddReceiverReferenceTime(ReceiverReferenceTime* report);
|
|
67
|
-
void AddDelaySinceLastRr(DelaySinceLastRr* report);
|
|
68
68
|
bool HasSenderReport()
|
|
69
69
|
{
|
|
70
70
|
return this->senderReportPacket.Begin() != this->senderReportPacket.End();
|
|
@@ -77,6 +77,14 @@ namespace RTC
|
|
|
77
77
|
[](const ExtendedReportBlock* report)
|
|
78
78
|
{ return report->GetType() == ExtendedReportBlock::Type::RRT; });
|
|
79
79
|
}
|
|
80
|
+
bool HasDelaySinceLastRr()
|
|
81
|
+
{
|
|
82
|
+
return std::any_of(
|
|
83
|
+
this->xrPacket.Begin(),
|
|
84
|
+
this->xrPacket.End(),
|
|
85
|
+
[](const ExtendedReportBlock* report)
|
|
86
|
+
{ return report->GetType() == ExtendedReportBlock::Type::DLRR; });
|
|
87
|
+
}
|
|
80
88
|
void Serialize(uint8_t* data);
|
|
81
89
|
|
|
82
90
|
private:
|
|
@@ -85,6 +93,7 @@ namespace RTC
|
|
|
85
93
|
ReceiverReportPacket receiverReportPacket;
|
|
86
94
|
SdesPacket sdesPacket;
|
|
87
95
|
ExtendedReportPacket xrPacket;
|
|
96
|
+
DelaySinceLastRr* delaySinceLastRr{ nullptr };
|
|
88
97
|
};
|
|
89
98
|
} // namespace RTCP
|
|
90
99
|
} // namespace RTC
|
|
@@ -214,7 +214,7 @@ namespace RTC
|
|
|
214
214
|
// A serialized packet can contain a maximum of 31 chunks.
|
|
215
215
|
// If number of chunks exceeds 31 then the required number of packets
|
|
216
216
|
// will be serialized which will take the size calculated below.
|
|
217
|
-
size_t size = Packet::CommonHeaderSize * ((this->GetCount() / MaxChunksPerPacket) + 1);
|
|
217
|
+
size_t size = Packet::CommonHeaderSize * ((this->GetCount() / (MaxChunksPerPacket + 1)) + 1);
|
|
218
218
|
|
|
219
219
|
for (auto* chunk : this->chunks)
|
|
220
220
|
{
|
|
@@ -119,6 +119,19 @@ namespace RTC
|
|
|
119
119
|
{
|
|
120
120
|
this->ssrcInfos.push_back(ssrcInfo);
|
|
121
121
|
}
|
|
122
|
+
// NOTE: This method not only removes given number of ssrc info sub-blocks
|
|
123
|
+
// but also deletes their SsrcInfo instances.
|
|
124
|
+
void RemoveLastSsrcInfos(size_t number)
|
|
125
|
+
{
|
|
126
|
+
while (!this->ssrcInfos.empty() && number-- > 0)
|
|
127
|
+
{
|
|
128
|
+
auto* ssrcInfo = this->ssrcInfos.back();
|
|
129
|
+
|
|
130
|
+
this->ssrcInfos.pop_back();
|
|
131
|
+
|
|
132
|
+
delete ssrcInfo;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
122
135
|
Iterator Begin()
|
|
123
136
|
{
|
|
124
137
|
return this->ssrcInfos.begin();
|
|
@@ -37,7 +37,7 @@ namespace RTC
|
|
|
37
37
|
void ReceiveRtcpReceiverReport(RTC::RTCP::ReceiverReport* report);
|
|
38
38
|
void ReceiveRtcpXrReceiverReferenceTime(RTC::RTCP::ReceiverReferenceTime* report);
|
|
39
39
|
RTC::RTCP::SenderReport* GetRtcpSenderReport(uint64_t nowMs);
|
|
40
|
-
RTC::RTCP::DelaySinceLastRr::SsrcInfo*
|
|
40
|
+
RTC::RTCP::DelaySinceLastRr::SsrcInfo* GetRtcpXrDelaySinceLastRrSsrcInfo(uint64_t nowMs);
|
|
41
41
|
RTC::RTCP::SdesChunk* GetRtcpSdesChunk();
|
|
42
42
|
void Pause() override;
|
|
43
43
|
void Resume() override;
|
|
@@ -345,7 +345,7 @@ namespace RTC
|
|
|
345
345
|
|
|
346
346
|
std::vector<RTCP::SenderReport*> senderReports;
|
|
347
347
|
std::vector<RTCP::SdesChunk*> sdesChunks;
|
|
348
|
-
std::vector<RTCP::DelaySinceLastRr*>
|
|
348
|
+
std::vector<RTCP::DelaySinceLastRr::SsrcInfo*> delaySinceLastRrSsrcInfos;
|
|
349
349
|
|
|
350
350
|
for (auto* rtpStream : this->rtpStreams)
|
|
351
351
|
{
|
|
@@ -362,19 +362,16 @@ namespace RTC
|
|
|
362
362
|
auto* sdesChunk = rtpStream->GetRtcpSdesChunk();
|
|
363
363
|
sdesChunks.push_back(sdesChunk);
|
|
364
364
|
|
|
365
|
-
auto*
|
|
365
|
+
auto* delaySinceLastRrSsrcInfo = rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowMs);
|
|
366
366
|
|
|
367
|
-
if (
|
|
367
|
+
if (delaySinceLastRrSsrcInfo)
|
|
368
368
|
{
|
|
369
|
-
|
|
370
|
-
report->AddSsrcInfo(dlrr);
|
|
371
|
-
|
|
372
|
-
xrReports.push_back(report);
|
|
369
|
+
delaySinceLastRrSsrcInfos.push_back(delaySinceLastRrSsrcInfo);
|
|
373
370
|
}
|
|
374
371
|
}
|
|
375
372
|
|
|
376
373
|
// RTCP Compound packet buffer cannot hold the data.
|
|
377
|
-
if (!packet->Add(senderReports, sdesChunks,
|
|
374
|
+
if (!packet->Add(senderReports, sdesChunks, delaySinceLastRrSsrcInfos))
|
|
378
375
|
{
|
|
379
376
|
return false;
|
|
380
377
|
}
|
|
@@ -72,7 +72,9 @@ namespace RTC
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
bool CompoundPacket::Add(
|
|
75
|
-
SenderReport* senderReport,
|
|
75
|
+
SenderReport* senderReport,
|
|
76
|
+
SdesChunk* sdesChunk,
|
|
77
|
+
DelaySinceLastRr::SsrcInfo* delaySinceLastRrSsrcInfo)
|
|
76
78
|
{
|
|
77
79
|
// Add the items into the packet.
|
|
78
80
|
|
|
@@ -86,9 +88,16 @@ namespace RTC
|
|
|
86
88
|
this->sdesPacket.AddChunk(sdesChunk);
|
|
87
89
|
}
|
|
88
90
|
|
|
89
|
-
if (
|
|
91
|
+
if (delaySinceLastRrSsrcInfo)
|
|
90
92
|
{
|
|
91
|
-
|
|
93
|
+
// Add a DLRR block into the XR packet if no present.
|
|
94
|
+
if (!this->delaySinceLastRr)
|
|
95
|
+
{
|
|
96
|
+
this->delaySinceLastRr = new RTC::RTCP::DelaySinceLastRr();
|
|
97
|
+
this->xrPacket.AddReport(this->delaySinceLastRr);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
this->delaySinceLastRr->AddSsrcInfo(delaySinceLastRrSsrcInfo);
|
|
92
101
|
}
|
|
93
102
|
|
|
94
103
|
// New items can hold in the packet, report it.
|
|
@@ -112,10 +121,10 @@ namespace RTC
|
|
|
112
121
|
delete sdesChunk;
|
|
113
122
|
}
|
|
114
123
|
|
|
115
|
-
if (
|
|
124
|
+
if (delaySinceLastRrSsrcInfo)
|
|
116
125
|
{
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
// NOTE: This method deletes the removed instances in place.
|
|
127
|
+
this->delaySinceLastRr->RemoveLastSsrcInfos(1);
|
|
119
128
|
}
|
|
120
129
|
|
|
121
130
|
return false;
|
|
@@ -124,7 +133,7 @@ namespace RTC
|
|
|
124
133
|
bool CompoundPacket::Add(
|
|
125
134
|
std::vector<SenderReport*>& senderReports,
|
|
126
135
|
std::vector<SdesChunk*>& sdesChunks,
|
|
127
|
-
std::vector<DelaySinceLastRr*>&
|
|
136
|
+
std::vector<DelaySinceLastRr::SsrcInfo*>& delaySinceLastRrSsrcInfos)
|
|
128
137
|
{
|
|
129
138
|
// Add the items into the packet.
|
|
130
139
|
|
|
@@ -138,9 +147,16 @@ namespace RTC
|
|
|
138
147
|
this->sdesPacket.AddChunk(chunk);
|
|
139
148
|
}
|
|
140
149
|
|
|
141
|
-
|
|
150
|
+
// Add a DLRR block into the XR packet if no present.
|
|
151
|
+
if (!delaySinceLastRrSsrcInfos.empty() && !this->delaySinceLastRr)
|
|
142
152
|
{
|
|
143
|
-
this->
|
|
153
|
+
this->delaySinceLastRr = new RTC::RTCP::DelaySinceLastRr();
|
|
154
|
+
this->xrPacket.AddReport(this->delaySinceLastRr);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
for (auto* ssrcInfo : delaySinceLastRrSsrcInfos)
|
|
158
|
+
{
|
|
159
|
+
this->delaySinceLastRr->AddSsrcInfo(ssrcInfo);
|
|
144
160
|
}
|
|
145
161
|
|
|
146
162
|
// New items can hold in the packet, report it.
|
|
@@ -164,10 +180,10 @@ namespace RTC
|
|
|
164
180
|
delete chunk;
|
|
165
181
|
}
|
|
166
182
|
|
|
167
|
-
|
|
183
|
+
if (!delaySinceLastRrSsrcInfos.empty())
|
|
168
184
|
{
|
|
169
|
-
|
|
170
|
-
|
|
185
|
+
// NOTE: This method deletes the instances in place.
|
|
186
|
+
this->delaySinceLastRr->RemoveLastSsrcInfos(delaySinceLastRrSsrcInfos.size());
|
|
171
187
|
}
|
|
172
188
|
|
|
173
189
|
return false;
|
|
@@ -266,19 +282,5 @@ namespace RTC
|
|
|
266
282
|
|
|
267
283
|
this->sdesPacket.AddChunk(chunk);
|
|
268
284
|
}
|
|
269
|
-
|
|
270
|
-
void CompoundPacket::AddReceiverReferenceTime(ReceiverReferenceTime* report)
|
|
271
|
-
{
|
|
272
|
-
MS_TRACE();
|
|
273
|
-
|
|
274
|
-
this->xrPacket.AddReport(report);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
void CompoundPacket::AddDelaySinceLastRr(DelaySinceLastRr* report)
|
|
278
|
-
{
|
|
279
|
-
MS_TRACE();
|
|
280
|
-
|
|
281
|
-
this->xrPacket.AddReport(report);
|
|
282
|
-
}
|
|
283
285
|
} // namespace RTCP
|
|
284
286
|
} // namespace RTC
|
|
@@ -274,7 +274,7 @@ namespace RTC
|
|
|
274
274
|
return report;
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
RTC::RTCP::DelaySinceLastRr::SsrcInfo* RtpStreamSend::
|
|
277
|
+
RTC::RTCP::DelaySinceLastRr::SsrcInfo* RtpStreamSend::GetRtcpXrDelaySinceLastRrSsrcInfo(uint64_t nowMs)
|
|
278
278
|
{
|
|
279
279
|
MS_TRACE();
|
|
280
280
|
|
|
@@ -439,18 +439,10 @@ namespace RTC
|
|
|
439
439
|
// Build SDES chunk for this sender.
|
|
440
440
|
auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk();
|
|
441
441
|
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
auto* dlrr = this->rtpStream->GetRtcpXrDelaySinceLastRr(nowMs);
|
|
445
|
-
|
|
446
|
-
if (dlrr)
|
|
447
|
-
{
|
|
448
|
-
delaySinceLastRrReport = new RTC::RTCP::DelaySinceLastRr();
|
|
449
|
-
delaySinceLastRrReport->AddSsrcInfo(dlrr);
|
|
450
|
-
}
|
|
442
|
+
auto* delaySinceLastRrSsrcInfo = this->rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowMs);
|
|
451
443
|
|
|
452
444
|
// RTCP Compound packet buffer cannot hold the data.
|
|
453
|
-
if (!packet->Add(senderReport, sdesChunk,
|
|
445
|
+
if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrSsrcInfo))
|
|
454
446
|
{
|
|
455
447
|
return false;
|
|
456
448
|
}
|
|
@@ -1081,18 +1081,10 @@ namespace RTC
|
|
|
1081
1081
|
// Build SDES chunk for this sender.
|
|
1082
1082
|
auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk();
|
|
1083
1083
|
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
auto* dlrr = this->rtpStream->GetRtcpXrDelaySinceLastRr(nowMs);
|
|
1087
|
-
|
|
1088
|
-
if (dlrr)
|
|
1089
|
-
{
|
|
1090
|
-
delaySinceLastRrReport = new RTC::RTCP::DelaySinceLastRr();
|
|
1091
|
-
delaySinceLastRrReport->AddSsrcInfo(dlrr);
|
|
1092
|
-
}
|
|
1084
|
+
auto* delaySinceLastRrSsrcInfo = this->rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowMs);
|
|
1093
1085
|
|
|
1094
1086
|
// RTCP Compound packet buffer cannot hold the data.
|
|
1095
|
-
if (!packet->Add(senderReport, sdesChunk,
|
|
1087
|
+
if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrSsrcInfo))
|
|
1096
1088
|
{
|
|
1097
1089
|
return false;
|
|
1098
1090
|
}
|
|
@@ -795,18 +795,10 @@ namespace RTC
|
|
|
795
795
|
// Build SDES chunk for this sender.
|
|
796
796
|
auto* sdesChunk = this->rtpStream->GetRtcpSdesChunk();
|
|
797
797
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
auto* dlrr = this->rtpStream->GetRtcpXrDelaySinceLastRr(nowMs);
|
|
801
|
-
|
|
802
|
-
if (dlrr)
|
|
803
|
-
{
|
|
804
|
-
delaySinceLastRrReport = new RTC::RTCP::DelaySinceLastRr();
|
|
805
|
-
delaySinceLastRrReport->AddSsrcInfo(dlrr);
|
|
806
|
-
}
|
|
798
|
+
auto* delaySinceLastRrSsrcInfo = this->rtpStream->GetRtcpXrDelaySinceLastRrSsrcInfo(nowMs);
|
|
807
799
|
|
|
808
800
|
// RTCP Compound packet buffer cannot hold the data.
|
|
809
|
-
if (!packet->Add(senderReport, sdesChunk,
|
|
801
|
+
if (!packet->Add(senderReport, sdesChunk, delaySinceLastRrSsrcInfo))
|
|
810
802
|
{
|
|
811
803
|
return false;
|
|
812
804
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#include "common.hpp"
|
|
2
|
+
#include "RTC/RTCP/Packet.hpp"
|
|
2
3
|
#include "RTC/RTCP/Sdes.hpp"
|
|
3
4
|
#include <catch2/catch.hpp>
|
|
4
5
|
#include <cstring> // std::memcmp()
|
|
@@ -383,40 +384,118 @@ SCENARIO("RTCP SDES parsing", "[parser][rtcp][sdes]")
|
|
|
383
384
|
REQUIRE(!packet);
|
|
384
385
|
}
|
|
385
386
|
|
|
387
|
+
SECTION("create SDES packet with 31 chunks")
|
|
388
|
+
{
|
|
389
|
+
const size_t count = 31;
|
|
390
|
+
|
|
391
|
+
SdesPacket packet;
|
|
392
|
+
// Create a chunk and an item to obtain their size.
|
|
393
|
+
SdesChunk* chunk = new SdesChunk(1234 /*ssrc*/);
|
|
394
|
+
auto* item1 =
|
|
395
|
+
new RTC::RTCP::SdesItem(SdesItem::Type::CNAME, item1Value.size(), item1Value.c_str());
|
|
396
|
+
|
|
397
|
+
chunk->AddItem(item1);
|
|
398
|
+
|
|
399
|
+
auto chunkSize = chunk->GetSize();
|
|
400
|
+
|
|
401
|
+
delete chunk;
|
|
402
|
+
|
|
403
|
+
for (auto i{ 1 }; i <= count; ++i)
|
|
404
|
+
{
|
|
405
|
+
// Create chunk and add to packet.
|
|
406
|
+
SdesChunk* chunk = new SdesChunk(i /*ssrc*/);
|
|
407
|
+
|
|
408
|
+
auto* item1 =
|
|
409
|
+
new RTC::RTCP::SdesItem(SdesItem::Type::CNAME, item1Value.size(), item1Value.c_str());
|
|
410
|
+
|
|
411
|
+
chunk->AddItem(item1);
|
|
412
|
+
|
|
413
|
+
packet.AddChunk(chunk);
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
REQUIRE(packet.GetCount() == count);
|
|
417
|
+
REQUIRE(packet.GetSize() == Packet::CommonHeaderSize + (count * chunkSize));
|
|
418
|
+
|
|
419
|
+
uint8_t buffer1[1500] = { 0 };
|
|
420
|
+
|
|
421
|
+
// Serialization must contain 1 SDES packet since report count doesn't
|
|
422
|
+
// exceed 31.
|
|
423
|
+
packet.Serialize(buffer1);
|
|
424
|
+
|
|
425
|
+
auto* packet2 = static_cast<SdesPacket*>(Packet::Parse(buffer1, sizeof(buffer1)));
|
|
426
|
+
|
|
427
|
+
REQUIRE(packet2 != nullptr);
|
|
428
|
+
REQUIRE(packet2->GetCount() == count);
|
|
429
|
+
REQUIRE(packet2->GetSize() == Packet::CommonHeaderSize + (count * chunkSize));
|
|
430
|
+
|
|
431
|
+
auto reportIt = packet2->Begin();
|
|
432
|
+
|
|
433
|
+
for (auto i{ 1 }; i <= 31; ++i, reportIt++)
|
|
434
|
+
{
|
|
435
|
+
auto* chunk = *reportIt;
|
|
436
|
+
|
|
437
|
+
REQUIRE(chunk->GetSsrc() == i);
|
|
438
|
+
|
|
439
|
+
auto* item = *(chunk->Begin());
|
|
440
|
+
|
|
441
|
+
REQUIRE(item->GetType() == SdesItem::Type::CNAME);
|
|
442
|
+
REQUIRE(item->GetSize() == 2 + item1Value.size());
|
|
443
|
+
REQUIRE(std::string(item->GetValue()) == item1Value);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
SdesPacket* packet3 = static_cast<SdesPacket*>(packet2->GetNext());
|
|
447
|
+
|
|
448
|
+
REQUIRE(packet3 == nullptr);
|
|
449
|
+
|
|
450
|
+
delete packet3;
|
|
451
|
+
}
|
|
452
|
+
|
|
386
453
|
SECTION("create SDES packet with more than 31 chunks")
|
|
387
454
|
{
|
|
388
455
|
const size_t count = 33;
|
|
389
456
|
|
|
390
457
|
SdesPacket packet;
|
|
458
|
+
// Create a chunk and an item to obtain their size.
|
|
459
|
+
SdesChunk* chunk = new SdesChunk(1234 /*ssrc*/);
|
|
460
|
+
auto* item1 =
|
|
461
|
+
new RTC::RTCP::SdesItem(SdesItem::Type::CNAME, item1Value.size(), item1Value.c_str());
|
|
462
|
+
|
|
463
|
+
chunk->AddItem(item1);
|
|
464
|
+
|
|
465
|
+
auto chunkSize = chunk->GetSize();
|
|
466
|
+
|
|
467
|
+
delete chunk;
|
|
391
468
|
|
|
392
|
-
for (auto i
|
|
469
|
+
for (auto i{ 1 }; i <= count; ++i)
|
|
393
470
|
{
|
|
394
471
|
// Create chunk and add to packet.
|
|
395
|
-
SdesChunk*
|
|
472
|
+
SdesChunk* chunk = new SdesChunk(i /*ssrc*/);
|
|
396
473
|
|
|
397
474
|
auto* item1 =
|
|
398
475
|
new RTC::RTCP::SdesItem(SdesItem::Type::CNAME, item1Value.size(), item1Value.c_str());
|
|
399
476
|
|
|
400
|
-
|
|
477
|
+
chunk->AddItem(item1);
|
|
401
478
|
|
|
402
|
-
packet.AddChunk(
|
|
479
|
+
packet.AddChunk(chunk);
|
|
403
480
|
}
|
|
404
481
|
|
|
405
482
|
REQUIRE(packet.GetCount() == count);
|
|
483
|
+
REQUIRE(packet.GetSize() == Packet::CommonHeaderSize + (31 * chunkSize) + Packet::CommonHeaderSize + ((count - 31) * chunkSize));
|
|
406
484
|
|
|
407
485
|
uint8_t buffer1[1500] = { 0 };
|
|
408
486
|
|
|
409
|
-
// Serialization must contain 2
|
|
487
|
+
// Serialization must contain 2 SDES packets since report count exceeds 31.
|
|
410
488
|
packet.Serialize(buffer1);
|
|
411
489
|
|
|
412
490
|
auto* packet2 = static_cast<SdesPacket*>(Packet::Parse(buffer1, sizeof(buffer1)));
|
|
413
491
|
|
|
414
492
|
REQUIRE(packet2 != nullptr);
|
|
415
493
|
REQUIRE(packet2->GetCount() == 31);
|
|
494
|
+
REQUIRE(packet2->GetSize() == Packet::CommonHeaderSize + (31 * chunkSize));
|
|
416
495
|
|
|
417
496
|
auto reportIt = packet2->Begin();
|
|
418
497
|
|
|
419
|
-
for (auto i
|
|
498
|
+
for (auto i{ 1 }; i <= 31; ++i, reportIt++)
|
|
420
499
|
{
|
|
421
500
|
auto* chunk = *reportIt;
|
|
422
501
|
|
|
@@ -432,11 +511,12 @@ SCENARIO("RTCP SDES parsing", "[parser][rtcp][sdes]")
|
|
|
432
511
|
SdesPacket* packet3 = static_cast<SdesPacket*>(packet2->GetNext());
|
|
433
512
|
|
|
434
513
|
REQUIRE(packet3 != nullptr);
|
|
435
|
-
REQUIRE(packet3->GetCount() ==
|
|
514
|
+
REQUIRE(packet3->GetCount() == count - 31);
|
|
515
|
+
REQUIRE(packet3->GetSize() == Packet::CommonHeaderSize + ((count - 31) * chunkSize));
|
|
436
516
|
|
|
437
517
|
reportIt = packet3->Begin();
|
|
438
518
|
|
|
439
|
-
for (auto i
|
|
519
|
+
for (auto i{ 1 }; i <= 2; ++i, reportIt++)
|
|
440
520
|
{
|
|
441
521
|
auto* chunk = *reportIt;
|
|
442
522
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
#include "RTC/RTCP/XrDelaySinceLastRr.hpp"
|
|
4
4
|
#include "RTC/RTCP/XrReceiverReferenceTime.hpp"
|
|
5
5
|
#include <catch2/catch.hpp>
|
|
6
|
-
#include <cstring> // std::memcmp
|
|
6
|
+
#include <cstring> // std::memcmp(), std::memcpy()
|
|
7
7
|
|
|
8
8
|
using namespace RTC::RTCP;
|
|
9
9
|
|
|
@@ -12,7 +12,7 @@ SCENARIO("RTCP XR parsing", "[parser][rtcp][xr]")
|
|
|
12
12
|
// clang-format off
|
|
13
13
|
uint8_t buffer[] =
|
|
14
14
|
{
|
|
15
|
-
0xa0, 0xcf, 0x00,
|
|
15
|
+
0xa0, 0xcf, 0x00, 0x09, // Padding, Type: 207 (XR), Length: 9
|
|
16
16
|
0x5d, 0x93, 0x15, 0x34, // Sender SSRC: 0x5d931534
|
|
17
17
|
// Extended Report DLRR
|
|
18
18
|
0x05, 0x00, 0x00, 0x06, // BT: 5 (DLRR), Block Length: 6
|
|
@@ -33,6 +33,7 @@ SCENARIO("RTCP XR parsing", "[parser][rtcp][xr]")
|
|
|
33
33
|
REQUIRE(packet);
|
|
34
34
|
// Despite total buffer size is 40 bytes, our GetSize() method doesn't not
|
|
35
35
|
// consider RTCP padding (4 bytes in this case).
|
|
36
|
+
// https://github.com/versatica/mediasoup/issues/1233
|
|
36
37
|
REQUIRE(packet->GetSize() == 36);
|
|
37
38
|
REQUIRE(packet->GetCount() == 0);
|
|
38
39
|
REQUIRE(packet->GetSsrc() == 0x5d931534);
|
|
@@ -89,6 +90,40 @@ SCENARIO("RTCP XR parsing", "[parser][rtcp][xr]")
|
|
|
89
90
|
// There are 1 block (the DLRR block).
|
|
90
91
|
REQUIRE(blockIdx == 1);
|
|
91
92
|
|
|
93
|
+
SECTION("serialize packet instance")
|
|
94
|
+
{
|
|
95
|
+
// NOTE: Padding in RTCP is removed (if not needed) when serializing the
|
|
96
|
+
// packet, so we must mangle the buffer content (padding bit) and the
|
|
97
|
+
// buffer length before comparing the serialized packet with and original
|
|
98
|
+
// buffer.
|
|
99
|
+
|
|
100
|
+
const size_t paddingBytes{ 4 };
|
|
101
|
+
const size_t serializedBufferLength = sizeof(buffer) - paddingBytes;
|
|
102
|
+
uint8_t serialized[serializedBufferLength] = { 0 };
|
|
103
|
+
|
|
104
|
+
// Clone the original buffer into a new buffer without padding.
|
|
105
|
+
uint8_t clonedBuffer[serializedBufferLength] = { 0 };
|
|
106
|
+
std::memcpy(clonedBuffer, buffer, serializedBufferLength);
|
|
107
|
+
|
|
108
|
+
// Remove the padding bit in the first byte of the cloned buffer.
|
|
109
|
+
clonedBuffer[0] = 0x80;
|
|
110
|
+
|
|
111
|
+
// Change RTCP length field in the cloned buffer.
|
|
112
|
+
clonedBuffer[3] = clonedBuffer[3] - 1;
|
|
113
|
+
|
|
114
|
+
packet->Serialize(serialized);
|
|
115
|
+
|
|
116
|
+
auto* packet2 = ExtendedReportPacket::Parse(serialized, serializedBufferLength);
|
|
117
|
+
|
|
118
|
+
REQUIRE(packet2->GetType() == Type::XR);
|
|
119
|
+
REQUIRE(packet2->GetCount() == 0);
|
|
120
|
+
REQUIRE(packet2->GetSize() == 36);
|
|
121
|
+
|
|
122
|
+
REQUIRE(std::memcmp(clonedBuffer, serialized, serializedBufferLength) == 0);
|
|
123
|
+
|
|
124
|
+
delete packet2;
|
|
125
|
+
}
|
|
126
|
+
|
|
92
127
|
delete packet;
|
|
93
128
|
}
|
|
94
129
|
}
|