1/* 2 * Copyright (c) 2011 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_MAIN_SOURCE_GAIN_CONTROL_IMPL_H_ 12#define WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_GAIN_CONTROL_IMPL_H_ 13 14#include <vector> 15 16#include "audio_processing.h" 17#include "processing_component.h" 18 19namespace webrtc { 20class AudioProcessingImpl; 21class AudioBuffer; 22 23class 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(); 35 virtual int get_version(char* version, int version_len_bytes) const; 36 37 // GainControl implementation. 38 virtual bool is_enabled() const; 39 virtual int stream_analog_level(); 40 41 private: 42 // GainControl implementation. 43 virtual int Enable(bool enable); 44 virtual int set_stream_analog_level(int level); 45 virtual int set_mode(Mode mode); 46 virtual Mode mode() const; 47 virtual int set_target_level_dbfs(int level); 48 virtual int target_level_dbfs() const; 49 virtual int set_compression_gain_db(int gain); 50 virtual int compression_gain_db() const; 51 virtual int enable_limiter(bool enable); 52 virtual bool is_limiter_enabled() const; 53 virtual int set_analog_level_limits(int minimum, int maximum); 54 virtual int analog_level_minimum() const; 55 virtual int analog_level_maximum() const; 56 virtual bool stream_is_saturated() const; 57 58 // ProcessingComponent implementation. 59 virtual void* CreateHandle() const; 60 virtual int InitializeHandle(void* handle) const; 61 virtual int ConfigureHandle(void* handle) const; 62 virtual int DestroyHandle(void* handle) const; 63 virtual int num_handles_required() const; 64 virtual int GetHandleError(void* handle) const; 65 66 const AudioProcessingImpl* apm_; 67 Mode mode_; 68 int minimum_capture_level_; 69 int maximum_capture_level_; 70 bool limiter_enabled_; 71 int target_level_dbfs_; 72 int compression_gain_db_; 73 std::vector<int> capture_levels_; 74 int analog_capture_level_; 75 bool was_analog_level_set_; 76 bool stream_is_saturated_; 77}; 78} // namespace webrtc 79 80#endif // WEBRTC_MODULES_AUDIO_PROCESSING_MAIN_SOURCE_GAIN_CONTROL_IMPL_H_ 81