Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
e7c0fe11
提交
e7c0fe11
authored
9月 12, 2017
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consumer: Fix RTP sequence number when switching streams
上级
0d23c80c
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
60 行增加
和
15 行删除
+60
-15
Consumer.hpp
worker/include/RTC/Consumer.hpp
+1
-0
Consumer.cpp
worker/src/RTC/Consumer.cpp
+21
-9
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+15
-6
RtpStreamRecv.cpp
worker/src/RTC/RtpStreamRecv.cpp
+23
-0
没有找到文件。
worker/include/RTC/Consumer.hpp
浏览文件 @
e7c0fe11
...
@@ -94,6 +94,7 @@ namespace RTC
...
@@ -94,6 +94,7 @@ namespace RTC
RTC
::
RtpDataCounter
retransmittedCounter
;
RTC
::
RtpDataCounter
retransmittedCounter
;
// RTP sequence number and timestamp.
// RTP sequence number and timestamp.
uint16_t
seqNum
{
0
};
uint16_t
seqNum
{
0
};
uint16_t
maxSeqNum
{
0
};
uint32_t
rtpTimestamp
{
0
};
uint32_t
rtpTimestamp
{
0
};
uint16_t
lastRecvSeqNum
{
0
};
uint16_t
lastRecvSeqNum
{
0
};
uint32_t
lastRecvRtpTimestamp
{
0
};
uint32_t
lastRecvRtpTimestamp
{
0
};
...
...
worker/src/RTC/Consumer.cpp
浏览文件 @
e7c0fe11
...
@@ -24,7 +24,7 @@ namespace RTC
...
@@ -24,7 +24,7 @@ namespace RTC
MS_TRACE
();
MS_TRACE
();
// Initialize sequence number.
// Initialize sequence number.
this
->
s
eqNum
=
static_cast
<
uint16_t
>
(
Utils
::
Crypto
::
GetRandomUInt
(
0x00FF
,
0xFFFF
));
this
->
maxS
eqNum
=
static_cast
<
uint16_t
>
(
Utils
::
Crypto
::
GetRandomUInt
(
0x00FF
,
0xFFFF
));
// Set the RTCP report generation interval.
// Set the RTCP report generation interval.
if
(
this
->
kind
==
RTC
::
Media
::
Kind
::
AUDIO
)
if
(
this
->
kind
==
RTC
::
Media
::
Kind
::
AUDIO
)
...
@@ -331,19 +331,38 @@ namespace RTC
...
@@ -331,19 +331,38 @@ namespace RTC
// Check whether sequence number and timestamp sync is required.
// Check whether sequence number and timestamp sync is required.
if
(
this
->
syncRequired
)
if
(
this
->
syncRequired
)
{
{
this
->
seqNum
=
this
->
maxRecvSeqNum
+
1
;
this
->
seqNum
=
++
this
->
maxSeqNum
;
auto
now
=
static_cast
<
uint32_t
>
(
DepLibUV
::
GetTime
());
auto
now
=
static_cast
<
uint32_t
>
(
DepLibUV
::
GetTime
());
if
(
now
>
this
->
rtpTimestamp
)
if
(
now
>
this
->
rtpTimestamp
)
this
->
rtpTimestamp
=
now
;
this
->
rtpTimestamp
=
now
;
this
->
maxRecvExtendedSeqNum
=
packet
->
GetExtendedSequenceNumber
();
this
->
maxRecvSeqNum
=
packet
->
GetSequenceNumber
();
this
->
syncRequired
=
false
;
this
->
syncRequired
=
false
;
MS_DEBUG_TAG
(
rtp
,
"re-syncing Consumer stream [seqNum:%"
PRIu16
", maxRecvSeqNum:%"
PRIu16
", maxRecvExtendedSeqNum:%"
PRIu32
"]"
,
this
->
seqNum
,
this
->
maxRecvSeqNum
,
this
->
maxRecvExtendedSeqNum
);
}
}
else
else
{
{
this
->
seqNum
+=
packet
->
GetSequenceNumber
()
-
this
->
lastRecvSeqNum
;
this
->
seqNum
+=
packet
->
GetSequenceNumber
()
-
this
->
lastRecvSeqNum
;
this
->
rtpTimestamp
+=
packet
->
GetTimestamp
()
-
this
->
lastRecvRtpTimestamp
;
this
->
rtpTimestamp
+=
packet
->
GetTimestamp
()
-
this
->
lastRecvRtpTimestamp
;
// Update the max received sequence number if required.
if
(
packet
->
GetExtendedSequenceNumber
()
>
this
->
maxRecvExtendedSeqNum
)
{
this
->
maxRecvExtendedSeqNum
=
packet
->
GetExtendedSequenceNumber
();
this
->
maxRecvSeqNum
=
packet
->
GetSequenceNumber
();
this
->
maxSeqNum
=
this
->
seqNum
;
}
}
}
// Save the received sequence number.
// Save the received sequence number.
...
@@ -355,13 +374,6 @@ namespace RTC
...
@@ -355,13 +374,6 @@ namespace RTC
// Save real SSRC.
// Save real SSRC.
auto
ssrc
=
packet
->
GetSsrc
();
auto
ssrc
=
packet
->
GetSsrc
();
// Update the max received sequence number if required.
if
(
packet
->
GetExtendedSequenceNumber
()
>
this
->
maxRecvExtendedSeqNum
)
{
this
->
maxRecvExtendedSeqNum
=
packet
->
GetExtendedSequenceNumber
();
this
->
maxRecvSeqNum
=
this
->
lastRecvSeqNum
;
}
// Rewrite packet SSRC.
// Rewrite packet SSRC.
packet
->
SetSsrc
(
this
->
rtpParameters
.
encodings
[
0
].
ssrc
);
packet
->
SetSsrc
(
this
->
rtpParameters
.
encodings
[
0
].
ssrc
);
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
e7c0fe11
...
@@ -98,6 +98,10 @@ namespace RTC
...
@@ -98,6 +98,10 @@ namespace RTC
uint16_t
seq
=
packet
->
GetSequenceNumber
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
uint16_t
udelta
=
seq
-
this
->
maxSeq
;
uint16_t
udelta
=
seq
-
this
->
maxSeq
;
// If the new packet sequence number is greater than the max seen but not
// "so much bigger", accept it.
// NOTE: udelta also handles the case of a new cycle, this is:
// maxSeq:65536, seq:0 => udelta:1
if
(
udelta
<
MaxDropout
)
if
(
udelta
<
MaxDropout
)
{
{
// In order, with permissible gap.
// In order, with permissible gap.
...
@@ -109,16 +113,16 @@ namespace RTC
...
@@ -109,16 +113,16 @@ namespace RTC
this
->
maxSeq
=
seq
;
this
->
maxSeq
=
seq
;
}
}
// Too old packet received (older than the allowed misorder).
// Or to new packet (more than acceptable dropout).
else
if
(
udelta
<=
RtpSeqMod
-
MaxMisorder
)
else
if
(
udelta
<=
RtpSeqMod
-
MaxMisorder
)
{
{
// The sequence number made a very large jump.
// The sequence number made a very large jump. If two sequential packets
// arrive, accept the latter.
if
(
seq
==
this
->
badSeq
)
if
(
seq
==
this
->
badSeq
)
{
{
/*
// Two sequential packets. Assume that the other side restarted without
* Two sequential packets -- assume that the other side
// telling us so just re-sync (i.e., pretend this was the first packet).
* restarted without telling us so just re-sync
* (i.e., pretend this was the first packet).
*/
MS_WARN_TAG
(
MS_WARN_TAG
(
rtp
,
rtp
,
"too bad sequence number, re-syncing RTP [ssrc:%"
PRIu32
", seq:%"
PRIu16
"]"
,
"too bad sequence number, re-syncing RTP [ssrc:%"
PRIu32
", seq:%"
PRIu16
"]"
,
...
@@ -140,6 +144,11 @@ namespace RTC
...
@@ -140,6 +144,11 @@ namespace RTC
return
false
;
return
false
;
}
}
}
}
// Acceptable misorder.
else
{
// Do nothing.
}
this
->
received
++
;
this
->
received
++
;
...
...
worker/src/RTC/RtpStreamRecv.cpp
浏览文件 @
e7c0fe11
...
@@ -7,6 +7,10 @@
...
@@ -7,6 +7,10 @@
namespace
RTC
namespace
RTC
{
{
/* Static. */
static
constexpr
uint32_t
RtpSeqMod
{
1
<<
16
};
/* Instance methods. */
/* Instance methods. */
RtpStreamRecv
::
RtpStreamRecv
(
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
)
RtpStreamRecv
::
RtpStreamRecv
(
Listener
*
listener
,
RTC
::
RtpStream
::
Params
&
params
)
...
@@ -133,6 +137,25 @@ namespace RTC
...
@@ -133,6 +137,25 @@ namespace RTC
packet
->
SetExtendedSequenceNumber
(
packet
->
SetExtendedSequenceNumber
(
this
->
cycles
+
static_cast
<
uint32_t
>
(
packet
->
GetSequenceNumber
()));
this
->
cycles
+
static_cast
<
uint32_t
>
(
packet
->
GetSequenceNumber
()));
// Set the extended sequence number into the packet.
// Ensure that the NACKed packet sequence is not higher than the one of
// the media stream.
//
// We are in the same cycle.
if
(
packet
->
GetSequenceNumber
()
<=
this
->
maxSeq
)
{
packet
->
SetExtendedSequenceNumber
(
this
->
cycles
+
static_cast
<
uint32_t
>
(
packet
->
GetSequenceNumber
()));
}
// The nacket packet belongs to the previous cycle.
else
{
MS_DEBUG_TAG
(
rtx
,
"nacked packet belongs to previous seq cycle"
);
packet
->
SetExtendedSequenceNumber
(
this
->
cycles
-
RtpSeqMod
+
static_cast
<
uint32_t
>
(
packet
->
GetSequenceNumber
()));
}
// Pass the packet to the NackGenerator.
// Pass the packet to the NackGenerator.
if
(
this
->
params
.
useNack
)
if
(
this
->
params
.
useNack
)
this
->
nackGenerator
->
ReceivePacket
(
packet
);
this
->
nackGenerator
->
ReceivePacket
(
packet
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论