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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 return kNotFound; | 174 return kNotFound; |
175 } | 175 } |
176 | 176 |
177 const RTPHeader* PacketBuffer::NextRtpHeader() const { | 177 const RTPHeader* PacketBuffer::NextRtpHeader() const { |
178 if (Empty()) { | 178 if (Empty()) { |
179 return NULL; | 179 return NULL; |
180 } | 180 } |
181 return const_cast<const RTPHeader*>(&(buffer_.front()->header)); | 181 return const_cast<const RTPHeader*>(&(buffer_.front()->header)); |
182 } | 182 } |
183 | 183 |
184 Packet* PacketBuffer::GetNextPacket(int* discard_count) { | 184 Packet* PacketBuffer::GetNextPacket(size_t* discard_count) { |
185 if (Empty()) { | 185 if (Empty()) { |
186 // Buffer is empty. | 186 // Buffer is empty. |
187 return NULL; | 187 return NULL; |
188 } | 188 } |
189 | 189 |
190 Packet* packet = buffer_.front(); | 190 Packet* packet = buffer_.front(); |
191 // Assert that the packet sanity checks in InsertPacket method works. | 191 // Assert that the packet sanity checks in InsertPacket method works. |
192 assert(packet && packet->payload); | 192 assert(packet && packet->payload); |
193 buffer_.pop_front(); | 193 buffer_.pop_front(); |
194 | 194 |
195 // Discard other packets with the same timestamp. These are duplicates or | 195 // Discard other packets with the same timestamp. These are duplicates or |
196 // redundant payloads that should not be used. | 196 // redundant payloads that should not be used. |
197 int discards = 0; | 197 size_t discards = 0; |
198 | 198 |
199 while (!Empty() && | 199 while (!Empty() && |
200 buffer_.front()->header.timestamp == packet->header.timestamp) { | 200 buffer_.front()->header.timestamp == packet->header.timestamp) { |
201 if (DiscardNextPacket() != kOK) { | 201 if (DiscardNextPacket() != kOK) { |
202 assert(false); // Must be ok by design. | 202 assert(false); // Must be ok by design. |
203 } | 203 } |
204 ++discards; | 204 ++discards; |
205 } | 205 } |
206 // The way of inserting packet should not cause any packet discarding here. | 206 // The way of inserting packet should not cause any packet discarding here. |
207 // TODO(minyue): remove |discard_count|. | 207 // TODO(minyue): remove |discard_count|. |
(...skipping 25 matching lines...) Expand all Loading... |
233 assert(false); // Must be ok by design. | 233 assert(false); // Must be ok by design. |
234 } | 234 } |
235 } | 235 } |
236 return 0; | 236 return 0; |
237 } | 237 } |
238 | 238 |
239 int PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit) { | 239 int PacketBuffer::DiscardAllOldPackets(uint32_t timestamp_limit) { |
240 return DiscardOldPackets(timestamp_limit, 0); | 240 return DiscardOldPackets(timestamp_limit, 0); |
241 } | 241 } |
242 | 242 |
243 int PacketBuffer::NumPacketsInBuffer() const { | 243 size_t PacketBuffer::NumPacketsInBuffer() const { |
244 return static_cast<int>(buffer_.size()); | 244 return buffer_.size(); |
245 } | 245 } |
246 | 246 |
247 int PacketBuffer::NumSamplesInBuffer(DecoderDatabase* decoder_database, | 247 size_t PacketBuffer::NumSamplesInBuffer(DecoderDatabase* decoder_database, |
248 int last_decoded_length) const { | 248 size_t last_decoded_length) const { |
249 PacketList::const_iterator it; | 249 PacketList::const_iterator it; |
250 int num_samples = 0; | 250 size_t num_samples = 0; |
251 int last_duration = last_decoded_length; | 251 size_t last_duration = last_decoded_length; |
252 for (it = buffer_.begin(); it != buffer_.end(); ++it) { | 252 for (it = buffer_.begin(); it != buffer_.end(); ++it) { |
253 Packet* packet = (*it); | 253 Packet* packet = (*it); |
254 AudioDecoder* decoder = | 254 AudioDecoder* decoder = |
255 decoder_database->GetDecoder(packet->header.payloadType); | 255 decoder_database->GetDecoder(packet->header.payloadType); |
256 if (decoder && !packet->sync_packet) { | 256 if (decoder && !packet->sync_packet) { |
257 if (!packet->primary) { | 257 if (!packet->primary) { |
258 continue; | 258 continue; |
259 } | 259 } |
260 int duration = | 260 int duration = |
261 decoder->PacketDuration(packet->payload, packet->payload_length); | 261 decoder->PacketDuration(packet->payload, packet->payload_length); |
(...skipping 29 matching lines...) Expand all Loading... |
291 // Continue while the list is not empty. | 291 // Continue while the list is not empty. |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const { | 295 void PacketBuffer::BufferStat(int* num_packets, int* max_num_packets) const { |
296 *num_packets = static_cast<int>(buffer_.size()); | 296 *num_packets = static_cast<int>(buffer_.size()); |
297 *max_num_packets = static_cast<int>(max_number_of_packets_); | 297 *max_num_packets = static_cast<int>(max_number_of_packets_); |
298 } | 298 } |
299 | 299 |
300 } // namespace webrtc | 300 } // namespace webrtc |
OLD | NEW |