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

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

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