From de5f63910e2429472fc4fa7e53ac42fd91f69d02 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Tue, 10 Sep 2019 10:31:07 +0200 Subject: [PATCH] Removes decoder thread fallback from VideoReceiveStream. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The task queue variant has been the default without issues for a few months. Bug: webrtc:10365 Change-Id: I1e1707a80788243eba1b439c8db4f8f6162774ed Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152283 Reviewed-by: Erik Språng Reviewed-by: Niels Moller Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#29138} --- video/video_receive_stream.cc | 77 ++++++++--------------------------- video/video_receive_stream.h | 6 --- 2 files changed, 16 insertions(+), 67 deletions(-) diff --git a/video/video_receive_stream.cc b/video/video_receive_stream.cc index a52dac8ea0..29cfbbd87d 100644 --- a/video/video_receive_stream.cc +++ b/video/video_receive_stream.cc @@ -184,12 +184,6 @@ VideoReceiveStream::VideoReceiveStream( num_cpu_cores_(num_cpu_cores), process_thread_(process_thread), clock_(clock), - use_task_queue_( - !field_trial::IsDisabled("WebRTC-Video-DecodeOnTaskQueue")), - decode_thread_(&DecodeThreadFunction, - this, - "DecodingThread", - rtc::kHighestPriority), call_stats_(call_stats), source_tracker_(clock_), stats_proxy_(&config_, clock_), @@ -392,18 +386,14 @@ void VideoReceiveStream::Start() { // method does nothing that is useful for us, since we no longer use the old // jitter buffer. - // Start the decode thread + // Start decoding on task queue. video_receiver_.DecoderThreadStarting(); stats_proxy_.DecoderThreadStarting(); - if (!use_task_queue_) { - decode_thread_.Start(); - } else { - decode_queue_.PostTask([this] { - RTC_DCHECK_RUN_ON(&decode_queue_); - decoder_stopped_ = false; - StartNextDecode(); - }); - } + decode_queue_.PostTask([this] { + RTC_DCHECK_RUN_ON(&decode_queue_); + decoder_stopped_ = false; + StartNextDecode(); + }); decoder_running_ = true; rtp_video_stream_receiver_.StartReceive(); } @@ -415,11 +405,8 @@ void VideoReceiveStream::Stop() { stats_proxy_.OnUniqueFramesCounted( rtp_video_stream_receiver_.GetUniqueFramesSeen()); - if (!use_task_queue_) { - frame_buffer_->Stop(); - } else { - decode_queue_.PostTask([this] { frame_buffer_->Stop(); }); - } + decode_queue_.PostTask([this] { frame_buffer_->Stop(); }); + call_stats_->DeregisterStatsObserver(this); if (decoder_running_) { @@ -428,17 +415,14 @@ void VideoReceiveStream::Stop() { // before joining the decoder thread. video_receiver_.TriggerDecoderShutdown(); - if (!use_task_queue_) { - decode_thread_.Stop(); - } else { - rtc::Event done; - decode_queue_.PostTask([this, &done] { - RTC_DCHECK_RUN_ON(&decode_queue_); - decoder_stopped_ = true; - done.Set(); - }); - done.Wait(rtc::Event::kForever); - } + rtc::Event done; + decode_queue_.PostTask([this, &done] { + RTC_DCHECK_RUN_ON(&decode_queue_); + decoder_stopped_ = true; + done.Set(); + }); + done.Wait(rtc::Event::kForever); + decoder_running_ = false; video_receiver_.DecoderThreadStopped(); stats_proxy_.DecoderThreadStopped(); @@ -646,7 +630,6 @@ int64_t VideoReceiveStream::GetWaitMs() const { } void VideoReceiveStream::StartNextDecode() { - RTC_DCHECK(use_task_queue_); TRACE_EVENT0("webrtc", "VideoReceiveStream::StartNextDecode"); struct DecodeTask { @@ -674,34 +657,6 @@ void VideoReceiveStream::StartNextDecode() { }); } -void VideoReceiveStream::DecodeThreadFunction(void* ptr) { - ScopedRegisterThreadForDebugging thread_dbg(RTC_FROM_HERE); - while (static_cast(ptr)->Decode()) { - } -} - -bool VideoReceiveStream::Decode() { - RTC_DCHECK(!use_task_queue_); - TRACE_EVENT0("webrtc", "VideoReceiveStream::Decode"); - - std::unique_ptr frame; - video_coding::FrameBuffer::ReturnReason res = - frame_buffer_->NextFrame(GetWaitMs(), &frame, keyframe_required_); - - if (res == ReturnReason::kStopped) { - return false; - } - - if (frame) { - RTC_DCHECK_EQ(res, ReturnReason::kFrameFound); - HandleEncodedFrame(std::move(frame)); - } else { - RTC_DCHECK_EQ(res, ReturnReason::kTimeout); - HandleFrameBufferTimeout(); - } - return true; -} - void VideoReceiveStream::HandleEncodedFrame( std::unique_ptr frame) { int64_t now_ms = clock_->TimeInMilliseconds(); diff --git a/video/video_receive_stream.h b/video/video_receive_stream.h index 65c9601844..87a40e91f5 100644 --- a/video/video_receive_stream.h +++ b/video/video_receive_stream.h @@ -134,8 +134,6 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream, private: int64_t GetWaitMs() const; void StartNextDecode() RTC_RUN_ON(decode_queue_); - static void DecodeThreadFunction(void* ptr); - bool Decode(); void HandleEncodedFrame(std::unique_ptr frame); void HandleFrameBufferTimeout(); @@ -157,10 +155,6 @@ class VideoReceiveStream : public webrtc::VideoReceiveStream, ProcessThread* const process_thread_; Clock* const clock_; - const bool use_task_queue_; - - rtc::PlatformThread decode_thread_; - CallStats* const call_stats_; bool decoder_running_ RTC_GUARDED_BY(worker_sequence_checker_) = false;