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

Worker tests: RTCP BYE

上级 fa1e7166
...@@ -5,41 +5,86 @@ ...@@ -5,41 +5,86 @@
using namespace RTC::RTCP; using namespace RTC::RTCP;
SCENARIO("RTCP BYE parsing", "[parser][rtcp][bye]") namespace TestBye
{ {
SECTION("create ByePacket") // RCTP BYE packet.
uint8_t buffer[] =
{ {
uint32_t ssrc1 = 1111; 0x82, 0xcb, 0x00, 0x06, // Type: 203 (Bye), Count: 2, length: 2
uint32_t ssrc2 = 2222; 0x62, 0x42, 0x76, 0xe0, // SSRC: 0x624276e0
std::string reason("hasta la vista"); 0x26, 0x24, 0x67, 0x0e, // SSRC: 0x2624670e
// Create local Bye packet and check content. 0x0e, 0x48, 0x61, 0x73, // Length: 14, Text: "Hasta la vista"
// ByePacket(); 0x74, 0x61, 0x20, 0x6c,
ByePacket bye1; 0x61, 0x20, 0x76, 0x69,
0x73, 0x74, 0x61, 0x00
};
bye1.AddSsrc(ssrc1); uint32_t ssrc1 = 0x624276e0;
bye1.AddSsrc(ssrc2); uint32_t ssrc2 = 0x2624670e;
bye1.SetReason(reason); std::string reason("Hasta la vista");
void verifyPacket(ByePacket* packet)
{
REQUIRE(packet->GetReason() == reason);
ByePacket::Iterator it = bye1.Begin(); ByePacket::Iterator it = packet->Begin();
REQUIRE(*it == ssrc1); REQUIRE(*it == ssrc1);
it++; it++;
REQUIRE(*it == ssrc2); REQUIRE(*it == ssrc2);
REQUIRE(bye1.GetReason() == reason); }
}
// Locally store the content of the packet. using namespace TestBye;
uint8_t buffer[bye1.GetSize()];
bye1.Serialize(buffer); SCENARIO("RTCP BYE parsing", "[parser][rtcp][bye]")
{
SECTION("parse BYE packet")
{
ByePacket* packet = ByePacket::Parse(buffer, sizeof(buffer));
// Parse the buffer of the previous packet and check content. REQUIRE(packet);
ByePacket* bye2 = ByePacket::Parse(buffer, sizeof(buffer));
it = bye2->Begin(); verifyPacket(packet);
REQUIRE(*it == ssrc1); SECTION("serialize packet instance")
it++; {
REQUIRE(*it == ssrc2); uint8_t serialized[sizeof(buffer)] = {0};
REQUIRE(bye2->GetReason() == reason);
packet->Serialize(serialized);
SECTION("compare serialized instance with original buffer")
{
REQUIRE(std::memcmp(buffer, serialized, sizeof(buffer)) == 0);
}
}
delete packet;
}
SECTION("create ByePacket")
{
// Create local Bye packet and check content.
ByePacket packet;
packet.AddSsrc(ssrc1);
packet.AddSsrc(ssrc2);
packet.SetReason(reason);
verifyPacket(&packet);
SECTION("serialize packet instance")
{
uint8_t serialized[sizeof(buffer)] = {0};
packet.Serialize(serialized);
SECTION("compare serialized instance with original buffer")
{
REQUIRE(std::memcmp(buffer, serialized, sizeof(buffer)) == 0);
}
}
} }
} }
...@@ -61,7 +61,7 @@ SCENARIO("RTCP SR parsing", "[parser][rtcp][sr]") ...@@ -61,7 +61,7 @@ SCENARIO("RTCP SR parsing", "[parser][rtcp][sr]")
verifySenderReport(report); verifySenderReport(report);
SECTION("serialize SenderReport object") SECTION("serialize SenderReport instance")
{ {
uint8_t serialized[sizeof(SenderReport::Header)] = {0}; uint8_t serialized[sizeof(SenderReport::Header)] = {0};
......
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论