OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
255 } | 255 } |
256 return 0; | 256 return 0; |
257 } | 257 } |
258 | 258 |
259 int PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit) { | 259 int PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit) { |
260 return DiscardOldPackets(timestamp_limit, 0); | 260 return DiscardOldPackets(timestamp_limit, 0); |
261 } | 261 } |
262 | 262 |
263 void PacketBuffer::DiscardPacketsWithPayloadType(uint8_t payload_type) { | 263 void PacketBuffer::DiscardPacketsWithPayloadType(uint8_t payload_type) { |
264 for (auto it = buffer_.begin(); it != buffer_.end(); /* */) { | 264 for (auto it = buffer_.begin(); it != buffer_.end(); /* */) { |
265 Packet *packet = *it; | 265 Packet *packet = *it; |
hlundin-webrtc
2016/09/20 07:02:24
Packet* packet
ossu
2016/09/20 13:51:56
Acknowledged.
| |
266 if (packet->header.payloadType == payload_type) { | 266 if (packet->header.payloadType == payload_type) { |
267 delete packet; | 267 delete packet; |
268 it = buffer_.erase(it); | 268 it = buffer_.erase(it); |
269 } else { | 269 } else { |
270 ++it; | 270 ++it; |
271 } | 271 } |
272 } | 272 } |
kwiberg-webrtc
2016/09/20 09:14:45
Can you use std::remove_if instead? It should be s
ossu
2016/09/20 13:51:56
Since buffer_ is a std::list, this runs in O(n) an
kwiberg-webrtc
2016/09/20 14:56:23
Aha, an std::list. And yes, the manual memory mana
| |
273 } | 273 } |
274 | 274 |
275 size_t PacketBuffer::NumPacketsInBuffer() const { | 275 size_t PacketBuffer::NumPacketsInBuffer() const { |
276 return buffer_.size(); | 276 return buffer_.size(); |
277 } | 277 } |
278 | 278 |
279 size_t PacketBuffer::NumSamplesInBuffer(size_t last_decoded_length) const { | 279 size_t PacketBuffer::NumSamplesInBuffer(size_t last_decoded_length) const { |
280 size_t num_samples = 0; | 280 size_t num_samples = 0; |
281 size_t last_duration = last_decoded_length; | 281 size_t last_duration = last_decoded_length; |
282 for (Packet* packet : buffer_) { | 282 for (Packet* packet : buffer_) { |
283 if (packet->frame) { | 283 if (packet->frame) { |
284 if (!packet->primary) { | 284 // TODO(hlundin): Verify that it's fine to count all packets and remove |
285 // this check. | |
286 if (packet->priority != Packet::Priority(0, 0)) { | |
285 continue; | 287 continue; |
286 } | 288 } |
287 size_t duration = packet->frame->Duration(); | 289 size_t duration = packet->frame->Duration(); |
288 if (duration > 0) { | 290 if (duration > 0) { |
289 last_duration = duration; // Save the most up-to-date (valid) duration. | 291 last_duration = duration; // Save the most up-to-date (valid) duration. |
290 } | 292 } |
291 } | 293 } |
292 num_samples += last_duration; | 294 num_samples += last_duration; |
293 } | 295 } |
294 return num_samples; | 296 return num_samples; |
(...skipping 14 matching lines...) Expand all Loading... | |
309 // Continue while the list is not empty. | 311 // Continue while the list is not empty. |
310 } | 312 } |
311 } | 313 } |
312 | 314 |
313 void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const { | 315 void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const { |
314 *num_packets = static_cast<int>(buffer_.size()); | 316 *num_packets = static_cast<int>(buffer_.size()); |
315 *max_num_packets = static_cast<int>(max_number_of_packets_); | 317 *max_num_packets = static_cast<int>(max_number_of_packets_); |
316 } | 318 } |
317 | 319 |
318 } // namespace webrtc | 320 } // namespace webrtc |
OLD | NEW |