提交 a1e2d57d authored 作者: José Luis Millán's avatar José Luis Millán

Worker tests: RTCP packet

上级 53a83a48
...@@ -6,13 +6,15 @@ using namespace RTC::RTCP; ...@@ -6,13 +6,15 @@ using namespace RTC::RTCP;
SCENARIO("RTCP parsing", "[parser][rtcp][packet]") SCENARIO("RTCP parsing", "[parser][rtcp][packet]")
{ {
SECTION("a RTCP packet may only contain the RTCP common header") // RTCP common header
{ // Version:2, Padding:false, Count:0, Type:200(SR), Lengh:0
uint8_t buffer[] = uint8_t buffer[] =
{ {
0x81, 0xca, 0x00, 0x00 // RTCP common header 0x80, 0xc8, 0x00, 0x00
}; };
SECTION("a RTCP packet may only contain the RTCP common header")
{
Packet* packet = Packet::Parse(buffer, sizeof(buffer)); Packet* packet = Packet::Parse(buffer, sizeof(buffer));
REQUIRE(packet); REQUIRE(packet);
...@@ -22,12 +24,10 @@ SCENARIO("RTCP parsing", "[parser][rtcp][packet]") ...@@ -22,12 +24,10 @@ SCENARIO("RTCP parsing", "[parser][rtcp][packet]")
SECTION("a too small RTCP packet should fail") SECTION("a too small RTCP packet should fail")
{ {
uint8_t buffer[] = // Provide a wrong packet length.
{ size_t length = sizeof(buffer) - 1;
0x81, 0xca, 0x00
};
Packet* packet = Packet::Parse(buffer, sizeof(buffer)); Packet* packet = Packet::Parse(buffer, length);
REQUIRE_FALSE(packet); REQUIRE_FALSE(packet);
...@@ -36,11 +36,8 @@ SCENARIO("RTCP parsing", "[parser][rtcp][packet]") ...@@ -36,11 +36,8 @@ SCENARIO("RTCP parsing", "[parser][rtcp][packet]")
SECTION("a RTCP packet with incorrect version should fail") SECTION("a RTCP packet with incorrect version should fail")
{ {
uint8_t buffer[] = // Set an incorrect version value (0).
{ buffer[0] &= 0b00111111;
0x00, 0xca, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00
};
Packet* packet = Packet::Parse(buffer, sizeof(buffer)); Packet* packet = Packet::Parse(buffer, sizeof(buffer));
...@@ -51,11 +48,8 @@ SCENARIO("RTCP parsing", "[parser][rtcp][packet]") ...@@ -51,11 +48,8 @@ SCENARIO("RTCP parsing", "[parser][rtcp][packet]")
SECTION("a RTCP packet with incorrect length should fail") SECTION("a RTCP packet with incorrect length should fail")
{ {
uint8_t buffer[] = // Set the packet length to zero.
{ buffer[3] = 1;
0x81, 0xca, 0x00, 0x04,
0x00, 0x00, 0x00, 0x00
};
Packet* packet = Packet::Parse(buffer, sizeof(buffer)); Packet* packet = Packet::Parse(buffer, sizeof(buffer));
...@@ -66,11 +60,8 @@ SCENARIO("RTCP parsing", "[parser][rtcp][packet]") ...@@ -66,11 +60,8 @@ SCENARIO("RTCP parsing", "[parser][rtcp][packet]")
SECTION("a RTCP packet with unknown type should fail") SECTION("a RTCP packet with unknown type should fail")
{ {
uint8_t buffer[] = // Set and unknown packet type (0).
{ buffer[1] = 0;
0x81, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x00
};
Packet* packet = Packet::Parse(buffer, sizeof(buffer)); Packet* packet = Packet::Parse(buffer, sizeof(buffer));
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论