Add RtcEventLogFactory factory with explicit TaskQueueFactory

remove RtcEventLog factory function that relies on GlobalTaskQueueFactory,
move that default behaviour up to RtcEventLogFactory level.

Bug: webrtc:10284
Change-Id: I512d8a13e6a2f320000dd08e6355c0a7e9de8561
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/132542
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27573}
This commit is contained in:
Danil Chapovalov
2019-04-11 15:18:18 +02:00
committed by Commit Bot
parent 11d0d7b945
commit 304ea5f7b0
11 changed files with 58 additions and 18 deletions

View File

@ -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",

View File

@ -10,9 +10,14 @@
#include "call/rampup_tests.h"
#include <memory>
#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<RtcEventLogOutputFile>(
@ -592,6 +601,10 @@ class RampUpTest : public test::CallTest {
RTC_DCHECK(event_log_started);
}
}
private:
const std::unique_ptr<TaskQueueFactory> task_queue_factory_;
RtcEventLogFactory rtc_event_log_factory_;
};
static const uint32_t kStartBitrateBps = 60000;

View File

@ -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",

View File

@ -35,8 +35,6 @@ class RtcEventLog {
virtual ~RtcEventLog() {}
// Factory method to create an RtcEventLog object.
static std::unique_ptr<RtcEventLog> Create(EncodingType encoding_type);
static std::unique_ptr<RtcEventLog> Create(
EncodingType encoding_type,
TaskQueueFactory* task_queue_factory);

View File

@ -12,17 +12,25 @@
#include <utility>
#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<RtcEventLog> RtcEventLogFactory::CreateRtcEventLog(
RtcEventLog::EncodingType encoding_type) {
return RtcEventLog::Create(encoding_type);
return RtcEventLog::Create(encoding_type, task_queue_factory_);
}
std::unique_ptr<RtcEventLogFactoryInterface> CreateRtcEventLogFactory() {
return std::unique_ptr<RtcEventLogFactoryInterface>(new RtcEventLogFactory());
return absl::make_unique<RtcEventLogFactory>(&GlobalTaskQueueFactory());
}
} // namespace webrtc

View File

@ -13,6 +13,7 @@
#include <memory>
#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<RtcEventLog> 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<RtcEventLogFactoryInterface> CreateRtcEventLogFactory();
} // namespace webrtc

View File

@ -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> RtcEventLog::Create(EncodingType encoding_type) {
return RtcEventLog::Create(encoding_type, &GlobalTaskQueueFactory());
}
std::unique_ptr<RtcEventLog> RtcEventLog::Create(
RtcEventLog::EncodingType encoding_type,
TaskQueueFactory* task_queue_factory) {

View File

@ -18,6 +18,7 @@
#include <vector>
#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<RtcEventLog> event_log(RtcEventLog::Create(encoding_type_));
std::unique_ptr<RtcEventLog> 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<rtc::ScopedFakeClock>();
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<RtcEventLog> log_dumper(RtcEventLog::Create(encoding_type_));
std::unique_ptr<RtcEventLog> 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

View File

@ -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",

View File

@ -325,6 +325,7 @@ VideoQualityTest::VideoQualityTest(
std::unique_ptr<InjectionComponents> 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<RtcEventLogOutputFile> send_output(
absl::make_unique<RtcEventLogOutputFile>(
params.logging.rtc_event_log_name + "_send",
@ -1397,8 +1400,10 @@ void VideoQualityTest::RunWithRenderers(const Params& params) {
std::vector<std::unique_ptr<test::VideoRenderer>> 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<RtcEventLogOutputFile> send_output(
absl::make_unique<RtcEventLogOutputFile>(
params.logging.rtc_event_log_name + "_send",

View File

@ -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<TaskQueueFactory> task_queue_factory_;
RtcEventLogFactory rtc_event_log_factory_;
test::FunctionVideoDecoderFactory video_decoder_factory_;
InternalDecoderFactory internal_decoder_factory_;