![]() 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 : /usr/local/lib/node_modules/mediasoup/worker/src/RTC/RTCP/ |
Upload File : |
#define MS_CLASS "RTC::RTCP::XrDelaySinceLastRr" // #define MS_LOG_DEV_LEVEL 3 #include "RTC/RTCP/XrDelaySinceLastRr.hpp" #include "Logger.hpp" #include <cstring> namespace RTC { namespace RTCP { /* Class methods. */ DelaySinceLastRr::SsrcInfo* DelaySinceLastRr::SsrcInfo::Parse(const uint8_t* data, size_t len) { MS_TRACE(); // Ensure there is space for the common header and the SSRC of packet sender. if (len < sizeof(Body)) { MS_WARN_TAG(rtcp, "not enough space for a extended DSLR sub-block, sub-block discarded"); return nullptr; } // Get the header. auto* body = const_cast<SsrcInfo::Body*>(reinterpret_cast<const SsrcInfo::Body*>(data)); auto* ssrcInfo = new DelaySinceLastRr::SsrcInfo(body); return ssrcInfo; } /* Instance methods. */ void DelaySinceLastRr::SsrcInfo::Dump() const { MS_TRACE(); MS_DUMP(" <SsrcInfo>"); MS_DUMP(" ssrc : %" PRIu32, GetSsrc()); MS_DUMP(" lrr : %" PRIu32, GetLastReceiverReport()); MS_DUMP(" dlrr : %" PRIu32, GetDelaySinceLastReceiverReport()); MS_DUMP(" <SsrcInfo>"); } size_t DelaySinceLastRr::SsrcInfo::Serialize(uint8_t* buffer) { MS_TRACE(); // Copy the body. std::memcpy(buffer, this->body, sizeof(DelaySinceLastRr::SsrcInfo::Body)); return sizeof(DelaySinceLastRr::SsrcInfo::Body); } /* Class methods. */ DelaySinceLastRr* DelaySinceLastRr::Parse(const uint8_t* data, size_t len) { MS_TRACE(); auto* header = const_cast<ExtendedReportBlock::CommonHeader*>( reinterpret_cast<const ExtendedReportBlock::CommonHeader*>(data)); std::unique_ptr<DelaySinceLastRr> report(new DelaySinceLastRr(header)); size_t offset{ sizeof(ExtendedReportBlock::CommonHeader) }; uint16_t reportLength = ntohs(header->length) * 4; while (len > offset && reportLength >= sizeof(DelaySinceLastRr::SsrcInfo::Body)) { DelaySinceLastRr::SsrcInfo* ssrcInfo = DelaySinceLastRr::SsrcInfo::Parse(data + offset, len - offset); if (ssrcInfo) { report->AddSsrcInfo(ssrcInfo); offset += ssrcInfo->GetSize(); } else { return report.release(); } offset += ssrcInfo->GetSize(); reportLength -= sizeof(DelaySinceLastRr::SsrcInfo::Body); } return report.release(); } /* Instance methods. */ size_t DelaySinceLastRr::Serialize(uint8_t* buffer) { MS_TRACE(); size_t length = static_cast<uint16_t>((sizeof(SsrcInfo::Body) * this->ssrcInfos.size() / 4)); // Fill the common header. this->header->blockType = static_cast<uint8_t>(this->type); this->header->reserved = 0; this->header->length = uint16_t{ htons(length) }; std::memcpy(buffer, this->header, sizeof(ExtendedReportBlock::CommonHeader)); size_t offset{ sizeof(ExtendedReportBlock::CommonHeader) }; // Serialize sub-blocks. for (auto* ssrcInfo : this->ssrcInfos) { offset += ssrcInfo->Serialize(buffer + offset); } return offset; } void DelaySinceLastRr::Dump() const { MS_TRACE(); MS_DUMP("<DelaySinceLastRr>"); MS_DUMP(" block type : %" PRIu8, (uint8_t)this->type); MS_DUMP(" reserved : 0"); MS_DUMP( " length : %" PRIu16, static_cast<uint16_t>((sizeof(SsrcInfo::Body) * this->ssrcInfos.size() / 4))); for (auto* ssrcInfo : this->ssrcInfos) { ssrcInfo->Dump(); } MS_DUMP("</DelaySinceLastRr>"); } } // namespace RTCP } // namespace RTC