blob: 2de02f6e6b7a704045a0b9175cf067151b8069d0 [file] [log] [blame]
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +00001/*
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.org9fb16132013-05-28 08:11:59 +000016#include "webrtc/modules/audio_processing/include/audio_processing.h"
17#include "webrtc/modules/audio_processing/processing_component.h"
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000018
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.
pbos@webrtc.org24add922013-08-02 11:44:11 +000034 virtual int Initialize() OVERRIDE;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000035
36 // GainControl implementation.
pbos@webrtc.org24add922013-08-02 11:44:11 +000037 virtual bool is_enabled() const OVERRIDE;
38 virtual int stream_analog_level() OVERRIDE;
andrew@webrtc.orgb015cbe2012-10-22 18:19:23 +000039
40 private:
41 // GainControl implementation.
pbos@webrtc.org24add922013-08-02 11:44:11 +000042 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.orgb015cbe2012-10-22 18:19:23 +000056
57 // ProcessingComponent implementation.
pbos@webrtc.org24add922013-08-02 11:44:11 +000058 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.orgb015cbe2012-10-22 18:19:23 +000064
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_