| 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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 : crit_render_(crit_render), | 99 : crit_render_(crit_render), |
| 100 crit_capture_(crit_capture), | 100 crit_capture_(crit_capture), |
| 101 drift_compensation_enabled_(false), | 101 drift_compensation_enabled_(false), |
| 102 metrics_enabled_(false), | 102 metrics_enabled_(false), |
| 103 suppression_level_(kModerateSuppression), | 103 suppression_level_(kModerateSuppression), |
| 104 stream_drift_samples_(0), | 104 stream_drift_samples_(0), |
| 105 was_stream_drift_set_(false), | 105 was_stream_drift_set_(false), |
| 106 stream_has_echo_(false), | 106 stream_has_echo_(false), |
| 107 delay_logging_enabled_(false), | 107 delay_logging_enabled_(false), |
| 108 extended_filter_enabled_(false), | 108 extended_filter_enabled_(false), |
| 109 delay_agnostic_enabled_(false), | 109 delay_agnostic_enabled_(false) { |
| 110 aec3_enabled_(false) { | |
| 111 RTC_DCHECK(crit_render); | 110 RTC_DCHECK(crit_render); |
| 112 RTC_DCHECK(crit_capture); | 111 RTC_DCHECK(crit_capture); |
| 113 } | 112 } |
| 114 | 113 |
| 115 EchoCancellationImpl::~EchoCancellationImpl() = default; | 114 EchoCancellationImpl::~EchoCancellationImpl() = default; |
| 116 | 115 |
| 117 void EchoCancellationImpl::ProcessRenderAudio( | 116 void EchoCancellationImpl::ProcessRenderAudio( |
| 118 rtc::ArrayView<const float> packed_render_audio) { | 117 rtc::ArrayView<const float> packed_render_audio) { |
| 119 rtc::CritScope cs_capture(crit_capture_); | 118 rtc::CritScope cs_capture(crit_capture_); |
| 120 if (!enabled_) { | 119 if (!enabled_) { |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 bool EchoCancellationImpl::is_delay_logging_enabled() const { | 333 bool EchoCancellationImpl::is_delay_logging_enabled() const { |
| 335 rtc::CritScope cs(crit_capture_); | 334 rtc::CritScope cs(crit_capture_); |
| 336 return enabled_ && delay_logging_enabled_; | 335 return enabled_ && delay_logging_enabled_; |
| 337 } | 336 } |
| 338 | 337 |
| 339 bool EchoCancellationImpl::is_delay_agnostic_enabled() const { | 338 bool EchoCancellationImpl::is_delay_agnostic_enabled() const { |
| 340 rtc::CritScope cs(crit_capture_); | 339 rtc::CritScope cs(crit_capture_); |
| 341 return delay_agnostic_enabled_; | 340 return delay_agnostic_enabled_; |
| 342 } | 341 } |
| 343 | 342 |
| 344 bool EchoCancellationImpl::is_aec3_enabled() const { | |
| 345 rtc::CritScope cs(crit_capture_); | |
| 346 return aec3_enabled_; | |
| 347 } | |
| 348 | |
| 349 std::string EchoCancellationImpl::GetExperimentsDescription() { | 343 std::string EchoCancellationImpl::GetExperimentsDescription() { |
| 350 rtc::CritScope cs(crit_capture_); | 344 rtc::CritScope cs(crit_capture_); |
| 351 std::string description = (aec3_enabled_ ? "AEC3;" : ""); | 345 return refined_adaptive_filter_enabled_ ? "RefinedAdaptiveFilter;" : ""; |
| 352 if (refined_adaptive_filter_enabled_) { | |
| 353 description += "RefinedAdaptiveFilter;"; | |
| 354 } | |
| 355 return description; | |
| 356 } | 346 } |
| 357 | 347 |
| 358 bool EchoCancellationImpl::is_refined_adaptive_filter_enabled() const { | 348 bool EchoCancellationImpl::is_refined_adaptive_filter_enabled() const { |
| 359 rtc::CritScope cs(crit_capture_); | 349 rtc::CritScope cs(crit_capture_); |
| 360 return refined_adaptive_filter_enabled_; | 350 return refined_adaptive_filter_enabled_; |
| 361 } | 351 } |
| 362 | 352 |
| 363 bool EchoCancellationImpl::is_extended_filter_enabled() const { | 353 bool EchoCancellationImpl::is_extended_filter_enabled() const { |
| 364 rtc::CritScope cs(crit_capture_); | 354 rtc::CritScope cs(crit_capture_); |
| 365 return extended_filter_enabled_; | 355 return extended_filter_enabled_; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 } | 456 } |
| 467 } | 457 } |
| 468 | 458 |
| 469 void EchoCancellationImpl::SetExtraOptions(const webrtc::Config& config) { | 459 void EchoCancellationImpl::SetExtraOptions(const webrtc::Config& config) { |
| 470 { | 460 { |
| 471 rtc::CritScope cs(crit_capture_); | 461 rtc::CritScope cs(crit_capture_); |
| 472 extended_filter_enabled_ = config.Get<ExtendedFilter>().enabled; | 462 extended_filter_enabled_ = config.Get<ExtendedFilter>().enabled; |
| 473 delay_agnostic_enabled_ = config.Get<DelayAgnostic>().enabled; | 463 delay_agnostic_enabled_ = config.Get<DelayAgnostic>().enabled; |
| 474 refined_adaptive_filter_enabled_ = | 464 refined_adaptive_filter_enabled_ = |
| 475 config.Get<RefinedAdaptiveFilter>().enabled; | 465 config.Get<RefinedAdaptiveFilter>().enabled; |
| 476 aec3_enabled_ = config.Get<EchoCanceller3>().enabled; | |
| 477 } | 466 } |
| 478 Configure(); | 467 Configure(); |
| 479 } | 468 } |
| 480 | 469 |
| 481 int EchoCancellationImpl::Configure() { | 470 int EchoCancellationImpl::Configure() { |
| 482 rtc::CritScope cs_render(crit_render_); | 471 rtc::CritScope cs_render(crit_render_); |
| 483 rtc::CritScope cs_capture(crit_capture_); | 472 rtc::CritScope cs_capture(crit_capture_); |
| 484 AecConfig config; | 473 AecConfig config; |
| 485 config.metricsMode = metrics_enabled_; | 474 config.metricsMode = metrics_enabled_; |
| 486 config.nlpMode = MapSetting(suppression_level_); | 475 config.nlpMode = MapSetting(suppression_level_); |
| 487 config.skewMode = drift_compensation_enabled_; | 476 config.skewMode = drift_compensation_enabled_; |
| 488 config.delay_logging = delay_logging_enabled_; | 477 config.delay_logging = delay_logging_enabled_; |
| 489 | 478 |
| 490 int error = AudioProcessing::kNoError; | 479 int error = AudioProcessing::kNoError; |
| 491 for (auto& canceller : cancellers_) { | 480 for (auto& canceller : cancellers_) { |
| 492 WebRtcAec_enable_extended_filter(WebRtcAec_aec_core(canceller->state()), | 481 WebRtcAec_enable_extended_filter(WebRtcAec_aec_core(canceller->state()), |
| 493 extended_filter_enabled_ ? 1 : 0); | 482 extended_filter_enabled_ ? 1 : 0); |
| 494 WebRtcAec_enable_delay_agnostic(WebRtcAec_aec_core(canceller->state()), | 483 WebRtcAec_enable_delay_agnostic(WebRtcAec_aec_core(canceller->state()), |
| 495 delay_agnostic_enabled_ ? 1 : 0); | 484 delay_agnostic_enabled_ ? 1 : 0); |
| 496 WebRtcAec_enable_aec3(WebRtcAec_aec_core(canceller->state()), | |
| 497 aec3_enabled_ ? 1 : 0); | |
| 498 WebRtcAec_enable_refined_adaptive_filter( | 485 WebRtcAec_enable_refined_adaptive_filter( |
| 499 WebRtcAec_aec_core(canceller->state()), | 486 WebRtcAec_aec_core(canceller->state()), |
| 500 refined_adaptive_filter_enabled_); | 487 refined_adaptive_filter_enabled_); |
| 501 const int handle_error = WebRtcAec_set_config(canceller->state(), config); | 488 const int handle_error = WebRtcAec_set_config(canceller->state(), config); |
| 502 if (handle_error != AudioProcessing::kNoError) { | 489 if (handle_error != AudioProcessing::kNoError) { |
| 503 error = AudioProcessing::kNoError; | 490 error = AudioProcessing::kNoError; |
| 504 } | 491 } |
| 505 } | 492 } |
| 506 return error; | 493 return error; |
| 507 } | 494 } |
| 508 | 495 |
| 509 size_t EchoCancellationImpl::NumCancellersRequired( | 496 size_t EchoCancellationImpl::NumCancellersRequired( |
| 510 size_t num_output_channels, | 497 size_t num_output_channels, |
| 511 size_t num_reverse_channels) { | 498 size_t num_reverse_channels) { |
| 512 return num_output_channels * num_reverse_channels; | 499 return num_output_channels * num_reverse_channels; |
| 513 } | 500 } |
| 514 | 501 |
| 515 } // namespace webrtc | 502 } // namespace webrtc |
| OLD | NEW |