Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
18f17d12
提交
18f17d12
authored
12月 09, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Some work on RtpStream
上级
32bdc24e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
136 行增加
和
0 行删除
+136
-0
RtpStream.h
worker/include/RTC/RtpStream.h
+19
-0
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+117
-0
没有找到文件。
worker/include/RTC/RtpStream.h
浏览文件 @
18f17d12
...
@@ -20,9 +20,28 @@ namespace RTC
...
@@ -20,9 +20,28 @@ namespace RTC
RtpStream
(
size_t
bufferSize
);
RtpStream
(
size_t
bufferSize
);
~
RtpStream
();
~
RtpStream
();
bool
ReceivePacket
(
RTC
::
RtpPacket
*
packet
);
// TODO: REMOVE
bool
AddPacket
(
RTC
::
RtpPacket
*
packet
);
bool
AddPacket
(
RTC
::
RtpPacket
*
packet
);
private
:
private
:
void
InitSeq
(
uint16_t
seq
);
bool
UpdateSeq
(
uint16_t
seq
);
private
:
bool
started
=
false
;
// Whether at least a RTP packet has been received.
// https://tools.ietf.org/html/rfc3550#appendix-A.1 stuff.
uint16_t
max_seq
=
0
;
// Highest seq. number seen.
uint32_t
cycles
=
0
;
// Shifted count of seq. number cycles.
uint32_t
base_seq
=
0
;
// Base seq number.
uint32_t
bad_seq
=
0
;
// Last 'bad' seq number + 1.
uint32_t
probation
=
0
;
// Seq. packets till source is valid.
uint32_t
received
=
0
;
// Packets received.
uint32_t
expected_prior
=
0
;
// Packet expected at last interval.
uint32_t
received_prior
=
0
;
// Packet received at last interval.
uint32_t
transit
=
0
;
// Relative trans time for prev pkt.
uint32_t
jitter
=
0
;
// Estimated jitter.
// Others.
std
::
vector
<
StorageItem
>
storage
;
std
::
vector
<
StorageItem
>
storage
;
typedef
std
::
list
<
RTC
::
RtpPacket
*>
Packets
;
typedef
std
::
list
<
RTC
::
RtpPacket
*>
Packets
;
Packets
packets
;
Packets
packets
;
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
18f17d12
...
@@ -5,6 +5,11 @@
...
@@ -5,6 +5,11 @@
#include "RTC/RtpStream.h"
#include "RTC/RtpStream.h"
#include "Logger.h"
#include "Logger.h"
#define MIN_SEQUENTIAL 2
#define MAX_DROPOUT 3000
#define MAX_MISORDER 100
#define RTP_SEQ_MOD (1<<16)
namespace
RTC
namespace
RTC
{
{
/* Instance methods. */
/* Instance methods. */
...
@@ -26,6 +31,118 @@ namespace RTC
...
@@ -26,6 +31,118 @@ namespace RTC
}
}
}
}
bool
RtpStream
::
ReceivePacket
(
RTC
::
RtpPacket
*
packet
)
{
MS_TRACE
();
uint16_t
seq
=
packet
->
GetSequenceNumber
();
// If this is the first packet seen, initialize stuff.
if
(
!
this
->
started
)
{
this
->
started
=
true
;
InitSeq
(
seq
);
this
->
max_seq
=
seq
-
1
;
this
->
probation
=
MIN_SEQUENTIAL
;
}
// TODO: If this returns true, store the packet and return true just
// if it's not a duplicated packet.
UpdateSeq
(
seq
);
return
true
;
}
void
RtpStream
::
InitSeq
(
uint16_t
seq
)
{
MS_TRACE
();
this
->
base_seq
=
seq
;
this
->
max_seq
=
seq
;
this
->
bad_seq
=
RTP_SEQ_MOD
+
1
;
// So seq == bad_seq is false.
this
->
cycles
=
0
;
this
->
received
=
0
;
this
->
received_prior
=
0
;
this
->
expected_prior
=
0
;
}
bool
RtpStream
::
UpdateSeq
(
uint16_t
seq
)
{
MS_TRACE
();
uint16_t
udelta
=
seq
-
this
->
max_seq
;
/*
* Source is not valid until MIN_SEQUENTIAL packets with
* sequential sequence numbers have been received.
*/
if
(
this
->
probation
)
{
// Packet is in sequence.
if
(
seq
==
this
->
max_seq
+
1
)
{
this
->
probation
--
;
this
->
max_seq
=
seq
;
if
(
this
->
probation
==
0
)
{
InitSeq
(
seq
);
this
->
received
++
;
return
true
;
}
}
else
{
this
->
probation
=
MIN_SEQUENTIAL
-
1
;
this
->
max_seq
=
seq
;
}
return
false
;
}
else
if
(
udelta
<
MAX_DROPOUT
)
{
// In order, with permissible gap.
if
(
seq
<
this
->
max_seq
)
{
// Sequence number wrapped: count another 64K cycle.
this
->
cycles
+=
RTP_SEQ_MOD
;
}
this
->
max_seq
=
seq
;
}
else
if
(
udelta
<=
RTP_SEQ_MOD
-
MAX_MISORDER
)
{
// The sequence number made a very large jump.
if
(
seq
==
this
->
bad_seq
)
{
/*
* Two sequential packets -- assume that the other side
* restarted without telling us so just re-sync
* (i.e., pretend this was the first packet).
*/
InitSeq
(
seq
);
}
else
{
this
->
bad_seq
=
(
seq
+
1
)
&
(
RTP_SEQ_MOD
-
1
);
return
false
;
}
}
else
{
// Duplicate or reordered packet.
// TODO: so what? just return true?
}
this
->
received
++
;
return
true
;
}
// TODO: REMOVE
bool
RtpStream
::
AddPacket
(
RTC
::
RtpPacket
*
packet
)
bool
RtpStream
::
AddPacket
(
RTC
::
RtpPacket
*
packet
)
{
{
MS_TRACE
();
MS_TRACE
();
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论