mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-17 23:57:59 +01:00

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}
68 lines
2.4 KiB
C++
68 lines
2.4 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/test/controller_printer.h"
|
|
|
|
#include <limits>
|
|
#include <utility>
|
|
|
|
#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<RtcEventLogOutput> output,
|
|
std::unique_ptr<DebugStatePrinter> 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<double>();
|
|
auto estimate = state.target_rate->network_estimate;
|
|
double bandwidth = estimate.bandwidth.bps() / 8.0;
|
|
double rtt = estimate.round_trip_time.seconds<double>();
|
|
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<double>()
|
|
: std::numeric_limits<double>::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
|