Bump to WebRTC M120 release

Some API deprecation -- ExperimentalAgc and ExperimentalNs are gone.
We're continuing to carry iSAC even though it's gone upstream, but maybe
we'll want to drop that soon.
This commit is contained in:
Arun Raghavan
2023-12-12 10:42:58 -05:00
parent 9a202fb8c2
commit c6abf6cd3f
479 changed files with 20900 additions and 11996 deletions

View File

@ -21,9 +21,13 @@
// RTC_LOG(sev) logs the given stream at severity "sev", which must be a
// compile-time constant of the LoggingSeverity type, without the namespace
// prefix.
// RTC_LOG_IF(sev, condition) logs the given stream at severitye "sev" if
// "condition" is true.
// RTC_LOG_V(sev) Like RTC_LOG(), but sev is a run-time variable of the
// LoggingSeverity type (basically, it just doesn't prepend the namespace).
// RTC_LOG_F(sev) Like RTC_LOG(), but includes the name of the current function.
// RTC_LOG_IF_F(sev, condition), Like RTC_LOG_IF(), but includes the name of
// the current function.
// RTC_LOG_T(sev) Like RTC_LOG(), but includes the this pointer.
// RTC_LOG_T_F(sev) Like RTC_LOG_F(), but includes the this pointer.
// RTC_LOG_GLE(sev [, mod]) attempt to add a string description of the
@ -49,12 +53,15 @@
#include <atomic>
#include <sstream> // no-presubmit-check TODO(webrtc:8982)
#include <string>
#include <type_traits>
#include <utility>
#include "absl/base/attributes.h"
#include "absl/meta/type_traits.h"
#include "absl/strings/string_view.h"
#include "rtc_base/constructor_magic.h"
#include "rtc_base/deprecation.h"
#include "absl/types/optional.h"
#include "api/units/timestamp.h"
#include "rtc_base/platform_thread_types.h"
#include "rtc_base/strings/string_builder.h"
#include "rtc_base/system/inline.h"
@ -73,9 +80,7 @@
namespace rtc {
//////////////////////////////////////////////////////////////////////
// Note that the non-standard LoggingSeverity aliases exist because they are
// still in broad use. The meanings of the levels are:
// The meanings of the levels are:
// LS_VERBOSE: This level is for data which we do not want to appear in the
// normal debug log, but should appear in diagnostic logs.
// LS_INFO: Chatty level used in debugging for all sorts of things, the default
@ -89,9 +94,6 @@ enum LoggingSeverity {
LS_WARNING,
LS_ERROR,
LS_NONE,
INFO = LS_INFO,
WARNING = LS_WARNING,
LERROR = LS_ERROR
};
// LogErrorContext assists in interpreting the meaning of an error value.
@ -106,6 +108,50 @@ enum LogErrorContext {
};
class LogMessage;
// LogLineRef encapsulates all the information required to generate a log line.
// It is used both internally to LogMessage but also as a parameter to
// LogSink::OnLogMessage, allowing custom LogSinks to format the log in
// the most flexible way.
class LogLineRef {
public:
absl::string_view message() const { return message_; }
absl::string_view filename() const { return filename_; }
int line() const { return line_; }
absl::optional<PlatformThreadId> thread_id() const { return thread_id_; }
webrtc::Timestamp timestamp() const { return timestamp_; }
absl::string_view tag() const { return tag_; }
LoggingSeverity severity() const { return severity_; }
#if RTC_LOG_ENABLED()
std::string DefaultLogLine() const;
#else
std::string DefaultLogLine() const { return ""; }
#endif
private:
friend class LogMessage;
void set_message(std::string message) { message_ = std::move(message); }
void set_filename(absl::string_view filename) { filename_ = filename; }
void set_line(int line) { line_ = line; }
void set_thread_id(absl::optional<PlatformThreadId> thread_id) {
thread_id_ = thread_id;
}
void set_timestamp(webrtc::Timestamp timestamp) { timestamp_ = timestamp; }
void set_tag(absl::string_view tag) { tag_ = tag; }
void set_severity(LoggingSeverity severity) { severity_ = severity; }
std::string message_;
absl::string_view filename_;
int line_ = 0;
absl::optional<PlatformThreadId> thread_id_;
webrtc::Timestamp timestamp_ = webrtc::Timestamp::MinusInfinity();
// The default Android debug output tag.
absl::string_view tag_ = "libjingle";
// The severity level of this message
LoggingSeverity severity_;
};
// Virtual sink interface that can receive log messages.
class LogSink {
public:
@ -118,6 +164,14 @@ class LogSink {
LoggingSeverity severity);
virtual void OnLogMessage(const std::string& message) = 0;
virtual void OnLogMessage(absl::string_view msg,
LoggingSeverity severity,
const char* tag);
virtual void OnLogMessage(absl::string_view message,
LoggingSeverity severity);
virtual void OnLogMessage(absl::string_view message);
virtual void OnLogMessage(const LogLineRef& line);
private:
friend class ::rtc::LogMessage;
#if RTC_LOG_ENABLED()
@ -276,8 +330,15 @@ inline Val<LogArgType::kLogMetadataTag, LogMetadataTag> MakeVal(
template <typename T, class = void>
struct has_to_log_string : std::false_type {};
template <typename T>
struct has_to_log_string<T, decltype(ToLogString(std::declval<T>()))>
: std::true_type {};
struct has_to_log_string<T,
absl::enable_if_t<std::is_convertible<
decltype(ToLogString(std::declval<T>())),
std::string>::value>> : std::true_type {};
template <typename T, absl::enable_if_t<has_to_log_string<T>::value>* = nullptr>
ToStringVal MakeVal(const T& x) {
return {ToLogString(x)};
}
// Handle arbitrary types other than the above by falling back to stringstream.
// TODO(bugs.webrtc.org/9278): Get rid of this overload when callers don't need
@ -299,11 +360,6 @@ ToStringVal MakeVal(const T& x) {
return {os.str()};
}
template <typename T, absl::enable_if_t<has_to_log_string<T>::value>* = nullptr>
ToStringVal MakeVal(const T& x) {
return {ToLogString(x)};
}
#if RTC_LOG_ENABLED()
void Log(const LogArgType* fmt, ...);
#else
@ -431,16 +487,11 @@ class LogMessage {
#if defined(WEBRTC_ANDROID)
LogMessage(const char* file, int line, LoggingSeverity sev, const char* tag);
#endif
// DEPRECATED - DO NOT USE - PLEASE USE THE MACROS INSTEAD OF THE CLASS.
// Android code should use the 'const char*' version since tags are static
// and we want to avoid allocating a std::string copy per log line.
RTC_DEPRECATED
LogMessage(const char* file,
int line,
LoggingSeverity sev,
const std::string& tag);
~LogMessage();
LogMessage(const LogMessage&) = delete;
LogMessage& operator=(const LogMessage&) = delete;
void AddTag(const char* tag);
rtc::StringBuilder& stream();
// Returns the time at which this function was called for the first time.
@ -449,7 +500,7 @@ class LogMessage {
// which case the logging start time will be the time of the first LogMessage
// instance is created.
static int64_t LogStartTime();
// Returns the wall clock equivalent of |LogStartTime|, in seconds from the
// Returns the wall clock equivalent of `LogStartTime`, in seconds from the
// epoch.
static uint32_t WallClockStartTime();
// LogThreads: Display the thread identifier of the current thread
@ -463,14 +514,14 @@ class LogMessage {
// Sets whether logs will be directed to stderr in debug mode.
static void SetLogToStderr(bool log_to_stderr);
// Stream: Any non-blocking stream interface.
// Installs the |stream| to collect logs with severtiy |min_sev| or higher.
// |stream| must live until deinstalled by RemoveLogToStream.
// If |stream| is the first stream added to the system, we might miss some
// Installs the `stream` to collect logs with severtiy `min_sev` or higher.
// `stream` must live until deinstalled by RemoveLogToStream.
// If `stream` is the first stream added to the system, we might miss some
// early concurrent log statement happening from another thread happening near
// this instant.
static void AddLogToStream(LogSink* stream, LoggingSeverity min_sev);
// Removes the specified stream, without destroying it. When the method
// has completed, it's guaranteed that |stream| will receive no more logging
// has completed, it's guaranteed that `stream` will receive no more logging
// calls.
static void RemoveLogToStream(LogSink* stream);
// Returns the severity for the specified stream, of if none is specified,
@ -481,10 +532,10 @@ class LogMessage {
static int GetMinLogSeverity();
// Parses the provided parameter stream to configure the options above.
// Useful for configuring logging from the command line.
static void ConfigureLogging(const char* params);
// Checks the current global debug severity and if the |streams_| collection
// is empty. If |severity| is smaller than the global severity and if the
// |streams_| collection is empty, the LogMessage will be considered a noop
static void ConfigureLogging(absl::string_view params);
// Checks the current global debug severity and if the `streams_` collection
// is empty. If `severity` is smaller than the global severity and if the
// `streams_` collection is empty, the LogMessage will be considered a noop
// LogMessage.
static bool IsNoop(LoggingSeverity severity);
// Version of IsNoop that uses fewer instructions at the call site, since the
@ -505,14 +556,6 @@ class LogMessage {
LogMessage(const char* file, int line, LoggingSeverity sev, const char* tag) {
}
#endif
// DEPRECATED - DO NOT USE - PLEASE USE THE MACROS INSTEAD OF THE CLASS.
// Android code should use the 'const char*' version since tags are static
// and we want to avoid allocating a std::string copy per log line.
RTC_DEPRECATED
LogMessage(const char* file,
int line,
LoggingSeverity sev,
const std::string& tag) {}
~LogMessage() = default;
inline void AddTag(const char* tag) {}
@ -530,7 +573,7 @@ class LogMessage {
inline static void RemoveLogToStream(LogSink* stream) {}
inline static int GetLogToStream(LogSink* stream = nullptr) { return 0; }
inline static int GetMinLogSeverity() { return 0; }
inline static void ConfigureLogging(const char* params) {}
inline static void ConfigureLogging(absl::string_view params) {}
static constexpr bool IsNoop(LoggingSeverity severity) { return true; }
template <LoggingSeverity S>
static constexpr bool IsNoop() {
@ -545,26 +588,14 @@ class LogMessage {
// Updates min_sev_ appropriately when debug sinks change.
static void UpdateMinLogSeverity();
// These write out the actual log messages.
#if defined(WEBRTC_ANDROID)
static void OutputToDebug(const std::string& msg,
LoggingSeverity severity,
const char* tag);
#else
static void OutputToDebug(const std::string& msg, LoggingSeverity severity);
#endif // defined(WEBRTC_ANDROID)
// This writes out the actual log messages.
static void OutputToDebug(const LogLineRef& log_line_ref);
// Called from the dtor (or from a test) to append optional extra error
// information to the log stream and a newline character.
void FinishPrintStream();
// The severity level of this message
LoggingSeverity severity_;
#if defined(WEBRTC_ANDROID)
// The default Android debug output tag.
const char* tag_ = "libjingle";
#endif
LogLineRef log_line_;
// String data generated in the constructor, that should be appended to
// the message before output.
@ -573,14 +604,15 @@ class LogMessage {
// The output streams and their associated severities
static LogSink* streams_;
// Holds true with high probability if |streams_| is empty, false with high
// Holds true with high probability if `streams_` is empty, false with high
// probability otherwise. Operated on with std::memory_order_relaxed because
// it's ok to lose or log some additional statements near the instant streams
// are added/removed.
static std::atomic<bool> streams_empty_;
// Flags for formatting options
static bool thread_, timestamp_;
// Flags for formatting options and their potential values.
static bool log_thread_;
static bool log_timestamp_;
// Determines if logs will be directed to stderr in debug mode.
static bool log_to_stderr_;
@ -588,11 +620,15 @@ class LogMessage {
// Next methods do nothing; no one will call these functions.
inline static void UpdateMinLogSeverity() {}
#if defined(WEBRTC_ANDROID)
inline static void OutputToDebug(const std::string& msg,
inline static void OutputToDebug(absl::string_view filename,
int line,
absl::string_view msg,
LoggingSeverity severity,
const char* tag) {}
#else
inline static void OutputToDebug(const std::string& msg,
inline static void OutputToDebug(absl::string_view filename,
int line,
absl::string_view msg,
LoggingSeverity severity) {}
#endif // defined(WEBRTC_ANDROID)
inline void FinishPrintStream() {}
@ -600,8 +636,6 @@ class LogMessage {
// The stringbuilder that buffers the formatted message before output
rtc::StringBuilder print_stream_;
RTC_DISALLOW_COPY_AND_ASSIGN(LogMessage);
};
//////////////////////////////////////////////////////////////////////
@ -613,21 +647,29 @@ class LogMessage {
::rtc::webrtc_logging_impl::LogStreamer<>() \
<< ::rtc::webrtc_logging_impl::LogMetadata(file, line, sev)
#define RTC_LOG(sev) \
!rtc::LogMessage::IsNoop<::rtc::sev>() && \
#define RTC_LOG(sev) \
!::rtc::LogMessage::IsNoop<::rtc::sev>() && \
RTC_LOG_FILE_LINE(::rtc::sev, __FILE__, __LINE__)
#define RTC_LOG_IF(sev, condition) \
!::rtc::LogMessage::IsNoop<::rtc::sev>() && (condition) && \
RTC_LOG_FILE_LINE(::rtc::sev, __FILE__, __LINE__)
// The _V version is for when a variable is passed in.
#define RTC_LOG_V(sev) \
!rtc::LogMessage::IsNoop(sev) && RTC_LOG_FILE_LINE(sev, __FILE__, __LINE__)
!::rtc::LogMessage::IsNoop(sev) && RTC_LOG_FILE_LINE(sev, __FILE__, __LINE__)
// The _F version prefixes the message with the current function name.
#if (defined(__GNUC__) && !defined(NDEBUG)) || defined(WANT_PRETTY_LOG_F)
#define RTC_LOG_F(sev) RTC_LOG(sev) << __PRETTY_FUNCTION__ << ": "
#define RTC_LOG_IF_F(sev, condition) \
RTC_LOG_IF(sev, condition) << __PRETTY_FUNCTION__ << ": "
#define RTC_LOG_T_F(sev) \
RTC_LOG(sev) << this << ": " << __PRETTY_FUNCTION__ << ": "
#else
#define RTC_LOG_F(sev) RTC_LOG(sev) << __FUNCTION__ << ": "
#define RTC_LOG_IF_F(sev, condition) \
RTC_LOG_IF(sev, condition) << __FUNCTION__ << ": "
#define RTC_LOG_T_F(sev) RTC_LOG(sev) << this << ": " << __FUNCTION__ << ": "
#endif
@ -639,7 +681,7 @@ inline bool LogCheckLevel(LoggingSeverity sev) {
}
#define RTC_LOG_E(sev, ctx, err) \
!rtc::LogMessage::IsNoop<::rtc::sev>() && \
!::rtc::LogMessage::IsNoop<::rtc::sev>() && \
::rtc::webrtc_logging_impl::LogCall() & \
::rtc::webrtc_logging_impl::LogStreamer<>() \
<< ::rtc::webrtc_logging_impl::LogMetadataErr { \
@ -677,7 +719,7 @@ inline const char* AdaptString(const std::string& str) {
} // namespace webrtc_logging_impl
#define RTC_LOG_TAG(sev, tag) \
!rtc::LogMessage::IsNoop(sev) && \
!::rtc::LogMessage::IsNoop(sev) && \
::rtc::webrtc_logging_impl::LogCall() & \
::rtc::webrtc_logging_impl::LogStreamer<>() \
<< ::rtc::webrtc_logging_impl::LogMetadataTag { \
@ -695,16 +737,20 @@ inline const char* AdaptString(const std::string& str) {
// they only generate code in debug builds.
#if RTC_DLOG_IS_ON
#define RTC_DLOG(sev) RTC_LOG(sev)
#define RTC_DLOG_IF(sev, condition) RTC_LOG_IF(sev, condition)
#define RTC_DLOG_V(sev) RTC_LOG_V(sev)
#define RTC_DLOG_F(sev) RTC_LOG_F(sev)
#define RTC_DLOG_IF_F(sev, condition) RTC_LOG_IF_F(sev, condition)
#else
#define RTC_DLOG_EAT_STREAM_PARAMS() \
while (false) \
::rtc::webrtc_logging_impl::LogMessageVoidify() & \
(::rtc::webrtc_logging_impl::LogStreamer<>())
#define RTC_DLOG(sev) RTC_DLOG_EAT_STREAM_PARAMS()
#define RTC_DLOG_IF(sev, condition) RTC_DLOG_EAT_STREAM_PARAMS()
#define RTC_DLOG_V(sev) RTC_DLOG_EAT_STREAM_PARAMS()
#define RTC_DLOG_F(sev) RTC_DLOG_EAT_STREAM_PARAMS()
#define RTC_DLOG_IF_F(sev, condition) RTC_DLOG_EAT_STREAM_PARAMS()
#endif
} // namespace rtc