VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /proc/self/root/usr/local/lib/node_modules/mediasoup/worker/test/src/RTC/RTCP/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/local/lib/node_modules/mediasoup/worker/test/src/RTC/RTCP/TestPacket.cpp
#include "common.hpp"
#include "RTC/RTCP/Packet.hpp"
#include <catch.hpp>

using namespace RTC::RTCP;

SCENARIO("RTCP parsing", "[parser][rtcp][packet]")
{
	// RTCP common header
	// Version:2, Padding:false, Count:0, Type:200(SR), Lengh:0

	// clang-format off
	uint8_t buffer[] =
	{
		0x80, 0xc8, 0x00, 0x00
	};
	// clang-format on

	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")
	{
		// Provide a wrong packet length.
		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")
	{
		// Set an incorrect version value (0).
		buffer[0] &= 0b00111111;

		Packet* packet = Packet::Parse(buffer, sizeof(buffer));

		REQUIRE_FALSE(packet);

		delete packet;
	}

	SECTION("a RTCP packet with incorrect length should fail")
	{
		// Set the packet length to zero.
		buffer[3] = 1;

		Packet* packet = Packet::Parse(buffer, sizeof(buffer));

		REQUIRE_FALSE(packet);

		delete packet;
	}

	SECTION("a RTCP packet with unknown type should fail")
	{
		// Set and unknown packet type (0).
		buffer[1] = 0;

		Packet* packet = Packet::Parse(buffer, sizeof(buffer));

		REQUIRE_FALSE(packet);

		delete packet;
	}
}

VaKeR 2022