xref: /aosp_15_r20/external/webrtc/modules/audio_processing/aec3/block_processor_metrics.h (revision d9f758449e529ab9291ac668be2861e7a55c2422)
1 /*
2  *  Copyright (c) 2017 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_BLOCK_PROCESSOR_METRICS_H_
12 #define MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_METRICS_H_
13 
14 namespace webrtc {
15 
16 // Handles the reporting of metrics for the block_processor.
17 class BlockProcessorMetrics {
18  public:
19   BlockProcessorMetrics() = default;
20 
21   BlockProcessorMetrics(const BlockProcessorMetrics&) = delete;
22   BlockProcessorMetrics& operator=(const BlockProcessorMetrics&) = delete;
23 
24   // Updates the metric with new capture data.
25   void UpdateCapture(bool underrun);
26 
27   // Updates the metric with new render data.
28   void UpdateRender(bool overrun);
29 
30   // Returns true if the metrics have just been reported, otherwise false.
MetricsReported()31   bool MetricsReported() { return metrics_reported_; }
32 
33  private:
34   // Resets the metrics.
35   void ResetMetrics();
36 
37   int capture_block_counter_ = 0;
38   bool metrics_reported_ = false;
39   int render_buffer_underruns_ = 0;
40   int render_buffer_overruns_ = 0;
41   int buffer_render_calls_ = 0;
42 };
43 
44 }  // namespace webrtc
45 
46 #endif  // MODULES_AUDIO_PROCESSING_AEC3_BLOCK_PROCESSOR_METRICS_H_
47