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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 struct AudioProcessingImpl::ApmPrivateSubmodules { | 234 struct AudioProcessingImpl::ApmPrivateSubmodules { |
235 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) | 235 explicit ApmPrivateSubmodules(NonlinearBeamformer* beamformer) |
236 : beamformer(beamformer) {} | 236 : beamformer(beamformer) {} |
237 // Accessed internally from capture or during initialization | 237 // Accessed internally from capture or during initialization |
238 std::unique_ptr<NonlinearBeamformer> beamformer; | 238 std::unique_ptr<NonlinearBeamformer> beamformer; |
239 std::unique_ptr<AgcManagerDirect> agc_manager; | 239 std::unique_ptr<AgcManagerDirect> agc_manager; |
240 std::unique_ptr<LevelController> level_controller; | 240 std::unique_ptr<LevelController> level_controller; |
241 }; | 241 }; |
242 | 242 |
243 AudioProcessing* AudioProcessing::Create() { | 243 AudioProcessing* AudioProcessing::Create() { |
244 Config config; | 244 webrtc::Config config; |
245 return Create(config, nullptr); | 245 return Create(config, nullptr); |
246 } | 246 } |
247 | 247 |
248 AudioProcessing* AudioProcessing::Create(const Config& config) { | 248 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config) { |
249 return Create(config, nullptr); | 249 return Create(config, nullptr); |
250 } | 250 } |
251 | 251 |
252 AudioProcessing* AudioProcessing::Create(const Config& config, | 252 AudioProcessing* AudioProcessing::Create(const webrtc::Config& config, |
253 NonlinearBeamformer* beamformer) { | 253 NonlinearBeamformer* beamformer) { |
254 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); | 254 AudioProcessingImpl* apm = new AudioProcessingImpl(config, beamformer); |
255 if (apm->Initialize() != kNoError) { | 255 if (apm->Initialize() != kNoError) { |
256 delete apm; | 256 delete apm; |
257 apm = nullptr; | 257 apm = nullptr; |
258 } | 258 } |
259 | 259 |
260 return apm; | 260 return apm; |
261 } | 261 } |
262 | 262 |
263 AudioProcessingImpl::AudioProcessingImpl(const Config& config) | 263 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config) |
264 : AudioProcessingImpl(config, nullptr) {} | 264 : AudioProcessingImpl(config, nullptr) {} |
265 | 265 |
266 AudioProcessingImpl::AudioProcessingImpl(const Config& config, | 266 AudioProcessingImpl::AudioProcessingImpl(const webrtc::Config& config, |
267 NonlinearBeamformer* beamformer) | 267 NonlinearBeamformer* beamformer) |
268 : public_submodules_(new ApmPublicSubmodules()), | 268 : public_submodules_(new ApmPublicSubmodules()), |
269 private_submodules_(new ApmPrivateSubmodules(beamformer)), | 269 private_submodules_(new ApmPrivateSubmodules(beamformer)), |
270 constants_(config.Get<ExperimentalAgc>().startup_min_volume, | 270 constants_(config.Get<ExperimentalAgc>().startup_min_volume, |
271 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 271 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
272 false), | 272 false), |
273 #else | 273 #else |
274 config.Get<ExperimentalAgc>().enabled), | 274 config.Get<ExperimentalAgc>().enabled), |
275 #endif | 275 #endif |
276 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) | 276 #if defined(WEBRTC_ANDROID) || defined(WEBRTC_IOS) |
277 capture_(false, | 277 capture_(false, |
278 #else | 278 #else |
279 capture_(config.Get<ExperimentalNs>().enabled, | 279 capture_(config.Get<ExperimentalNs>().enabled, |
280 #endif | 280 #endif |
281 config.Get<Beamforming>().array_geometry, | 281 config.Get<Beamforming>().array_geometry, |
282 config.Get<Beamforming>().target_direction), | 282 config.Get<Beamforming>().target_direction), |
283 capture_nonlocked_(config.Get<Beamforming>().enabled, | 283 capture_nonlocked_(config.Get<Beamforming>().enabled, |
284 config.Get<Intelligibility>().enabled, | 284 config.Get<Intelligibility>().enabled) { |
285 config.Get<LevelControl>().enabled) { | |
286 { | 285 { |
287 rtc::CritScope cs_render(&crit_render_); | 286 rtc::CritScope cs_render(&crit_render_); |
288 rtc::CritScope cs_capture(&crit_capture_); | 287 rtc::CritScope cs_capture(&crit_capture_); |
289 | 288 |
290 public_submodules_->echo_cancellation.reset( | 289 public_submodules_->echo_cancellation.reset( |
291 new EchoCancellationImpl(&crit_render_, &crit_capture_)); | 290 new EchoCancellationImpl(&crit_render_, &crit_capture_)); |
292 public_submodules_->echo_control_mobile.reset( | 291 public_submodules_->echo_control_mobile.reset( |
293 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); | 292 new EchoControlMobileImpl(&crit_render_, &crit_capture_)); |
294 public_submodules_->gain_control.reset( | 293 public_submodules_->gain_control.reset( |
295 new GainControlImpl(&crit_capture_, &crit_capture_)); | 294 new GainControlImpl(&crit_capture_, &crit_capture_)); |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
523 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { | 522 capture_nonlocked_.fwd_proc_format.sample_rate_hz() == kSampleRate48kHz) { |
524 capture_nonlocked_.split_rate = kSampleRate16kHz; | 523 capture_nonlocked_.split_rate = kSampleRate16kHz; |
525 } else { | 524 } else { |
526 capture_nonlocked_.split_rate = | 525 capture_nonlocked_.split_rate = |
527 capture_nonlocked_.fwd_proc_format.sample_rate_hz(); | 526 capture_nonlocked_.fwd_proc_format.sample_rate_hz(); |
528 } | 527 } |
529 | 528 |
530 return InitializeLocked(); | 529 return InitializeLocked(); |
531 } | 530 } |
532 | 531 |
533 void AudioProcessingImpl::SetExtraOptions(const Config& config) { | 532 void AudioProcessingImpl::ApplyConfig(const AudioProcessing::Config& config) { |
| 533 AudioProcessing::Config config_to_use = config; |
| 534 |
| 535 bool config_ok = LevelController::Validate(config_to_use.level_controller); |
| 536 if (!config_ok) { |
| 537 LOG(LS_ERROR) << "AudioProcessing module config error" << std::endl |
| 538 << "level_controller: " |
| 539 << LevelController::ToString(config_to_use.level_controller) |
| 540 << std::endl |
| 541 << "Reverting to default parameter set"; |
| 542 config_to_use.level_controller = AudioProcessing::Config::LevelController(); |
| 543 } |
| 544 |
| 545 // Run in a single-threaded manner when applying the settings. |
| 546 rtc::CritScope cs_render(&crit_render_); |
| 547 rtc::CritScope cs_capture(&crit_capture_); |
| 548 |
| 549 if (config.level_controller.enabled != |
| 550 capture_nonlocked_.level_controller_enabled) { |
| 551 InitializeLevelController(); |
| 552 LOG(LS_INFO) << "Level controller activated: " |
| 553 << capture_nonlocked_.level_controller_enabled; |
| 554 capture_nonlocked_.level_controller_enabled = |
| 555 config.level_controller.enabled; |
| 556 } |
| 557 } |
| 558 |
| 559 void AudioProcessingImpl::SetExtraOptions(const webrtc::Config& config) { |
534 // Run in a single-threaded manner when setting the extra options. | 560 // Run in a single-threaded manner when setting the extra options. |
535 rtc::CritScope cs_render(&crit_render_); | 561 rtc::CritScope cs_render(&crit_render_); |
536 rtc::CritScope cs_capture(&crit_capture_); | 562 rtc::CritScope cs_capture(&crit_capture_); |
537 | 563 |
538 public_submodules_->echo_cancellation->SetExtraOptions(config); | 564 public_submodules_->echo_cancellation->SetExtraOptions(config); |
539 | 565 |
540 if (capture_.transient_suppressor_enabled != | 566 if (capture_.transient_suppressor_enabled != |
541 config.Get<ExperimentalNs>().enabled) { | 567 config.Get<ExperimentalNs>().enabled) { |
542 capture_.transient_suppressor_enabled = | 568 capture_.transient_suppressor_enabled = |
543 config.Get<ExperimentalNs>().enabled; | 569 config.Get<ExperimentalNs>().enabled; |
544 InitializeTransient(); | 570 InitializeTransient(); |
545 } | 571 } |
546 | 572 |
547 if (capture_nonlocked_.level_controller_enabled != | |
548 config.Get<LevelControl>().enabled) { | |
549 capture_nonlocked_.level_controller_enabled = | |
550 config.Get<LevelControl>().enabled; | |
551 LOG(LS_INFO) << "Level controller activated: " | |
552 << config.Get<LevelControl>().enabled; | |
553 | |
554 InitializeLevelController(); | |
555 } | |
556 | |
557 #if WEBRTC_INTELLIGIBILITY_ENHANCER | 573 #if WEBRTC_INTELLIGIBILITY_ENHANCER |
558 if(capture_nonlocked_.intelligibility_enabled != | 574 if(capture_nonlocked_.intelligibility_enabled != |
559 config.Get<Intelligibility>().enabled) { | 575 config.Get<Intelligibility>().enabled) { |
560 capture_nonlocked_.intelligibility_enabled = | 576 capture_nonlocked_.intelligibility_enabled = |
561 config.Get<Intelligibility>().enabled; | 577 config.Get<Intelligibility>().enabled; |
562 InitializeIntelligibility(); | 578 InitializeIntelligibility(); |
563 } | 579 } |
564 #endif | 580 #endif |
565 | 581 |
566 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD | 582 #ifdef WEBRTC_ANDROID_PLATFORM_BUILD |
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1598 fwd_proc_format(kSampleRate16kHz), | 1614 fwd_proc_format(kSampleRate16kHz), |
1599 split_rate(kSampleRate16kHz) {} | 1615 split_rate(kSampleRate16kHz) {} |
1600 | 1616 |
1601 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; | 1617 AudioProcessingImpl::ApmCaptureState::~ApmCaptureState() = default; |
1602 | 1618 |
1603 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; | 1619 AudioProcessingImpl::ApmRenderState::ApmRenderState() = default; |
1604 | 1620 |
1605 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; | 1621 AudioProcessingImpl::ApmRenderState::~ApmRenderState() = default; |
1606 | 1622 |
1607 } // namespace webrtc | 1623 } // namespace webrtc |
OLD | NEW |