Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
ede3644e
Unverified
提交
ede3644e
authored
8月 08, 2021
作者:
Junlong Zou
提交者:
GitHub
8月 08, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix timestamp when simulcast consumer switching layers (#626)
上级
b38e2a7b
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
12 行删除
+17
-12
SimulcastConsumer.hpp
worker/include/RTC/SimulcastConsumer.hpp
+1
-0
SimulcastConsumer.cpp
worker/src/RTC/SimulcastConsumer.cpp
+16
-12
没有找到文件。
worker/include/RTC/SimulcastConsumer.hpp
浏览文件 @
ede3644e
...
@@ -101,6 +101,7 @@ namespace RTC
...
@@ -101,6 +101,7 @@ namespace RTC
std
::
vector
<
RTC
::
RtpStreamSend
*>
rtpStreams
;
std
::
vector
<
RTC
::
RtpStreamSend
*>
rtpStreams
;
std
::
vector
<
RTC
::
RtpStream
*>
producerRtpStreams
;
// Indexed by spatial layer.
std
::
vector
<
RTC
::
RtpStream
*>
producerRtpStreams
;
// Indexed by spatial layer.
bool
syncRequired
{
false
};
bool
syncRequired
{
false
};
bool
lastSentPacketHasMarker
{
false
};
RTC
::
SeqManager
<
uint16_t
>
rtpSeqManager
;
RTC
::
SeqManager
<
uint16_t
>
rtpSeqManager
;
int16_t
preferredSpatialLayer
{
-
1
};
int16_t
preferredSpatialLayer
{
-
1
};
int16_t
preferredTemporalLayer
{
-
1
};
int16_t
preferredTemporalLayer
{
-
1
};
...
...
worker/src/RTC/SimulcastConsumer.cpp
浏览文件 @
ede3644e
...
@@ -754,9 +754,14 @@ namespace RTC
...
@@ -754,9 +754,14 @@ namespace RTC
// https://en.wikipedia.org/wiki/Audio-to-video_synchronization#Recommendations
// https://en.wikipedia.org/wiki/Audio-to-video_synchronization#Recommendations
static
const
uint32_t
MaxExtraOffsetMs
{
75u
};
static
const
uint32_t
MaxExtraOffsetMs
{
75u
};
// Outgoing packet matches the highest timestamp seen in the previous stream.
// Apply an expected offset for a new frame in a 30fps stream.
static
const
uint8_t
MsOffset
{
33u
};
// (1 / 30 * 1000).
int64_t
maxTsExtraOffset
=
MaxExtraOffsetMs
*
this
->
rtpStream
->
GetClockRate
()
/
1000
;
int64_t
maxTsExtraOffset
=
MaxExtraOffsetMs
*
this
->
rtpStream
->
GetClockRate
()
/
1000
;
uint32_t
tsExtraOffset
=
this
->
rtpStream
->
GetMaxPacketTs
()
-
packet
->
GetTimestamp
()
+
tsOffset
;
uint32_t
tsExtraOffset
=
this
->
rtpStream
->
GetMaxPacketTs
()
-
packet
->
GetTimestamp
()
+
tsOffset
+
MsOffset
*
this
->
rtpStream
->
GetClockRate
()
/
1000
;
// NOTE: Don't ask for a key frame if already done.
// NOTE: Don't ask for a key frame if already done.
if
(
this
->
keyFrameForTsOffsetRequested
)
if
(
this
->
keyFrameForTsOffsetRequested
)
...
@@ -787,15 +792,6 @@ namespace RTC
...
@@ -787,15 +792,6 @@ namespace RTC
return
;
return
;
}
}
// It's common that, when switching spatial layer, the resulting TS for the
// outgoing packet matches the highest seen in the previous stream. Fix it.
else
if
(
tsExtraOffset
==
0u
)
{
// Apply an expected offset for a new frame in a 30fps stream.
static
const
uint8_t
MsOffset
{
33u
};
// (1 / 30 * 1000).
tsExtraOffset
=
MsOffset
*
this
->
rtpStream
->
GetClockRate
()
/
1000
;
}
if
(
tsExtraOffset
>
0u
)
if
(
tsExtraOffset
>
0u
)
{
{
...
@@ -813,7 +809,12 @@ namespace RTC
...
@@ -813,7 +809,12 @@ namespace RTC
this
->
tsOffset
=
tsOffset
;
this
->
tsOffset
=
tsOffset
;
// Sync our RTP stream's sequence number.
// Sync our RTP stream's sequence number.
this
->
rtpSeqManager
.
Sync
(
packet
->
GetSequenceNumber
()
-
1
);
// If previous frame has not been sent completely when we switch layer, we can tell
// libwebrtc that previous frame is incomplete by skipping one RTP sequence number.
// 'packet->GetSequenceNumber() -2' may increase SeqManager::base and increase the
// output sequence number.
// https://github.com/versatica/mediasoup/issues/408
this
->
rtpSeqManager
.
Sync
(
packet
->
GetSequenceNumber
()
-
(
this
->
lastSentPacketHasMarker
?
1
:
2
));
this
->
encodingContext
->
SyncRequired
();
this
->
encodingContext
->
SyncRequired
();
...
@@ -891,6 +892,9 @@ namespace RTC
...
@@ -891,6 +892,9 @@ namespace RTC
// Process the packet.
// Process the packet.
if
(
this
->
rtpStream
->
ReceivePacket
(
packet
))
if
(
this
->
rtpStream
->
ReceivePacket
(
packet
))
{
{
if
(
this
->
rtpSeqManager
.
GetMaxOutput
()
==
packet
->
GetSequenceNumber
())
this
->
lastSentPacketHasMarker
=
packet
->
HasMarker
();
// Send the packet.
// Send the packet.
this
->
listener
->
OnConsumerSendRtpPacket
(
this
,
packet
);
this
->
listener
->
OnConsumerSendRtpPacket
(
this
,
packet
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论