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 | |
bjornv@webrtc.org | 0c6f931 | 2012-01-30 09:39:08 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 13 | |
| 14 | #include <vector> |
| 15 | |
pbos@webrtc.org | 7fad4b8 | 2013-05-28 08:11:59 +0000 | [diff] [blame] | 16 | #include "webrtc/modules/audio_processing/include/audio_processing.h" |
| 17 | #include "webrtc/modules/audio_processing/processing_component.h" |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 18 | |
| 19 | namespace webrtc { |
andrew@webrtc.org | 56e4a05 | 2014-02-27 22:23:17 +0000 | [diff] [blame] | 20 | |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 21 | class AudioBuffer; |
andrew@webrtc.org | 56e4a05 | 2014-02-27 22:23:17 +0000 | [diff] [blame] | 22 | class CriticalSectionWrapper; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 23 | |
| 24 | class GainControlImpl : public GainControl, |
| 25 | public ProcessingComponent { |
| 26 | public: |
andrew@webrtc.org | 56e4a05 | 2014-02-27 22:23:17 +0000 | [diff] [blame] | 27 | GainControlImpl(const AudioProcessing* apm, |
| 28 | CriticalSectionWrapper* crit); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 29 | virtual ~GainControlImpl(); |
| 30 | |
| 31 | int ProcessRenderAudio(AudioBuffer* audio); |
| 32 | int AnalyzeCaptureAudio(AudioBuffer* audio); |
| 33 | int ProcessCaptureAudio(AudioBuffer* audio); |
| 34 | |
| 35 | // ProcessingComponent implementation. |
pbos@webrtc.org | 9162080 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 36 | virtual int Initialize() OVERRIDE; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 37 | |
| 38 | // GainControl implementation. |
pbos@webrtc.org | 9162080 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 39 | virtual bool is_enabled() const OVERRIDE; |
| 40 | virtual int stream_analog_level() OVERRIDE; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 41 | |
| 42 | private: |
| 43 | // GainControl implementation. |
pbos@webrtc.org | 9162080 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 44 | virtual int Enable(bool enable) OVERRIDE; |
| 45 | virtual int set_stream_analog_level(int level) OVERRIDE; |
| 46 | virtual int set_mode(Mode mode) OVERRIDE; |
| 47 | virtual Mode mode() const OVERRIDE; |
| 48 | virtual int set_target_level_dbfs(int level) OVERRIDE; |
| 49 | virtual int target_level_dbfs() const OVERRIDE; |
| 50 | virtual int set_compression_gain_db(int gain) OVERRIDE; |
| 51 | virtual int compression_gain_db() const OVERRIDE; |
| 52 | virtual int enable_limiter(bool enable) OVERRIDE; |
| 53 | virtual bool is_limiter_enabled() const OVERRIDE; |
| 54 | virtual int set_analog_level_limits(int minimum, int maximum) OVERRIDE; |
| 55 | virtual int analog_level_minimum() const OVERRIDE; |
| 56 | virtual int analog_level_maximum() const OVERRIDE; |
| 57 | virtual bool stream_is_saturated() const OVERRIDE; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 58 | |
| 59 | // ProcessingComponent implementation. |
pbos@webrtc.org | 9162080 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 60 | virtual void* CreateHandle() const OVERRIDE; |
| 61 | virtual int InitializeHandle(void* handle) const OVERRIDE; |
| 62 | virtual int ConfigureHandle(void* handle) const OVERRIDE; |
bjornv@webrtc.org | 5964fe0 | 2014-04-22 06:52:28 +0000 | [diff] [blame] | 63 | virtual void DestroyHandle(void* handle) const OVERRIDE; |
pbos@webrtc.org | 9162080 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 64 | virtual int num_handles_required() const OVERRIDE; |
| 65 | virtual int GetHandleError(void* handle) const OVERRIDE; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 66 | |
andrew@webrtc.org | 56e4a05 | 2014-02-27 22:23:17 +0000 | [diff] [blame] | 67 | const AudioProcessing* apm_; |
| 68 | CriticalSectionWrapper* crit_; |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 69 | Mode mode_; |
| 70 | int minimum_capture_level_; |
| 71 | int maximum_capture_level_; |
| 72 | bool limiter_enabled_; |
| 73 | int target_level_dbfs_; |
| 74 | int compression_gain_db_; |
| 75 | std::vector<int> capture_levels_; |
| 76 | int analog_capture_level_; |
| 77 | bool was_analog_level_set_; |
| 78 | bool stream_is_saturated_; |
| 79 | }; |
| 80 | } // namespace webrtc |
| 81 | |
bjornv@webrtc.org | 0c6f931 | 2012-01-30 09:39:08 +0000 | [diff] [blame] | 82 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ |