diff --git a/call/BUILD.gn b/call/BUILD.gn index bcd30787b9..5dc9670fae 100644 --- a/call/BUILD.gn +++ b/call/BUILD.gn @@ -423,10 +423,13 @@ if (rtc_include_tests) { ":video_stream_api", "../api:simulated_network_api", "../api/audio_codecs:builtin_audio_encoder_factory", + "../api/task_queue", + "../api/task_queue:default_task_queue_factory", "../api/video:builtin_video_bitrate_allocator_factory", "../api/video:video_bitrate_allocation", "../api/video_codecs:video_codecs_api", "../logging:rtc_event_log_api", + "../logging:rtc_event_log_impl_base", "../logging:rtc_event_log_impl_output", "../modules/audio_coding", "../modules/audio_device", diff --git a/call/rampup_tests.cc b/call/rampup_tests.cc index 55d6a9b449..85e8d9566a 100644 --- a/call/rampup_tests.cc +++ b/call/rampup_tests.cc @@ -10,9 +10,14 @@ #include "call/rampup_tests.h" +#include + #include "absl/memory/memory.h" +#include "api/task_queue/default_task_queue_factory.h" +#include "api/task_queue/task_queue_factory.h" #include "call/fake_network_pipe.h" #include "logging/rtc_event_log/output/rtc_event_log_output_file.h" +#include "logging/rtc_event_log/rtc_event_log_factory.h" #include "rtc_base/checks.h" #include "rtc_base/flags.h" #include "rtc_base/logging.h" @@ -575,11 +580,15 @@ void RampUpDownUpTester::EvolveTestState(int bitrate_bps, bool suspended) { class RampUpTest : public test::CallTest { public: - RampUpTest() { + RampUpTest() + : task_queue_factory_(CreateDefaultTaskQueueFactory()), + rtc_event_log_factory_(task_queue_factory_.get()) { std::string dump_name(FLAG_ramp_dump_name); if (!dump_name.empty()) { - send_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); - recv_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); + send_event_log_ = rtc_event_log_factory_.CreateRtcEventLog( + RtcEventLog::EncodingType::Legacy); + recv_event_log_ = rtc_event_log_factory_.CreateRtcEventLog( + RtcEventLog::EncodingType::Legacy); bool event_log_started = send_event_log_->StartLogging( absl::make_unique( @@ -592,6 +601,10 @@ class RampUpTest : public test::CallTest { RTC_DCHECK(event_log_started); } } + + private: + const std::unique_ptr task_queue_factory_; + RtcEventLogFactory rtc_event_log_factory_; }; static const uint32_t kStartBitrateBps = 60000; diff --git a/logging/BUILD.gn b/logging/BUILD.gn index 81f24b5f20..e1d5289cb0 100644 --- a/logging/BUILD.gn +++ b/logging/BUILD.gn @@ -385,6 +385,7 @@ if (rtc_enable_protobuf) { "../api:array_view", "../api:libjingle_peerconnection_api", "../api:rtp_headers", + "../api/task_queue:default_task_queue_factory", "../call", "../call:call_interfaces", "../modules/audio_coding:audio_network_adaptor", diff --git a/logging/rtc_event_log/rtc_event_log.h b/logging/rtc_event_log/rtc_event_log.h index edfeef99ba..08b5475610 100644 --- a/logging/rtc_event_log/rtc_event_log.h +++ b/logging/rtc_event_log/rtc_event_log.h @@ -35,8 +35,6 @@ class RtcEventLog { virtual ~RtcEventLog() {} // Factory method to create an RtcEventLog object. - static std::unique_ptr Create(EncodingType encoding_type); - static std::unique_ptr Create( EncodingType encoding_type, TaskQueueFactory* task_queue_factory); diff --git a/logging/rtc_event_log/rtc_event_log_factory.cc b/logging/rtc_event_log/rtc_event_log_factory.cc index a1169732d7..b38b7bc52b 100644 --- a/logging/rtc_event_log/rtc_event_log_factory.cc +++ b/logging/rtc_event_log/rtc_event_log_factory.cc @@ -12,17 +12,25 @@ #include +#include "absl/memory/memory.h" +#include "api/task_queue/global_task_queue_factory.h" #include "logging/rtc_event_log/rtc_event_log.h" +#include "rtc_base/checks.h" namespace webrtc { +RtcEventLogFactory::RtcEventLogFactory(TaskQueueFactory* task_queue_factory) + : task_queue_factory_(task_queue_factory) { + RTC_DCHECK(task_queue_factory_); +} + std::unique_ptr RtcEventLogFactory::CreateRtcEventLog( RtcEventLog::EncodingType encoding_type) { - return RtcEventLog::Create(encoding_type); + return RtcEventLog::Create(encoding_type, task_queue_factory_); } std::unique_ptr CreateRtcEventLogFactory() { - return std::unique_ptr(new RtcEventLogFactory()); + return absl::make_unique(&GlobalTaskQueueFactory()); } } // namespace webrtc diff --git a/logging/rtc_event_log/rtc_event_log_factory.h b/logging/rtc_event_log/rtc_event_log_factory.h index 1480551faa..01e3994099 100644 --- a/logging/rtc_event_log/rtc_event_log_factory.h +++ b/logging/rtc_event_log/rtc_event_log_factory.h @@ -13,6 +13,7 @@ #include +#include "api/task_queue/task_queue_factory.h" #include "logging/rtc_event_log/rtc_event_log.h" #include "logging/rtc_event_log/rtc_event_log_factory_interface.h" @@ -20,12 +21,17 @@ namespace webrtc { class RtcEventLogFactory : public RtcEventLogFactoryInterface { public: + explicit RtcEventLogFactory(TaskQueueFactory* task_queue_factory); ~RtcEventLogFactory() override {} std::unique_ptr CreateRtcEventLog( RtcEventLog::EncodingType encoding_type) override; + + private: + TaskQueueFactory* const task_queue_factory_; }; +// TODO(bugs.webrtc.org/10284): Stop using the RtcEventLogFactory factory. std::unique_ptr CreateRtcEventLogFactory(); } // namespace webrtc diff --git a/logging/rtc_event_log/rtc_event_log_impl.cc b/logging/rtc_event_log/rtc_event_log_impl.cc index f62f690cd6..51fa74a9ec 100644 --- a/logging/rtc_event_log/rtc_event_log_impl.cc +++ b/logging/rtc_event_log/rtc_event_log_impl.cc @@ -20,7 +20,6 @@ #include "absl/memory/memory.h" #include "absl/types/optional.h" #include "api/rtc_event_log_output.h" -#include "api/task_queue/global_task_queue_factory.h" #include "api/task_queue/queued_task.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder_legacy.h" #include "logging/rtc_event_log/encoder/rtc_event_log_encoder_new_format.h" @@ -371,10 +370,6 @@ void RtcEventLogImpl::WriteToOutput(const std::string& output_string) { #endif // ENABLE_RTC_EVENT_LOG // RtcEventLog member functions. -std::unique_ptr RtcEventLog::Create(EncodingType encoding_type) { - return RtcEventLog::Create(encoding_type, &GlobalTaskQueueFactory()); -} - std::unique_ptr RtcEventLog::Create( RtcEventLog::EncodingType encoding_type, TaskQueueFactory* task_queue_factory) { diff --git a/logging/rtc_event_log/rtc_event_log_unittest.cc b/logging/rtc_event_log/rtc_event_log_unittest.cc index 05d519b1ed..2c57220440 100644 --- a/logging/rtc_event_log/rtc_event_log_unittest.cc +++ b/logging/rtc_event_log/rtc_event_log_unittest.cc @@ -18,6 +18,7 @@ #include #include "absl/memory/memory.h" +#include "api/task_queue/default_task_queue_factory.h" #include "logging/rtc_event_log/events/rtc_event_audio_network_adaptation.h" #include "logging/rtc_event_log/events/rtc_event_audio_playout.h" #include "logging/rtc_event_log/events/rtc_event_audio_receive_stream_config.h" @@ -40,6 +41,7 @@ #include "logging/rtc_event_log/events/rtc_event_video_send_stream_config.h" #include "logging/rtc_event_log/output/rtc_event_log_output_file.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_parser.h" #include "logging/rtc_event_log/rtc_event_log_unittest_helper.h" #include "logging/rtc_event_log/rtc_stream_config.h" @@ -305,8 +307,11 @@ void RtcEventLogSession::WriteLog(EventCounts count, // TODO(terelius): Allow test to run with either a real or a fake clock_. // Maybe always use the ScopedFakeClock, but conditionally SleepMs()? + auto task_queue_factory = CreateDefaultTaskQueueFactory(); + RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get()); // The log file will be flushed to disk when the event_log goes out of scope. - std::unique_ptr event_log(RtcEventLog::Create(encoding_type_)); + std::unique_ptr event_log = + rtc_event_log_factory.CreateRtcEventLog(encoding_type_); // We can't send or receive packets without configured streams. RTC_CHECK_GE(count.video_recv_streams, 1); @@ -822,9 +827,12 @@ TEST_P(RtcEventLogCircularBufferTest, KeepsMostRecentEvents) { absl::make_unique(); fake_clock->SetTimeMicros(kStartTime); + auto task_queue_factory = CreateDefaultTaskQueueFactory(); + RtcEventLogFactory rtc_event_log_factory(task_queue_factory.get()); // When log_dumper goes out of scope, it causes the log file to be flushed // to disk. - std::unique_ptr log_dumper(RtcEventLog::Create(encoding_type_)); + std::unique_ptr log_dumper = + rtc_event_log_factory.CreateRtcEventLog(encoding_type_); for (size_t i = 0; i < kNumEvents; i++) { // The purpose of the test is to verify that the log can handle diff --git a/video/BUILD.gn b/video/BUILD.gn index ddcbaab266..fffd58261c 100644 --- a/video/BUILD.gn +++ b/video/BUILD.gn @@ -256,6 +256,7 @@ if (rtc_include_tests) { "../call:simulated_network", "../common_video", "../logging:rtc_event_log_api", + "../logging:rtc_event_log_impl_base", "../logging:rtc_event_log_impl_output", "../media:rtc_audio_video", "../media:rtc_encoder_simulcast_proxy", diff --git a/video/video_quality_test.cc b/video/video_quality_test.cc index 5aead68e18..5c1a903c23 100644 --- a/video/video_quality_test.cc +++ b/video/video_quality_test.cc @@ -325,6 +325,7 @@ VideoQualityTest::VideoQualityTest( std::unique_ptr injection_components) : clock_(Clock::GetRealTimeClock()), task_queue_factory_(CreateDefaultTaskQueueFactory()), + rtc_event_log_factory_(task_queue_factory_.get()), video_decoder_factory_([this](const SdpVideoFormat& format) { return this->CreateVideoDecoder(format); }), @@ -1177,8 +1178,10 @@ void VideoQualityTest::RunWithAnalyzer(const Params& params) { } if (!params.logging.rtc_event_log_name.empty()) { - send_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); - recv_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); + send_event_log_ = rtc_event_log_factory_.CreateRtcEventLog( + RtcEventLog::EncodingType::Legacy); + recv_event_log_ = rtc_event_log_factory_.CreateRtcEventLog( + RtcEventLog::EncodingType::Legacy); std::unique_ptr send_output( absl::make_unique( params.logging.rtc_event_log_name + "_send", @@ -1397,8 +1400,10 @@ void VideoQualityTest::RunWithRenderers(const Params& params) { std::vector> loopback_renderers; if (!params.logging.rtc_event_log_name.empty()) { - send_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); - recv_event_log_ = RtcEventLog::Create(RtcEventLog::EncodingType::Legacy); + send_event_log_ = rtc_event_log_factory_.CreateRtcEventLog( + RtcEventLog::EncodingType::Legacy); + recv_event_log_ = rtc_event_log_factory_.CreateRtcEventLog( + RtcEventLog::EncodingType::Legacy); std::unique_ptr send_output( absl::make_unique( params.logging.rtc_event_log_name + "_send", diff --git a/video/video_quality_test.h b/video/video_quality_test.h index b0f9036cd4..bd871b7573 100644 --- a/video/video_quality_test.h +++ b/video/video_quality_test.h @@ -20,6 +20,7 @@ #include "api/test/video_quality_test_fixture.h" #include "api/video/video_bitrate_allocator_factory.h" #include "call/fake_network_pipe.h" +#include "logging/rtc_event_log/rtc_event_log_factory.h" #include "media/engine/internal_decoder_factory.h" #include "media/engine/internal_encoder_factory.h" #include "test/call_test.h" @@ -102,6 +103,7 @@ class VideoQualityTest : thumbnail_capturers_; Clock* const clock_; const std::unique_ptr task_queue_factory_; + RtcEventLogFactory rtc_event_log_factory_; test::FunctionVideoDecoderFactory video_decoder_factory_; InternalDecoderFactory internal_decoder_factory_;