blob: e1669ccc75505348910ac241fdcc0b735bb98851 [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 {
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000020
niklase@google.com470e71d2011-07-07 08:21:25 +000021class AudioBuffer;
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000022class CriticalSectionWrapper;
niklase@google.com470e71d2011-07-07 08:21:25 +000023
24class GainControlImpl : public GainControl,
25 public ProcessingComponent {
26 public:
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000027 GainControlImpl(const AudioProcessing* apm,
28 CriticalSectionWrapper* crit);
niklase@google.com470e71d2011-07-07 08:21:25 +000029 virtual ~GainControlImpl();
30
31 int ProcessRenderAudio(AudioBuffer* audio);
32 int AnalyzeCaptureAudio(AudioBuffer* audio);
33 int ProcessCaptureAudio(AudioBuffer* audio);
34
35 // ProcessingComponent implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000036 virtual int Initialize() OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000037
38 // GainControl implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000039 virtual bool is_enabled() const OVERRIDE;
40 virtual int stream_analog_level() OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000041
42 private:
43 // GainControl implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000044 virtual int Enable(bool enable) OVERRIDE;
45 virtual int set_stream_analog_level(int level) OVERRIDE;
46 virtual int set_mode(Mode mode) OVERRIDE;
47 virtual Mode mode() const OVERRIDE;
48 virtual int set_target_level_dbfs(int level) OVERRIDE;
49 virtual int target_level_dbfs() const OVERRIDE;
50 virtual int set_compression_gain_db(int gain) OVERRIDE;
51 virtual int compression_gain_db() const OVERRIDE;
52 virtual int enable_limiter(bool enable) OVERRIDE;
53 virtual bool is_limiter_enabled() const OVERRIDE;
54 virtual int set_analog_level_limits(int minimum, int maximum) OVERRIDE;
55 virtual int analog_level_minimum() const OVERRIDE;
56 virtual int analog_level_maximum() const OVERRIDE;
57 virtual bool stream_is_saturated() const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000058
59 // ProcessingComponent implementation.
pbos@webrtc.org91620802013-08-02 11:44:11 +000060 virtual void* CreateHandle() const OVERRIDE;
61 virtual int InitializeHandle(void* handle) const OVERRIDE;
62 virtual int ConfigureHandle(void* handle) const OVERRIDE;
63 virtual int DestroyHandle(void* handle) const OVERRIDE;
64 virtual int num_handles_required() const OVERRIDE;
65 virtual int GetHandleError(void* handle) const OVERRIDE;
niklase@google.com470e71d2011-07-07 08:21:25 +000066
andrew@webrtc.org56e4a052014-02-27 22:23:17 +000067 const AudioProcessing* apm_;
68 CriticalSectionWrapper* crit_;
niklase@google.com470e71d2011-07-07 08:21:25 +000069 Mode mode_;
70 int minimum_capture_level_;
71 int maximum_capture_level_;
72 bool limiter_enabled_;
73 int target_level_dbfs_;
74 int compression_gain_db_;
75 std::vector<int> capture_levels_;
76 int analog_capture_level_;
77 bool was_analog_level_set_;
78 bool stream_is_saturated_;
79};
80} // namespace webrtc
81
bjornv@webrtc.org0c6f9312012-01-30 09:39:08 +000082#endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_IMPL_H_