From a3ce407023a80002d6654647997e218323057e08 Mon Sep 17 00:00:00 2001 From: Danil Chapovalov Date: Fri, 13 Oct 2023 13:53:00 +0200 Subject: [PATCH] Cleanup Call construction Return unique_ptr to clearly communicate ownership is transfered. Remove Call::Config alias Bug: None Change-Id: Ie3aa1da383ad65fae490d218fced443d44961eab Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/323160 Reviewed-by: Rasmus Brandt Auto-Submit: Danil Chapovalov Reviewed-by: Harald Alvestrand Commit-Queue: Danil Chapovalov Cr-Commit-Position: refs/heads/main@{#40934} --- api/call/call_factory_interface.h | 4 +- api/test/create_time_controller.cc | 2 +- call/BUILD.gn | 2 - call/call.cc | 22 +++++----- call/call.h | 13 +++--- call/call_factory.cc | 11 +++-- call/call_factory.h | 7 ++-- call/call_perf_tests.cc | 4 +- call/call_unittest.cc | 41 +++++++++---------- media/engine/webrtc_video_engine_unittest.cc | 34 +++++++-------- media/engine/webrtc_voice_engine_unittest.cc | 22 +++++----- pc/peer_connection_factory.cc | 5 +-- rtc_tools/video_replay.cc | 4 +- test/call_test.cc | 22 +++++----- test/call_test.h | 8 ++-- test/fuzzers/utils/rtp_replayer.cc | 2 +- test/scenario/call_client.cc | 17 ++++---- video/end_to_end_tests/multi_stream_tester.cc | 7 ++-- video/end_to_end_tests/network_state_tests.cc | 2 +- video/end_to_end_tests/stats_tests.cc | 4 +- video/video_quality_test.cc | 14 +++---- video/video_quality_test.h | 4 +- 22 files changed, 124 insertions(+), 127 deletions(-) diff --git a/api/call/call_factory_interface.h b/api/call/call_factory_interface.h index 6051409cc3..fde8cba66e 100644 --- a/api/call/call_factory_interface.h +++ b/api/call/call_factory_interface.h @@ -26,9 +26,9 @@ struct CallConfig; // is constructed with a CallFactoryInterface, which may or may not be null. class CallFactoryInterface { public: - virtual ~CallFactoryInterface() {} + virtual ~CallFactoryInterface() = default; - virtual Call* CreateCall(const CallConfig& config) = 0; + virtual std::unique_ptr CreateCall(const CallConfig& config) = 0; }; RTC_EXPORT std::unique_ptr CreateCallFactory(); diff --git a/api/test/create_time_controller.cc b/api/test/create_time_controller.cc index d198f2b0fe..2c356cb887 100644 --- a/api/test/create_time_controller.cc +++ b/api/test/create_time_controller.cc @@ -36,7 +36,7 @@ std::unique_ptr CreateTimeControllerBasedCallFactory( public: explicit TimeControllerBasedCallFactory(TimeController* time_controller) : time_controller_(time_controller) {} - Call* CreateCall(const Call::Config& config) override { + std::unique_ptr CreateCall(const CallConfig& config) override { RtpTransportConfig transportConfig = config.ExtractTransportConfig(); return Call::Create(config, time_controller_->GetClock(), diff --git a/call/BUILD.gn b/call/BUILD.gn index 17c797c163..4cc42fd99f 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -345,7 +345,6 @@ rtc_library("call") { ] absl_deps = [ "//third_party/abseil-cpp/absl/functional:bind_front", - "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] @@ -544,7 +543,6 @@ if (rtc_include_tests) { absl_deps = [ "//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/functional:any_invocable", - "//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:variant", diff --git a/call/call.cc b/call/call.cc index fa5d14d204..b42c7d13dc 100644 --- a/call/call.cc +++ b/call/call.cc @@ -184,7 +184,7 @@ class Call final : public webrtc::Call, public BitrateAllocator::LimitObserver { public: Call(Clock* clock, - const Call::Config& config, + const CallConfig& config, std::unique_ptr transport_send, TaskQueueFactory* task_queue_factory); ~Call() override; @@ -355,7 +355,7 @@ class Call final : public webrtc::Call, const int num_cpu_cores_; const std::unique_ptr call_stats_; const std::unique_ptr bitrate_allocator_; - const Call::Config config_ RTC_GUARDED_BY(worker_thread_); + const CallConfig config_ RTC_GUARDED_BY(worker_thread_); // Maps to config_.trials, can be used from any thread via `trials()`. const FieldTrialsView& trials_; @@ -478,20 +478,22 @@ std::string Call::Stats::ToString(int64_t time_ms) const { return ss.str(); } -Call* Call::Create(const Call::Config& config) { +std::unique_ptr Call::Create(const CallConfig& config) { Clock* clock = Clock::GetRealTimeClock(); return Create(config, clock, RtpTransportControllerSendFactory().Create( config.ExtractTransportConfig(), clock)); } -Call* Call::Create(const Call::Config& config, - Clock* clock, - std::unique_ptr - transportControllerSend) { +std::unique_ptr Call::Create( + const CallConfig& config, + Clock* clock, + std::unique_ptr + transportControllerSend) { RTC_DCHECK(config.task_queue_factory); - return new internal::Call(clock, config, std::move(transportControllerSend), - config.task_queue_factory); + return std::make_unique(clock, config, + std::move(transportControllerSend), + config.task_queue_factory); } // This method here to avoid subclasses has to implement this method. @@ -658,7 +660,7 @@ void Call::SendStats::SetMinAllocatableRate(BitrateAllocationLimits limits) { } Call::Call(Clock* clock, - const Call::Config& config, + const CallConfig& config, std::unique_ptr transport_send, TaskQueueFactory* task_queue_factory) : clock_(clock), diff --git a/call/call.h b/call/call.h index 366978392e..6f8e4cd6d7 100644 --- a/call/call.h +++ b/call/call.h @@ -46,8 +46,6 @@ namespace webrtc { class Call { public: - using Config = CallConfig; - struct Stats { std::string ToString(int64_t time_ms) const; @@ -58,11 +56,12 @@ class Call { int64_t rtt_ms = -1; }; - static Call* Create(const Call::Config& config); - static Call* Create(const Call::Config& config, - Clock* clock, - std::unique_ptr - transportControllerSend); + static std::unique_ptr Create(const CallConfig& config); + static std::unique_ptr Create( + const CallConfig& config, + Clock* clock, + std::unique_ptr + transportControllerSend); virtual AudioSendStream* CreateAudioSendStream( const AudioSendStream::Config& config) = 0; diff --git a/call/call_factory.cc b/call/call_factory.cc index 380e80ce12..043b11da37 100644 --- a/call/call_factory.cc +++ b/call/call_factory.cc @@ -17,7 +17,6 @@ #include #include -#include "absl/memory/memory.h" #include "absl/types/optional.h" #include "api/test/simulated_network.h" #include "api/units/time_delta.h" @@ -83,7 +82,7 @@ CallFactory::CallFactory() { call_thread_.Detach(); } -Call* CallFactory::CreateCall(const Call::Config& config) { +std::unique_ptr CallFactory::CreateCall(const CallConfig& config) { RTC_DCHECK_RUN_ON(&call_thread_); RTC_DCHECK(config.trials); @@ -95,22 +94,22 @@ Call* CallFactory::CreateCall(const Call::Config& config) { RtpTransportConfig transportConfig = config.ExtractTransportConfig(); - Call* call = + std::unique_ptr call = Call::Create(config, Clock::GetRealTimeClock(), config.rtp_transport_controller_send_factory->Create( transportConfig, Clock::GetRealTimeClock())); if (!send_degradation_configs.empty() || !receive_degradation_configs.empty()) { - return new DegradedCall(absl::WrapUnique(call), send_degradation_configs, - receive_degradation_configs); + return std::make_unique( + std::move(call), send_degradation_configs, receive_degradation_configs); } return call; } std::unique_ptr CreateCallFactory() { - return std::unique_ptr(new CallFactory()); + return std::make_unique(); } } // namespace webrtc diff --git a/call/call_factory.h b/call/call_factory.h index 9feed7bbb6..f75b1bd71b 100644 --- a/call/call_factory.h +++ b/call/call_factory.h @@ -11,6 +11,8 @@ #ifndef CALL_CALL_FACTORY_H_ #define CALL_CALL_FACTORY_H_ +#include + #include "api/call/call_factory_interface.h" #include "api/sequence_checker.h" #include "call/call.h" @@ -22,11 +24,10 @@ namespace webrtc { class CallFactory : public CallFactoryInterface { public: CallFactory(); + ~CallFactory() override = default; private: - ~CallFactory() override {} - - Call* CreateCall(const CallConfig& config) override; + std::unique_ptr CreateCall(const CallConfig& config) override; RTC_NO_UNIQUE_ADDRESS SequenceChecker call_thread_; }; diff --git a/call/call_perf_tests.cc b/call/call_perf_tests.cc index 3c6562caa8..0ba6d05b19 100644 --- a/call/call_perf_tests.cc +++ b/call/call_perf_tests.cc @@ -223,12 +223,12 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec, send_audio_state_config.audio_processing = AudioProcessingBuilder().Create(); send_audio_state_config.audio_device_module = fake_audio_device; - Call::Config sender_config(send_event_log_.get()); + CallConfig sender_config(send_event_log_.get()); auto audio_state = AudioState::Create(send_audio_state_config); fake_audio_device->RegisterAudioCallback(audio_state->audio_transport()); sender_config.audio_state = audio_state; - Call::Config receiver_config(recv_event_log_.get()); + CallConfig receiver_config(recv_event_log_.get()); receiver_config.audio_state = audio_state; CreateCalls(sender_config, receiver_config); diff --git a/call/call_unittest.cc b/call/call_unittest.cc index 01476eed19..886a15aaf0 100644 --- a/call/call_unittest.cc +++ b/call/call_unittest.cc @@ -15,7 +15,6 @@ #include #include -#include "absl/memory/memory.h" #include "absl/strings/string_view.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/media_types.h" @@ -40,6 +39,7 @@ #include "test/mock_transport.h" #include "test/run_loop.h" +namespace webrtc { namespace { using ::testing::_; @@ -47,41 +47,38 @@ using ::testing::Contains; using ::testing::MockFunction; using ::testing::NiceMock; using ::testing::StrictMock; +using ::webrtc::test::MockAudioDeviceModule; +using ::webrtc::test::MockAudioMixer; +using ::webrtc::test::MockAudioProcessing; +using ::webrtc::test::RunLoop; struct CallHelper { explicit CallHelper(bool use_null_audio_processing) { - task_queue_factory_ = webrtc::CreateDefaultTaskQueueFactory(); - webrtc::AudioState::Config audio_state_config; - audio_state_config.audio_mixer = - rtc::make_ref_counted(); + task_queue_factory_ = CreateDefaultTaskQueueFactory(); + AudioState::Config audio_state_config; + audio_state_config.audio_mixer = rtc::make_ref_counted(); audio_state_config.audio_processing = use_null_audio_processing ? nullptr - : rtc::make_ref_counted< - NiceMock>(); + : rtc::make_ref_counted>(); audio_state_config.audio_device_module = - rtc::make_ref_counted(); - webrtc::Call::Config config(&event_log_); - config.audio_state = webrtc::AudioState::Create(audio_state_config); + rtc::make_ref_counted(); + CallConfig config(&event_log_); + config.audio_state = AudioState::Create(audio_state_config); config.task_queue_factory = task_queue_factory_.get(); config.trials = &field_trials_; - call_.reset(webrtc::Call::Create(config)); + call_ = Call::Create(config); } - webrtc::Call* operator->() { return call_.get(); } + Call* operator->() { return call_.get(); } private: - webrtc::test::RunLoop loop_; - webrtc::RtcEventLogNull event_log_; - webrtc::FieldTrialBasedConfig field_trials_; - std::unique_ptr task_queue_factory_; - std::unique_ptr call_; + RunLoop loop_; + RtcEventLogNull event_log_; + FieldTrialBasedConfig field_trials_; + std::unique_ptr task_queue_factory_; + std::unique_ptr call_; }; -} // namespace - -namespace webrtc { - -namespace { rtc::scoped_refptr FindResourceWhoseNameContains( const std::vector>& resources, diff --git a/media/engine/webrtc_video_engine_unittest.cc b/media/engine/webrtc_video_engine_unittest.cc index 0f416aaeea..b98d8e481d 100644 --- a/media/engine/webrtc_video_engine_unittest.cc +++ b/media/engine/webrtc_video_engine_unittest.cc @@ -19,7 +19,6 @@ #include #include "absl/algorithm/container.h" -#include "absl/memory/memory.h" #include "absl/strings/match.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/rtp_parameters.h" @@ -99,6 +98,8 @@ using ::testing::StrNe; using ::testing::Values; using ::testing::WithArg; using ::webrtc::BitrateConstraints; +using ::webrtc::Call; +using ::webrtc::CallConfig; using ::webrtc::kDefaultScalabilityModeStr; using ::webrtc::RtpExtension; using ::webrtc::RtpPacket; @@ -355,8 +356,8 @@ class WebRtcVideoEngineTest : public ::testing::Test { : field_trials_(field_trials), time_controller_(webrtc::Timestamp::Millis(4711)), task_queue_factory_(time_controller_.CreateTaskQueueFactory()), - call_(webrtc::Call::Create([&] { - webrtc::Call::Config call_config(&event_log_); + call_(Call::Create([&] { + CallConfig call_config(&event_log_); call_config.task_queue_factory = task_queue_factory_.get(); call_config.trials = &field_trials_; return call_config; @@ -401,7 +402,7 @@ class WebRtcVideoEngineTest : public ::testing::Test { std::unique_ptr task_queue_factory_; // Used in WebRtcVideoEngineVoiceTest, but defined here so it's properly // initialized when the constructor is called. - std::unique_ptr call_; + std::unique_ptr call_; cricket::FakeWebRtcVideoEncoderFactory* encoder_factory_; cricket::FakeWebRtcVideoDecoderFactory* decoder_factory_; std::unique_ptr @@ -1443,11 +1444,11 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) { webrtc::GlobalSimulatedTimeController time_controller( webrtc::Timestamp::Millis(4711)); auto task_queue_factory = time_controller.CreateTaskQueueFactory(); - webrtc::Call::Config call_config(&event_log); + CallConfig call_config(&event_log); webrtc::FieldTrialBasedConfig field_trials; call_config.trials = &field_trials; call_config.task_queue_factory = task_queue_factory.get(); - const auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); + const std::unique_ptr call = Call::Create(call_config); // Create send channel. const int send_ssrc = 123; @@ -1575,10 +1576,9 @@ TEST_F(WebRtcVideoEngineTest, SetVideoRtxEnabled) { class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { protected: - webrtc::Call::Config GetCallConfig( - webrtc::RtcEventLogNull* event_log, - webrtc::TaskQueueFactory* task_queue_factory) { - webrtc::Call::Config call_config(event_log); + CallConfig GetCallConfig(webrtc::RtcEventLogNull* event_log, + webrtc::TaskQueueFactory* task_queue_factory) { + CallConfig call_config(event_log); call_config.task_queue_factory = task_queue_factory; call_config.trials = &field_trials_; return call_config; @@ -1586,8 +1586,8 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { WebRtcVideoChannelEncodedFrameCallbackTest() : task_queue_factory_(time_controller_.CreateTaskQueueFactory()), - call_(absl::WrapUnique(webrtc::Call::Create( - GetCallConfig(&event_log_, task_queue_factory_.get())))), + call_(Call::Create( + GetCallConfig(&event_log_, task_queue_factory_.get()))), video_bitrate_allocator_factory_( webrtc::CreateBuiltinVideoBitrateAllocatorFactory()), engine_( @@ -1639,7 +1639,7 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { webrtc::test::ScopedKeyValueConfig field_trials_; webrtc::RtcEventLogNull event_log_; std::unique_ptr task_queue_factory_; - std::unique_ptr call_; + std::unique_ptr call_; std::unique_ptr video_bitrate_allocator_factory_; WebRtcVideoEngine engine_; @@ -1775,10 +1775,10 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test { void SetUp() override { // One testcase calls SetUp in a loop, only create call_ once. if (!call_) { - webrtc::Call::Config call_config(&event_log_); + CallConfig call_config(&event_log_); call_config.task_queue_factory = task_queue_factory_.get(); call_config.trials = &field_trials_; - call_.reset(webrtc::Call::Create(call_config)); + call_ = Call::Create(call_config); } cricket::MediaConfig media_config; @@ -1981,7 +1981,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test { webrtc::test::ScopedKeyValueConfig field_trials_; std::unique_ptr override_field_trials_; std::unique_ptr task_queue_factory_; - std::unique_ptr call_; + std::unique_ptr call_; std::unique_ptr video_bitrate_allocator_factory_; WebRtcVideoEngine engine_; @@ -6777,7 +6777,7 @@ TEST_F(WebRtcVideoChannelTest, GetStatsTranslatesReceivePacketStatsCorrectly) { TEST_F(WebRtcVideoChannelTest, TranslatesCallStatsCorrectly) { AddSendStream(); AddSendStream(); - webrtc::Call::Stats stats; + Call::Stats stats; stats.rtt_ms = 123; fake_call_->SetStats(stats); diff --git a/media/engine/webrtc_voice_engine_unittest.cc b/media/engine/webrtc_voice_engine_unittest.cc index 0a3c592d17..b1393eec74 100644 --- a/media/engine/webrtc_voice_engine_unittest.cc +++ b/media/engine/webrtc_voice_engine_unittest.cc @@ -55,6 +55,8 @@ using ::testing::ReturnPointee; using ::testing::SaveArg; using ::testing::StrictMock; using ::testing::UnorderedElementsAreArray; +using ::webrtc::Call; +using ::webrtc::CallConfig; namespace { using webrtc::BitrateConstraints; @@ -3690,10 +3692,10 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) { nullptr, nullptr, field_trials); engine.Init(); webrtc::RtcEventLogNull event_log; - webrtc::Call::Config call_config(&event_log); + CallConfig call_config(&event_log); call_config.trials = &field_trials; call_config.task_queue_factory = task_queue_factory.get(); - auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); + std::unique_ptr call = Call::Create(call_config); std::unique_ptr send_channel = engine.CreateSendChannel( call.get(), cricket::MediaConfig(), cricket::AudioOptions(), @@ -3726,10 +3728,10 @@ TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) { nullptr, nullptr, field_trials); engine.Init(); webrtc::RtcEventLogNull event_log; - webrtc::Call::Config call_config(&event_log); + CallConfig call_config(&event_log); call_config.trials = &field_trials; call_config.task_queue_factory = task_queue_factory.get(); - auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); + std::unique_ptr call = Call::Create(call_config); std::unique_ptr send_channel = engine.CreateSendChannel( call.get(), cricket::MediaConfig(), cricket::AudioOptions(), @@ -3816,10 +3818,10 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) { nullptr, nullptr, field_trials); engine.Init(); webrtc::RtcEventLogNull event_log; - webrtc::Call::Config call_config(&event_log); + CallConfig call_config(&event_log); call_config.trials = &field_trials; call_config.task_queue_factory = task_queue_factory.get(); - auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); + std::unique_ptr call = Call::Create(call_config); std::vector> channels; @@ -3862,10 +3864,10 @@ TEST(WebRtcVoiceEngineTest, SetRecvCodecs) { nullptr, field_trials); engine.Init(); webrtc::RtcEventLogNull event_log; - webrtc::Call::Config call_config(&event_log); + CallConfig call_config(&event_log); call_config.trials = &field_trials; call_config.task_queue_factory = task_queue_factory.get(); - auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); + std::unique_ptr call = Call::Create(call_config); cricket::WebRtcVoiceReceiveChannel channel( &engine, cricket::MediaConfig(), cricket::AudioOptions(), webrtc::CryptoOptions(), call.get(), @@ -3891,7 +3893,7 @@ TEST(WebRtcVoiceEngineTest, SetRtpSendParametersMaxBitrate) { field_trials); engine.Init(); webrtc::RtcEventLogNull event_log; - webrtc::Call::Config call_config(&event_log); + CallConfig call_config(&event_log); call_config.trials = &field_trials; call_config.task_queue_factory = task_queue_factory.get(); { @@ -3901,7 +3903,7 @@ TEST(WebRtcVoiceEngineTest, SetRtpSendParametersMaxBitrate) { webrtc::test::MockAudioDeviceModule::CreateNice(); call_config.audio_state = webrtc::AudioState::Create(config); } - auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); + std::unique_ptr call = Call::Create(call_config); cricket::WebRtcVoiceSendChannel channel( &engine, cricket::MediaConfig(), cricket::AudioOptions(), webrtc::CryptoOptions(), call.get(), webrtc::AudioCodecPairId::Create()); diff --git a/pc/peer_connection_factory.cc b/pc/peer_connection_factory.cc index d933ba6aea..81780cf51e 100644 --- a/pc/peer_connection_factory.cc +++ b/pc/peer_connection_factory.cc @@ -301,7 +301,7 @@ std::unique_ptr PeerConnectionFactory::CreateCall_w( const PeerConnectionInterface::RTCConfiguration& configuration) { RTC_DCHECK_RUN_ON(worker_thread()); - webrtc::Call::Config call_config(event_log, network_thread()); + CallConfig call_config(event_log, network_thread()); if (!media_engine() || !context_->call_factory()) { return nullptr; } @@ -342,8 +342,7 @@ std::unique_ptr PeerConnectionFactory::CreateCall_w( transport_controller_send_factory_.get(); call_config.metronome = metronome_.get(); call_config.pacer_burst_interval = configuration.pacer_burst_interval; - return std::unique_ptr( - context_->call_factory()->CreateCall(call_config)); + return context_->call_factory()->CreateCall(call_config); } bool PeerConnectionFactory::IsTrialEnabled(absl::string_view key) const { diff --git a/rtc_tools/video_replay.cc b/rtc_tools/video_replay.cc index c8bfec2ade..b19850ed57 100644 --- a/rtc_tools/video_replay.cc +++ b/rtc_tools/video_replay.cc @@ -494,10 +494,10 @@ class RtpReplayer final { "worker_thread", TaskQueueFactory::Priority::NORMAL)); rtc::Event event; worker_thread_->PostTask([&]() { - Call::Config call_config(&event_log_); + CallConfig call_config(&event_log_); call_config.trials = field_trials_.get(); call_config.task_queue_factory = task_queue_factory; - call_.reset(Call::Create(call_config)); + call_ = Call::Create(call_config); // Creation of the streams must happen inside a task queue because it is // resued as a worker thread. diff --git a/test/call_test.cc b/test/call_test.cc index b8a1cd76b8..2b71608ac6 100644 --- a/test/call_test.cc +++ b/test/call_test.cc @@ -97,7 +97,7 @@ void CallTest::RunBaseTest(BaseTest* test) { num_audio_streams_ = test->GetNumAudioStreams(); num_flexfec_streams_ = test->GetNumFlexfecStreams(); RTC_DCHECK(num_video_streams_ > 0 || num_audio_streams_ > 0); - Call::Config send_config(send_event_log_.get()); + CallConfig send_config(send_event_log_.get()); test->ModifySenderBitrateConfig(&send_config.bitrate_config); if (num_audio_streams_ > 0) { CreateFakeAudioDevices(test->CreateCapturer(), test->CreateRenderer()); @@ -117,7 +117,7 @@ void CallTest::RunBaseTest(BaseTest* test) { } CreateSenderCall(send_config); if (test->ShouldCreateReceivers()) { - Call::Config recv_config(recv_event_log_.get()); + CallConfig recv_config(recv_event_log_.get()); test->ModifyReceiverBitrateConfig(&recv_config.bitrate_config); if (num_audio_streams_ > 0) { AudioState::Config audio_state_config; @@ -207,35 +207,35 @@ void CallTest::RunBaseTest(BaseTest* test) { } void CallTest::CreateCalls() { - CreateCalls(Call::Config(send_event_log_.get()), - Call::Config(recv_event_log_.get())); + CreateCalls(CallConfig(send_event_log_.get()), + CallConfig(recv_event_log_.get())); } -void CallTest::CreateCalls(const Call::Config& sender_config, - const Call::Config& receiver_config) { +void CallTest::CreateCalls(const CallConfig& sender_config, + const CallConfig& receiver_config) { CreateSenderCall(sender_config); CreateReceiverCall(receiver_config); } void CallTest::CreateSenderCall() { - CreateSenderCall(Call::Config(send_event_log_.get())); + CreateSenderCall(CallConfig(send_event_log_.get())); } -void CallTest::CreateSenderCall(const Call::Config& config) { +void CallTest::CreateSenderCall(const CallConfig& config) { auto sender_config = config; sender_config.task_queue_factory = task_queue_factory_.get(); sender_config.network_state_predictor_factory = network_state_predictor_factory_.get(); sender_config.network_controller_factory = network_controller_factory_.get(); sender_config.trials = &field_trials_; - sender_call_.reset(Call::Create(sender_config)); + sender_call_ = Call::Create(sender_config); } -void CallTest::CreateReceiverCall(const Call::Config& config) { +void CallTest::CreateReceiverCall(const CallConfig& config) { auto receiver_config = config; receiver_config.task_queue_factory = task_queue_factory_.get(); receiver_config.trials = &field_trials_; - receiver_call_.reset(Call::Create(receiver_config)); + receiver_call_ = Call::Create(receiver_config); } void CallTest::DestroyCalls() { diff --git a/test/call_test.h b/test/call_test.h index 08d0e49a68..8d2b001f72 100644 --- a/test/call_test.h +++ b/test/call_test.h @@ -63,11 +63,11 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface { void RunBaseTest(BaseTest* test); void CreateCalls(); - void CreateCalls(const Call::Config& sender_config, - const Call::Config& receiver_config); + void CreateCalls(const CallConfig& sender_config, + const CallConfig& receiver_config); void CreateSenderCall(); - void CreateSenderCall(const Call::Config& config); - void CreateReceiverCall(const Call::Config& config); + void CreateSenderCall(const CallConfig& config); + void CreateReceiverCall(const CallConfig& config); void DestroyCalls(); void CreateVideoSendConfig(VideoSendStream::Config* video_config, diff --git a/test/fuzzers/utils/rtp_replayer.cc b/test/fuzzers/utils/rtp_replayer.cc index 83f894dc28..f6d7119338 100644 --- a/test/fuzzers/utils/rtp_replayer.cc +++ b/test/fuzzers/utils/rtp_replayer.cc @@ -76,7 +76,7 @@ void RtpReplayer::Replay( webrtc::RtcEventLogNull event_log; std::unique_ptr task_queue_factory = CreateDefaultTaskQueueFactory(); - Call::Config call_config(&event_log); + CallConfig call_config(&event_log); call_config.task_queue_factory = task_queue_factory.get(); FieldTrialBasedConfig field_trials; call_config.trials = &field_trials; diff --git a/test/scenario/call_client.cc b/test/scenario/call_client.cc index d2019aebc7..fdf36dee08 100644 --- a/test/scenario/call_client.cc +++ b/test/scenario/call_client.cc @@ -59,11 +59,12 @@ CallClientFakeAudio InitAudio(TimeController* time_controller) { return setup; } -Call* CreateCall(TimeController* time_controller, - RtcEventLog* event_log, - CallClientConfig config, - LoggingNetworkControllerFactory* network_controller_factory, - rtc::scoped_refptr audio_state) { +std::unique_ptr CreateCall( + TimeController* time_controller, + RtcEventLog* event_log, + CallClientConfig config, + LoggingNetworkControllerFactory* network_controller_factory, + rtc::scoped_refptr audio_state) { CallConfig call_config(event_log); call_config.bitrate_config.max_bitrate_bps = config.transport.rates.max_rate.bps_or(-1); @@ -230,9 +231,9 @@ CallClient::CallClient( log_writer_factory_.get()); fake_audio_setup_ = InitAudio(time_controller_); - call_.reset(CreateCall(time_controller_, event_log_.get(), config, - &network_controller_factory_, - fake_audio_setup_.audio_state)); + call_ = + CreateCall(time_controller_, event_log_.get(), config, + &network_controller_factory_, fake_audio_setup_.audio_state); transport_ = std::make_unique(clock_, call_.get()); }); } diff --git a/video/end_to_end_tests/multi_stream_tester.cc b/video/end_to_end_tests/multi_stream_tester.cc index 8d99329194..1eb388cc76 100644 --- a/video/end_to_end_tests/multi_stream_tester.cc +++ b/video/end_to_end_tests/multi_stream_tester.cc @@ -14,7 +14,6 @@ #include #include -#include "absl/memory/memory.h" #include "api/rtc_event_log/rtc_event_log.h" #include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/task_queue_base.h" @@ -50,7 +49,7 @@ void MultiStreamTester::RunTest() { // to make test more stable. auto task_queue = task_queue_factory->CreateTaskQueue( "TaskQueue", TaskQueueFactory::Priority::HIGH); - Call::Config config(&event_log); + CallConfig config(&event_log); test::ScopedKeyValueConfig field_trials; config.trials = &field_trials; config.task_queue_factory = task_queue_factory.get(); @@ -69,8 +68,8 @@ void MultiStreamTester::RunTest() { InternalDecoderFactory decoder_factory; SendTask(task_queue.get(), [&]() { - sender_call = absl::WrapUnique(Call::Create(config)); - receiver_call = absl::WrapUnique(Call::Create(config)); + sender_call = Call::Create(config); + receiver_call = Call::Create(config); sender_transport = CreateSendTransport(task_queue.get(), sender_call.get()); receiver_transport = CreateReceiveTransport(task_queue.get(), receiver_call.get()); diff --git a/video/end_to_end_tests/network_state_tests.cc b/video/end_to_end_tests/network_state_tests.cc index 4d43f7609c..7bc9f1493e 100644 --- a/video/end_to_end_tests/network_state_tests.cc +++ b/video/end_to_end_tests/network_state_tests.cc @@ -94,7 +94,7 @@ void NetworkStateEndToEndTest::VerifyNewVideoSendStreamsRespectNetworkState( SendTask(task_queue(), [this, network_to_bring_up, &encoder_factory, transport]() { - CreateSenderCall(Call::Config(send_event_log_.get())); + CreateSenderCall(CallConfig(send_event_log_.get())); sender_call_->SignalChannelNetworkState(network_to_bring_up, kNetworkUp); CreateSendConfig(1, 0, 0, transport); diff --git a/video/end_to_end_tests/stats_tests.cc b/video/end_to_end_tests/stats_tests.cc index 475a6cd2da..cc0b328b2b 100644 --- a/video/end_to_end_tests/stats_tests.cc +++ b/video/end_to_end_tests/stats_tests.cc @@ -518,9 +518,9 @@ TEST_F(StatsEndToEndTest, MAYBE_ContentTypeSwitches) { metrics::Reset(); - Call::Config send_config(send_event_log_.get()); + CallConfig send_config(send_event_log_.get()); test.ModifySenderBitrateConfig(&send_config.bitrate_config); - Call::Config recv_config(recv_event_log_.get()); + CallConfig recv_config(recv_event_log_.get()); test.ModifyReceiverBitrateConfig(&recv_config.bitrate_config); VideoEncoderConfig encoder_config_with_screenshare; diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 5eae8ebda0..4086cdf62e 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -1247,8 +1247,8 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) { } SendTask(task_queue(), [this, ¶ms, &send_transport, &recv_transport]() { - Call::Config send_call_config(send_event_log_.get()); - Call::Config recv_call_config(recv_event_log_.get()); + CallConfig send_call_config(send_event_log_.get()); + CallConfig recv_call_config(recv_event_log_.get()); send_call_config.bitrate_config = params.call.call_bitrate_config; recv_call_config.bitrate_config = params.call.call_bitrate_config; if (params_.audio.enabled) @@ -1366,8 +1366,8 @@ rtc::scoped_refptr VideoQualityTest::CreateAudioDevice() { #endif } -void VideoQualityTest::InitializeAudioDevice(Call::Config* send_call_config, - Call::Config* recv_call_config, +void VideoQualityTest::InitializeAudioDevice(CallConfig* send_call_config, + CallConfig* recv_call_config, bool use_real_adm) { rtc::scoped_refptr audio_device; if (use_real_adm) { @@ -1473,11 +1473,11 @@ void VideoQualityTest::RunWithRenderers(const Params& params) { params_ = params; CheckParamsAndInjectionComponents(); - // TODO(ivica): Remove bitrate_config and use the default Call::Config(), to + // TODO(ivica): Remove bitrate_config and use the default CallConfig(), to // match the full stack tests. - Call::Config send_call_config(send_event_log_.get()); + CallConfig send_call_config(send_event_log_.get()); send_call_config.bitrate_config = params_.call.call_bitrate_config; - Call::Config recv_call_config(recv_event_log_.get()); + CallConfig recv_call_config(recv_event_log_.get()); if (params_.audio.enabled) InitializeAudioDevice(&send_call_config, &recv_call_config, diff --git a/video/video_quality_test.h b/video/video_quality_test.h index f66256e94c..63fa4813f0 100644 --- a/video/video_quality_test.h +++ b/video/video_quality_test.h @@ -90,8 +90,8 @@ class VideoQualityTest : public test::CallTest, void DestroyThumbnailStreams(); // Helper method for creating a real ADM (using hardware) for all platforms. rtc::scoped_refptr CreateAudioDevice(); - void InitializeAudioDevice(Call::Config* send_call_config, - Call::Config* recv_call_config, + void InitializeAudioDevice(CallConfig* send_call_config, + CallConfig* recv_call_config, bool use_real_adm); void SetupAudio(Transport* transport);