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

@ -13,12 +13,14 @@
#include <stddef.h>
#include <atomic>
#include <map>
#include <memory>
#include <string>
#include "rtc_base/atomic_ops.h"
#include "absl/strings/string_view.h"
#include "rtc_base/checks.h"
#include "rtc_base/string_utils.h"
#if defined(RTC_DISABLE_METRICS)
#define RTC_METRICS_ENABLED 0
@ -30,8 +32,8 @@ namespace webrtc {
namespace metrics_impl {
template <typename... Ts>
void NoOp(const Ts&...) {}
}
}
} // namespace metrics_impl
} // namespace webrtc
#if RTC_METRICS_ENABLED
#define EXPECT_METRIC_EQ(val1, val2) EXPECT_EQ(val1, val2)
@ -44,12 +46,16 @@ void NoOp(const Ts&...) {}
#define EXPECT_METRIC_THAT(value, matcher) EXPECT_THAT(value, matcher)
#else
#define EXPECT_METRIC_EQ(val1, val2) webrtc::metrics_impl::NoOp(val1, val2)
#define EXPECT_METRIC_EQ_WAIT(val1, val2, timeout) webrtc::metrics_impl::NoOp(val1, val2, timeout)
#define EXPECT_METRIC_EQ_WAIT(val1, val2, timeout) \
webrtc::metrics_impl::NoOp(val1, val2, timeout)
#define EXPECT_METRIC_GT(val1, val2) webrtc::metrics_impl::NoOp(val1, val2)
#define EXPECT_METRIC_LE(val1, val2) webrtc::metrics_impl::NoOp(val1, val2)
#define EXPECT_METRIC_TRUE(condition) webrtc::metrics_impl::NoOp(condition || true)
#define EXPECT_METRIC_FALSE(condition) webrtc::metrics_impl::NoOp(condition && false)
#define EXPECT_METRIC_THAT(value, matcher) webrtc::metrics_impl::NoOp(value, testing::_)
#define EXPECT_METRIC_TRUE(condition) \
webrtc::metrics_impl::NoOp(condition || true)
#define EXPECT_METRIC_FALSE(condition) \
webrtc::metrics_impl::NoOp(condition && false)
#define EXPECT_METRIC_THAT(value, matcher) \
webrtc::metrics_impl::NoOp(value, testing::_)
#endif
#if RTC_METRICS_ENABLED
@ -76,12 +82,12 @@ void NoOp(const Ts&...) {}
// by setting the GN arg rtc_exclude_metrics_default to true).
// 2. Provide implementations of:
// Histogram* webrtc::metrics::HistogramFactoryGetCounts(
// const std::string& name, int sample, int min, int max,
// absl::string_view name, int sample, int min, int max,
// int bucket_count);
// Histogram* webrtc::metrics::HistogramFactoryGetEnumeration(
// const std::string& name, int sample, int boundary);
// absl::string_view name, int sample, int boundary);
// void webrtc::metrics::HistogramAdd(
// Histogram* histogram_pointer, const std::string& name, int sample);
// Histogram* histogram_pointer, absl::string_view name, int sample);
//
// Example usage:
//
@ -163,7 +169,7 @@ void NoOp(const Ts&...) {}
RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, 2)
// Histogram for enumerators (evenly spaced buckets).
// |boundary| should be above the max enumerator sample.
// `boundary` should be above the max enumerator sample.
//
// TODO(qingsi): Refactor the default implementation given by RtcHistogram,
// which is already sparse, and remove the boundary argument from the macro.
@ -181,33 +187,29 @@ void NoOp(const Ts&...) {}
RTC_HISTOGRAM_ENUMERATION(name, sample, 2)
// Histogram for enumerators (evenly spaced buckets).
// |boundary| should be above the max enumerator sample.
// `boundary` should be above the max enumerator sample.
#define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \
RTC_HISTOGRAM_COMMON_BLOCK_SLOW( \
name, sample, \
webrtc::metrics::HistogramFactoryGetEnumeration(name, boundary))
// The name of the histogram should not vary.
// TODO(asapersson): Consider changing string to const char*.
#define RTC_HISTOGRAM_COMMON_BLOCK(constant_name, sample, \
factory_get_invocation) \
do { \
static webrtc::metrics::Histogram* atomic_histogram_pointer = nullptr; \
webrtc::metrics::Histogram* histogram_pointer = \
rtc::AtomicOps::AcquireLoadPtr(&atomic_histogram_pointer); \
if (!histogram_pointer) { \
histogram_pointer = factory_get_invocation; \
webrtc::metrics::Histogram* prev_pointer = \
rtc::AtomicOps::CompareAndSwapPtr( \
&atomic_histogram_pointer, \
static_cast<webrtc::metrics::Histogram*>(nullptr), \
histogram_pointer); \
RTC_DCHECK(prev_pointer == nullptr || \
prev_pointer == histogram_pointer); \
} \
if (histogram_pointer) { \
webrtc::metrics::HistogramAdd(histogram_pointer, sample); \
} \
#define RTC_HISTOGRAM_COMMON_BLOCK(constant_name, sample, \
factory_get_invocation) \
do { \
static std::atomic<webrtc::metrics::Histogram*> atomic_histogram_pointer( \
nullptr); \
webrtc::metrics::Histogram* histogram_pointer = \
atomic_histogram_pointer.load(std::memory_order_acquire); \
if (!histogram_pointer) { \
histogram_pointer = factory_get_invocation; \
webrtc::metrics::Histogram* null_histogram = nullptr; \
atomic_histogram_pointer.compare_exchange_strong(null_histogram, \
histogram_pointer); \
} \
if (histogram_pointer) { \
webrtc::metrics::HistogramAdd(histogram_pointer, sample); \
} \
} while (0)
// The histogram is constructed/found for each call.
@ -223,7 +225,7 @@ void NoOp(const Ts&...) {}
// Helper macros.
// Macros for calling a histogram with varying name (e.g. when using a metric
// in different modes such as real-time vs screenshare). Fast, because pointer
// is cached. |index| should be different for different names. Allowed |index|
// is cached. `index` should be different for different names. Allowed `index`
// values are 0, 1, and 2.
#define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) \
RTC_HISTOGRAMS_COMMON(index, name, sample, \
@ -270,7 +272,7 @@ void NoOp(const Ts&...) {}
macro_invocation; \
break; \
default: \
RTC_NOTREACHED(); \
RTC_DCHECK_NOTREACHED(); \
} \
} while (0)
@ -280,17 +282,23 @@ void NoOp(const Ts&...) {}
// This section defines no-op alternatives to the metrics macros when
// RTC_METRICS_ENABLED is defined.
#define RTC_HISTOGRAM_COUNTS_100(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_100(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_200(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_200(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_500(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_500(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_1000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_1000(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_10000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_10000(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_100000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_100000(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS(name, sample, min, max, bucket_count) \
webrtc::metrics_impl::NoOp(name, sample, min, max, bucket_count)
@ -298,31 +306,41 @@ void NoOp(const Ts&...) {}
#define RTC_HISTOGRAM_COUNTS_LINEAR(name, sample, min, max, bucket_count) \
webrtc::metrics_impl::NoOp(name, sample, min, max, bucket_count)
#define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_100(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_200(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_200(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_500(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_500(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_1000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_1000(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_10000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_10000(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_100000(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE_100000(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_COUNTS_SPARSE(name, sample, min, max, bucket_count) \
webrtc::metrics_impl::NoOp(name, sample, min, max, bucket_count)
#define RTC_HISTOGRAM_PERCENTAGE_SPARSE(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_PERCENTAGE_SPARSE(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_BOOLEAN_SPARSE(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_BOOLEAN_SPARSE(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_ENUMERATION_SPARSE(name, sample, boundary) \
webrtc::metrics_impl::NoOp(name, sample, boundary)
#define RTC_HISTOGRAM_PERCENTAGE(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_PERCENTAGE(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_BOOLEAN(name, sample) webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_BOOLEAN(name, sample) \
webrtc::metrics_impl::NoOp(name, sample)
#define RTC_HISTOGRAM_ENUMERATION(name, sample, boundary) \
webrtc::metrics_impl::NoOp(name, sample, boundary)
@ -334,11 +352,14 @@ void NoOp(const Ts&...) {}
#define RTC_HISTOGRAM_COMMON_BLOCK_SLOW(name, sample, factory_get_invocation) \
webrtc::metrics_impl::NoOp(name, sample, factory_get_invocation)
#define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_100(index, name, sample) \
webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_200(index, name, sample) \
webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_500(index, name, sample) webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_500(index, name, sample) \
webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COUNTS_1000(index, name, sample) \
webrtc::metrics_impl::NoOp(index, name, sample)
@ -352,7 +373,8 @@ void NoOp(const Ts&...) {}
#define RTC_HISTOGRAMS_ENUMERATION(index, name, sample, boundary) \
webrtc::metrics_impl::NoOp(index, name, sample, boundary)
#define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_PERCENTAGE(index, name, sample) \
webrtc::metrics_impl::NoOp(index, name, sample)
#define RTC_HISTOGRAMS_COMMON(index, name, sample, macro_invocation) \
webrtc::metrics_impl::NoOp(index, name, sample, macro_invocation)
@ -363,7 +385,7 @@ namespace webrtc {
namespace metrics {
// Time that should have elapsed for stats that are gathered once per call.
enum { kMinRunTimeInSeconds = 10 };
constexpr int kMinRunTimeInSeconds = 10;
class Histogram;
@ -371,32 +393,31 @@ class Histogram;
// histogram).
// Get histogram for counters.
Histogram* HistogramFactoryGetCounts(const std::string& name,
Histogram* HistogramFactoryGetCounts(absl::string_view name,
int min,
int max,
int bucket_count);
// Get histogram for counters with linear bucket spacing.
Histogram* HistogramFactoryGetCountsLinear(const std::string& name,
Histogram* HistogramFactoryGetCountsLinear(absl::string_view name,
int min,
int max,
int bucket_count);
// Get histogram for enumerators.
// |boundary| should be above the max enumerator sample.
Histogram* HistogramFactoryGetEnumeration(const std::string& name,
int boundary);
// `boundary` should be above the max enumerator sample.
Histogram* HistogramFactoryGetEnumeration(absl::string_view name, int boundary);
// Get sparse histogram for enumerators.
// |boundary| should be above the max enumerator sample.
Histogram* SparseHistogramFactoryGetEnumeration(const std::string& name,
// `boundary` should be above the max enumerator sample.
Histogram* SparseHistogramFactoryGetEnumeration(absl::string_view name,
int boundary);
// Function for adding a |sample| to a histogram.
// Function for adding a `sample` to a histogram.
void HistogramAdd(Histogram* histogram_pointer, int sample);
struct SampleInfo {
SampleInfo(const std::string& name, int min, int max, size_t bucket_count);
SampleInfo(absl::string_view name, int min, int max, size_t bucket_count);
~SampleInfo();
const std::string name;
@ -412,25 +433,26 @@ void Enable();
// Gets histograms and clears all samples.
void GetAndReset(
std::map<std::string, std::unique_ptr<SampleInfo>>* histograms);
std::map<std::string, std::unique_ptr<SampleInfo>, rtc::AbslStringViewCmp>*
histograms);
// Functions below are mainly for testing.
// Clears all samples.
void Reset();
// Returns the number of times the |sample| has been added to the histogram.
int NumEvents(const std::string& name, int sample);
// Returns the number of times the `sample` has been added to the histogram.
int NumEvents(absl::string_view name, int sample);
// Returns the total number of added samples to the histogram.
int NumSamples(const std::string& name);
int NumSamples(absl::string_view name);
// Returns the minimum sample value (or -1 if the histogram has no samples).
int MinSample(const std::string& name);
int MinSample(absl::string_view name);
// Returns a map with keys the samples with at least one event and values the
// number of events for that sample.
std::map<int, int> Samples(const std::string& name);
std::map<int, int> Samples(absl::string_view name);
} // namespace metrics
} // namespace webrtc