Make TaskQueueFactory required construction parameter for Call

Bug: webrtc:10284
Change-Id: I573ee0087c035e26918260c21b8b0213ddfe7ebc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/143791
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28467}
This commit is contained in:
Danil Chapovalov 2019-07-03 14:56:33 +02:00 committed by Commit Bot
parent 84ce3c08a5
commit 53d45baa50
10 changed files with 52 additions and 26 deletions

View File

@ -227,7 +227,6 @@ rtc_static_library("call") {
"../api:rtp_headers", "../api:rtp_headers",
"../api:simulated_network_api", "../api:simulated_network_api",
"../api:transport_api", "../api:transport_api",
"../api/task_queue:global_task_queue_factory",
"../api/transport:network_control", "../api/transport:network_control",
"../api/units:time_delta", "../api/units:time_delta",
"../api/video_codecs:video_codecs_api", "../api/video_codecs:video_codecs_api",

View File

@ -18,7 +18,6 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "api/task_queue/global_task_queue_factory.h"
#include "api/transport/network_control.h" #include "api/transport/network_control.h"
#include "audio/audio_receive_stream.h" #include "audio/audio_receive_stream.h"
#include "audio/audio_send_stream.h" #include "audio/audio_send_stream.h"
@ -430,18 +429,14 @@ Call* Call::Create(const Call::Config& config,
Clock* clock, Clock* clock,
std::unique_ptr<ProcessThread> call_thread, std::unique_ptr<ProcessThread> call_thread,
std::unique_ptr<ProcessThread> pacer_thread) { std::unique_ptr<ProcessThread> pacer_thread) {
// TODO(bugs.webrtc.org/10284): DCHECK task_queue_factory dependency is RTC_DCHECK(config.task_queue_factory);
// always provided in the config.
TaskQueueFactory* task_queue_factory = config.task_queue_factory
? config.task_queue_factory
: &GlobalTaskQueueFactory();
return new internal::Call( return new internal::Call(
clock, config, clock, config,
absl::make_unique<RtpTransportControllerSend>( absl::make_unique<RtpTransportControllerSend>(
clock, config.event_log, config.network_state_predictor_factory, clock, config.event_log, config.network_state_predictor_factory,
config.network_controller_factory, config.bitrate_config, config.network_controller_factory, config.bitrate_config,
std::move(pacer_thread), task_queue_factory), std::move(pacer_thread), config.task_queue_factory),
std::move(call_thread), task_queue_factory); std::move(call_thread), config.task_queue_factory);
} }
// This method here to avoid subclasses has to implement this method. // This method here to avoid subclasses has to implement this method.

View File

@ -47,7 +47,7 @@ struct CallConfig {
// FecController to use for this call. // FecController to use for this call.
FecControllerFactoryInterface* fec_controller_factory = nullptr; FecControllerFactoryInterface* fec_controller_factory = nullptr;
// Task Queue Factory to be used in this call. // Task Queue Factory to be used in this call. Required.
TaskQueueFactory* task_queue_factory = nullptr; TaskQueueFactory* task_queue_factory = nullptr;
// NetworkStatePredictor to use for this call. // NetworkStatePredictor to use for this call.

View File

@ -15,6 +15,7 @@
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "api/test/fake_media_transport.h" #include "api/test/fake_media_transport.h"
#include "api/test/mock_audio_mixer.h" #include "api/test/mock_audio_mixer.h"
#include "audio/audio_receive_stream.h" #include "audio/audio_receive_stream.h"
@ -35,6 +36,7 @@ namespace {
struct CallHelper { struct CallHelper {
CallHelper() { CallHelper() {
task_queue_factory_ = webrtc::CreateDefaultTaskQueueFactory();
webrtc::AudioState::Config audio_state_config; webrtc::AudioState::Config audio_state_config;
audio_state_config.audio_mixer = audio_state_config.audio_mixer =
new rtc::RefCountedObject<webrtc::test::MockAudioMixer>(); new rtc::RefCountedObject<webrtc::test::MockAudioMixer>();
@ -44,6 +46,7 @@ struct CallHelper {
new rtc::RefCountedObject<webrtc::test::MockAudioDeviceModule>(); new rtc::RefCountedObject<webrtc::test::MockAudioDeviceModule>();
webrtc::Call::Config config(&event_log_); webrtc::Call::Config config(&event_log_);
config.audio_state = webrtc::AudioState::Create(audio_state_config); config.audio_state = webrtc::AudioState::Create(audio_state_config);
config.task_queue_factory = task_queue_factory_.get();
call_.reset(webrtc::Call::Create(config)); call_.reset(webrtc::Call::Create(config));
} }
@ -51,6 +54,7 @@ struct CallHelper {
private: private:
webrtc::RtcEventLogNullImpl event_log_; webrtc::RtcEventLogNullImpl event_log_;
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
std::unique_ptr<webrtc::Call> call_; std::unique_ptr<webrtc::Call> call_;
}; };
} // namespace } // namespace

View File

@ -19,6 +19,7 @@
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "api/media_transport_config.h" #include "api/media_transport_config.h"
#include "api/rtp_parameters.h" #include "api/rtp_parameters.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "api/test/fake_media_transport.h" #include "api/test/fake_media_transport.h"
#include "api/test/mock_video_bitrate_allocator.h" #include "api/test/mock_video_bitrate_allocator.h"
#include "api/test/mock_video_bitrate_allocator_factory.h" #include "api/test/mock_video_bitrate_allocator_factory.h"
@ -226,7 +227,12 @@ class WebRtcVideoEngineTest : public ::testing::Test {
? nullptr ? nullptr
: absl::make_unique<webrtc::test::ScopedFieldTrials>( : absl::make_unique<webrtc::test::ScopedFieldTrials>(
field_trials)), field_trials)),
call_(webrtc::Call::Create(webrtc::Call::Config(&event_log_))), task_queue_factory_(webrtc::CreateDefaultTaskQueueFactory()),
call_(webrtc::Call::Create([&] {
webrtc::Call::Config call_config(&event_log_);
call_config.task_queue_factory = task_queue_factory_.get();
return call_config;
}())),
encoder_factory_(new cricket::FakeWebRtcVideoEncoderFactory), encoder_factory_(new cricket::FakeWebRtcVideoEncoderFactory),
decoder_factory_(new cricket::FakeWebRtcVideoDecoderFactory), decoder_factory_(new cricket::FakeWebRtcVideoDecoderFactory),
video_bitrate_allocator_factory_( video_bitrate_allocator_factory_(
@ -264,6 +270,7 @@ class WebRtcVideoEngineTest : public ::testing::Test {
rtc::ScopedFakeClock fake_clock_; rtc::ScopedFakeClock fake_clock_;
std::unique_ptr<webrtc::test::ScopedFieldTrials> override_field_trials_; std::unique_ptr<webrtc::test::ScopedFieldTrials> override_field_trials_;
webrtc::RtcEventLogNullImpl event_log_; webrtc::RtcEventLogNullImpl event_log_;
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<webrtc::Call> call_;
@ -1137,8 +1144,10 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, Vp8) {
// Create a call. // Create a call.
webrtc::RtcEventLogNullImpl event_log; webrtc::RtcEventLogNullImpl event_log;
std::unique_ptr<webrtc::Call> call( auto task_queue_factory = webrtc::CreateDefaultTaskQueueFactory();
webrtc::Call::Create(webrtc::Call::Config(&event_log))); webrtc::Call::Config call_config(&event_log);
call_config.task_queue_factory = task_queue_factory.get();
const auto call = absl::WrapUnique(webrtc::Call::Create(call_config));
// Create send channel. // Create send channel.
const int send_ssrc = 123; const int send_ssrc = 123;
@ -1205,8 +1214,10 @@ TEST(WebRtcVideoEngineNewVideoCodecFactoryTest, NullDecoder) {
// Create a call. // Create a call.
webrtc::RtcEventLogNullImpl event_log; webrtc::RtcEventLogNullImpl event_log;
std::unique_ptr<webrtc::Call> call( auto task_queue_factory = webrtc::CreateDefaultTaskQueueFactory();
webrtc::Call::Create(webrtc::Call::Config(&event_log))); webrtc::Call::Config call_config(&event_log);
call_config.task_queue_factory = task_queue_factory.get();
const auto call = absl::WrapUnique(webrtc::Call::Create(call_config));
// Create recv channel. // Create recv channel.
const int recv_ssrc = 321; const int recv_ssrc = 321;
@ -1286,7 +1297,8 @@ TEST_F(WebRtcVideoEngineTest, DISABLED_RecreatesEncoderOnContentTypeChange) {
class WebRtcVideoChannelBaseTest : public ::testing::Test { class WebRtcVideoChannelBaseTest : public ::testing::Test {
protected: protected:
WebRtcVideoChannelBaseTest() WebRtcVideoChannelBaseTest()
: video_bitrate_allocator_factory_( : task_queue_factory_(webrtc::CreateDefaultTaskQueueFactory()),
video_bitrate_allocator_factory_(
webrtc::CreateBuiltinVideoBitrateAllocatorFactory()), webrtc::CreateBuiltinVideoBitrateAllocatorFactory()),
engine_(webrtc::CreateBuiltinVideoEncoderFactory(), engine_(webrtc::CreateBuiltinVideoEncoderFactory(),
webrtc::CreateBuiltinVideoDecoderFactory()) {} webrtc::CreateBuiltinVideoDecoderFactory()) {}
@ -1294,7 +1306,9 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test {
virtual void SetUp() { virtual void SetUp() {
// 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_) {
call_.reset(webrtc::Call::Create(webrtc::Call::Config(&event_log_))); webrtc::Call::Config call_config(&event_log_);
call_config.task_queue_factory = task_queue_factory_.get();
call_.reset(webrtc::Call::Create(call_config));
} }
cricket::MediaConfig media_config; cricket::MediaConfig media_config;
// Disabling cpu overuse detection actually disables quality scaling too; it // Disabling cpu overuse detection actually disables quality scaling too; it
@ -1475,6 +1489,7 @@ class WebRtcVideoChannelBaseTest : public ::testing::Test {
} }
webrtc::RtcEventLogNullImpl event_log_; webrtc::RtcEventLogNullImpl event_log_;
std::unique_ptr<webrtc::TaskQueueFactory> task_queue_factory_;
std::unique_ptr<webrtc::Call> call_; std::unique_ptr<webrtc::Call> call_;
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
video_bitrate_allocator_factory_; video_bitrate_allocator_factory_;

View File

@ -11,6 +11,7 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include "absl/memory/memory.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "api/audio_codecs/builtin_audio_decoder_factory.h" #include "api/audio_codecs/builtin_audio_decoder_factory.h"
#include "api/audio_codecs/builtin_audio_encoder_factory.h" #include "api/audio_codecs/builtin_audio_encoder_factory.h"
@ -3457,8 +3458,9 @@ TEST(WebRtcVoiceEngineTest, StartupShutdown) {
webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm); webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm);
engine.Init(); engine.Init();
webrtc::RtcEventLogNullImpl event_log; webrtc::RtcEventLogNullImpl event_log;
std::unique_ptr<webrtc::Call> call( webrtc::Call::Config call_config(&event_log);
webrtc::Call::Create(webrtc::Call::Config(&event_log))); call_config.task_queue_factory = task_queue_factory.get();
auto call = absl::WrapUnique(webrtc::Call::Create(call_config));
cricket::VoiceMediaChannel* channel = engine.CreateMediaChannel( cricket::VoiceMediaChannel* channel = engine.CreateMediaChannel(
call.get(), cricket::MediaConfig(), cricket::AudioOptions(), call.get(), cricket::MediaConfig(), cricket::AudioOptions(),
webrtc::CryptoOptions()); webrtc::CryptoOptions());
@ -3484,8 +3486,9 @@ TEST(WebRtcVoiceEngineTest, StartupShutdownWithExternalADM) {
webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm); webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm);
engine.Init(); engine.Init();
webrtc::RtcEventLogNullImpl event_log; webrtc::RtcEventLogNullImpl event_log;
std::unique_ptr<webrtc::Call> call( webrtc::Call::Config call_config(&event_log);
webrtc::Call::Create(webrtc::Call::Config(&event_log))); call_config.task_queue_factory = task_queue_factory.get();
auto call = absl::WrapUnique(webrtc::Call::Create(call_config));
cricket::VoiceMediaChannel* channel = engine.CreateMediaChannel( cricket::VoiceMediaChannel* channel = engine.CreateMediaChannel(
call.get(), cricket::MediaConfig(), cricket::AudioOptions(), call.get(), cricket::MediaConfig(), cricket::AudioOptions(),
webrtc::CryptoOptions()); webrtc::CryptoOptions());
@ -3557,8 +3560,9 @@ TEST(WebRtcVoiceEngineTest, Has32Channels) {
webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm); webrtc::MockAudioDecoderFactory::CreateUnusedFactory(), nullptr, apm);
engine.Init(); engine.Init();
webrtc::RtcEventLogNullImpl event_log; webrtc::RtcEventLogNullImpl event_log;
std::unique_ptr<webrtc::Call> call( webrtc::Call::Config call_config(&event_log);
webrtc::Call::Create(webrtc::Call::Config(&event_log))); call_config.task_queue_factory = task_queue_factory.get();
auto call = absl::WrapUnique(webrtc::Call::Create(call_config));
cricket::VoiceMediaChannel* channels[32]; cricket::VoiceMediaChannel* channels[32];
size_t num_channels = 0; size_t num_channels = 0;
@ -3599,8 +3603,9 @@ TEST(WebRtcVoiceEngineTest, SetRecvCodecs) {
webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, apm); webrtc::CreateBuiltinAudioDecoderFactory(), nullptr, apm);
engine.Init(); engine.Init();
webrtc::RtcEventLogNullImpl event_log; webrtc::RtcEventLogNullImpl event_log;
std::unique_ptr<webrtc::Call> call( webrtc::Call::Config call_config(&event_log);
webrtc::Call::Create(webrtc::Call::Config(&event_log))); call_config.task_queue_factory = task_queue_factory.get();
auto call = absl::WrapUnique(webrtc::Call::Create(call_config));
cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(), cricket::WebRtcVoiceMediaChannel channel(&engine, cricket::MediaConfig(),
cricket::AudioOptions(), cricket::AudioOptions(),
webrtc::CryptoOptions(), call.get()); webrtc::CryptoOptions(), call.get());

View File

@ -22,6 +22,7 @@
#include "api/peer_connection_interface.h" #include "api/peer_connection_interface.h"
#include "api/peer_connection_proxy.h" #include "api/peer_connection_proxy.h"
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "api/test/fake_media_transport.h" #include "api/test/fake_media_transport.h"
#include "media/base/codec.h" #include "media/base/codec.h"
#include "media/base/fake_media_engine.h" #include "media/base/fake_media_engine.h"
@ -71,6 +72,7 @@ PeerConnectionFactoryDependencies CreatePeerConnectionFactoryDependencies(
deps.network_thread = network_thread; deps.network_thread = network_thread;
deps.worker_thread = worker_thread; deps.worker_thread = worker_thread;
deps.signaling_thread = signaling_thread; deps.signaling_thread = signaling_thread;
deps.task_queue_factory = CreateDefaultTaskQueueFactory();
deps.media_engine = std::move(media_engine); deps.media_engine = std::move(media_engine);
deps.call_factory = std::move(call_factory); deps.call_factory = std::move(call_factory);
deps.media_transport_factory = std::move(media_transport_factory); deps.media_transport_factory = std::move(media_transport_factory);

View File

@ -22,6 +22,7 @@
#include "api/peer_connection_proxy.h" #include "api/peer_connection_proxy.h"
#include "api/rtc_error.h" #include "api/rtc_error.h"
#include "api/scoped_refptr.h" #include "api/scoped_refptr.h"
#include "api/task_queue/default_task_queue_factory.h"
#include "media/base/fake_media_engine.h" #include "media/base/fake_media_engine.h"
#include "p2p/base/mock_async_resolver.h" #include "p2p/base/mock_async_resolver.h"
#include "p2p/base/port_allocator.h" #include "p2p/base/port_allocator.h"
@ -74,6 +75,7 @@ class PeerConnectionFactoryForUsageHistogramTest
dependencies.network_thread = rtc::Thread::Current(); dependencies.network_thread = rtc::Thread::Current();
dependencies.worker_thread = rtc::Thread::Current(); dependencies.worker_thread = rtc::Thread::Current();
dependencies.signaling_thread = rtc::Thread::Current(); dependencies.signaling_thread = rtc::Thread::Current();
dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
dependencies.media_engine = dependencies.media_engine =
absl::make_unique<cricket::FakeMediaEngine>(); absl::make_unique<cricket::FakeMediaEngine>();
dependencies.call_factory = CreateCallFactory(); dependencies.call_factory = CreateCallFactory();

View File

@ -217,6 +217,7 @@ void CallTest::CreateSenderCall() {
void CallTest::CreateSenderCall(const Call::Config& config) { void CallTest::CreateSenderCall(const Call::Config& config) {
auto sender_config = config; auto sender_config = config;
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();
@ -224,7 +225,9 @@ void CallTest::CreateSenderCall(const Call::Config& config) {
} }
void CallTest::CreateReceiverCall(const Call::Config& config) { void CallTest::CreateReceiverCall(const Call::Config& config) {
receiver_call_.reset(Call::Create(config)); auto receiver_config = config;
receiver_config.task_queue_factory = task_queue_factory_.get();
receiver_call_.reset(Call::Create(receiver_config));
} }
void CallTest::DestroyCalls() { void CallTest::DestroyCalls() {

View File

@ -48,6 +48,7 @@ void MultiStreamTester::RunTest() {
webrtc::RtcEventLogNullImpl event_log; webrtc::RtcEventLogNullImpl event_log;
auto task_queue_factory = CreateDefaultTaskQueueFactory(); auto task_queue_factory = CreateDefaultTaskQueueFactory();
Call::Config config(&event_log); Call::Config config(&event_log);
config.task_queue_factory = task_queue_factory.get();
std::unique_ptr<Call> sender_call; std::unique_ptr<Call> sender_call;
std::unique_ptr<Call> receiver_call; std::unique_ptr<Call> receiver_call;
std::unique_ptr<test::DirectTransport> sender_transport; std::unique_ptr<test::DirectTransport> sender_transport;