Unverified 提交 97e3fd62 authored 作者: Iñaki Baz Castillo's avatar Iñaki Baz Castillo 提交者: GitHub

RTC::RtpRetransmissionBuffer: Handle corner case in which received packet has…

RTC::RtpRetransmissionBuffer: Handle corner case in which received packet has lower seq than newest packet in the buffer but higher timestamp (#1044)
上级 752883bc
......@@ -4,6 +4,7 @@
### NEXT
* `RtpStreamSend`: Reset RTP retransmission buffer upon RTP sequence number reset ([PR #1041](https://github.com/versatica/mediasoup/pull/1041)).
* `RtpRetransmissionBuffer`: Handle corner case in which received packet has lower seq than newest packet in the buffer but higher timestamp ([PR #1044](https://github.com/versatica/mediasoup/pull/1044)).
### 3.11.19
......
......@@ -30,7 +30,7 @@
"sctp": "^1.0.0",
"ts-jest": "^29.0.5",
"tsc-watch": "^6.0.0",
"typescript": "^5.0.2"
"typescript": "^5.0.3"
},
"engines": {
"node": ">=16"
......@@ -5808,9 +5808,9 @@
}
},
"node_modules/typescript": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz",
"integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==",
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz",
"integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
......@@ -10295,9 +10295,9 @@
"dev": true
},
"typescript": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.2.tgz",
"integrity": "sha512-wVORMBGO/FAs/++blGNeAVdbNKtIh1rbBL2EyQ1+J9lClJ93KiiKe8PmFIVdXhHcyv44SL9oglmfeSsndo0jRw==",
"version": "5.0.3",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.3.tgz",
"integrity": "sha512-xv8mOEDnigb/tN9PSMTwSEqAnUvkoXMQlicOb0IUVDBSQCgBSaAAROUZYy2IcUy5qU6XajK5jjjO7TMWqBTKZA==",
"dev": true
},
"unique-string": {
......
......@@ -105,6 +105,6 @@
"sctp": "^1.0.0",
"ts-jest": "^29.0.5",
"tsc-watch": "^6.0.0",
"typescript": "^5.0.2"
"typescript": "^5.0.3"
}
}
......@@ -84,6 +84,29 @@ namespace RTC
auto* oldestItem = GetOldest();
auto* newestItem = GetNewest();
// Special case: Received packet has lower seq than newest packet in the
// buffer, however its timestamp is higher. If so, clear the whole buffer.
if (
RTC::SeqManager<uint16_t>::IsSeqLowerThan(seq, newestItem->sequenceNumber) &&
RTC::SeqManager<uint32_t>::IsSeqHigherThan(timestamp, newestItem->timestamp))
{
MS_WARN_TAG(
rtp,
"packet has lower seq but higher timestamp than newest packet in the buffer, emptying the buffer [ssrc:%" PRIu32
", seq:%" PRIu16 ", timestamp:%" PRIu32 "]",
ssrc,
seq,
timestamp);
Clear();
auto* item = new Item();
this->buffer.push_back(FillItem(item, packet, sharedPacket));
return;
}
// Clear too old packets in the buffer.
// NOTE: Here we must consider the case in which, due for example to huge
// packet loss, received packet has higher timestamp but "older" seq number
......@@ -101,7 +124,8 @@ namespace RTC
// Buffer content has been modified so we must check it again.
if (this->buffer.empty())
{
MS_DEBUG_DEV(
MS_WARN_TAG(
rtp,
"buffer empty after clearing too old packets [seq:%" PRIu16 ", timestamp:%" PRIu32 "]",
seq,
timestamp);
......
......@@ -253,6 +253,30 @@ SCENARIO("RtpRetransmissionBuffer", "[rtp][rtx]")
// clang-format on
}
SECTION(
"packet with lower seq than newest packet in the buffer and higher timestamp forces buffer emptying")
{
uint16_t maxItems{ 4 };
uint32_t maxRetransmissionDelayMs{ 2000u };
uint32_t clockRate{ 90000 };
RtpMyRetransmissionBuffer myRetransmissionBuffer(maxItems, maxRetransmissionDelayMs, clockRate);
myRetransmissionBuffer.Insert(33331, 1000000001);
myRetransmissionBuffer.Insert(33332, 1000000002);
myRetransmissionBuffer.Insert(33330, 1000000003);
myRetransmissionBuffer.Dump();
// clang-format off
myRetransmissionBuffer.AssertBuffer(
{
{ true, 33330, 1000000003 }
}
);
// clang-format on
}
SECTION("fuzzer generated packets")
{
uint16_t maxItems{ 2500u };
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论