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 #include "webrtc/modules/video_coding/main/source/jitter_buffer.h" | 10 #include "webrtc/modules/video_coding/main/source/jitter_buffer.h" |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 num_discarded_packets_ = 0; | 310 num_discarded_packets_ = 0; |
311 time_first_packet_ms_ = 0; | 311 time_first_packet_ms_ = 0; |
312 | 312 |
313 // Start in a non-signaled state. | 313 // Start in a non-signaled state. |
314 waiting_for_completion_.frame_size = 0; | 314 waiting_for_completion_.frame_size = 0; |
315 waiting_for_completion_.timestamp = 0; | 315 waiting_for_completion_.timestamp = 0; |
316 waiting_for_completion_.latest_packet_time = -1; | 316 waiting_for_completion_.latest_packet_time = -1; |
317 first_packet_since_reset_ = true; | 317 first_packet_since_reset_ = true; |
318 rtt_ms_ = kDefaultRtt; | 318 rtt_ms_ = kDefaultRtt; |
319 last_decoded_state_.Reset(); | 319 last_decoded_state_.Reset(); |
320 vp9_ss_map_.Reset(); | |
321 } | 320 } |
322 | 321 |
323 void VCMJitterBuffer::Stop() { | 322 void VCMJitterBuffer::Stop() { |
324 crit_sect_->Enter(); | 323 crit_sect_->Enter(); |
325 UpdateHistograms(); | 324 UpdateHistograms(); |
326 running_ = false; | 325 running_ = false; |
327 last_decoded_state_.Reset(); | 326 last_decoded_state_.Reset(); |
328 vp9_ss_map_.Reset(); | |
329 | 327 |
330 // Make sure all frames are free and reset. | 328 // Make sure all frames are free and reset. |
331 for (FrameList::iterator it = decodable_frames_.begin(); | 329 for (FrameList::iterator it = decodable_frames_.begin(); |
332 it != decodable_frames_.end(); ++it) { | 330 it != decodable_frames_.end(); ++it) { |
333 free_frames_.push_back(it->second); | 331 free_frames_.push_back(it->second); |
334 } | 332 } |
335 for (FrameList::iterator it = incomplete_frames_.begin(); | 333 for (FrameList::iterator it = incomplete_frames_.begin(); |
336 it != incomplete_frames_.end(); ++it) { | 334 it != incomplete_frames_.end(); ++it) { |
337 free_frames_.push_back(it->second); | 335 free_frames_.push_back(it->second); |
338 } | 336 } |
(...skipping 11 matching lines...) Expand all Loading... |
350 bool VCMJitterBuffer::Running() const { | 348 bool VCMJitterBuffer::Running() const { |
351 CriticalSectionScoped cs(crit_sect_); | 349 CriticalSectionScoped cs(crit_sect_); |
352 return running_; | 350 return running_; |
353 } | 351 } |
354 | 352 |
355 void VCMJitterBuffer::Flush() { | 353 void VCMJitterBuffer::Flush() { |
356 CriticalSectionScoped cs(crit_sect_); | 354 CriticalSectionScoped cs(crit_sect_); |
357 decodable_frames_.Reset(&free_frames_); | 355 decodable_frames_.Reset(&free_frames_); |
358 incomplete_frames_.Reset(&free_frames_); | 356 incomplete_frames_.Reset(&free_frames_); |
359 last_decoded_state_.Reset(); // TODO(mikhal): sync reset. | 357 last_decoded_state_.Reset(); // TODO(mikhal): sync reset. |
360 vp9_ss_map_.Reset(); | |
361 num_consecutive_old_packets_ = 0; | 358 num_consecutive_old_packets_ = 0; |
362 // Also reset the jitter and delay estimates | 359 // Also reset the jitter and delay estimates |
363 jitter_estimate_.Reset(); | 360 jitter_estimate_.Reset(); |
364 inter_frame_delay_.Reset(clock_->TimeInMilliseconds()); | 361 inter_frame_delay_.Reset(clock_->TimeInMilliseconds()); |
365 waiting_for_completion_.frame_size = 0; | 362 waiting_for_completion_.frame_size = 0; |
366 waiting_for_completion_.timestamp = 0; | 363 waiting_for_completion_.timestamp = 0; |
367 waiting_for_completion_.latest_packet_time = -1; | 364 waiting_for_completion_.latest_packet_time = -1; |
368 first_packet_since_reset_ = true; | 365 first_packet_since_reset_ = true; |
369 missing_sequence_numbers_.clear(); | 366 missing_sequence_numbers_.clear(); |
370 } | 367 } |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
682 << num_consecutive_old_packets_ | 679 << num_consecutive_old_packets_ |
683 << " consecutive old packets received. Flushing the jitter buffer."; | 680 << " consecutive old packets received. Flushing the jitter buffer."; |
684 Flush(); | 681 Flush(); |
685 return kFlushIndicator; | 682 return kFlushIndicator; |
686 } | 683 } |
687 return kOldPacket; | 684 return kOldPacket; |
688 } | 685 } |
689 | 686 |
690 num_consecutive_old_packets_ = 0; | 687 num_consecutive_old_packets_ = 0; |
691 | 688 |
692 if (packet.codec == kVideoCodecVP9) { | 689 if (packet.codec == kVideoCodecVP9 && |
693 if (packet.codecSpecificHeader.codecHeader.VP9.flexible_mode) { | 690 packet.codecSpecificHeader.codecHeader.VP9.flexible_mode) { |
694 // TODO(asapersson): Add support for flexible mode. | 691 // TODO(asapersson): Add support for flexible mode. |
695 return kGeneralError; | 692 return kGeneralError; |
696 } | |
697 if (!packet.codecSpecificHeader.codecHeader.VP9.flexible_mode) { | |
698 if (vp9_ss_map_.Insert(packet)) | |
699 vp9_ss_map_.UpdateFrames(&incomplete_frames_); | |
700 | |
701 vp9_ss_map_.UpdatePacket(const_cast<VCMPacket*>(&packet)); | |
702 } | |
703 if (!last_decoded_state_.in_initial_state()) | |
704 vp9_ss_map_.RemoveOld(last_decoded_state_.time_stamp()); | |
705 } | 693 } |
706 | 694 |
707 VCMFrameBuffer* frame; | 695 VCMFrameBuffer* frame; |
708 FrameList* frame_list; | 696 FrameList* frame_list; |
709 const VCMFrameBufferEnum error = GetFrame(packet, &frame, &frame_list); | 697 const VCMFrameBufferEnum error = GetFrame(packet, &frame, &frame_list); |
710 if (error != kNoError) | 698 if (error != kNoError) |
711 return error; | 699 return error; |
712 | 700 |
713 int64_t now_ms = clock_->TimeInMilliseconds(); | 701 int64_t now_ms = clock_->TimeInMilliseconds(); |
714 // We are keeping track of the first and latest seq numbers, and | 702 // We are keeping track of the first and latest seq numbers, and |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1331 } | 1319 } |
1332 // Evaluate if the RTT is higher than |high_rtt_nack_threshold_ms_|, and in | 1320 // Evaluate if the RTT is higher than |high_rtt_nack_threshold_ms_|, and in |
1333 // that case we don't wait for retransmissions. | 1321 // that case we don't wait for retransmissions. |
1334 if (high_rtt_nack_threshold_ms_ >= 0 && | 1322 if (high_rtt_nack_threshold_ms_ >= 0 && |
1335 rtt_ms_ >= high_rtt_nack_threshold_ms_) { | 1323 rtt_ms_ >= high_rtt_nack_threshold_ms_) { |
1336 return false; | 1324 return false; |
1337 } | 1325 } |
1338 return true; | 1326 return true; |
1339 } | 1327 } |
1340 } // namespace webrtc | 1328 } // namespace webrtc |
OLD | NEW |