mediasoup 3.11.13 → 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 +8 -8
- 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/RtpRetransmissionBuffer.hpp +68 -0
- package/worker/include/RTC/RtpStream.hpp +21 -12
- package/worker/include/RTC/RtpStreamRecv.hpp +19 -12
- package/worker/include/RTC/RtpStreamSend.hpp +12 -56
- package/worker/include/common.hpp +11 -8
- package/worker/meson.build +3 -0
- package/worker/src/RTC/RtpRetransmissionBuffer.cpp +553 -0
- package/worker/src/RTC/RtpStreamRecv.cpp +62 -0
- package/worker/src/RTC/RtpStreamSend.cpp +68 -310
- package/worker/src/handles/Timer.cpp +28 -0
- package/worker/test/src/RTC/TestRtpRetransmissionBuffer.cpp +272 -0
- package/worker/test/src/RTC/TestRtpStreamSend.cpp +6 -1
- package/worker/test/src/tests.cpp +13 -0
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)",
|
|
@@ -92,15 +92,15 @@
|
|
|
92
92
|
},
|
|
93
93
|
"devDependencies": {
|
|
94
94
|
"@types/debug": "^4.1.7",
|
|
95
|
-
"@types/jest": "^29.
|
|
96
|
-
"@types/node": "^18.
|
|
95
|
+
"@types/jest": "^29.5.0",
|
|
96
|
+
"@types/node": "^18.15.5",
|
|
97
97
|
"@types/uuid": "^9.0.1",
|
|
98
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
99
|
-
"@typescript-eslint/parser": "^5.
|
|
100
|
-
"eslint": "^8.
|
|
98
|
+
"@typescript-eslint/eslint-plugin": "^5.56.0",
|
|
99
|
+
"@typescript-eslint/parser": "^5.56.0",
|
|
100
|
+
"eslint": "^8.36.0",
|
|
101
101
|
"eslint-plugin-jest": "^27.2.1",
|
|
102
|
-
"jest": "^29.
|
|
103
|
-
"open-cli": "^7.
|
|
102
|
+
"jest": "^29.5.0",
|
|
103
|
+
"open-cli": "^7.2.0",
|
|
104
104
|
"pick-port": "^1.0.1",
|
|
105
105
|
"sctp": "^1.0.0",
|
|
106
106
|
"ts-jest": "^29.0.5",
|
|
@@ -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;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#ifndef MS_RTC_RTP_RETRANSMISSION_BUFFER_HPP
|
|
2
|
+
#define MS_RTC_RTP_RETRANSMISSION_BUFFER_HPP
|
|
3
|
+
|
|
4
|
+
#include "common.hpp"
|
|
5
|
+
#include "RTC/RtpPacket.hpp"
|
|
6
|
+
#include <deque>
|
|
7
|
+
|
|
8
|
+
namespace RTC
|
|
9
|
+
{
|
|
10
|
+
// Special container that stores `Item`* elements addressable by their `uint16_t`
|
|
11
|
+
// sequence number, while only taking as little memory as necessary to store
|
|
12
|
+
// the range covering a maximum of `MaxRetransmissionDelayForVideoMs` or
|
|
13
|
+
// `MaxRetransmissionDelayForAudioMs` ms.
|
|
14
|
+
class RtpRetransmissionBuffer
|
|
15
|
+
{
|
|
16
|
+
public:
|
|
17
|
+
struct Item
|
|
18
|
+
{
|
|
19
|
+
void Reset();
|
|
20
|
+
|
|
21
|
+
// Original packet.
|
|
22
|
+
std::shared_ptr<RTC::RtpPacket> packet{ nullptr };
|
|
23
|
+
// Correct SSRC since original packet may not have the same.
|
|
24
|
+
uint32_t ssrc{ 0u };
|
|
25
|
+
// Correct sequence number since original packet may not have the same.
|
|
26
|
+
uint16_t sequenceNumber{ 0u };
|
|
27
|
+
// Correct timestamp since original packet may not have the same.
|
|
28
|
+
uint32_t timestamp{ 0u };
|
|
29
|
+
// Last time this packet was resent.
|
|
30
|
+
uint64_t resentAtMs{ 0u };
|
|
31
|
+
// Number of times this packet was resent.
|
|
32
|
+
uint8_t sentTimes{ 0u };
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
public:
|
|
36
|
+
RtpRetransmissionBuffer(uint16_t maxItems, uint32_t maxRetransmissionDelayMs, uint32_t clockRate);
|
|
37
|
+
~RtpRetransmissionBuffer();
|
|
38
|
+
|
|
39
|
+
Item* Get(uint16_t seq) const;
|
|
40
|
+
void Insert(RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket);
|
|
41
|
+
void Clear();
|
|
42
|
+
void Dump() const;
|
|
43
|
+
|
|
44
|
+
private:
|
|
45
|
+
Item* GetOldest() const;
|
|
46
|
+
Item* GetNewest() const;
|
|
47
|
+
void RemoveOldest();
|
|
48
|
+
void RemoveOldest(uint16_t numItems);
|
|
49
|
+
void ClearTooOld();
|
|
50
|
+
bool IsTooOld(uint32_t timestamp, uint32_t newestTimestamp) const;
|
|
51
|
+
Item* FillItem(
|
|
52
|
+
Item* item, RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket) const;
|
|
53
|
+
|
|
54
|
+
protected:
|
|
55
|
+
// Make buffer protected for testing purposes.
|
|
56
|
+
std::deque<Item*> buffer;
|
|
57
|
+
|
|
58
|
+
private:
|
|
59
|
+
// Given as argument.
|
|
60
|
+
uint16_t maxItems;
|
|
61
|
+
uint32_t maxRetransmissionDelayMs;
|
|
62
|
+
uint32_t clockRate;
|
|
63
|
+
// Others.
|
|
64
|
+
uint16_t startSeq{ 0u };
|
|
65
|
+
};
|
|
66
|
+
} // namespace RTC
|
|
67
|
+
|
|
68
|
+
#endif
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
#include "RTC/RTCP/XrDelaySinceLastRr.hpp"
|
|
14
14
|
#include "RTC/RTCP/XrReceiverReferenceTime.hpp"
|
|
15
15
|
#include "RTC/RtpDictionaries.hpp"
|
|
16
|
+
#include "RTC/RtpPacket.hpp"
|
|
16
17
|
#include "RTC/RtxStream.hpp"
|
|
17
18
|
#include <nlohmann/json.hpp>
|
|
18
19
|
#include <string>
|
|
@@ -180,12 +181,18 @@ namespace RTC
|
|
|
180
181
|
Params params;
|
|
181
182
|
// Others.
|
|
182
183
|
// https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff.
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
uint32_t
|
|
187
|
-
|
|
188
|
-
|
|
184
|
+
// Highest seq. number seen.
|
|
185
|
+
uint16_t maxSeq{ 0u };
|
|
186
|
+
// Shifted count of seq. number cycles.
|
|
187
|
+
uint32_t cycles{ 0u };
|
|
188
|
+
// Base seq number.
|
|
189
|
+
uint32_t baseSeq{ 0u };
|
|
190
|
+
// Last 'bad' seq number + 1.
|
|
191
|
+
uint32_t badSeq{ 0u };
|
|
192
|
+
// Highest timestamp seen.
|
|
193
|
+
uint32_t maxPacketTs{ 0u };
|
|
194
|
+
// When the packet with highest timestammp was seen.
|
|
195
|
+
uint64_t maxPacketMs{ 0u };
|
|
189
196
|
uint32_t packetsLost{ 0u };
|
|
190
197
|
uint8_t fractionLost{ 0u };
|
|
191
198
|
size_t packetsDiscarded{ 0u };
|
|
@@ -195,12 +202,14 @@ namespace RTC
|
|
|
195
202
|
size_t nackPacketCount{ 0u };
|
|
196
203
|
size_t pliCount{ 0u };
|
|
197
204
|
size_t firCount{ 0u };
|
|
198
|
-
|
|
199
|
-
size_t
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
205
|
+
// Packets repaired at last interval for score calculation.
|
|
206
|
+
size_t repairedPriorScore{ 0u };
|
|
207
|
+
// Packets retransmitted at last interval for score calculation.
|
|
208
|
+
size_t retransmittedPriorScore{ 0u };
|
|
209
|
+
// NTP timestamp in last Sender Report (in ms).
|
|
210
|
+
uint64_t lastSenderReportNtpMs{ 0u };
|
|
211
|
+
// RTP timestamp in last Sender Report.
|
|
212
|
+
uint32_t lastSenderReportTs{ 0u };
|
|
204
213
|
float rtt{ 0 };
|
|
205
214
|
bool hasRtt{ false };
|
|
206
215
|
// Instance of RtxStream.
|
|
@@ -93,24 +93,31 @@ namespace RTC
|
|
|
93
93
|
// Passed by argument.
|
|
94
94
|
unsigned int sendNackDelayMs{ 0u };
|
|
95
95
|
// Others.
|
|
96
|
-
|
|
97
|
-
uint32_t
|
|
98
|
-
|
|
99
|
-
uint32_t
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
96
|
+
// Packets expected at last interval.
|
|
97
|
+
uint32_t expectedPrior{ 0u };
|
|
98
|
+
// Packets expected at last interval for score calculation.
|
|
99
|
+
uint32_t expectedPriorScore{ 0u };
|
|
100
|
+
// Packets received at last interval.
|
|
101
|
+
uint32_t receivedPrior{ 0u };
|
|
102
|
+
// Packets received at last interval for score calculation.
|
|
103
|
+
uint32_t receivedPriorScore{ 0u };
|
|
104
|
+
// The middle 32 bits out of 64 in the NTP timestamp received in the most
|
|
105
|
+
// recent sender report.
|
|
106
|
+
uint32_t lastSrTimestamp{ 0u };
|
|
107
|
+
// Wallclock time representing the most recent sender report arrival.
|
|
108
|
+
uint64_t lastSrReceived{ 0u };
|
|
109
|
+
// Relative transit time for prev packet.
|
|
110
|
+
int32_t transit{ 0u };
|
|
106
111
|
uint32_t jitter{ 0u };
|
|
107
112
|
uint8_t firSeqNumber{ 0u };
|
|
108
113
|
uint32_t reportedPacketLost{ 0u };
|
|
109
114
|
std::unique_ptr<RTC::NackGenerator> nackGenerator;
|
|
110
115
|
Timer* inactivityCheckPeriodicTimer{ nullptr };
|
|
111
116
|
bool inactive{ false };
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
// Valid media + valid RTX.
|
|
118
|
+
TransmissionCounter transmissionCounter;
|
|
119
|
+
// Just valid media.
|
|
120
|
+
RTC::RtpDataCounter mediaTransmissionCounter;
|
|
114
121
|
};
|
|
115
122
|
} // namespace RTC
|
|
116
123
|
|
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
#define MS_RTC_RTP_STREAM_SEND_HPP
|
|
3
3
|
|
|
4
4
|
#include "RTC/RateCalculator.hpp"
|
|
5
|
+
#include "RTC/RtpRetransmissionBuffer.hpp"
|
|
5
6
|
#include "RTC/RtpStream.hpp"
|
|
6
|
-
#include <deque>
|
|
7
7
|
|
|
8
8
|
namespace RTC
|
|
9
9
|
{
|
|
10
10
|
class RtpStreamSend : public RTC::RtpStream
|
|
11
11
|
{
|
|
12
12
|
public:
|
|
13
|
-
// Minimum retransmission buffer size (ms).
|
|
14
|
-
const static uint32_t MinRetransmissionDelayMs;
|
|
15
13
|
// Maximum retransmission buffer size for video (ms).
|
|
16
14
|
const static uint32_t MaxRetransmissionDelayForVideoMs;
|
|
17
15
|
// Maximum retransmission buffer size for audio (ms).
|
|
@@ -25,47 +23,6 @@ namespace RTC
|
|
|
25
23
|
RTC::RtpStreamSend* rtpStream, RTC::RtpPacket* packet) = 0;
|
|
26
24
|
};
|
|
27
25
|
|
|
28
|
-
public:
|
|
29
|
-
struct StorageItem
|
|
30
|
-
{
|
|
31
|
-
void Reset();
|
|
32
|
-
|
|
33
|
-
// Original packet.
|
|
34
|
-
std::shared_ptr<RTC::RtpPacket> packet{ nullptr };
|
|
35
|
-
// Correct SSRC since original packet may not have the same.
|
|
36
|
-
uint32_t ssrc{ 0 };
|
|
37
|
-
// Correct sequence number since original packet may not have the same.
|
|
38
|
-
uint16_t sequenceNumber{ 0 };
|
|
39
|
-
// Correct timestamp since original packet may not have the same.
|
|
40
|
-
uint32_t timestamp{ 0 };
|
|
41
|
-
// Last time this packet was resent.
|
|
42
|
-
uint64_t resentAtMs{ 0u };
|
|
43
|
-
// Number of times this packet was resent.
|
|
44
|
-
uint8_t sentTimes{ 0u };
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
private:
|
|
48
|
-
// Special container that stores `StorageItem*` elements addressable by
|
|
49
|
-
// their `uint16_t` sequence number, while only taking as little memory as
|
|
50
|
-
// necessary to store the range covering a maximum of
|
|
51
|
-
// MaxRetransmissionDelayForVideoMs or MaxRetransmissionDelayForAudioMs ms.
|
|
52
|
-
class StorageItemBuffer
|
|
53
|
-
{
|
|
54
|
-
public:
|
|
55
|
-
~StorageItemBuffer();
|
|
56
|
-
|
|
57
|
-
StorageItem* GetFirst() const;
|
|
58
|
-
StorageItem* Get(uint16_t seq) const;
|
|
59
|
-
size_t GetBufferSize() const;
|
|
60
|
-
void Insert(uint16_t seq, StorageItem* storageItem);
|
|
61
|
-
void RemoveFirst();
|
|
62
|
-
void Clear();
|
|
63
|
-
|
|
64
|
-
private:
|
|
65
|
-
uint16_t startSeq{ 0 };
|
|
66
|
-
std::deque<StorageItem*> buffer;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
26
|
public:
|
|
70
27
|
RtpStreamSend(
|
|
71
28
|
RTC::RtpStreamSend::Listener* listener, RTC::RtpStream::Params& params, std::string& mid);
|
|
@@ -93,25 +50,24 @@ namespace RTC
|
|
|
93
50
|
|
|
94
51
|
private:
|
|
95
52
|
void StorePacket(RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket);
|
|
96
|
-
void ClearOldPackets(const RtpPacket* packet);
|
|
97
|
-
void ClearBuffer();
|
|
98
53
|
void FillRetransmissionContainer(uint16_t seq, uint16_t bitmask);
|
|
99
54
|
void UpdateScore(RTC::RTCP::ReceiverReport* report);
|
|
100
55
|
|
|
101
56
|
private:
|
|
102
|
-
|
|
103
|
-
uint32_t
|
|
104
|
-
|
|
57
|
+
// Packets lost at last interval for score calculation.
|
|
58
|
+
uint32_t lostPriorScore{ 0u };
|
|
59
|
+
// Packets sent at last interval for score calculation.
|
|
60
|
+
uint32_t sentPriorScore{ 0u };
|
|
105
61
|
std::string mid;
|
|
106
|
-
uint32_t maxRetransmissionDelayMs;
|
|
107
|
-
uint32_t retransmissionBufferSize;
|
|
108
62
|
uint16_t rtxSeq{ 0u };
|
|
109
63
|
RTC::RtpDataCounter transmissionCounter;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
64
|
+
RTC::RtpRetransmissionBuffer* retransmissionBuffer{ nullptr };
|
|
65
|
+
// The middle 32 bits out of 64 in the NTP timestamp received in the most
|
|
66
|
+
// recent receiver reference timestamp.
|
|
67
|
+
uint32_t lastRrTimestamp{ 0u };
|
|
68
|
+
// Wallclock time representing the most recent receiver reference timestamp
|
|
69
|
+
// arrival.
|
|
70
|
+
uint64_t lastRrReceivedMs{ 0u };
|
|
115
71
|
};
|
|
116
72
|
} // namespace RTC
|
|
117
73
|
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
#include <memory> // std::addressof()
|
|
10
10
|
#ifdef _WIN32
|
|
11
11
|
#include <winsock2.h>
|
|
12
|
-
//
|
|
12
|
+
// Avoid uv/win.h: error C2628 'intptr_t' followed by 'int' is illegal.
|
|
13
13
|
#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED)
|
|
14
14
|
#include <BaseTsd.h>
|
|
15
15
|
typedef SSIZE_T ssize_t;
|
|
@@ -25,15 +25,17 @@ typedef SSIZE_T ssize_t;
|
|
|
25
25
|
|
|
26
26
|
using ChannelReadCtx = void*;
|
|
27
27
|
using ChannelReadFreeFn = void (*)(uint8_t*, uint32_t, size_t);
|
|
28
|
-
// Returns `ChannelReadFree` on successful read that must be used to free
|
|
28
|
+
// Returns `ChannelReadFree` on successful read that must be used to free
|
|
29
|
+
// `message`.
|
|
29
30
|
using ChannelReadFn = ChannelReadFreeFn (*)(
|
|
30
31
|
uint8_t** /* message */,
|
|
31
32
|
uint32_t* /* messageLen */,
|
|
32
33
|
size_t* /* messageCtx */,
|
|
33
|
-
// This is `uv_async_t` handle that can be called later with `uv_async_send()`
|
|
34
|
-
// data to read.
|
|
34
|
+
// This is `uv_async_t` handle that can be called later with `uv_async_send()`
|
|
35
|
+
// when there is more data to read.
|
|
35
36
|
const void* /* handle */,
|
|
36
|
-
ChannelReadCtx /* ctx */
|
|
37
|
+
ChannelReadCtx /* ctx */
|
|
38
|
+
);
|
|
37
39
|
|
|
38
40
|
using ChannelWriteCtx = void*;
|
|
39
41
|
using ChannelWriteFn =
|
|
@@ -41,7 +43,8 @@ using ChannelWriteFn =
|
|
|
41
43
|
|
|
42
44
|
using PayloadChannelReadCtx = void*;
|
|
43
45
|
using PayloadChannelReadFreeFn = void (*)(uint8_t*, uint32_t, size_t);
|
|
44
|
-
// Returns `PayloadChannelReadFree` on successful read that must be used to free
|
|
46
|
+
// Returns `PayloadChannelReadFree` on successful read that must be used to free
|
|
47
|
+
// `message` and `payload`.
|
|
45
48
|
using PayloadChannelReadFn = PayloadChannelReadFreeFn (*)(
|
|
46
49
|
uint8_t** /* message */,
|
|
47
50
|
uint32_t* /* messageLen */,
|
|
@@ -49,8 +52,8 @@ using PayloadChannelReadFn = PayloadChannelReadFreeFn (*)(
|
|
|
49
52
|
uint8_t** /* payload */,
|
|
50
53
|
uint32_t* /* payloadLen */,
|
|
51
54
|
size_t* /* payloadCapacity */,
|
|
52
|
-
// This is `uv_async_t` handle that can be called later with `uv_async_send()`
|
|
53
|
-
// data to read.
|
|
55
|
+
// This is `uv_async_t` handle that can be called later with `uv_async_send()`
|
|
56
|
+
// when there is more data to read.
|
|
54
57
|
const void* /* handle */,
|
|
55
58
|
PayloadChannelReadCtx /* ctx */);
|
|
56
59
|
|
package/worker/meson.build
CHANGED
|
@@ -89,6 +89,7 @@ common_sources = [
|
|
|
89
89
|
'src/RTC/RtpObserver.cpp',
|
|
90
90
|
'src/RTC/RtpPacket.cpp',
|
|
91
91
|
'src/RTC/RtpProbationGenerator.cpp',
|
|
92
|
+
'src/RTC/RtpRetransmissionBuffer.cpp',
|
|
92
93
|
'src/RTC/RtpStream.cpp',
|
|
93
94
|
'src/RTC/RtpStreamRecv.cpp',
|
|
94
95
|
'src/RTC/RtpStreamSend.cpp',
|
|
@@ -289,6 +290,7 @@ mediasoup_worker_test = executable(
|
|
|
289
290
|
'test/src/RTC/TestRateCalculator.cpp',
|
|
290
291
|
'test/src/RTC/TestRtpPacket.cpp',
|
|
291
292
|
'test/src/RTC/TestRtpPacketH264Svc.cpp',
|
|
293
|
+
'test/src/RTC/TestRtpRetransmissionBuffer.cpp',
|
|
292
294
|
'test/src/RTC/TestRtpStreamSend.cpp',
|
|
293
295
|
'test/src/RTC/TestRtpStreamRecv.cpp',
|
|
294
296
|
'test/src/RTC/TestSeqManager.cpp',
|
|
@@ -352,6 +354,7 @@ executable(
|
|
|
352
354
|
'fuzzer/src/FuzzerUtils.cpp',
|
|
353
355
|
'fuzzer/src/RTC/FuzzerStunPacket.cpp',
|
|
354
356
|
'fuzzer/src/RTC/FuzzerRtpPacket.cpp',
|
|
357
|
+
'fuzzer/src/RTC/FuzzerRtpRetransmissionBuffer.cpp',
|
|
355
358
|
'fuzzer/src/RTC/FuzzerRtpStreamSend.cpp',
|
|
356
359
|
'fuzzer/src/RTC/FuzzerTrendCalculator.cpp',
|
|
357
360
|
'fuzzer/src/RTC/RTCP/FuzzerBye.cpp',
|