In PeerConnection unittests set TaskQueueFactory explicitly
instead of using factories for MediaEngine and RtcEventLog that rely on GlobalTaskQueueFactory
Bug: webrtc:10284
Change-Id: Ie1135f70f4ae4d047c4d6bf2db61489a663385aa
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141875
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Seth Hampson <shampson@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28328}
diff --git a/pc/peer_connection_interface_unittest.cc b/pc/peer_connection_interface_unittest.cc
index 2ea3e86..1ea4b7f 100644
--- a/pc/peer_connection_interface_unittest.cc
+++ b/pc/peer_connection_interface_unittest.cc
@@ -33,24 +33,25 @@
#include "api/media_types.h"
#include "api/peer_connection_interface.h"
#include "api/rtc_error.h"
+#include "api/rtc_event_log/rtc_event_log.h"
+#include "api/rtc_event_log/rtc_event_log_factory.h"
#include "api/rtc_event_log_output.h"
#include "api/rtc_event_log_output_file.h"
#include "api/rtp_receiver_interface.h"
#include "api/rtp_sender_interface.h"
#include "api/rtp_transceiver_interface.h"
#include "api/scoped_refptr.h"
+#include "api/task_queue/default_task_queue_factory.h"
#include "api/video_codecs/builtin_video_decoder_factory.h"
#include "api/video_codecs/builtin_video_encoder_factory.h"
#include "api/video_codecs/video_decoder_factory.h"
#include "api/video_codecs/video_encoder_factory.h"
-#include "logging/rtc_event_log/rtc_event_log.h"
-#include "logging/rtc_event_log/rtc_event_log_factory.h"
-#include "logging/rtc_event_log/rtc_event_log_factory_interface.h"
#include "media/base/codec.h"
#include "media/base/media_config.h"
#include "media/base/media_engine.h"
#include "media/base/stream_params.h"
#include "media/engine/webrtc_media_engine.h"
+#include "media/engine/webrtc_media_engine_defaults.h"
#include "media/sctp/sctp_transport_internal.h"
#include "modules/audio_device/include/audio_device.h"
#include "modules/audio_processing/include/audio_processing.h"
@@ -640,27 +641,22 @@
public:
static rtc::scoped_refptr<PeerConnectionFactoryForTest>
CreatePeerConnectionFactoryForTest() {
- auto audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();
- auto audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory();
- auto video_encoder_factory = webrtc::CreateBuiltinVideoEncoderFactory();
- auto video_decoder_factory = webrtc::CreateBuiltinVideoDecoderFactory();
-
PeerConnectionFactoryDependencies dependencies;
dependencies.worker_thread = rtc::Thread::Current();
dependencies.network_thread = rtc::Thread::Current();
dependencies.signaling_thread = rtc::Thread::Current();
-
+ dependencies.task_queue_factory = CreateDefaultTaskQueueFactory();
+ cricket::MediaEngineDependencies media_deps;
+ media_deps.task_queue_factory = dependencies.task_queue_factory.get();
// Use fake audio device module since we're only testing the interface
// level, and using a real one could make tests flaky when run in parallel.
- dependencies.media_engine = std::unique_ptr<cricket::MediaEngineInterface>(
- cricket::WebRtcMediaEngineFactory::Create(
- FakeAudioCaptureModule::Create(), audio_encoder_factory,
- audio_decoder_factory, std::move(video_encoder_factory),
- std::move(video_decoder_factory), nullptr,
- webrtc::AudioProcessingBuilder().Create()));
-
+ media_deps.adm = FakeAudioCaptureModule::Create();
+ SetMediaEngineDefaults(&media_deps);
+ dependencies.media_engine =
+ cricket::CreateMediaEngine(std::move(media_deps));
dependencies.call_factory = webrtc::CreateCallFactory();
- dependencies.event_log_factory = webrtc::CreateRtcEventLogFactory();
+ dependencies.event_log_factory = absl::make_unique<RtcEventLogFactory>(
+ dependencies.task_queue_factory.get());
return new rtc::RefCountedObject<PeerConnectionFactoryForTest>(
std::move(dependencies));