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

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: Initialize volume Created 5 years, 2 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
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/agc/agc_manager_direct_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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. 26 // TODO(aluebs): Remove VolumeCallbacks.
27 class VolumeCallbacks { 27 class VolumeCallbacks {
28 public: 28 public:
29 virtual ~VolumeCallbacks() {} 29 virtual ~VolumeCallbacks() {}
30 virtual void SetMicVolume(int volume) = 0; 30 virtual void SetMicVolume(int volume) = 0;
31 virtual int GetMicVolume() = 0; 31 virtual int GetMicVolume() = 0;
32 }; 32 };
33 33
34 // Direct interface to use AGC to set volume and compression values. 34 // Direct interface to use AGC to set volume and compression values.
35 // AudioProcessing uses this interface directly to integrate the callback-less 35 // AudioProcessing uses this interface directly to integrate the callback-less
36 // AGC. AgcManager delegates most of its calls here. See agc_manager.h for 36 // AGC.
37 // undocumented methods.
38 // 37 //
39 // This class is not thread-safe. 38 // This class is not thread-safe.
40 class AgcManagerDirect { 39 class AgcManagerDirect final {
41 public: 40 public:
42 // AgcManagerDirect will configure GainControl internally. The user is 41 // AgcManagerDirect will configure GainControl internally. The user is
43 // responsible for processing the audio using it after the call to Process. 42 // 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 43 // The operating range of startup_min_level is [12, 255] and any input value
45 // outside that range will be clamped. 44 // outside that range will be clamped.
46 AgcManagerDirect(GainControl* gctrl, 45 AgcManagerDirect(GainControl* gctrl,
47 VolumeCallbacks* volume_callbacks, 46 VolumeCallbacks* volume_callbacks,
48 int startup_min_level); 47 int startup_min_level);
49 // Dependency injection for testing. Don't delete |agc| as the memory is owned 48 // Dependency injection for testing. Don't delete |agc| as the memory is owned
50 // by the manager. 49 // by the manager.
51 AgcManagerDirect(Agc* agc, 50 AgcManagerDirect(Agc* agc,
52 GainControl* gctrl, 51 GainControl* gctrl,
53 VolumeCallbacks* volume_callbacks, 52 VolumeCallbacks* volume_callbacks,
54 int startup_min_level); 53 int startup_min_level);
55 ~AgcManagerDirect(); 54 ~AgcManagerDirect();
56 55
57 int Initialize(); 56 int Initialize();
58 void AnalyzePreProcess(int16_t* audio, 57 void AnalyzePreProcess(int16_t* audio,
59 int num_channels, 58 int num_channels,
60 size_t samples_per_channel); 59 size_t samples_per_channel);
61 void Process(const int16_t* audio, size_t length, int sample_rate_hz); 60 void Process(const int16_t* audio, size_t length, int sample_rate_hz);
62 61
62 // Call when the capture stream has been muted/unmuted. This causes the
63 // manager to disregard all incoming audio; chances are good it's background
64 // noise to which we'd like to avoid adapting.
65 void SetCaptureMuted(bool muted);
66 bool capture_muted() { return capture_muted_; }
67
68 float voice_probability();
69
70 private:
63 // Sets a new microphone level, after first checking that it hasn't been 71 // 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. 72 // updated by the user, in which case no action is taken.
65 void SetLevel(int new_level); 73 void SetLevel(int new_level);
66 74
67 // Set the maximum level the AGC is allowed to apply. Also updates the 75 // 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 76 // maximum compression gain to compensate. The level must be at least
69 // |kClippedLevelMin|. 77 // |kClippedLevelMin|.
70 void SetMaxLevel(int level); 78 void SetMaxLevel(int level);
71 79
72 void SetCaptureMuted(bool muted);
73 bool capture_muted() { return capture_muted_; }
74
75 float voice_probability();
76
77 private:
78 int CheckVolumeAndReset(); 80 int CheckVolumeAndReset();
79 void UpdateGain(); 81 void UpdateGain();
80 void UpdateCompressor(); 82 void UpdateCompressor();
81 83
82 rtc::scoped_ptr<Agc> agc_; 84 rtc::scoped_ptr<Agc> agc_;
83 GainControl* gctrl_; 85 GainControl* gctrl_;
84 VolumeCallbacks* volume_callbacks_; 86 VolumeCallbacks* volume_callbacks_;
85 87
86 int frames_since_clipped_; 88 int frames_since_clipped_;
87 int level_; 89 int level_;
88 int max_level_; 90 int max_level_;
89 int max_compression_gain_; 91 int max_compression_gain_;
90 int target_compression_; 92 int target_compression_;
91 int compression_; 93 int compression_;
92 float compression_accumulator_; 94 float compression_accumulator_;
93 bool capture_muted_; 95 bool capture_muted_;
94 bool check_volume_on_next_process_; 96 bool check_volume_on_next_process_;
95 bool startup_; 97 bool startup_;
96 int startup_min_level_; 98 int startup_min_level_;
97 99
98 rtc::scoped_ptr<DebugFile> file_preproc_; 100 rtc::scoped_ptr<DebugFile> file_preproc_;
99 rtc::scoped_ptr<DebugFile> file_postproc_; 101 rtc::scoped_ptr<DebugFile> file_postproc_;
102
103 RTC_DISALLOW_COPY_AND_ASSIGN(AgcManagerDirect);
100 }; 104 };
101 105
102 } // namespace webrtc 106 } // namespace webrtc
103 107
104 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_ 108 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AGC_AGC_MANAGER_DIRECT_H_
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/audio_processing/agc/agc_manager_direct_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698