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 <brandtr@webrtc.org>
Auto-Submit: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#40934}
diff --git a/test/call_test.cc b/test/call_test.cc
index b8a1cd7..2b71608 100644
--- a/test/call_test.cc
+++ b/test/call_test.cc
@@ -97,7 +97,7 @@
     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 @@
     }
     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::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 08d0e49..8d2b001 100644
--- a/test/call_test.h
+++ b/test/call_test.h
@@ -63,11 +63,11 @@
   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 83f894d..f6d7119 100644
--- a/test/fuzzers/utils/rtp_replayer.cc
+++ b/test/fuzzers/utils/rtp_replayer.cc
@@ -76,7 +76,7 @@
   webrtc::RtcEventLogNull event_log;
   std::unique_ptr<TaskQueueFactory> 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 d2019ae..fdf36de 100644
--- a/test/scenario/call_client.cc
+++ b/test/scenario/call_client.cc
@@ -59,11 +59,12 @@
   return setup;
 }
 
-Call* CreateCall(TimeController* time_controller,
-                 RtcEventLog* event_log,
-                 CallClientConfig config,
-                 LoggingNetworkControllerFactory* network_controller_factory,
-                 rtc::scoped_refptr<AudioState> audio_state) {
+std::unique_ptr<Call> CreateCall(
+    TimeController* time_controller,
+    RtcEventLog* event_log,
+    CallClientConfig config,
+    LoggingNetworkControllerFactory* network_controller_factory,
+    rtc::scoped_refptr<AudioState> 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 @@
                                 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<NetworkNodeTransport>(clock_, call_.get());
   });
 }