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_API_CALL_JITTER_METRICS_H_ 12 #define MODULES_AUDIO_PROCESSING_AEC3_API_CALL_JITTER_METRICS_H_ 13 14 namespace webrtc { 15 16 // Stores data for reporting metrics on the API call jitter. 17 class ApiCallJitterMetrics { 18 public: 19 class Jitter { 20 public: 21 Jitter(); 22 void Update(int num_api_calls_in_a_row); 23 void Reset(); 24 min()25 int min() const { return min_; } max()26 int max() const { return max_; } 27 28 private: 29 int max_; 30 int min_; 31 }; 32 ApiCallJitterMetrics()33 ApiCallJitterMetrics() { Reset(); } 34 35 // Update metrics for render API call. 36 void ReportRenderCall(); 37 38 // Update and periodically report metrics for capture API call. 39 void ReportCaptureCall(); 40 41 // Methods used only for testing. render_jitter()42 const Jitter& render_jitter() const { return render_jitter_; } capture_jitter()43 const Jitter& capture_jitter() const { return capture_jitter_; } 44 bool WillReportMetricsAtNextCapture() const; 45 46 private: 47 void Reset(); 48 49 Jitter render_jitter_; 50 Jitter capture_jitter_; 51 52 int num_api_calls_in_a_row_ = 0; 53 int frames_since_last_report_ = 0; 54 bool last_call_was_render_ = false; 55 bool proper_call_observed_ = false; 56 }; 57 58 } // namespace webrtc 59 60 #endif // MODULES_AUDIO_PROCESSING_AEC3_API_CALL_JITTER_METRICS_H_ 61