Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
02d6ea96
提交
02d6ea96
authored
5月 20, 2019
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
VP8 & H264: improve temporal layer switching (better currentTemporalLayer handling)
上级
4a75900b
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
57 行增加
和
58 行删除
+57
-58
PayloadDescriptorHandler.hpp
worker/include/RTC/Codecs/PayloadDescriptorHandler.hpp
+7
-12
H264.cpp
worker/src/RTC/Codecs/H264.cpp
+26
-26
VP8.cpp
worker/src/RTC/Codecs/VP8.cpp
+24
-20
没有找到文件。
worker/include/RTC/Codecs/PayloadDescriptorHandler.hpp
浏览文件 @
02d6ea96
...
@@ -15,7 +15,8 @@ namespace RTC
...
@@ -15,7 +15,8 @@ namespace RTC
virtual
void
Dump
()
const
=
0
;
virtual
void
Dump
()
const
=
0
;
};
};
// Encoding context used by PayloadDescriptorHandler to properly rewrite the PayloadDescriptor.
// Encoding context used by PayloadDescriptorHandler to properly rewrite the
// PayloadDescriptor.
class
EncodingContext
class
EncodingContext
{
{
public
:
public
:
...
@@ -29,11 +30,10 @@ namespace RTC
...
@@ -29,11 +30,10 @@ namespace RTC
};
};
public
:
public
:
virtual
void
SyncRequired
()
=
0
;
virtual
~
EncodingContext
()
=
default
;
virtual
void
SetPreferences
(
Preferences
preferences
);
public
:
public
:
virtual
~
EncodingContext
()
=
default
;
virtual
void
SyncRequired
()
=
0
;
public
:
public
:
Preferences
preferences
;
Preferences
preferences
;
...
@@ -41,6 +41,9 @@ namespace RTC
...
@@ -41,6 +41,9 @@ namespace RTC
class
PayloadDescriptorHandler
class
PayloadDescriptorHandler
{
{
public
:
virtual
~
PayloadDescriptorHandler
()
=
default
;
public
:
public
:
virtual
void
Dump
()
const
=
0
;
virtual
void
Dump
()
const
=
0
;
virtual
bool
Encode
(
RTC
::
Codecs
::
EncodingContext
*
context
,
uint8_t
*
data
)
=
0
;
virtual
bool
Encode
(
RTC
::
Codecs
::
EncodingContext
*
context
,
uint8_t
*
data
)
=
0
;
...
@@ -48,15 +51,7 @@ namespace RTC
...
@@ -48,15 +51,7 @@ namespace RTC
virtual
uint8_t
GetSpatialLayer
()
const
=
0
;
virtual
uint8_t
GetSpatialLayer
()
const
=
0
;
virtual
uint8_t
GetTemporalLayer
()
const
=
0
;
virtual
uint8_t
GetTemporalLayer
()
const
=
0
;
virtual
bool
IsKeyFrame
()
const
=
0
;
virtual
bool
IsKeyFrame
()
const
=
0
;
public
:
virtual
~
PayloadDescriptorHandler
()
=
default
;
};
};
inline
void
EncodingContext
::
SetPreferences
(
Preferences
preferences
)
{
this
->
preferences
=
preferences
;
}
}
// namespace Codecs
}
// namespace Codecs
}
// namespace RTC
}
// namespace RTC
...
...
worker/src/RTC/Codecs/H264.cpp
浏览文件 @
02d6ea96
...
@@ -172,37 +172,37 @@ namespace RTC
...
@@ -172,37 +172,37 @@ namespace RTC
auto
*
context
=
static_cast
<
RTC
::
Codecs
::
H264
::
EncodingContext
*>
(
encodingContext
);
auto
*
context
=
static_cast
<
RTC
::
Codecs
::
H264
::
EncodingContext
*>
(
encodingContext
);
// Check temporal layer.
// If a key frame, update currentTemporalLayer.
if
(
this
->
payloadDescriptor
->
isKeyFrame
)
context
->
currentTemporalLayer
=
std
::
numeric_limits
<
uint8_t
>::
max
();
// TODO: We should check incremental picture id here somehow and let it pass
// TODO: We should check incremental picture id here somehow and let it pass
// if so.
// if older than highest seen.
// Check temporal layer.
if
(
this
->
payloadDescriptor
->
tid
>
context
->
preferences
.
temporalLayer
)
if
(
this
->
payloadDescriptor
->
tid
>
context
->
preferences
.
temporalLayer
)
{
{
return
false
;
return
false
;
}
}
else
if
(
context
->
currentTemporalLayer
!=
context
->
preferences
.
temporalLayer
)
// Upgrade required. Drop current packet if base flag is not set.
{
// TODO: Cannot enable this until this issue is fixed (in libwebrtc?):
// Payload descriptor contains the target temporal layer.
// https://github.com/versatica/mediasoup/issues/306
if
(
this
->
payloadDescriptor
->
tid
==
context
->
preferences
.
temporalLayer
)
//
{
// clang-format off
// Upgrade required. Drop current packet if base flag is not set.
// else if (
// NOTE: It seems that Base Layer Sync flag is never set when in lowest
// this->payloadDescriptor->tid > context->currentTemporalLayer &&
// simulcast stream. We may need to implement "The Layer Refresh Request
// !this->payloadDescriptor->b
// (LRR) RTCP Feedback Message":
// )
// https://tools.ietf.org/html/draft-ietf-avtext-lrr-07)
// // clang-format on
//
// {
// clang-format off
// return false;
// if (
// }
// this->payloadDescriptor->tid > context->currentTemporalLayer &&
// !this->payloadDescriptor->b
// Update/fix currentTemporalLayer.
// )
if
(
this
->
payloadDescriptor
->
tid
>
context
->
currentTemporalLayer
)
// // clang-format on
context
->
currentTemporalLayer
=
this
->
payloadDescriptor
->
tid
;
// {
else
if
(
context
->
currentTemporalLayer
>
context
->
preferences
.
temporalLayer
)
// return false;
context
->
currentTemporalLayer
=
context
->
preferences
.
temporalLayer
;
// }
context
->
currentTemporalLayer
=
this
->
payloadDescriptor
->
tid
;
}
}
return
true
;
return
true
;
}
}
...
...
worker/src/RTC/Codecs/VP8.cpp
浏览文件 @
02d6ea96
...
@@ -232,9 +232,14 @@ namespace RTC
...
@@ -232,9 +232,14 @@ namespace RTC
{
{
context
->
pictureIdManager
.
Sync
(
this
->
payloadDescriptor
->
pictureId
-
1
);
context
->
pictureIdManager
.
Sync
(
this
->
payloadDescriptor
->
pictureId
-
1
);
context
->
tl0PictureIndexManager
.
Sync
(
this
->
payloadDescriptor
->
tl0PictureIndex
-
1
);
context
->
tl0PictureIndexManager
.
Sync
(
this
->
payloadDescriptor
->
tl0PictureIndex
-
1
);
context
->
syncRequired
=
false
;
context
->
syncRequired
=
false
;
}
}
// If a key frame, update currentTemporalLayer.
if
(
this
->
payloadDescriptor
->
isKeyFrame
)
context
->
currentTemporalLayer
=
std
::
numeric_limits
<
uint8_t
>::
max
();
// Incremental pictureId. Check the temporal layer.
// Incremental pictureId. Check the temporal layer.
// clang-format off
// clang-format off
if
(
if
(
...
@@ -254,27 +259,18 @@ namespace RTC
...
@@ -254,27 +259,18 @@ namespace RTC
return
false
;
return
false
;
}
}
else
if
(
context
->
currentTemporalLayer
!=
context
->
preferences
.
temporalLayer
)
// Upgrade required. Drop current packet if sync flag is not set.
// clang-format off
else
if
(
this
->
payloadDescriptor
->
tlIndex
>
context
->
currentTemporalLayer
&&
!
this
->
payloadDescriptor
->
y
)
// clang-format on
{
{
// Payload descriptor contains the target temporal layer.
context
->
pictureIdManager
.
Drop
(
this
->
payloadDescriptor
->
pictureId
);
if
(
this
->
payloadDescriptor
->
tlIndex
==
context
->
preferences
.
temporalLayer
)
context
->
tl0PictureIndexManager
.
Drop
(
this
->
payloadDescriptor
->
tl0PictureIndex
);
{
// Upgrade required. Drop current packet if sync flag is not set.
return
false
;
// clang-format off
if
(
this
->
payloadDescriptor
->
tlIndex
>
context
->
currentTemporalLayer
&&
!
this
->
payloadDescriptor
->
y
)
// clang-format on
{
context
->
pictureIdManager
.
Drop
(
this
->
payloadDescriptor
->
pictureId
);
context
->
tl0PictureIndexManager
.
Drop
(
this
->
payloadDescriptor
->
tl0PictureIndex
);
return
false
;
}
context
->
currentTemporalLayer
=
this
->
payloadDescriptor
->
tlIndex
;
}
}
}
}
}
...
@@ -284,7 +280,9 @@ namespace RTC
...
@@ -284,7 +280,9 @@ namespace RTC
// Do not send a dropped pictureId.
// Do not send a dropped pictureId.
if
(
!
context
->
pictureIdManager
.
Input
(
this
->
payloadDescriptor
->
pictureId
,
pictureId
))
if
(
!
context
->
pictureIdManager
.
Input
(
this
->
payloadDescriptor
->
pictureId
,
pictureId
))
{
return
false
;
return
false
;
}
// Do not send a dropped tl0PicutreIndex.
// Do not send a dropped tl0PicutreIndex.
if
(
!
context
->
tl0PictureIndexManager
.
Input
(
if
(
!
context
->
tl0PictureIndexManager
.
Input
(
...
@@ -293,6 +291,12 @@ namespace RTC
...
@@ -293,6 +291,12 @@ namespace RTC
return
false
;
return
false
;
}
}
// Update/fix currentTemporalLayer.
if
(
this
->
payloadDescriptor
->
tlIndex
>
context
->
currentTemporalLayer
)
context
->
currentTemporalLayer
=
this
->
payloadDescriptor
->
tlIndex
;
else
if
(
context
->
currentTemporalLayer
>
context
->
preferences
.
temporalLayer
)
context
->
currentTemporalLayer
=
context
->
preferences
.
temporalLayer
;
this
->
payloadDescriptor
->
Encode
(
data
,
pictureId
,
tl0PictureIndex
);
this
->
payloadDescriptor
->
Encode
(
data
,
pictureId
,
tl0PictureIndex
);
return
true
;
return
true
;
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论