andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2012 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 WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ |
| 12 | #define WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ |
| 13 | |
| 14 | #include <vector> |
| 15 | |
pbos@webrtc.org | 9fb1613 | 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" |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +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. |
pbos@webrtc.org | 24add92 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 34 | virtual int Initialize() OVERRIDE; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 35 | |
| 36 | // GainControl implementation. |
pbos@webrtc.org | 24add92 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 37 | virtual bool is_enabled() const OVERRIDE; |
| 38 | virtual int stream_analog_level() OVERRIDE; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 39 | |
| 40 | private: |
| 41 | // GainControl implementation. |
pbos@webrtc.org | 24add92 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 42 | virtual int Enable(bool enable) OVERRIDE; |
| 43 | virtual int set_stream_analog_level(int level) OVERRIDE; |
| 44 | virtual int set_mode(Mode mode) OVERRIDE; |
| 45 | virtual Mode mode() const OVERRIDE; |
| 46 | virtual int set_target_level_dbfs(int level) OVERRIDE; |
| 47 | virtual int target_level_dbfs() const OVERRIDE; |
| 48 | virtual int set_compression_gain_db(int gain) OVERRIDE; |
| 49 | virtual int compression_gain_db() const OVERRIDE; |
| 50 | virtual int enable_limiter(bool enable) OVERRIDE; |
| 51 | virtual bool is_limiter_enabled() const OVERRIDE; |
| 52 | virtual int set_analog_level_limits(int minimum, int maximum) OVERRIDE; |
| 53 | virtual int analog_level_minimum() const OVERRIDE; |
| 54 | virtual int analog_level_maximum() const OVERRIDE; |
| 55 | virtual bool stream_is_saturated() const OVERRIDE; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 56 | |
| 57 | // ProcessingComponent implementation. |
pbos@webrtc.org | 24add92 | 2013-08-02 11:44:11 +0000 | [diff] [blame] | 58 | virtual void* CreateHandle() const OVERRIDE; |
| 59 | virtual int InitializeHandle(void* handle) const OVERRIDE; |
| 60 | virtual int ConfigureHandle(void* handle) const OVERRIDE; |
| 61 | virtual int DestroyHandle(void* handle) const OVERRIDE; |
| 62 | virtual int num_handles_required() const OVERRIDE; |
| 63 | virtual int GetHandleError(void* handle) const OVERRIDE; |
andrew@webrtc.org | b015cbe | 2012-10-22 18:19:23 +0000 | [diff] [blame] | 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 | |
| 79 | #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_ |