Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
9ae56538
Unverified
提交
9ae56538
authored
3月 22, 2023
作者:
Iñaki Baz Castillo
提交者:
GitHub
3月 22, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
RtpRetransmissionBuffer: get rid of startSeq private member (#1029)
上级
5be8faa8
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
36 行增加
和
43 行删除
+36
-43
CHANGELOG.md
CHANGELOG.md
+6
-1
RtpRetransmissionBuffer.hpp
worker/include/RTC/RtpRetransmissionBuffer.hpp
+0
-2
RtpRetransmissionBuffer.cpp
worker/src/RTC/RtpRetransmissionBuffer.cpp
+30
-40
没有找到文件。
CHANGELOG.md
浏览文件 @
9ae56538
# Changelog
# Changelog
### NEXT
*
`RtpRetransmissionBuffer`
: Get rid of not necessary
`startSeq`
private member (
[
PR #1029
](
https://github.com/versatica/mediasoup/pull/1029
)
.
### 3.11.15
### 3.11.15
*
`RtpRetransmissionBuffer
.cpp
`
: Fix crash and add fuzzer (
[
PR #1028
](
https://github.com/versatica/mediasoup/pull/1028
)
.
*
`RtpRetransmissionBuffer`
: Fix crash and add fuzzer (
[
PR #1028
](
https://github.com/versatica/mediasoup/pull/1028
)
.
*
Update NPM deps.
*
Update NPM deps.
...
...
worker/include/RTC/RtpRetransmissionBuffer.hpp
浏览文件 @
9ae56538
...
@@ -60,8 +60,6 @@ namespace RTC
...
@@ -60,8 +60,6 @@ namespace RTC
uint16_t
maxItems
;
uint16_t
maxItems
;
uint32_t
maxRetransmissionDelayMs
;
uint32_t
maxRetransmissionDelayMs
;
uint32_t
clockRate
;
uint32_t
clockRate
;
// Others.
uint16_t
startSeq
{
0u
};
};
};
}
// namespace RTC
}
// namespace RTC
...
...
worker/src/RTC/RtpRetransmissionBuffer.cpp
浏览文件 @
9ae56538
...
@@ -29,17 +29,19 @@ namespace RTC
...
@@ -29,17 +29,19 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
if
(
this
->
buffer
.
empty
())
const
auto
*
oldestItem
=
GetOldest
();
if
(
!
oldestItem
)
{
{
return
nullptr
;
return
nullptr
;
}
}
if
(
RTC
::
SeqManager
<
uint16_t
>::
IsSeqLowerThan
(
seq
,
this
->
startSeq
))
if
(
RTC
::
SeqManager
<
uint16_t
>::
IsSeqLowerThan
(
seq
,
oldestItem
->
sequenceNumber
))
{
{
return
nullptr
;
return
nullptr
;
}
}
auto
idx
=
static_cast
<
uint16_t
>
(
seq
-
this
->
startSeq
);
const
auto
idx
=
static_cast
<
uint16_t
>
(
seq
-
oldestItem
->
sequenceNumber
);
if
(
idx
>
static_cast
<
uint16_t
>
(
this
->
buffer
.
size
()
-
1
))
if
(
idx
>
static_cast
<
uint16_t
>
(
this
->
buffer
.
size
()
-
1
))
{
{
...
@@ -61,9 +63,9 @@ namespace RTC
...
@@ -61,9 +63,9 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
auto
ssrc
=
packet
->
GetSsrc
();
const
auto
ssrc
=
packet
->
GetSsrc
();
auto
seq
=
packet
->
GetSequenceNumber
();
const
auto
seq
=
packet
->
GetSequenceNumber
();
auto
timestamp
=
packet
->
GetTimestamp
();
const
auto
timestamp
=
packet
->
GetTimestamp
();
MS_DEBUG_DEV
(
"packet [seq:%"
PRIu16
", timestamp:%"
PRIu32
"]"
,
seq
,
timestamp
);
MS_DEBUG_DEV
(
"packet [seq:%"
PRIu16
", timestamp:%"
PRIu32
"]"
,
seq
,
timestamp
);
...
@@ -76,17 +78,14 @@ namespace RTC
...
@@ -76,17 +78,14 @@ namespace RTC
this
->
buffer
.
push_back
(
FillItem
(
item
,
packet
,
sharedPacket
));
this
->
buffer
.
push_back
(
FillItem
(
item
,
packet
,
sharedPacket
));
// Packet's seq number becomes startSeq.
this
->
startSeq
=
seq
;
return
;
return
;
}
}
// Clear too old packets in the buffer.
// Clear too old packets in the buffer.
ClearTooOld
();
ClearTooOld
();
auto
*
oldestItem
=
GetOldest
();
const
auto
*
oldestItem
=
GetOldest
();
auto
*
newestItem
=
GetNewest
();
const
auto
*
newestItem
=
GetNewest
();
MS_ASSERT
(
oldestItem
!=
nullptr
,
"oldest item doesn't exist"
);
MS_ASSERT
(
oldestItem
!=
nullptr
,
"oldest item doesn't exist"
);
MS_ASSERT
(
newestItem
!=
nullptr
,
"newest item doesn't exist"
);
MS_ASSERT
(
newestItem
!=
nullptr
,
"newest item doesn't exist"
);
...
@@ -120,7 +119,7 @@ namespace RTC
...
@@ -120,7 +119,7 @@ namespace RTC
// the buffer.
// the buffer.
if
(
this
->
buffer
.
size
()
+
numBlankSlots
+
1
>
this
->
maxItems
)
if
(
this
->
buffer
.
size
()
+
numBlankSlots
+
1
>
this
->
maxItems
)
{
{
auto
numItemsToRemove
=
const
auto
numItemsToRemove
=
static_cast
<
uint16_t
>
(
this
->
buffer
.
size
()
+
numBlankSlots
+
1
-
this
->
maxItems
);
static_cast
<
uint16_t
>
(
this
->
buffer
.
size
()
+
numBlankSlots
+
1
-
this
->
maxItems
);
// If num of items to be removed exceed buffer size minus one (needed to
// If num of items to be removed exceed buffer size minus one (needed to
...
@@ -138,9 +137,6 @@ namespace RTC
...
@@ -138,9 +137,6 @@ namespace RTC
numBlankSlots
=
0u
;
numBlankSlots
=
0u
;
Clear
();
Clear
();
// After clearing the buffer, update startSeq.
this
->
startSeq
=
seq
;
}
}
else
else
{
{
...
@@ -203,7 +199,7 @@ namespace RTC
...
@@ -203,7 +199,7 @@ namespace RTC
// Calculate how many blank slots it would be necessary to add when
// Calculate how many blank slots it would be necessary to add when
// pushing new item to the fton of the buffer.
// pushing new item to the fton of the buffer.
auto
numBlankSlots
=
static_cast
<
uint16_t
>
(
oldestItem
->
sequenceNumber
-
seq
-
1
);
const
auto
numBlankSlots
=
static_cast
<
uint16_t
>
(
oldestItem
->
sequenceNumber
-
seq
-
1
);
// If adding this packet (and needed blank slots) to the front makes the
// If adding this packet (and needed blank slots) to the front makes the
// buffer exceed its max size, discard this packet.
// buffer exceed its max size, discard this packet.
...
@@ -230,9 +226,6 @@ namespace RTC
...
@@ -230,9 +226,6 @@ namespace RTC
auto
*
item
=
new
Item
();
auto
*
item
=
new
Item
();
this
->
buffer
.
push_front
(
FillItem
(
item
,
packet
,
sharedPacket
));
this
->
buffer
.
push_front
(
FillItem
(
item
,
packet
,
sharedPacket
));
// Packet's seq number becomes startSeq.
this
->
startSeq
=
seq
;
}
}
// Otherwise packet must be inserted between oldest and newest stored items
// Otherwise packet must be inserted between oldest and newest stored items
// so there is already an allocated slot for it.
// so there is already an allocated slot for it.
...
@@ -259,13 +252,13 @@ namespace RTC
...
@@ -259,13 +252,13 @@ namespace RTC
}
}
// idx is the intended position of the received packet in the buffer.
// idx is the intended position of the received packet in the buffer.
auto
idx
=
static_cast
<
uint16_t
>
(
seq
-
this
->
startSeq
);
const
auto
idx
=
static_cast
<
uint16_t
>
(
seq
-
oldestItem
->
sequenceNumber
);
// Validate that packet timestamp is equal or higher than the timestamp of
// Validate that packet timestamp is equal or higher than the timestamp of
// the immediate older packet (if any).
// the immediate older packet (if any).
for
(
auto
idx2
=
static_cast
<
int32_t
>
(
idx
-
1
);
idx2
>=
0
;
--
idx2
)
for
(
auto
idx2
=
static_cast
<
int32_t
>
(
idx
-
1
);
idx2
>=
0
;
--
idx2
)
{
{
auto
*
olderItem
=
this
->
buffer
.
at
(
idx2
);
const
auto
*
olderItem
=
this
->
buffer
.
at
(
idx2
);
// Blank slot, continue.
// Blank slot, continue.
if
(
!
olderItem
)
if
(
!
olderItem
)
...
@@ -296,7 +289,7 @@ namespace RTC
...
@@ -296,7 +289,7 @@ namespace RTC
// the immediate newer packet (if any).
// the immediate newer packet (if any).
for
(
auto
idx2
=
static_cast
<
size_t
>
(
idx
+
1
);
idx2
<
this
->
buffer
.
size
();
++
idx2
)
for
(
auto
idx2
=
static_cast
<
size_t
>
(
idx
+
1
);
idx2
<
this
->
buffer
.
size
();
++
idx2
)
{
{
auto
*
newerItem
=
this
->
buffer
.
at
(
idx2
);
const
auto
*
newerItem
=
this
->
buffer
.
at
(
idx2
);
// Blank slot, continue.
// Blank slot, continue.
if
(
!
newerItem
)
if
(
!
newerItem
)
...
@@ -354,7 +347,6 @@ namespace RTC
...
@@ -354,7 +347,6 @@ namespace RTC
}
}
this
->
buffer
.
clear
();
this
->
buffer
.
clear
();
this
->
startSeq
=
0u
;
}
}
void
RtpRetransmissionBuffer
::
Dump
()
const
void
RtpRetransmissionBuffer
::
Dump
()
const
...
@@ -362,11 +354,7 @@ namespace RTC
...
@@ -362,11 +354,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
MS_DUMP
(
"<RtpRetransmissionBuffer>"
);
MS_DUMP
(
"<RtpRetransmissionBuffer>"
);
MS_DUMP
(
MS_DUMP
(
" buffer [size:%zu, maxSize:%"
PRIu16
"]"
,
this
->
buffer
.
size
(),
this
->
maxItems
);
" buffer [size:%zu, maxSize:%"
PRIu16
", startSeq:%"
PRIu16
"]"
,
this
->
buffer
.
size
(),
this
->
maxItems
,
this
->
startSeq
);
if
(
this
->
buffer
.
size
()
>
0
)
if
(
this
->
buffer
.
size
()
>
0
)
{
{
const
auto
*
oldestItem
=
GetOldest
();
const
auto
*
oldestItem
=
GetOldest
();
...
@@ -392,14 +380,24 @@ namespace RTC
...
@@ -392,14 +380,24 @@ namespace RTC
{
{
MS_TRACE
();
MS_TRACE
();
return
this
->
Get
(
this
->
startSeq
);
if
(
this
->
buffer
.
empty
())
{
return
nullptr
;
}
return
this
->
buffer
.
front
();
}
}
RtpRetransmissionBuffer
::
Item
*
RtpRetransmissionBuffer
::
GetNewest
()
const
RtpRetransmissionBuffer
::
Item
*
RtpRetransmissionBuffer
::
GetNewest
()
const
{
{
MS_TRACE
();
MS_TRACE
();
return
this
->
Get
(
this
->
startSeq
+
this
->
buffer
.
size
()
-
1
);
if
(
this
->
buffer
.
empty
())
{
return
nullptr
;
}
return
this
->
buffer
.
back
();
}
}
void
RtpRetransmissionBuffer
::
RemoveOldest
()
void
RtpRetransmissionBuffer
::
RemoveOldest
()
...
@@ -411,7 +409,7 @@ namespace RTC
...
@@ -411,7 +409,7 @@ namespace RTC
return
;
return
;
}
}
auto
*
item
=
this
->
buffer
.
at
(
0
);
auto
*
item
=
this
->
buffer
.
front
(
);
// Reset the stored item (decrease RTP packet shared pointer counter).
// Reset the stored item (decrease RTP packet shared pointer counter).
item
->
Reset
();
item
->
Reset
();
...
@@ -419,7 +417,6 @@ namespace RTC
...
@@ -419,7 +417,6 @@ namespace RTC
delete
item
;
delete
item
;
this
->
buffer
.
pop_front
();
this
->
buffer
.
pop_front
();
this
->
startSeq
++
;
MS_DEBUG_DEV
(
"removed 1 item from the front"
);
MS_DEBUG_DEV
(
"removed 1 item from the front"
);
...
@@ -430,7 +427,6 @@ namespace RTC
...
@@ -430,7 +427,6 @@ namespace RTC
while
(
!
this
->
buffer
.
empty
()
&&
this
->
buffer
.
front
()
==
nullptr
)
while
(
!
this
->
buffer
.
empty
()
&&
this
->
buffer
.
front
()
==
nullptr
)
{
{
this
->
buffer
.
pop_front
();
this
->
buffer
.
pop_front
();
this
->
startSeq
++
;
++
numItemsRemoved
;
++
numItemsRemoved
;
}
}
...
@@ -439,12 +435,6 @@ namespace RTC
...
@@ -439,12 +435,6 @@ namespace RTC
{
{
MS_DEBUG_DEV
(
"removed 1 blank slot from the front"
);
MS_DEBUG_DEV
(
"removed 1 blank slot from the front"
);
}
}
// If we emptied the full buffer, reset startSeq.
if
(
this
->
buffer
.
empty
())
{
this
->
startSeq
=
0u
;
}
}
}
void
RtpRetransmissionBuffer
::
RemoveOldest
(
uint16_t
numItems
)
void
RtpRetransmissionBuffer
::
RemoveOldest
(
uint16_t
numItems
)
...
@@ -458,7 +448,7 @@ namespace RTC
...
@@ -458,7 +448,7 @@ namespace RTC
numItems
,
numItems
,
this
->
buffer
.
size
());
this
->
buffer
.
size
());
auto
intendedBufferSize
=
this
->
buffer
.
size
()
-
numItems
;
const
auto
intendedBufferSize
=
this
->
buffer
.
size
()
-
numItems
;
while
(
this
->
buffer
.
size
()
>
intendedBufferSize
)
while
(
this
->
buffer
.
size
()
>
intendedBufferSize
)
{
{
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论