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 : #include "webrtc/modules/audio_processing/gain_control_for_experimental_agc.h"
12 :
13 : #include "webrtc/base/checks.h"
14 : #include "webrtc/base/criticalsection.h"
15 : #include "webrtc/modules/audio_processing/include/audio_processing.h"
16 : #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
17 :
18 : namespace webrtc {
19 :
20 : int GainControlForExperimentalAgc::instance_counter_ = 0;
21 :
22 0 : GainControlForExperimentalAgc::GainControlForExperimentalAgc(
23 : GainControl* gain_control,
24 0 : rtc::CriticalSection* crit_capture)
25 0 : : data_dumper_(new ApmDataDumper(instance_counter_)),
26 : real_gain_control_(gain_control),
27 : volume_(0),
28 0 : crit_capture_(crit_capture) {
29 0 : instance_counter_++;
30 0 : }
31 :
32 : GainControlForExperimentalAgc::~GainControlForExperimentalAgc() = default;
33 :
34 0 : int GainControlForExperimentalAgc::Enable(bool enable) {
35 0 : return real_gain_control_->Enable(enable);
36 : }
37 :
38 0 : bool GainControlForExperimentalAgc::is_enabled() const {
39 0 : return real_gain_control_->is_enabled();
40 : }
41 :
42 0 : int GainControlForExperimentalAgc::set_stream_analog_level(int level) {
43 0 : rtc::CritScope cs_capture(crit_capture_);
44 0 : data_dumper_->DumpRaw("experimental_gain_control_set_stream_analog_level", 1,
45 0 : &level);
46 0 : volume_ = level;
47 0 : return AudioProcessing::kNoError;
48 : }
49 :
50 0 : int GainControlForExperimentalAgc::stream_analog_level() {
51 0 : rtc::CritScope cs_capture(crit_capture_);
52 0 : data_dumper_->DumpRaw("experimental_gain_control_stream_analog_level", 1,
53 0 : &volume_);
54 0 : return volume_;
55 : }
56 :
57 0 : int GainControlForExperimentalAgc::set_mode(Mode mode) {
58 0 : return AudioProcessing::kNoError;
59 : }
60 :
61 0 : GainControl::Mode GainControlForExperimentalAgc::mode() const {
62 0 : return GainControl::kAdaptiveAnalog;
63 : }
64 :
65 0 : int GainControlForExperimentalAgc::set_target_level_dbfs(int level) {
66 0 : return AudioProcessing::kNoError;
67 : }
68 :
69 0 : int GainControlForExperimentalAgc::target_level_dbfs() const {
70 0 : return real_gain_control_->target_level_dbfs();
71 : }
72 :
73 0 : int GainControlForExperimentalAgc::set_compression_gain_db(int gain) {
74 0 : return AudioProcessing::kNoError;
75 : }
76 :
77 0 : int GainControlForExperimentalAgc::compression_gain_db() const {
78 0 : return real_gain_control_->compression_gain_db();
79 : }
80 :
81 0 : int GainControlForExperimentalAgc::enable_limiter(bool enable) {
82 0 : return AudioProcessing::kNoError;
83 : }
84 :
85 0 : bool GainControlForExperimentalAgc::is_limiter_enabled() const {
86 0 : return real_gain_control_->is_limiter_enabled();
87 : }
88 :
89 0 : int GainControlForExperimentalAgc::set_analog_level_limits(int minimum,
90 : int maximum) {
91 0 : return AudioProcessing::kNoError;
92 : }
93 :
94 0 : int GainControlForExperimentalAgc::analog_level_minimum() const {
95 0 : return real_gain_control_->analog_level_minimum();
96 : }
97 :
98 0 : int GainControlForExperimentalAgc::analog_level_maximum() const {
99 0 : return real_gain_control_->analog_level_maximum();
100 : }
101 :
102 0 : bool GainControlForExperimentalAgc::stream_is_saturated() const {
103 0 : return real_gain_control_->stream_is_saturated();
104 : }
105 :
106 0 : void GainControlForExperimentalAgc::SetMicVolume(int volume) {
107 0 : rtc::CritScope cs_capture(crit_capture_);
108 0 : volume_ = volume;
109 0 : }
110 :
111 0 : int GainControlForExperimentalAgc::GetMicVolume() {
112 0 : rtc::CritScope cs_capture(crit_capture_);
113 0 : return volume_;
114 : }
115 :
116 0 : void GainControlForExperimentalAgc::Initialize() {
117 0 : data_dumper_->InitiateNewSetOfRecordings();
118 0 : }
119 :
120 : } // namespace webrtc
|