Sam Zackrisson | f0d1c03 | 2019-03-27 13:28:08 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2019 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_GAIN_CONTROL_CONFIG_PROXY_H_ |
| 12 | #define MODULES_AUDIO_PROCESSING_GAIN_CONTROL_CONFIG_PROXY_H_ |
| 13 | |
| 14 | #include "modules/audio_processing/include/audio_processing.h" |
| 15 | #include "modules/audio_processing/include/gain_control.h" |
| 16 | #include "rtc_base/critical_section.h" |
| 17 | #include "rtc_base/thread_annotations.h" |
| 18 | |
| 19 | namespace webrtc { |
| 20 | |
| 21 | // This class forwards all gain control configuration to the audio processing |
| 22 | // module, for compatibility with AudioProcessing::Config. |
| 23 | class GainControlConfigProxy : public GainControl { |
| 24 | public: |
| 25 | GainControlConfigProxy(rtc::CriticalSection* crit_capture, |
| 26 | AudioProcessing* apm, |
| 27 | GainControl* agc); |
| 28 | GainControlConfigProxy(const GainControlConfigProxy&) = delete; |
| 29 | GainControlConfigProxy& operator=(const GainControlConfigProxy&) = delete; |
| 30 | |
| 31 | ~GainControlConfigProxy() override; |
| 32 | |
| 33 | private: |
| 34 | // GainControl API during processing. |
| 35 | int set_stream_analog_level(int level) override; |
| 36 | int stream_analog_level() const override; |
| 37 | |
| 38 | // GainControl config setters. |
| 39 | int Enable(bool enable) override; |
| 40 | int set_mode(Mode mode) override; |
| 41 | int set_target_level_dbfs(int level) override; |
| 42 | int set_compression_gain_db(int gain) override; |
| 43 | int enable_limiter(bool enable) override; |
| 44 | int set_analog_level_limits(int minimum, int maximum) override; |
| 45 | |
| 46 | // GainControl config getters. |
| 47 | bool is_enabled() const override; |
| 48 | bool is_limiter_enabled() const override; |
| 49 | int compression_gain_db() const override; |
| 50 | int target_level_dbfs() const override; |
| 51 | int analog_level_minimum() const override; |
| 52 | int analog_level_maximum() const override; |
| 53 | bool stream_is_saturated() const override; |
| 54 | Mode mode() const override; |
| 55 | |
| 56 | rtc::CriticalSection* crit_capture_ = nullptr; |
| 57 | AudioProcessing* apm_ = nullptr; |
| 58 | GainControl* agc_ RTC_GUARDED_BY(crit_capture_) = nullptr; |
| 59 | }; |
| 60 | |
| 61 | } // namespace webrtc |
| 62 | #endif // MODULES_AUDIO_PROCESSING_GAIN_CONTROL_CONFIG_PROXY_H_ |