1 /*
2  *  Copyright (c) 2018 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef MODULES_AUDIO_PROCESSING_AEC3_CLOCKDRIFT_DETECTOR_H_
12 #define MODULES_AUDIO_PROCESSING_AEC3_CLOCKDRIFT_DETECTOR_H_
13 
14 #include <stddef.h>
15 
16 #include <array>
17 
18 namespace webrtc {
19 
20 class ApmDataDumper;
21 struct DownsampledRenderBuffer;
22 struct EchoCanceller3Config;
23 
24 // Detects clockdrift by analyzing the estimated delay.
25 class ClockdriftDetector {
26  public:
27   enum class Level { kNone, kProbable, kVerified, kNumCategories };
28   ClockdriftDetector();
29   ~ClockdriftDetector();
30   void Update(int delay_estimate);
ClockdriftLevel()31   Level ClockdriftLevel() const { return level_; }
32 
33  private:
34   std::array<int, 3> delay_history_;
35   Level level_;
36   size_t stability_counter_;
37 };
38 }  // namespace webrtc
39 
40 #endif  // MODULES_AUDIO_PROCESSING_AEC3_CLOCKDRIFT_DETECTOR_H_
41