Line data Source code
1 : /*
2 : * Copyright (c) 2016 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_FOR_EXPERIMENTAL_AGC_H_
12 : #define WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_FOR_EXPERIMENTAL_AGC_H_
13 :
14 : #include "webrtc/base/constructormagic.h"
15 : #include "webrtc/base/criticalsection.h"
16 : #include "webrtc/base/thread_checker.h"
17 : #include "webrtc/modules/audio_processing/agc/agc_manager_direct.h"
18 : #include "webrtc/modules/audio_processing/include/audio_processing.h"
19 :
20 : namespace webrtc {
21 :
22 : class ApmDataDumper;
23 :
24 : // This class has two main purposes:
25 : //
26 : // 1) It is returned instead of the real GainControl after the new AGC has been
27 : // enabled in order to prevent an outside user from overriding compression
28 : // settings. It doesn't do anything in its implementation, except for
29 : // delegating the const methods and Enable calls to the real GainControl, so
30 : // AGC can still be disabled.
31 : //
32 : // 2) It is injected into AgcManagerDirect and implements volume callbacks for
33 : // getting and setting the volume level. It just caches this value to be used
34 : // in VoiceEngine later.
35 0 : class GainControlForExperimentalAgc : public GainControl,
36 : public VolumeCallbacks {
37 : public:
38 : GainControlForExperimentalAgc(GainControl* gain_control,
39 : rtc::CriticalSection* crit_capture);
40 : ~GainControlForExperimentalAgc() override;
41 :
42 : // GainControl implementation.
43 : int Enable(bool enable) override;
44 : bool is_enabled() const override;
45 : int set_stream_analog_level(int level) override;
46 : int stream_analog_level() override;
47 : int set_mode(Mode mode) override;
48 : Mode mode() const override;
49 : int set_target_level_dbfs(int level) override;
50 : int target_level_dbfs() const override;
51 : int set_compression_gain_db(int gain) override;
52 : int compression_gain_db() const override;
53 : int enable_limiter(bool enable) override;
54 : bool is_limiter_enabled() const override;
55 : int set_analog_level_limits(int minimum, int maximum) override;
56 : int analog_level_minimum() const override;
57 : int analog_level_maximum() const override;
58 : bool stream_is_saturated() const override;
59 :
60 : // VolumeCallbacks implementation.
61 : void SetMicVolume(int volume) override;
62 : int GetMicVolume() override;
63 :
64 : void Initialize();
65 :
66 : private:
67 : std::unique_ptr<ApmDataDumper> data_dumper_;
68 : GainControl* real_gain_control_;
69 : int volume_;
70 : rtc::CriticalSection* crit_capture_;
71 : static int instance_counter_;
72 : RTC_DISALLOW_IMPLICIT_CONSTRUCTORS(GainControlForExperimentalAgc);
73 : };
74 :
75 : } // namespace webrtc
76 :
77 : #endif // WEBRTC_MODULES_AUDIO_PROCESSING_GAIN_CONTROL_FOR_EXPERIMENTAL_AGC_H_
|