Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h

Issue 2378113002: Allow max 1 block per type in RTCP Extended Reports (Closed)
Patch Set: use operator==(T, Optional<T>) for slightly cleaner tests Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/base/constructormagic.h" 16 #include "webrtc/base/constructormagic.h"
17 #include "webrtc/base/optional.h"
17 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h" 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet.h"
18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h" 19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/dlrr.h"
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h" 20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/rrtr.h"
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h" 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/voip_metric.h"
21 22
22 namespace webrtc { 23 namespace webrtc {
23 namespace rtcp { 24 namespace rtcp {
24 class CommonHeader; 25 class CommonHeader;
25 26
26 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR). 27 // From RFC 3611: RTP Control Protocol Extended Reports (RTCP XR).
27 class ExtendedReports : public RtcpPacket { 28 class ExtendedReports : public RtcpPacket {
28 public: 29 public:
29 static constexpr uint8_t kPacketType = 207; 30 static constexpr uint8_t kPacketType = 207;
30 31
31 ExtendedReports(); 32 ExtendedReports();
32 ~ExtendedReports() override; 33 ~ExtendedReports() override;
33 34
34 // Parse assumes header is already parsed and validated. 35 // Parse assumes header is already parsed and validated.
35 bool Parse(const CommonHeader& packet); 36 bool Parse(const CommonHeader& packet);
36 37
37 void SetSenderSsrc(uint32_t ssrc) { sender_ssrc_ = ssrc; } 38 void SetSenderSsrc(uint32_t ssrc) { sender_ssrc_ = ssrc; }
38 39
39 // Max 50 items of each of {Rrtr, Dlrr, VoipMetric} allowed per Xr. 40 void SetRrtr(const Rrtr& rrtr);
40 bool AddRrtr(const Rrtr& rrtr); 41 void AddDlrrItem(const ReceiveTimeInfo& time_info);
41 bool AddDlrr(const Dlrr& dlrr); 42 void SetVoipMetric(const VoipMetric& voip_metric);
42 bool AddVoipMetric(const VoipMetric& voip_metric);
43 43
44 uint32_t sender_ssrc() const { return sender_ssrc_; } 44 uint32_t sender_ssrc() const { return sender_ssrc_; }
45 const std::vector<Rrtr>& rrtrs() const { return rrtr_blocks_; } 45 const rtc::Optional<Rrtr>& rrtr() const { return rrtr_block_; }
46 const std::vector<Dlrr>& dlrrs() const { return dlrr_blocks_; } 46 const Dlrr& dlrr() const { return dlrr_block_; }
47 const std::vector<VoipMetric>& voip_metrics() const { 47 const rtc::Optional<VoipMetric>& voip_metric() const {
48 return voip_metric_blocks_; 48 return voip_metric_block_;
49 } 49 }
50 50
51 protected: 51 protected:
52 bool Create(uint8_t* packet, 52 bool Create(uint8_t* packet,
53 size_t* index, 53 size_t* index,
54 size_t max_length, 54 size_t max_length,
55 RtcpPacket::PacketReadyCallback* callback) const override; 55 RtcpPacket::PacketReadyCallback* callback) const override;
56 56
57 private: 57 private:
58 static const size_t kMaxNumberOfRrtrBlocks = 50;
59 static const size_t kMaxNumberOfDlrrBlocks = 50;
60 static const size_t kMaxNumberOfVoipMetricBlocks = 50;
61 static constexpr size_t kXrBaseLength = 4; 58 static constexpr size_t kXrBaseLength = 4;
62 59
63 size_t BlockLength() const override { 60 size_t BlockLength() const override {
64 return kHeaderLength + kXrBaseLength + RrtrLength() + DlrrLength() + 61 return kHeaderLength + kXrBaseLength + RrtrLength() + DlrrLength() +
65 VoipMetricLength(); 62 VoipMetricLength();
66 } 63 }
67 64
68 size_t RrtrLength() const { return Rrtr::kLength * rrtr_blocks_.size(); } 65 size_t RrtrLength() const { return rrtr_block_ ? Rrtr::kLength : 0; }
69 size_t DlrrLength() const; 66 size_t DlrrLength() const { return dlrr_block_.BlockLength(); }
70 size_t VoipMetricLength() const { 67 size_t VoipMetricLength() const {
71 return VoipMetric::kLength * voip_metric_blocks_.size(); 68 return voip_metric_block_ ? VoipMetric::kLength : 0;
72 } 69 }
73 70
74 void ParseRrtrBlock(const uint8_t* block, uint16_t block_length); 71 void ParseRrtrBlock(const uint8_t* block, uint16_t block_length);
75 void ParseDlrrBlock(const uint8_t* block, uint16_t block_length); 72 void ParseDlrrBlock(const uint8_t* block, uint16_t block_length);
76 void ParseVoipMetricBlock(const uint8_t* block, uint16_t block_length); 73 void ParseVoipMetricBlock(const uint8_t* block, uint16_t block_length);
77 74
78 uint32_t sender_ssrc_; 75 uint32_t sender_ssrc_;
79 std::vector<Rrtr> rrtr_blocks_; 76 rtc::Optional<Rrtr> rrtr_block_;
80 std::vector<Dlrr> dlrr_blocks_; 77 Dlrr dlrr_block_; // Dlrr without items treated same as no dlrr block.
81 std::vector<VoipMetric> voip_metric_blocks_; 78 rtc::Optional<VoipMetric> voip_metric_block_;
82 79
83 RTC_DISALLOW_COPY_AND_ASSIGN(ExtendedReports); 80 RTC_DISALLOW_COPY_AND_ASSIGN(ExtendedReports);
84 }; 81 };
85 } // namespace rtcp 82 } // namespace rtcp
86 } // namespace webrtc 83 } // namespace webrtc
87 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_ 84 #endif // WEBRTC_MODULES_RTP_RTCP_SOURCE_RTCP_PACKET_EXTENDED_REPORTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698