![]() 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/include/RTC/RTCP/ |
Upload File : |
#ifndef MS_RTC_RTCP_XR_HPP #define MS_RTC_RTCP_XR_HPP #include "common.hpp" #include "RTC/RTCP/Packet.hpp" #include <vector> /* https://tools.ietf.org/html/rfc3611 * RTP Control Protocol Extended Reports (RTCP XR) 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |V=2|P|reserved | PT=XR=207 | length | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | SSRC | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ : report blocks : +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ */ namespace RTC { namespace RTCP { class ExtendedReportBlock { public: enum class Type : uint8_t { LRLE = 1, DRLE = 2, PRT = 3, RRT = 4, DLRR = 5, SS = 6, VM = 7 }; public: /* Struct for Extended Report Block common header. */ struct CommonHeader { uint8_t blockType : 8; uint8_t reserved : 8; uint16_t length : 16; }; public: static ExtendedReportBlock* Parse(const uint8_t* data, size_t len); public: ExtendedReportBlock(Type type) : type(type) { this->header = reinterpret_cast<CommonHeader*>(this->raw); this->header->reserved = 0; } virtual ~ExtendedReportBlock() = default; public: virtual void Dump() const = 0; virtual size_t Serialize(uint8_t* buffer) = 0; virtual size_t GetSize() const = 0; ExtendedReportBlock::Type GetType() const { return this->type; } protected: Type type; CommonHeader* header{ nullptr }; private: uint8_t raw[sizeof(CommonHeader)] = { 0 }; }; class ExtendedReportPacket : public Packet { public: using Iterator = std::vector<ExtendedReportBlock*>::iterator; public: static ExtendedReportPacket* Parse(const uint8_t* data, size_t len); public: ExtendedReportPacket() : Packet(Type::XR) { } explicit ExtendedReportPacket(CommonHeader* commonHeader) : Packet(commonHeader) { } ~ExtendedReportPacket() override { for (auto* report : this->reports) { delete report; } } void AddReport(ExtendedReportBlock* report) { this->reports.push_back(report); } uint32_t GetSsrc() const { return this->ssrc; } void SetSsrc(uint32_t ssrc) { this->ssrc = ssrc; } Iterator Begin() { return this->reports.begin(); } Iterator End() { return this->reports.end(); } /* Pure virtual methods inherited from Packet. */ public: void Dump() const override; size_t Serialize(uint8_t* buffer) override; size_t GetCount() const override { return 0; } size_t GetSize() const override { size_t size = sizeof(Packet::CommonHeader) + 4u /*ssrc*/; for (auto* report : this->reports) { size += report->GetSize(); } return size; } private: uint32_t ssrc{ 0u }; std::vector<ExtendedReportBlock*> reports; }; } // namespace RTCP } // namespace RTC #endif