aboutsummaryrefslogtreecommitdiff
path: root/modules/audio_mixer
diff options
context:
space:
mode:
authorAlex Loiko <aleloi@webrtc.org>2018-03-14 12:27:05 +0100
committerCommit Bot <commit-bot@chromium.org>2018-03-15 10:51:06 +0000
commit6f2fcb4962e9488e0c251c9315c5f2a5480acdde (patch)
treedcc60ec02e7ac194104d4baaf0d83582e4e022bf /modules/audio_mixer
parentaaa882cea5dc42532e44d8ed9b1eaeb064a249a1 (diff)
downloadwebrtc-6f2fcb4962e9488e0c251c9315c5f2a5480acdde.tar.gz
Add more Audio Mixer and Fixed Gain Controller metrics.
We want to know how the AudioMixer is used and how FixedGainController behaves. The WebRTC.Audio.Agc2.FixedDigitalGainCurveRegion.* metrics measures how often the input level hits different regions of the Fixed Gain Controller gain curve (when the limiter is enabled). They also measure how long the metrics stay in different regions. They are related to WebRTC.Audio.ApmCaptureOutputLevelPeakRms, but the new metrics measure the level before any processing done in APM. The AudioMixer mixes incoming audio streams. Their number should be mostly constant, and often some of them could be muted. The metrics WebRTC.Audio.AudioMixer.NumIncomingStreams, WebRTC.Audio.AudioMixer.NumIncomingActiveStreams log the number of incoming stream and how many are not muted. We currently don't have any stats related to that. The metric WebRTC.Audio.AudioMixer.MixingRate logs the rate selected for mixing. The rate can sometimes be inferred from WebRTC.Audio.Encoder.CodecType. But that metric measures encoding and not decoding, and codecs don't always map to rates. See also accompanying Chromium CL https://chromium-review.googlesource.com/c/chromium/src/+/939473 Bug: webrtc:8925 Change-Id: Ib1405877fc1b39e5d2f0ceccba04434813f20b0d Reviewed-on: https://webrtc-review.googlesource.com/57740 Reviewed-by: Alessio Bazzica <alessiob@webrtc.org> Commit-Queue: Alex Loiko <aleloi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22443}
Diffstat (limited to 'modules/audio_mixer')
-rw-r--r--modules/audio_mixer/BUILD.gn1
-rw-r--r--modules/audio_mixer/frame_combiner.cc32
-rw-r--r--modules/audio_mixer/frame_combiner.h5
3 files changed, 38 insertions, 0 deletions
diff --git a/modules/audio_mixer/BUILD.gn b/modules/audio_mixer/BUILD.gn
index 644c8ab265..8cb4bfb60e 100644
--- a/modules/audio_mixer/BUILD.gn
+++ b/modules/audio_mixer/BUILD.gn
@@ -47,6 +47,7 @@ rtc_static_library("audio_mixer_impl") {
"../../rtc_base:rtc_base_approved",
"../../system_wrappers",
"../../system_wrappers:field_trial_api",
+ "../../system_wrappers:metrics_api",
"../audio_processing",
"../audio_processing:apm_logging",
"../audio_processing:audio_frame_view",
diff --git a/modules/audio_mixer/frame_combiner.cc b/modules/audio_mixer/frame_combiner.cc
index faca0908ae..2c83e2e0b7 100644
--- a/modules/audio_mixer/frame_combiner.cc
+++ b/modules/audio_mixer/frame_combiner.cc
@@ -20,8 +20,10 @@
#include "modules/audio_mixer/audio_frame_manipulator.h"
#include "modules/audio_mixer/audio_mixer_impl.h"
#include "modules/audio_processing/logging/apm_data_dumper.h"
+#include "rtc_base/arraysize.h"
#include "rtc_base/checks.h"
#include "rtc_base/logging.h"
+#include "system_wrappers/include/metrics.h"
namespace webrtc {
namespace {
@@ -253,6 +255,36 @@ void FrameCombiner::Combine(const std::vector<AudioFrame*>& mix_list,
}
InterleaveToAudioFrame(mixing_buffer_view, audio_frame_for_mixing);
+
+ LogMixingStats(mix_list, sample_rate, number_of_streams);
+}
+
+void FrameCombiner::LogMixingStats(const std::vector<AudioFrame*>& mix_list,
+ int sample_rate,
+ size_t number_of_streams) const {
+ // Log every second.
+ uma_logging_counter_++;
+ if (uma_logging_counter_ > 1000 / AudioMixerImpl::kFrameDurationInMs) {
+ uma_logging_counter_ = 0;
+ RTC_HISTOGRAM_COUNTS_100("WebRTC.Audio.AudioMixer.NumIncomingStreams",
+ static_cast<int>(number_of_streams));
+ RTC_HISTOGRAM_ENUMERATION(
+ "WebRTC.Audio.AudioMixer.NumIncomingActiveStreams",
+ static_cast<int>(mix_list.size()),
+ AudioMixerImpl::kMaximumAmountOfMixedAudioSources);
+
+ using NativeRate = AudioProcessing::NativeRate;
+ static constexpr NativeRate native_rates[] = {
+ NativeRate::kSampleRate8kHz, NativeRate::kSampleRate16kHz,
+ NativeRate::kSampleRate32kHz, NativeRate::kSampleRate48kHz};
+ const auto* rate_position = std::lower_bound(
+ std::begin(native_rates), std::end(native_rates), sample_rate);
+
+ RTC_HISTOGRAM_ENUMERATION(
+ "WebRTC.Audio.AudioMixer.MixingRate",
+ std::distance(std::begin(native_rates), rate_position),
+ arraysize(native_rates));
+ }
}
} // namespace webrtc
diff --git a/modules/audio_mixer/frame_combiner.h b/modules/audio_mixer/frame_combiner.h
index 3d43128d6a..14257d27dd 100644
--- a/modules/audio_mixer/frame_combiner.h
+++ b/modules/audio_mixer/frame_combiner.h
@@ -44,10 +44,15 @@ class FrameCombiner {
AudioFrame* audio_frame_for_mixing);
private:
+ void LogMixingStats(const std::vector<AudioFrame*>& mix_list,
+ int sample_rate,
+ size_t number_of_streams) const;
+
LimiterType limiter_type_;
std::unique_ptr<AudioProcessing> apm_agc_limiter_;
std::unique_ptr<ApmDataDumper> data_dumper_;
FixedGainController apm_agc2_limiter_;
+ mutable int uma_logging_counter_ = 0;
};
} // namespace webrtc