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_MATCHED_FILTER_LAG_AGGREGATOR_H_ 12 #define MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_ 13 14 #include <vector> 15 16 #include "absl/types/optional.h" 17 #include "api/audio/echo_canceller3_config.h" 18 #include "modules/audio_processing/aec3/delay_estimate.h" 19 #include "modules/audio_processing/aec3/matched_filter.h" 20 #include "rtc_base/constructor_magic.h" 21 22 namespace webrtc { 23 24 class ApmDataDumper; 25 26 // Aggregates lag estimates produced by the MatchedFilter class into a single 27 // reliable combined lag estimate. 28 class MatchedFilterLagAggregator { 29 public: 30 MatchedFilterLagAggregator( 31 ApmDataDumper* data_dumper, 32 size_t max_filter_lag, 33 const EchoCanceller3Config::Delay::DelaySelectionThresholds& thresholds); 34 ~MatchedFilterLagAggregator(); 35 36 // Resets the aggregator. 37 void Reset(bool hard_reset); 38 39 // Aggregates the provided lag estimates. 40 absl::optional<DelayEstimate> Aggregate( 41 rtc::ArrayView<const MatchedFilter::LagEstimate> lag_estimates); 42 43 private: 44 ApmDataDumper* const data_dumper_; 45 std::vector<int> histogram_; 46 std::array<int, 250> histogram_data_; 47 int histogram_data_index_ = 0; 48 bool significant_candidate_found_ = false; 49 const EchoCanceller3Config::Delay::DelaySelectionThresholds thresholds_; 50 51 RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(MatchedFilterLagAggregator); 52 }; 53 } // namespace webrtc 54 55 #endif // MODULES_AUDIO_PROCESSING_AEC3_MATCHED_FILTER_LAG_AGGREGATOR_H_ 56