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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.cc

Issue 2348623003: Unify rtcp packet setters (Closed)
Patch Set: +call/rtc_event_log_unittest 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 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h"
12 12
13 #include <utility>
14
13 #include "webrtc/base/checks.h" 15 #include "webrtc/base/checks.h"
14 #include "webrtc/base/logging.h" 16 #include "webrtc/base/logging.h"
15 #include "webrtc/modules/rtp_rtcp/source/byte_io.h" 17 #include "webrtc/modules/rtp_rtcp/source/byte_io.h"
16 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" 18 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h"
17 19
18 namespace webrtc { 20 namespace webrtc {
19 namespace rtcp { 21 namespace rtcp {
20 constexpr uint8_t Remb::kFeedbackMessageType; 22 constexpr uint8_t Remb::kFeedbackMessageType;
21 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb). 23 // Receiver Estimated Max Bitrate (REMB) (draft-alvestrand-rmcat-remb).
22 // 24 //
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 ssrcs_.clear(); 76 ssrcs_.clear();
75 ssrcs_.reserve(number_of_ssrcs); 77 ssrcs_.reserve(number_of_ssrcs);
76 for (uint8_t i = 0; i < number_of_ssrcs; ++i) { 78 for (uint8_t i = 0; i < number_of_ssrcs; ++i) {
77 ssrcs_.push_back(ByteReader<uint32_t>::ReadBigEndian(next_ssrc)); 79 ssrcs_.push_back(ByteReader<uint32_t>::ReadBigEndian(next_ssrc));
78 next_ssrc += sizeof(uint32_t); 80 next_ssrc += sizeof(uint32_t);
79 } 81 }
80 82
81 return true; 83 return true;
82 } 84 }
83 85
84 bool Remb::AppliesTo(uint32_t ssrc) { 86 bool Remb::SetSsrcs(std::vector<uint32_t> ssrcs) {
85 if (ssrcs_.size() >= kMaxNumberOfSsrcs) { 87 if (ssrcs.size() > kMaxNumberOfSsrcs) {
86 LOG(LS_WARNING) << "Max number of REMB feedback SSRCs reached."; 88 LOG(LS_WARNING) << "Not enough space for all given SSRCs.";
87 return false; 89 return false;
88 } 90 }
89 ssrcs_.push_back(ssrc); 91 ssrcs_ = std::move(ssrcs);
90 return true; 92 return true;
91 } 93 }
92 94
93 bool Remb::AppliesToMany(const std::vector<uint32_t>& ssrcs) {
94 if (ssrcs_.size() + ssrcs.size() > kMaxNumberOfSsrcs) {
95 LOG(LS_WARNING) << "Not enough space for all given SSRCs.";
96 return false;
97 }
98 // Append.
99 ssrcs_.insert(ssrcs_.end(), ssrcs.begin(), ssrcs.end());
100 return true;
101 }
102
103 bool Remb::Create(uint8_t* packet, 95 bool Remb::Create(uint8_t* packet,
104 size_t* index, 96 size_t* index,
105 size_t max_length, 97 size_t max_length,
106 RtcpPacket::PacketReadyCallback* callback) const { 98 RtcpPacket::PacketReadyCallback* callback) const {
107 while (*index + BlockLength() > max_length) { 99 while (*index + BlockLength() > max_length) {
108 if (!OnBufferFull(packet, index, callback)) 100 if (!OnBufferFull(packet, index, callback))
109 return false; 101 return false;
110 } 102 }
111 size_t index_end = *index + BlockLength(); 103 size_t index_end = *index + BlockLength();
112 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet, 104 CreateHeader(kFeedbackMessageType, kPacketType, HeaderLength(), packet,
(...skipping 18 matching lines...) Expand all
131 123
132 for (uint32_t ssrc : ssrcs_) { 124 for (uint32_t ssrc : ssrcs_) {
133 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, ssrc); 125 ByteWriter<uint32_t>::WriteBigEndian(packet + *index, ssrc);
134 *index += sizeof(uint32_t); 126 *index += sizeof(uint32_t);
135 } 127 }
136 RTC_DCHECK_EQ(index_end, *index); 128 RTC_DCHECK_EQ(index_end, *index);
137 return true; 129 return true;
138 } 130 }
139 } // namespace rtcp 131 } // namespace rtcp
140 } // namespace webrtc 132 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/remb.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/remb_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698