Commit 971f184b authored by bjornv's avatar bjornv Committed by Commit bot

Simplify WebRTC DelayMetrics query in MediaStreamAudioProcessor

As of webrtc roll https://chromium.googlesource.com/chromium/src/+/724ab4480d4af0c4a64752078a7cd5046782789c
a longer aggregation window is used and we can now match it to simplify the query.

BUG=450193
TESTED=locally on Mac

Review URL: https://codereview.chromium.org/982333002

Cr-Commit-Position: refs/heads/master@{#319564}
parent 0b7c0c44
...@@ -221,28 +221,25 @@ bool MediaAudioConstraints::GetDefaultValueForConstraint( ...@@ -221,28 +221,25 @@ bool MediaAudioConstraints::GetDefaultValueForConstraint(
} }
EchoInformation::EchoInformation() EchoInformation::EchoInformation()
: num_chunks_(0), : num_chunks_(0) {}
num_queries_(0),
echo_fraction_poor_delays_(0.0f) {}
EchoInformation::~EchoInformation() {} EchoInformation::~EchoInformation() {}
void EchoInformation::UpdateAecDelayStats( void EchoInformation::UpdateAecDelayStats(
webrtc::EchoCancellation* echo_cancellation) { webrtc::EchoCancellation* echo_cancellation) {
// In WebRTC, three echo delay metrics are calculated and updated every // In WebRTC, three echo delay metrics are calculated and updated every
// second. We use one of them, |fraction_poor_delays|, but aggregate over // five seconds. We use one of them, |fraction_poor_delays| to log in a UMA
// five seconds to log in a UMA histogram to monitor Echo Cancellation // histogram an Echo Cancellation quality metric. The stat in WebRTC has a
// quality. Since the stat in WebRTC has a fixed aggregation window of one // fixed aggregation window of five seconds, so we use the same query
// second we query the stat every second and average over five such queries. // frequency to avoid logging old values.
// WebRTC process audio in 10 ms chunks. const int kNumChunksInFiveSeconds = 500;
const int kNumChunksInOneSecond = 100;
if (!echo_cancellation->is_delay_logging_enabled() || if (!echo_cancellation->is_delay_logging_enabled() ||
!echo_cancellation->is_enabled()) { !echo_cancellation->is_enabled()) {
return; return;
} }
num_chunks_++; num_chunks_++;
if (num_chunks_ < kNumChunksInOneSecond) { if (num_chunks_ < kNumChunksInFiveSeconds) {
return; return;
} }
...@@ -251,30 +248,13 @@ void EchoInformation::UpdateAecDelayStats( ...@@ -251,30 +248,13 @@ void EchoInformation::UpdateAecDelayStats(
if (echo_cancellation->GetDelayMetrics( if (echo_cancellation->GetDelayMetrics(
&dummy_median, &dummy_std, &fraction_poor_delays) == &dummy_median, &dummy_std, &fraction_poor_delays) ==
webrtc::AudioProcessing::kNoError) { webrtc::AudioProcessing::kNoError) {
echo_fraction_poor_delays_ += fraction_poor_delays;
num_queries_++;
num_chunks_ = 0; num_chunks_ = 0;
} }
LogAecDelayStats(); // Map |fraction_poor_delays| to an Echo Cancellation quality and log in UMA
} // histogram. See DelayBasedEchoQuality for information on histogram buckets.
void EchoInformation::LogAecDelayStats() {
// We update the UMA statistics every 5 seconds.
const int kNumQueriesIn5Seconds = 5;
if (num_queries_ < kNumQueriesIn5Seconds) {
return;
}
// Calculate how frequent the AEC delay was out of bounds since last time we
// updated UMA histograms by averaging |echo_fraction_poor_delays_| over
// |num_queries_|. Then store the result into one of four histogram buckets;
// see DelayBasedEchoQuality.
float poor_delay_frequency = echo_fraction_poor_delays_ / num_queries_;
UMA_HISTOGRAM_ENUMERATION("WebRTC.AecDelayBasedQuality", UMA_HISTOGRAM_ENUMERATION("WebRTC.AecDelayBasedQuality",
EchoDelayFrequencyToQuality(poor_delay_frequency), EchoDelayFrequencyToQuality(fraction_poor_delays),
DELAY_BASED_ECHO_QUALITY_MAX); DELAY_BASED_ECHO_QUALITY_MAX);
num_queries_ = 0;
echo_fraction_poor_delays_ = 0.0f;
} }
void EnableEchoCancellation(AudioProcessing* audio_processing) { void EnableEchoCancellation(AudioProcessing* audio_processing) {
......
...@@ -97,14 +97,9 @@ class CONTENT_EXPORT EchoInformation { ...@@ -97,14 +97,9 @@ class CONTENT_EXPORT EchoInformation {
void UpdateAecDelayStats(webrtc::EchoCancellation* echo_cancellation); void UpdateAecDelayStats(webrtc::EchoCancellation* echo_cancellation);
private: private:
// Updates UMA histograms with an interval of 5 seconds. // Counter to track 5 seconds of processed 10 ms chunks in order to query a
void LogAecDelayStats(); // new metric from webrtc::EchoCancellation::GetEchoDelayMetrics().
// Counters to be able to aquire a 5 second aggregated metric out of 1 second
// aggregated webrtc::EchoCancellation::GetEchoDelayMetrics() queries.
int num_chunks_; int num_chunks_;
int num_queries_;
float echo_fraction_poor_delays_;
DISALLOW_COPY_AND_ASSIGN(EchoInformation); DISALLOW_COPY_AND_ASSIGN(EchoInformation);
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment