blob: 4c58f2253421513b694ba4786cfa595edbd7cff6 [file] [log] [blame]
niklase@google.com470e71d2011-07-07 08:21:25 +00001/*
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +00002 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
niklase@google.com470e71d2011-07-07 08:21:25 +00003 *
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.org0c6f9312012-01-30 09:39:08 +000011#ifndef WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_
12#define WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_
niklase@google.com470e71d2011-07-07 08:21:25 +000013
14#include <vector>
15
pbos@webrtc.org7fad4b82013-05-28 08:11:59 +000016#include "webrtc/modules/audio_processing/include/audio_processing.h"
17#include "webrtc/modules/audio_processing/processing_component.h"
niklase@google.com470e71d2011-07-07 08:21:25 +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.
34 virtual int Initialize();
niklase@google.com470e71d2011-07-07 08:21:25 +000035
36 // GainControl implementation.
37 virtual bool is_enabled() const;
ajm@google.com808e0e02011-08-03 21:08:51 +000038 virtual int stream_analog_level();
niklase@google.com470e71d2011-07-07 08:21:25 +000039
40 private:
41 // GainControl implementation.
42 virtual int Enable(bool enable);
43 virtual int set_stream_analog_level(int level);
niklase@google.com470e71d2011-07-07 08:21:25 +000044 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.org0c6f9312012-01-30 09:39:08 +000079#endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_