Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
e06b8136
提交
e06b8136
authored
12月 21, 2016
作者:
Iñaki Baz Castillo
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Working on RtpStream (habemus RTP buffer)
上级
ae310629
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
89 行增加
和
62 行删除
+89
-62
RtpReceiver.h
worker/include/RTC/RtpReceiver.h
+1
-2
RtpStream.h
worker/include/RTC/RtpStream.h
+12
-4
RtpReceiver.cpp
worker/src/RTC/RtpReceiver.cpp
+3
-6
RtpStream.cpp
worker/src/RTC/RtpStream.cpp
+73
-50
没有找到文件。
worker/include/RTC/RtpReceiver.h
浏览文件 @
e06b8136
...
...
@@ -70,8 +70,7 @@ namespace RTC
// Others.
bool
rtpRawEventEnabled
=
false
;
bool
rtpObjectEventEnabled
=
false
;
// Receiver Report holding the RTP stats
// Receiver Report holding the RTP stats.
std
::
auto_ptr
<
RTC
::
RTCP
::
ReceiverReport
>
receiverReport
;
};
...
...
worker/include/RTC/RtpStream.h
浏览文件 @
e06b8136
...
...
@@ -16,17 +16,25 @@ namespace RTC
uint8_t
store
[
65536
];
};
private
:
struct
BufferItem
{
uint32_t
seq32
=
0
;
// RTP seq in 32 bytes plus 16 bits cycles.
RTC
::
RtpPacket
*
packet
=
nullptr
;
};
public
:
RtpStream
(
size_t
bufferSize
);
~
RtpStream
();
bool
ReceivePacket
(
RTC
::
RtpPacket
*
packet
);
// TODO: REMOVE
bool
AddPacket
(
RTC
::
RtpPacket
*
packet
);
private
:
void
InitSeq
(
uint16_t
seq
);
bool
UpdateSeq
(
uint16_t
seq
);
void
CleanBuffer
();
void
StorePacket
(
RTC
::
RtpPacket
*
packet
);
void
Dump
();
private
:
bool
started
=
false
;
// Whether at least a RTP packet has been received.
...
...
@@ -43,8 +51,8 @@ namespace RTC
uint32_t
jitter
=
0
;
// Estimated jitter.
// Others.
std
::
vector
<
StorageItem
>
storage
;
typedef
std
::
list
<
RTC
::
RtpPacket
*>
Packets
;
Packets
packets
;
typedef
std
::
list
<
BufferItem
>
Buffer
;
Buffer
buffer
;
};
}
...
...
worker/src/RTC/RtpReceiver.cpp
浏览文件 @
e06b8136
...
...
@@ -18,8 +18,9 @@ namespace RTC
{
MS_TRACE
();
// Create the RtpStream instance.
this
->
rtpStream
=
new
RTC
::
RtpStream
(
50
);
// Create an RtpStream instance if video.
if
(
kind
==
RTC
::
Media
::
Kind
::
VIDEO
)
this
->
rtpStream
=
new
RTC
::
RtpStream
(
50
);
// TODO: Set a proper size.
}
RtpReceiver
::~
RtpReceiver
()
...
...
@@ -219,15 +220,11 @@ namespace RTC
// TODO: Must check what kind of packet we are storing, right?
// TODO: RtpStream.ReceivePacket() should return true if the packet is valid and
// false if it must be ignored.
// TODO: testing for just video (remove)
if
(
this
->
kind
==
RTC
::
Media
::
Kind
::
VIDEO
)
{
// TODO: Enable when properly implemented.
if
(
!
this
->
rtpStream
->
ReceivePacket
(
packet
))
return
;
// TODO: REMOVE
// this->rtpStream->ReceivePacket(packet);
}
// Notify the listener.
...
...
worker/src/RTC/RtpStream.cpp
浏览文件 @
e06b8136
...
...
@@ -24,11 +24,8 @@ namespace RTC
{
MS_TRACE
();
// Delete cloned packets.
for
(
auto
&
packet
:
this
->
packets
)
{
delete
packet
;
}
// Clear buffer.
CleanBuffer
();
}
bool
RtpStream
::
ReceivePacket
(
RTC
::
RtpPacket
*
packet
)
...
...
@@ -56,6 +53,12 @@ namespace RTC
return
false
;
}
// Store the packet into the buffer.
StorePacket
(
packet
);
// TODO: TMP
Dump
();
return
true
;
}
...
...
@@ -63,6 +66,7 @@ namespace RTC
{
MS_TRACE
();
// Initialize/reset RTP counters.
this
->
base_seq
=
seq
;
this
->
max_seq
=
seq
;
this
->
bad_seq
=
RTP_SEQ_MOD
+
1
;
// So seq == bad_seq is false.
...
...
@@ -70,6 +74,9 @@ namespace RTC
this
->
received
=
0
;
this
->
received_prior
=
0
;
this
->
expected_prior
=
0
;
// Clean buffer.
CleanBuffer
();
}
bool
RtpStream
::
UpdateSeq
(
uint16_t
seq
)
...
...
@@ -147,98 +154,114 @@ namespace RTC
return
true
;
}
// TODO: REMOVE
bool
RtpStream
::
AddPacket
(
RTC
::
RtpPacket
*
packet
)
void
RtpStream
::
CleanBuffer
()
{
MS_TRACE
();
// Delete cloned packets.
for
(
auto
&
buffer_item
:
this
->
buffer
)
{
delete
buffer_item
.
packet
;
}
// Clear list.
this
->
buffer
.
clear
();
}
inline
void
RtpStream
::
StorePacket
(
RTC
::
RtpPacket
*
packet
)
{
MS_TRACE
();
MS_WARN
(
"BEGIN | seq_number: %"
PRIu16
,
packet
->
GetSequenceNumber
());
// Sum the packet seq number and the number of 16 bits cycles.
uint32_t
packet_seq32
=
(
uint32_t
)
packet
->
GetSequenceNumber
()
+
this
->
cycles
;
BufferItem
buffer_item
;
buffer_item
.
seq32
=
packet_seq32
;
// If empty do it easy.
if
(
this
->
packets
.
size
()
==
0
)
if
(
this
->
buffer
.
size
()
==
0
)
{
MS_WARN
(
" empty packet list"
);
auto
store
=
this
->
storage
[
0
].
store
;
auto
cloned_packet
=
packet
->
Clone
(
store
);
this
->
packets
.
push_back
(
cloned_packet
);
buffer_item
.
packet
=
packet
->
Clone
(
store
);
MS_WARN
(
"END | seq_number: %"
PRIu16
,
packet
->
GetSequenceNumber
()
);
this
->
buffer
.
push_back
(
buffer_item
);
return
true
;
return
;
}
// Otherwise, do the stuff.
Packets
::
iterator
new
_it
;
Buffer
::
iterator
new_buffer
_it
;
uint8_t
*
store
=
nullptr
;
auto
it_r
=
this
->
packets
.
rbegin
();
for
(;
it_r
!=
this
->
packets
.
rend
();
it_r
++
)
// Iterate the buffer in reverse order and find the proper place to store the
// packet.
auto
buffer_it_r
=
this
->
buffer
.
rbegin
();
for
(;
buffer_it_r
!=
this
->
buffer
.
rend
();
buffer_it_r
++
)
{
auto
current_
packet
=
*
it_r
;
auto
current_
seq32
=
(
*
buffer_it_r
).
seq32
;
if
(
packet
->
GetSequenceNumber
()
>
current_packet
->
GetSequenceNumber
()
)
if
(
packet
_seq32
>
current_seq32
)
{
// Get a forward iterator pointing to the same element.
auto
it
=
it_r
.
base
();
auto
it
=
buffer_
it_r
.
base
();
new_
it
=
this
->
packets
.
insert
(
it
,
nullptr
);
new_
buffer_it
=
this
->
buffer
.
insert
(
it
,
buffer_item
);
// Exit the loop.
break
;
}
}
// If the packet was older than anything in the storate, just ignore it.
if
(
it_r
==
this
->
packets
.
rend
())
// If the packet was older than anything in the buffer, just ignore it.
// NOTE: This should never happen.
if
(
buffer_it_r
==
this
->
buffer
.
rend
())
{
// TODO: Wrong, this will drop all the received packets once sequence_number
// reaches 65535
MS_WARN
(
"packet is older than anything in the buffer, ignoring it"
);
MS_WARN
(
" packet is older than anything in the storage, ignoring it"
);
MS_WARN
(
"END | seq_number: %"
PRIu16
,
packet
->
GetSequenceNumber
());
return
false
;
return
;
}
MS_WARN
(
" packets.size:%zu, storage.size:%zu"
,
this
->
packets
.
size
(),
this
->
storage
.
size
());
// If the storage is not full use the next free area.
if
(
this
->
packets
.
size
()
-
1
<
this
->
storage
.
size
())
// If the storage is not full use its next free store.
if
(
this
->
buffer
.
size
()
-
1
<
this
->
storage
.
size
())
{
MS_WARN
(
" storage not full"
);
// Store points to the next free mem area.
store
=
this
->
storage
[
this
->
packets
.
size
()
-
1
].
store
;
store
=
this
->
storage
[
this
->
buffer
.
size
()
-
1
].
store
;
}
// Otherwise remove the first packet
list entry
and replace its storage area.
// Otherwise remove the first packet
of the buffer
and replace its storage area.
else
{
auto
first_packet
=
*
(
this
->
packets
.
begin
());
MS_WARN
(
" storage full, deleting first list packet with seq_number: %"
PRIu16
,
first_packet
->
GetSequenceNumber
());
auto
&
first_buffer_item
=
*
(
this
->
buffer
.
begin
());
auto
first_packet
=
first_buffer_item
.
packet
;
// Store points to the store used by the first packet.
store
=
(
uint8_t
*
)
first_packet
->
GetRaw
();
// Free the first packet.
delete
first_packet
;
// Remove the first element in the list.
this
->
packets
.
pop_front
();
this
->
buffer
.
pop_front
();
}
// Update the new list entry so it points to the cloned packed.
*
new_it
=
packet
->
Clone
(
store
);
// Update the new buffer item so it points to the cloned packed.
(
*
new_buffer_it
).
packet
=
packet
->
Clone
(
store
);
}
MS_WARN
(
"END | seq_number: %"
PRIu16
,
packet
->
GetSequenceNumber
());
// TODO: TMP
void
RtpStream
::
Dump
()
{
MS_TRACE
();
MS_WARN
(
"<DUMP>"
);
for
(
auto
&
packet
:
this
->
packets
)
MS_WARN
(
" [buffer.size:%zu, storage.size:%zu]"
,
this
->
buffer
.
size
(),
this
->
storage
.
size
());
for
(
auto
&
buffer_item
:
this
->
buffer
)
{
MS_WARN
(
" - seq_number: %"
PRIu16
,
packet
->
GetSequenceNumber
());
auto
packet
=
buffer_item
.
packet
;
MS_WARN
(
" packet [seq:%"
PRIu16
", seq32:%"
PRIu32
"]"
,
packet
->
GetSequenceNumber
(),
buffer_item
.
seq32
);
}
MS_WARN
(
"</DUMP>
\n
"
);
return
true
;
MS_WARN
(
"</DUMP>"
)
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论