2017-02-28 22:08:53 -08:00
|
|
|
/*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_METRICS_H_
|
|
|
|
|
#define MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_METRICS_H_
|
2017-02-28 22:08:53 -08:00
|
|
|
|
2018-10-23 12:03:01 +02:00
|
|
|
#include <stddef.h>
|
|
|
|
|
|
2024-08-29 13:00:40 +00:00
|
|
|
#include <optional>
|
|
|
|
|
|
AEC3: Clockdrift detection
This change introduces a clockdrift detector operating on the estimated
delay of the echo path delay estimator. Each time the delay estimate
changes it is compared to previous estimates. If the estimates are
slowly increasing or decreasing, clockdrift is detected.
Four different patterns are considered clockdrift:
- k, k+1, k+2, k+3
- k, k+2, k+1, k+3
- k, k-1, k-2, k-3
- k, k-2, k-1, k-3
A delay estimate history matching the three last elements in one of the
patterns is considered probable clockdrift. Matching all four elements
is considered verified clockdrift.
If the delay is constant for some time after clockdrift is detected the
clockdrift detector will revert to no detected clockdrift.
The level of clockdrift is reported via an UMA histogram.
Bug: webrtc:10014
Change-Id: I1cce4d593e101a8b3fa99df6935e59b4243cb97a
Reviewed-on: https://webrtc-review.googlesource.com/c/111381
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25758}
2018-11-22 16:02:34 +01:00
|
|
|
#include "modules/audio_processing/aec3/clockdrift_detector.h"
|
2017-02-28 22:08:53 -08:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
|
|
|
|
// Handles the reporting of metrics for the render delay controller.
|
|
|
|
|
class RenderDelayControllerMetrics {
|
|
|
|
|
public:
|
2018-02-22 17:51:39 +01:00
|
|
|
RenderDelayControllerMetrics();
|
2017-02-28 22:08:53 -08:00
|
|
|
|
2022-01-21 09:49:39 +09:00
|
|
|
RenderDelayControllerMetrics(const RenderDelayControllerMetrics&) = delete;
|
|
|
|
|
RenderDelayControllerMetrics& operator=(const RenderDelayControllerMetrics&) =
|
|
|
|
|
delete;
|
|
|
|
|
|
2017-02-28 22:08:53 -08:00
|
|
|
// Updates the metric with new data.
|
2024-08-29 13:00:40 +00:00
|
|
|
void Update(std::optional<size_t> delay_samples,
|
|
|
|
|
std::optional<size_t> buffer_delay_blocks,
|
AEC3: Clockdrift detection
This change introduces a clockdrift detector operating on the estimated
delay of the echo path delay estimator. Each time the delay estimate
changes it is compared to previous estimates. If the estimates are
slowly increasing or decreasing, clockdrift is detected.
Four different patterns are considered clockdrift:
- k, k+1, k+2, k+3
- k, k+2, k+1, k+3
- k, k-1, k-2, k-3
- k, k-2, k-1, k-3
A delay estimate history matching the three last elements in one of the
patterns is considered probable clockdrift. Matching all four elements
is considered verified clockdrift.
If the delay is constant for some time after clockdrift is detected the
clockdrift detector will revert to no detected clockdrift.
The level of clockdrift is reported via an UMA histogram.
Bug: webrtc:10014
Change-Id: I1cce4d593e101a8b3fa99df6935e59b4243cb97a
Reviewed-on: https://webrtc-review.googlesource.com/c/111381
Commit-Queue: Gustaf Ullberg <gustaf@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25758}
2018-11-22 16:02:34 +01:00
|
|
|
ClockdriftDetector::Level clockdrift);
|
2017-02-28 22:08:53 -08:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// Resets the metrics.
|
|
|
|
|
void ResetMetrics();
|
|
|
|
|
|
|
|
|
|
size_t delay_blocks_ = 0;
|
|
|
|
|
int reliable_delay_estimate_counter_ = 0;
|
|
|
|
|
int delay_change_counter_ = 0;
|
|
|
|
|
int call_counter_ = 0;
|
|
|
|
|
int initial_call_counter_ = 0;
|
|
|
|
|
bool initial_update = true;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // MODULES_AUDIO_PROCESSING_AEC3_RENDER_DELAY_CONTROLLER_METRICS_H_
|