niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 1 | /* |
bjornv@webrtc.org | 0c6f931 | 2012-01-30 09:39:08 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 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 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 11 | #ifndef MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 14 | #include <memory> |
| 15 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 16 | #include "modules/audio_processing/include/audio_processing.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame^] | 17 | #include "rtc_base/constructor_magic.h" |
| 18 | #include "rtc_base/critical_section.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 19 | |
| 20 | namespace webrtc { |
andrew@webrtc.org | 56e4a05 | 2014-02-27 22:23:17 +0000 | [diff] [blame] | 21 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 22 | class AudioBuffer; |
henrik.lundin | 5049942 | 2016-11-29 04:26:24 -0800 | [diff] [blame] | 23 | class RmsLevel; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 24 | |
solenberg | 949028f | 2015-12-15 11:39:38 -0800 | [diff] [blame] | 25 | class LevelEstimatorImpl : public LevelEstimator { |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 26 | public: |
solenberg | 949028f | 2015-12-15 11:39:38 -0800 | [diff] [blame] | 27 | explicit LevelEstimatorImpl(rtc::CriticalSection* crit); |
| 28 | ~LevelEstimatorImpl() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | |
solenberg | 949028f | 2015-12-15 11:39:38 -0800 | [diff] [blame] | 30 | // TODO(peah): Fold into ctor, once public API is removed. |
| 31 | void Initialize(); |
| 32 | void ProcessStream(AudioBuffer* audio); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 33 | |
| 34 | // LevelEstimator implementation. |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 35 | int Enable(bool enable) override; |
solenberg | 949028f | 2015-12-15 11:39:38 -0800 | [diff] [blame] | 36 | bool is_enabled() const override; |
kjellander@webrtc.org | 14665ff | 2015-03-04 12:58:35 +0000 | [diff] [blame] | 37 | int RMS() override; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 38 | |
solenberg | 949028f | 2015-12-15 11:39:38 -0800 | [diff] [blame] | 39 | private: |
| 40 | rtc::CriticalSection* const crit_ = nullptr; |
danilchap | 56359be | 2017-09-07 07:53:45 -0700 | [diff] [blame] | 41 | bool enabled_ RTC_GUARDED_BY(crit_) = false; |
| 42 | std::unique_ptr<RmsLevel> rms_ RTC_GUARDED_BY(crit_); |
solenberg | 949028f | 2015-12-15 11:39:38 -0800 | [diff] [blame] | 43 | RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(LevelEstimatorImpl); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | }; |
| 45 | } // namespace webrtc |
| 46 | |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 47 | #endif // MODULES_AUDIO_PROCESSING_LEVEL_ESTIMATOR_IMPL_H_ |