Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
908a9ab8
Unverified
提交
908a9ab8
authored
6月 09, 2022
作者:
Dmitry Dolzhenko
提交者:
GitHub
6月 09, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix old buffer items cleanup in `RTC::RateCalculator` (#830)
上级
89a6c5c2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
23 行增加
和
20 行删除
+23
-20
RateCalculator.cpp
worker/src/RTC/RateCalculator.cpp
+7
-20
TestRateCalculator.cpp
worker/test/src/RTC/TestRateCalculator.cpp
+16
-0
没有找到文件。
worker/src/RTC/RateCalculator.cpp
浏览文件 @
908a9ab8
...
@@ -29,22 +29,9 @@ namespace RTC
...
@@ -29,22 +29,9 @@ namespace RTC
if
(
this
->
newestItemIndex
>=
this
->
windowItems
)
if
(
this
->
newestItemIndex
>=
this
->
windowItems
)
this
->
newestItemIndex
=
0
;
this
->
newestItemIndex
=
0
;
// Newest index overlaps with the oldest one, remove it.
MS_ASSERT
(
if
(
this
->
newestItemIndex
==
this
->
oldestItemIndex
&&
this
->
oldestItemIndex
!=
-
1
)
this
->
newestItemIndex
!=
this
->
oldestItemIndex
||
this
->
oldestItemIndex
==
-
1
,
{
"newest index overlaps with the oldest one"
);
MS_WARN_TAG
(
info
,
"calculation buffer full, windowSizeMs:%zu ms windowItems:%"
PRIu16
,
this
->
windowSizeMs
,
this
->
windowItems
);
BufferItem
&
oldestItem
=
this
->
buffer
[
this
->
oldestItemIndex
];
this
->
totalCount
-=
oldestItem
.
count
;
oldestItem
.
count
=
0u
;
oldestItem
.
time
=
0u
;
if
(
++
this
->
oldestItemIndex
>=
this
->
windowItems
)
this
->
oldestItemIndex
=
0
;
}
// Set the newest item.
// Set the newest item.
BufferItem
&
item
=
this
->
buffer
[
this
->
newestItemIndex
];
BufferItem
&
item
=
this
->
buffer
[
this
->
newestItemIndex
];
...
@@ -98,21 +85,21 @@ namespace RTC
...
@@ -98,21 +85,21 @@ namespace RTC
if
(
this
->
newestItemIndex
<
0
||
this
->
oldestItemIndex
<
0
)
if
(
this
->
newestItemIndex
<
0
||
this
->
oldestItemIndex
<
0
)
return
;
return
;
uint64_t
new
o
ldestTime
=
nowMs
-
this
->
windowSizeMs
;
uint64_t
new
O
ldestTime
=
nowMs
-
this
->
windowSizeMs
;
// Oldest item already removed.
// Oldest item already removed.
if
(
new
oldestTime
<=
this
->
oldestItemStartTime
)
if
(
new
OldestTime
<
this
->
oldestItemStartTime
)
return
;
return
;
// A whole window size time has elapsed since last entry. Reset the buffer.
// A whole window size time has elapsed since last entry. Reset the buffer.
if
(
new
oldestTime
>
this
->
newestItemStartTime
)
if
(
new
OldestTime
>=
this
->
newestItemStartTime
)
{
{
Reset
();
Reset
();
return
;
return
;
}
}
while
(
this
->
oldestItemStartTime
<
newoldes
tTime
)
while
(
newOldestTime
>=
this
->
oldestItemStar
tTime
)
{
{
BufferItem
&
oldestItem
=
this
->
buffer
[
this
->
oldestItemIndex
];
BufferItem
&
oldestItem
=
this
->
buffer
[
this
->
oldestItemIndex
];
this
->
totalCount
-=
oldestItem
.
count
;
this
->
totalCount
-=
oldestItem
.
count
;
...
...
worker/test/src/RTC/TestRateCalculator.cpp
浏览文件 @
908a9ab8
...
@@ -59,6 +59,22 @@ SCENARIO("Bitrate calculator", "[rtp][bitrate]")
...
@@ -59,6 +59,22 @@ SCENARIO("Bitrate calculator", "[rtp][bitrate]")
validate
(
rate
,
nowMs
,
input
);
validate
(
rate
,
nowMs
,
input
);
}
}
SECTION
(
"receive item every 1000 ms"
)
{
RateCalculator
rate
(
1000
,
8000
,
100
);
// clang-format off
std
::
vector
<
data
>
input
=
{
{
0
,
5
,
40
},
{
1000
,
5
,
40
},
{
2000
,
5
,
40
}
};
// clang-format on
validate
(
rate
,
nowMs
,
input
);
}
SECTION
(
"slide"
)
SECTION
(
"slide"
)
{
{
RateCalculator
rate
(
1000
,
8000
,
1000
);
RateCalculator
rate
(
1000
,
8000
,
1000
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论