Skip to content
项目
群组
代码片段
帮助
正在加载...
登录
切换导航
M
mediasoup
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
聂卓夫
mediasoup
Commits
f0d87fe2
提交
f0d87fe2
authored
1月 02, 2017
作者:
José Luis Millán
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Tests: add RTCP BYE tests
上级
ad52aaf2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
48 行增加
和
6 行删除
+48
-6
Bye.cpp
worker/src/RTC/RTCP/Bye.cpp
+12
-6
test-rtcp.cpp
worker/test/test-rtcp.cpp
+36
-0
没有找到文件。
worker/src/RTC/RTCP/Bye.cpp
浏览文件 @
f0d87fe2
...
...
@@ -29,14 +29,15 @@ namespace RTC { namespace RTCP
return
nullptr
;
}
packet
->
AddSsrc
(
Utils
::
Byte
::
Get4Bytes
(
data
+
offset
,
0
));
packet
->
AddSsrc
(
ntohl
(
Utils
::
Byte
::
Get4Bytes
(
data
,
offset
)
));
offset
+=
sizeof
(
uint32_t
);
}
if
(
count
==
0
)
if
(
len
-
offset
>
0
)
{
size_t
length
=
size_t
(
Utils
::
Byte
::
Get1Byte
(
data
+
offset
,
0
));
if
(
sizeof
(
uint8_t
)
+
length
<=
len
-
offset
)
size_t
length
=
size_t
(
Utils
::
Byte
::
Get1Byte
(
data
,
offset
));
offset
+=
sizeof
(
uint8_t
);
if
(
length
<=
len
-
offset
)
{
packet
->
SetReason
(
std
::
string
((
char
*
)
data
+
offset
,
length
));
}
...
...
@@ -53,16 +54,21 @@ namespace RTC { namespace RTCP
size_t
offset
=
Packet
::
Serialize
(
data
);
// SSRCs.
for
(
auto
ssrc
:
this
->
ssrcs
)
{
std
::
memcpy
(
data
,
&
ssrc
,
sizeof
(
uint32_t
));
Utils
::
Byte
::
Set4Bytes
(
data
,
offset
,
htonl
(
ssrc
));
offset
+=
sizeof
(
uint32_t
);
}
if
(
!
this
->
reason
.
empty
())
{
// Length field.
Utils
::
Byte
::
Set1Byte
(
data
,
offset
,
this
->
reason
.
length
());
offset
+=
sizeof
(
uint8_t
);
// Length field.
offset
+=
sizeof
(
uint8_t
);
// Reason field.
std
::
memcpy
(
data
+
offset
,
this
->
reason
.
c_str
(),
this
->
reason
.
length
());
offset
+=
this
->
reason
.
length
();
}
...
...
worker/test/test-rtcp.cpp
浏览文件 @
f0d87fe2
...
...
@@ -5,6 +5,7 @@
#include "RTC/RTCP/Sdes.h"
#include "RTC/RTCP/SenderReport.h"
#include "RTC/RTCP/ReceiverReport.h"
#include "RTC/RTCP/Bye.h"
#include "Logger.h"
#include <string>
...
...
@@ -305,5 +306,40 @@ FCTMF_SUITE_BGN(test_rtcp)
}
FCT_TEST_END
()
FCT_TEST_BGN
(
create_parse_bye
)
{
uint32_t
ssrc1
=
1111
;
uint32_t
ssrc2
=
2222
;
std
::
string
reason
(
"hasta la vista"
);
// Create local Bye packet and check content.
// ByePacket();
ByePacket
bye1
;
bye1
.
AddSsrc
(
ssrc1
);
bye1
.
AddSsrc
(
ssrc2
);
bye1
.
SetReason
(
reason
);
ByePacket
::
Iterator
it
=
bye1
.
Begin
();
fct_chk_eq_int
(
*
(
it
),
ssrc1
);
fct_chk_eq_int
(
*
(
++
it
),
ssrc2
);
fct_chk
(
bye1
.
GetReason
()
==
reason
);
// Locally store the content of the packet.
uint8_t
buffer
[
bye1
.
GetSize
()];
bye1
.
Serialize
(
buffer
);
// Parse the buffer of the previous packet and check content.
ByePacket
*
bye2
=
ByePacket
::
Parse
(
buffer
,
sizeof
(
buffer
));
it
=
bye2
->
Begin
();
fct_chk_eq_int
(
*
(
it
),
ssrc1
);
fct_chk_eq_int
(
*
(
++
it
),
ssrc2
);
fct_chk
(
bye2
->
GetReason
()
==
reason
);
}
FCT_TEST_END
()
}
FCTMF_SUITE_END
();
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论