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}
This commit is contained in:
Danil Chapovalov 2023-10-13 13:53:00 +02:00 committed by WebRTC LUCI CQ
parent 9254df0f11
commit a3ce407023
22 changed files with 124 additions and 127 deletions

View File

@ -26,9 +26,9 @@ struct CallConfig;
// is constructed with a CallFactoryInterface, which may or may not be null. // is constructed with a CallFactoryInterface, which may or may not be null.
class CallFactoryInterface { class CallFactoryInterface {
public: public:
virtual ~CallFactoryInterface() {} virtual ~CallFactoryInterface() = default;
virtual Call* CreateCall(const CallConfig& config) = 0; virtual std::unique_ptr<Call> CreateCall(const CallConfig& config) = 0;
}; };
RTC_EXPORT std::unique_ptr<CallFactoryInterface> CreateCallFactory(); RTC_EXPORT std::unique_ptr<CallFactoryInterface> CreateCallFactory();

View File

@ -36,7 +36,7 @@ std::unique_ptr<CallFactoryInterface> CreateTimeControllerBasedCallFactory(
public: public:
explicit TimeControllerBasedCallFactory(TimeController* time_controller) explicit TimeControllerBasedCallFactory(TimeController* time_controller)
: time_controller_(time_controller) {} : time_controller_(time_controller) {}
Call* CreateCall(const Call::Config& config) override { std::unique_ptr<Call> CreateCall(const CallConfig& config) override {
RtpTransportConfig transportConfig = config.ExtractTransportConfig(); RtpTransportConfig transportConfig = config.ExtractTransportConfig();
return Call::Create(config, time_controller_->GetClock(), return Call::Create(config, time_controller_->GetClock(),

View File

@ -345,7 +345,6 @@ rtc_library("call") {
] ]
absl_deps = [ absl_deps = [
"//third_party/abseil-cpp/absl/functional:bind_front", "//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/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
@ -544,7 +543,6 @@ if (rtc_include_tests) {
absl_deps = [ absl_deps = [
"//third_party/abseil-cpp/absl/container:inlined_vector", "//third_party/abseil-cpp/absl/container:inlined_vector",
"//third_party/abseil-cpp/absl/functional:any_invocable", "//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/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
"//third_party/abseil-cpp/absl/types:variant", "//third_party/abseil-cpp/absl/types:variant",

View File

@ -184,7 +184,7 @@ class Call final : public webrtc::Call,
public BitrateAllocator::LimitObserver { public BitrateAllocator::LimitObserver {
public: public:
Call(Clock* clock, Call(Clock* clock,
const Call::Config& config, const CallConfig& config,
std::unique_ptr<RtpTransportControllerSendInterface> transport_send, std::unique_ptr<RtpTransportControllerSendInterface> transport_send,
TaskQueueFactory* task_queue_factory); TaskQueueFactory* task_queue_factory);
~Call() override; ~Call() override;
@ -355,7 +355,7 @@ class Call final : public webrtc::Call,
const int num_cpu_cores_; const int num_cpu_cores_;
const std::unique_ptr<CallStats> call_stats_; const std::unique_ptr<CallStats> call_stats_;
const std::unique_ptr<BitrateAllocator> bitrate_allocator_; const std::unique_ptr<BitrateAllocator> 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()`. // Maps to config_.trials, can be used from any thread via `trials()`.
const FieldTrialsView& trials_; const FieldTrialsView& trials_;
@ -478,19 +478,21 @@ std::string Call::Stats::ToString(int64_t time_ms) const {
return ss.str(); return ss.str();
} }
Call* Call::Create(const Call::Config& config) { std::unique_ptr<Call> Call::Create(const CallConfig& config) {
Clock* clock = Clock::GetRealTimeClock(); Clock* clock = Clock::GetRealTimeClock();
return Create(config, clock, return Create(config, clock,
RtpTransportControllerSendFactory().Create( RtpTransportControllerSendFactory().Create(
config.ExtractTransportConfig(), clock)); config.ExtractTransportConfig(), clock));
} }
Call* Call::Create(const Call::Config& config, std::unique_ptr<Call> Call::Create(
const CallConfig& config,
Clock* clock, Clock* clock,
std::unique_ptr<RtpTransportControllerSendInterface> std::unique_ptr<RtpTransportControllerSendInterface>
transportControllerSend) { transportControllerSend) {
RTC_DCHECK(config.task_queue_factory); RTC_DCHECK(config.task_queue_factory);
return new internal::Call(clock, config, std::move(transportControllerSend), return std::make_unique<internal::Call>(clock, config,
std::move(transportControllerSend),
config.task_queue_factory); config.task_queue_factory);
} }
@ -658,7 +660,7 @@ void Call::SendStats::SetMinAllocatableRate(BitrateAllocationLimits limits) {
} }
Call::Call(Clock* clock, Call::Call(Clock* clock,
const Call::Config& config, const CallConfig& config,
std::unique_ptr<RtpTransportControllerSendInterface> transport_send, std::unique_ptr<RtpTransportControllerSendInterface> transport_send,
TaskQueueFactory* task_queue_factory) TaskQueueFactory* task_queue_factory)
: clock_(clock), : clock_(clock),

View File

@ -46,8 +46,6 @@ namespace webrtc {
class Call { class Call {
public: public:
using Config = CallConfig;
struct Stats { struct Stats {
std::string ToString(int64_t time_ms) const; std::string ToString(int64_t time_ms) const;
@ -58,8 +56,9 @@ class Call {
int64_t rtt_ms = -1; int64_t rtt_ms = -1;
}; };
static Call* Create(const Call::Config& config); static std::unique_ptr<Call> Create(const CallConfig& config);
static Call* Create(const Call::Config& config, static std::unique_ptr<Call> Create(
const CallConfig& config,
Clock* clock, Clock* clock,
std::unique_ptr<RtpTransportControllerSendInterface> std::unique_ptr<RtpTransportControllerSendInterface>
transportControllerSend); transportControllerSend);

View File

@ -17,7 +17,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/memory/memory.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/test/simulated_network.h" #include "api/test/simulated_network.h"
#include "api/units/time_delta.h" #include "api/units/time_delta.h"
@ -83,7 +82,7 @@ CallFactory::CallFactory() {
call_thread_.Detach(); call_thread_.Detach();
} }
Call* CallFactory::CreateCall(const Call::Config& config) { std::unique_ptr<Call> CallFactory::CreateCall(const CallConfig& config) {
RTC_DCHECK_RUN_ON(&call_thread_); RTC_DCHECK_RUN_ON(&call_thread_);
RTC_DCHECK(config.trials); RTC_DCHECK(config.trials);
@ -95,22 +94,22 @@ Call* CallFactory::CreateCall(const Call::Config& config) {
RtpTransportConfig transportConfig = config.ExtractTransportConfig(); RtpTransportConfig transportConfig = config.ExtractTransportConfig();
Call* call = std::unique_ptr<Call> call =
Call::Create(config, Clock::GetRealTimeClock(), Call::Create(config, Clock::GetRealTimeClock(),
config.rtp_transport_controller_send_factory->Create( config.rtp_transport_controller_send_factory->Create(
transportConfig, Clock::GetRealTimeClock())); transportConfig, Clock::GetRealTimeClock()));
if (!send_degradation_configs.empty() || if (!send_degradation_configs.empty() ||
!receive_degradation_configs.empty()) { !receive_degradation_configs.empty()) {
return new DegradedCall(absl::WrapUnique(call), send_degradation_configs, return std::make_unique<DegradedCall>(
receive_degradation_configs); std::move(call), send_degradation_configs, receive_degradation_configs);
} }
return call; return call;
} }
std::unique_ptr<CallFactoryInterface> CreateCallFactory() { std::unique_ptr<CallFactoryInterface> CreateCallFactory() {
return std::unique_ptr<CallFactoryInterface>(new CallFactory()); return std::make_unique<CallFactory>();
} }
} // namespace webrtc } // namespace webrtc

View File

@ -11,6 +11,8 @@
#ifndef CALL_CALL_FACTORY_H_ #ifndef CALL_CALL_FACTORY_H_
#define CALL_CALL_FACTORY_H_ #define CALL_CALL_FACTORY_H_
#include <memory>
#include "api/call/call_factory_interface.h" #include "api/call/call_factory_interface.h"
#include "api/sequence_checker.h" #include "api/sequence_checker.h"
#include "call/call.h" #include "call/call.h"
@ -22,11 +24,10 @@ namespace webrtc {
class CallFactory : public CallFactoryInterface { class CallFactory : public CallFactoryInterface {
public: public:
CallFactory(); CallFactory();
~CallFactory() override = default;
private: private:
~CallFactory() override {} std::unique_ptr<Call> CreateCall(const CallConfig& config) override;
Call* CreateCall(const CallConfig& config) override;
RTC_NO_UNIQUE_ADDRESS SequenceChecker call_thread_; RTC_NO_UNIQUE_ADDRESS SequenceChecker call_thread_;
}; };

View File

@ -223,12 +223,12 @@ void CallPerfTest::TestAudioVideoSync(FecMode fec,
send_audio_state_config.audio_processing = send_audio_state_config.audio_processing =
AudioProcessingBuilder().Create(); AudioProcessingBuilder().Create();
send_audio_state_config.audio_device_module = fake_audio_device; 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); auto audio_state = AudioState::Create(send_audio_state_config);
fake_audio_device->RegisterAudioCallback(audio_state->audio_transport()); fake_audio_device->RegisterAudioCallback(audio_state->audio_transport());
sender_config.audio_state = audio_state; 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; receiver_config.audio_state = audio_state;
CreateCalls(sender_config, receiver_config); CreateCalls(sender_config, receiver_config);

View File

@ -15,7 +15,6 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "absl/memory/memory.h"
#include "absl/strings/string_view.h" #include "absl/strings/string_view.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/media_types.h" #include "api/media_types.h"
@ -40,6 +39,7 @@
#include "test/mock_transport.h" #include "test/mock_transport.h"
#include "test/run_loop.h" #include "test/run_loop.h"
namespace webrtc {
namespace { namespace {
using ::testing::_; using ::testing::_;
@ -47,41 +47,38 @@ using ::testing::Contains;
using ::testing::MockFunction; using ::testing::MockFunction;
using ::testing::NiceMock; using ::testing::NiceMock;
using ::testing::StrictMock; using ::testing::StrictMock;
using ::webrtc::test::MockAudioDeviceModule;
using ::webrtc::test::MockAudioMixer;
using ::webrtc::test::MockAudioProcessing;
using ::webrtc::test::RunLoop;
struct CallHelper { struct CallHelper {
explicit CallHelper(bool use_null_audio_processing) { explicit CallHelper(bool use_null_audio_processing) {
task_queue_factory_ = webrtc::CreateDefaultTaskQueueFactory(); task_queue_factory_ = CreateDefaultTaskQueueFactory();
webrtc::AudioState::Config audio_state_config; AudioState::Config audio_state_config;
audio_state_config.audio_mixer = audio_state_config.audio_mixer = rtc::make_ref_counted<MockAudioMixer>();
rtc::make_ref_counted<webrtc::test::MockAudioMixer>();
audio_state_config.audio_processing = audio_state_config.audio_processing =
use_null_audio_processing use_null_audio_processing
? nullptr ? nullptr
: rtc::make_ref_counted< : rtc::make_ref_counted<NiceMock<MockAudioProcessing>>();
NiceMock<webrtc::test::MockAudioProcessing>>();
audio_state_config.audio_device_module = audio_state_config.audio_device_module =
rtc::make_ref_counted<webrtc::test::MockAudioDeviceModule>(); rtc::make_ref_counted<MockAudioDeviceModule>();
webrtc::Call::Config config(&event_log_); CallConfig config(&event_log_);
config.audio_state = webrtc::AudioState::Create(audio_state_config); config.audio_state = AudioState::Create(audio_state_config);
config.task_queue_factory = task_queue_factory_.get(); config.task_queue_factory = task_queue_factory_.get();
config.trials = &field_trials_; 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: private:
webrtc::test::RunLoop loop_; RunLoop loop_;
webrtc::RtcEventLogNull event_log_; RtcEventLogNull event_log_;
webrtc::FieldTrialBasedConfig field_trials_; FieldTrialBasedConfig field_trials_;
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_; std::unique_ptr<TaskQueueFactory> task_queue_factory_;
std::unique_ptr<webrtc::Call> call_; std::unique_ptr<Call> call_;
}; };
} // namespace
namespace webrtc {
namespace {
rtc::scoped_refptr<Resource> FindResourceWhoseNameContains( rtc::scoped_refptr<Resource> FindResourceWhoseNameContains(
const std::vector<rtc::scoped_refptr<Resource>>& resources, const std::vector<rtc::scoped_refptr<Resource>>& resources,

View File

@ -19,7 +19,6 @@
#include <vector> #include <vector>
#include "absl/algorithm/container.h" #include "absl/algorithm/container.h"
#include "absl/memory/memory.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log/rtc_event_log.h"
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
@ -99,6 +98,8 @@ using ::testing::StrNe;
using ::testing::Values; using ::testing::Values;
using ::testing::WithArg; using ::testing::WithArg;
using ::webrtc::BitrateConstraints; using ::webrtc::BitrateConstraints;
using ::webrtc::Call;
using ::webrtc::CallConfig;
using ::webrtc::kDefaultScalabilityModeStr; using ::webrtc::kDefaultScalabilityModeStr;
using ::webrtc::RtpExtension; using ::webrtc::RtpExtension;
using ::webrtc::RtpPacket; using ::webrtc::RtpPacket;
@ -355,8 +356,8 @@ class WebRtcVideoEngineTest : public ::testing::Test {
: field_trials_(field_trials), : field_trials_(field_trials),
time_controller_(webrtc::Timestamp::Millis(4711)), time_controller_(webrtc::Timestamp::Millis(4711)),
task_queue_factory_(time_controller_.CreateTaskQueueFactory()), task_queue_factory_(time_controller_.CreateTaskQueueFactory()),
call_(webrtc::Call::Create([&] { call_(Call::Create([&] {
webrtc::Call::Config call_config(&event_log_); CallConfig call_config(&event_log_);
call_config.task_queue_factory = task_queue_factory_.get(); call_config.task_queue_factory = task_queue_factory_.get();
call_config.trials = &field_trials_; call_config.trials = &field_trials_;
return call_config; return call_config;
@ -401,7 +402,7 @@ class WebRtcVideoEngineTest : public ::testing::Test {
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_; std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
// Used in WebRtcVideoEngineVoiceTest, but defined here so it's properly // Used in WebRtcVideoEngineVoiceTest, but defined here so it's properly
// initialized when the constructor is called. // initialized when the constructor is called.
std::unique_ptr<webrtc::Call> call_; std::unique_ptr<Call> call_;
cricket::FakeWebRtcVideoEncoderFactory* encoder_factory_; cricket::FakeWebRtcVideoEncoderFactory* encoder_factory_;
cricket::FakeWebRtcVideoDecoderFactory* decoder_factory_; cricket::FakeWebRtcVideoDecoderFactory* decoder_factory_;
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
@ -1443,11 +1444,11 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
webrtc::GlobalSimulatedTimeController time_controller( webrtc::GlobalSimulatedTimeController time_controller(
webrtc::Timestamp::Millis(4711)); webrtc::Timestamp::Millis(4711));
auto task_queue_factory = time_controller.CreateTaskQueueFactory(); auto task_queue_factory = time_controller.CreateTaskQueueFactory();
webrtc::Call::Config call_config(&event_log); CallConfig call_config(&event_log);
webrtc::FieldTrialBasedConfig field_trials; webrtc::FieldTrialBasedConfig field_trials;
call_config.trials = &field_trials; call_config.trials = &field_trials;
call_config.task_queue_factory = task_queue_factory.get(); 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 = Call::Create(call_config);
// Create send channel. // Create send channel.
const int send_ssrc = 123; const int send_ssrc = 123;
@ -1575,10 +1576,9 @@ TEST_F(WebRtcVideoEngineTest, SetVideoRtxEnabled) {
class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test { class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test {
protected: protected:
webrtc::Call::Config GetCallConfig( CallConfig GetCallConfig(webrtc::RtcEventLogNull* event_log,
webrtc::RtcEventLogNull* event_log,
webrtc::TaskQueueFactory* task_queue_factory) { webrtc::TaskQueueFactory* task_queue_factory) {
webrtc::Call::Config call_config(event_log); CallConfig call_config(event_log);
call_config.task_queue_factory = task_queue_factory; call_config.task_queue_factory = task_queue_factory;
call_config.trials = &field_trials_; call_config.trials = &field_trials_;
return call_config; return call_config;
@ -1586,8 +1586,8 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test {
WebRtcVideoChannelEncodedFrameCallbackTest() WebRtcVideoChannelEncodedFrameCallbackTest()
: task_queue_factory_(time_controller_.CreateTaskQueueFactory()), : task_queue_factory_(time_controller_.CreateTaskQueueFactory()),
call_(absl::WrapUnique(webrtc::Call::Create( call_(Call::Create(
GetCallConfig(&event_log_, task_queue_factory_.get())))), GetCallConfig(&event_log_, task_queue_factory_.get()))),
video_bitrate_allocator_factory_( video_bitrate_allocator_factory_(
webrtc::CreateBuiltinVideoBitrateAllocatorFactory()), webrtc::CreateBuiltinVideoBitrateAllocatorFactory()),
engine_( engine_(
@ -1639,7 +1639,7 @@ class WebRtcVideoChannelEncodedFrameCallbackTest : public ::testing::Test {
webrtc::test::ScopedKeyValueConfig field_trials_; webrtc::test::ScopedKeyValueConfig field_trials_;
webrtc::RtcEventLogNull event_log_; webrtc::RtcEventLogNull event_log_;
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_; std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
std::unique_ptr<webrtc::Call> call_; std::unique_ptr<Call> call_;
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
video_bitrate_allocator_factory_; video_bitrate_allocator_factory_;
WebRtcVideoEngine engine_; WebRtcVideoEngine engine_;
@ -1775,10 +1775,10 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test {
void SetUp() override { void SetUp() override {
// One testcase calls SetUp in a loop, only create call_ once. // One testcase calls SetUp in a loop, only create call_ once.
if (!call_) { 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.task_queue_factory = task_queue_factory_.get();
call_config.trials = &field_trials_; call_config.trials = &field_trials_;
call_.reset(webrtc::Call::Create(call_config)); call_ = Call::Create(call_config);
} }
cricket::MediaConfig media_config; cricket::MediaConfig media_config;
@ -1981,7 +1981,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test {
webrtc::test::ScopedKeyValueConfig field_trials_; webrtc::test::ScopedKeyValueConfig field_trials_;
std::unique_ptr<webrtc::test::ScopedKeyValueConfig> override_field_trials_; std::unique_ptr<webrtc::test::ScopedKeyValueConfig> override_field_trials_;
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_; std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
std::unique_ptr<webrtc::Call> call_; std::unique_ptr<Call> call_;
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
video_bitrate_allocator_factory_; video_bitrate_allocator_factory_;
WebRtcVideoEngine engine_; WebRtcVideoEngine engine_;
@ -6777,7 +6777,7 @@ TEST_F(WebRtcVideoChannelTest, GetStatsTranslatesReceivePacketStatsCorrectly) {
TEST_F(WebRtcVideoChannelTest, TranslatesCallStatsCorrectly) { TEST_F(WebRtcVideoChannelTest, TranslatesCallStatsCorrectly) {
AddSendStream(); AddSendStream();
AddSendStream(); AddSendStream();
webrtc::Call::Stats stats; Call::Stats stats;
stats.rtt_ms = 123; stats.rtt_ms = 123;
fake_call_->SetStats(stats); fake_call_->SetStats(stats);

View File

@ -55,6 +55,8 @@ using ::testing::ReturnPointee;
using ::testing::SaveArg; using ::testing::SaveArg;
using ::testing::StrictMock; using ::testing::StrictMock;
using ::testing::UnorderedElementsAreArray; using ::testing::UnorderedElementsAreArray;
using ::webrtc::Call;
using ::webrtc::CallConfig;
namespace { namespace {
using webrtc::BitrateConstraints; using webrtc::BitrateConstraints;
@ -3690,10 +3692,10 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) {
nullptr, nullptr, field_trials); nullptr, nullptr, field_trials);
engine.Init(); engine.Init();
webrtc::RtcEventLogNull event_log; webrtc::RtcEventLogNull event_log;
webrtc::Call::Config call_config(&event_log); CallConfig call_config(&event_log);
call_config.trials = &field_trials; call_config.trials = &field_trials;
call_config.task_queue_factory = task_queue_factory.get(); call_config.task_queue_factory = task_queue_factory.get();
auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); std::unique_ptr<Call> call = Call::Create(call_config);
std::unique_ptr<cricket::VoiceMediaSendChannelInterface> send_channel = std::unique_ptr<cricket::VoiceMediaSendChannelInterface> send_channel =
engine.CreateSendChannel( engine.CreateSendChannel(
call.get(), cricket::MediaConfig(), cricket::AudioOptions(), call.get(), cricket::MediaConfig(), cricket::AudioOptions(),
@ -3726,10 +3728,10 @@ TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) {
nullptr, nullptr, field_trials); nullptr, nullptr, field_trials);
engine.Init(); engine.Init();
webrtc::RtcEventLogNull event_log; webrtc::RtcEventLogNull event_log;
webrtc::Call::Config call_config(&event_log); CallConfig call_config(&event_log);
call_config.trials = &field_trials; call_config.trials = &field_trials;
call_config.task_queue_factory = task_queue_factory.get(); call_config.task_queue_factory = task_queue_factory.get();
auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); std::unique_ptr<Call> call = Call::Create(call_config);
std::unique_ptr<cricket::VoiceMediaSendChannelInterface> send_channel = std::unique_ptr<cricket::VoiceMediaSendChannelInterface> send_channel =
engine.CreateSendChannel( engine.CreateSendChannel(
call.get(), cricket::MediaConfig(), cricket::AudioOptions(), call.get(), cricket::MediaConfig(), cricket::AudioOptions(),
@ -3816,10 +3818,10 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) {
nullptr, nullptr, field_trials); nullptr, nullptr, field_trials);
engine.Init(); engine.Init();
webrtc::RtcEventLogNull event_log; webrtc::RtcEventLogNull event_log;
webrtc::Call::Config call_config(&event_log); CallConfig call_config(&event_log);
call_config.trials = &field_trials; call_config.trials = &field_trials;
call_config.task_queue_factory = task_queue_factory.get(); call_config.task_queue_factory = task_queue_factory.get();
auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); std::unique_ptr<Call> call = Call::Create(call_config);
std::vector<std::unique_ptr<cricket::VoiceMediaSendChannelInterface>> std::vector<std::unique_ptr<cricket::VoiceMediaSendChannelInterface>>
channels; channels;
@ -3862,10 +3864,10 @@ TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
nullptr, field_trials); nullptr, field_trials);
engine.Init(); engine.Init();
webrtc::RtcEventLogNull event_log; webrtc::RtcEventLogNull event_log;
webrtc::Call::Config call_config(&event_log); CallConfig call_config(&event_log);
call_config.trials = &field_trials; call_config.trials = &field_trials;
call_config.task_queue_factory = task_queue_factory.get(); call_config.task_queue_factory = task_queue_factory.get();
auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); std::unique_ptr<Call> call = Call::Create(call_config);
cricket::WebRtcVoiceReceiveChannel channel( cricket::WebRtcVoiceReceiveChannel channel(
&engine, cricket::MediaConfig(), cricket::AudioOptions(), &engine, cricket::MediaConfig(), cricket::AudioOptions(),
webrtc::CryptoOptions(), call.get(), webrtc::CryptoOptions(), call.get(),
@ -3891,7 +3893,7 @@ TEST(WebRtcVoiceEngineTest, SetRtpSendParametersMaxBitrate) {
field_trials); field_trials);
engine.Init(); engine.Init();
webrtc::RtcEventLogNull event_log; webrtc::RtcEventLogNull event_log;
webrtc::Call::Config call_config(&event_log); CallConfig call_config(&event_log);
call_config.trials = &field_trials; call_config.trials = &field_trials;
call_config.task_queue_factory = task_queue_factory.get(); call_config.task_queue_factory = task_queue_factory.get();
{ {
@ -3901,7 +3903,7 @@ TEST(WebRtcVoiceEngineTest, SetRtpSendParametersMaxBitrate) {
webrtc::test::MockAudioDeviceModule::CreateNice(); webrtc::test::MockAudioDeviceModule::CreateNice();
call_config.audio_state = webrtc::AudioState::Create(config); call_config.audio_state = webrtc::AudioState::Create(config);
} }
auto call = absl::WrapUnique(webrtc::Call::Create(call_config)); std::unique_ptr<Call> call = Call::Create(call_config);
cricket::WebRtcVoiceSendChannel channel( cricket::WebRtcVoiceSendChannel channel(
&engine, cricket::MediaConfig(), cricket::AudioOptions(), &engine, cricket::MediaConfig(), cricket::AudioOptions(),
webrtc::CryptoOptions(), call.get(), webrtc::AudioCodecPairId::Create()); webrtc::CryptoOptions(), call.get(), webrtc::AudioCodecPairId::Create());

View File

@ -301,7 +301,7 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
const PeerConnectionInterface::RTCConfiguration& configuration) { const PeerConnectionInterface::RTCConfiguration& configuration) {
RTC_DCHECK_RUN_ON(worker_thread()); 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()) { if (!media_engine() || !context_->call_factory()) {
return nullptr; return nullptr;
} }
@ -342,8 +342,7 @@ std::unique_ptr<Call> PeerConnectionFactory::CreateCall_w(
transport_controller_send_factory_.get(); transport_controller_send_factory_.get();
call_config.metronome = metronome_.get(); call_config.metronome = metronome_.get();
call_config.pacer_burst_interval = configuration.pacer_burst_interval; call_config.pacer_burst_interval = configuration.pacer_burst_interval;
return std::unique_ptr<Call>( return context_->call_factory()->CreateCall(call_config);
context_->call_factory()->CreateCall(call_config));
} }
bool PeerConnectionFactory::IsTrialEnabled(absl::string_view key) const { bool PeerConnectionFactory::IsTrialEnabled(absl::string_view key) const {

View File

@ -494,10 +494,10 @@ class RtpReplayer final {
"worker_thread", TaskQueueFactory::Priority::NORMAL)); "worker_thread", TaskQueueFactory::Priority::NORMAL));
rtc::Event event; rtc::Event event;
worker_thread_->PostTask([&]() { worker_thread_->PostTask([&]() {
Call::Config call_config(&event_log_); CallConfig call_config(&event_log_);
call_config.trials = field_trials_.get(); call_config.trials = field_trials_.get();
call_config.task_queue_factory = task_queue_factory; 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 // Creation of the streams must happen inside a task queue because it is
// resued as a worker thread. // resued as a worker thread.

View File

@ -97,7 +97,7 @@ void CallTest::RunBaseTest(BaseTest* test) {
num_audio_streams_ = test->GetNumAudioStreams(); num_audio_streams_ = test->GetNumAudioStreams();
num_flexfec_streams_ = test->GetNumFlexfecStreams(); num_flexfec_streams_ = test->GetNumFlexfecStreams();
RTC_DCHECK(num_video_streams_ > 0 || num_audio_streams_ > 0); 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); test->ModifySenderBitrateConfig(&send_config.bitrate_config);
if (num_audio_streams_ > 0) { if (num_audio_streams_ > 0) {
CreateFakeAudioDevices(test->CreateCapturer(), test->CreateRenderer()); CreateFakeAudioDevices(test->CreateCapturer(), test->CreateRenderer());
@ -117,7 +117,7 @@ void CallTest::RunBaseTest(BaseTest* test) {
} }
CreateSenderCall(send_config); CreateSenderCall(send_config);
if (test->ShouldCreateReceivers()) { if (test->ShouldCreateReceivers()) {
Call::Config recv_config(recv_event_log_.get()); CallConfig recv_config(recv_event_log_.get());
test->ModifyReceiverBitrateConfig(&recv_config.bitrate_config); test->ModifyReceiverBitrateConfig(&recv_config.bitrate_config);
if (num_audio_streams_ > 0) { if (num_audio_streams_ > 0) {
AudioState::Config audio_state_config; AudioState::Config audio_state_config;
@ -207,35 +207,35 @@ void CallTest::RunBaseTest(BaseTest* test) {
} }
void CallTest::CreateCalls() { void CallTest::CreateCalls() {
CreateCalls(Call::Config(send_event_log_.get()), CreateCalls(CallConfig(send_event_log_.get()),
Call::Config(recv_event_log_.get())); CallConfig(recv_event_log_.get()));
} }
void CallTest::CreateCalls(const Call::Config& sender_config, void CallTest::CreateCalls(const CallConfig& sender_config,
const Call::Config& receiver_config) { const CallConfig& receiver_config) {
CreateSenderCall(sender_config); CreateSenderCall(sender_config);
CreateReceiverCall(receiver_config); CreateReceiverCall(receiver_config);
} }
void CallTest::CreateSenderCall() { 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; auto sender_config = config;
sender_config.task_queue_factory = task_queue_factory_.get(); sender_config.task_queue_factory = task_queue_factory_.get();
sender_config.network_state_predictor_factory = sender_config.network_state_predictor_factory =
network_state_predictor_factory_.get(); network_state_predictor_factory_.get();
sender_config.network_controller_factory = network_controller_factory_.get(); sender_config.network_controller_factory = network_controller_factory_.get();
sender_config.trials = &field_trials_; 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; auto receiver_config = config;
receiver_config.task_queue_factory = task_queue_factory_.get(); receiver_config.task_queue_factory = task_queue_factory_.get();
receiver_config.trials = &field_trials_; receiver_config.trials = &field_trials_;
receiver_call_.reset(Call::Create(receiver_config)); receiver_call_ = Call::Create(receiver_config);
} }
void CallTest::DestroyCalls() { void CallTest::DestroyCalls() {

View File

@ -63,11 +63,11 @@ class CallTest : public ::testing::Test, public RtpPacketSinkInterface {
void RunBaseTest(BaseTest* test); void RunBaseTest(BaseTest* test);
void CreateCalls(); void CreateCalls();
void CreateCalls(const Call::Config& sender_config, void CreateCalls(const CallConfig& sender_config,
const Call::Config& receiver_config); const CallConfig& receiver_config);
void CreateSenderCall(); void CreateSenderCall();
void CreateSenderCall(const Call::Config& config); void CreateSenderCall(const CallConfig& config);
void CreateReceiverCall(const Call::Config& config); void CreateReceiverCall(const CallConfig& config);
void DestroyCalls(); void DestroyCalls();
void CreateVideoSendConfig(VideoSendStream::Config* video_config, void CreateVideoSendConfig(VideoSendStream::Config* video_config,

View File

@ -76,7 +76,7 @@ void RtpReplayer::Replay(
webrtc::RtcEventLogNull event_log; webrtc::RtcEventLogNull event_log;
std::unique_ptr<TaskQueueFactory> task_queue_factory = std::unique_ptr<TaskQueueFactory> task_queue_factory =
CreateDefaultTaskQueueFactory(); CreateDefaultTaskQueueFactory();
Call::Config call_config(&event_log); CallConfig call_config(&event_log);
call_config.task_queue_factory = task_queue_factory.get(); call_config.task_queue_factory = task_queue_factory.get();
FieldTrialBasedConfig field_trials; FieldTrialBasedConfig field_trials;
call_config.trials = &field_trials; call_config.trials = &field_trials;

View File

@ -59,7 +59,8 @@ CallClientFakeAudio InitAudio(TimeController* time_controller) {
return setup; return setup;
} }
Call* CreateCall(TimeController* time_controller, std::unique_ptr<Call> CreateCall(
TimeController* time_controller,
RtcEventLog* event_log, RtcEventLog* event_log,
CallClientConfig config, CallClientConfig config,
LoggingNetworkControllerFactory* network_controller_factory, LoggingNetworkControllerFactory* network_controller_factory,
@ -230,9 +231,9 @@ CallClient::CallClient(
log_writer_factory_.get()); log_writer_factory_.get());
fake_audio_setup_ = InitAudio(time_controller_); fake_audio_setup_ = InitAudio(time_controller_);
call_.reset(CreateCall(time_controller_, event_log_.get(), config, call_ =
&network_controller_factory_, CreateCall(time_controller_, event_log_.get(), config,
fake_audio_setup_.audio_state)); &network_controller_factory_, fake_audio_setup_.audio_state);
transport_ = std::make_unique<NetworkNodeTransport>(clock_, call_.get()); transport_ = std::make_unique<NetworkNodeTransport>(clock_, call_.get());
}); });
} }

View File

@ -14,7 +14,6 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#include "absl/memory/memory.h"
#include "api/rtc_event_log/rtc_event_log.h" #include "api/rtc_event_log/rtc_event_log.h"
#include "api/task_queue/default_task_queue_factory.h" #include "api/task_queue/default_task_queue_factory.h"
#include "api/task_queue/task_queue_base.h" #include "api/task_queue/task_queue_base.h"
@ -50,7 +49,7 @@ void MultiStreamTester::RunTest() {
// to make test more stable. // to make test more stable.
auto task_queue = task_queue_factory->CreateTaskQueue( auto task_queue = task_queue_factory->CreateTaskQueue(
"TaskQueue", TaskQueueFactory::Priority::HIGH); "TaskQueue", TaskQueueFactory::Priority::HIGH);
Call::Config config(&event_log); CallConfig config(&event_log);
test::ScopedKeyValueConfig field_trials; test::ScopedKeyValueConfig field_trials;
config.trials = &field_trials; config.trials = &field_trials;
config.task_queue_factory = task_queue_factory.get(); config.task_queue_factory = task_queue_factory.get();
@ -69,8 +68,8 @@ void MultiStreamTester::RunTest() {
InternalDecoderFactory decoder_factory; InternalDecoderFactory decoder_factory;
SendTask(task_queue.get(), [&]() { SendTask(task_queue.get(), [&]() {
sender_call = absl::WrapUnique(Call::Create(config)); sender_call = Call::Create(config);
receiver_call = absl::WrapUnique(Call::Create(config)); receiver_call = Call::Create(config);
sender_transport = CreateSendTransport(task_queue.get(), sender_call.get()); sender_transport = CreateSendTransport(task_queue.get(), sender_call.get());
receiver_transport = receiver_transport =
CreateReceiveTransport(task_queue.get(), receiver_call.get()); CreateReceiveTransport(task_queue.get(), receiver_call.get());

View File

@ -94,7 +94,7 @@ void NetworkStateEndToEndTest::VerifyNewVideoSendStreamsRespectNetworkState(
SendTask(task_queue(), [this, network_to_bring_up, &encoder_factory, SendTask(task_queue(), [this, network_to_bring_up, &encoder_factory,
transport]() { transport]() {
CreateSenderCall(Call::Config(send_event_log_.get())); CreateSenderCall(CallConfig(send_event_log_.get()));
sender_call_->SignalChannelNetworkState(network_to_bring_up, kNetworkUp); sender_call_->SignalChannelNetworkState(network_to_bring_up, kNetworkUp);
CreateSendConfig(1, 0, 0, transport); CreateSendConfig(1, 0, 0, transport);

View File

@ -518,9 +518,9 @@ TEST_F(StatsEndToEndTest, MAYBE_ContentTypeSwitches) {
metrics::Reset(); metrics::Reset();
Call::Config send_config(send_event_log_.get()); CallConfig send_config(send_event_log_.get());
test.ModifySenderBitrateConfig(&send_config.bitrate_config); 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); test.ModifyReceiverBitrateConfig(&recv_config.bitrate_config);
VideoEncoderConfig encoder_config_with_screenshare; VideoEncoderConfig encoder_config_with_screenshare;

View File

@ -1247,8 +1247,8 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) {
} }
SendTask(task_queue(), [this, &params, &send_transport, &recv_transport]() { SendTask(task_queue(), [this, &params, &send_transport, &recv_transport]() {
Call::Config send_call_config(send_event_log_.get()); CallConfig send_call_config(send_event_log_.get());
Call::Config recv_call_config(recv_event_log_.get()); CallConfig recv_call_config(recv_event_log_.get());
send_call_config.bitrate_config = params.call.call_bitrate_config; send_call_config.bitrate_config = params.call.call_bitrate_config;
recv_call_config.bitrate_config = params.call.call_bitrate_config; recv_call_config.bitrate_config = params.call.call_bitrate_config;
if (params_.audio.enabled) if (params_.audio.enabled)
@ -1366,8 +1366,8 @@ rtc::scoped_refptr<AudioDeviceModule> VideoQualityTest::CreateAudioDevice() {
#endif #endif
} }
void VideoQualityTest::InitializeAudioDevice(Call::Config* send_call_config, void VideoQualityTest::InitializeAudioDevice(CallConfig* send_call_config,
Call::Config* recv_call_config, CallConfig* recv_call_config,
bool use_real_adm) { bool use_real_adm) {
rtc::scoped_refptr<AudioDeviceModule> audio_device; rtc::scoped_refptr<AudioDeviceModule> audio_device;
if (use_real_adm) { if (use_real_adm) {
@ -1473,11 +1473,11 @@ void VideoQualityTest::RunWithRenderers(const Params& params) {
params_ = params; params_ = params;
CheckParamsAndInjectionComponents(); 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. // 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; 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) if (params_.audio.enabled)
InitializeAudioDevice(&send_call_config, &recv_call_config, InitializeAudioDevice(&send_call_config, &recv_call_config,

View File

@ -90,8 +90,8 @@ class VideoQualityTest : public test::CallTest,
void DestroyThumbnailStreams(); void DestroyThumbnailStreams();
// Helper method for creating a real ADM (using hardware) for all platforms. // Helper method for creating a real ADM (using hardware) for all platforms.
rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice(); rtc::scoped_refptr<AudioDeviceModule> CreateAudioDevice();
void InitializeAudioDevice(Call::Config* send_call_config, void InitializeAudioDevice(CallConfig* send_call_config,
Call::Config* recv_call_config, CallConfig* recv_call_config,
bool use_real_adm); bool use_real_adm);
void SetupAudio(Transport* transport); void SetupAudio(Transport* transport);