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

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtp_packet.cc

Issue 2217383002: Use RtpPacketToSend in RtpSenderVideo (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Expand comment about non-trivial minor optimization in rtp::Packet::AllocatePayload 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
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_sender.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 } 267 }
268 buffer_.SetSize(payload_offset_); 268 buffer_.SetSize(payload_offset_);
269 } 269 }
270 270
271 uint8_t* Packet::AllocatePayload(size_t size_bytes) { 271 uint8_t* Packet::AllocatePayload(size_t size_bytes) {
272 RTC_DCHECK_EQ(padding_size_, 0u); 272 RTC_DCHECK_EQ(padding_size_, 0u);
273 if (payload_offset_ + size_bytes > capacity()) { 273 if (payload_offset_ + size_bytes > capacity()) {
274 LOG(LS_WARNING) << "Cannot set payload, not enough space in buffer."; 274 LOG(LS_WARNING) << "Cannot set payload, not enough space in buffer.";
275 return nullptr; 275 return nullptr;
276 } 276 }
277 // Reset payload size to 0. If CopyOnWrite buffer_ was shared, this will cause
278 // reallocation and memcpy. Setting size to just headers reduces memcpy size.
279 buffer_.SetSize(payload_offset_);
277 payload_size_ = size_bytes; 280 payload_size_ = size_bytes;
278 buffer_.SetSize(payload_offset_ + payload_size_); 281 buffer_.SetSize(payload_offset_ + payload_size_);
279 return WriteAt(payload_offset_); 282 return WriteAt(payload_offset_);
280 } 283 }
281 284
282 void Packet::SetPayloadSize(size_t size_bytes) { 285 void Packet::SetPayloadSize(size_t size_bytes) {
283 RTC_DCHECK_EQ(padding_size_, 0u); 286 RTC_DCHECK_EQ(padding_size_, 0u);
284 RTC_DCHECK_LE(size_bytes, payload_size_); 287 RTC_DCHECK_LE(size_bytes, payload_size_);
285 payload_size_ = size_bytes; 288 payload_size_ = size_bytes;
286 buffer_.SetSize(payload_offset_ + payload_size_); 289 buffer_.SetSize(payload_offset_ + payload_size_);
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 uint8_t* Packet::WriteAt(size_t offset) { 525 uint8_t* Packet::WriteAt(size_t offset) {
523 return buffer_.data() + offset; 526 return buffer_.data() + offset;
524 } 527 }
525 528
526 void Packet::WriteAt(size_t offset, uint8_t byte) { 529 void Packet::WriteAt(size_t offset, uint8_t byte) {
527 buffer_.data()[offset] = byte; 530 buffer_.data()[offset] = byte;
528 } 531 }
529 532
530 } // namespace rtp 533 } // namespace rtp
531 } // namespace webrtc 534 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/rtp_rtcp/source/rtp_sender.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698