From 871ac425978b9157c2b55556fb8fcc28f8138cb5 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Fri, 17 May 2019 17:53:44 +0200 Subject: [PATCH] Refactor of GoogCC debug printer. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Simplifying the code to better fit with how it is used. Bug: webrtc:9883 Change-Id: I2bd52f26b829413e516dee4f551cf36574275019 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/136681 Reviewed-by: Björn Terelius Commit-Queue: Sebastian Jansson Cr-Commit-Position: refs/heads/master@{#27994} --- modules/congestion_controller/BUILD.gn | 17 --- modules/congestion_controller/bbr/BUILD.gn | 16 --- .../bbr/test/bbr_printer.cc | 61 ---------- .../bbr/test/bbr_printer.h | 54 --------- .../congestion_controller/goog_cc/BUILD.gn | 2 +- .../goog_cc/test/goog_cc_printer.cc | 112 +++++++++++------- .../goog_cc/test/goog_cc_printer.h | 33 ++++-- .../test/controller_printer.cc | 68 ----------- .../test/controller_printer.h | 44 ------- test/scenario/BUILD.gn | 1 - test/scenario/call_client.cc | 20 +--- test/scenario/call_client.h | 6 +- 12 files changed, 100 insertions(+), 334 deletions(-) delete mode 100644 modules/congestion_controller/bbr/test/bbr_printer.cc delete mode 100644 modules/congestion_controller/bbr/test/bbr_printer.h delete mode 100644 modules/congestion_controller/test/controller_printer.cc delete mode 100644 modules/congestion_controller/test/controller_printer.h diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn index fc5941dc69..abb2584bf6 100644 --- a/modules/congestion_controller/BUILD.gn +++ b/modules/congestion_controller/BUILD.gn @@ -81,23 +81,6 @@ rtc_static_library("transport_feedback") { } if (rtc_include_tests) { - rtc_source_set("test_controller_printer") { - testonly = true - sources = [ - "test/controller_printer.cc", - "test/controller_printer.h", - ] - deps = [ - "../../api/transport:network_control", - "../../api/units:data_rate", - "../../api/units:data_size", - "../../api/units:time_delta", - "../../api/units:timestamp", - "../../rtc_base:checks", - "../../test/logging:log_writer", - "//third_party/abseil-cpp/absl/types:optional", - ] - } rtc_source_set("congestion_controller_unittests") { testonly = true diff --git a/modules/congestion_controller/bbr/BUILD.gn b/modules/congestion_controller/bbr/BUILD.gn index 7e321345f9..dd99b02d65 100644 --- a/modules/congestion_controller/bbr/BUILD.gn +++ b/modules/congestion_controller/bbr/BUILD.gn @@ -116,22 +116,6 @@ rtc_source_set("windowed_filter") { ] } if (rtc_include_tests) { - rtc_source_set("test_bbr_printer") { - testonly = true - sources = [ - "test/bbr_printer.cc", - "test/bbr_printer.h", - ] - deps = [ - ":bbr", - ":bbr_controller", - "..:test_controller_printer", - "../../../api/transport:network_control", - "../../../api/units:timestamp", - "../../../logging:rtc_event_log_api", - "../../../rtc_base:checks", - ] - } rtc_source_set("bbr_unittests") { testonly = true sources = [ diff --git a/modules/congestion_controller/bbr/test/bbr_printer.cc b/modules/congestion_controller/bbr/test/bbr_printer.cc deleted file mode 100644 index 3249493466..0000000000 --- a/modules/congestion_controller/bbr/test/bbr_printer.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2018 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "modules/congestion_controller/bbr/test/bbr_printer.h" - -#include "rtc_base/checks.h" - -namespace webrtc { - -BbrStatePrinter::BbrStatePrinter() = default; -BbrStatePrinter::~BbrStatePrinter() = default; - -void BbrStatePrinter::Attach(bbr::BbrNetworkController* controller) { - controller_ = controller; -} - -bool BbrStatePrinter::Attached() const { - return controller_ != nullptr; -} - -void BbrStatePrinter::PrintHeaders(RtcEventLogOutput* out) { - LogWriteFormat( - out, "bbr_mode bbr_recovery_state round_trip_count gain_cycle_index"); -} - -void BbrStatePrinter::PrintValues(RtcEventLogOutput* out) { - RTC_CHECK(controller_); - bbr::BbrNetworkController::DebugState debug(*controller_); - LogWriteFormat(out, "%i %i %i %i", debug.mode, debug.recovery_state, - static_cast(debug.round_trip_count), - debug.gain_cycle_index); -} - -NetworkControlUpdate BbrStatePrinter::GetState(Timestamp at_time) const { - RTC_CHECK(controller_); - return controller_->CreateRateUpdate(at_time); -} - -BbrDebugFactory::BbrDebugFactory(BbrStatePrinter* printer) - : printer_(printer) {} - -std::unique_ptr BbrDebugFactory::Create( - NetworkControllerConfig config) { - RTC_CHECK(controller_ == nullptr); - auto controller = BbrNetworkControllerFactory::Create(config); - controller_ = static_cast(controller.get()); - printer_->Attach(controller_); - return controller; -} - -bbr::BbrNetworkController* BbrDebugFactory::BbrController() { - return controller_; -} - -} // namespace webrtc diff --git a/modules/congestion_controller/bbr/test/bbr_printer.h b/modules/congestion_controller/bbr/test/bbr_printer.h deleted file mode 100644 index c2b2843185..0000000000 --- a/modules/congestion_controller/bbr/test/bbr_printer.h +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2018 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#ifndef MODULES_CONGESTION_CONTROLLER_BBR_TEST_BBR_PRINTER_H_ -#define MODULES_CONGESTION_CONTROLLER_BBR_TEST_BBR_PRINTER_H_ - -#include -#include - -#include "api/transport/network_control.h" -#include "api/transport/network_types.h" -#include "api/units/timestamp.h" -#include "logging/rtc_event_log/rtc_event_log.h" -#include "modules/congestion_controller/bbr/bbr_factory.h" -#include "modules/congestion_controller/bbr/bbr_network_controller.h" -#include "modules/congestion_controller/test/controller_printer.h" - -namespace webrtc { -class BbrStatePrinter : public DebugStatePrinter { - public: - BbrStatePrinter(); - ~BbrStatePrinter() override; - void Attach(bbr::BbrNetworkController*); - bool Attached() const override; - - void PrintHeaders(RtcEventLogOutput* out) override; - void PrintValues(RtcEventLogOutput* out) override; - - NetworkControlUpdate GetState(Timestamp at_time) const override; - - private: - bbr::BbrNetworkController* controller_ = nullptr; -}; - -class BbrDebugFactory : public BbrNetworkControllerFactory { - public: - explicit BbrDebugFactory(BbrStatePrinter* printer); - std::unique_ptr Create( - NetworkControllerConfig config) override; - bbr::BbrNetworkController* BbrController(); - - private: - BbrStatePrinter* printer_; - bbr::BbrNetworkController* controller_ = nullptr; -}; -} // namespace webrtc - -#endif // MODULES_CONGESTION_CONTROLLER_BBR_TEST_BBR_PRINTER_H_ diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index 2daca286ba..cbfcf77877 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -204,12 +204,12 @@ if (rtc_include_tests) { ":delay_based_bwe", ":estimators", ":goog_cc", - "..:test_controller_printer", "../../../api/transport:goog_cc", "../../../api/transport:network_control", "../../../api/units:timestamp", "../../../logging:rtc_event_log_api", "../../../rtc_base:checks", + "../../../test/logging:log_writer", "../../remote_bitrate_estimator", "//third_party/abseil-cpp/absl/types:optional", ] diff --git a/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc b/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc index 18dcd5bc4b..8184f2a969 100644 --- a/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc +++ b/modules/congestion_controller/goog_cc/test/goog_cc_printer.cc @@ -31,9 +31,16 @@ void WriteTypedValue(RtcEventLogOutput* out, double value) { void WriteTypedValue(RtcEventLogOutput* out, absl::optional value) { LogWriteFormat(out, "%.0f", value ? value->bytes_per_sec() : NAN); } +void WriteTypedValue(RtcEventLogOutput* out, absl::optional value) { + LogWriteFormat(out, "%.0f", value ? value->bytes() : NAN); +} void WriteTypedValue(RtcEventLogOutput* out, absl::optional value) { LogWriteFormat(out, "%.3f", value ? value->seconds() : NAN); } +void WriteTypedValue(RtcEventLogOutput* out, absl::optional value) { + LogWriteFormat(out, "%.3f", value ? value->seconds() : NAN); +} + template class TypedFieldLogger : public FieldLogger { public: @@ -60,13 +67,7 @@ GoogCcStatePrinter::GoogCcStatePrinter() { loggers_.emplace_back(logger); } } -const NetworkStateEstimate& GoogCcStatePrinter::GetEst() { - static NetworkStateEstimate kFallback; - if (controller_->network_estimator_ && - controller_->network_estimator_->GetCurrentEstimate()) - return *controller_->network_estimator_->GetCurrentEstimate(); - return kFallback; -} + std::deque GoogCcStatePrinter::CreateLoggers() { auto stable_estimate = [this] { return DataRate::kbps( @@ -85,6 +86,13 @@ std::deque GoogCcStatePrinter::CreateLoggers() { return controller_->acknowledged_bitrate_estimator_->bitrate(); }; std::deque loggers({ + Log("time", [=] { return target_.at_time; }), + Log("bandwidth", [=] { return target_.network_estimate.bandwidth; }), + Log("rtt", [=] { return target_.network_estimate.round_trip_time; }), + Log("target", [=] { return target_.target_rate; }), + Log("pacing", [=] { return pacing_.data_rate(); }), + Log("padding", [=] { return pacing_.pad_rate(); }), + Log("window", [=] { return congestion_window_; }), Log("rate_control_state", [=] { return rate_control_state(); }), Log("stable_estimate", [=] { return stable_estimate(); }), Log("trendline", [=] { return trend()->prev_trend_; }), @@ -92,62 +100,82 @@ std::deque GoogCcStatePrinter::CreateLoggers() { [=] { return trend()->prev_modified_trend_; }), Log("trendline_offset_threshold", [=] { return trend()->threshold_; }), Log("acknowledged_rate", [=] { return acknowledged_rate(); }), - Log("est_capacity", [=] { return GetEst().link_capacity; }), - Log("est_capacity_dev", [=] { return GetEst().link_capacity_std_dev; }), - Log("est_capacity_min", [=] { return GetEst().link_capacity_min; }), - Log("est_cross_traffic", [=] { return GetEst().cross_traffic_ratio; }), - Log("est_cross_delay", [=] { return GetEst().cross_delay_rate; }), - Log("est_spike_delay", [=] { return GetEst().spike_delay_rate; }), - Log("est_pre_buffer", [=] { return GetEst().pre_link_buffer_delay; }), - Log("est_post_buffer", [=] { return GetEst().post_link_buffer_delay; }), - Log("est_propagation", [=] { return GetEst().propagation_delay; }), + Log("est_capacity", [=] { return est_.link_capacity; }), + Log("est_capacity_dev", [=] { return est_.link_capacity_std_dev; }), + Log("est_capacity_min", [=] { return est_.link_capacity_min; }), + Log("est_cross_traffic", [=] { return est_.cross_traffic_ratio; }), + Log("est_cross_delay", [=] { return est_.cross_delay_rate; }), + Log("est_spike_delay", [=] { return est_.spike_delay_rate; }), + Log("est_pre_buffer", [=] { return est_.pre_link_buffer_delay; }), + Log("est_post_buffer", [=] { return est_.post_link_buffer_delay; }), + Log("est_propagation", [=] { return est_.propagation_delay; }), }); return loggers; } GoogCcStatePrinter::~GoogCcStatePrinter() = default; -void GoogCcStatePrinter::Attach(GoogCcNetworkController* controller) { +void GoogCcStatePrinter::PrintHeaders(RtcEventLogOutput* log) { + int ix = 0; + for (const auto& logger : loggers_) { + if (ix++) + log->Write(" "); + log->Write(logger->name()); + } + log->Write("\n"); + log->Flush(); +} + +void GoogCcStatePrinter::PrintState(RtcEventLogOutput* log, + GoogCcNetworkController* controller, + Timestamp at_time) { controller_ = controller; -} + auto state_update = controller_->GetNetworkState(at_time); + target_ = state_update.target_rate.value(); + pacing_ = state_update.pacer_config.value(); + if (state_update.congestion_window) + congestion_window_ = *state_update.congestion_window; + if (controller_->network_estimator_) { + est_ = controller_->network_estimator_->GetCurrentEstimate().value_or( + NetworkStateEstimate()); + } -bool GoogCcStatePrinter::Attached() const { - return controller_ != nullptr; -} - -void GoogCcStatePrinter::PrintHeaders(RtcEventLogOutput* out) { int ix = 0; for (const auto& logger : loggers_) { if (ix++) - out->Write(" "); - out->Write(logger->name()); + log->Write(" "); + logger->WriteValue(log); } + + log->Write("\n"); + log->Flush(); } -void GoogCcStatePrinter::PrintValues(RtcEventLogOutput* out) { - RTC_CHECK(controller_); - int ix = 0; - for (const auto& logger : loggers_) { - if (ix++) - out->Write(" "); - logger->WriteValue(out); - } -} +GoogCcDebugFactory::GoogCcDebugFactory() + : GoogCcDebugFactory(GoogCcFactoryConfig()) {} -NetworkControlUpdate GoogCcStatePrinter::GetState(Timestamp at_time) const { - RTC_CHECK(controller_); - return controller_->GetNetworkState(at_time); -} - -GoogCcDebugFactory::GoogCcDebugFactory(GoogCcStatePrinter* printer) - : printer_(printer) {} +GoogCcDebugFactory::GoogCcDebugFactory(GoogCcFactoryConfig config) + : GoogCcNetworkControllerFactory(std::move(config)) {} std::unique_ptr GoogCcDebugFactory::Create( NetworkControllerConfig config) { RTC_CHECK(controller_ == nullptr); auto controller = GoogCcNetworkControllerFactory::Create(config); controller_ = static_cast(controller.get()); - printer_->Attach(controller_); return controller; } +void GoogCcDebugFactory::PrintState(const Timestamp at_time) { + if (controller_ && log_writer_) { + printer_.PrintState(log_writer_.get(), controller_, at_time); + } +} + +void GoogCcDebugFactory::AttachWriter( + std::unique_ptr log_writer) { + if (log_writer) { + log_writer_ = std::move(log_writer); + printer_.PrintHeaders(log_writer_.get()); + } +} + } // namespace webrtc diff --git a/modules/congestion_controller/goog_cc/test/goog_cc_printer.h b/modules/congestion_controller/goog_cc/test/goog_cc_printer.h index 179a70abae..86dac47aa9 100644 --- a/modules/congestion_controller/goog_cc/test/goog_cc_printer.h +++ b/modules/congestion_controller/goog_cc/test/goog_cc_printer.h @@ -20,7 +20,7 @@ #include "api/units/timestamp.h" #include "logging/rtc_event_log/rtc_event_log.h" #include "modules/congestion_controller/goog_cc/goog_cc_network_control.h" -#include "modules/congestion_controller/test/controller_printer.h" +#include "test/logging/log_writer.h" namespace webrtc { @@ -31,37 +31,44 @@ class FieldLogger { virtual void WriteValue(RtcEventLogOutput* out) = 0; }; -class GoogCcStatePrinter : public DebugStatePrinter { +class GoogCcStatePrinter { public: GoogCcStatePrinter(); GoogCcStatePrinter(const GoogCcStatePrinter&) = delete; GoogCcStatePrinter& operator=(const GoogCcStatePrinter&) = delete; - ~GoogCcStatePrinter() override; - void Attach(GoogCcNetworkController*); - bool Attached() const override; + ~GoogCcStatePrinter(); - void PrintHeaders(RtcEventLogOutput* out) override; - void PrintValues(RtcEventLogOutput* out) override; - - NetworkControlUpdate GetState(Timestamp at_time) const override; + void PrintHeaders(RtcEventLogOutput* log); + void PrintState(RtcEventLogOutput* log, + GoogCcNetworkController* controller, + Timestamp at_time); private: - const NetworkStateEstimate& GetEst(); std::deque CreateLoggers(); - std::deque> loggers_; + GoogCcNetworkController* controller_ = nullptr; + TargetTransferRate target_; + PacerConfig pacing_; + DataSize congestion_window_ = DataSize::PlusInfinity(); + NetworkStateEstimate est_; }; class GoogCcDebugFactory : public GoogCcNetworkControllerFactory { public: - explicit GoogCcDebugFactory(GoogCcStatePrinter* printer); + GoogCcDebugFactory(); + explicit GoogCcDebugFactory(GoogCcFactoryConfig config); std::unique_ptr Create( NetworkControllerConfig config) override; + void PrintState(const Timestamp at_time); + + void AttachWriter(std::unique_ptr log_writer); + private: - GoogCcStatePrinter* printer_; + GoogCcStatePrinter printer_; GoogCcNetworkController* controller_ = nullptr; + std::unique_ptr log_writer_; }; } // namespace webrtc diff --git a/modules/congestion_controller/test/controller_printer.cc b/modules/congestion_controller/test/controller_printer.cc deleted file mode 100644 index 9b3cb5967b..0000000000 --- a/modules/congestion_controller/test/controller_printer.cc +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2018 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#include "modules/congestion_controller/test/controller_printer.h" - -#include -#include - -#include "absl/types/optional.h" -#include "api/units/data_rate.h" -#include "api/units/data_size.h" -#include "api/units/time_delta.h" - -namespace webrtc { - -ControlStatePrinter::ControlStatePrinter( - std::unique_ptr output, - std::unique_ptr debug_printer) - : output_(std::move(output)), debug_printer_(std::move(debug_printer)) {} - -ControlStatePrinter::~ControlStatePrinter() = default; - -void ControlStatePrinter::PrintHeaders() { - output_->Write("time bandwidth rtt target pacing padding window"); - if (debug_printer_) { - output_->Write(" "); - debug_printer_->PrintHeaders(output_.get()); - } - output_->Write("\n"); - output_->Flush(); -} - -void ControlStatePrinter::PrintState(const Timestamp time, - const NetworkControlUpdate state) { - double timestamp = time.seconds(); - auto estimate = state.target_rate->network_estimate; - double bandwidth = estimate.bandwidth.bps() / 8.0; - double rtt = estimate.round_trip_time.seconds(); - double target_rate = state.target_rate->target_rate.bps() / 8.0; - double pacing_rate = state.pacer_config->data_rate().bps() / 8.0; - double padding_rate = state.pacer_config->pad_rate().bps() / 8.0; - double congestion_window = state.congestion_window - ? state.congestion_window->bytes() - : std::numeric_limits::infinity(); - LogWriteFormat(output_.get(), "%f %f %f %f %f %f %f", timestamp, bandwidth, - rtt, target_rate, pacing_rate, padding_rate, - congestion_window); - - if (debug_printer_) { - output_->Write(" "); - debug_printer_->PrintValues(output_.get()); - } - output_->Write("\n"); - output_->Flush(); -} - -void ControlStatePrinter::PrintState(const Timestamp time) { - if (debug_printer_ && debug_printer_->Attached()) { - PrintState(time, debug_printer_->GetState(time)); - } -} -} // namespace webrtc diff --git a/modules/congestion_controller/test/controller_printer.h b/modules/congestion_controller/test/controller_printer.h deleted file mode 100644 index f88d50ba4b..0000000000 --- a/modules/congestion_controller/test/controller_printer.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2018 The WebRTC project authors. All Rights Reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ -#ifndef MODULES_CONGESTION_CONTROLLER_TEST_CONTROLLER_PRINTER_H_ -#define MODULES_CONGESTION_CONTROLLER_TEST_CONTROLLER_PRINTER_H_ - -#include - -#include "api/transport/network_types.h" -#include "api/units/timestamp.h" -#include "test/logging/log_writer.h" - -namespace webrtc { -class DebugStatePrinter { - public: - virtual bool Attached() const = 0; - virtual void PrintHeaders(RtcEventLogOutput* out) = 0; - virtual void PrintValues(RtcEventLogOutput* out) = 0; - virtual NetworkControlUpdate GetState(Timestamp at_time) const = 0; - virtual ~DebugStatePrinter() = default; -}; - -class ControlStatePrinter { - public: - ControlStatePrinter(std::unique_ptr output, - std::unique_ptr debug_printer); - ~ControlStatePrinter(); - void PrintHeaders(); - void PrintState(const Timestamp time, const NetworkControlUpdate state); - void PrintState(const Timestamp time); - - private: - std::unique_ptr output_; - std::unique_ptr debug_printer_; -}; -} // namespace webrtc - -#endif // MODULES_CONGESTION_CONTROLLER_TEST_CONTROLLER_PRINTER_H_ diff --git a/test/scenario/BUILD.gn b/test/scenario/BUILD.gn index e00683c281..16f841fb6a 100644 --- a/test/scenario/BUILD.gn +++ b/test/scenario/BUILD.gn @@ -114,7 +114,6 @@ if (rtc_include_tests) { "../../modules/audio_device:mock_audio_device", "../../modules/audio_mixer:audio_mixer_impl", "../../modules/audio_processing", - "../../modules/congestion_controller:test_controller_printer", "../../modules/congestion_controller/goog_cc:test_goog_cc_printer", "../../modules/rtp_rtcp", "../../modules/rtp_rtcp:mock_rtp_rtcp", diff --git a/test/scenario/call_client.cc b/test/scenario/call_client.cc index 7258bd7d33..bc93a490f0 100644 --- a/test/scenario/call_client.cc +++ b/test/scenario/call_client.cc @@ -13,7 +13,6 @@ #include "absl/memory/memory.h" #include "modules/audio_mixer/audio_mixer_impl.h" -#include "modules/congestion_controller/goog_cc/test/goog_cc_printer.h" namespace webrtc { namespace test { @@ -96,18 +95,11 @@ LoggingNetworkControllerFactory::LoggingNetworkControllerFactory( << "Can't log controller state for injected network controllers"; } else { if (log_writer_factory) { - auto goog_printer = absl::make_unique(); - owned_cc_factory_.reset(new GoogCcDebugFactory(goog_printer.get())); - cc_factory_ = owned_cc_factory_.get(); - cc_printer_.reset( - new ControlStatePrinter(log_writer_factory->Create(".cc_state.txt"), - std::move(goog_printer))); - cc_printer_->PrintHeaders(); - } else { - owned_cc_factory_.reset( - new GoogCcNetworkControllerFactory(GoogCcFactoryConfig())); - cc_factory_ = owned_cc_factory_.get(); + goog_cc_factory_.AttachWriter( + log_writer_factory->Create(".cc_state.txt")); + print_cc_state_ = true; } + cc_factory_ = &goog_cc_factory_; } } @@ -116,8 +108,8 @@ LoggingNetworkControllerFactory::~LoggingNetworkControllerFactory() { void LoggingNetworkControllerFactory::LogCongestionControllerStats( Timestamp at_time) { - if (cc_printer_) - cc_printer_->PrintState(at_time); + if (print_cc_state_) + goog_cc_factory_.PrintState(at_time); } std::unique_ptr diff --git a/test/scenario/call_client.h b/test/scenario/call_client.h index 13f09b8061..a28e425fa8 100644 --- a/test/scenario/call_client.h +++ b/test/scenario/call_client.h @@ -19,7 +19,7 @@ #include "call/call.h" #include "logging/rtc_event_log/rtc_event_log.h" #include "modules/audio_device/include/test_audio_device.h" -#include "modules/congestion_controller/test/controller_printer.h" +#include "modules/congestion_controller/goog_cc/test/goog_cc_printer.h" #include "modules/rtp_rtcp/include/rtp_header_parser.h" #include "rtc_base/constructor_magic.h" #include "rtc_base/task_queue_for_test.h" @@ -47,9 +47,9 @@ class LoggingNetworkControllerFactory void LogCongestionControllerStats(Timestamp at_time); private: - std::unique_ptr owned_cc_factory_; + GoogCcDebugFactory goog_cc_factory_; NetworkControllerFactoryInterface* cc_factory_ = nullptr; - std::unique_ptr cc_printer_; + bool print_cc_state_ = false; }; struct CallClientFakeAudio {