Chromium Code Reviews| Index: webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.cc |
| diff --git a/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.cc b/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..417c984cabba1bdc30194d7d437c51c62cd05688 |
| --- /dev/null |
| +++ b/webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.cc |
| @@ -0,0 +1,94 @@ |
| +/* |
| + * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
| + * |
| + * Use of this source code is governed by a BSD-style license |
| + * that can be found in the LICENSE file in the root of the source |
| + * tree. An additional intellectual property rights grant can be found |
| + * in the file PATENTS. All contributing project authors may |
| + * be found in the AUTHORS file in the root of the source tree. |
| + */ |
| + |
| +#include "webrtc/modules/audio_processing/aec3/render_delay_controller_metrics.h" |
| + |
| +#include <algorithm> |
| + |
| +#include "webrtc/modules/audio_processing/aec3/aec3_common.h" |
| +#include "webrtc/system_wrappers/include/metrics.h" |
| + |
| +namespace webrtc { |
| + |
| +RenderDelayControllerMetrics::RenderDelayControllerMetrics() { |
| + ResetMetrics(); |
|
hlundin-webrtc
2017/02/28 10:04:23
No need.
peah-webrtc
2017/02/28 12:57:26
Done.
|
| +} |
| + |
| +void RenderDelayControllerMetrics::ResetMetrics() { |
|
hlundin-webrtc
2017/02/28 10:04:23
Wrong order of methods.
peah-webrtc
2017/02/28 12:57:26
Done.
|
| + delay_change_counter_ = 0; |
| + reliable_delay_estimate_counter_ = 0; |
| +} |
| + |
| +void RenderDelayControllerMetrics::Update(rtc::Optional<size_t> delay_samples, |
| + size_t buffer_delay_blocks) { |
| + ++call_counter_; |
| + |
| + if (!initial_update) { |
| + if (delay_samples) { |
| + ++reliable_delay_estimate_counter_; |
| + size_t delay_blocks = (*delay_samples) / kBlockSize; |
| + |
| + if (delay_blocks != delay_blocks_) { |
| + ++delay_change_counter_; |
| + delay_blocks_ = delay_blocks; |
| + } |
| + } |
| + } else if (++initial_call_counter_ == 5 * 250) { |
| + initial_update = false; |
| + } |
| + |
| + if (call_counter_ == kMetricsReportingInterval) { |
| + int value_to_report = static_cast<int>(delay_blocks_); |
| + value_to_report = std::min(124, value_to_report); |
| + RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.Audio.EchoCanceller.EchoPathDelay", |
| + value_to_report, 0, 124, 125); |
| + |
| + value_to_report = static_cast<int>(buffer_delay_blocks); |
| + value_to_report = std::min(124, value_to_report); |
| + RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.Audio.EchoCanceller.BufferDelay", |
| + value_to_report, 0, 124, 125); |
| + |
| + if (reliable_delay_estimate_counter_ == 0) { |
| + value_to_report = 0; |
|
hlundin-webrtc
2017/02/28 10:04:23
Again, some kind of enum?
peah-webrtc
2017/02/28 12:57:26
Done.
|
| + } else if (reliable_delay_estimate_counter_ > (call_counter_ >> 1)) { |
| + value_to_report = 4; |
| + } else if (reliable_delay_estimate_counter_ > 100) { |
| + value_to_report = 3; |
| + } else if (reliable_delay_estimate_counter_ > 10) { |
| + value_to_report = 2; |
| + } else { |
| + value_to_report = 1; |
| + } |
| + RTC_HISTOGRAM_COUNTS_LINEAR( |
|
hlundin-webrtc
2017/02/28 10:04:23
RTC_HISTOGRAM_ENUMERATION
peah-webrtc
2017/02/28 12:57:26
Done.
|
| + "WebRTC.Audio.EchoCanceller.ReliableDelayEstimates", value_to_report, 0, |
| + 4, 5); |
| + |
| + if (delay_change_counter_ == 0) { |
| + value_to_report = 0; |
| + } else if (delay_change_counter_ > 10) { |
| + value_to_report = 4; |
| + } else if (delay_change_counter_ > 5) { |
| + value_to_report = 3; |
| + } else if (delay_change_counter_ > 2) { |
| + value_to_report = 2; |
| + } else { |
| + value_to_report = 1; |
| + } |
| + RTC_HISTOGRAM_COUNTS_LINEAR("WebRTC.Audio.EchoCanceller.DelayChanges", |
|
hlundin-webrtc
2017/02/28 10:04:23
RTC_HISTOGRAM_ENUMERATION
peah-webrtc
2017/02/28 12:57:26
Done.
|
| + value_to_report, 0, 4, 5); |
| + |
| + metric_reported_ = true; |
| + call_counter_ = 0; |
| + } else { |
| + metric_reported_ = false; |
| + } |
| +} |
| + |
| +} // namespace webrtc |