Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ | 11 #ifndef WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ |
| 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ | 12 #define WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ |
| 13 | 13 |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" | 16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" |
| 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h" | 17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h" |
| 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h" | 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h" |
| 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h" | 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h" |
| 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" | 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_utility.h" |
| 21 | 21 |
| 22 namespace webrtc { | 22 namespace webrtc { |
| 23 namespace rtcp { | 23 namespace rtcp { |
| 24 | 24 |
| 25 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR). | 25 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR). |
| 26 class ExtendedReports : public RtcpPacket { | 26 class ExtendedReports : public RtcpPacket { |
| 27 public: | 27 public: |
| 28 typedef std::vector<RTCPUtility::RTCPPacketXRDLRRReportBlockItem> DlrrBlock; | 28 static const uint8_t kPacketType = 207; |
| 29 ExtendedReports() : RtcpPacket() { | |
| 30 memset(&xr_header_, 0, sizeof(xr_header_)); | |
| 31 } | |
| 32 | 29 |
| 33 virtual ~ExtendedReports() {} | 30 ExtendedReports(); |
| 31 ~ExtendedReports() override; | |
| 34 | 32 |
| 35 void From(uint32_t ssrc) { | 33 // Parse assumes header is already parsed and validated. |
| 36 xr_header_.OriginatorSSRC = ssrc; | 34 bool Parse(const RTCPUtility::RtcpCommonHeader& header, |
| 37 } | 35 const uint8_t* payload); // Size of the payload is in the header. |
| 36 | |
| 37 void From(uint32_t ssrc) { sender_ssrc_ = ssrc; } | |
| 38 | 38 |
| 39 // Max 50 items of each of {Rrtr, Dlrr, VoipMetric} allowed per Xr. | 39 // Max 50 items of each of {Rrtr, Dlrr, VoipMetric} allowed per Xr. |
| 40 bool WithRrtr(Rrtr* rrtr); | 40 bool WithRrtr(const Rrtr& rrtr); |
| 41 bool WithDlrr(Dlrr* dlrr); | 41 bool WithDlrr(const Dlrr& dlrr); |
| 42 bool WithVoipMetric(VoipMetric* voip_metric); | 42 bool WithVoipMetric(const VoipMetric& voip_metric); |
| 43 | |
| 44 uint32_t sender_ssrc() const { return sender_ssrc_; } | |
| 45 const std::vector<Rrtr>& rrtrs() const { return rrtr_blocks_; } | |
| 46 const std::vector<Dlrr>& dlrrs() const { return dlrr_blocks_; } | |
| 47 const std::vector<VoipMetric>& voip_metrics() const { | |
| 48 return voip_metric_blocks_; | |
| 49 } | |
| 43 | 50 |
| 44 protected: | 51 protected: |
| 45 bool Create(uint8_t* packet, | 52 bool Create(uint8_t* packet, |
| 46 size_t* index, | 53 size_t* index, |
| 47 size_t max_length, | 54 size_t max_length, |
| 48 RtcpPacket::PacketReadyCallback* callback) const override; | 55 RtcpPacket::PacketReadyCallback* callback) const override; |
| 49 | 56 |
| 50 private: | 57 private: |
| 51 static const int kMaxNumberOfRrtrBlocks = 50; | 58 static const size_t kMaxNumberOfRrtrBlocks = 50; |
| 52 static const int kMaxNumberOfDlrrBlocks = 50; | 59 static const size_t kMaxNumberOfDlrrBlocks = 50; |
| 53 static const int kMaxNumberOfVoipMetricBlocks = 50; | 60 static const size_t kMaxNumberOfVoipMetricBlocks = 50; |
| 61 static const size_t kXrHeaderLength = 4; | |
|
åsapersson
2016/01/29 12:46:09
maybe kXrBaseLength (since xr header is 8 bytes).
danilchap
2016/01/29 13:49:30
Done. My understanding where XR header starts didn
| |
| 54 | 62 |
| 55 size_t BlockLength() const { | 63 size_t BlockLength() const override { |
| 56 const size_t kXrHeaderLength = 8; | 64 return kHeaderLength + kXrHeaderLength + RrtrLength() + DlrrLength() + |
| 57 return kXrHeaderLength + RrtrLength() + DlrrLength() + VoipMetricLength(); | 65 VoipMetricLength(); |
| 58 } | 66 } |
| 59 | 67 |
| 60 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); } | 68 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); } |
| 61 | |
| 62 size_t DlrrLength() const; | 69 size_t DlrrLength() const; |
| 63 | |
| 64 size_t VoipMetricLength() const { | 70 size_t VoipMetricLength() const { |
| 65 return VoipMetric::kLength * voip_metric_blocks_.size(); | 71 return VoipMetric::kLength * voip_metric_blocks_.size(); |
| 66 } | 72 } |
| 67 | 73 |
| 68 RTCPUtility::RTCPPacketXR xr_header_; | 74 void ParseRrtrBlock(const uint8_t* block, uint16_t block_size); |
| 75 void ParseDlrrBlock(const uint8_t* block, uint16_t block_size); | |
| 76 void ParseVoipMetricBlock(const uint8_t* block, uint16_t block_size); | |
| 77 | |
| 78 uint32_t sender_ssrc_; | |
| 69 std::vector<Rrtr> rrtr_blocks_; | 79 std::vector<Rrtr> rrtr_blocks_; |
| 70 std::vector<Dlrr> dlrr_blocks_; | 80 std::vector<Dlrr> dlrr_blocks_; |
| 71 std::vector<VoipMetric> voip_metric_blocks_; | 81 std::vector<VoipMetric> voip_metric_blocks_; |
| 72 | 82 |
| 73 RTC_DISALLOW_COPY_AND_ASSIGN(ExtendedReports); | 83 RTC_DISALLOW_COPY_AND_ASSIGN(ExtendedReports); |
| 74 }; | 84 }; |
| 75 | |
| 76 } // namespace rtcp | 85 } // namespace rtcp |
| 77 } // namespace webrtc | 86 } // namespace webrtc |
| 78 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ | 87 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ |
| OLD | NEW |