#include "common.hpp"
#include "RTC/RTCP/FeedbackPs.hpp"
#include "RTC/RTCP/FeedbackRtp.hpp"
#include "RTC/RTCP/Packet.hpp"
#include <catch2/catch_test_macros.hpp>
SCENARIO("RTCP Packet", "[rtcp][packet]")
{
alignas(4) uint8_t buffer[] =
{
0x80, 0xc8, 0x00, 0x00
};
SECTION("alignof() RTCP structs")
{
REQUIRE(alignof(RTC::RTCP::Packet::CommonHeader) == 2);
REQUIRE(alignof(RTC::RTCP::FeedbackRtpPacket::Header) == 4);
REQUIRE(alignof(RTC::RTCP::FeedbackPsPacket::Header) == 4);
}
SECTION("a RTCP packet may only contain the RTCP common header")
{
const std::unique_ptr<RTC::RTCP::Packet> packet{ RTC::RTCP::Packet::Parse(buffer, sizeof(buffer)) };
REQUIRE(packet);
}
SECTION("a too small RTCP packet should fail")
{
const size_t length = sizeof(buffer) - 1;
const std::unique_ptr<RTC::RTCP::Packet> packet{ RTC::RTCP::Packet::Parse(buffer, length) };
REQUIRE(!packet);
}
SECTION("a RTCP packet with incorrect version should fail")
{
buffer[0] &= 0b00111111;
const std::unique_ptr<RTC::RTCP::Packet> packet{ RTC::RTCP::Packet::Parse(buffer, sizeof(buffer)) };
REQUIRE(!packet);
}
SECTION("a RTCP packet with incorrect length should fail")
{
buffer[3] = 1;
const std::unique_ptr<RTC::RTCP::Packet> packet{ RTC::RTCP::Packet::Parse(buffer, sizeof(buffer)) };
REQUIRE(!packet);
}
SECTION("a RTCP packet with unknown type should fail")
{
buffer[1] = 0;
const std::unique_ptr<RTC::RTCP::Packet> packet{ RTC::RTCP::Packet::Parse(buffer, sizeof(buffer)) };
REQUIRE(!packet);
}
}