| 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 crit_capture_(crit_capture), | 95 crit_capture_(crit_capture), |
| 96 drift_compensation_enabled_(false), | 96 drift_compensation_enabled_(false), |
| 97 metrics_enabled_(false), | 97 metrics_enabled_(false), |
| 98 suppression_level_(kModerateSuppression), | 98 suppression_level_(kModerateSuppression), |
| 99 stream_drift_samples_(0), | 99 stream_drift_samples_(0), |
| 100 was_stream_drift_set_(false), | 100 was_stream_drift_set_(false), |
| 101 stream_has_echo_(false), | 101 stream_has_echo_(false), |
| 102 delay_logging_enabled_(false), | 102 delay_logging_enabled_(false), |
| 103 extended_filter_enabled_(false), | 103 extended_filter_enabled_(false), |
| 104 delay_agnostic_enabled_(false), | 104 delay_agnostic_enabled_(false), |
| 105 next_generation_aec_enabled_(false), | 105 aec3_enabled_(false), |
| 106 render_queue_element_max_size_(0) { | 106 render_queue_element_max_size_(0) { |
| 107 RTC_DCHECK(apm); | 107 RTC_DCHECK(apm); |
| 108 RTC_DCHECK(crit_render); | 108 RTC_DCHECK(crit_render); |
| 109 RTC_DCHECK(crit_capture); | 109 RTC_DCHECK(crit_capture); |
| 110 } | 110 } |
| 111 | 111 |
| 112 EchoCancellationImpl::~EchoCancellationImpl() {} | 112 EchoCancellationImpl::~EchoCancellationImpl() {} |
| 113 | 113 |
| 114 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { | 114 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { |
| 115 rtc::CritScope cs_render(crit_render_); | 115 rtc::CritScope cs_render(crit_render_); |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 bool EchoCancellationImpl::is_delay_logging_enabled() const { | 380 bool EchoCancellationImpl::is_delay_logging_enabled() const { |
| 381 rtc::CritScope cs(crit_capture_); | 381 rtc::CritScope cs(crit_capture_); |
| 382 return delay_logging_enabled_; | 382 return delay_logging_enabled_; |
| 383 } | 383 } |
| 384 | 384 |
| 385 bool EchoCancellationImpl::is_delay_agnostic_enabled() const { | 385 bool EchoCancellationImpl::is_delay_agnostic_enabled() const { |
| 386 rtc::CritScope cs(crit_capture_); | 386 rtc::CritScope cs(crit_capture_); |
| 387 return delay_agnostic_enabled_; | 387 return delay_agnostic_enabled_; |
| 388 } | 388 } |
| 389 | 389 |
| 390 bool EchoCancellationImpl::is_next_generation_aec_enabled() const { | 390 bool EchoCancellationImpl::is_aec3_enabled() const { |
| 391 rtc::CritScope cs(crit_capture_); | 391 rtc::CritScope cs(crit_capture_); |
| 392 return next_generation_aec_enabled_; | 392 return aec3_enabled_; |
| 393 } | 393 } |
| 394 | 394 |
| 395 bool EchoCancellationImpl::is_extended_filter_enabled() const { | 395 bool EchoCancellationImpl::is_extended_filter_enabled() const { |
| 396 rtc::CritScope cs(crit_capture_); | 396 rtc::CritScope cs(crit_capture_); |
| 397 return extended_filter_enabled_; | 397 return extended_filter_enabled_; |
| 398 } | 398 } |
| 399 | 399 |
| 400 // TODO(bjornv): How should we handle the multi-channel case? | 400 // TODO(bjornv): How should we handle the multi-channel case? |
| 401 int EchoCancellationImpl::GetDelayMetrics(int* median, int* std) { | 401 int EchoCancellationImpl::GetDelayMetrics(int* median, int* std) { |
| 402 rtc::CritScope cs(crit_capture_); | 402 rtc::CritScope cs(crit_capture_); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 496 } else { | 496 } else { |
| 497 render_signal_queue_->Clear(); | 497 render_signal_queue_->Clear(); |
| 498 } | 498 } |
| 499 } | 499 } |
| 500 | 500 |
| 501 void EchoCancellationImpl::SetExtraOptions(const Config& config) { | 501 void EchoCancellationImpl::SetExtraOptions(const Config& config) { |
| 502 { | 502 { |
| 503 rtc::CritScope cs(crit_capture_); | 503 rtc::CritScope cs(crit_capture_); |
| 504 extended_filter_enabled_ = config.Get<ExtendedFilter>().enabled; | 504 extended_filter_enabled_ = config.Get<ExtendedFilter>().enabled; |
| 505 delay_agnostic_enabled_ = config.Get<DelayAgnostic>().enabled; | 505 delay_agnostic_enabled_ = config.Get<DelayAgnostic>().enabled; |
| 506 next_generation_aec_enabled_ = config.Get<NextGenerationAec>().enabled; | 506 aec3_enabled_ = config.Get<EchoCanceller3>().enabled; |
| 507 } | 507 } |
| 508 Configure(); | 508 Configure(); |
| 509 } | 509 } |
| 510 | 510 |
| 511 int EchoCancellationImpl::Configure() { | 511 int EchoCancellationImpl::Configure() { |
| 512 rtc::CritScope cs_render(crit_render_); | 512 rtc::CritScope cs_render(crit_render_); |
| 513 rtc::CritScope cs_capture(crit_capture_); | 513 rtc::CritScope cs_capture(crit_capture_); |
| 514 AecConfig config; | 514 AecConfig config; |
| 515 config.metricsMode = metrics_enabled_; | 515 config.metricsMode = metrics_enabled_; |
| 516 config.nlpMode = MapSetting(suppression_level_); | 516 config.nlpMode = MapSetting(suppression_level_); |
| 517 config.skewMode = drift_compensation_enabled_; | 517 config.skewMode = drift_compensation_enabled_; |
| 518 config.delay_logging = delay_logging_enabled_; | 518 config.delay_logging = delay_logging_enabled_; |
| 519 | 519 |
| 520 int error = AudioProcessing::kNoError; | 520 int error = AudioProcessing::kNoError; |
| 521 for (size_t i = 0; i < cancellers_.size(); i++) { | 521 for (size_t i = 0; i < cancellers_.size(); i++) { |
| 522 Handle* my_handle = cancellers_[i]->state(); | 522 Handle* my_handle = cancellers_[i]->state(); |
| 523 WebRtcAec_enable_extended_filter(WebRtcAec_aec_core(my_handle), | 523 WebRtcAec_enable_extended_filter(WebRtcAec_aec_core(my_handle), |
| 524 extended_filter_enabled_ ? 1 : 0); | 524 extended_filter_enabled_ ? 1 : 0); |
| 525 WebRtcAec_enable_delay_agnostic(WebRtcAec_aec_core(my_handle), | 525 WebRtcAec_enable_delay_agnostic(WebRtcAec_aec_core(my_handle), |
| 526 delay_agnostic_enabled_ ? 1 : 0); | 526 delay_agnostic_enabled_ ? 1 : 0); |
| 527 WebRtcAec_enable_next_generation_aec(WebRtcAec_aec_core(my_handle), | 527 WebRtcAec_enable_aec3(WebRtcAec_aec_core(my_handle), aec3_enabled_ ? 1 : 0); |
| 528 next_generation_aec_enabled_ ? 1 : 0); | |
| 529 const int handle_error = WebRtcAec_set_config(my_handle, config); | 528 const int handle_error = WebRtcAec_set_config(my_handle, config); |
| 530 if (handle_error != AudioProcessing::kNoError) { | 529 if (handle_error != AudioProcessing::kNoError) { |
| 531 error = AudioProcessing::kNoError; | 530 error = AudioProcessing::kNoError; |
| 532 } | 531 } |
| 533 } | 532 } |
| 534 return error; | 533 return error; |
| 535 } | 534 } |
| 536 | 535 |
| 537 size_t EchoCancellationImpl::num_handles_required() const { | 536 size_t EchoCancellationImpl::num_handles_required() const { |
| 538 // Not locked as it only relies on APM public API which is threadsafe. | 537 // Not locked as it only relies on APM public API which is threadsafe. |
| 539 return apm_->num_output_channels() * apm_->num_reverse_channels(); | 538 return apm_->num_output_channels() * apm_->num_reverse_channels(); |
| 540 } | 539 } |
| 541 | 540 |
| 542 } // namespace webrtc | 541 } // namespace webrtc |
| OLD | NEW |