mediasoup 3.9.13 → 3.9.16
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/node/lib/ActiveSpeakerObserver.d.ts +1 -1
- package/node/lib/ActiveSpeakerObserver.d.ts.map +1 -1
- package/node/lib/AudioLevelObserver.d.ts +1 -1
- package/node/lib/AudioLevelObserver.d.ts.map +1 -1
- package/node/lib/Consumer.d.ts +4 -4
- package/node/lib/Consumer.d.ts.map +1 -1
- package/node/lib/Consumer.js +1 -1
- package/node/lib/DataConsumer.d.ts +4 -4
- package/node/lib/DataConsumer.d.ts.map +1 -1
- package/node/lib/DataConsumer.js +1 -1
- package/node/lib/DataProducer.d.ts +4 -4
- package/node/lib/DataProducer.d.ts.map +1 -1
- package/node/lib/DataProducer.js +1 -1
- package/node/lib/DirectTransport.d.ts +1 -1
- package/node/lib/DirectTransport.d.ts.map +1 -1
- package/node/lib/PipeTransport.d.ts +2 -2
- package/node/lib/PipeTransport.d.ts.map +1 -1
- package/node/lib/PipeTransport.js +1 -1
- package/node/lib/PlainTransport.d.ts +1 -1
- package/node/lib/PlainTransport.d.ts.map +1 -1
- package/node/lib/Producer.d.ts +4 -4
- package/node/lib/Producer.d.ts.map +1 -1
- package/node/lib/Producer.js +1 -1
- package/node/lib/Router.d.ts +4 -4
- package/node/lib/Router.d.ts.map +1 -1
- package/node/lib/Router.js +7 -7
- package/node/lib/RtpObserver.d.ts +3 -3
- package/node/lib/RtpObserver.d.ts.map +1 -1
- package/node/lib/RtpObserver.js +1 -1
- package/node/lib/Transport.d.ts +3 -3
- package/node/lib/Transport.d.ts.map +1 -1
- package/node/lib/Transport.js +5 -5
- package/node/lib/WebRtcTransport.d.ts +1 -1
- package/node/lib/WebRtcTransport.d.ts.map +1 -1
- package/node/lib/Worker.d.ts +3 -3
- package/node/lib/Worker.d.ts.map +1 -1
- package/node/lib/Worker.js +3 -3
- package/node/lib/index.d.ts +1 -1
- package/node/lib/index.d.ts.map +1 -1
- package/node/lib/index.js +2 -2
- package/node/lib/ortc.js +1 -0
- package/node/lib/supportedRtpCapabilities.d.ts.map +1 -1
- package/node/lib/supportedRtpCapabilities.js +15 -0
- package/package.json +6 -6
- package/worker/include/RTC/Codecs/H264_SVC.hpp +115 -0
- package/worker/include/RTC/Codecs/Tools.hpp +11 -0
- package/worker/include/RTC/Consumer.hpp +5 -4
- package/worker/include/RTC/DirectTransport.hpp +4 -0
- package/worker/include/RTC/NackGenerator.hpp +5 -2
- package/worker/include/RTC/PipeConsumer.hpp +1 -0
- package/worker/include/RTC/RTCP/CompoundPacket.hpp +2 -0
- package/worker/include/RTC/RtpDictionaries.hpp +1 -0
- package/worker/include/RTC/RtpStream.hpp +2 -0
- package/worker/include/RTC/RtpStreamRecv.hpp +7 -1
- package/worker/include/RTC/RtpStreamSend.hpp +7 -0
- package/worker/include/RTC/SimpleConsumer.hpp +1 -0
- package/worker/include/RTC/SimulcastConsumer.hpp +4 -0
- package/worker/include/RTC/SvcConsumer.hpp +1 -0
- package/worker/meson.build +4 -0
- package/worker/src/RTC/Codecs/H264_SVC.cpp +428 -0
- package/worker/src/RTC/DirectTransport.cpp +10 -1
- package/worker/src/RTC/NackGenerator.cpp +27 -9
- package/worker/src/RTC/PipeConsumer.cpp +20 -0
- package/worker/src/RTC/Producer.cpp +5 -1
- package/worker/src/RTC/RTCP/CompoundPacket.cpp +7 -0
- package/worker/src/RTC/RtpDictionaries/RtpCodecMimeType.cpp +2 -0
- package/worker/src/RTC/RtpStreamRecv.cpp +4 -3
- package/worker/src/RTC/RtpStreamSend.cpp +32 -0
- package/worker/src/RTC/SimpleConsumer.cpp +17 -0
- package/worker/src/RTC/SimulcastConsumer.cpp +45 -4
- package/worker/src/RTC/SvcConsumer.cpp +17 -0
- package/worker/src/RTC/Transport.cpp +14 -0
- package/worker/src/RTC/TransportCongestionControlClient.cpp +0 -3
- package/worker/test/include/helpers.hpp +119 -0
- package/worker/test/src/RTC/Codecs/TestH264.cpp +30 -0
- package/worker/test/src/RTC/Codecs/TestH264_SVC.cpp +181 -0
- package/worker/test/src/RTC/TestNackGenerator.cpp +3 -1
- package/worker/test/src/RTC/TestRtpPacketH264Svc.cpp +455 -0
- package/worker/test/src/RTC/TestRtpStreamRecv.cpp +4 -3
|
@@ -0,0 +1,455 @@
|
|
|
1
|
+
#include "common.hpp"
|
|
2
|
+
#include "helpers.hpp"
|
|
3
|
+
#include "RTC/Codecs/H264_SVC.hpp"
|
|
4
|
+
#include "RTC/RtpPacket.hpp"
|
|
5
|
+
#include <catch2/catch.hpp>
|
|
6
|
+
#include <cstring> // std::memset()
|
|
7
|
+
#include <string>
|
|
8
|
+
#include <vector>
|
|
9
|
+
|
|
10
|
+
using namespace RTC;
|
|
11
|
+
|
|
12
|
+
static uint8_t buffer[65536];
|
|
13
|
+
static uint8_t buffer2[65536];
|
|
14
|
+
|
|
15
|
+
SCENARIO("parse RTP packets with H264 SVC", "[parser][rtp]")
|
|
16
|
+
{
|
|
17
|
+
SECTION("parse I0-7.bin")
|
|
18
|
+
{
|
|
19
|
+
size_t len;
|
|
20
|
+
uint8_t extenLen;
|
|
21
|
+
uint8_t* extenValue;
|
|
22
|
+
|
|
23
|
+
if (!helpers::readBinaryFile("data/H264_SVC/I0-7.bin", buffer, &len))
|
|
24
|
+
FAIL("cannot open file");
|
|
25
|
+
|
|
26
|
+
RtpPacket* packet = RtpPacket::Parse(buffer, len);
|
|
27
|
+
|
|
28
|
+
if (!packet)
|
|
29
|
+
FAIL("not a RTP packet");
|
|
30
|
+
|
|
31
|
+
REQUIRE(packet->HasMarker() == false);
|
|
32
|
+
REQUIRE(packet->HasHeaderExtension() == true);
|
|
33
|
+
REQUIRE(packet->GetPayloadType() == 111);
|
|
34
|
+
REQUIRE(packet->GetSequenceNumber() == 23617);
|
|
35
|
+
REQUIRE(packet->GetTimestamp() == 1660241882);
|
|
36
|
+
REQUIRE(packet->GetSsrc() == 2674985186);
|
|
37
|
+
REQUIRE(packet->GetHeaderExtensionId() == 0xBEDE);
|
|
38
|
+
REQUIRE(packet->GetHeaderExtensionLength() == 4);
|
|
39
|
+
REQUIRE(packet->HasOneByteExtensions());
|
|
40
|
+
REQUIRE(packet->HasTwoBytesExtensions() == false);
|
|
41
|
+
|
|
42
|
+
packet->SetFrameMarkingExtensionId(1);
|
|
43
|
+
extenValue = packet->GetExtension(1, extenLen);
|
|
44
|
+
|
|
45
|
+
REQUIRE(packet->HasExtension(1) == true);
|
|
46
|
+
REQUIRE(extenLen == 1);
|
|
47
|
+
REQUIRE(extenValue);
|
|
48
|
+
REQUIRE(extenValue[0] == 0xa0);
|
|
49
|
+
|
|
50
|
+
auto* payload = packet->GetPayload();
|
|
51
|
+
RtpPacket::FrameMarking* frameMarking{ nullptr };
|
|
52
|
+
uint8_t frameMarkingLen{ 0 };
|
|
53
|
+
|
|
54
|
+
// Read frame-marking.
|
|
55
|
+
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);
|
|
56
|
+
|
|
57
|
+
const auto* payloadDescriptor =
|
|
58
|
+
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
|
|
59
|
+
|
|
60
|
+
REQUIRE(payloadDescriptor);
|
|
61
|
+
|
|
62
|
+
REQUIRE(payloadDescriptor->s == 1);
|
|
63
|
+
REQUIRE(payloadDescriptor->e == 0);
|
|
64
|
+
REQUIRE(payloadDescriptor->i == 1);
|
|
65
|
+
REQUIRE(payloadDescriptor->d == 0);
|
|
66
|
+
REQUIRE(payloadDescriptor->b == 0);
|
|
67
|
+
REQUIRE(payloadDescriptor->hasTlIndex);
|
|
68
|
+
REQUIRE(payloadDescriptor->tlIndex == 0);
|
|
69
|
+
REQUIRE(payloadDescriptor->hasSlIndex == false);
|
|
70
|
+
REQUIRE(payloadDescriptor->isKeyFrame == true);
|
|
71
|
+
|
|
72
|
+
delete payloadDescriptor;
|
|
73
|
+
|
|
74
|
+
delete packet;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
SECTION("parse I0-8.bin")
|
|
78
|
+
{
|
|
79
|
+
size_t len;
|
|
80
|
+
uint8_t extenLen;
|
|
81
|
+
uint8_t* extenValue;
|
|
82
|
+
|
|
83
|
+
if (!helpers::readBinaryFile("data/H264_SVC/I0-8.bin", buffer, &len))
|
|
84
|
+
FAIL("cannot open file");
|
|
85
|
+
|
|
86
|
+
RtpPacket* packet = RtpPacket::Parse(buffer, len);
|
|
87
|
+
|
|
88
|
+
if (!packet)
|
|
89
|
+
FAIL("not a RTP packet");
|
|
90
|
+
|
|
91
|
+
REQUIRE(packet->HasMarker() == false);
|
|
92
|
+
REQUIRE(packet->HasHeaderExtension() == true);
|
|
93
|
+
REQUIRE(packet->GetPayloadType() == 111);
|
|
94
|
+
REQUIRE(packet->GetSequenceNumber() == 23617);
|
|
95
|
+
REQUIRE(packet->GetTimestamp() == 1660241882);
|
|
96
|
+
REQUIRE(packet->GetSsrc() == 2674985186);
|
|
97
|
+
REQUIRE(packet->GetHeaderExtensionId() == 0xBEDE);
|
|
98
|
+
REQUIRE(packet->GetHeaderExtensionLength() == 4);
|
|
99
|
+
REQUIRE(packet->HasOneByteExtensions());
|
|
100
|
+
REQUIRE(packet->HasTwoBytesExtensions() == false);
|
|
101
|
+
|
|
102
|
+
packet->SetFrameMarkingExtensionId(1);
|
|
103
|
+
extenValue = packet->GetExtension(1, extenLen);
|
|
104
|
+
|
|
105
|
+
REQUIRE(packet->HasExtension(1) == true);
|
|
106
|
+
REQUIRE(extenLen == 1);
|
|
107
|
+
REQUIRE(extenValue);
|
|
108
|
+
REQUIRE(extenValue[0] == 0x00);
|
|
109
|
+
|
|
110
|
+
auto* payload = packet->GetPayload();
|
|
111
|
+
RtpPacket::FrameMarking* frameMarking{ nullptr };
|
|
112
|
+
uint8_t frameMarkingLen{ 0 };
|
|
113
|
+
|
|
114
|
+
// Read frame-marking.
|
|
115
|
+
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);
|
|
116
|
+
|
|
117
|
+
const auto* payloadDescriptor =
|
|
118
|
+
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
|
|
119
|
+
|
|
120
|
+
REQUIRE(payloadDescriptor);
|
|
121
|
+
|
|
122
|
+
REQUIRE(payloadDescriptor->s == 0);
|
|
123
|
+
REQUIRE(payloadDescriptor->e == 0);
|
|
124
|
+
REQUIRE(payloadDescriptor->i == 0);
|
|
125
|
+
REQUIRE(payloadDescriptor->d == 0);
|
|
126
|
+
REQUIRE(payloadDescriptor->b == 0);
|
|
127
|
+
REQUIRE(payloadDescriptor->hasTlIndex);
|
|
128
|
+
REQUIRE(payloadDescriptor->tlIndex == 0);
|
|
129
|
+
REQUIRE(payloadDescriptor->hasSlIndex == false);
|
|
130
|
+
REQUIRE(payloadDescriptor->isKeyFrame == false);
|
|
131
|
+
|
|
132
|
+
delete payloadDescriptor;
|
|
133
|
+
|
|
134
|
+
delete packet;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
SECTION("parse I0-5.bin")
|
|
138
|
+
{
|
|
139
|
+
size_t len;
|
|
140
|
+
uint8_t extenLen;
|
|
141
|
+
uint8_t* extenValue;
|
|
142
|
+
|
|
143
|
+
if (!helpers::readBinaryFile("data/H264_SVC/I0-5.bin", buffer, &len))
|
|
144
|
+
FAIL("cannot open file");
|
|
145
|
+
|
|
146
|
+
RtpPacket* packet = RtpPacket::Parse(buffer, len);
|
|
147
|
+
|
|
148
|
+
if (!packet)
|
|
149
|
+
FAIL("not a RTP packet");
|
|
150
|
+
|
|
151
|
+
REQUIRE(packet->HasMarker() == false);
|
|
152
|
+
REQUIRE(packet->HasHeaderExtension() == true);
|
|
153
|
+
REQUIRE(packet->GetPayloadType() == 111);
|
|
154
|
+
REQUIRE(packet->GetSequenceNumber() == 23617);
|
|
155
|
+
REQUIRE(packet->GetTimestamp() == 1660241882);
|
|
156
|
+
REQUIRE(packet->GetSsrc() == 2674985186);
|
|
157
|
+
REQUIRE(packet->GetHeaderExtensionId() == 0xBEDE);
|
|
158
|
+
REQUIRE(packet->GetHeaderExtensionLength() == 4);
|
|
159
|
+
REQUIRE(packet->HasOneByteExtensions());
|
|
160
|
+
REQUIRE(packet->HasTwoBytesExtensions() == false);
|
|
161
|
+
|
|
162
|
+
packet->SetFrameMarkingExtensionId(1);
|
|
163
|
+
extenValue = packet->GetExtension(1, extenLen);
|
|
164
|
+
|
|
165
|
+
REQUIRE(packet->HasExtension(1) == true);
|
|
166
|
+
REQUIRE(extenLen == 1);
|
|
167
|
+
REQUIRE(extenValue);
|
|
168
|
+
REQUIRE(extenValue[0] == 0x60);
|
|
169
|
+
|
|
170
|
+
auto* payload = packet->GetPayload();
|
|
171
|
+
RtpPacket::FrameMarking* frameMarking{ nullptr };
|
|
172
|
+
uint8_t frameMarkingLen{ 0 };
|
|
173
|
+
|
|
174
|
+
// Read frame-marking.
|
|
175
|
+
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);
|
|
176
|
+
|
|
177
|
+
const auto* payloadDescriptor =
|
|
178
|
+
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
|
|
179
|
+
|
|
180
|
+
REQUIRE(payloadDescriptor);
|
|
181
|
+
|
|
182
|
+
REQUIRE(payloadDescriptor->s == 0);
|
|
183
|
+
REQUIRE(payloadDescriptor->e == 1);
|
|
184
|
+
REQUIRE(payloadDescriptor->i == 1);
|
|
185
|
+
REQUIRE(payloadDescriptor->d == 0);
|
|
186
|
+
REQUIRE(payloadDescriptor->b == 0);
|
|
187
|
+
REQUIRE(payloadDescriptor->isKeyFrame == true);
|
|
188
|
+
REQUIRE(payloadDescriptor->hasSlIndex == false);
|
|
189
|
+
REQUIRE(payloadDescriptor->hasTlIndex == false);
|
|
190
|
+
|
|
191
|
+
delete payloadDescriptor;
|
|
192
|
+
|
|
193
|
+
delete packet;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
SECTION("parse I1-15.bin")
|
|
197
|
+
{
|
|
198
|
+
size_t len;
|
|
199
|
+
uint8_t extenLen;
|
|
200
|
+
uint8_t* extenValue;
|
|
201
|
+
|
|
202
|
+
if (!helpers::readBinaryFile("data/H264_SVC/I1-15.bin", buffer, &len))
|
|
203
|
+
FAIL("cannot open file");
|
|
204
|
+
|
|
205
|
+
RtpPacket* packet = RtpPacket::Parse(buffer, len);
|
|
206
|
+
|
|
207
|
+
if (!packet)
|
|
208
|
+
FAIL("not a RTP packet");
|
|
209
|
+
|
|
210
|
+
REQUIRE(packet->HasMarker() == false);
|
|
211
|
+
REQUIRE(packet->HasHeaderExtension() == true);
|
|
212
|
+
REQUIRE(packet->GetPayloadType() == 111);
|
|
213
|
+
REQUIRE(packet->GetSequenceNumber() == 23617);
|
|
214
|
+
REQUIRE(packet->GetTimestamp() == 1660241882);
|
|
215
|
+
REQUIRE(packet->GetSsrc() == 2674985186);
|
|
216
|
+
REQUIRE(packet->GetHeaderExtensionId() == 0xBEDE);
|
|
217
|
+
REQUIRE(packet->GetHeaderExtensionLength() == 4);
|
|
218
|
+
REQUIRE(packet->HasOneByteExtensions());
|
|
219
|
+
REQUIRE(packet->HasTwoBytesExtensions() == false);
|
|
220
|
+
|
|
221
|
+
packet->SetFrameMarkingExtensionId(1);
|
|
222
|
+
extenValue = packet->GetExtension(1, extenLen);
|
|
223
|
+
|
|
224
|
+
REQUIRE(packet->HasExtension(1) == true);
|
|
225
|
+
REQUIRE(extenLen == 1);
|
|
226
|
+
REQUIRE(extenValue);
|
|
227
|
+
REQUIRE(extenValue[0] == 0x80);
|
|
228
|
+
|
|
229
|
+
auto* payload = packet->GetPayload();
|
|
230
|
+
RtpPacket::FrameMarking* frameMarking{ nullptr };
|
|
231
|
+
uint8_t frameMarkingLen{ 0 };
|
|
232
|
+
|
|
233
|
+
// Read frame-marking.
|
|
234
|
+
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);
|
|
235
|
+
|
|
236
|
+
const auto* payloadDescriptor =
|
|
237
|
+
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
|
|
238
|
+
|
|
239
|
+
REQUIRE(payloadDescriptor);
|
|
240
|
+
|
|
241
|
+
REQUIRE(payloadDescriptor->s == 1);
|
|
242
|
+
REQUIRE(payloadDescriptor->e == 0);
|
|
243
|
+
REQUIRE(payloadDescriptor->i == 0);
|
|
244
|
+
REQUIRE(payloadDescriptor->d == 0);
|
|
245
|
+
REQUIRE(payloadDescriptor->b == 0);
|
|
246
|
+
REQUIRE(payloadDescriptor->hasTlIndex);
|
|
247
|
+
REQUIRE(payloadDescriptor->tlIndex == 0);
|
|
248
|
+
REQUIRE(payloadDescriptor->hasSlIndex == false);
|
|
249
|
+
REQUIRE(payloadDescriptor->isKeyFrame == false);
|
|
250
|
+
|
|
251
|
+
delete payloadDescriptor;
|
|
252
|
+
|
|
253
|
+
delete packet;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
SECTION("parse I0-14.bin")
|
|
257
|
+
{
|
|
258
|
+
size_t len;
|
|
259
|
+
uint8_t extenLen;
|
|
260
|
+
uint8_t* extenValue;
|
|
261
|
+
|
|
262
|
+
if (!helpers::readBinaryFile("data/H264_SVC/I0-14.bin", buffer, &len))
|
|
263
|
+
FAIL("cannot open file");
|
|
264
|
+
|
|
265
|
+
RtpPacket* packet = RtpPacket::Parse(buffer, len);
|
|
266
|
+
|
|
267
|
+
if (!packet)
|
|
268
|
+
FAIL("not a RTP packet");
|
|
269
|
+
|
|
270
|
+
REQUIRE(packet->HasMarker() == false);
|
|
271
|
+
REQUIRE(packet->HasHeaderExtension() == true);
|
|
272
|
+
REQUIRE(packet->GetPayloadType() == 111);
|
|
273
|
+
REQUIRE(packet->GetSequenceNumber() == 23617);
|
|
274
|
+
REQUIRE(packet->GetTimestamp() == 1660241882);
|
|
275
|
+
REQUIRE(packet->GetSsrc() == 2674985186);
|
|
276
|
+
REQUIRE(packet->GetHeaderExtensionId() == 0xBEDE);
|
|
277
|
+
REQUIRE(packet->GetHeaderExtensionLength() == 4);
|
|
278
|
+
REQUIRE(packet->HasOneByteExtensions());
|
|
279
|
+
REQUIRE(packet->HasTwoBytesExtensions() == false);
|
|
280
|
+
|
|
281
|
+
packet->SetFrameMarkingExtensionId(1);
|
|
282
|
+
extenValue = packet->GetExtension(1, extenLen);
|
|
283
|
+
|
|
284
|
+
REQUIRE(packet->HasExtension(1) == true);
|
|
285
|
+
REQUIRE(extenLen == 1);
|
|
286
|
+
REQUIRE(extenValue);
|
|
287
|
+
REQUIRE(extenValue[0] == 0xa0);
|
|
288
|
+
|
|
289
|
+
auto* payload = packet->GetPayload();
|
|
290
|
+
RtpPacket::FrameMarking* frameMarking{ nullptr };
|
|
291
|
+
uint8_t frameMarkingLen{ 0 };
|
|
292
|
+
|
|
293
|
+
// Read frame-marking.
|
|
294
|
+
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);
|
|
295
|
+
|
|
296
|
+
const auto* payloadDescriptor =
|
|
297
|
+
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
|
|
298
|
+
|
|
299
|
+
REQUIRE(payloadDescriptor);
|
|
300
|
+
|
|
301
|
+
REQUIRE(payloadDescriptor->s == 1);
|
|
302
|
+
REQUIRE(payloadDescriptor->e == 0);
|
|
303
|
+
REQUIRE(payloadDescriptor->i == 1);
|
|
304
|
+
REQUIRE(payloadDescriptor->d == 0);
|
|
305
|
+
REQUIRE(payloadDescriptor->b == 0);
|
|
306
|
+
REQUIRE(payloadDescriptor->hasTlIndex);
|
|
307
|
+
REQUIRE(payloadDescriptor->tlIndex == 0);
|
|
308
|
+
REQUIRE(payloadDescriptor->hasSlIndex == false);
|
|
309
|
+
REQUIRE(payloadDescriptor->isKeyFrame == true);
|
|
310
|
+
|
|
311
|
+
delete payloadDescriptor;
|
|
312
|
+
|
|
313
|
+
delete packet;
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
SECTION("parse 2SL-I14.bin")
|
|
317
|
+
{
|
|
318
|
+
size_t len;
|
|
319
|
+
uint8_t extenLen;
|
|
320
|
+
uint8_t* extenValue;
|
|
321
|
+
|
|
322
|
+
if (!helpers::readBinaryFile("data/H264_SVC/2SL-I14.bin", buffer, &len))
|
|
323
|
+
FAIL("cannot open file");
|
|
324
|
+
|
|
325
|
+
RtpPacket* packet = RtpPacket::Parse(buffer, len);
|
|
326
|
+
|
|
327
|
+
if (!packet)
|
|
328
|
+
FAIL("not a RTP packet");
|
|
329
|
+
|
|
330
|
+
REQUIRE(packet->HasMarker() == false);
|
|
331
|
+
REQUIRE(packet->HasHeaderExtension() == true);
|
|
332
|
+
REQUIRE(packet->GetPayloadType() == 111);
|
|
333
|
+
REQUIRE(packet->GetSequenceNumber() == 23617);
|
|
334
|
+
REQUIRE(packet->GetTimestamp() == 1660241882);
|
|
335
|
+
REQUIRE(packet->GetSsrc() == 2674985186);
|
|
336
|
+
REQUIRE(packet->GetHeaderExtensionId() == 0xBEDE);
|
|
337
|
+
REQUIRE(packet->GetHeaderExtensionLength() == 4);
|
|
338
|
+
REQUIRE(packet->HasOneByteExtensions());
|
|
339
|
+
REQUIRE(packet->HasTwoBytesExtensions() == false);
|
|
340
|
+
|
|
341
|
+
packet->SetFrameMarkingExtensionId(1);
|
|
342
|
+
extenValue = packet->GetExtension(1, extenLen);
|
|
343
|
+
|
|
344
|
+
REQUIRE(packet->HasExtension(1) == true);
|
|
345
|
+
REQUIRE(extenLen == 2);
|
|
346
|
+
REQUIRE(extenValue);
|
|
347
|
+
REQUIRE(extenValue[0] == 0xa0);
|
|
348
|
+
|
|
349
|
+
auto* payload = packet->GetPayload();
|
|
350
|
+
RtpPacket::FrameMarking* frameMarking{ nullptr };
|
|
351
|
+
uint8_t frameMarkingLen{ 0 };
|
|
352
|
+
|
|
353
|
+
// Read frame-marking.
|
|
354
|
+
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);
|
|
355
|
+
|
|
356
|
+
const auto* payloadDescriptor =
|
|
357
|
+
Codecs::H264_SVC::Parse(payload, sizeof(payload), frameMarking, frameMarkingLen);
|
|
358
|
+
|
|
359
|
+
REQUIRE(payloadDescriptor);
|
|
360
|
+
|
|
361
|
+
REQUIRE(payloadDescriptor->s == 1);
|
|
362
|
+
REQUIRE(payloadDescriptor->e == 0);
|
|
363
|
+
REQUIRE(payloadDescriptor->i == 1);
|
|
364
|
+
REQUIRE(payloadDescriptor->d == 0);
|
|
365
|
+
REQUIRE(payloadDescriptor->b == 0);
|
|
366
|
+
REQUIRE(payloadDescriptor->hasTlIndex);
|
|
367
|
+
REQUIRE(payloadDescriptor->tlIndex == 0);
|
|
368
|
+
REQUIRE(payloadDescriptor->hasSlIndex);
|
|
369
|
+
REQUIRE(payloadDescriptor->slIndex == 0);
|
|
370
|
+
REQUIRE(payloadDescriptor->isKeyFrame == true);
|
|
371
|
+
|
|
372
|
+
delete payloadDescriptor;
|
|
373
|
+
|
|
374
|
+
delete packet;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
SECTION("create and test RTP files")
|
|
378
|
+
{
|
|
379
|
+
int32_t tmparray[7];
|
|
380
|
+
|
|
381
|
+
int32_t pos = 0, i = 0, rows = 0;
|
|
382
|
+
uint8_t type = 0;
|
|
383
|
+
int32_t bytes = 0;
|
|
384
|
+
int32_t sid = -1;
|
|
385
|
+
int32_t tid = -1;
|
|
386
|
+
int32_t isIdr = -1;
|
|
387
|
+
int32_t start = -1;
|
|
388
|
+
int32_t end = -1;
|
|
389
|
+
size_t len = 0;
|
|
390
|
+
|
|
391
|
+
std::fstream nf;
|
|
392
|
+
nf.open("data/H264_SVC/naluInfo/naluInfo.csv", std::ios::in);
|
|
393
|
+
if (nf.is_open())
|
|
394
|
+
{
|
|
395
|
+
std::string line, word;
|
|
396
|
+
getline(nf, line); // omit the header in the CSV
|
|
397
|
+
while (getline(nf, line))
|
|
398
|
+
{
|
|
399
|
+
std::stringstream s(line);
|
|
400
|
+
i = 0;
|
|
401
|
+
while (getline(s, word, ','))
|
|
402
|
+
{
|
|
403
|
+
tmparray[i++] = std::stoi(word);
|
|
404
|
+
}
|
|
405
|
+
type = tmparray[0];
|
|
406
|
+
bytes = tmparray[1];
|
|
407
|
+
sid = tmparray[2];
|
|
408
|
+
tid = tmparray[3];
|
|
409
|
+
isIdr = tmparray[4];
|
|
410
|
+
start = tmparray[5];
|
|
411
|
+
end = tmparray[6];
|
|
412
|
+
|
|
413
|
+
if (!helpers::readPayloadData(
|
|
414
|
+
"data/H264_SVC/naluInfo/naluInfo.264", pos + 4, bytes - 4, buffer))
|
|
415
|
+
FAIL("Failed to read payload data!\n");
|
|
416
|
+
|
|
417
|
+
// TODO: One additional byte is written as last value is omitted in the
|
|
418
|
+
// test bench
|
|
419
|
+
std::string strFile1 = "rtp-" + std::to_string(rows) + ".bin";
|
|
420
|
+
if (!helpers::writeRtpPacket(
|
|
421
|
+
strFile1.c_str(), type, bytes - 4, sid, tid, isIdr, start, end, buffer, buffer2, &len))
|
|
422
|
+
FAIL("Failed to write RTP packet!\n");
|
|
423
|
+
|
|
424
|
+
RtpPacket* packet = RtpPacket::Parse(buffer2, len);
|
|
425
|
+
|
|
426
|
+
if (!packet)
|
|
427
|
+
FAIL("not a RTP packet");
|
|
428
|
+
|
|
429
|
+
packet->SetFrameMarkingExtensionId(1);
|
|
430
|
+
|
|
431
|
+
auto* payload = packet->GetPayload();
|
|
432
|
+
RtpPacket::FrameMarking* frameMarking{ nullptr };
|
|
433
|
+
uint8_t frameMarkingLen{ 0 };
|
|
434
|
+
|
|
435
|
+
// Read frame-marking.
|
|
436
|
+
packet->ReadFrameMarking(&frameMarking, frameMarkingLen);
|
|
437
|
+
|
|
438
|
+
const auto* payloadDescriptor = Codecs::H264_SVC::Parse(
|
|
439
|
+
payload, packet->GetPayloadLength(), frameMarking, frameMarkingLen);
|
|
440
|
+
|
|
441
|
+
REQUIRE(payloadDescriptor);
|
|
442
|
+
|
|
443
|
+
// payloadDescriptor->Dump();
|
|
444
|
+
|
|
445
|
+
pos += bytes;
|
|
446
|
+
rows++;
|
|
447
|
+
|
|
448
|
+
delete payloadDescriptor;
|
|
449
|
+
delete packet;
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
nf.close();
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
}
|
|
@@ -10,6 +10,7 @@ using namespace RTC;
|
|
|
10
10
|
|
|
11
11
|
// 17: 16 bit mask + the initial sequence number.
|
|
12
12
|
static constexpr size_t MaxRequestedPackets{ 17 };
|
|
13
|
+
static constexpr unsigned int SendNackDelay{ 0u }; // In ms.
|
|
13
14
|
|
|
14
15
|
SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
|
|
15
16
|
{
|
|
@@ -140,7 +141,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
|
|
|
140
141
|
SECTION("NACK one packet")
|
|
141
142
|
{
|
|
142
143
|
RtpStreamRecvListener listener;
|
|
143
|
-
RtpStreamRecv rtpStream(&listener, params);
|
|
144
|
+
RtpStreamRecv rtpStream(&listener, params, SendNackDelay);
|
|
144
145
|
|
|
145
146
|
packet->SetSequenceNumber(1);
|
|
146
147
|
rtpStream.ReceivePacket(packet);
|
|
@@ -169,7 +170,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
|
|
|
169
170
|
SECTION("wrapping sequence numbers")
|
|
170
171
|
{
|
|
171
172
|
RtpStreamRecvListener listener;
|
|
172
|
-
RtpStreamRecv rtpStream(&listener, params);
|
|
173
|
+
RtpStreamRecv rtpStream(&listener, params, SendNackDelay);
|
|
173
174
|
|
|
174
175
|
packet->SetSequenceNumber(0xfffe);
|
|
175
176
|
rtpStream.ReceivePacket(packet);
|
|
@@ -189,7 +190,7 @@ SCENARIO("receive RTP packets and trigger NACK", "[rtp][rtpstream]")
|
|
|
189
190
|
SECTION("require key frame")
|
|
190
191
|
{
|
|
191
192
|
RtpStreamRecvListener listener;
|
|
192
|
-
RtpStreamRecv rtpStream(&listener, params);
|
|
193
|
+
RtpStreamRecv rtpStream(&listener, params, SendNackDelay);
|
|
193
194
|
|
|
194
195
|
packet->SetSequenceNumber(1);
|
|
195
196
|
rtpStream.ReceivePacket(packet);
|