mediasoup 3.11.14 → 3.11.15
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/Worker.js +1 -1
- package/node/lib/index.d.ts +1 -1
- package/node/lib/index.js +1 -1
- package/package.json +4 -4
- package/worker/fuzzer/include/RTC/FuzzerRtpRetransmissionBuffer.hpp +17 -0
- package/worker/fuzzer/src/FuzzerUtils.cpp +6 -0
- package/worker/fuzzer/src/RTC/FuzzerRtpPacket.cpp +4 -0
- package/worker/fuzzer/src/RTC/FuzzerRtpRetransmissionBuffer.cpp +44 -0
- package/worker/fuzzer/src/RTC/FuzzerRtpStreamSend.cpp +1 -1
- package/worker/fuzzer/src/RTC/FuzzerStunPacket.cpp +4 -0
- package/worker/fuzzer/src/fuzzer.cpp +24 -20
- package/worker/include/RTC/{RetransmissionBuffer.hpp → RtpRetransmissionBuffer.hpp} +3 -3
- package/worker/include/RTC/RtpStreamSend.hpp +2 -2
- package/worker/meson.build +3 -2
- package/worker/src/RTC/{RetransmissionBuffer.cpp → RtpRetransmissionBuffer.cpp} +30 -21
- package/worker/src/RTC/RtpStreamSend.cpp +2 -2
- package/worker/test/src/RTC/{TestRetransmissionBuffer.cpp → TestRtpRetransmissionBuffer.cpp} +53 -13
package/node/lib/Worker.js
CHANGED
|
@@ -90,7 +90,7 @@ class Worker extends EnhancedEventEmitter_1.EnhancedEventEmitter {
|
|
|
90
90
|
// options
|
|
91
91
|
{
|
|
92
92
|
env: {
|
|
93
|
-
MEDIASOUP_VERSION: '3.11.
|
|
93
|
+
MEDIASOUP_VERSION: '3.11.15',
|
|
94
94
|
// Let the worker process inherit all environment variables, useful
|
|
95
95
|
// if a custom and not in the path GCC is used so the user can set
|
|
96
96
|
// LD_LIBRARY_PATH environment variable for runtime.
|
package/node/lib/index.d.ts
CHANGED
package/node/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mediasoup",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.15",
|
|
4
4
|
"description": "Cutting Edge WebRTC Video Conferencing",
|
|
5
5
|
"contributors": [
|
|
6
6
|
"Iñaki Baz Castillo <ibc@aliax.net> (https://inakibaz.me)",
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@types/debug": "^4.1.7",
|
|
95
95
|
"@types/jest": "^29.5.0",
|
|
96
|
-
"@types/node": "^18.15.
|
|
96
|
+
"@types/node": "^18.15.5",
|
|
97
97
|
"@types/uuid": "^9.0.1",
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
99
|
-
"@typescript-eslint/parser": "^5.
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
99
|
+
"@typescript-eslint/parser": "^5.56.0",
|
|
100
100
|
"eslint": "^8.36.0",
|
|
101
101
|
"eslint-plugin-jest": "^27.2.1",
|
|
102
102
|
"jest": "^29.5.0",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#ifndef MS_FUZZER_RTC_RTP_RETRANSMISSION_BUFFER_HPP
|
|
2
|
+
#define MS_FUZZER_RTC_RTP_RETRANSMISSION_BUFFER_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
|
|
6
|
+
namespace Fuzzer
|
|
7
|
+
{
|
|
8
|
+
namespace RTC
|
|
9
|
+
{
|
|
10
|
+
namespace RtpRetransmissionBuffer
|
|
11
|
+
{
|
|
12
|
+
void Fuzz(const uint8_t* data, size_t len);
|
|
13
|
+
}
|
|
14
|
+
} // namespace RTC
|
|
15
|
+
} // namespace Fuzzer
|
|
16
|
+
|
|
17
|
+
#endif
|
|
@@ -12,10 +12,13 @@ void Fuzzer::Utils::Fuzz(const uint8_t* data, size_t len)
|
|
|
12
12
|
/* IP class. */
|
|
13
13
|
|
|
14
14
|
std::string ip;
|
|
15
|
+
|
|
15
16
|
ip = std::string(reinterpret_cast<const char*>(data2), INET6_ADDRSTRLEN / 2);
|
|
16
17
|
::Utils::IP::GetFamily(ip);
|
|
18
|
+
|
|
17
19
|
ip = std::string(reinterpret_cast<const char*>(data2), INET6_ADDRSTRLEN);
|
|
18
20
|
::Utils::IP::GetFamily(ip);
|
|
21
|
+
|
|
19
22
|
ip = std::string(reinterpret_cast<const char*>(data2), INET6_ADDRSTRLEN * 2);
|
|
20
23
|
::Utils::IP::GetFamily(ip);
|
|
21
24
|
|
|
@@ -23,6 +26,7 @@ void Fuzzer::Utils::Fuzz(const uint8_t* data, size_t len)
|
|
|
23
26
|
try
|
|
24
27
|
{
|
|
25
28
|
auto ip = std::string(reinterpret_cast<const char*>(data2), len);
|
|
29
|
+
|
|
26
30
|
::Utils::IP::NormalizeIp(ip);
|
|
27
31
|
}
|
|
28
32
|
catch (const MediaSoupError& error)
|
|
@@ -60,6 +64,7 @@ void Fuzzer::Utils::Fuzz(const uint8_t* data, size_t len)
|
|
|
60
64
|
try
|
|
61
65
|
{
|
|
62
66
|
size_t outLen;
|
|
67
|
+
|
|
63
68
|
::Utils::String::Base64Encode(data2, len);
|
|
64
69
|
::Utils::String::Base64Decode(data2, len, outLen);
|
|
65
70
|
}
|
|
@@ -70,6 +75,7 @@ void Fuzzer::Utils::Fuzz(const uint8_t* data, size_t len)
|
|
|
70
75
|
/* Time class. */
|
|
71
76
|
|
|
72
77
|
auto ntp = ::Utils::Time::TimeMs2Ntp(static_cast<uint64_t>(len));
|
|
78
|
+
|
|
73
79
|
::Utils::Time::Ntp2TimeMs(ntp);
|
|
74
80
|
::Utils::Time::IsNewerTimestamp(static_cast<uint32_t>(len), static_cast<uint32_t>(len * len));
|
|
75
81
|
::Utils::Time::IsNewerTimestamp(static_cast<uint32_t>(len * len), static_cast<uint32_t>(len));
|
|
@@ -7,7 +7,9 @@
|
|
|
7
7
|
void Fuzzer::RTC::RtpPacket::Fuzz(const uint8_t* data, size_t len)
|
|
8
8
|
{
|
|
9
9
|
if (!::RTC::RtpPacket::IsRtp(data, len))
|
|
10
|
+
{
|
|
10
11
|
return;
|
|
12
|
+
}
|
|
11
13
|
|
|
12
14
|
// We need to clone the given data into a separate buffer because setters
|
|
13
15
|
// below will try to write into packet memory.
|
|
@@ -31,7 +33,9 @@ void Fuzzer::RTC::RtpPacket::Fuzz(const uint8_t* data, size_t len)
|
|
|
31
33
|
::RTC::RtpPacket* packet = ::RTC::RtpPacket::Parse(data2, len);
|
|
32
34
|
|
|
33
35
|
if (!packet)
|
|
36
|
+
{
|
|
34
37
|
return;
|
|
38
|
+
}
|
|
35
39
|
|
|
36
40
|
// packet->Dump();
|
|
37
41
|
packet->GetData();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#include "RTC/FuzzerRtpRetransmissionBuffer.hpp"
|
|
2
|
+
#include "Utils.hpp"
|
|
3
|
+
#include "RTC/RtpPacket.hpp"
|
|
4
|
+
#include "RTC/RtpRetransmissionBuffer.hpp"
|
|
5
|
+
|
|
6
|
+
void Fuzzer::RTC::RtpRetransmissionBuffer::Fuzz(const uint8_t* data, size_t len)
|
|
7
|
+
{
|
|
8
|
+
uint16_t maxItems{ 2500u };
|
|
9
|
+
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
10
|
+
uint32_t clockRate{ 90000 };
|
|
11
|
+
|
|
12
|
+
// Trick to initialize our stuff just once (use static).
|
|
13
|
+
static ::RTC::RtpRetransmissionBuffer retransmissionBuffer(
|
|
14
|
+
maxItems, maxRetransmissionDelayMs, clockRate);
|
|
15
|
+
|
|
16
|
+
// clang-format off
|
|
17
|
+
uint8_t buffer[] =
|
|
18
|
+
{
|
|
19
|
+
0b10000000, 0b01111011, 0b01010010, 0b00001110,
|
|
20
|
+
0b01011011, 0b01101011, 0b11001010, 0b10110101,
|
|
21
|
+
0, 0, 0, 2
|
|
22
|
+
};
|
|
23
|
+
// clang-format on
|
|
24
|
+
|
|
25
|
+
// Create base RtpPacket instance.
|
|
26
|
+
auto* packet = ::RTC::RtpPacket::Parse(buffer, 12);
|
|
27
|
+
size_t offset{ 0u };
|
|
28
|
+
|
|
29
|
+
while (len >= 4u)
|
|
30
|
+
{
|
|
31
|
+
std::shared_ptr<::RTC::RtpPacket> sharedPacket;
|
|
32
|
+
|
|
33
|
+
// Set 'random' sequence number and timestamp.
|
|
34
|
+
packet->SetSequenceNumber(Utils::Byte::Get2Bytes(data, offset));
|
|
35
|
+
packet->SetTimestamp(Utils::Byte::Get4Bytes(data, offset));
|
|
36
|
+
|
|
37
|
+
retransmissionBuffer.Insert(packet, sharedPacket);
|
|
38
|
+
|
|
39
|
+
len -= 4u;
|
|
40
|
+
offset += 4;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
delete packet;
|
|
44
|
+
}
|
|
@@ -27,7 +27,6 @@ void Fuzzer::RTC::RtpStreamSend::Fuzz(const uint8_t* data, size_t len)
|
|
|
27
27
|
|
|
28
28
|
// Create base RtpPacket instance.
|
|
29
29
|
auto* packet = ::RTC::RtpPacket::Parse(buffer, 12);
|
|
30
|
-
size_t offset{ 0u };
|
|
31
30
|
|
|
32
31
|
// Create a RtpStreamSend instance.
|
|
33
32
|
TestRtpStreamListener testRtpStreamListener;
|
|
@@ -44,6 +43,7 @@ void Fuzzer::RTC::RtpStreamSend::Fuzz(const uint8_t* data, size_t len)
|
|
|
44
43
|
|
|
45
44
|
std::string mid;
|
|
46
45
|
auto* stream = new ::RTC::RtpStreamSend(&testRtpStreamListener, params, mid);
|
|
46
|
+
size_t offset{ 0u };
|
|
47
47
|
|
|
48
48
|
while (len >= 4u)
|
|
49
49
|
{
|
|
@@ -4,12 +4,16 @@
|
|
|
4
4
|
void Fuzzer::RTC::StunPacket::Fuzz(const uint8_t* data, size_t len)
|
|
5
5
|
{
|
|
6
6
|
if (!::RTC::StunPacket::IsStun(data, len))
|
|
7
|
+
{
|
|
7
8
|
return;
|
|
9
|
+
}
|
|
8
10
|
|
|
9
11
|
::RTC::StunPacket* packet = ::RTC::StunPacket::Parse(data, len);
|
|
10
12
|
|
|
11
13
|
if (!packet)
|
|
14
|
+
{
|
|
12
15
|
return;
|
|
16
|
+
}
|
|
13
17
|
|
|
14
18
|
// packet->Dump();
|
|
15
19
|
packet->GetClass();
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
#include "Settings.hpp"
|
|
11
11
|
#include "Utils.hpp"
|
|
12
12
|
#include "RTC/FuzzerRtpPacket.hpp"
|
|
13
|
+
#include "RTC/FuzzerRtpRetransmissionBuffer.hpp"
|
|
13
14
|
#include "RTC/FuzzerRtpStreamSend.hpp"
|
|
14
15
|
#include "RTC/FuzzerStunPacket.hpp"
|
|
15
16
|
#include "RTC/FuzzerTrendCalculator.hpp"
|
|
@@ -19,11 +20,10 @@
|
|
|
19
20
|
#include <stddef.h>
|
|
20
21
|
#include <stdint.h>
|
|
21
22
|
|
|
22
|
-
bool fuzzStun
|
|
23
|
-
bool fuzzRtp
|
|
24
|
-
bool fuzzRtcp
|
|
25
|
-
bool
|
|
26
|
-
bool fuzzUtils = false;
|
|
23
|
+
bool fuzzStun = false;
|
|
24
|
+
bool fuzzRtp = false;
|
|
25
|
+
bool fuzzRtcp = false;
|
|
26
|
+
bool fuzzUtils = false;
|
|
27
27
|
|
|
28
28
|
int Init();
|
|
29
29
|
|
|
@@ -36,16 +36,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t len)
|
|
|
36
36
|
unused++;
|
|
37
37
|
|
|
38
38
|
if (fuzzStun)
|
|
39
|
+
{
|
|
39
40
|
Fuzzer::RTC::StunPacket::Fuzz(data, len);
|
|
41
|
+
}
|
|
40
42
|
|
|
41
43
|
if (fuzzRtp)
|
|
44
|
+
{
|
|
42
45
|
Fuzzer::RTC::RtpPacket::Fuzz(data, len);
|
|
46
|
+
Fuzzer::RTC::RtpStreamSend::Fuzz(data, len);
|
|
47
|
+
Fuzzer::RTC::RtpRetransmissionBuffer::Fuzz(data, len);
|
|
48
|
+
}
|
|
43
49
|
|
|
44
50
|
if (fuzzRtcp)
|
|
51
|
+
{
|
|
45
52
|
Fuzzer::RTC::RTCP::Packet::Fuzz(data, len);
|
|
46
|
-
|
|
47
|
-
if (fuzzRtpStream)
|
|
48
|
-
Fuzzer::RTC::RtpStreamSend::Fuzz(data, len);
|
|
53
|
+
}
|
|
49
54
|
|
|
50
55
|
if (fuzzUtils)
|
|
51
56
|
{
|
|
@@ -64,11 +69,17 @@ int Init()
|
|
|
64
69
|
if (std::getenv("MS_FUZZ_LOG_LEVEL"))
|
|
65
70
|
{
|
|
66
71
|
if (std::string(std::getenv("MS_FUZZ_LOG_LEVEL")) == "debug")
|
|
72
|
+
{
|
|
67
73
|
logLevel = LogLevel::LOG_DEBUG;
|
|
74
|
+
}
|
|
68
75
|
else if (std::string(std::getenv("MS_FUZZ_LOG_LEVEL")) == "warn")
|
|
76
|
+
{
|
|
69
77
|
logLevel = LogLevel::LOG_WARN;
|
|
78
|
+
}
|
|
70
79
|
else if (std::string(std::getenv("MS_FUZZ_LOG_LEVEL")) == "error")
|
|
80
|
+
{
|
|
71
81
|
logLevel = LogLevel::LOG_ERROR;
|
|
82
|
+
}
|
|
72
83
|
}
|
|
73
84
|
|
|
74
85
|
// Select what to fuzz.
|
|
@@ -90,27 +101,20 @@ int Init()
|
|
|
90
101
|
|
|
91
102
|
fuzzRtcp = true;
|
|
92
103
|
}
|
|
93
|
-
if (std::getenv("MS_FUZZ_RTP_STREAM") && std::string(std::getenv("MS_FUZZ_RTP_STREAM")) == "1")
|
|
94
|
-
{
|
|
95
|
-
std::cout << "[fuzzer] RTP Stream fuzzers enabled" << std::endl;
|
|
96
|
-
|
|
97
|
-
fuzzRtpStream = true;
|
|
98
|
-
}
|
|
99
104
|
if (std::getenv("MS_FUZZ_UTILS") && std::string(std::getenv("MS_FUZZ_UTILS")) == "1")
|
|
100
105
|
{
|
|
101
106
|
std::cout << "[fuzzer] Utils fuzzers enabled" << std::endl;
|
|
102
107
|
|
|
103
108
|
fuzzUtils = true;
|
|
104
109
|
}
|
|
105
|
-
if (!fuzzUtils && !fuzzStun && !fuzzRtcp && !fuzzRtp
|
|
110
|
+
if (!fuzzUtils && !fuzzStun && !fuzzRtcp && !fuzzRtp)
|
|
106
111
|
{
|
|
107
112
|
std::cout << "[fuzzer] all fuzzers enabled" << std::endl;
|
|
108
113
|
|
|
109
|
-
fuzzStun
|
|
110
|
-
fuzzRtp
|
|
111
|
-
fuzzRtcp
|
|
112
|
-
|
|
113
|
-
fuzzUtils = true;
|
|
114
|
+
fuzzStun = true;
|
|
115
|
+
fuzzRtp = true;
|
|
116
|
+
fuzzRtcp = true;
|
|
117
|
+
fuzzUtils = true;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
Settings::configuration.logLevel = logLevel;
|
|
@@ -11,7 +11,7 @@ namespace RTC
|
|
|
11
11
|
// sequence number, while only taking as little memory as necessary to store
|
|
12
12
|
// the range covering a maximum of `MaxRetransmissionDelayForVideoMs` or
|
|
13
13
|
// `MaxRetransmissionDelayForAudioMs` ms.
|
|
14
|
-
class
|
|
14
|
+
class RtpRetransmissionBuffer
|
|
15
15
|
{
|
|
16
16
|
public:
|
|
17
17
|
struct Item
|
|
@@ -33,8 +33,8 @@ namespace RTC
|
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
public:
|
|
36
|
-
|
|
37
|
-
~
|
|
36
|
+
RtpRetransmissionBuffer(uint16_t maxItems, uint32_t maxRetransmissionDelayMs, uint32_t clockRate);
|
|
37
|
+
~RtpRetransmissionBuffer();
|
|
38
38
|
|
|
39
39
|
Item* Get(uint16_t seq) const;
|
|
40
40
|
void Insert(RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#define MS_RTC_RTP_STREAM_SEND_HPP
|
|
3
3
|
|
|
4
4
|
#include "RTC/RateCalculator.hpp"
|
|
5
|
-
#include "RTC/
|
|
5
|
+
#include "RTC/RtpRetransmissionBuffer.hpp"
|
|
6
6
|
#include "RTC/RtpStream.hpp"
|
|
7
7
|
|
|
8
8
|
namespace RTC
|
|
@@ -61,7 +61,7 @@ namespace RTC
|
|
|
61
61
|
std::string mid;
|
|
62
62
|
uint16_t rtxSeq{ 0u };
|
|
63
63
|
RTC::RtpDataCounter transmissionCounter;
|
|
64
|
-
RTC::
|
|
64
|
+
RTC::RtpRetransmissionBuffer* retransmissionBuffer{ nullptr };
|
|
65
65
|
// The middle 32 bits out of 64 in the NTP timestamp received in the most
|
|
66
66
|
// recent receiver reference timestamp.
|
|
67
67
|
uint32_t lastRrTimestamp{ 0u };
|
package/worker/meson.build
CHANGED
|
@@ -84,12 +84,12 @@ common_sources = [
|
|
|
84
84
|
'src/RTC/PortManager.cpp',
|
|
85
85
|
'src/RTC/Producer.cpp',
|
|
86
86
|
'src/RTC/RateCalculator.cpp',
|
|
87
|
-
'src/RTC/RetransmissionBuffer.cpp',
|
|
88
87
|
'src/RTC/Router.cpp',
|
|
89
88
|
'src/RTC/RtpListener.cpp',
|
|
90
89
|
'src/RTC/RtpObserver.cpp',
|
|
91
90
|
'src/RTC/RtpPacket.cpp',
|
|
92
91
|
'src/RTC/RtpProbationGenerator.cpp',
|
|
92
|
+
'src/RTC/RtpRetransmissionBuffer.cpp',
|
|
93
93
|
'src/RTC/RtpStream.cpp',
|
|
94
94
|
'src/RTC/RtpStreamRecv.cpp',
|
|
95
95
|
'src/RTC/RtpStreamSend.cpp',
|
|
@@ -288,9 +288,9 @@ mediasoup_worker_test = executable(
|
|
|
288
288
|
'test/src/RTC/TestKeyFrameRequestManager.cpp',
|
|
289
289
|
'test/src/RTC/TestNackGenerator.cpp',
|
|
290
290
|
'test/src/RTC/TestRateCalculator.cpp',
|
|
291
|
-
'test/src/RTC/TestRetransmissionBuffer.cpp',
|
|
292
291
|
'test/src/RTC/TestRtpPacket.cpp',
|
|
293
292
|
'test/src/RTC/TestRtpPacketH264Svc.cpp',
|
|
293
|
+
'test/src/RTC/TestRtpRetransmissionBuffer.cpp',
|
|
294
294
|
'test/src/RTC/TestRtpStreamSend.cpp',
|
|
295
295
|
'test/src/RTC/TestRtpStreamRecv.cpp',
|
|
296
296
|
'test/src/RTC/TestSeqManager.cpp',
|
|
@@ -354,6 +354,7 @@ executable(
|
|
|
354
354
|
'fuzzer/src/FuzzerUtils.cpp',
|
|
355
355
|
'fuzzer/src/RTC/FuzzerStunPacket.cpp',
|
|
356
356
|
'fuzzer/src/RTC/FuzzerRtpPacket.cpp',
|
|
357
|
+
'fuzzer/src/RTC/FuzzerRtpRetransmissionBuffer.cpp',
|
|
357
358
|
'fuzzer/src/RTC/FuzzerRtpStreamSend.cpp',
|
|
358
359
|
'fuzzer/src/RTC/FuzzerTrendCalculator.cpp',
|
|
359
360
|
'fuzzer/src/RTC/RTCP/FuzzerBye.cpp',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
#define MS_CLASS "RTC::
|
|
1
|
+
#define MS_CLASS "RTC::RtpRetransmissionBuffer"
|
|
2
2
|
// #define MS_LOG_DEV_LEVEL 3
|
|
3
3
|
|
|
4
|
-
#include "RTC/
|
|
4
|
+
#include "RTC/RtpRetransmissionBuffer.hpp"
|
|
5
5
|
#include "Logger.hpp"
|
|
6
6
|
#include "RTC/SeqManager.hpp"
|
|
7
7
|
|
|
@@ -9,7 +9,7 @@ namespace RTC
|
|
|
9
9
|
{
|
|
10
10
|
/* Instance methods. */
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
RtpRetransmissionBuffer::RtpRetransmissionBuffer(
|
|
13
13
|
uint16_t maxItems, uint32_t maxRetransmissionDelayMs, uint32_t clockRate)
|
|
14
14
|
: maxItems(maxItems), maxRetransmissionDelayMs(maxRetransmissionDelayMs), clockRate(clockRate)
|
|
15
15
|
{
|
|
@@ -18,14 +18,14 @@ namespace RTC
|
|
|
18
18
|
MS_ASSERT(maxItems > 0u, "maxItems must be greater than 0");
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
|
|
21
|
+
RtpRetransmissionBuffer::~RtpRetransmissionBuffer()
|
|
22
22
|
{
|
|
23
23
|
MS_TRACE();
|
|
24
24
|
|
|
25
25
|
Clear();
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
RtpRetransmissionBuffer::Item* RtpRetransmissionBuffer::Get(uint16_t seq) const
|
|
29
29
|
{
|
|
30
30
|
MS_TRACE();
|
|
31
31
|
|
|
@@ -56,7 +56,8 @@ namespace RTC
|
|
|
56
56
|
* not properly fit (by ensuring that elements in the buffer are not only
|
|
57
57
|
* ordered by increasing seq but also that their timestamp are incremental).
|
|
58
58
|
*/
|
|
59
|
-
void
|
|
59
|
+
void RtpRetransmissionBuffer::Insert(
|
|
60
|
+
RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket)
|
|
60
61
|
{
|
|
61
62
|
MS_TRACE();
|
|
62
63
|
|
|
@@ -135,7 +136,11 @@ namespace RTC
|
|
|
135
136
|
timestamp);
|
|
136
137
|
|
|
137
138
|
numBlankSlots = 0u;
|
|
139
|
+
|
|
138
140
|
Clear();
|
|
141
|
+
|
|
142
|
+
// After clearing the buffer, update startSeq.
|
|
143
|
+
this->startSeq = seq;
|
|
139
144
|
}
|
|
140
145
|
else
|
|
141
146
|
{
|
|
@@ -331,7 +336,7 @@ namespace RTC
|
|
|
331
336
|
this->maxItems);
|
|
332
337
|
}
|
|
333
338
|
|
|
334
|
-
void
|
|
339
|
+
void RtpRetransmissionBuffer::Clear()
|
|
335
340
|
{
|
|
336
341
|
MS_TRACE();
|
|
337
342
|
|
|
@@ -352,12 +357,16 @@ namespace RTC
|
|
|
352
357
|
this->startSeq = 0u;
|
|
353
358
|
}
|
|
354
359
|
|
|
355
|
-
void
|
|
360
|
+
void RtpRetransmissionBuffer::Dump() const
|
|
356
361
|
{
|
|
357
362
|
MS_TRACE();
|
|
358
363
|
|
|
359
|
-
MS_DUMP("<
|
|
360
|
-
MS_DUMP(
|
|
364
|
+
MS_DUMP("<RtpRetransmissionBuffer>");
|
|
365
|
+
MS_DUMP(
|
|
366
|
+
" buffer [size:%zu, maxSize:%" PRIu16 ", startSeq:%" PRIu16 "]",
|
|
367
|
+
this->buffer.size(),
|
|
368
|
+
this->maxItems,
|
|
369
|
+
this->startSeq);
|
|
361
370
|
if (this->buffer.size() > 0)
|
|
362
371
|
{
|
|
363
372
|
const auto* oldestItem = GetOldest();
|
|
@@ -376,24 +385,24 @@ namespace RTC
|
|
|
376
385
|
static_cast<uint32_t>(newestItem->timestamp * 1000 / this->clockRate) -
|
|
377
386
|
static_cast<uint32_t>(oldestItem->timestamp * 1000 / this->clockRate));
|
|
378
387
|
}
|
|
379
|
-
MS_DUMP("</
|
|
388
|
+
MS_DUMP("</RtpRetransmissionBuffer>");
|
|
380
389
|
}
|
|
381
390
|
|
|
382
|
-
|
|
391
|
+
RtpRetransmissionBuffer::Item* RtpRetransmissionBuffer::GetOldest() const
|
|
383
392
|
{
|
|
384
393
|
MS_TRACE();
|
|
385
394
|
|
|
386
395
|
return this->Get(this->startSeq);
|
|
387
396
|
}
|
|
388
397
|
|
|
389
|
-
|
|
398
|
+
RtpRetransmissionBuffer::Item* RtpRetransmissionBuffer::GetNewest() const
|
|
390
399
|
{
|
|
391
400
|
MS_TRACE();
|
|
392
401
|
|
|
393
402
|
return this->Get(this->startSeq + this->buffer.size() - 1);
|
|
394
403
|
}
|
|
395
404
|
|
|
396
|
-
void
|
|
405
|
+
void RtpRetransmissionBuffer::RemoveOldest()
|
|
397
406
|
{
|
|
398
407
|
MS_TRACE();
|
|
399
408
|
|
|
@@ -438,7 +447,7 @@ namespace RTC
|
|
|
438
447
|
}
|
|
439
448
|
}
|
|
440
449
|
|
|
441
|
-
void
|
|
450
|
+
void RtpRetransmissionBuffer::RemoveOldest(uint16_t numItems)
|
|
442
451
|
{
|
|
443
452
|
MS_TRACE();
|
|
444
453
|
|
|
@@ -457,7 +466,7 @@ namespace RTC
|
|
|
457
466
|
}
|
|
458
467
|
}
|
|
459
468
|
|
|
460
|
-
void
|
|
469
|
+
void RtpRetransmissionBuffer::ClearTooOld()
|
|
461
470
|
{
|
|
462
471
|
MS_TRACE();
|
|
463
472
|
|
|
@@ -468,7 +477,7 @@ namespace RTC
|
|
|
468
477
|
return;
|
|
469
478
|
}
|
|
470
479
|
|
|
471
|
-
|
|
480
|
+
RtpRetransmissionBuffer::Item* oldestItem{ nullptr };
|
|
472
481
|
|
|
473
482
|
// Go through all buffer items starting with the first and free all items
|
|
474
483
|
// that contain too old packets.
|
|
@@ -487,7 +496,7 @@ namespace RTC
|
|
|
487
496
|
}
|
|
488
497
|
}
|
|
489
498
|
|
|
490
|
-
bool
|
|
499
|
+
bool RtpRetransmissionBuffer::IsTooOld(uint32_t timestamp, uint32_t newestTimestamp) const
|
|
491
500
|
{
|
|
492
501
|
MS_TRACE();
|
|
493
502
|
|
|
@@ -501,8 +510,8 @@ namespace RTC
|
|
|
501
510
|
return static_cast<uint32_t>(diffTs * 1000 / this->clockRate) > this->maxRetransmissionDelayMs;
|
|
502
511
|
}
|
|
503
512
|
|
|
504
|
-
|
|
505
|
-
|
|
513
|
+
RtpRetransmissionBuffer::Item* RtpRetransmissionBuffer::FillItem(
|
|
514
|
+
RtpRetransmissionBuffer::Item* item,
|
|
506
515
|
RTC::RtpPacket* packet,
|
|
507
516
|
std::shared_ptr<RTC::RtpPacket>& sharedPacket) const
|
|
508
517
|
{
|
|
@@ -530,7 +539,7 @@ namespace RTC
|
|
|
530
539
|
return item;
|
|
531
540
|
}
|
|
532
541
|
|
|
533
|
-
void
|
|
542
|
+
void RtpRetransmissionBuffer::Item::Reset()
|
|
534
543
|
{
|
|
535
544
|
MS_TRACE();
|
|
536
545
|
|
|
@@ -15,7 +15,7 @@ namespace RTC
|
|
|
15
15
|
static constexpr size_t RetransmissionBufferMaxItems{ 2500u };
|
|
16
16
|
// 17: 16 bit mask + the initial sequence number.
|
|
17
17
|
static constexpr size_t MaxRequestedPackets{ 17u };
|
|
18
|
-
thread_local static std::vector<RTC::
|
|
18
|
+
thread_local static std::vector<RTC::RtpRetransmissionBuffer::Item*> RetransmissionContainer(
|
|
19
19
|
MaxRequestedPackets + 1);
|
|
20
20
|
static constexpr uint32_t DefaultRtt{ 100u };
|
|
21
21
|
|
|
@@ -58,7 +58,7 @@ namespace RTC
|
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
this->retransmissionBuffer = new RTC::
|
|
61
|
+
this->retransmissionBuffer = new RTC::RtpRetransmissionBuffer(
|
|
62
62
|
RetransmissionBufferMaxItems, maxRetransmissionDelayMs, params.clockRate);
|
|
63
63
|
}
|
|
64
64
|
}
|
package/worker/test/src/RTC/{TestRetransmissionBuffer.cpp → TestRtpRetransmissionBuffer.cpp}
RENAMED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
#include "common.hpp"
|
|
2
|
-
#include "RTC/RetransmissionBuffer.hpp"
|
|
3
2
|
#include "RTC/RtpPacket.hpp"
|
|
3
|
+
#include "RTC/RtpRetransmissionBuffer.hpp"
|
|
4
4
|
#include <catch2/catch.hpp>
|
|
5
5
|
#include <vector>
|
|
6
6
|
|
|
7
7
|
using namespace RTC;
|
|
8
8
|
|
|
9
|
-
// Class inheriting from
|
|
9
|
+
// Class inheriting from RtpRetransmissionBuffer so we can access its protected
|
|
10
10
|
// buffer member.
|
|
11
|
-
class
|
|
11
|
+
class RtpMyRetransmissionBuffer : public RtpRetransmissionBuffer
|
|
12
12
|
{
|
|
13
13
|
public:
|
|
14
14
|
struct VerificationItem
|
|
@@ -19,8 +19,8 @@ public:
|
|
|
19
19
|
};
|
|
20
20
|
|
|
21
21
|
public:
|
|
22
|
-
|
|
23
|
-
:
|
|
22
|
+
RtpMyRetransmissionBuffer(uint16_t maxItems, uint32_t maxRetransmissionDelayMs, uint32_t clockRate)
|
|
23
|
+
: RtpRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate)
|
|
24
24
|
{
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -43,7 +43,7 @@ public:
|
|
|
43
43
|
|
|
44
44
|
std::shared_ptr<RtpPacket> sharedPacket;
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
RtpRetransmissionBuffer::Insert(packet, sharedPacket);
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
void AssertBuffer(std::vector<VerificationItem> verificationBuffer)
|
|
@@ -66,7 +66,7 @@ public:
|
|
|
66
66
|
}
|
|
67
67
|
};
|
|
68
68
|
|
|
69
|
-
SCENARIO("
|
|
69
|
+
SCENARIO("RtpRetransmissionBuffer", "[rtp][rtx]")
|
|
70
70
|
{
|
|
71
71
|
SECTION("proper packets received in order")
|
|
72
72
|
{
|
|
@@ -74,7 +74,7 @@ SCENARIO("RetransmissionBuffer", "[rtp][rtx]")
|
|
|
74
74
|
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
75
75
|
uint32_t clockRate{ 90000 };
|
|
76
76
|
|
|
77
|
-
|
|
77
|
+
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
|
|
78
78
|
|
|
79
79
|
myRetransmissionBuffer.Insert(10001, 1000000000);
|
|
80
80
|
myRetransmissionBuffer.Insert(10002, 1000000000);
|
|
@@ -99,7 +99,7 @@ SCENARIO("RetransmissionBuffer", "[rtp][rtx]")
|
|
|
99
99
|
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
100
100
|
uint32_t clockRate{ 90000 };
|
|
101
101
|
|
|
102
|
-
|
|
102
|
+
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
|
|
103
103
|
|
|
104
104
|
myRetransmissionBuffer.Insert(20004, 2000000200);
|
|
105
105
|
myRetransmissionBuffer.Insert(20001, 2000000000);
|
|
@@ -124,7 +124,7 @@ SCENARIO("RetransmissionBuffer", "[rtp][rtx]")
|
|
|
124
124
|
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
125
125
|
uint32_t clockRate{ 90000 };
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
|
|
128
128
|
|
|
129
129
|
myRetransmissionBuffer.Insert(30001, 3000000000);
|
|
130
130
|
myRetransmissionBuffer.Insert(30002, 3000000000);
|
|
@@ -146,7 +146,7 @@ SCENARIO("RetransmissionBuffer", "[rtp][rtx]")
|
|
|
146
146
|
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
147
147
|
uint32_t clockRate{ 90000 };
|
|
148
148
|
|
|
149
|
-
|
|
149
|
+
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
|
|
150
150
|
|
|
151
151
|
myRetransmissionBuffer.Insert(40002, 4000000002);
|
|
152
152
|
// Packet must be discarded since its timestamp is lower than in seq 40002.
|
|
@@ -184,7 +184,7 @@ SCENARIO("RetransmissionBuffer", "[rtp][rtx]")
|
|
|
184
184
|
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
185
185
|
uint32_t clockRate{ 90000 };
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
|
|
188
188
|
|
|
189
189
|
myRetransmissionBuffer.Insert(10001, 1000000001);
|
|
190
190
|
myRetransmissionBuffer.Insert(10002, 1000000002);
|
|
@@ -209,7 +209,7 @@ SCENARIO("RetransmissionBuffer", "[rtp][rtx]")
|
|
|
209
209
|
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
210
210
|
uint32_t clockRate{ 90000 };
|
|
211
211
|
|
|
212
|
-
|
|
212
|
+
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
|
|
213
213
|
|
|
214
214
|
auto maxDiffTs = static_cast<uint32_t>(maxRetransmissionDelayMs * clockRate / 1000);
|
|
215
215
|
|
|
@@ -229,4 +229,44 @@ SCENARIO("RetransmissionBuffer", "[rtp][rtx]")
|
|
|
229
229
|
);
|
|
230
230
|
// clang-format on
|
|
231
231
|
}
|
|
232
|
+
|
|
233
|
+
SECTION("fuzzer generated packets")
|
|
234
|
+
{
|
|
235
|
+
uint16_t maxItems{ 2500u };
|
|
236
|
+
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
237
|
+
uint32_t clockRate{ 90000 };
|
|
238
|
+
|
|
239
|
+
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
|
|
240
|
+
|
|
241
|
+
// These packets reproduce an already fixed crash reported here:
|
|
242
|
+
// https://github.com/versatica/mediasoup/issues/1027#issuecomment-1478464584
|
|
243
|
+
// I've commented first packets and just left those that produce the crash.
|
|
244
|
+
|
|
245
|
+
// myRetransmissionBuffer.Insert(14906, 976891962);
|
|
246
|
+
// myRetransmissionBuffer.Insert(14906, 976891962);
|
|
247
|
+
// myRetransmissionBuffer.Insert(14906, 976892730);
|
|
248
|
+
// myRetransmissionBuffer.Insert(13157, 862283031);
|
|
249
|
+
// myRetransmissionBuffer.Insert(13114, 859453491);
|
|
250
|
+
// myRetransmissionBuffer.Insert(14906, 976892264);
|
|
251
|
+
// myRetransmissionBuffer.Insert(14906, 976897098);
|
|
252
|
+
// myRetransmissionBuffer.Insert(13114, 859464290);
|
|
253
|
+
// myRetransmissionBuffer.Insert(14906, 976889088);
|
|
254
|
+
// myRetransmissionBuffer.Insert(13056, 855638184);
|
|
255
|
+
// myRetransmissionBuffer.Insert(14906, 976891950);
|
|
256
|
+
// myRetransmissionBuffer.Insert(17722, 1161443894);
|
|
257
|
+
// myRetransmissionBuffer.Insert(12846, 841888049);
|
|
258
|
+
// myRetransmissionBuffer.Insert(14906, 976905830);
|
|
259
|
+
// myRetransmissionBuffer.Insert(15677, 1027420485);
|
|
260
|
+
// myRetransmissionBuffer.Insert(33742, 2211317269);
|
|
261
|
+
// myRetransmissionBuffer.Insert(14906, 976892672);
|
|
262
|
+
// myRetransmissionBuffer.Insert(13102, 858665774);
|
|
263
|
+
// myRetransmissionBuffer.Insert(12850, 842150702);
|
|
264
|
+
// myRetransmissionBuffer.Insert(14906, 976891941);
|
|
265
|
+
// myRetransmissionBuffer.Insert(15677, 1027423549);
|
|
266
|
+
// myRetransmissionBuffer.Insert(12346, 809120580);
|
|
267
|
+
// myRetransmissionBuffer.Insert(12645, 828715313);
|
|
268
|
+
myRetransmissionBuffer.Insert(12645, 828702743);
|
|
269
|
+
myRetransmissionBuffer.Insert(33998, 2228092928);
|
|
270
|
+
myRetransmissionBuffer.Insert(33998, 2228092928);
|
|
271
|
+
}
|
|
232
272
|
}
|