| 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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Assert that the packet sanity checks in InsertPacket method works. | 214 // Assert that the packet sanity checks in InsertPacket method works. |
| 215 RTC_DCHECK(!buffer_.front().empty()); | 215 RTC_DCHECK(!buffer_.front().empty()); |
| 216 buffer_.pop_front(); | 216 buffer_.pop_front(); |
| 217 stats->PacketsDiscarded(1); | 217 stats->PacketsDiscarded(1); |
| 218 return kOK; | 218 return kOK; |
| 219 } | 219 } |
| 220 | 220 |
| 221 void PacketBuffer::DiscardOldPackets(uint32_t timestamp_limit, | 221 void PacketBuffer::DiscardOldPackets(uint32_t timestamp_limit, |
| 222 uint32_t horizon_samples, | 222 uint32_t horizon_samples, |
| 223 StatisticsCalculator* stats) { | 223 StatisticsCalculator* stats) { |
| 224 // TODO(minyue): the following implementation is wrong. It won't discard | 224 const size_t old_size = buffer_.size(); |
| 225 // old packets if the buffer_.front() is newer than timestamp_limit - | 225 buffer_.remove_if([timestamp_limit, horizon_samples](const Packet& p) { |
| 226 // horizon_samples. https://bugs.chromium.org/p/webrtc/issues/detail?id=7937 | 226 return timestamp_limit != p.timestamp && |
| 227 while (!Empty() && timestamp_limit != buffer_.front().timestamp && | 227 IsObsoleteTimestamp(p.timestamp, timestamp_limit, horizon_samples); |
| 228 IsObsoleteTimestamp(buffer_.front().timestamp, timestamp_limit, | 228 }); |
| 229 horizon_samples)) { | 229 if (old_size > buffer_.size()) { |
| 230 if (DiscardNextPacket(stats) != kOK) { | 230 stats->PacketsDiscarded(old_size - buffer_.size()); |
| 231 assert(false); // Must be ok by design. | |
| 232 } | |
| 233 } | 231 } |
| 234 } | 232 } |
| 235 | 233 |
| 236 void PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit, | 234 void PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit, |
| 237 StatisticsCalculator* stats) { | 235 StatisticsCalculator* stats) { |
| 238 DiscardOldPackets(timestamp_limit, 0, stats); | 236 DiscardOldPackets(timestamp_limit, 0, stats); |
| 239 } | 237 } |
| 240 | 238 |
| 241 void PacketBuffer::DiscardPacketsWithPayloadType(uint8_t payload_type, | 239 void PacketBuffer::DiscardPacketsWithPayloadType(uint8_t payload_type, |
| 242 StatisticsCalculator* stats) { | 240 StatisticsCalculator* stats) { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 } | 275 } |
| 278 return num_samples; | 276 return num_samples; |
| 279 } | 277 } |
| 280 | 278 |
| 281 void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const { | 279 void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const { |
| 282 *num_packets = static_cast<int>(buffer_.size()); | 280 *num_packets = static_cast<int>(buffer_.size()); |
| 283 *max_num_packets = static_cast<int>(max_number_of_packets_); | 281 *max_num_packets = static_cast<int>(max_number_of_packets_); |
| 284 } | 282 } |
| 285 | 283 |
| 286 } // namespace webrtc | 284 } // namespace webrtc |
| OLD | NEW |