mediasoup 3.11.17 → 3.11.18
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 +1 -1
- package/worker/include/RTC/RtpRetransmissionBuffer.hpp +1 -1
- package/worker/src/RTC/RtpRetransmissionBuffer.cpp +40 -12
- package/worker/src/RTC/RtpStream.cpp +1 -1
- package/worker/src/RTC/RtpStreamSend.cpp +1 -1
- package/worker/test/src/RTC/TestRtpRetransmissionBuffer.cpp +23 -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.18',
|
|
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
|
@@ -46,7 +46,7 @@ namespace RTC
|
|
|
46
46
|
Item* GetNewest() const;
|
|
47
47
|
void RemoveOldest();
|
|
48
48
|
void RemoveOldest(uint16_t numItems);
|
|
49
|
-
|
|
49
|
+
bool ClearTooOld(uint32_t newestTimestamp);
|
|
50
50
|
bool IsTooOld(uint32_t timestamp, uint32_t newestTimestamp) const;
|
|
51
51
|
Item* FillItem(
|
|
52
52
|
Item* item, RTC::RtpPacket* packet, std::shared_ptr<RTC::RtpPacket>& sharedPacket) const;
|
|
@@ -81,11 +81,41 @@ namespace RTC
|
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
auto* oldestItem = GetOldest();
|
|
85
|
+
auto* newestItem = GetNewest();
|
|
86
|
+
|
|
84
87
|
// Clear too old packets in the buffer.
|
|
85
|
-
|
|
88
|
+
// NOTE: Here we must consider the case in which, due for example to huge
|
|
89
|
+
// packet loss, received packet has higher timestamp but "older" seq number
|
|
90
|
+
// than the newest packet in the buffer and, if so, use it to clear too old
|
|
91
|
+
// packets rather than the newest packet in the buffer.
|
|
92
|
+
auto newestTimestamp =
|
|
93
|
+
RTC::SeqManager<uint32_t>::IsSeqHigherThan(timestamp, newestItem->timestamp)
|
|
94
|
+
? timestamp
|
|
95
|
+
: newestItem->timestamp;
|
|
96
|
+
|
|
97
|
+
// ClearTooOld() returns true if at least one packet has been removed from
|
|
98
|
+
// the front.
|
|
99
|
+
if (ClearTooOld(newestTimestamp))
|
|
100
|
+
{
|
|
101
|
+
// Buffer content has been modified so we must check it again.
|
|
102
|
+
if (this->buffer.empty())
|
|
103
|
+
{
|
|
104
|
+
MS_DEBUG_DEV(
|
|
105
|
+
"buffer empty after clearing too old packets [seq:%" PRIu16 ", timestamp:%" PRIu32 "]",
|
|
106
|
+
seq,
|
|
107
|
+
timestamp);
|
|
86
108
|
|
|
87
|
-
|
|
88
|
-
|
|
109
|
+
auto* item = new Item();
|
|
110
|
+
|
|
111
|
+
this->buffer.push_back(FillItem(item, packet, sharedPacket));
|
|
112
|
+
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
oldestItem = GetOldest();
|
|
117
|
+
newestItem = GetNewest();
|
|
118
|
+
}
|
|
89
119
|
|
|
90
120
|
MS_ASSERT(oldestItem != nullptr, "oldest item doesn't exist");
|
|
91
121
|
MS_ASSERT(newestItem != nullptr, "newest item doesn't exist");
|
|
@@ -456,26 +486,22 @@ namespace RTC
|
|
|
456
486
|
}
|
|
457
487
|
}
|
|
458
488
|
|
|
459
|
-
|
|
489
|
+
bool RtpRetransmissionBuffer::ClearTooOld(uint32_t newestTimestamp)
|
|
460
490
|
{
|
|
461
491
|
MS_TRACE();
|
|
462
492
|
|
|
463
|
-
const auto* newestItem = GetNewest();
|
|
464
|
-
|
|
465
|
-
if (!newestItem)
|
|
466
|
-
{
|
|
467
|
-
return;
|
|
468
|
-
}
|
|
469
|
-
|
|
470
493
|
RtpRetransmissionBuffer::Item* oldestItem{ nullptr };
|
|
494
|
+
bool itemsRemoved{ false };
|
|
471
495
|
|
|
472
496
|
// Go through all buffer items starting with the first and free all items
|
|
473
497
|
// that contain too old packets.
|
|
474
498
|
while ((oldestItem = GetOldest()))
|
|
475
499
|
{
|
|
476
|
-
if (IsTooOld(oldestItem->timestamp,
|
|
500
|
+
if (IsTooOld(oldestItem->timestamp, newestTimestamp))
|
|
477
501
|
{
|
|
478
502
|
RemoveOldest();
|
|
503
|
+
|
|
504
|
+
itemsRemoved = true;
|
|
479
505
|
}
|
|
480
506
|
// If current oldest stored packet is not too old, exit the loop since we
|
|
481
507
|
// know that packets stored after it are guaranteed to be newer.
|
|
@@ -484,6 +510,8 @@ namespace RTC
|
|
|
484
510
|
break;
|
|
485
511
|
}
|
|
486
512
|
}
|
|
513
|
+
|
|
514
|
+
return itemsRemoved;
|
|
487
515
|
}
|
|
488
516
|
|
|
489
517
|
bool RtpRetransmissionBuffer::IsTooOld(uint32_t timestamp, uint32_t newestTimestamp) const
|
|
@@ -193,7 +193,7 @@ namespace RTC
|
|
|
193
193
|
this->maxSeq = seq;
|
|
194
194
|
}
|
|
195
195
|
// Too old packet received (older than the allowed misorder).
|
|
196
|
-
// Or
|
|
196
|
+
// Or too new packet (more than acceptable dropout).
|
|
197
197
|
else if (udelta <= RtpSeqMod - MaxMisorder)
|
|
198
198
|
{
|
|
199
199
|
// The sequence number made a very large jump. If two sequential packets
|
|
@@ -12,7 +12,7 @@ namespace RTC
|
|
|
12
12
|
/* Static. */
|
|
13
13
|
|
|
14
14
|
// Limit max number of items in the retransmission buffer.
|
|
15
|
-
static constexpr size_t RetransmissionBufferMaxItems{
|
|
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
18
|
thread_local static std::vector<RTC::RtpRetransmissionBuffer::Item*> RetransmissionContainer(
|
|
@@ -230,6 +230,29 @@ SCENARIO("RtpRetransmissionBuffer", "[rtp][rtx]")
|
|
|
230
230
|
// clang-format on
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
+
SECTION("packet with very newest timestamp is inserted as newest item despite its seq is old")
|
|
234
|
+
{
|
|
235
|
+
uint16_t maxItems{ 4 };
|
|
236
|
+
uint32_t maxRetransmissionDelayMs{ 2000u };
|
|
237
|
+
uint32_t clockRate{ 90000 };
|
|
238
|
+
|
|
239
|
+
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
|
|
240
|
+
|
|
241
|
+
// Scenario based on https://github.com/versatica/mediasoup/issues/1037.
|
|
242
|
+
|
|
243
|
+
myRetransmissionBuffer.Insert(24816, 1024930187);
|
|
244
|
+
myRetransmissionBuffer.Insert(24980, 1025106407);
|
|
245
|
+
myRetransmissionBuffer.Insert(18365, 1026593387);
|
|
246
|
+
|
|
247
|
+
// clang-format off
|
|
248
|
+
myRetransmissionBuffer.AssertBuffer(
|
|
249
|
+
{
|
|
250
|
+
{ true, 18365, 1026593387 }
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
// clang-format on
|
|
254
|
+
}
|
|
255
|
+
|
|
233
256
|
SECTION("fuzzer generated packets")
|
|
234
257
|
{
|
|
235
258
|
uint16_t maxItems{ 2500u };
|