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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.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/sdes.h" 11 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.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 // Source Description (SDES) (RFC 3550). 22 // Source Description (SDES) (RFC 3550).
21 // 23 //
22 // 0 1 2 3 24 // 0 1 2 3
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 132 }
131 // Adjust to 32bit boundary. 133 // Adjust to 32bit boundary.
132 looking_at += (payload_end - looking_at) % 4; 134 looking_at += (payload_end - looking_at) % 4;
133 } 135 }
134 136
135 chunks_ = std::move(chunks); 137 chunks_ = std::move(chunks);
136 block_length_ = block_length; 138 block_length_ = block_length;
137 return true; 139 return true;
138 } 140 }
139 141
140 bool Sdes::WithCName(uint32_t ssrc, const std::string& cname) { 142 bool Sdes::AddCName(uint32_t ssrc, std::string cname) {
141 RTC_DCHECK_LE(cname.length(), 0xffu); 143 RTC_DCHECK_LE(cname.length(), 0xffu);
142 if (chunks_.size() >= kMaxNumberOfChunks) { 144 if (chunks_.size() >= kMaxNumberOfChunks) {
143 LOG(LS_WARNING) << "Max SDES chunks reached."; 145 LOG(LS_WARNING) << "Max SDES chunks reached.";
144 return false; 146 return false;
145 } 147 }
146 Chunk chunk; 148 Chunk chunk;
147 chunk.ssrc = ssrc; 149 chunk.ssrc = ssrc;
148 chunk.cname = cname; 150 chunk.cname = std::move(cname);
149 chunks_.push_back(chunk); 151 chunks_.push_back(chunk);
150 block_length_ += ChunkSize(chunk); 152 block_length_ += ChunkSize(chunk);
151 return true; 153 return true;
152 } 154 }
153 155
154 bool Sdes::Create(uint8_t* packet, 156 bool Sdes::Create(uint8_t* packet,
155 size_t* index, 157 size_t* index,
156 size_t max_length, 158 size_t max_length,
157 RtcpPacket::PacketReadyCallback* callback) const { 159 RtcpPacket::PacketReadyCallback* callback) const {
158 while (*index + BlockLength() > max_length) { 160 while (*index + BlockLength() > max_length) {
(...skipping 18 matching lines...) Expand all
177 const int kPadding = 0; 179 const int kPadding = 0;
178 memset(packet + *index, kPadding, padding_size); 180 memset(packet + *index, kPadding, padding_size);
179 *index += padding_size; 181 *index += padding_size;
180 } 182 }
181 183
182 RTC_CHECK_EQ(*index, index_end); 184 RTC_CHECK_EQ(*index, index_end);
183 return true; 185 return true;
184 } 186 }
185 } // namespace rtcp 187 } // namespace rtcp
186 } // namespace webrtc 188 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes.h ('k') | webrtc/modules/rtp_rtcp/source/rtcp_packet/sdes_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698