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

Side by Side Diff: webrtc/modules/audio_processing/audio_processing_impl.cc

Issue 1772553002: Removed the ProcessingComponent class (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@RemoveComponentFromAGC_CL
Patch Set: Changed file name of the queue verifier Created 4 years, 9 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) 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
(...skipping 15 matching lines...) Expand all
26 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h" 26 #include "webrtc/modules/audio_processing/beamformer/nonlinear_beamformer.h"
27 #include "webrtc/modules/audio_processing/common.h" 27 #include "webrtc/modules/audio_processing/common.h"
28 #include "webrtc/modules/audio_processing/echo_cancellation_impl.h" 28 #include "webrtc/modules/audio_processing/echo_cancellation_impl.h"
29 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h" 29 #include "webrtc/modules/audio_processing/echo_control_mobile_impl.h"
30 #include "webrtc/modules/audio_processing/gain_control_for_experimental_agc.h" 30 #include "webrtc/modules/audio_processing/gain_control_for_experimental_agc.h"
31 #include "webrtc/modules/audio_processing/gain_control_impl.h" 31 #include "webrtc/modules/audio_processing/gain_control_impl.h"
32 #include "webrtc/modules/audio_processing/high_pass_filter_impl.h" 32 #include "webrtc/modules/audio_processing/high_pass_filter_impl.h"
33 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc er.h" 33 #include "webrtc/modules/audio_processing/intelligibility/intelligibility_enhanc er.h"
34 #include "webrtc/modules/audio_processing/level_estimator_impl.h" 34 #include "webrtc/modules/audio_processing/level_estimator_impl.h"
35 #include "webrtc/modules/audio_processing/noise_suppression_impl.h" 35 #include "webrtc/modules/audio_processing/noise_suppression_impl.h"
36 #include "webrtc/modules/audio_processing/processing_component.h"
37 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h" 36 #include "webrtc/modules/audio_processing/transient/transient_suppressor.h"
38 #include "webrtc/modules/audio_processing/voice_detection_impl.h" 37 #include "webrtc/modules/audio_processing/voice_detection_impl.h"
39 #include "webrtc/modules/include/module_common_types.h" 38 #include "webrtc/modules/include/module_common_types.h"
40 #include "webrtc/system_wrappers/include/file_wrapper.h" 39 #include "webrtc/system_wrappers/include/file_wrapper.h"
41 #include "webrtc/system_wrappers/include/logging.h" 40 #include "webrtc/system_wrappers/include/logging.h"
42 #include "webrtc/system_wrappers/include/metrics.h" 41 #include "webrtc/system_wrappers/include/metrics.h"
43 42
44 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 43 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
45 // Files generated at build-time by the protobuf compiler. 44 // Files generated at build-time by the protobuf compiler.
46 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD 45 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 96
98 // Accessed internally from both render and capture. 97 // Accessed internally from both render and capture.
99 std::unique_ptr<TransientSuppressor> transient_suppressor; 98 std::unique_ptr<TransientSuppressor> transient_suppressor;
100 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer; 99 std::unique_ptr<IntelligibilityEnhancer> intelligibility_enhancer;
101 }; 100 };
102 101
103 struct AudioProcessingImpl::ApmPrivateSubmodules { 102 struct AudioProcessingImpl::ApmPrivateSubmodules {
104 explicit ApmPrivateSubmodules(Beamformer<float>* beamformer) 103 explicit ApmPrivateSubmodules(Beamformer<float>* beamformer)
105 : beamformer(beamformer) {} 104 : beamformer(beamformer) {}
106 // Accessed internally from capture or during initialization 105 // Accessed internally from capture or during initialization
107 std::list<ProcessingComponent*> component_list;
108 std::unique_ptr<Beamformer<float>> beamformer; 106 std::unique_ptr<Beamformer<float>> beamformer;
109 std::unique_ptr<AgcManagerDirect> agc_manager; 107 std::unique_ptr<AgcManagerDirect> agc_manager;
110 }; 108 };
111 109
112 const int AudioProcessing::kNativeSampleRatesHz[] = { 110 const int AudioProcessing::kNativeSampleRatesHz[] = {
113 AudioProcessing::kSampleRate8kHz, 111 AudioProcessing::kSampleRate8kHz,
114 AudioProcessing::kSampleRate16kHz, 112 AudioProcessing::kSampleRate16kHz,
115 AudioProcessing::kSampleRate32kHz, 113 AudioProcessing::kSampleRate32kHz,
116 AudioProcessing::kSampleRate48kHz}; 114 AudioProcessing::kSampleRate48kHz};
117 const size_t AudioProcessing::kNumNativeSampleRates = 115 const size_t AudioProcessing::kNumNativeSampleRates =
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 187
190 SetExtraOptions(config); 188 SetExtraOptions(config);
191 } 189 }
192 190
193 AudioProcessingImpl::~AudioProcessingImpl() { 191 AudioProcessingImpl::~AudioProcessingImpl() {
194 // Depends on gain_control_ and 192 // Depends on gain_control_ and
195 // public_submodules_->gain_control_for_experimental_agc. 193 // public_submodules_->gain_control_for_experimental_agc.
196 private_submodules_->agc_manager.reset(); 194 private_submodules_->agc_manager.reset();
197 // Depends on gain_control_. 195 // Depends on gain_control_.
198 public_submodules_->gain_control_for_experimental_agc.reset(); 196 public_submodules_->gain_control_for_experimental_agc.reset();
199 while (!private_submodules_->component_list.empty()) {
200 ProcessingComponent* component =
201 private_submodules_->component_list.front();
202 component->Destroy();
203 delete component;
204 private_submodules_->component_list.pop_front();
205 }
206 197
207 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP 198 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP
208 if (debug_dump_.debug_file->Open()) { 199 if (debug_dump_.debug_file->Open()) {
209 debug_dump_.debug_file->CloseFile(); 200 debug_dump_.debug_file->CloseFile();
210 } 201 }
211 #endif 202 #endif
212 } 203 }
213 204
214 int AudioProcessingImpl::Initialize() { 205 int AudioProcessingImpl::Initialize() {
215 // Run in a single-threaded manner during initialization. 206 // Run in a single-threaded manner during initialization.
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 render_.render_audio.reset(nullptr); 291 render_.render_audio.reset(nullptr);
301 render_.render_converter.reset(nullptr); 292 render_.render_converter.reset(nullptr);
302 } 293 }
303 capture_.capture_audio.reset( 294 capture_.capture_audio.reset(
304 new AudioBuffer(formats_.api_format.input_stream().num_frames(), 295 new AudioBuffer(formats_.api_format.input_stream().num_frames(),
305 formats_.api_format.input_stream().num_channels(), 296 formats_.api_format.input_stream().num_channels(),
306 capture_nonlocked_.fwd_proc_format.num_frames(), 297 capture_nonlocked_.fwd_proc_format.num_frames(),
307 fwd_audio_buffer_channels, 298 fwd_audio_buffer_channels,
308 formats_.api_format.output_stream().num_frames())); 299 formats_.api_format.output_stream().num_frames()));
309 300
310 // Initialize all components.
311 for (auto item : private_submodules_->component_list) {
312 int err = item->Initialize();
313 if (err != kNoError) {
314 return err;
315 }
316 }
317
318 InitializeGainController(); 301 InitializeGainController();
319 InitializeEchoCanceller(); 302 InitializeEchoCanceller();
320 InitializeEchoControlMobile(); 303 InitializeEchoControlMobile();
321 InitializeExperimentalAgc(); 304 InitializeExperimentalAgc();
322 InitializeTransient(); 305 InitializeTransient();
323 InitializeBeamformer(); 306 InitializeBeamformer();
324 InitializeIntelligibility(); 307 InitializeIntelligibility();
325 InitializeHighPassFilter(); 308 InitializeHighPassFilter();
326 InitializeNoiseSuppression(); 309 InitializeNoiseSuppression();
327 InitializeLevelEstimator(); 310 InitializeLevelEstimator();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 capture_nonlocked_.fwd_proc_format.sample_rate_hz(); 391 capture_nonlocked_.fwd_proc_format.sample_rate_hz();
409 } 392 }
410 393
411 return InitializeLocked(); 394 return InitializeLocked();
412 } 395 }
413 396
414 void AudioProcessingImpl::SetExtraOptions(const Config& config) { 397 void AudioProcessingImpl::SetExtraOptions(const Config& config) {
415 // Run in a single-threaded manner when setting the extra options. 398 // Run in a single-threaded manner when setting the extra options.
416 rtc::CritScope cs_render(&crit_render_); 399 rtc::CritScope cs_render(&crit_render_);
417 rtc::CritScope cs_capture(&crit_capture_); 400 rtc::CritScope cs_capture(&crit_capture_);
418 for (auto item : private_submodules_->component_list) {
419 item->SetExtraOptions(config);
420 }
421 401
422 public_submodules_->echo_cancellation->SetExtraOptions(config); 402 public_submodules_->echo_cancellation->SetExtraOptions(config);
423 403
424 if (capture_.transient_suppressor_enabled != 404 if (capture_.transient_suppressor_enabled !=
425 config.Get<ExperimentalNs>().enabled) { 405 config.Get<ExperimentalNs>().enabled) {
426 capture_.transient_suppressor_enabled = 406 capture_.transient_suppressor_enabled =
427 config.Get<ExperimentalNs>().enabled; 407 config.Get<ExperimentalNs>().enabled;
428 InitializeTransient(); 408 InitializeTransient();
429 } 409 }
430 410
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 // modify the data. 1112 // modify the data.
1133 if (capture_nonlocked_.beamformer_enabled || 1113 if (capture_nonlocked_.beamformer_enabled ||
1134 public_submodules_->high_pass_filter->is_enabled() || 1114 public_submodules_->high_pass_filter->is_enabled() ||
1135 public_submodules_->noise_suppression->is_enabled() || 1115 public_submodules_->noise_suppression->is_enabled() ||
1136 public_submodules_->echo_cancellation->is_enabled() || 1116 public_submodules_->echo_cancellation->is_enabled() ||
1137 public_submodules_->echo_control_mobile->is_enabled() || 1117 public_submodules_->echo_control_mobile->is_enabled() ||
1138 public_submodules_->gain_control->is_enabled()) { 1118 public_submodules_->gain_control->is_enabled()) {
1139 return true; 1119 return true;
1140 } 1120 }
1141 1121
1142 // All of the private submodules modify the data.
1143 for (auto item : private_submodules_->component_list) {
1144 if (item->is_component_enabled()) {
1145 return true;
1146 }
1147 }
1148
1149 // The capture data is otherwise unchanged. 1122 // The capture data is otherwise unchanged.
1150 return false; 1123 return false;
1151 } 1124 }
1152 1125
1153 bool AudioProcessingImpl::output_copy_needed(bool is_data_processed) const { 1126 bool AudioProcessingImpl::output_copy_needed(bool is_data_processed) const {
1154 // Check if we've upmixed or downmixed the audio. 1127 // Check if we've upmixed or downmixed the audio.
1155 return ((formats_.api_format.output_stream().num_channels() != 1128 return ((formats_.api_format.output_stream().num_channels() !=
1156 formats_.api_format.input_stream().num_channels()) || 1129 formats_.api_format.input_stream().num_channels()) ||
1157 is_data_processed || capture_.transient_suppressor_enabled); 1130 is_data_processed || capture_.transient_suppressor_enabled);
1158 } 1131 }
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
1465 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config); 1438 debug_dump_.capture.event_msg->mutable_config()->CopyFrom(config);
1466 1439
1467 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(), 1440 RETURN_ON_ERR(WriteMessageToDebugFile(debug_dump_.debug_file.get(),
1468 &debug_dump_.num_bytes_left_for_log_, 1441 &debug_dump_.num_bytes_left_for_log_,
1469 &crit_debug_, &debug_dump_.capture)); 1442 &crit_debug_, &debug_dump_.capture));
1470 return kNoError; 1443 return kNoError;
1471 } 1444 }
1472 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP 1445 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP
1473 1446
1474 } // namespace webrtc 1447 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698