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

Worker tests: more work on RTCP

上级 baf362a4
...@@ -178,7 +178,7 @@ namespace RTC ...@@ -178,7 +178,7 @@ namespace RTC
inline size_t SenderReportPacket::GetCount() const inline size_t SenderReportPacket::GetCount() const
{ {
return this->reports.size(); return 0;
} }
inline size_t SenderReportPacket::GetSize() const inline size_t SenderReportPacket::GetSize() const
......
...@@ -7,18 +7,13 @@ using namespace RTC::RTCP; ...@@ -7,18 +7,13 @@ using namespace RTC::RTCP;
namespace TestReceiverReport namespace TestReceiverReport
{ {
// RTCP Packet. Sender Report and Receiver Report. // RTCP Receiver Report Packet.
// clang-format off // clang-format off
uint8_t buffer[] = uint8_t buffer[] =
{ {
0x81, 0xc8, 0x00, 0x0c, // Type: 200 (Sender Report), Count: 1, Length: 12 0x81, 0xc9, 0x00, 0x07, // Type: 201 (Receiver Report), Count: 1, Length: 7
0x5d, 0x93, 0x15, 0x34, // SSRC: 0x5d931534 0x5d, 0x93, 0x15, 0x34, // Sender SSRC: 0x5d931534
0xdd, 0x3a, 0xc1, 0xb4, // NTP Sec: 3711615412
0x76, 0x54, 0x71, 0x71, // NTP Frac: 1985245553
0x00, 0x08, 0xcf, 0x00, // RTP timestamp: 577280
0x00, 0x00, 0x0e, 0x18, // Packet count: 3608
0x00, 0x08, 0xcf, 0x00, // Octed count: 577280
// Receiver Report // Receiver Report
0x01, 0x93, 0x2d, 0xb4, // SSRC. 0x01932db4 0x01, 0x93, 0x2d, 0xb4, // SSRC. 0x01932db4
0x00, 0x00, 0x00, 0x01, // Fraction lost: 0, Total lost: 1 0x00, 0x00, 0x00, 0x01, // Fraction lost: 0, Total lost: 1
...@@ -30,7 +25,7 @@ namespace TestReceiverReport ...@@ -30,7 +25,7 @@ namespace TestReceiverReport
// clang-format on // clang-format on
// Receiver Report buffer start point. // Receiver Report buffer start point.
uint8_t* rrBuffer = buffer + sizeof(Packet::CommonHeader) + sizeof(SenderReport::Header); uint8_t* rrBuffer = buffer + sizeof(Packet::CommonHeader) + sizeof(uint32_t) /*Sender SSRC*/;
uint32_t ssrc = 0x01932db4; uint32_t ssrc = 0x01932db4;
uint8_t fractionLost = 0; uint8_t fractionLost = 0;
...@@ -56,7 +51,30 @@ using namespace TestReceiverReport; ...@@ -56,7 +51,30 @@ using namespace TestReceiverReport;
SCENARIO("RTCP RR parsing", "[parser][rtcp][rr]") SCENARIO("RTCP RR parsing", "[parser][rtcp][rr]")
{ {
SECTION("parse ReceiverReport") SECTION("parse RR packet")
{
ReceiverReportPacket* packet = ReceiverReportPacket::Parse(buffer, sizeof(buffer));
auto* report = *(packet->Begin());
verify(report);
SECTION("serialize packet instance")
{
uint8_t serialized[sizeof(buffer)] = { 0 };
packet->Serialize(serialized);
SECTION("compare serialized packet with original buffer")
{
REQUIRE(std::memcmp(buffer, serialized, sizeof(buffer)) == 0);
}
}
delete packet;
}
SECTION("parse RR")
{ {
ReceiverReport* report = ReceiverReport::Parse(rrBuffer, sizeof(ReceiverReport::Header)); ReceiverReport* report = ReceiverReport::Parse(rrBuffer, sizeof(ReceiverReport::Header));
...@@ -67,7 +85,7 @@ SCENARIO("RTCP RR parsing", "[parser][rtcp][rr]") ...@@ -67,7 +85,7 @@ SCENARIO("RTCP RR parsing", "[parser][rtcp][rr]")
delete report; delete report;
} }
SECTION("create ReceiverReport") SECTION("create RR")
{ {
// Create local report and check content. // Create local report and check content.
ReceiverReport report1; ReceiverReport report1;
......
...@@ -12,20 +12,13 @@ namespace TestSenderReport ...@@ -12,20 +12,13 @@ namespace TestSenderReport
// clang-format off // clang-format off
uint8_t buffer[] = uint8_t buffer[] =
{ {
0x81, 0xc8, 0x00, 0x0c, // Type: 200 (Sender Report), Count: 1, Length: 12 0x80, 0xc8, 0x00, 0x06, // Type: 200 (Sender Report), Count: 0, Length: 6
0x5d, 0x93, 0x15, 0x34, // SSRC: 0x5d931534 0x5d, 0x93, 0x15, 0x34, // SSRC: 0x5d931534
0xdd, 0x3a, 0xc1, 0xb4, // NTP Sec: 3711615412 0xdd, 0x3a, 0xc1, 0xb4, // NTP Sec: 3711615412
0x76, 0x54, 0x71, 0x71, // NTP Frac: 1985245553 0x76, 0x54, 0x71, 0x71, // NTP Frac: 1985245553
0x00, 0x08, 0xcf, 0x00, // RTP timestamp: 577280 0x00, 0x08, 0xcf, 0x00, // RTP timestamp: 577280
0x00, 0x00, 0x0e, 0x18, // Packet count: 3608 0x00, 0x00, 0x0e, 0x18, // Packet count: 3608
0x00, 0x08, 0xcf, 0x00, // Octed count: 577280 0x00, 0x08, 0xcf, 0x00 // Octet count: 577280
// Receiver Report
0x01, 0x93, 0x2d, 0xb4, // SSRC. 0x01932db4
0x00, 0x00, 0x00, 0x01, // Fraction lost: 0, Total lost: 1
0x00, 0x00, 0x00, 0x00, // Extended highest sequence number: 0
0x00, 0x00, 0x00, 0x00, // Jitter: 0
0x00, 0x00, 0x00, 0x00, // Last SR: 0
0x00, 0x00, 0x00, 0x05 // DLSR: 0
}; };
// clang-format on // clang-format on
...@@ -55,7 +48,30 @@ using namespace TestSenderReport; ...@@ -55,7 +48,30 @@ using namespace TestSenderReport;
SCENARIO("RTCP SR parsing", "[parser][rtcp][sr]") SCENARIO("RTCP SR parsing", "[parser][rtcp][sr]")
{ {
SECTION("parse sender report") SECTION("parse SR packet")
{
SenderReportPacket* packet = SenderReportPacket::Parse(buffer, sizeof(buffer));
auto* report = *(packet->Begin());
verify(report);
SECTION("serialize packet instance")
{
uint8_t serialized[sizeof(buffer)] = { 0 };
packet->Serialize(serialized);
SECTION("compare serialized packet with original buffer")
{
REQUIRE(std::memcmp(buffer, serialized, sizeof(buffer)) == 0);
}
}
delete packet;
}
SECTION("parse SR")
{ {
SenderReport* report = SenderReport::Parse(srBuffer, sizeof(SenderReport::Header)); SenderReport* report = SenderReport::Parse(srBuffer, sizeof(SenderReport::Header));
...@@ -78,7 +94,7 @@ SCENARIO("RTCP SR parsing", "[parser][rtcp][sr]") ...@@ -78,7 +94,7 @@ SCENARIO("RTCP SR parsing", "[parser][rtcp][sr]")
delete report; delete report;
} }
SECTION("create SenderReport") SECTION("create SR")
{ {
// Create local report and check content. // Create local report and check content.
SenderReport report1; SenderReport report1;
...@@ -99,21 +115,4 @@ SCENARIO("RTCP SR parsing", "[parser][rtcp][sr]") ...@@ -99,21 +115,4 @@ SCENARIO("RTCP SR parsing", "[parser][rtcp][sr]")
verify(&report2); verify(&report2);
} }
} }
SECTION("parse Packet with SenderReport and ReceiverReport")
{
auto packet = Packet::Parse(buffer, sizeof(buffer));
REQUIRE(packet);
REQUIRE(packet->GetType() == Type::SR);
auto sr = dynamic_cast<SenderReportPacket*>(packet);
auto it = sr->Begin();
auto report = *it;
verify(report);
REQUIRE(packet->GetNext());
REQUIRE(packet->GetNext()->GetType() == Type::RR);
}
} }
Markdown 格式
0% 或
您添加了 0 人 到此讨论。请谨慎行事。
请先完成此评论的编辑!
请 注册 或者 后发表评论