#include "common.hpp"
#include "RTC/RTCP/Packet.hpp"
#include <catch2/catch.hpp>
using namespace RTC::RTCP;
SCENARIO("RTCP parsing", "[parser][rtcp][packet]")
{
uint8_t buffer[] =
{
0x80, 0xc8, 0x00, 0x00
};
SECTION("a RTCP packet may only contain the RTCP common header")
{
Packet* packet = Packet::Parse(buffer, sizeof(buffer));
REQUIRE(packet);
delete packet;
}
SECTION("a too small RTCP packet should fail")
{
size_t length = sizeof(buffer) - 1;
Packet* packet = Packet::Parse(buffer, length);
REQUIRE_FALSE(packet);
delete packet;
}
SECTION("a RTCP packet with incorrect version should fail")
{
buffer[0] &= 0b00111111;
Packet* packet = Packet::Parse(buffer, sizeof(buffer));
REQUIRE_FALSE(packet);
delete packet;
}
SECTION("a RTCP packet with incorrect length should fail")
{
buffer[3] = 1;
Packet* packet = Packet::Parse(buffer, sizeof(buffer));
REQUIRE_FALSE(packet);
delete packet;
}
SECTION("a RTCP packet with unknown type should fail")
{
buffer[1] = 0;
Packet* packet = Packet::Parse(buffer, sizeof(buffer));
REQUIRE_FALSE(packet);
delete packet;
}
}