Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(42)

Side by Side Diff: webrtc/modules/video_coding/main/source/jitter_buffer.cc

Issue 1211353002: Integration of VP9 packetization. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: set ss data if not set Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 : clock_(clock), 118 : clock_(clock),
119 running_(false), 119 running_(false),
120 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), 120 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()),
121 frame_event_(event.Pass()), 121 frame_event_(event.Pass()),
122 max_number_of_frames_(kStartNumberOfFrames), 122 max_number_of_frames_(kStartNumberOfFrames),
123 free_frames_(), 123 free_frames_(),
124 decodable_frames_(), 124 decodable_frames_(),
125 incomplete_frames_(), 125 incomplete_frames_(),
126 last_decoded_state_(), 126 last_decoded_state_(),
127 first_packet_since_reset_(true), 127 first_packet_since_reset_(true),
128 last_gof_timestamp_(0),
129 last_gof_valid_(false),
128 stats_callback_(NULL), 130 stats_callback_(NULL),
129 incoming_frame_rate_(0), 131 incoming_frame_rate_(0),
130 incoming_frame_count_(0), 132 incoming_frame_count_(0),
131 time_last_incoming_frame_count_(0), 133 time_last_incoming_frame_count_(0),
132 incoming_bit_count_(0), 134 incoming_bit_count_(0),
133 incoming_bit_rate_(0), 135 incoming_bit_rate_(0),
134 num_consecutive_old_packets_(0), 136 num_consecutive_old_packets_(0),
135 num_packets_(0), 137 num_packets_(0),
136 num_duplicated_packets_(0), 138 num_duplicated_packets_(0),
137 num_discarded_packets_(0), 139 num_discarded_packets_(0),
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 num_discarded_packets_ = 0; 215 num_discarded_packets_ = 0;
214 time_first_packet_ms_ = 0; 216 time_first_packet_ms_ = 0;
215 217
216 // Start in a non-signaled state. 218 // Start in a non-signaled state.
217 waiting_for_completion_.frame_size = 0; 219 waiting_for_completion_.frame_size = 0;
218 waiting_for_completion_.timestamp = 0; 220 waiting_for_completion_.timestamp = 0;
219 waiting_for_completion_.latest_packet_time = -1; 221 waiting_for_completion_.latest_packet_time = -1;
220 first_packet_since_reset_ = true; 222 first_packet_since_reset_ = true;
221 rtt_ms_ = kDefaultRtt; 223 rtt_ms_ = kDefaultRtt;
222 last_decoded_state_.Reset(); 224 last_decoded_state_.Reset();
225 last_gof_valid_ = false;
223 } 226 }
224 227
225 void VCMJitterBuffer::Stop() { 228 void VCMJitterBuffer::Stop() {
226 crit_sect_->Enter(); 229 crit_sect_->Enter();
227 UpdateHistograms(); 230 UpdateHistograms();
228 running_ = false; 231 running_ = false;
229 last_decoded_state_.Reset(); 232 last_decoded_state_.Reset();
233 last_gof_valid_ = false;
234
230 // Make sure all frames are free and reset. 235 // Make sure all frames are free and reset.
231 for (FrameList::iterator it = decodable_frames_.begin(); 236 for (FrameList::iterator it = decodable_frames_.begin();
232 it != decodable_frames_.end(); ++it) { 237 it != decodable_frames_.end(); ++it) {
233 free_frames_.push_back(it->second); 238 free_frames_.push_back(it->second);
234 } 239 }
235 for (FrameList::iterator it = incomplete_frames_.begin(); 240 for (FrameList::iterator it = incomplete_frames_.begin();
236 it != incomplete_frames_.end(); ++it) { 241 it != incomplete_frames_.end(); ++it) {
237 free_frames_.push_back(it->second); 242 free_frames_.push_back(it->second);
238 } 243 }
239 for (UnorderedFrameList::iterator it = free_frames_.begin(); 244 for (UnorderedFrameList::iterator it = free_frames_.begin();
(...skipping 10 matching lines...) Expand all
250 bool VCMJitterBuffer::Running() const { 255 bool VCMJitterBuffer::Running() const {
251 CriticalSectionScoped cs(crit_sect_); 256 CriticalSectionScoped cs(crit_sect_);
252 return running_; 257 return running_;
253 } 258 }
254 259
255 void VCMJitterBuffer::Flush() { 260 void VCMJitterBuffer::Flush() {
256 CriticalSectionScoped cs(crit_sect_); 261 CriticalSectionScoped cs(crit_sect_);
257 decodable_frames_.Reset(&free_frames_); 262 decodable_frames_.Reset(&free_frames_);
258 incomplete_frames_.Reset(&free_frames_); 263 incomplete_frames_.Reset(&free_frames_);
259 last_decoded_state_.Reset(); // TODO(mikhal): sync reset. 264 last_decoded_state_.Reset(); // TODO(mikhal): sync reset.
265 last_gof_valid_ = false;
260 num_consecutive_old_packets_ = 0; 266 num_consecutive_old_packets_ = 0;
261 // Also reset the jitter and delay estimates 267 // Also reset the jitter and delay estimates
262 jitter_estimate_.Reset(); 268 jitter_estimate_.Reset();
263 inter_frame_delay_.Reset(clock_->TimeInMilliseconds()); 269 inter_frame_delay_.Reset(clock_->TimeInMilliseconds());
264 waiting_for_completion_.frame_size = 0; 270 waiting_for_completion_.frame_size = 0;
265 waiting_for_completion_.timestamp = 0; 271 waiting_for_completion_.timestamp = 0;
266 waiting_for_completion_.latest_packet_time = -1; 272 waiting_for_completion_.latest_packet_time = -1;
267 first_packet_since_reset_ = true; 273 first_packet_since_reset_ = true;
268 missing_sequence_numbers_.clear(); 274 missing_sequence_numbers_.clear();
269 } 275 }
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 if (num_consecutive_old_packets_ > kMaxConsecutiveOldPackets) { 585 if (num_consecutive_old_packets_ > kMaxConsecutiveOldPackets) {
580 LOG(LS_WARNING) 586 LOG(LS_WARNING)
581 << num_consecutive_old_packets_ 587 << num_consecutive_old_packets_
582 << " consecutive old packets received. Flushing the jitter buffer."; 588 << " consecutive old packets received. Flushing the jitter buffer.";
583 Flush(); 589 Flush();
584 return kFlushIndicator; 590 return kFlushIndicator;
585 } 591 }
586 return kOldPacket; 592 return kOldPacket;
587 } 593 }
588 594
595 if (packet.codec == kVideoCodecVP9) {
596 // TODO(asapersson): Move this code to appropriate place.
597 // TODO(asapersson): Handle out of order GOF.
598 if (packet.codecSpecificHeader.codecHeader.VP9.flexible_mode) {
599 // TODO(asapersson): Add support for flexible mode.
600 return kGeneralError;
601 }
602 if (packet.codecSpecificHeader.codecHeader.VP9.ss_data_available) {
603 if (!last_gof_valid_ ||
604 IsNewerTimestamp(packet.timestamp, last_gof_timestamp_)) {
605 last_gof_.CopyGofInfoVP9(
606 packet.codecSpecificHeader.codecHeader.VP9.gof);
607 last_gof_timestamp_ = packet.timestamp;
608 last_gof_valid_ = true;
609 }
610 }
611 if (last_gof_valid_ &&
612 !packet.codecSpecificHeader.codecHeader.VP9.flexible_mode) {
613 uint8_t gof_idx = packet.codecSpecificHeader.codecHeader.VP9.gof_idx;
614 if (gof_idx != kNoGofIdx) {
615 if (gof_idx >= last_gof_.num_frames_in_gof) {
616 LOG(LS_WARNING) << "Incorrect gof_idx: " << gof_idx;
617 return kGeneralError;
618 }
619 RTPVideoTypeHeader* hdr = const_cast<RTPVideoTypeHeader*>(
620 &packet.codecSpecificHeader.codecHeader);
621 hdr->VP9.temporal_idx = last_gof_.temporal_idx[gof_idx];
622 hdr->VP9.temporal_up_switch = last_gof_.temporal_up_switch[gof_idx];
623 }
624 }
625 }
626
589 num_consecutive_old_packets_ = 0; 627 num_consecutive_old_packets_ = 0;
590 628
591 VCMFrameBuffer* frame; 629 VCMFrameBuffer* frame;
592 FrameList* frame_list; 630 FrameList* frame_list;
593 const VCMFrameBufferEnum error = GetFrame(packet, &frame, &frame_list); 631 const VCMFrameBufferEnum error = GetFrame(packet, &frame, &frame_list);
594 if (error != kNoError) 632 if (error != kNoError)
595 return error; 633 return error;
596 634
597 int64_t now_ms = clock_->TimeInMilliseconds(); 635 int64_t now_ms = clock_->TimeInMilliseconds();
598 // We are keeping track of the first and latest seq numbers, and 636 // We are keeping track of the first and latest seq numbers, and
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after
1215 } 1253 }
1216 // Evaluate if the RTT is higher than |high_rtt_nack_threshold_ms_|, and in 1254 // Evaluate if the RTT is higher than |high_rtt_nack_threshold_ms_|, and in
1217 // that case we don't wait for retransmissions. 1255 // that case we don't wait for retransmissions.
1218 if (high_rtt_nack_threshold_ms_ >= 0 && 1256 if (high_rtt_nack_threshold_ms_ >= 0 &&
1219 rtt_ms_ >= high_rtt_nack_threshold_ms_) { 1257 rtt_ms_ >= high_rtt_nack_threshold_ms_) {
1220 return false; 1258 return false;
1221 } 1259 }
1222 return true; 1260 return true;
1223 } 1261 }
1224 } // namespace webrtc 1262 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/main/source/jitter_buffer.h ('k') | webrtc/modules/video_coding/main/source/session_info.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698