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 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 struct AudioProcessingImpl::ApmPrivateSubmodules { | 147 struct AudioProcessingImpl::ApmPrivateSubmodules { |
148 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) | 148 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) |
149 : beamformer(beamformer) {} | 149 : beamformer(beamformer) {} |
150 // Accessed internally from capture or during initialization | 150 // Accessed internally from capture or during initialization |
151 std::unique_ptr<NonlinearBeamformer> beamformer; | 151 std::unique_ptr<NonlinearBeamformer> beamformer; |
152 std::unique_ptr<AgcManagerDirect> agc_manager; | 152 std::unique_ptr<AgcManagerDirect> agc_manager; |
153 std::unique_ptr<LevelController> level_controller; | 153 std::unique_ptr<LevelController> level_controller; |
154 }; | 154 }; |
155 | 155 |
156 AudioProcessing* AudioProcessing::Create() { | 156 AudioProcessing* AudioProcessing::Create() { |
157 webrtc::Config config; | 157 Config config; |
158 return Create(config, nullptr); | 158 return Create(config, nullptr); |
159 } | 159 } |
160 | 160 |
161 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) { | 161 AudioProcessing* AudioProcessing::Create(const Config& config) { |
162 return Create(config, nullptr); | 162 return Create(config, nullptr); |
163 } | 163 } |
164 | 164 |
165 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config, | 165 AudioProcessing* AudioProcessing::Create(const Config& config, |
166 NonlinearBeamformer* beamformer) { | 166 NonlinearBeamformer* beamformer) { |
167 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); | 167 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); |
168 if (apm->Initialize() != kNoError) { | 168 if (apm->Initialize() != kNoError) { |
169 delete apm; | 169 delete apm; |
170 apm = nullptr; | 170 apm = nullptr; |
171 } | 171 } |
172 | 172 |
173 return apm; | 173 return apm; |
174 } | 174 } |
175 | 175 |
176 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config) | 176 AudioProcessingImpl::AudioProcessingImpl(const Config& config) |
177 : AudioProcessingImpl(config, nullptr) {} | 177 : AudioProcessingImpl(config, nullptr) {} |
178 | 178 |
179 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config, | 179 AudioProcessingImpl::AudioProcessingImpl(const Config& config, |
180 NonlinearBeamformer* beamformer) | 180 NonlinearBeamformer* beamformer) |
181 : public_submodules_(new ApmPublicSubmodules()), | 181 : public_submodules_(new ApmPublicSubmodules()), |
182 private_submodules_(new ApmPrivateSubmodules(beamformer)), | 182 private_submodules_(new ApmPrivateSubmodules(beamformer)), |
183 constants_(config.Get<ExperimentalAgc>().startup_min_volume, | 183 constants_(config.Get<ExperimentalAgc>().startup_min_volume, |
184 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 184 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
185 false), | 185 false), |
186 #else | 186 #else |
187 config.Get<ExperimentalAgc>().enabled), | 187 config.Get<ExperimentalAgc>().enabled), |
188 #endif | 188 #endif |
189 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 189 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
190 capture_(false, | 190 capture_(false, |
191 #else | 191 #else |
192 capture_(config.Get<ExperimentalNs>().enabled, | 192 capture_(config.Get<ExperimentalNs>().enabled, |
193 #endif | 193 #endif |
194 config.Get<Beamforming>().array_geometry, | 194 config.Get<Beamforming>().array_geometry, |
195 config.Get<Beamforming>().target_direction), | 195 config.Get<Beamforming>().target_direction), |
196 capture_nonlocked_(config.Get<Beamforming>().enabled, | 196 capture_nonlocked_(config.Get<Beamforming>().enabled, |
197 config.Get<Intelligibility>().enabled) { | 197 config.Get<Intelligibility>().enabled, |
| 198 config.Get<LevelControl>().enabled) { |
198 { | 199 { |
199 rtc::CritScope cs_render(&crit_render_); | 200 rtc::CritScope cs_render(&crit_render_); |
200 rtc::CritScope cs_capture(&crit_capture_); | 201 rtc::CritScope cs_capture(&crit_capture_); |
201 | 202 |
202 public_submodules_->echo_cancellation.reset( | 203 public_submodules_->echo_cancellation.reset( |
203 new EchoCancellationImpl(&crit_render_, &crit_capture_)); | 204 new EchoCancellationImpl(&crit_render_, &crit_capture_)); |
204 public_submodules_->echo_control_mobile.reset( | 205 public_submodules_->echo_control_mobile.reset( |
205 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); | 206 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); |
206 public_submodules_->gain_control.reset( | 207 public_submodules_->gain_control.reset( |
207 new GainControlImpl(&crit_capture_, &crit_capture_)); | 208 new GainControlImpl(&crit_capture_, &crit_capture_)); |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { | 425 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { |
425 capture_nonlocked_.split_rate = kSampleRate16kHz; | 426 capture_nonlocked_.split_rate = kSampleRate16kHz; |
426 } else { | 427 } else { |
427 capture_nonlocked_.split_rate = | 428 capture_nonlocked_.split_rate = |
428 capture_nonlocked_.fwd_proc_format.sample_rate_hz(); | 429 capture_nonlocked_.fwd_proc_format.sample_rate_hz(); |
429 } | 430 } |
430 | 431 |
431 return InitializeLocked(); | 432 return InitializeLocked(); |
432 } | 433 } |
433 | 434 |
434 void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) { | 435 void AudioProcessingImpl::SetExtraOptions(const Config& config) { |
435 AudioProcessing::Config config_to_use = config; | |
436 | |
437 bool config_ok = LevelController::Validate(config_to_use.level_controller); | |
438 if (!config_ok) { | |
439 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl | |
440 << "level_controller: " | |
441 << LevelController::ToString(config_to_use.level_controller) | |
442 << std::endl | |
443 << "Reverting to default parameter set"; | |
444 config_to_use.level_controller = AudioProcessing::Config::LevelController(); | |
445 } | |
446 | |
447 // Run in a single-threaded manner when applying the settings. | |
448 rtc::CritScope cs_render(&crit_render_); | |
449 rtc::CritScope cs_capture(&crit_capture_); | |
450 | |
451 if (config.level_controller.enabled != | |
452 capture_nonlocked_.level_controller_enabled) { | |
453 InitializeLevelController(); | |
454 LOG(LS_INFO) << "Level controller activated: " | |
455 << capture_nonlocked_.level_controller_enabled; | |
456 capture_nonlocked_.level_controller_enabled = | |
457 config.level_controller.enabled; | |
458 } | |
459 } | |
460 | |
461 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { | |
462 // Run in a single-threaded manner when setting the extra options. | 436 // Run in a single-threaded manner when setting the extra options. |
463 rtc::CritScope cs_render(&crit_render_); | 437 rtc::CritScope cs_render(&crit_render_); |
464 rtc::CritScope cs_capture(&crit_capture_); | 438 rtc::CritScope cs_capture(&crit_capture_); |
465 | 439 |
466 public_submodules_->echo_cancellation->SetExtraOptions(config); | 440 public_submodules_->echo_cancellation->SetExtraOptions(config); |
467 | 441 |
468 if (capture_.transient_suppressor_enabled != | 442 if (capture_.transient_suppressor_enabled != |
469 config.Get<ExperimentalNs>().enabled) { | 443 config.Get<ExperimentalNs>().enabled) { |
470 capture_.transient_suppressor_enabled = | 444 capture_.transient_suppressor_enabled = |
471 config.Get<ExperimentalNs>().enabled; | 445 config.Get<ExperimentalNs>().enabled; |
472 InitializeTransient(); | 446 InitializeTransient(); |
473 } | 447 } |
474 | 448 |
| 449 if (capture_nonlocked_.level_controller_enabled != |
| 450 config.Get<LevelControl>().enabled) { |
| 451 capture_nonlocked_.level_controller_enabled = |
| 452 config.Get<LevelControl>().enabled; |
| 453 LOG(LS_INFO) << "Level controller activated: " |
| 454 << config.Get<LevelControl>().enabled; |
| 455 |
| 456 InitializeLevelController(); |
| 457 } |
| 458 |
475 #if WEBRTC_INTELLIGIBILITY_ENHANCER | 459 #if WEBRTC_INTELLIGIBILITY_ENHANCER |
476 if(capture_nonlocked_.intelligibility_enabled != | 460 if(capture_nonlocked_.intelligibility_enabled != |
477 config.Get<Intelligibility>().enabled) { | 461 config.Get<Intelligibility>().enabled) { |
478 capture_nonlocked_.intelligibility_enabled = | 462 capture_nonlocked_.intelligibility_enabled = |
479 config.Get<Intelligibility>().enabled; | 463 config.Get<Intelligibility>().enabled; |
480 InitializeIntelligibility(); | 464 InitializeIntelligibility(); |
481 } | 465 } |
482 #endif | 466 #endif |
483 | 467 |
484 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 468 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1577 fwd_proc_format(kSampleRate16kHz), | 1561 fwd_proc_format(kSampleRate16kHz), |
1578 split_rate(kSampleRate16kHz) {} | 1562 split_rate(kSampleRate16kHz) {} |
1579 | 1563 |
1580 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; | 1564 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; |
1581 | 1565 |
1582 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; | 1566 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; |
1583 | 1567 |
1584 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; | 1568 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; |
1585 | 1569 |
1586 } // namespace webrtc | 1570 } // namespace webrtc |
OLD | NEW |