OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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_AUDIO_PROCESSING_IMPL_H_ | 11 #ifndef WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 12 #define WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
13 | 13 |
14 #include <list> | 14 #include <list> |
15 #include <memory> | 15 #include <memory> |
16 #include <string> | 16 #include <string> |
17 #include <vector> | 17 #include <vector> |
18 | 18 |
19 #include "webrtc/base/criticalsection.h" | 19 #include "webrtc/base/criticalsection.h" |
| 20 #include "webrtc/base/function_view.h" |
20 #include "webrtc/base/gtest_prod_util.h" | 21 #include "webrtc/base/gtest_prod_util.h" |
21 #include "webrtc/base/ignore_wundef.h" | 22 #include "webrtc/base/ignore_wundef.h" |
22 #include "webrtc/base/swap_queue.h" | 23 #include "webrtc/base/swap_queue.h" |
23 #include "webrtc/base/thread_annotations.h" | 24 #include "webrtc/base/thread_annotations.h" |
24 #include "webrtc/modules/audio_processing/audio_buffer.h" | 25 #include "webrtc/modules/audio_processing/audio_buffer.h" |
25 #include "webrtc/modules/audio_processing/include/audio_processing.h" | 26 #include "webrtc/modules/audio_processing/include/audio_processing.h" |
26 #include "webrtc/modules/audio_processing/render_queue_item_verifier.h" | 27 #include "webrtc/modules/audio_processing/render_queue_item_verifier.h" |
27 #include "webrtc/system_wrappers/include/file_wrapper.h" | 28 #include "webrtc/system_wrappers/include/file_wrapper.h" |
28 | 29 |
29 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | 30 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 AudioProcessingStatistics GetStatistics() const override; | 120 AudioProcessingStatistics GetStatistics() const override; |
120 | 121 |
121 // Methods returning pointers to APM submodules. | 122 // Methods returning pointers to APM submodules. |
122 // No locks are aquired in those, as those locks | 123 // No locks are aquired in those, as those locks |
123 // would offer no protection (the submodules are | 124 // would offer no protection (the submodules are |
124 // created only once in a single-treaded manner | 125 // created only once in a single-treaded manner |
125 // during APM creation). | 126 // during APM creation). |
126 EchoCancellation* echo_cancellation() const override; | 127 EchoCancellation* echo_cancellation() const override; |
127 EchoControlMobile* echo_control_mobile() const override; | 128 EchoControlMobile* echo_control_mobile() const override; |
128 GainControl* gain_control() const override; | 129 GainControl* gain_control() const override; |
| 130 // TODO(peah): Deprecate this API call. |
129 HighPassFilter* high_pass_filter() const override; | 131 HighPassFilter* high_pass_filter() const override; |
130 LevelEstimator* level_estimator() const override; | 132 LevelEstimator* level_estimator() const override; |
131 NoiseSuppression* noise_suppression() const override; | 133 NoiseSuppression* noise_suppression() const override; |
132 VoiceDetection* voice_detection() const override; | 134 VoiceDetection* voice_detection() const override; |
133 | 135 |
| 136 // TODO(peah): Remove these two methods once the new API allows that. |
| 137 void MutateConfig(rtc::FunctionView<void(AudioProcessing::Config*)> mutator); |
| 138 AudioProcessing::Config GetConfig() const; |
| 139 |
134 protected: | 140 protected: |
135 // Overridden in a mock. | 141 // Overridden in a mock. |
136 virtual int InitializeLocked() | 142 virtual int InitializeLocked() |
137 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 143 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
138 | 144 |
139 private: | 145 private: |
140 // TODO(peah): These friend classes should be removed as soon as the new | 146 // TODO(peah): These friend classes should be removed as soon as the new |
141 // parameter setting scheme allows. | 147 // parameter setting scheme allows. |
142 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, DefaultBehavior); | 148 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, DefaultBehavior); |
143 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, ValidConfigBehavior); | 149 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, ValidConfigBehavior); |
144 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, InValidConfigBehavior); | 150 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, InValidConfigBehavior); |
145 struct ApmPublicSubmodules; | 151 struct ApmPublicSubmodules; |
146 struct ApmPrivateSubmodules; | 152 struct ApmPrivateSubmodules; |
147 | 153 |
| 154 // Submodule interface implementations. |
| 155 std::unique_ptr<HighPassFilter> high_pass_filter_impl_; |
| 156 |
148 class ApmSubmoduleStates { | 157 class ApmSubmoduleStates { |
149 public: | 158 public: |
150 ApmSubmoduleStates(); | 159 ApmSubmoduleStates(); |
151 // Updates the submodule state and returns true if it has changed. | 160 // Updates the submodule state and returns true if it has changed. |
152 bool Update(bool high_pass_filter_enabled, | 161 bool Update(bool low_cut_filter_enabled, |
153 bool echo_canceller_enabled, | 162 bool echo_canceller_enabled, |
154 bool mobile_echo_controller_enabled, | 163 bool mobile_echo_controller_enabled, |
155 bool residual_echo_detector_enabled, | 164 bool residual_echo_detector_enabled, |
156 bool noise_suppressor_enabled, | 165 bool noise_suppressor_enabled, |
157 bool intelligibility_enhancer_enabled, | 166 bool intelligibility_enhancer_enabled, |
158 bool beamformer_enabled, | 167 bool beamformer_enabled, |
159 bool adaptive_gain_controller_enabled, | 168 bool adaptive_gain_controller_enabled, |
160 bool level_controller_enabled, | 169 bool level_controller_enabled, |
161 bool voice_activity_detector_enabled, | 170 bool voice_activity_detector_enabled, |
162 bool level_estimator_enabled, | 171 bool level_estimator_enabled, |
163 bool transient_suppressor_enabled); | 172 bool transient_suppressor_enabled); |
164 bool CaptureMultiBandSubModulesActive() const; | 173 bool CaptureMultiBandSubModulesActive() const; |
165 bool CaptureMultiBandProcessingActive() const; | 174 bool CaptureMultiBandProcessingActive() const; |
166 bool RenderMultiBandSubModulesActive() const; | 175 bool RenderMultiBandSubModulesActive() const; |
167 bool RenderMultiBandProcessingActive() const; | 176 bool RenderMultiBandProcessingActive() const; |
168 | 177 |
169 private: | 178 private: |
170 bool high_pass_filter_enabled_ = false; | 179 bool low_cut_filter_enabled_ = false; |
171 bool echo_canceller_enabled_ = false; | 180 bool echo_canceller_enabled_ = false; |
172 bool mobile_echo_controller_enabled_ = false; | 181 bool mobile_echo_controller_enabled_ = false; |
173 bool residual_echo_detector_enabled_ = false; | 182 bool residual_echo_detector_enabled_ = false; |
174 bool noise_suppressor_enabled_ = false; | 183 bool noise_suppressor_enabled_ = false; |
175 bool intelligibility_enhancer_enabled_ = false; | 184 bool intelligibility_enhancer_enabled_ = false; |
176 bool beamformer_enabled_ = false; | 185 bool beamformer_enabled_ = false; |
177 bool adaptive_gain_controller_enabled_ = false; | 186 bool adaptive_gain_controller_enabled_ = false; |
178 bool level_controller_enabled_ = false; | 187 bool level_controller_enabled_ = false; |
179 bool level_estimator_enabled_ = false; | 188 bool level_estimator_enabled_ = false; |
180 bool voice_activity_detector_enabled_ = false; | 189 bool voice_activity_detector_enabled_ = false; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 242 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
234 void InitializeBeamformer() | 243 void InitializeBeamformer() |
235 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 244 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
236 void InitializeIntelligibility() | 245 void InitializeIntelligibility() |
237 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 246 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
238 int InitializeLocked(const ProcessingConfig& config) | 247 int InitializeLocked(const ProcessingConfig& config) |
239 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 248 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
240 void InitializeLevelController() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | 249 void InitializeLevelController() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
241 void InitializeResidualEchoDetector() | 250 void InitializeResidualEchoDetector() |
242 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 251 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 252 void InitializeLowCutFilter() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
243 | 253 |
244 void EmptyQueuedRenderAudio(); | 254 void EmptyQueuedRenderAudio(); |
245 void AllocateRenderQueue() | 255 void AllocateRenderQueue() |
246 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 256 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
247 void QueueRenderAudio(AudioBuffer* audio) | 257 void QueueRenderAudio(AudioBuffer* audio) |
248 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | 258 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
249 | 259 |
250 // Capture-side exclusive methods possibly running APM in a multi-threaded | 260 // Capture-side exclusive methods possibly running APM in a multi-threaded |
251 // manner that are called with the render lock already acquired. | 261 // manner that are called with the render lock already acquired. |
252 int ProcessCaptureStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | 262 int ProcessCaptureStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
405 std::unique_ptr< | 415 std::unique_ptr< |
406 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> | 416 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> |
407 agc_render_signal_queue_; | 417 agc_render_signal_queue_; |
408 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> | 418 std::unique_ptr<SwapQueue<std::vector<float>, RenderQueueItemVerifier<float>>> |
409 red_render_signal_queue_; | 419 red_render_signal_queue_; |
410 }; | 420 }; |
411 | 421 |
412 } // namespace webrtc | 422 } // namespace webrtc |
413 | 423 |
414 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 424 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
OLD | NEW |