diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc index b5e00b2ce5..f9313a6724 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc @@ -221,11 +221,12 @@ RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, packets_per_second_stats_(), kbps_stats_(), start_plotting_time_ms_(0), -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE flow_id_(flow_id), -#endif name_(name), - algorithm_name_(algorithm_name) {} + algorithm_name_(algorithm_name) { + // Only used when compiling with BWE test logging enabled. + RTC_UNUSED(flow_id_); +} RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, const FlowIds& flow_ids, @@ -276,7 +277,6 @@ Stats RateCounterFilter::GetBitrateStats() const { void RateCounterFilter::Plot(int64_t timestamp_ms) { // TODO(stefan): Reorganize logging configuration to reduce amount // of preprocessor conditionals in the code. -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE uint32_t plot_kbps = 0; if (timestamp_ms >= start_plotting_time_ms_) { plot_kbps = rate_counter_.bits_per_second() / 1000.0; @@ -290,7 +290,7 @@ void RateCounterFilter::Plot(int64_t timestamp_ms) { timestamp_ms, plot_kbps, flow_id_, algorithm_name_); } -#endif + RTC_UNUSED(plot_kbps); } void RateCounterFilter::RunFor(int64_t /*time_ms*/, Packets* in_out) { diff --git a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h index c5a16a68b8..adc3b9951d 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h @@ -34,6 +34,7 @@ #include "webrtc/modules/remote_bitrate_estimator/test/packet.h" #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" #include "webrtc/system_wrappers/include/clock.h" +#include "webrtc/typedefs.h" namespace webrtc { @@ -250,9 +251,7 @@ class RateCounterFilter : public PacketProcessor { Stats packets_per_second_stats_; Stats kbps_stats_; int64_t start_plotting_time_ms_; -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE int flow_id_ = 0; -#endif std::string name_; // Algorithm name if single flow, Total link utilization if all flows. std::string algorithm_name_; diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc index 39b5c14b05..9c3e342c8a 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc @@ -17,6 +17,7 @@ #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" #include "webrtc/modules/rtp_rtcp/include/receive_statistics.h" #include "webrtc/test/gtest.h" +#include "webrtc/typedefs.h" namespace webrtc { namespace testing { @@ -65,9 +66,7 @@ int RembBweSender::GetFeedbackIntervalMs() const { RembReceiver::RembReceiver(int flow_id, bool plot) : BweReceiver(flow_id), estimate_log_prefix_(), -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE plot_estimate_(plot), -#endif clock_(0), recv_stats_(ReceiveStatistics::Create(&clock_)), latest_estimate_bps_(-1), @@ -121,13 +120,12 @@ FeedbackPacket* RembReceiver::GetFeedback(int64_t now_ms) { estimated_bps, latest_report_block_); last_feedback_ms_ = now_ms; -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE double estimated_kbps = static_cast(estimated_bps) / 1000.0; + RTC_UNUSED(estimated_kbps); if (plot_estimate_) { BWE_TEST_LOGGING_PLOT(0, estimate_log_prefix_, clock_.TimeInMilliseconds(), estimated_kbps); } -#endif } return feedback; } diff --git a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h index 855dc6ff0e..73e4a30db3 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h @@ -70,9 +70,7 @@ class RembReceiver : public BweReceiver, public RemoteBitrateObserver { bool LatestEstimate(uint32_t* estimate_bps); std::string estimate_log_prefix_; -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE bool plot_estimate_ = false; -#endif SimulatedClock clock_; std::unique_ptr recv_stats_; int64_t latest_estimate_bps_; diff --git a/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc b/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc index 70a39f4795..c0dc7415a8 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc @@ -13,6 +13,7 @@ #include #include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h" +#include "webrtc/typedefs.h" namespace webrtc { namespace testing { @@ -262,7 +263,6 @@ void MetricRecorder::PlotThroughputHistogram( size_t num_flows, int64_t extra_offset_ms, const std::string optimum_id) const { -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE double optimal_bitrate_per_flow_kbps = static_cast( optimal_throughput_bits_ / RunDurationMs(extra_offset_ms)); @@ -290,7 +290,11 @@ void MetricRecorder::PlotThroughputHistogram( "%lf %%", 100.0 * static_cast(average_bitrate_kbps) / optimal_bitrate_per_flow_kbps); -#endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE + + RTC_UNUSED(pos_error); + RTC_UNUSED(neg_error); + RTC_UNUSED(extra_error); + RTC_UNUSED(optimal_bitrate_per_flow_kbps); } void MetricRecorder::PlotThroughputHistogram(const std::string& title, @@ -304,7 +308,6 @@ void MetricRecorder::PlotDelayHistogram(const std::string& title, const std::string& bwe_name, size_t num_flows, int64_t one_way_path_delay_ms) const { -#if BWE_TEST_LOGGING_COMPILE_TIME_ENABLE double average_delay_ms = static_cast(sum_delays_ms_) / num_packets_received_; int64_t percentile_5_ms = NthDelayPercentile(5); @@ -322,7 +325,10 @@ void MetricRecorder::PlotDelayHistogram(const std::string& title, "%ld ms", percentile_5_ms - one_way_path_delay_ms); BWE_TEST_LOGGING_LOG1("RESULTS >>> " + bwe_name + " Delay 95th percentile : ", "%ld ms", percentile_95_ms - one_way_path_delay_ms); -#endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE + + RTC_UNUSED(average_delay_ms); + RTC_UNUSED(percentile_5_ms); + RTC_UNUSED(percentile_95_ms); } void MetricRecorder::PlotLossHistogram(const std::string& title, diff --git a/webrtc/typedefs.h b/webrtc/typedefs.h index 16e10c5ea1..bc48c08290 100644 --- a/webrtc/typedefs.h +++ b/webrtc/typedefs.h @@ -80,6 +80,8 @@ // Put after a variable that might not be used, to prevent compiler warnings: // int result ATTRIBUTE_UNUSED = DoSomething(); // assert(result == 17); +// Deprecated since it only works with GCC & clang. See RTC_UNUSED below. +// TODO(terelius): Remove. #ifndef ATTRIBUTE_UNUSED #if defined(__GNUC__) || defined(__clang__) #define ATTRIBUTE_UNUSED __attribute__ ((__unused__)) @@ -109,4 +111,14 @@ #endif #endif +// Prevent the compiler from warning about an unused variable. For example: +// int result = DoSomething(); +// assert(result == 17); +// RTC_UNUSED(result); +// Note: In most cases it is better to remove the unused variable rather than +// suppressing the compiler warning. +#ifndef RTC_UNUSED +#define RTC_UNUSED(x) static_cast(x) +#endif // RTC_UNUSED + #endif // WEBRTC_TYPEDEFS_H_