forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathecho_information.cc
66 lines (52 loc) · 2.09 KB
/
echo_information.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/webrtc/echo_information.h"
#include "base/metrics/histogram_macros.h"
#include "third_party/webrtc/modules/audio_processing/include/audio_processing.h"
namespace media {
EchoInformation::EchoInformation()
: divergent_filter_stats_time_ms_(0),
num_divergent_filter_fraction_(0),
num_non_zero_divergent_filter_fraction_(0) {}
EchoInformation::~EchoInformation() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
ReportAndResetAecDivergentFilterStats();
}
void EchoInformation::UpdateAecStats(
const webrtc::AudioProcessingStats& audio_processing_stats) {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
if (!audio_processing_stats.divergent_filter_fraction) {
return;
}
divergent_filter_stats_time_ms_ += webrtc::AudioProcessing::kChunkSizeMs;
if (divergent_filter_stats_time_ms_ <
100 * webrtc::AudioProcessing::kChunkSizeMs) { // 1 second
return;
}
double divergent_filter_fraction =
*audio_processing_stats.divergent_filter_fraction;
// If not yet calculated, |metrics.divergent_filter_fraction| is -1.0. After
// being calculated the first time, it is updated periodically.
if (divergent_filter_fraction < 0.0f) {
DCHECK_EQ(num_divergent_filter_fraction_, 0);
return;
}
if (divergent_filter_fraction > 0.0f) {
++num_non_zero_divergent_filter_fraction_;
}
++num_divergent_filter_fraction_;
divergent_filter_stats_time_ms_ = 0;
}
void EchoInformation::ReportAndResetAecDivergentFilterStats() {
DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
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.AecFilterHasDivergence", non_zero_percent);
divergent_filter_stats_time_ms_ = 0;
num_non_zero_divergent_filter_fraction_ = 0;
num_divergent_filter_fraction_ = 0;
}
} // namespace media