Chromium Code Reviews| Index: content/renderer/media/media_stream_audio_processor_options.cc |
| diff --git a/content/renderer/media/media_stream_audio_processor_options.cc b/content/renderer/media/media_stream_audio_processor_options.cc |
| index 83831909728e46cf403408b22afcc963a4a376e6..3cf206e51e6358e2497e8235d5ae071795101e31 100644 |
| --- a/content/renderer/media/media_stream_audio_processor_options.cc |
| +++ b/content/renderer/media/media_stream_audio_processor_options.cc |
| @@ -300,11 +300,16 @@ std::string MediaAudioConstraints::GetGoogArrayGeometry() const { |
| } |
| EchoInformation::EchoInformation() |
| - : num_chunks_(0), echo_frames_received_(false) { |
| + : chunks_for_delay_stats_(0), |
| + echo_frames_received_(false), |
| + chunks_for_divergent_filter_stats_(0), |
| + num_divergent_filter_fraction_(0), |
| + num_non_zero_divergent_filter_fraction_(0) {} |
| + |
| +EchoInformation::~EchoInformation() { |
| + ReportAndResetAecDivergentFilterStats(); |
| } |
| -EchoInformation::~EchoInformation() {} |
| - |
| void EchoInformation::UpdateAecDelayStats( |
| webrtc::EchoCancellation* echo_cancellation) { |
| // Only start collecting stats if we know echo cancellation has measured an |
| @@ -325,17 +330,16 @@ void EchoInformation::UpdateAecDelayStats( |
| return; |
| } |
| - num_chunks_++; |
| - if (num_chunks_ < kNumChunksInFiveSeconds) { |
| + ++chunks_for_delay_stats_; |
| + if (chunks_for_delay_stats_ < kNumChunksInFiveSeconds) |
| return; |
| - } |
| int dummy_median = 0, dummy_std = 0; |
| float fraction_poor_delays = 0; |
| if (echo_cancellation->GetDelayMetrics( |
| &dummy_median, &dummy_std, &fraction_poor_delays) == |
| webrtc::AudioProcessing::kNoError) { |
| - num_chunks_ = 0; |
| + chunks_for_delay_stats_ = 0; |
| // Map |fraction_poor_delays| to an Echo Cancellation quality and log in UMA |
| // histogram. See DelayBasedEchoQuality for information on histogram |
| // buckets. |
| @@ -345,6 +349,51 @@ void EchoInformation::UpdateAecDelayStats( |
| } |
| } |
| +void EchoInformation::UpdateAecDivergentFilterStats( |
| + webrtc::EchoCancellation* echo_cancellation) { |
| + if (!echo_cancellation->is_enabled() || |
| + !echo_cancellation->are_metrics_enabled()) { |
| + return; |
| + } |
| + |
| + const int kNumChunksInOneSecond = 100; |
|
minyue
2016/06/28 08:18:41
kNumChunksInOneSecond and kNumChunksInFiveSeconds
Henrik Grunell
2016/06/28 09:33:10
Using time and kChunkDurationMs.
|
| + ++chunks_for_divergent_filter_stats_; |
| + if (chunks_for_divergent_filter_stats_ < kNumChunksInOneSecond) |
| + return; |
| + |
| + webrtc::EchoCancellation::Metrics metrics; |
| + if (echo_cancellation->GetMetrics(&metrics) == |
| + webrtc::AudioProcessing::kNoError) { |
| + // If not yet calculated, |metrics.divergent_filter_fraction| is -1.0. After |
| + // being calculated the first time, it is updated periodically. |
| + if (metrics.divergent_filter_fraction < 0.0f) { |
| + DCHECK_EQ(num_divergent_filter_fraction_, 0); |
| + return; |
| + } |
| + if (metrics.divergent_filter_fraction > 0.0f) { |
| + ++num_non_zero_divergent_filter_fraction_; |
| + } |
| + } else { |
| + DLOG(WARNING) << "Get echo cancellation metrics failed."; |
| + } |
| + ++num_divergent_filter_fraction_; |
| + chunks_for_divergent_filter_stats_ = 0; |
| +} |
| + |
| +void EchoInformation::ReportAndResetAecDivergentFilterStats() { |
| + if (num_divergent_filter_fraction_ == 0) |
| + return; |
| + |
| + int non_zero_percent = 100 * num_non_zero_divergent_filter_fraction_ / |
| + num_divergent_filter_fraction_; |
| + UMA_HISTOGRAM_PERCENTAGE("WebRTC.AecDivergentFilterNonZeroPeriods", |
| + non_zero_percent); |
| + |
| + chunks_for_divergent_filter_stats_ = 0; |
| + num_non_zero_divergent_filter_fraction_ = 0; |
| + num_divergent_filter_fraction_ = 0; |
| +} |
| + |
| void EnableEchoCancellation(AudioProcessing* audio_processing) { |
| #if defined(OS_ANDROID) |
| // Mobile devices are using AECM. |