OLD | NEW |
---|---|
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 Loading... | |
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 buffer_.SetSize(payload_offset_); // Reset payload size to avoid copying it. | |
sprang_webrtc
2016/09/27 10:45:00
I'm not sure I follow this. How does doing this Se
danilchap
2016/09/27 11:47:05
comment expanded.
this optimization was added to R
| |
277 payload_size_ = size_bytes; | 278 payload_size_ = size_bytes; |
278 buffer_.SetSize(payload_offset_ + payload_size_); | 279 buffer_.SetSize(payload_offset_ + payload_size_); |
279 return WriteAt(payload_offset_); | 280 return WriteAt(payload_offset_); |
280 } | 281 } |
281 | 282 |
282 void Packet::SetPayloadSize(size_t size_bytes) { | 283 void Packet::SetPayloadSize(size_t size_bytes) { |
283 RTC_DCHECK_EQ(padding_size_, 0u); | 284 RTC_DCHECK_EQ(padding_size_, 0u); |
284 RTC_DCHECK_LE(size_bytes, payload_size_); | 285 RTC_DCHECK_LE(size_bytes, payload_size_); |
285 payload_size_ = size_bytes; | 286 payload_size_ = size_bytes; |
286 buffer_.SetSize(payload_offset_ + payload_size_); | 287 buffer_.SetSize(payload_offset_ + payload_size_); |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 uint8_t* Packet::WriteAt(size_t offset) { | 523 uint8_t* Packet::WriteAt(size_t offset) { |
523 return buffer_.data() + offset; | 524 return buffer_.data() + offset; |
524 } | 525 } |
525 | 526 |
526 void Packet::WriteAt(size_t offset, uint8_t byte) { | 527 void Packet::WriteAt(size_t offset, uint8_t byte) { |
527 buffer_.data()[offset] = byte; | 528 buffer_.data()[offset] = byte; |
528 } | 529 } |
529 | 530 |
530 } // namespace rtp | 531 } // namespace rtp |
531 } // namespace webrtc | 532 } // namespace webrtc |
OLD | NEW |