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

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

Issue 2370313002: Reland of Unify rtcp packet setters (Closed)
Patch Set: Fix breaking mistype 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) 2015 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2015 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/bye.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.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 22
21 // Bye packet (BYE) (RFC 3550). 23 // Bye packet (BYE) (RFC 3550).
22 // 24 //
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 RTC_DCHECK_LE(bytes_to_pad, 3u); 104 RTC_DCHECK_LE(bytes_to_pad, 3u);
103 if (bytes_to_pad > 0) { 105 if (bytes_to_pad > 0) {
104 memset(&packet[*index], 0, bytes_to_pad); 106 memset(&packet[*index], 0, bytes_to_pad);
105 *index += bytes_to_pad; 107 *index += bytes_to_pad;
106 } 108 }
107 } 109 }
108 RTC_DCHECK_EQ(index_end, *index); 110 RTC_DCHECK_EQ(index_end, *index);
109 return true; 111 return true;
110 } 112 }
111 113
112 bool Bye::WithCsrc(uint32_t csrc) { 114 bool Bye::SetCsrcs(std::vector<uint32_t> csrcs) {
113 if (csrcs_.size() >= kMaxNumberOfCsrcs) { 115 if (csrcs.size() > kMaxNumberOfCsrcs) {
114 LOG(LS_WARNING) << "Max CSRC size reached."; 116 LOG(LS_WARNING) << "Too many CSRCs for Bye packet.";
115 return false; 117 return false;
116 } 118 }
117 csrcs_.push_back(csrc); 119 csrcs_ = std::move(csrcs);
118 return true; 120 return true;
119 } 121 }
120 122
121 void Bye::WithReason(const std::string& reason) { 123 void Bye::SetReason(std::string reason) {
122 RTC_DCHECK_LE(reason.size(), 0xffu); 124 RTC_DCHECK_LE(reason.size(), 0xffu);
123 reason_ = reason; 125 reason_ = std::move(reason);
124 } 126 }
125 127
126 size_t Bye::BlockLength() const { 128 size_t Bye::BlockLength() const {
127 size_t src_count = (1 + csrcs_.size()); 129 size_t src_count = (1 + csrcs_.size());
128 size_t reason_size_in_32bits = reason_.empty() ? 0 : (reason_.size() / 4 + 1); 130 size_t reason_size_in_32bits = reason_.empty() ? 0 : (reason_.size() / 4 + 1);
129 return kHeaderLength + 4 * (src_count + reason_size_in_32bits); 131 return kHeaderLength + 4 * (src_count + reason_size_in_32bits);
130 } 132 }
131 133
132 } // namespace rtcp 134 } // namespace rtcp
133 } // namespace webrtc 135 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/bye_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698