diff --git a/webrtc/base/BUILD.gn b/webrtc/base/BUILD.gn index 82e23d0a08..e5b0e97b2a 100644 --- a/webrtc/base/BUILD.gn +++ b/webrtc/base/BUILD.gn @@ -392,8 +392,6 @@ rtc_static_library("rtc_base") { "asynctcpsocket.h", "asyncudpsocket.cc", "asyncudpsocket.h", - "common.cc", - "common.h", "crc32.cc", "crc32.h", "cryptstring.cc", diff --git a/webrtc/base/common.cc b/webrtc/base/common.cc deleted file mode 100644 index 07eb0b1c33..0000000000 --- a/webrtc/base/common.cc +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2004 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 -#include -#include -#include - -#ifdef WEBRTC_WIN -#define WIN32_LEAN_AND_MEAN -#include -#endif // WEBRTC_WIN - -#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS) -#include -#endif // WEBRTC_MAC && !defined(WEBRTC_IOS) - -#include -#include "webrtc/base/common.h" -#include "webrtc/base/logging.h" - -////////////////////////////////////////////////////////////////////// -// Assertions -////////////////////////////////////////////////////////////////////// - -namespace rtc { - -void Break() { -#ifdef WEBRTC_WIN - ::DebugBreak(); -#else // !WEBRTC_WIN - // On POSIX systems, SIGTRAP signals debuggers to break without killing the - // process. If a debugger isn't attached, the uncaught SIGTRAP will crash the - // app. - raise(SIGTRAP); -#endif - // If a debugger wasn't attached, we will have crashed by this point. If a - // debugger is attached, we'll continue from here. -} - -static AssertLogger custom_assert_logger_ = NULL; - -void SetCustomAssertLogger(AssertLogger logger) { - custom_assert_logger_ = logger; -} - -void LogAssert(const char* function, const char* file, int line, - const char* expression) { - if (custom_assert_logger_) { - custom_assert_logger_(function, file, line, expression); - } else { - LOG(LS_ERROR) << file << "(" << line << ")" << ": ASSERT FAILED: " - << expression << " @ " << function; - } -} - -bool IsOdd(int n) { - return (n & 0x1); -} - -bool IsEven(int n) { - return !IsOdd(n); -} - -} // namespace rtc diff --git a/webrtc/base/common.h b/webrtc/base/common.h deleted file mode 100644 index fe98ef5d6c..0000000000 --- a/webrtc/base/common.h +++ /dev/null @@ -1,201 +0,0 @@ -/* - * Copyright 2004 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 WEBRTC_BASE_COMMON_H_ // NOLINT -#define WEBRTC_BASE_COMMON_H_ - -#include "webrtc/base/constructormagic.h" - -#if defined(_MSC_VER) -// warning C4355: 'this' : used in base member initializer list -#pragma warning(disable:4355) -#endif - -////////////////////////////////////////////////////////////////////// -// General Utilities -////////////////////////////////////////////////////////////////////// - -#ifndef RTC_UNUSED -#define RTC_UNUSED(x) RtcUnused(static_cast(&x)) -#define RTC_UNUSED2(x, y) RtcUnused(static_cast(&x)); \ - RtcUnused(static_cast(&y)) -#define RTC_UNUSED3(x, y, z) RtcUnused(static_cast(&x)); \ - RtcUnused(static_cast(&y)); \ - RtcUnused(static_cast(&z)) -#define RTC_UNUSED4(x, y, z, a) RtcUnused(static_cast(&x)); \ - RtcUnused(static_cast(&y)); \ - RtcUnused(static_cast(&z)); \ - RtcUnused(static_cast(&a)) -#define RTC_UNUSED5(x, y, z, a, b) RtcUnused(static_cast(&x)); \ - RtcUnused(static_cast(&y)); \ - RtcUnused(static_cast(&z)); \ - RtcUnused(static_cast(&a)); \ - RtcUnused(static_cast(&b)) -inline void RtcUnused(const void*) {} -#endif // RTC_UNUSED - -#if !defined(WEBRTC_WIN) - -#ifndef strnicmp -#define strnicmp(x, y, n) strncasecmp(x, y, n) -#endif - -#ifndef stricmp -#define stricmp(x, y) strcasecmp(x, y) -#endif - -#endif // !defined(WEBRTC_WIN) - -///////////////////////////////////////////////////////////////////////////// -// Assertions -///////////////////////////////////////////////////////////////////////////// - -#ifndef ENABLE_DEBUG -#if !defined(NDEBUG) -#define ENABLE_DEBUG 1 -#else -#define ENABLE_DEBUG 0 -#endif -#endif // !defined(ENABLE_DEBUG) - -// Even for release builds, allow for the override of LogAssert. Though no -// macro is provided, this can still be used for explicit runtime asserts -// and allow applications to override the assert behavior. - -namespace rtc { - - -// If a debugger is attached, triggers a debugger breakpoint. If a debugger is -// not attached, forces program termination. -void Break(); - -// LogAssert writes information about an assertion to the log. It's called by -// Assert (and from the ASSERT macro in debug mode) before any other action -// is taken (e.g. breaking the debugger, abort()ing, etc.). -void LogAssert(const char* function, const char* file, int line, - const char* expression); - -typedef void (*AssertLogger)(const char* function, - const char* file, - int line, - const char* expression); - -// Sets a custom assert logger to be used instead of the default LogAssert -// behavior. To clear the custom assert logger, pass NULL for |logger| and the -// default behavior will be restored. Only one custom assert logger can be set -// at a time, so this should generally be set during application startup and -// only by one component. -void SetCustomAssertLogger(AssertLogger logger); - -bool IsOdd(int n); - -bool IsEven(int n); - -} // namespace rtc - -#if ENABLE_DEBUG - -namespace rtc { - -inline bool Assert(bool result, const char* function, const char* file, - int line, const char* expression) { - if (!result) { - LogAssert(function, file, line, expression); - Break(); - } - return result; -} - -// Same as Assert above, but does not call Break(). Used in assert macros -// that implement their own breaking. -inline bool AssertNoBreak(bool result, const char* function, const char* file, - int line, const char* expression) { - if (!result) - LogAssert(function, file, line, expression); - return result; -} - -} // namespace rtc - -#if defined(_MSC_VER) && _MSC_VER < 1300 -#define __FUNCTION__ "" -#endif - -#ifndef ASSERT -#if defined(WIN32) -// Using debugbreak() inline on Windows directly in the ASSERT macro, has the -// benefit of breaking exactly where the failing expression is and not two -// calls up the stack. -#define ASSERT(x) \ - (rtc::AssertNoBreak((x), __FUNCTION__, __FILE__, __LINE__, #x) ? \ - (void)(1) : __debugbreak()) -#else -#define ASSERT(x) \ - (void)rtc::Assert((x), __FUNCTION__, __FILE__, __LINE__, #x) -#endif -#endif - -#ifndef VERIFY -#if defined(WIN32) -#define VERIFY(x) \ - (rtc::AssertNoBreak((x), __FUNCTION__, __FILE__, __LINE__, #x) ? \ - true : (__debugbreak(), false)) -#else -#define VERIFY(x) rtc::Assert((x), __FUNCTION__, __FILE__, __LINE__, #x) -#endif -#endif - -#else // !ENABLE_DEBUG - -namespace rtc { - -inline bool ImplicitCastToBool(bool result) { return result; } - -} // namespace rtc - -#ifndef ASSERT -#define ASSERT(x) (void)0 -#endif - -#ifndef VERIFY -#define VERIFY(x) rtc::ImplicitCastToBool(x) -#endif - -#endif // !ENABLE_DEBUG - -#define COMPILE_TIME_ASSERT(expr) char CTA_UNIQUE_NAME[expr] -#define CTA_UNIQUE_NAME CTA_MAKE_NAME(__LINE__) -#define CTA_MAKE_NAME(line) CTA_MAKE_NAME2(line) -#define CTA_MAKE_NAME2(line) constraint_ ## line - -// Forces compiler to inline, even against its better judgement. Use wisely. -#if defined(__GNUC__) -#define FORCE_INLINE __attribute__ ((__always_inline__)) -#elif defined(WEBRTC_WIN) -#define FORCE_INLINE __forceinline -#else -#define FORCE_INLINE -#endif - -// Annotate a function indicating the caller must examine the return value. -// Use like: -// int foo() WARN_UNUSED_RESULT; -// To explicitly ignore a result, see |ignore_result()| in . -// TODO(ajm): Hack to avoid multiple definitions until the base/ of webrtc and -// libjingle are merged. -#if !defined(WARN_UNUSED_RESULT) -#if defined(__GNUC__) || defined(__clang__) -#define WARN_UNUSED_RESULT __attribute__ ((__warn_unused_result__)) -#else -#define WARN_UNUSED_RESULT -#endif -#endif // WARN_UNUSED_RESULT - -#endif // WEBRTC_BASE_COMMON_H_ // NOLINT diff --git a/webrtc/base/httpserver.cc b/webrtc/base/httpserver.cc index 6594581aec..083fc0751a 100644 --- a/webrtc/base/httpserver.cc +++ b/webrtc/base/httpserver.cc @@ -14,7 +14,6 @@ #include "webrtc/base/asyncsocket.h" #include "webrtc/base/checks.h" -#include "webrtc/base/common.h" #include "webrtc/base/httpserver.h" #include "webrtc/base/logging.h" #include "webrtc/base/socketstream.h" @@ -223,7 +222,6 @@ HttpServer::Connection::onHttpComplete(HttpMode mode, HttpError err) { void HttpServer::Connection::onHttpClosed(HttpError err) { - RTC_UNUSED(err); server_->Remove(connection_id_); } diff --git a/webrtc/base/openssladapter.cc b/webrtc/base/openssladapter.cc index 135a32538a..6f9049d10b 100644 --- a/webrtc/base/openssladapter.cc +++ b/webrtc/base/openssladapter.cc @@ -27,7 +27,6 @@ #include "webrtc/base/arraysize.h" #include "webrtc/base/checks.h" -#include "webrtc/base/common.h" #include "webrtc/base/logging.h" #include "webrtc/base/openssl.h" #include "webrtc/base/safe_conversions.h" @@ -148,9 +147,6 @@ static int socket_puts(BIO* b, const char* str) { } static long socket_ctrl(BIO* b, int cmd, long num, void* ptr) { - RTC_UNUSED(num); - RTC_UNUSED(ptr); - switch (cmd) { case BIO_CTRL_RESET: return 0; diff --git a/webrtc/base/opensslstreamadapter.cc b/webrtc/base/opensslstreamadapter.cc index 6ff7fd584b..45ff30ae9a 100644 --- a/webrtc/base/opensslstreamadapter.cc +++ b/webrtc/base/opensslstreamadapter.cc @@ -25,7 +25,6 @@ #include #include "webrtc/base/checks.h" -#include "webrtc/base/common.h" #include "webrtc/base/logging.h" #include "webrtc/base/safe_conversions.h" #include "webrtc/base/stream.h" @@ -253,9 +252,6 @@ static int stream_puts(BIO* b, const char* str) { } static long stream_ctrl(BIO* b, int cmd, long num, void* ptr) { - RTC_UNUSED(num); - RTC_UNUSED(ptr); - switch (cmd) { case BIO_CTRL_RESET: return 0; 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 8b04d00d38..f6a61a6e8d 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.cc @@ -14,7 +14,6 @@ #include -#include "webrtc/base/common.h" #include "webrtc/base/constructormagic.h" namespace webrtc { @@ -223,12 +222,11 @@ 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) { - // Only used when compiling with BWE test logging enabled. - RTC_UNUSED(flow_id_); - } + algorithm_name_(algorithm_name) {} RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, const FlowIds& flow_ids, @@ -238,7 +236,6 @@ RateCounterFilter::RateCounterFilter(PacketProcessorListener* listener, packets_per_second_stats_(), kbps_stats_(), start_plotting_time_ms_(0), - flow_id_(0), name_(name), algorithm_name_(algorithm_name) { // TODO(terelius): Appending the flow IDs to the algorithm name is a hack to @@ -278,6 +275,9 @@ 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; @@ -291,8 +291,7 @@ void RateCounterFilter::Plot(int64_t timestamp_ms) { timestamp_ms, plot_kbps, flow_id_, algorithm_name_); } - - RTC_UNUSED(plot_kbps); +#endif } 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 1ae24af965..c5a16a68b8 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h +++ b/webrtc/modules/remote_bitrate_estimator/test/bwe_test_framework.h @@ -250,7 +250,9 @@ class RateCounterFilter : public PacketProcessor { Stats packets_per_second_stats_; Stats kbps_stats_; int64_t start_plotting_time_ms_; - int flow_id_; +#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 1917789b7c..39b5c14b05 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.cc @@ -12,7 +12,6 @@ #include "webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h" -#include "webrtc/base/common.h" #include "webrtc/modules/bitrate_controller/include/bitrate_controller.h" #include "webrtc/modules/remote_bitrate_estimator/remote_bitrate_estimator_abs_send_time.h" #include "webrtc/modules/remote_bitrate_estimator/test/bwe_test_logging.h" @@ -66,7 +65,9 @@ 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), @@ -120,12 +121,13 @@ 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 cb9af9ac94..855dc6ff0e 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h +++ b/webrtc/modules/remote_bitrate_estimator/test/estimators/remb.h @@ -70,7 +70,9 @@ class RembReceiver : public BweReceiver, public RemoteBitrateObserver { bool LatestEstimate(uint32_t* estimate_bps); std::string estimate_log_prefix_; - bool plot_estimate_; +#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 5448537046..ed2c1328a0 100644 --- a/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc +++ b/webrtc/modules/remote_bitrate_estimator/test/metric_recorder.cc @@ -12,7 +12,6 @@ #include -#include "webrtc/base/common.h" #include "webrtc/modules/remote_bitrate_estimator/test/packet_sender.h" namespace webrtc { @@ -263,6 +262,7 @@ 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,11 +290,7 @@ void MetricRecorder::PlotThroughputHistogram( "%lf %%", 100.0 * static_cast(average_bitrate_kbps) / optimal_bitrate_per_flow_kbps); - - RTC_UNUSED(pos_error); - RTC_UNUSED(neg_error); - RTC_UNUSED(extra_error); - RTC_UNUSED(optimal_bitrate_per_flow_kbps); +#endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE } void MetricRecorder::PlotThroughputHistogram(const std::string& title, @@ -308,6 +304,7 @@ 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_; @@ -329,10 +326,7 @@ 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); - - RTC_UNUSED(tenth_sigma_ms); - RTC_UNUSED(percentile_5_ms); - RTC_UNUSED(percentile_95_ms); +#endif // BWE_TEST_LOGGING_COMPILE_TIME_ENABLE } void MetricRecorder::PlotLossHistogram(const std::string& title, diff --git a/webrtc/pc/mediasession.cc b/webrtc/pc/mediasession.cc index 9a4dac9089..000c289c18 100644 --- a/webrtc/pc/mediasession.cc +++ b/webrtc/pc/mediasession.cc @@ -19,11 +19,11 @@ #include #include "webrtc/base/base64.h" -#include "webrtc/base/common.h" #include "webrtc/base/checks.h" #include "webrtc/base/helpers.h" #include "webrtc/base/logging.h" #include "webrtc/base/stringutils.h" +#include "webrtc/common_types.h" #include "webrtc/common_video/h264/profile_level_id.h" #include "webrtc/media/base/cryptoparams.h" #include "webrtc/media/base/mediaconstants.h" @@ -702,7 +702,7 @@ static bool ContainsRtxCodec(const std::vector& codecs) { template static bool IsRtxCodec(const C& codec) { - return stricmp(codec.name.c_str(), kRtxCodecName) == 0; + return STR_CASE_CMP(codec.name.c_str(), kRtxCodecName) == 0; } template @@ -717,7 +717,7 @@ static bool ContainsFlexfecCodec(const std::vector& codecs) { template static bool IsFlexfecCodec(const C& codec) { - return stricmp(codec.name.c_str(), kFlexfecCodecName) == 0; + return STR_CASE_CMP(codec.name.c_str(), kFlexfecCodecName) == 0; } static TransportOptions GetTransportOptions(const MediaSessionOptions& options, @@ -1013,7 +1013,7 @@ static void NegotiateRtpHeaderExtensions( static void StripCNCodecs(AudioCodecs* audio_codecs) { AudioCodecs::iterator iter = audio_codecs->begin(); while (iter != audio_codecs->end()) { - if (stricmp(iter->name.c_str(), kComfortNoiseCodecName) == 0) { + if (STR_CASE_CMP(iter->name.c_str(), kComfortNoiseCodecName) == 0) { iter = audio_codecs->erase(iter); } else { ++iter;