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

Side by Side Diff: webrtc/video/video_receive_stream.cc

Issue 2656983002: Revert of Make the new jitter buffer the default jitter buffer. (Closed)
Patch Set: Rebase Created 3 years, 10 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
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | webrtc/video/video_stream_decoder.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 num_cpu_cores_(num_cpu_cores), 200 num_cpu_cores_(num_cpu_cores),
201 process_thread_(process_thread), 201 process_thread_(process_thread),
202 clock_(Clock::GetRealTimeClock()), 202 clock_(Clock::GetRealTimeClock()),
203 decode_thread_(DecodeThreadFunction, this, "DecodingThread"), 203 decode_thread_(DecodeThreadFunction, this, "DecodingThread"),
204 congestion_controller_(congestion_controller), 204 congestion_controller_(congestion_controller),
205 call_stats_(call_stats), 205 call_stats_(call_stats),
206 timing_(new VCMTiming(clock_)), 206 timing_(new VCMTiming(clock_)),
207 video_receiver_(clock_, nullptr, this, timing_.get(), this, this), 207 video_receiver_(clock_, nullptr, this, timing_.get(), this, this),
208 stats_proxy_(&config_, clock_), 208 stats_proxy_(&config_, clock_),
209 rtp_stream_receiver_( 209 rtp_stream_receiver_(
210 &video_receiver_,
210 congestion_controller_->GetRemoteBitrateEstimator( 211 congestion_controller_->GetRemoteBitrateEstimator(
211 UseSendSideBwe(config_)), 212 UseSendSideBwe(config_)),
212 &transport_adapter_, 213 &transport_adapter_,
213 call_stats_->rtcp_rtt_stats(), 214 call_stats_->rtcp_rtt_stats(),
214 packet_router, 215 packet_router,
215 remb, 216 remb,
216 &config_, 217 &config_,
217 &stats_proxy_, 218 &stats_proxy_,
218 process_thread_, 219 process_thread_,
219 this, // NackSender 220 this, // NackSender
220 this, // KeyFrameRequestSender 221 this, // KeyFrameRequestSender
221 this, // OnCompleteFrameCallback 222 this, // OnCompleteFrameCallback
222 timing_.get()), 223 timing_.get()),
223 rtp_stream_sync_(&video_receiver_, &rtp_stream_receiver_) { 224 rtp_stream_sync_(&video_receiver_, &rtp_stream_receiver_),
225 jitter_buffer_experiment_(
226 field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") ==
227 "Enabled") {
224 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); 228 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString();
225 229
226 RTC_DCHECK(process_thread_); 230 RTC_DCHECK(process_thread_);
227 RTC_DCHECK(congestion_controller_); 231 RTC_DCHECK(congestion_controller_);
228 RTC_DCHECK(call_stats_); 232 RTC_DCHECK(call_stats_);
229 233
230 RTC_DCHECK(!config_.decoders.empty()); 234 RTC_DCHECK(!config_.decoders.empty());
231 std::set<int> decoder_payload_types; 235 std::set<int> decoder_payload_types;
232 for (const Decoder& decoder : config_.decoders) { 236 for (const Decoder& decoder : config_.decoders) {
233 RTC_CHECK(decoder.decoder); 237 RTC_CHECK(decoder.decoder);
234 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == 238 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) ==
235 decoder_payload_types.end()) 239 decoder_payload_types.end())
236 << "Duplicate payload type (" << decoder.payload_type 240 << "Duplicate payload type (" << decoder.payload_type
237 << ") for different decoders."; 241 << ") for different decoders.";
238 decoder_payload_types.insert(decoder.payload_type); 242 decoder_payload_types.insert(decoder.payload_type);
239 } 243 }
240 244
241 video_receiver_.SetRenderDelay(config.render_delay_ms); 245 video_receiver_.SetRenderDelay(config.render_delay_ms);
242 246
243 jitter_estimator_.reset(new VCMJitterEstimator(clock_)); 247 if (jitter_buffer_experiment_) {
244 frame_buffer_.reset(new video_coding::FrameBuffer( 248 jitter_estimator_.reset(new VCMJitterEstimator(clock_));
245 clock_, jitter_estimator_.get(), timing_.get(), &stats_proxy_)); 249 frame_buffer_.reset(new video_coding::FrameBuffer(
250 clock_, jitter_estimator_.get(), timing_.get()));
251 }
246 252
247 process_thread_->RegisterModule(&video_receiver_); 253 process_thread_->RegisterModule(&video_receiver_);
248 process_thread_->RegisterModule(&rtp_stream_sync_); 254 process_thread_->RegisterModule(&rtp_stream_sync_);
249 } 255 }
250 256
251 VideoReceiveStream::~VideoReceiveStream() { 257 VideoReceiveStream::~VideoReceiveStream() {
252 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); 258 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString();
253 Stop(); 259 Stop();
254 260
255 process_thread_->DeRegisterModule(&rtp_stream_sync_); 261 process_thread_->DeRegisterModule(&rtp_stream_sync_);
(...skipping 30 matching lines...) Expand all
286 rtp_stream_sync_.ConfigureSync(audio_channel_id, voe_sync_interface); 292 rtp_stream_sync_.ConfigureSync(audio_channel_id, voe_sync_interface);
287 voe_sync_interface->Release(); 293 voe_sync_interface->Release();
288 } else { 294 } else {
289 rtp_stream_sync_.ConfigureSync(-1, nullptr); 295 rtp_stream_sync_.ConfigureSync(-1, nullptr);
290 } 296 }
291 } 297 }
292 298
293 void VideoReceiveStream::Start() { 299 void VideoReceiveStream::Start() {
294 if (decode_thread_.IsRunning()) 300 if (decode_thread_.IsRunning())
295 return; 301 return;
302 if (jitter_buffer_experiment_) {
303 frame_buffer_->Start();
304 call_stats_->RegisterStatsObserver(&rtp_stream_receiver_);
296 305
297 frame_buffer_->Start(); 306 if (rtp_stream_receiver_.IsRetransmissionsEnabled() &&
298 call_stats_->RegisterStatsObserver(&rtp_stream_receiver_); 307 rtp_stream_receiver_.IsUlpfecEnabled()) {
299 308 frame_buffer_->SetProtectionMode(kProtectionNackFEC);
300 if (rtp_stream_receiver_.IsRetransmissionsEnabled() && 309 }
301 rtp_stream_receiver_.IsUlpfecEnabled()) {
302 frame_buffer_->SetProtectionMode(kProtectionNackFEC);
303 } 310 }
304
305 transport_adapter_.Enable(); 311 transport_adapter_.Enable();
306 rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr; 312 rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr;
307 if (config_.renderer) { 313 if (config_.renderer) {
308 if (config_.disable_prerenderer_smoothing) { 314 if (config_.disable_prerenderer_smoothing) {
309 renderer = this; 315 renderer = this;
310 } else { 316 } else {
311 incoming_video_stream_.reset( 317 incoming_video_stream_.reset(
312 new IncomingVideoStream(config_.render_delay_ms, this)); 318 new IncomingVideoStream(config_.render_delay_ms, this));
313 renderer = incoming_video_stream_.get(); 319 renderer = incoming_video_stream_.get();
314 } 320 }
(...skipping 23 matching lines...) Expand all
338 rtp_stream_receiver_.StartReceive(); 344 rtp_stream_receiver_.StartReceive();
339 } 345 }
340 346
341 void VideoReceiveStream::Stop() { 347 void VideoReceiveStream::Stop() {
342 rtp_stream_receiver_.StopReceive(); 348 rtp_stream_receiver_.StopReceive();
343 // TriggerDecoderShutdown will release any waiting decoder thread and make it 349 // TriggerDecoderShutdown will release any waiting decoder thread and make it
344 // stop immediately, instead of waiting for a timeout. Needs to be called 350 // stop immediately, instead of waiting for a timeout. Needs to be called
345 // before joining the decoder thread thread. 351 // before joining the decoder thread thread.
346 video_receiver_.TriggerDecoderShutdown(); 352 video_receiver_.TriggerDecoderShutdown();
347 353
348 frame_buffer_->Stop(); 354 if (jitter_buffer_experiment_) {
349 call_stats_->DeregisterStatsObserver(&rtp_stream_receiver_); 355 frame_buffer_->Stop();
356 call_stats_->DeregisterStatsObserver(&rtp_stream_receiver_);
357 }
350 358
351 if (decode_thread_.IsRunning()) { 359 if (decode_thread_.IsRunning()) {
352 decode_thread_.Stop(); 360 decode_thread_.Stop();
353 // Deregister external decoders so they are no longer running during 361 // Deregister external decoders so they are no longer running during
354 // destruction. This effectively stops the VCM since the decoder thread is 362 // destruction. This effectively stops the VCM since the decoder thread is
355 // stopped, the VCM is deregistered and no asynchronous decoder threads are 363 // stopped, the VCM is deregistered and no asynchronous decoder threads are
356 // running. 364 // running.
357 for (const Decoder& decoder : config_.decoders) 365 for (const Decoder& decoder : config_.decoders)
358 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); 366 video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type);
359 } 367 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 if (last_continuous_pid != -1) 459 if (last_continuous_pid != -1)
452 rtp_stream_receiver_.FrameContinuous(last_continuous_pid); 460 rtp_stream_receiver_.FrameContinuous(last_continuous_pid);
453 } 461 }
454 462
455 bool VideoReceiveStream::DecodeThreadFunction(void* ptr) { 463 bool VideoReceiveStream::DecodeThreadFunction(void* ptr) {
456 static_cast<VideoReceiveStream*>(ptr)->Decode(); 464 static_cast<VideoReceiveStream*>(ptr)->Decode();
457 return true; 465 return true;
458 } 466 }
459 467
460 void VideoReceiveStream::Decode() { 468 void VideoReceiveStream::Decode() {
461 static const int kMaxWaitForFrameMs = 3000; 469 static const int kMaxDecodeWaitTimeMs = 50;
462 std::unique_ptr<video_coding::FrameObject> frame; 470 if (jitter_buffer_experiment_) {
463 video_coding::FrameBuffer::ReturnReason res = 471 static const int kMaxWaitForFrameMs = 3000;
464 frame_buffer_->NextFrame(kMaxWaitForFrameMs, &frame); 472 std::unique_ptr<video_coding::FrameObject> frame;
473 video_coding::FrameBuffer::ReturnReason res =
474 frame_buffer_->NextFrame(kMaxWaitForFrameMs, &frame);
465 475
466 if (res == video_coding::FrameBuffer::ReturnReason::kStopped) 476 if (res == video_coding::FrameBuffer::ReturnReason::kStopped)
467 return; 477 return;
468 478
469 if (frame) { 479 if (frame) {
470 if (video_receiver_.Decode(frame.get()) == VCM_OK) 480 if (video_receiver_.Decode(frame.get()) == VCM_OK)
471 rtp_stream_receiver_.FrameDecoded(frame->picture_id); 481 rtp_stream_receiver_.FrameDecoded(frame->picture_id);
482 } else {
483 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs
484 << " ms, requesting keyframe.";
485 RequestKeyFrame();
486 }
472 } else { 487 } else {
473 LOG(LS_WARNING) << "No decodable frame in " << kMaxWaitForFrameMs 488 video_receiver_.Decode(kMaxDecodeWaitTimeMs);
474 << " ms, requesting keyframe.";
475 RequestKeyFrame();
476 } 489 }
477 } 490 }
478 491
479 } // namespace internal 492 } // namespace internal
480 } // namespace webrtc 493 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/video/video_receive_stream.h ('k') | webrtc/video/video_stream_decoder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698