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 { |
| 20 | class AudioProcessingImpl; |
| 21 | class AudioBuffer; |
| 22 | |
| 23 | class GainControlImpl : public GainControl, |
| 24 | public ProcessingComponent { |
| 25 | public: |
| 26 | explicit GainControlImpl(const AudioProcessingImpl* apm); |
| 27 | virtual ~GainControlImpl(); |
| 28 | |
| 29 | int ProcessRenderAudio(AudioBuffer* audio); |
| 30 | int AnalyzeCaptureAudio(AudioBuffer* audio); |
| 31 | int ProcessCaptureAudio(AudioBuffer* audio); |
| 32 | |
| 33 | // ProcessingComponent implementation. |
| 34 | virtual int Initialize(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 35 | |
| 36 | // GainControl implementation. |
| 37 | virtual bool is_enabled() const; |
ajm@google.com | 808e0e0 | 2011-08-03 21:08:51 +0000 | [diff] [blame] | 38 | virtual int stream_analog_level(); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | // GainControl implementation. |
| 42 | virtual int Enable(bool enable); |
| 43 | virtual int set_stream_analog_level(int level); |
niklase@google.com | 470e71d | 2011-07-07 08:21:25 +0000 | [diff] [blame] | 44 | virtual int set_mode(Mode mode); |
| 45 | virtual Mode mode() const; |
| 46 | virtual int set_target_level_dbfs(int level); |
| 47 | virtual int target_level_dbfs() const; |
| 48 | virtual int set_compression_gain_db(int gain); |
| 49 | virtual int compression_gain_db() const; |
| 50 | virtual int enable_limiter(bool enable); |
| 51 | virtual bool is_limiter_enabled() const; |
| 52 | virtual int set_analog_level_limits(int minimum, int maximum); |
| 53 | virtual int analog_level_minimum() const; |
| 54 | virtual int analog_level_maximum() const; |
| 55 | virtual bool stream_is_saturated() const; |
| 56 | |
| 57 | // ProcessingComponent implementation. |
| 58 | virtual void* CreateHandle() const; |
| 59 | virtual int InitializeHandle(void* handle) const; |
| 60 | virtual int ConfigureHandle(void* handle) const; |
| 61 | virtual int DestroyHandle(void* handle) const; |
| 62 | virtual int num_handles_required() const; |
| 63 | virtual int GetHandleError(void* handle) const; |
| 64 | |
| 65 | const AudioProcessingImpl* apm_; |
| 66 | Mode mode_; |
| 67 | int minimum_capture_level_; |
| 68 | int maximum_capture_level_; |
| 69 | bool limiter_enabled_; |
| 70 | int target_level_dbfs_; |
| 71 | int compression_gain_db_; |
| 72 | std::vector<int> capture_levels_; |
| 73 | int analog_capture_level_; |
| 74 | bool was_analog_level_set_; |
| 75 | bool stream_is_saturated_; |
| 76 | }; |
| 77 | } // namespace webrtc |
| 78 | |
bjornv@webrtc.org | 0c6f931 | 2012-01-30 09:39:08 +0000 | [diff] [blame] | 79 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ |