Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1015)

Side by Side Diff: webrtc/modules/audio_processing/agc/agc_manager_direct.h

Issue 1299143003: Remove AgcManager. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 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 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 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_ 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_ 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_
13 13
14 #include "webrtc/base/scoped_ptr.h" 14 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/modules/audio_processing/agc/agc.h" 15 #include "webrtc/modules/audio_processing/agc/agc.h"
16 16
17 namespace webrtc { 17 namespace webrtc {
18 18
19 class AudioFrame; 19 class AudioFrame;
20 class DebugFile; 20 class DebugFile;
21 class GainControl; 21 class GainControl;
22 22
23 // Callbacks that need to be injected into AgcManagerDirect to read and control 23 // Callbacks that need to be injected into AgcManagerDirect to read and control
24 // the volume values. They have different behavior if they are called from 24 // the volume values. This is done to remove the VoiceEngine dependency in
25 // AgcManager or AudioProcessing. This is done to remove the VoiceEngine 25 // AgcManagerDirect.
26 // dependency in AgcManagerDirect.
27 class VolumeCallbacks { 26 class VolumeCallbacks {
Andrew MacDonald 2015/08/19 17:58:39 Not for this CL, but do we need to use this callba
aluebs-webrtc 2015/09/28 22:51:08 Added TODO. But how would you imagine it to work?
Andrew MacDonald 2015/09/29 05:33:34 Instead of triggering a callback on volume change,
aluebs-webrtc 2015/09/29 18:10:39 And let the APM update the volume in the GainContr
Andrew MacDonald 2015/09/29 18:17:11 These callbacks don't get delivered to voice engin
aluebs-webrtc 2015/09/29 19:10:34 Ok, I think I get your point but we can discuss wh
28 public: 27 public:
29 virtual ~VolumeCallbacks() {} 28 virtual ~VolumeCallbacks() {}
30 virtual void SetMicVolume(int volume) = 0; 29 virtual void SetMicVolume(int volume) = 0;
31 virtual int GetMicVolume() = 0; 30 virtual int GetMicVolume() = 0;
32 }; 31 };
33 32
34 // Direct interface to use AGC to set volume and compression values. 33 // Direct interface to use AGC to set volume and compression values.
35 // AudioProcessing uses this interface directly to integrate the callback-less 34 // AudioProcessing uses this interface directly to integrate the callback-less
36 // AGC. AgcManager delegates most of its calls here. See agc_manager.h for 35 // AGC.
37 // undocumented methods.
38 // 36 //
39 // This class is not thread-safe. 37 // This class is not thread-safe.
40 class AgcManagerDirect { 38 class AgcManagerDirect {
Andrew MacDonald 2015/08/19 17:58:39 final, and DISALLOW_COPY_AND_ASSIGN
aluebs-webrtc 2015/09/28 22:51:08 Done.
41 public: 39 public:
42 // AgcManagerDirect will configure GainControl internally. The user is 40 // AgcManagerDirect will configure GainControl internally. The user is
43 // responsible for processing the audio using it after the call to Process. 41 // responsible for processing the audio using it after the call to Process.
44 // The operating range of startup_min_level is [12, 255] and any input value 42 // The operating range of startup_min_level is [12, 255] and any input value
45 // outside that range will be clamped. 43 // outside that range will be clamped.
46 AgcManagerDirect(GainControl* gctrl, 44 AgcManagerDirect(GainControl* gctrl,
47 VolumeCallbacks* volume_callbacks, 45 VolumeCallbacks* volume_callbacks,
48 int startup_min_level); 46 int startup_min_level);
49 // Dependency injection for testing. Don't delete |agc| as the memory is owned 47 // Dependency injection for testing. Don't delete |agc| as the memory is owned
50 // by the manager. 48 // by the manager.
51 AgcManagerDirect(Agc* agc, 49 AgcManagerDirect(Agc* agc,
52 GainControl* gctrl, 50 GainControl* gctrl,
53 VolumeCallbacks* volume_callbacks, 51 VolumeCallbacks* volume_callbacks,
54 int startup_min_level); 52 int startup_min_level);
55 ~AgcManagerDirect(); 53 ~AgcManagerDirect();
56 54
57 int Initialize(); 55 int Initialize();
58 void AnalyzePreProcess(int16_t* audio, 56 void AnalyzePreProcess(int16_t* audio,
59 int num_channels, 57 int num_channels,
60 int samples_per_channel); 58 int samples_per_channel);
61 void Process(const int16_t* audio, int length, int sample_rate_hz); 59 void Process(const int16_t* audio, int length, int sample_rate_hz);
62 60
61 // Call when the capture stream has been muted/unmuted. This causes the
62 // manager to disregard all incoming audio; chances are good it's background
63 // noise to which we'd like to avoid adapting.
64 void SetCaptureMuted(bool muted);
65 bool capture_muted() { return capture_muted_; }
66
67 float voice_probability();
68
69 private:
63 // Sets a new microphone level, after first checking that it hasn't been 70 // Sets a new microphone level, after first checking that it hasn't been
64 // updated by the user, in which case no action is taken. 71 // updated by the user, in which case no action is taken.
65 void SetLevel(int new_level); 72 void SetLevel(int new_level);
66 73
67 // Set the maximum level the AGC is allowed to apply. Also updates the 74 // Set the maximum level the AGC is allowed to apply. Also updates the
68 // maximum compression gain to compensate. The level must be at least 75 // maximum compression gain to compensate. The level must be at least
69 // |kClippedLevelMin|. 76 // |kClippedLevelMin|.
70 void SetMaxLevel(int level); 77 void SetMaxLevel(int level);
71 78
72 void SetCaptureMuted(bool muted);
73 bool capture_muted() { return capture_muted_; }
74
75 float voice_probability();
76
77 private:
78 int CheckVolumeAndReset(); 79 int CheckVolumeAndReset();
79 void UpdateGain(); 80 void UpdateGain();
80 void UpdateCompressor(); 81 void UpdateCompressor();
81 82
82 rtc::scoped_ptr<Agc> agc_; 83 rtc::scoped_ptr<Agc> agc_;
83 GainControl* gctrl_; 84 GainControl* gctrl_;
84 VolumeCallbacks* volume_callbacks_; 85 VolumeCallbacks* volume_callbacks_;
85 86
86 int frames_since_clipped_; 87 int frames_since_clipped_;
87 int level_; 88 int level_;
88 int max_level_; 89 int max_level_;
89 int max_compression_gain_; 90 int max_compression_gain_;
90 int target_compression_; 91 int target_compression_;
91 int compression_; 92 int compression_;
92 float compression_accumulator_; 93 float compression_accumulator_;
93 bool capture_muted_; 94 bool capture_muted_;
94 bool check_volume_on_next_process_; 95 bool check_volume_on_next_process_;
95 bool startup_; 96 bool startup_;
96 int startup_min_level_; 97 int startup_min_level_;
97 98
98 rtc::scoped_ptr<DebugFile> file_preproc_; 99 rtc::scoped_ptr<DebugFile> file_preproc_;
99 rtc::scoped_ptr<DebugFile> file_postproc_; 100 rtc::scoped_ptr<DebugFile> file_postproc_;
100 }; 101 };
101 102
102 } // namespace webrtc 103 } // namespace webrtc
103 104
104 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_ 105 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/tools/agc/agc_harness.cc » ('j') | webrtc/tools/agc/agc_manager_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698