Delete webrtc/base/common.h

BUG=webrtc:6424

Review-Url: https://codereview.webrtc.org/2684613002
Cr-Commit-Position: refs/heads/master@{#16718}
This commit is contained in:
nisse 2017-02-20 05:01:01 -08:00 committed by Commit bot
parent e5c27a5db6
commit 21e4e0b0ab
12 changed files with 25 additions and 311 deletions

View File

@ -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",

View File

@ -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 <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#ifdef WEBRTC_WIN
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#endif // WEBRTC_WIN
#if defined(WEBRTC_MAC) && !defined(WEBRTC_IOS)
#include <CoreServices/CoreServices.h>
#endif // WEBRTC_MAC && !defined(WEBRTC_IOS)
#include <algorithm>
#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

View File

@ -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<const void*>(&x))
#define RTC_UNUSED2(x, y) RtcUnused(static_cast<const void*>(&x)); \
RtcUnused(static_cast<const void*>(&y))
#define RTC_UNUSED3(x, y, z) RtcUnused(static_cast<const void*>(&x)); \
RtcUnused(static_cast<const void*>(&y)); \
RtcUnused(static_cast<const void*>(&z))
#define RTC_UNUSED4(x, y, z, a) RtcUnused(static_cast<const void*>(&x)); \
RtcUnused(static_cast<const void*>(&y)); \
RtcUnused(static_cast<const void*>(&z)); \
RtcUnused(static_cast<const void*>(&a))
#define RTC_UNUSED5(x, y, z, a, b) RtcUnused(static_cast<const void*>(&x)); \
RtcUnused(static_cast<const void*>(&y)); \
RtcUnused(static_cast<const void*>(&z)); \
RtcUnused(static_cast<const void*>(&a)); \
RtcUnused(static_cast<const void*>(&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 <base/basictypes.h>.
// 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

View File

@ -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_);
}

View File

@ -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;

View File

@ -25,7 +25,6 @@
#include <vector>
#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;

View File

@ -14,7 +14,6 @@
#include <sstream>
#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<double> 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) {

View File

@ -250,7 +250,9 @@ class RateCounterFilter : public PacketProcessor {
Stats<double> packets_per_second_stats_;
Stats<double> 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_;

View File

@ -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<double>(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;
}

View File

@ -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<ReceiveStatistics> recv_stats_;
int64_t latest_estimate_bps_;

View File

@ -12,7 +12,6 @@
#include <algorithm>
#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<double>(
optimal_throughput_bits_ / RunDurationMs(extra_offset_ms));
@ -290,11 +290,7 @@ void MetricRecorder::PlotThroughputHistogram(
"%lf %%",
100.0 * static_cast<double>(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<double>(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,

View File

@ -19,11 +19,11 @@
#include <utility>
#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<C>& codecs) {
template <class C>
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 <class C>
@ -717,7 +717,7 @@ static bool ContainsFlexfecCodec(const std::vector<C>& codecs) {
template <class C>
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;