Files
platform-external-webrtc/modules/congestion_controller/bbr/test/bbr_printer.cc
Sebastian Jansson 52de8b0270 Adds functionality to write logs to memory.
This makes it possible to save log outputs from scenario tests to
either files or memory.

Bug: webrtc:9510
Change-Id: I883bd8240ab712d31d54118adf979041bd83481a
Reviewed-on: https://webrtc-review.googlesource.com/c/116321
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Per Kjellander <perkj@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#26284}
2019-01-16 17:36:31 +00:00

62 lines
1.9 KiB
C++

/*
* 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<int>(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<NetworkControllerInterface> BbrDebugFactory::Create(
NetworkControllerConfig config) {
RTC_CHECK(controller_ == nullptr);
auto controller = BbrNetworkControllerFactory::Create(config);
controller_ = static_cast<bbr::BbrNetworkController*>(controller.get());
printer_->Attach(controller_);
return controller;
}
bbr::BbrNetworkController* BbrDebugFactory::BbrController() {
return controller_;
}
} // namespace webrtc