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_EXTENDED_REPORTS_H_ 12 #define MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ 13 14 #include <vector> 15 16 #include "absl/types/optional.h" 17 #include "modules/rtp_rtcp/source/rtcp_packet.h" 18 #include "modules/rtp_rtcp/source/rtcp_packet/dlrr.h" 19 #include "modules/rtp_rtcp/source/rtcp_packet/rrtr.h" 20 #include "modules/rtp_rtcp/source/rtcp_packet/target_bitrate.h" 21 22 namespace webrtc { 23 namespace rtcp { 24 class CommonHeader; 25 26 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR). 27 class ExtendedReports : public RtcpPacket { 28 public: 29 static constexpr uint8_t kPacketType = 207; 30 static constexpr size_t kMaxNumberOfDlrrItems = 50; 31 32 ExtendedReports(); 33 ExtendedReports(const ExtendedReports& xr); 34 ~ExtendedReports() override; 35 36 // Parse assumes header is already parsed and validated. 37 bool Parse(const CommonHeader& packet); 38 39 void SetRrtr(const Rrtr& rrtr); 40 bool AddDlrrItem(const ReceiveTimeInfo& time_info); 41 void SetTargetBitrate(const TargetBitrate& target_bitrate); 42 rrtr()43 const absl::optional<Rrtr>& rrtr() const { return rrtr_block_; } dlrr()44 const Dlrr& dlrr() const { return dlrr_block_; } target_bitrate()45 const absl::optional<TargetBitrate>& target_bitrate() const { 46 return target_bitrate_; 47 } 48 49 size_t BlockLength() const override; 50 51 bool Create(uint8_t* packet, 52 size_t* index, 53 size_t max_length, 54 PacketReadyCallback callback) const override; 55 56 private: 57 static constexpr size_t kXrBaseLength = 4; 58 RrtrLength()59 size_t RrtrLength() const { return rrtr_block_ ? Rrtr::kLength : 0; } DlrrLength()60 size_t DlrrLength() const { return dlrr_block_.BlockLength(); } 61 size_t TargetBitrateLength() const; 62 63 void ParseRrtrBlock(const uint8_t* block, uint16_t block_length); 64 void ParseDlrrBlock(const uint8_t* block, uint16_t block_length); 65 void ParseTargetBitrateBlock(const uint8_t* block, uint16_t block_length); 66 67 absl::optional<Rrtr> rrtr_block_; 68 Dlrr dlrr_block_; // Dlrr without items treated same as no dlrr block. 69 absl::optional<TargetBitrate> target_bitrate_; 70 }; 71 } // namespace rtcp 72 } // namespace webrtc 73 #endif // MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ 74