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/TestBye.cpp
#include "common.hpp"
#include "RTC/RTCP/Bye.hpp"
#include <catch.hpp>
#include <cstring> // std::memcmp()
#include <string>

using namespace RTC::RTCP;

namespace TestBye
{
	// RCTP BYE packet.

	// clang-format off
	uint8_t buffer[] =
	{
		0x82, 0xcb, 0x00, 0x06, // Type: 203 (Bye), Count: 2, length: 2
		0x62, 0x42, 0x76, 0xe0, // SSRC: 0x624276e0
		0x26, 0x24, 0x67, 0x0e, // SSRC: 0x2624670e
		0x0e, 0x48, 0x61, 0x73, // Length: 14, Text: "Hasta la vista"
		0x74, 0x61, 0x20, 0x6c,
		0x61, 0x20, 0x76, 0x69,
		0x73, 0x74, 0x61, 0x00
	};
	// clang-format on

	uint32_t ssrc1{ 0x624276e0 };
	uint32_t ssrc2{ 0x2624670e };
	std::string reason("Hasta la vista");

	void verify(ByePacket* packet)
	{
		REQUIRE(packet->GetReason() == reason);

		ByePacket::Iterator it = packet->Begin();

		REQUIRE(*it == ssrc1);

		it++;

		REQUIRE(*it == ssrc2);
	}
} // namespace TestBye

using namespace TestBye;

SCENARIO("RTCP BYE parsing", "[parser][rtcp][bye]")
{
	SECTION("parse BYE packet")
	{
		ByePacket* packet = ByePacket::Parse(buffer, sizeof(buffer));

		REQUIRE(packet);

		verify(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);
			}
		}

		delete packet;
	}

	SECTION("create ByePacket")
	{
		// Create local Bye packet and check content.
		ByePacket packet;

		packet.AddSsrc(ssrc1);
		packet.AddSsrc(ssrc2);
		packet.SetReason(reason);

		verify(&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);
			}
		}
	}
}

VaKeR 2022