diff --git a/modules/congestion_controller/BUILD.gn b/modules/congestion_controller/BUILD.gn index 05494707ea..51699f6f49 100644 --- a/modules/congestion_controller/BUILD.gn +++ b/modules/congestion_controller/BUILD.gn @@ -8,17 +8,8 @@ import("../../webrtc.gni") -config("bwe_test_logging") { - if (rtc_enable_bwe_test_logging) { - defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ] - } else { - defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ] - } -} - rtc_library("congestion_controller") { visibility = [ "*" ] - configs += [ ":bwe_test_logging" ] sources = [ "include/receive_side_congestion_controller.h", "receive_side_congestion_controller.cc", diff --git a/modules/congestion_controller/goog_cc/BUILD.gn b/modules/congestion_controller/goog_cc/BUILD.gn index 75126c8a90..a1527297d3 100644 --- a/modules/congestion_controller/goog_cc/BUILD.gn +++ b/modules/congestion_controller/goog_cc/BUILD.gn @@ -8,16 +8,7 @@ import("../../../webrtc.gni") -config("bwe_test_logging") { - if (rtc_enable_bwe_test_logging) { - defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ] - } else { - defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ] - } -} - rtc_library("goog_cc") { - configs += [ ":bwe_test_logging" ] sources = [ "goog_cc_network_control.cc", "goog_cc_network_control.h", @@ -103,7 +94,6 @@ rtc_library("alr_detector") { ] } rtc_library("estimators") { - configs += [ ":bwe_test_logging" ] sources = [ "acknowledged_bitrate_estimator.cc", "acknowledged_bitrate_estimator.h", @@ -166,7 +156,6 @@ rtc_library("loss_based_bwe_v2") { } rtc_library("loss_based_bwe_v1") { - configs += [ ":bwe_test_logging" ] sources = [ "loss_based_bandwidth_estimation.cc", "loss_based_bandwidth_estimation.h", @@ -185,7 +174,6 @@ rtc_library("loss_based_bwe_v1") { } rtc_library("send_side_bwe") { - configs += [ ":bwe_test_logging" ] sources = [ "send_side_bandwidth_estimation.cc", "send_side_bandwidth_estimation.h", @@ -212,7 +200,6 @@ rtc_library("send_side_bwe") { } rtc_library("delay_based_bwe") { - configs += [ ":bwe_test_logging" ] sources = [ "delay_based_bwe.cc", "delay_based_bwe.h", diff --git a/modules/congestion_controller/goog_cc/bitrate_estimator.cc b/modules/congestion_controller/goog_cc/bitrate_estimator.cc index e4f12ae06f..3ec978009f 100644 --- a/modules/congestion_controller/goog_cc/bitrate_estimator.cc +++ b/modules/congestion_controller/goog_cc/bitrate_estimator.cc @@ -20,7 +20,6 @@ #include "api/units/data_size.h" #include "api/units/time_delta.h" #include "api/units/timestamp.h" -#include "modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/field_trial_parser.h" @@ -114,8 +113,6 @@ void BitrateEstimator::Update(Timestamp at_time, DataSize amount, bool in_alr) { std::max(bitrate_estimate_kbps_, estimate_floor_.Get().kbps()); bitrate_estimate_var_ = sample_var * pred_bitrate_estimate_var / (sample_var + pred_bitrate_estimate_var); - BWE_TEST_LOGGING_PLOT(1, "acknowledged_bitrate", at_time.ms(), - bitrate_estimate_kbps_ * 1000); } float BitrateEstimator::UpdateWindow(int64_t now_ms, diff --git a/modules/congestion_controller/goog_cc/delay_based_bwe.cc b/modules/congestion_controller/goog_cc/delay_based_bwe.cc index ac6a36d08f..187ef6946b 100644 --- a/modules/congestion_controller/goog_cc/delay_based_bwe.cc +++ b/modules/congestion_controller/goog_cc/delay_based_bwe.cc @@ -31,7 +31,6 @@ #include "modules/congestion_controller/goog_cc/inter_arrival_delta.h" #include "modules/congestion_controller/goog_cc/trendline_estimator.h" #include "modules/remote_bitrate_estimator/include/bwe_defines.h" -#include "modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/struct_parameters_parser.h" #include "rtc_base/logging.h" @@ -253,8 +252,6 @@ DelayBasedBwe::Result DelayBasedBwe::MaybeUpdateEstimate( detector_state != prev_state_) { DataRate bitrate = result.updated ? result.target_bitrate : prev_bitrate_; - BWE_TEST_LOGGING_PLOT(1, "target_bitrate_bps", at_time.ms(), bitrate.bps()); - if (event_log_) { event_log_->Log(std::make_unique( bitrate.bps(), detector_state)); diff --git a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc index 5de8a40a26..182e79358e 100644 --- a/modules/congestion_controller/goog_cc/goog_cc_network_control.cc +++ b/modules/congestion_controller/goog_cc/goog_cc_network_control.cc @@ -40,7 +40,6 @@ #include "modules/congestion_controller/goog_cc/probe_controller.h" #include "modules/congestion_controller/goog_cc/send_side_bandwidth_estimation.h" #include "modules/remote_bitrate_estimator/include/bwe_defines.h" -#include "modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/field_trial_parser.h" #include "rtc_base/experiments/rate_control_settings.h" @@ -259,8 +258,6 @@ NetworkControlUpdate GoogCcNetworkController::OnRemoteBitrateReport( } bandwidth_estimation_->UpdateReceiverEstimate(msg.receive_time, msg.bandwidth); - BWE_TEST_LOGGING_PLOT(1, "REMB_kbps", msg.receive_time.ms(), - msg.bandwidth.bps() / 1000); return NetworkControlUpdate(); } @@ -640,12 +637,6 @@ void GoogCcNetworkController::MaybeTriggerOnNetworkChanged( LossBasedState loss_based_state = bandwidth_estimation_->loss_based_state(); DataRate pushback_target_rate = loss_based_target_rate; - BWE_TEST_LOGGING_PLOT(1, "fraction_loss_%", at_time.ms(), - (fraction_loss * 100) / 256); - BWE_TEST_LOGGING_PLOT(1, "rtt_ms", at_time.ms(), round_trip_time.ms()); - BWE_TEST_LOGGING_PLOT(1, "Target_bitrate_kbps", at_time.ms(), - loss_based_target_rate.kbps()); - double cwnd_reduce_ratio = 0.0; if (congestion_window_pushback_controller_) { int64_t pushback_rate = diff --git a/modules/congestion_controller/goog_cc/trendline_estimator.cc b/modules/congestion_controller/goog_cc/trendline_estimator.cc index 958ce53b5e..309afaa88b 100644 --- a/modules/congestion_controller/goog_cc/trendline_estimator.cc +++ b/modules/congestion_controller/goog_cc/trendline_estimator.cc @@ -26,7 +26,6 @@ #include "api/field_trials_view.h" #include "api/network_state_predictor.h" #include "api/transport/bandwidth_usage.h" -#include "modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "rtc_base/checks.h" #include "rtc_base/experiments/struct_parameters_parser.h" #include "rtc_base/logging.h" @@ -211,12 +210,8 @@ void TrendlineEstimator::UpdateTrendline(double recv_delta_ms, // Exponential backoff filter. accumulated_delay_ += delta_ms; - BWE_TEST_LOGGING_PLOT(1, "accumulated_delay_ms", arrival_time_ms, - accumulated_delay_); smoothed_delay_ = smoothing_coef_ * smoothed_delay_ + (1 - smoothing_coef_) * accumulated_delay_; - BWE_TEST_LOGGING_PLOT(1, "smoothed_delay_ms", arrival_time_ms, - smoothed_delay_); // Maintain packet window delay_hist_.emplace_back( @@ -251,7 +246,6 @@ void TrendlineEstimator::UpdateTrendline(double recv_delta_ms, } } } - BWE_TEST_LOGGING_PLOT(1, "trendline_slope", arrival_time_ms, trend); Detect(trend, send_delta_ms, arrival_time_ms); } @@ -284,8 +278,6 @@ void TrendlineEstimator::Detect(double trend, double ts_delta, int64_t now_ms) { const double modified_trend = std::min(num_of_deltas_, kMinNumDeltas) * trend * threshold_gain_; prev_modified_trend_ = modified_trend; - BWE_TEST_LOGGING_PLOT(1, "T", now_ms, modified_trend); - BWE_TEST_LOGGING_PLOT(1, "threshold", now_ms, threshold_); if (modified_trend > threshold_) { if (time_over_using_ == -1) { // Initialize the timer. Assume that we've been diff --git a/modules/congestion_controller/rtp/BUILD.gn b/modules/congestion_controller/rtp/BUILD.gn index e900322255..8435ddb24a 100644 --- a/modules/congestion_controller/rtp/BUILD.gn +++ b/modules/congestion_controller/rtp/BUILD.gn @@ -8,14 +8,6 @@ import("../../../webrtc.gni") -config("bwe_test_logging") { - if (rtc_enable_bwe_test_logging) { - defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ] - } else { - defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ] - } -} - rtc_library("control_handler") { visibility = [ "*" ] sources = [ diff --git a/modules/remote_bitrate_estimator/BUILD.gn b/modules/remote_bitrate_estimator/BUILD.gn index 24e8a8473b..9f39f3b522 100644 --- a/modules/remote_bitrate_estimator/BUILD.gn +++ b/modules/remote_bitrate_estimator/BUILD.gn @@ -28,7 +28,6 @@ rtc_library("remote_bitrate_estimator") { "remote_bitrate_estimator_single_stream.cc", "remote_bitrate_estimator_single_stream.h", "rtp_transport_feedback_generator.h", - "test/bwe_test_logging.h", "transport_sequence_number_feedback_generator.cc", "transport_sequence_number_feedback_generator.h", ] @@ -61,14 +60,6 @@ rtc_library("remote_bitrate_estimator") { "//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/types:optional", ] - - if (rtc_enable_bwe_test_logging) { - defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=1" ] - sources += [ "test/bwe_test_logging.cc" ] - deps += [ "../../rtc_base:platform_thread" ] - } else { - defines = [ "BWE_TEST_LOGGING_COMPILE_TIME_ENABLE=0" ] - } } if (!build_with_chromium) { diff --git a/modules/remote_bitrate_estimator/overuse_detector.cc b/modules/remote_bitrate_estimator/overuse_detector.cc index 888f18cd9e..9ee56b8108 100644 --- a/modules/remote_bitrate_estimator/overuse_detector.cc +++ b/modules/remote_bitrate_estimator/overuse_detector.cc @@ -16,7 +16,6 @@ #include #include -#include "modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "rtc_base/checks.h" #include "rtc_base/numerics/safe_minmax.h" @@ -45,8 +44,6 @@ BandwidthUsage OveruseDetector::Detect(double offset, return BandwidthUsage::kBwNormal; } const double T = std::min(num_of_deltas, kMaxNumDeltas) * offset; - BWE_TEST_LOGGING_PLOT(1, "T", now_ms, T); - BWE_TEST_LOGGING_PLOT(1, "threshold", now_ms, threshold_); if (T > threshold_) { if (time_over_using_ == -1) { // Initialize the timer. Assume that we've been diff --git a/modules/remote_bitrate_estimator/overuse_estimator.cc b/modules/remote_bitrate_estimator/overuse_estimator.cc index e26c609b98..a42a90c06b 100644 --- a/modules/remote_bitrate_estimator/overuse_estimator.cc +++ b/modules/remote_bitrate_estimator/overuse_estimator.cc @@ -16,7 +16,6 @@ #include #include "api/transport/bandwidth_usage.h" -#include "modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "rtc_base/logging.h" namespace webrtc { @@ -36,7 +35,6 @@ void OveruseEstimator::Update(int64_t t_delta, int64_t now_ms) { const double min_frame_period = UpdateMinFramePeriod(ts_delta); const double t_ts_delta = t_delta - ts_delta; - BWE_TEST_LOGGING_PLOT(1, "dm_ms", now_ms, t_ts_delta); double fs_delta = size_delta; ++num_of_deltas_; @@ -59,8 +57,6 @@ void OveruseEstimator::Update(int64_t t_delta, const double Eh[2] = {E_[0][0] * h[0] + E_[0][1] * h[1], E_[1][0] * h[0] + E_[1][1] * h[1]}; - BWE_TEST_LOGGING_PLOT(1, "d_ms", now_ms, slope_ * h[0] - offset_); - const double residual = t_ts_delta - slope_ * h[0] - offset_; const bool in_stable_state = @@ -104,11 +100,6 @@ void OveruseEstimator::Update(int64_t t_delta, slope_ = slope_ + K[0] * residual; prev_offset_ = offset_; offset_ = offset_ + K[1] * residual; - - BWE_TEST_LOGGING_PLOT(1, "kc", now_ms, K[0]); - BWE_TEST_LOGGING_PLOT(1, "km", now_ms, K[1]); - BWE_TEST_LOGGING_PLOT(1, "slope_1/bps", now_ms, slope_); - BWE_TEST_LOGGING_PLOT(1, "var_noise", now_ms, var_noise_); } double OveruseEstimator::UpdateMinFramePeriod(double ts_delta) { diff --git a/modules/remote_bitrate_estimator/test/bwe_test_logging.cc b/modules/remote_bitrate_estimator/test/bwe_test_logging.cc deleted file mode 100644 index c8f6faa127..0000000000 --- a/modules/remote_bitrate_estimator/test/bwe_test_logging.cc +++ /dev/null @@ -1,262 +0,0 @@ -/* - * Copyright (c) 2013 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/remote_bitrate_estimator/test/bwe_test_logging.h" - -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE - -#include -#include -#include - -#include - -#include "rtc_base/checks.h" -#include "rtc_base/platform_thread.h" -#include "rtc_base/strings/string_builder.h" - -namespace webrtc { -namespace testing { -namespace bwe { - -static std::string ToString(uint32_t v) { - rtc::StringBuilder ss; - ss << v; - return ss.Release(); -} - -Logging::ThreadState::ThreadState() = default; -Logging::ThreadState::~ThreadState() = default; - -Logging::Context::Context(uint32_t name, int64_t timestamp_ms, bool enabled) { - Logging::GetInstance()->PushState(ToString(name), timestamp_ms, enabled); -} - -Logging::Context::Context(const std::string& name, - int64_t timestamp_ms, - bool enabled) { - Logging::GetInstance()->PushState(name, timestamp_ms, enabled); -} - -Logging::Context::Context(const char* name, - int64_t timestamp_ms, - bool enabled) { - Logging::GetInstance()->PushState(name, timestamp_ms, enabled); -} - -Logging::Context::~Context() { - Logging::GetInstance()->PopState(); -} - -Logging* Logging::GetInstance() { - static Logging* logging = new Logging(); - return logging; -} - -void Logging::SetGlobalContext(uint32_t name) { - MutexLock lock(&mutex_); - thread_map_[rtc::CurrentThreadId()].global_state.tag = ToString(name); -} - -void Logging::SetGlobalContext(const std::string& name) { - MutexLock lock(&mutex_); - thread_map_[rtc::CurrentThreadId()].global_state.tag = name; -} - -void Logging::SetGlobalContext(const char* name) { - MutexLock lock(&mutex_); - thread_map_[rtc::CurrentThreadId()].global_state.tag = name; -} - -void Logging::SetGlobalEnable(bool enabled) { - MutexLock lock(&mutex_); - thread_map_[rtc::CurrentThreadId()].global_state.enabled = enabled; -} - -void Logging::Log(const char format[], ...) { - MutexLock lock(&mutex_); - ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); - RTC_DCHECK(it != thread_map_.end()); - const State& state = it->second.stack.top(); - if (state.enabled) { - printf("%s\t", state.tag.c_str()); - va_list args; - va_start(args, format); - vprintf(format, args); - va_end(args); - printf("\n"); - } -} - -void Logging::Plot(int figure, const std::string& name, double value) { - Plot(figure, name, value, 0, "-"); -} - -void Logging::Plot(int figure, - const std::string& name, - double value, - uint32_t ssrc) { - Plot(figure, name, value, ssrc, "-"); -} - -void Logging::Plot(int figure, - const std::string& name, - double value, - const std::string& alg_name) { - Plot(figure, name, value, 0, alg_name); -} - -void Logging::Plot(int figure, - const std::string& name, - double value, - uint32_t ssrc, - const std::string& alg_name) { - MutexLock lock(&mutex_); - ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); - RTC_DCHECK(it != thread_map_.end()); - const State& state = it->second.stack.top(); - if (state.enabled) { - printf("PLOT\t%d\t%s:%" PRIu32 "@%s\t%f\t%f\n", figure, name.c_str(), ssrc, - alg_name.c_str(), state.timestamp_ms * 0.001, value); - } -} - -void Logging::PlotBar(int figure, - const std::string& name, - double value, - int flow_id) { - MutexLock lock(&mutex_); - ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); - RTC_DCHECK(it != thread_map_.end()); - const State& state = it->second.stack.top(); - if (state.enabled) { - printf("BAR\t%d\t%s_%d\t%f\n", figure, name.c_str(), flow_id, value); - } -} - -void Logging::PlotBaselineBar(int figure, - const std::string& name, - double value, - int flow_id) { - MutexLock lock(&mutex_); - ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); - RTC_DCHECK(it != thread_map_.end()); - const State& state = it->second.stack.top(); - if (state.enabled) { - printf("BASELINE\t%d\t%s_%d\t%f\n", figure, name.c_str(), flow_id, value); - } -} - -void Logging::PlotErrorBar(int figure, - const std::string& name, - double value, - double ylow, - double yhigh, - const std::string& error_title, - int flow_id) { - MutexLock lock(&mutex_); - ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); - RTC_DCHECK(it != thread_map_.end()); - const State& state = it->second.stack.top(); - if (state.enabled) { - printf("ERRORBAR\t%d\t%s_%d\t%f\t%f\t%f\t%s\n", figure, name.c_str(), - flow_id, value, ylow, yhigh, error_title.c_str()); - } -} - -void Logging::PlotLimitErrorBar(int figure, - const std::string& name, - double value, - double ylow, - double yhigh, - const std::string& error_title, - double ymax, - const std::string& limit_title, - int flow_id) { - MutexLock lock(&mutex_); - ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); - RTC_DCHECK(it != thread_map_.end()); - const State& state = it->second.stack.top(); - if (state.enabled) { - printf("LIMITERRORBAR\t%d\t%s_%d\t%f\t%f\t%f\t%s\t%f\t%s\n", figure, - name.c_str(), flow_id, value, ylow, yhigh, error_title.c_str(), ymax, - limit_title.c_str()); - } -} - -void Logging::PlotLabel(int figure, - const std::string& title, - const std::string& y_label, - int num_flows) { - MutexLock lock(&mutex_); - ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); - RTC_DCHECK(it != thread_map_.end()); - const State& state = it->second.stack.top(); - if (state.enabled) { - printf("LABEL\t%d\t%s\t%s\t%d\n", figure, title.c_str(), y_label.c_str(), - num_flows); - } -} - -Logging::Logging() : thread_map_() {} - -Logging::~Logging() = default; - -Logging::State::State() : tag(""), timestamp_ms(0), enabled(true) {} - -Logging::State::State(const std::string& tag, - int64_t timestamp_ms, - bool enabled) - : tag(tag), timestamp_ms(timestamp_ms), enabled(enabled) {} - -void Logging::State::MergePrevious(const State& previous) { - if (tag.empty()) { - tag = previous.tag; - } else if (!previous.tag.empty()) { - tag = previous.tag + "_" + tag; - } - timestamp_ms = std::max(previous.timestamp_ms, timestamp_ms); - enabled = previous.enabled && enabled; -} - -void Logging::PushState(const std::string& append_to_tag, - int64_t timestamp_ms, - bool enabled) { - MutexLock lock(&mutex_); - State new_state(append_to_tag, timestamp_ms, enabled); - ThreadState* thread_state = &thread_map_[rtc::CurrentThreadId()]; - std::stack* stack = &thread_state->stack; - if (stack->empty()) { - new_state.MergePrevious(thread_state->global_state); - } else { - new_state.MergePrevious(stack->top()); - } - stack->push(new_state); -} - -void Logging::PopState() { - MutexLock lock(&mutex_); - ThreadMap::iterator it = thread_map_.find(rtc::CurrentThreadId()); - RTC_DCHECK(it != thread_map_.end()); - std::stack* stack = &it->second.stack; - int64_t newest_timestamp_ms = stack->top().timestamp_ms; - stack->pop(); - if (!stack->empty()) { - State* state = &stack->top(); - // Update time so that next log/plot will use the latest time seen so far - // in this call tree. - state->timestamp_ms = std::max(state->timestamp_ms, newest_timestamp_ms); - } -} -} // namespace bwe -} // namespace testing -} // namespace webrtc - -#endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE diff --git a/modules/remote_bitrate_estimator/test/bwe_test_logging.h b/modules/remote_bitrate_estimator/test/bwe_test_logging.h deleted file mode 100644 index 49e1e716b2..0000000000 --- a/modules/remote_bitrate_estimator/test/bwe_test_logging.h +++ /dev/null @@ -1,360 +0,0 @@ -/* - * Copyright (c) 2013 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_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_TEST_LOGGING_H_ -#define MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_TEST_LOGGING_H_ - -// To enable BWE logging, run this command from trunk/ : -// build/gyp_chromium --depth=. webrtc/modules/modules.gyp -// -Denable_bwe_test_logging=1 -#ifndef BWE_TEST_LOGGING_COMPILE_TIME_ENABLE -#define BWE_TEST_LOGGING_COMPILE_TIME_ENABLE 0 -#endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE - -// BWE logging allows you to insert dynamically named log/plot points in the -// call tree. E.g. the function: -// void f1() { -// BWE_TEST_LOGGING_TIME(clock_->TimeInMilliseconds()); -// BWE_TEST_LOGGING_CONTEXT("stream"); -// for (uint32_t i=0; i<4; ++i) { -// BWE_TEST_LOGGING_ENABLE(i & 1); -// BWE_TEST_LOGGING_CONTEXT(i); -// BWE_TEST_LOGGING_LOG1("weight", "%f tonnes", weights_[i]); -// for (float j=0.0f; j<1.0; j+=0.4f) { -// BWE_TEST_LOGGING_PLOT(0, "bps", -1, j); -// } -// } -// } -// -// Might produce the output: -// stream_00000001_weight 13.000000 tonnes -// PLOT stream_00000001_bps 1.000000 0.000000 -// PLOT stream_00000001_bps 1.000000 0.400000 -// PLOT stream_00000001_bps 1.000000 0.800000 -// stream_00000003_weight 39.000000 tonnes -// PLOT stream_00000003_bps 1.000000 0.000000 -// PLOT stream_00000003_bps 1.000000 0.400000 -// PLOT stream_00000003_bps 1.000000 0.800000 -// -// Log *contexts* are names concatenated with '_' between them, with the name -// of the logged/plotted string/value last. Plot *time* is inherited down the -// tree. A branch is enabled by default but can be *disabled* to reduce output. -// The difference between the RTC_LOG and PLOT macros is that PLOT prefixes the -// line so it can be easily filtered, plus it outputs the current time. - -#if !(BWE_TEST_LOGGING_COMPILE_TIME_ENABLE) - -// Set a thread-global base logging context. This name will be prepended to all -// hierarchical contexts. -// `name` is a char*, std::string or uint32_t to name the context. -#define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) - -// Thread-globally allow/disallow logging. -// `enable` is expected to be a bool. -#define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) - -// Insert a (hierarchical) logging context. -// `name` is a char*, std::string or uint32_t to name the context. -#define BWE_TEST_LOGGING_CONTEXT(name) - -// Allow/disallow logging down the call tree from this point. Logging must be -// enabled all the way to the root of the call tree to take place. -// `enable` is expected to be a bool. -#define BWE_TEST_LOGGING_ENABLE(enabled) - -// Set current time (only affects PLOT output). Down the call tree, the latest -// time set always takes precedence. -// `time` is an int64_t time in ms, or -1 to inherit time from previous context. -#define BWE_TEST_LOGGING_TIME(time) - -// Print to stdout, e.g.: -// Context1_Context2_Name printf-formated-string -// `name` is a char*, std::string or uint32_t to name the log line. -// `format` is a printf format string. -// |_1...| are arguments for printf. -#define BWE_TEST_LOGGING_LOG1(name, format, _1) -#define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) -#define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) -#define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) -#define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) - -// Print to stdout in tab-separated format suitable for plotting, e.g.: -// PLOT figure Context1_Context2_Name time value -// `figure` is a figure id. Different figures are plotted in different windows. -// `name` is a char*, std::string or uint32_t to name the plotted value. -// `time` is an int64_t time in ms, or -1 to inherit time from previous context. -// `value` is a double precision float to be plotted. -// `ssrc` identifies the source of a stream -// `alg_name` is an optional argument, a string -#define BWE_TEST_LOGGING_PLOT(figure, name, time, value) -#define BWE_TEST_LOGGING_PLOT_WITH_NAME(figure, name, time, value, alg_name) -#define BWE_TEST_LOGGING_PLOT_WITH_SSRC(figure, name, time, value, ssrc) -#define BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(figure, name, time, value, \ - ssrc, alg_name) - -// Print to stdout in tab-separated format suitable for plotting, e.g.: -// BAR figure Context1_Context2_Name x_left width value -// `figure` is a figure id. Different figures are plotted in different windows. -// `name` is a char*, std::string or uint32_t to name the plotted value. -// `value` is a double precision float to be plotted. -// `ylow` and `yhigh` are double precision float for the error line. -// `title` is a string and refers to the error label. -// `ymax` is a double precision float for the limit horizontal line. -// `limit_title` is a string and refers to the limit label. -#define BWE_TEST_LOGGING_BAR(figure, name, value, flow_id) -#define BWE_TEST_LOGGING_ERRORBAR(figure, name, value, ylow, yhigh, \ - error_title, flow_id) -#define BWE_TEST_LOGGING_LIMITERRORBAR( \ - figure, name, value, ylow, yhigh, error_title, ymax, limit_title, flow_id) - -#define BWE_TEST_LOGGING_BASELINEBAR(figure, name, value, flow_id) - -// `num_flows` is an integer refering to the number of RMCAT flows in the -// scenario. -// Define `x_label` and `y_label` for plots. -#define BWE_TEST_LOGGING_LABEL(figure, x_label, y_label, num_flows) - -#else // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE - -#include -#include -#include -#include - -#include "rtc_base/synchronization/mutex.h" - -#define BWE_TEST_LOGGING_GLOBAL_CONTEXT(name) \ - do { \ - webrtc::testing::bwe::Logging::GetInstance()->SetGlobalContext(name); \ - } while (0) - -#define BWE_TEST_LOGGING_GLOBAL_ENABLE(enabled) \ - do { \ - webrtc::testing::bwe::Logging::GetInstance()->SetGlobalEnable(enabled); \ - } while (0) - -#define __BWE_TEST_LOGGING_CONTEXT_NAME(ctx, line) ctx##line -#define __BWE_TEST_LOGGING_CONTEXT_DECLARE(ctx, line, name, time, enabled) \ - webrtc::testing::bwe::Logging::Context __BWE_TEST_LOGGING_CONTEXT_NAME( \ - ctx, line)(name, time, enabled) - -#define BWE_TEST_LOGGING_CONTEXT(name) \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, name, -1, true) -#define BWE_TEST_LOGGING_ENABLE(enabled) \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", -1, \ - static_cast(enabled)) -#define BWE_TEST_LOGGING_TIME(time) \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __LINE__, "", \ - static_cast(time), true) - -#define BWE_TEST_LOGGING_LOG1(name, format, _1) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1); \ - } while (0) -#define BWE_TEST_LOGGING_LOG2(name, format, _1, _2) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2); \ - } while (0) -#define BWE_TEST_LOGGING_LOG3(name, format, _1, _2, _3) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3); \ - } while (0) -#define BWE_TEST_LOGGING_LOG4(name, format, _1, _2, _3, _4) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, _4); \ - } while (0) -#define BWE_TEST_LOGGING_LOG5(name, format, _1, _2, _3, _4, _5) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->Log(format, _1, _2, _3, _4, \ - _5); \ - } while (0) - -#define BWE_TEST_LOGGING_PLOT(figure, name, time, value) \ - do { \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __PLOT__, name, \ - static_cast(time), true); \ - webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, name, value); \ - } while (0) - -#define BWE_TEST_LOGGING_PLOT_WITH_NAME(figure, name, time, value, alg_name) \ - do { \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __PLOT__, name, \ - static_cast(time), true); \ - webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, name, value, \ - alg_name); \ - } while (0) - -#define BWE_TEST_LOGGING_PLOT_WITH_SSRC(figure, name, time, value, ssrc) \ - do { \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __PLOT__, name, \ - static_cast(time), true); \ - webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, name, value, \ - ssrc); \ - } while (0) - -#define BWE_TEST_LOGGING_PLOT_WITH_NAME_AND_SSRC(figure, name, time, value, \ - ssrc, alg_name) \ - do { \ - __BWE_TEST_LOGGING_CONTEXT_DECLARE(__bwe_log_, __PLOT__, name, \ - static_cast(time), true); \ - webrtc::testing::bwe::Logging::GetInstance()->Plot(figure, name, value, \ - ssrc, alg_name); \ - } while (0) - -#define BWE_TEST_LOGGING_BAR(figure, name, value, flow_id) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->PlotBar(figure, name, value, \ - flow_id); \ - } while (0) - -#define BWE_TEST_LOGGING_BASELINEBAR(figure, name, value, flow_id) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->PlotBaselineBar( \ - figure, name, value, flow_id); \ - } while (0) - -#define BWE_TEST_LOGGING_ERRORBAR(figure, name, value, ylow, yhigh, title, \ - flow_id) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->PlotErrorBar( \ - figure, name, value, ylow, yhigh, title, flow_id); \ - } while (0) - -#define BWE_TEST_LOGGING_LIMITERRORBAR( \ - figure, name, value, ylow, yhigh, error_title, ymax, limit_title, flow_id) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(name); \ - webrtc::testing::bwe::Logging::GetInstance()->PlotLimitErrorBar( \ - figure, name, value, ylow, yhigh, error_title, ymax, limit_title, \ - flow_id); \ - } while (0) - -#define BWE_TEST_LOGGING_LABEL(figure, title, y_label, num_flows) \ - do { \ - BWE_TEST_LOGGING_CONTEXT(title); \ - webrtc::testing::bwe::Logging::GetInstance()->PlotLabel( \ - figure, title, y_label, num_flows); \ - } while (0) - -namespace webrtc { -namespace testing { -namespace bwe { - -class Logging { - public: - class Context { - public: - Context(uint32_t name, int64_t timestamp_ms, bool enabled); - Context(const std::string& name, int64_t timestamp_ms, bool enabled); - Context(const char* name, int64_t timestamp_ms, bool enabled); - - Context() = delete; - Context(const Context&) = delete; - Context& operator=(const Context&) = delete; - ~Context(); - }; - - static Logging* GetInstance(); - - void SetGlobalContext(uint32_t name); - void SetGlobalContext(const std::string& name); - void SetGlobalContext(const char* name); - void SetGlobalEnable(bool enabled); - -#if defined(__GNUC__) - // Note: Implicit `this` argument counts as the first argument. - __attribute__((__format__(__printf__, 2, 3))) -#endif - void - Log(const char format[], ...); - void Plot(int figure, const std::string& name, double value); - void Plot(int figure, - const std::string& name, - double value, - const std::string& alg_name); - void Plot(int figure, const std::string& name, double value, uint32_t ssrc); - void Plot(int figure, - const std::string& name, - double value, - uint32_t ssrc, - const std::string& alg_name); - void PlotBar(int figure, const std::string& name, double value, int flow_id); - void PlotBaselineBar(int figure, - const std::string& name, - double value, - int flow_id); - void PlotErrorBar(int figure, - const std::string& name, - double value, - double ylow, - double yhigh, - const std::string& error_title, - int flow_id); - - void PlotLimitErrorBar(int figure, - const std::string& name, - double value, - double ylow, - double yhigh, - const std::string& error_title, - double ymax, - const std::string& limit_title, - int flow_id); - void PlotLabel(int figure, - const std::string& title, - const std::string& y_label, - int num_flows); - - private: - struct State { - State(); - State(const std::string& new_tag, int64_t timestamp_ms, bool enabled); - void MergePrevious(const State& previous); - - std::string tag; - int64_t timestamp_ms; - bool enabled; - }; - struct ThreadState { - ThreadState(); - ~ThreadState(); - State global_state; - std::stack stack; - }; - typedef std::map ThreadMap; - - Logging(); - ~Logging(); - - Logging(const Logging&) = delete; - Logging& operator=(const Logging&) = delete; - - void PushState(const std::string& append_to_tag, - int64_t timestamp_ms, - bool enabled); - void PopState(); - - Mutex mutex_; - ThreadMap thread_map_; -}; -} // namespace bwe -} // namespace testing -} // namespace webrtc - -#endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE -#endif // MODULES_REMOTE_BITRATE_ESTIMATOR_TEST_BWE_TEST_LOGGING_H_ diff --git a/tools_webrtc/mb/mb_config.pyl b/tools_webrtc/mb/mb_config.pyl index a64b9e0537..572d9ce388 100644 --- a/tools_webrtc/mb/mb_config.pyl +++ b/tools_webrtc/mb/mb_config.pyl @@ -34,7 +34,6 @@ 'Android32': 'android_release_bot_arm', 'Android32 (dbg)': 'android_debug_static_bot_arm', 'Android32 (more configs)': { - 'bwe_test_logging': 'bwe_test_logging_android_arm', 'dummy_audio_file_devices_no_protobuf': 'dummy_audio_file_devices_no_protobuf_android_arm', 'rtti_no_sctp': 'rtti_no_sctp_android_arm', @@ -55,7 +54,6 @@ # "More configs" bots will build all the following configs in sequence. # This is using MB's "phases" feature. 'Linux (more configs)': { - 'bwe_test_logging': 'bwe_test_logging_x64', 'dummy_audio_file_devices_no_protobuf': 'dummy_audio_file_devices_no_protobuf_x64', 'rtti_no_sctp': 'rtti_no_sctp_x64', @@ -86,7 +84,6 @@ # Windows 'Win (more configs)': { - 'bwe_test_logging': 'bwe_test_logging_x86', 'dummy_audio_file_devices_no_protobuf': 'dummy_audio_file_devices_no_protobuf_x86', 'rtti_no_sctp': 'rtti_no_sctp_no_unicode_win_x86', @@ -142,7 +139,6 @@ 'android_arm64_rel': 'android_release_bot_arm64', 'android_arm_dbg': 'android_debug_static_bot_arm', 'android_arm_more_configs': { - 'bwe_test_logging': 'bwe_test_logging_android_arm', 'dummy_audio_file_devices_no_protobuf': 'dummy_audio_file_devices_no_protobuf_android_arm', 'rtti_no_sctp': 'rtti_no_sctp_android_arm', @@ -181,7 +177,6 @@ 'linux_dbg': 'debug_bot_x64', 'linux_libfuzzer_rel': 'libfuzzer_asan_release_bot_x64', 'linux_more_configs': { - 'bwe_test_logging': 'bwe_test_logging_x64', 'dummy_audio_file_devices_no_protobuf': 'dummy_audio_file_devices_no_protobuf_x64', 'rtti_no_sctp': 'rtti_no_sctp_x64', @@ -218,7 +213,6 @@ 'win_x86_clang_dbg': 'win_clang_debug_bot_x86', 'win_x86_clang_rel': 'win_clang_release_bot_x86', 'win_x86_more_configs': { - 'bwe_test_logging': 'bwe_test_logging_x86', 'dummy_audio_file_devices_no_protobuf': 'dummy_audio_file_devices_no_protobuf_x86', 'rtti_no_sctp': 'rtti_no_sctp_no_unicode_win_x86', @@ -294,10 +288,6 @@ 'x64', 'h265', ], - 'bwe_test_logging_android_arm': - ['android', 'debug_static_bot', 'arm', 'bwe_test_logging'], - 'bwe_test_logging_x64': ['debug_bot', 'x64', 'bwe_test_logging'], - 'bwe_test_logging_x86': ['debug_bot', 'x86', 'bwe_test_logging'], 'code_coverage_bot_x64': [ 'openh264', 'release_bot', 'x64', 'code_coverage', 'partial_code_coverage_instrumentation', 'h265' @@ -441,9 +431,6 @@ 'asan': { 'gn_args': 'is_asan=true', }, - 'bwe_test_logging': { - 'gn_args': 'rtc_enable_bwe_test_logging=true', - }, # is_clang=true by default, this is only to guard from upstream changes. 'clang': { 'gn_args': 'is_clang=true', diff --git a/webrtc.gni b/webrtc.gni index 0e3487e715..993b19c1f5 100644 --- a/webrtc.gni +++ b/webrtc.gni @@ -135,9 +135,6 @@ declare_args() { # Selects whether the audio processing module should be excluded. rtc_exclude_audio_processing_module = false - # Set this to true to enable BWE test logging. - rtc_enable_bwe_test_logging = false - # Set this to false to skip building examples. rtc_build_examples = true