1 /* 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #ifndef MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SENDER_REPORT_H_ 12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SENDER_REPORT_H_ 13 14 #include <vector> 15 16 #include "modules/rtp_rtcp/source/rtcp_packet.h" 17 #include "modules/rtp_rtcp/source/rtcp_packet/report_block.h" 18 #include "system_wrappers/include/ntp_time.h" 19 20 namespace webrtc { 21 namespace rtcp { 22 class CommonHeader; 23 24 class SenderReport : public RtcpPacket { 25 public: 26 static constexpr uint8_t kPacketType = 200; 27 static constexpr size_t kMaxNumberOfReportBlocks = 0x1f; 28 29 SenderReport(); 30 SenderReport(const SenderReport&); 31 SenderReport(SenderReport&&); 32 SenderReport& operator=(const SenderReport&); 33 SenderReport& operator=(SenderReport&&); 34 ~SenderReport() override; 35 36 // Parse assumes header is already parsed and validated. 37 bool Parse(const CommonHeader& packet); 38 SetNtp(NtpTime ntp)39 void SetNtp(NtpTime ntp) { ntp_ = ntp; } SetRtpTimestamp(uint32_t rtp_timestamp)40 void SetRtpTimestamp(uint32_t rtp_timestamp) { 41 rtp_timestamp_ = rtp_timestamp; 42 } SetPacketCount(uint32_t packet_count)43 void SetPacketCount(uint32_t packet_count) { 44 sender_packet_count_ = packet_count; 45 } SetOctetCount(uint32_t octet_count)46 void SetOctetCount(uint32_t octet_count) { 47 sender_octet_count_ = octet_count; 48 } 49 bool AddReportBlock(const ReportBlock& block); 50 bool SetReportBlocks(std::vector<ReportBlock> blocks); ClearReportBlocks()51 void ClearReportBlocks() { report_blocks_.clear(); } 52 ntp()53 NtpTime ntp() const { return ntp_; } rtp_timestamp()54 uint32_t rtp_timestamp() const { return rtp_timestamp_; } sender_packet_count()55 uint32_t sender_packet_count() const { return sender_packet_count_; } sender_octet_count()56 uint32_t sender_octet_count() const { return sender_octet_count_; } 57 report_blocks()58 const std::vector<ReportBlock>& report_blocks() const { 59 return report_blocks_; 60 } 61 62 size_t BlockLength() const override; 63 64 bool Create(uint8_t* packet, 65 size_t* index, 66 size_t max_length, 67 PacketReadyCallback callback) const override; 68 69 private: 70 static constexpr size_t kSenderBaseLength = 24; 71 72 NtpTime ntp_; 73 uint32_t rtp_timestamp_; 74 uint32_t sender_packet_count_; 75 uint32_t sender_octet_count_; 76 std::vector<ReportBlock> report_blocks_; 77 }; 78 79 } // namespace rtcp 80 } // namespace webrtc 81 #endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_SENDER_REPORT_H_ 82