From 6dbc1723f1b42d5da68eda8840e09168272d3e11 Mon Sep 17 00:00:00 2001 From: Evan Shrubsole Date: Tue, 22 Mar 2022 12:20:11 +0100 Subject: [PATCH] [cleanup] Prefer VCMTiming unique_ptr in VideoReceiveStream2 c'tor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ifc2667ef9da38563266fb5ca7800ec757464035e Bug: None Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256363 Reviewed-by: Erik Språng Commit-Queue: Evan Shrubsole Cr-Commit-Position: refs/heads/main@{#36289} --- call/call.cc | 2 +- video/video_receive_stream2.cc | 4 +-- video/video_receive_stream2.h | 2 +- video/video_receive_stream2_unittest.cc | 39 +++++++++++++------------ 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/call/call.cc b/call/call.cc index f2101cfc6b..9db3adc0e1 100644 --- a/call/call.cc +++ b/call/call.cc @@ -1154,7 +1154,7 @@ webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream( VideoReceiveStream2* receive_stream = new VideoReceiveStream2( task_queue_factory_, this, num_cpu_cores_, transport_send_->packet_router(), std::move(configuration), - call_stats_.get(), clock_, new VCMTiming(clock_), + call_stats_.get(), clock_, std::make_unique(clock_), &nack_periodic_processor_, decode_sync_.get()); // TODO(bugs.webrtc.org/11993): Set this up asynchronously on the network // thread. diff --git a/video/video_receive_stream2.cc b/video/video_receive_stream2.cc index 8a452fa23a..572feaa546 100644 --- a/video/video_receive_stream2.cc +++ b/video/video_receive_stream2.cc @@ -209,7 +209,7 @@ VideoReceiveStream2::VideoReceiveStream2( VideoReceiveStream::Config config, CallStats* call_stats, Clock* clock, - VCMTiming* timing, + std::unique_ptr timing, NackPeriodicProcessor* nack_periodic_processor, DecodeSynchronizer* decode_sync) : task_queue_factory_(task_queue_factory), @@ -225,7 +225,7 @@ VideoReceiveStream2::VideoReceiveStream2( call->worker_thread(), call->trials()), rtp_receive_statistics_(ReceiveStatistics::Create(clock_)), - timing_(timing), + timing_(std::move(timing)), video_receiver_(clock_, timing_.get()), rtp_video_stream_receiver_(call->worker_thread(), clock_, diff --git a/video/video_receive_stream2.h b/video/video_receive_stream2.h index 2b65844c00..ffb1b81f68 100644 --- a/video/video_receive_stream2.h +++ b/video/video_receive_stream2.h @@ -100,7 +100,7 @@ class VideoReceiveStream2 VideoReceiveStream::Config config, CallStats* call_stats, Clock* clock, - VCMTiming* timing, + std::unique_ptr timing, NackPeriodicProcessor* nack_periodic_processor, DecodeSynchronizer* decode_sync); // Destruction happens on the worker thread. Prior to destruction the caller diff --git a/video/video_receive_stream2_unittest.cc b/video/video_receive_stream2_unittest.cc index c7718454fb..6a719e7d84 100644 --- a/video/video_receive_stream2_unittest.cc +++ b/video/video_receive_stream2_unittest.cc @@ -17,6 +17,7 @@ #include #include +#include "absl/memory/memory.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/test/mock_video_decoder.h" #include "api/test/mock_video_decoder_factory.h" @@ -106,8 +107,8 @@ class VideoReceiveStream2Test : public ::testing::Test { video_receive_stream_ = std::make_unique( task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), &call_stats_, clock_, timing_, - &nack_periodic_processor_, nullptr); + &packet_router_, config_.Copy(), &call_stats_, clock_, + absl::WrapUnique(timing_), &nack_periodic_processor_, nullptr); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); } @@ -283,10 +284,11 @@ class VideoReceiveStream2TestWithFakeDecoder : public ::testing::Test { video_receive_stream_ = nullptr; } timing_ = new VCMTiming(clock_); - video_receive_stream_.reset(new webrtc::internal::VideoReceiveStream2( - task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), &call_stats_, clock_, timing_, - &nack_periodic_processor_, nullptr)); + video_receive_stream_ = + std::make_unique( + task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, + &packet_router_, config_.Copy(), &call_stats_, clock_, + absl::WrapUnique(timing_), &nack_periodic_processor_, nullptr); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); video_receive_stream_->SetAndGetRecordingState(std::move(state), false); @@ -545,16 +547,17 @@ class VideoReceiveStream2TestWithSimulatedClock &fake_decoder_factory_, &fake_renderer_)), call_stats_(time_controller_.GetClock(), loop_.task_queue()), - video_receive_stream_(time_controller_.GetTaskQueueFactory(), - &fake_call_, - /*num_cores=*/2, - &packet_router_, - config_.Copy(), - &call_stats_, - time_controller_.GetClock(), - new VCMTiming(time_controller_.GetClock()), - &nack_periodic_processor_, - nullptr) { + video_receive_stream_( + time_controller_.GetTaskQueueFactory(), + &fake_call_, + /*num_cores=*/2, + &packet_router_, + config_.Copy(), + &call_stats_, + time_controller_.GetClock(), + std::make_unique(time_controller_.GetClock()), + &nack_periodic_processor_, + nullptr) { if (std::get<1>(GetParam())) { fake_call_.SetFieldTrial("WebRTC-FrameBuffer3/arm:FrameBuffer3/"); } else { @@ -741,8 +744,8 @@ class VideoReceiveStream2TestWithLazyDecoderCreation : public ::testing::Test { video_receive_stream_ = std::make_unique( task_queue_factory_.get(), &fake_call_, kDefaultNumCpuCores, - &packet_router_, config_.Copy(), &call_stats_, clock_, timing_, - &nack_periodic_processor_, nullptr); + &packet_router_, config_.Copy(), &call_stats_, clock_, + absl::WrapUnique(timing_), &nack_periodic_processor_, nullptr); video_receive_stream_->RegisterWithTransport( &rtp_stream_receiver_controller_); }