Chromium Code Reviews| 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/gtest_prod_util.h" | 20 #include "webrtc/base/gtest_prod_util.h" |
| 21 #include "webrtc/base/ignore_wundef.h" | 21 #include "webrtc/base/ignore_wundef.h" |
| 22 #include "webrtc/base/swap_queue.h" | 22 #include "webrtc/base/swap_queue.h" |
| 23 #include "webrtc/base/thread_annotations.h" | 23 #include "webrtc/base/thread_annotations.h" |
| 24 #include "webrtc/modules/audio_processing/audio_buffer.h" | 24 #include "webrtc/modules/audio_processing/audio_buffer.h" |
| 25 #include "webrtc/modules/audio_processing/high_pass_filter_impl.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 |
| 30 // Files generated at build-time by the protobuf compiler. | 31 // Files generated at build-time by the protobuf compiler. |
| 31 RTC_PUSH_IGNORING_WUNDEF() | 32 RTC_PUSH_IGNORING_WUNDEF() |
| 32 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 33 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
| 33 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" | 34 #include "external/webrtc/webrtc/modules/audio_processing/debug.pb.h" |
| 34 #else | 35 #else |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 117 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | 118 EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 118 | 119 |
| 119 // Methods returning pointers to APM submodules. | 120 // Methods returning pointers to APM submodules. |
| 120 // No locks are aquired in those, as those locks | 121 // No locks are aquired in those, as those locks |
| 121 // would offer no protection (the submodules are | 122 // would offer no protection (the submodules are |
| 122 // created only once in a single-treaded manner | 123 // created only once in a single-treaded manner |
| 123 // during APM creation). | 124 // during APM creation). |
| 124 EchoCancellation* echo_cancellation() const override; | 125 EchoCancellation* echo_cancellation() const override; |
| 125 EchoControlMobile* echo_control_mobile() const override; | 126 EchoControlMobile* echo_control_mobile() const override; |
| 126 GainControl* gain_control() const override; | 127 GainControl* gain_control() const override; |
| 128 // TODO(peah): Deprecate this API call. | |
| 127 HighPassFilter* high_pass_filter() const override; | 129 HighPassFilter* high_pass_filter() const override; |
| 128 LevelEstimator* level_estimator() const override; | 130 LevelEstimator* level_estimator() const override; |
| 129 NoiseSuppression* noise_suppression() const override; | 131 NoiseSuppression* noise_suppression() const override; |
| 130 VoiceDetection* voice_detection() const override; | 132 VoiceDetection* voice_detection() const override; |
| 131 | 133 |
| 134 // TODO(peah): Remove these two methods once the new API allows that. | |
| 135 template <typename MutatorFunction> | |
| 136 void MutateConfig(MutatorFunction mutator) { | |
|
the sun
2016/10/28 10:52:53
Nice! Can we do without it being a template though
kwiberg-webrtc
2016/10/28 11:07:00
rtc::FunctionView is the right thing to use in a c
peah-webrtc
2016/10/28 12:19:52
Great suggestion!
Done.
peah-webrtc
2016/10/28 12:19:52
Thanks! I think the FunctionView became really nic
kwiberg-webrtc
2016/10/28 12:28:56
No, you used std::function instead (which will als
peah-webrtc
2016/10/28 12:36:12
You are right! I tried both locally and removed th
| |
| 137 rtc::CritScope cs_render(&crit_render_); | |
| 138 rtc::CritScope cs_capture(&crit_capture_); | |
| 139 mutator(&config_); | |
| 140 ApplyConfig(config_); | |
| 141 } | |
| 142 | |
| 143 AudioProcessing::Config GetConfig() const { | |
| 144 rtc::CritScope cs_render(&crit_render_); | |
| 145 rtc::CritScope cs_capture(&crit_capture_); | |
| 146 return config_; | |
| 147 } | |
| 148 | |
| 132 protected: | 149 protected: |
| 133 // Overridden in a mock. | 150 // Overridden in a mock. |
| 134 virtual int InitializeLocked() | 151 virtual int InitializeLocked() |
| 135 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 152 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 136 | 153 |
| 137 private: | 154 private: |
| 138 // TODO(peah): These friend classes should be removed as soon as the new | 155 // TODO(peah): These friend classes should be removed as soon as the new |
| 139 // parameter setting scheme allows. | 156 // parameter setting scheme allows. |
| 140 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, DefaultBehavior); | 157 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, DefaultBehavior); |
| 141 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, ValidConfigBehavior); | 158 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, ValidConfigBehavior); |
| 142 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, InValidConfigBehavior); | 159 FRIEND_TEST_ALL_PREFIXES(ApmConfiguration, InValidConfigBehavior); |
| 143 struct ApmPublicSubmodules; | 160 struct ApmPublicSubmodules; |
| 144 struct ApmPrivateSubmodules; | 161 struct ApmPrivateSubmodules; |
| 145 | 162 |
| 163 // Submodule interface implementations. | |
| 164 std::unique_ptr<HighPassFilterImpl> high_pass_filter_impl_; | |
|
the sun
2016/10/28 10:52:53
I don't see why you couldn't have a pointer to a H
peah-webrtc
2016/10/28 12:19:52
That is an awesome suggestion!!!
Done.
| |
| 165 | |
| 146 class ApmSubmoduleStates { | 166 class ApmSubmoduleStates { |
| 147 public: | 167 public: |
| 148 ApmSubmoduleStates(); | 168 ApmSubmoduleStates(); |
| 149 // Updates the submodule state and returns true if it has changed. | 169 // Updates the submodule state and returns true if it has changed. |
| 150 bool Update(bool high_pass_filter_enabled, | 170 bool Update(bool high_pass_filter_enabled, |
| 151 bool echo_canceller_enabled, | 171 bool echo_canceller_enabled, |
| 152 bool mobile_echo_controller_enabled, | 172 bool mobile_echo_controller_enabled, |
| 153 bool noise_suppressor_enabled, | 173 bool noise_suppressor_enabled, |
| 154 bool intelligibility_enhancer_enabled, | 174 bool intelligibility_enhancer_enabled, |
| 155 bool beamformer_enabled, | 175 bool beamformer_enabled, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 // acquired. | 247 // acquired. |
| 228 void InitializeTransient() | 248 void InitializeTransient() |
| 229 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 249 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 230 void InitializeBeamformer() | 250 void InitializeBeamformer() |
| 231 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 251 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 232 void InitializeIntelligibility() | 252 void InitializeIntelligibility() |
| 233 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 253 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 234 int InitializeLocked(const ProcessingConfig& config) | 254 int InitializeLocked(const ProcessingConfig& config) |
| 235 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 255 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 236 void InitializeLevelController() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | 256 void InitializeLevelController() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| 257 void InitializeHighPassFilter() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | |
| 237 | 258 |
| 238 void EmptyQueuedRenderAudio(); | 259 void EmptyQueuedRenderAudio(); |
| 239 void AllocateRenderQueue() | 260 void AllocateRenderQueue() |
| 240 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); | 261 EXCLUSIVE_LOCKS_REQUIRED(crit_render_, crit_capture_); |
| 241 void QueueRenderAudio(AudioBuffer* audio) | 262 void QueueRenderAudio(AudioBuffer* audio) |
| 242 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); | 263 EXCLUSIVE_LOCKS_REQUIRED(crit_render_); |
| 243 | 264 |
| 244 // Capture-side exclusive methods possibly running APM in a multi-threaded | 265 // Capture-side exclusive methods possibly running APM in a multi-threaded |
| 245 // manner that are called with the render lock already acquired. | 266 // manner that are called with the render lock already acquired. |
| 246 int ProcessCaptureStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); | 267 int ProcessCaptureStreamLocked() EXCLUSIVE_LOCKS_REQUIRED(crit_capture_); |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 393 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> | 414 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> |
| 394 aecm_render_signal_queue_; | 415 aecm_render_signal_queue_; |
| 395 std::unique_ptr< | 416 std::unique_ptr< |
| 396 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> | 417 SwapQueue<std::vector<int16_t>, RenderQueueItemVerifier<int16_t>>> |
| 397 agc_render_signal_queue_; | 418 agc_render_signal_queue_; |
| 398 }; | 419 }; |
| 399 | 420 |
| 400 } // namespace webrtc | 421 } // namespace webrtc |
| 401 | 422 |
| 402 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ | 423 #endif // WEBRTC_MODULES_AUDIO_PROCESSING_AUDIO_PROCESSING_IMPL_H_ |
| OLD | NEW |