Index: webrtc/video/video_receive_stream.cc |
diff --git a/webrtc/video/video_receive_stream.cc b/webrtc/video/video_receive_stream.cc |
index ad9beb35e75384801cf03d264f935a7137a9b383..9909e29c433b394da8ed2b9ca18b51442e4ddb5e 100644 |
--- a/webrtc/video/video_receive_stream.cc |
+++ b/webrtc/video/video_receive_stream.cc |
@@ -144,7 +144,6 @@ |
} // namespace |
namespace internal { |
- |
VideoReceiveStream::VideoReceiveStream( |
int num_cpu_cores, |
CongestionController* congestion_controller, |
@@ -161,6 +160,7 @@ |
congestion_controller_(congestion_controller), |
call_stats_(call_stats), |
video_receiver_(clock_, nullptr, this, this, this), |
+ incoming_video_stream_(config_.disable_prerenderer_smoothing), |
stats_proxy_(&config_, clock_), |
rtp_stream_receiver_(&video_receiver_, |
congestion_controller_->GetRemoteBitrateEstimator( |
@@ -173,12 +173,23 @@ |
&config_, |
&stats_proxy_, |
process_thread_), |
+ video_stream_decoder_(&video_receiver_, |
+ &rtp_stream_receiver_, |
+ &rtp_stream_receiver_, |
+ rtp_stream_receiver_.IsRetransmissionsEnabled(), |
+ rtp_stream_receiver_.IsFecEnabled(), |
+ &stats_proxy_, |
+ &incoming_video_stream_, |
+ config.pre_render_callback), |
vie_sync_(&video_receiver_) { |
LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
RTC_DCHECK(process_thread_); |
RTC_DCHECK(congestion_controller_); |
RTC_DCHECK(call_stats_); |
+ |
+ // Register the channel to receive stats updates. |
+ call_stats_->RegisterStatsObserver(&video_stream_decoder_); |
RTC_DCHECK(!config_.decoders.empty()); |
std::set<int> decoder_payload_types; |
@@ -199,6 +210,8 @@ |
} |
video_receiver_.SetRenderDelay(config.render_delay_ms); |
+ incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms); |
+ incoming_video_stream_.SetExternalCallback(this); |
process_thread_->RegisterModule(&video_receiver_); |
process_thread_->RegisterModule(&vie_sync_); |
@@ -218,6 +231,8 @@ |
for (const Decoder& decoder : config_.decoders) |
video_receiver_.RegisterExternalDecoder(nullptr, decoder.payload_type); |
+ call_stats_->DeregisterStatsObserver(&video_stream_decoder_); |
+ |
congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) |
->RemoveStream(rtp_stream_receiver_.GetRemoteSsrc()); |
} |
@@ -241,24 +256,7 @@ |
if (decode_thread_.IsRunning()) |
return; |
transport_adapter_.Enable(); |
- rtc::VideoSinkInterface<VideoFrame>* renderer = nullptr; |
- if (config_.renderer) { |
- if (config_.disable_prerenderer_smoothing) { |
- renderer = this; |
- } else { |
- incoming_video_stream_.reset( |
- new IncomingVideoStream(config_.render_delay_ms, this)); |
- renderer = incoming_video_stream_.get(); |
- } |
- } |
- |
- video_stream_decoder_.reset(new VideoStreamDecoder( |
- &video_receiver_, &rtp_stream_receiver_, &rtp_stream_receiver_, |
- rtp_stream_receiver_.IsRetransmissionsEnabled(), |
- rtp_stream_receiver_.IsFecEnabled(), &stats_proxy_, renderer, |
- config_.pre_render_callback)); |
- // Register the channel to receive stats updates. |
- call_stats_->RegisterStatsObserver(video_stream_decoder_.get()); |
+ incoming_video_stream_.Start(); |
// Start the decode thread |
decode_thread_.Start(); |
decode_thread_.SetPriority(rtc::kHighestPriority); |
@@ -266,12 +264,10 @@ |
} |
void VideoReceiveStream::Stop() { |
+ incoming_video_stream_.Stop(); |
rtp_stream_receiver_.StopReceive(); |
video_receiver_.TriggerDecoderShutdown(); |
decode_thread_.Stop(); |
- call_stats_->DeregisterStatsObserver(video_stream_decoder_.get()); |
- video_stream_decoder_.reset(); |
- incoming_video_stream_.reset(); |
transport_adapter_.Disable(); |
} |
@@ -293,26 +289,16 @@ |
return stats_proxy_.GetStats(); |
} |
-// TODO(tommi): This method grabs a lock 6 times. |
void VideoReceiveStream::OnFrame(const VideoFrame& video_frame) { |
- // TODO(tommi): OnDecodedFrame grabs a lock, incidentally the same lock |
- // that OnSyncOffsetUpdated() and OnRenderedFrame() below grab. |
stats_proxy_.OnDecodedFrame(); |
int64_t sync_offset_ms; |
- // TODO(tommi): GetStreamSyncOffsetInMs grabs three locks. One inside the |
- // function itself, another in GetChannel() and a third in |
- // GetPlayoutTimestamp. Seems excessive. Anyhow, I'm assuming the function |
- // succeeds most of the time, which leads to grabbing a fourth lock. |
- if (vie_sync_.GetStreamSyncOffsetInMs(video_frame, &sync_offset_ms)) { |
- // TODO(tommi): OnSyncOffsetUpdated grabs a lock. |
+ if (vie_sync_.GetStreamSyncOffsetInMs(video_frame, &sync_offset_ms)) |
stats_proxy_.OnSyncOffsetUpdated(sync_offset_ms); |
- } |
- |
- // config_.renderer must never be null if we're getting this callback. |
- config_.renderer->OnFrame(video_frame); |
- |
- // TODO(tommi): OnRenderFrame grabs a lock too. |
+ |
+ if (config_.renderer) |
+ config_.renderer->OnFrame(video_frame); |
+ |
stats_proxy_.OnRenderedFrame(video_frame.width(), video_frame.height()); |
} |