| 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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 drift_compensation_enabled_(false), | 107 drift_compensation_enabled_(false), |
| 108 metrics_enabled_(false), | 108 metrics_enabled_(false), |
| 109 suppression_level_(kModerateSuppression), | 109 suppression_level_(kModerateSuppression), |
| 110 stream_drift_samples_(0), | 110 stream_drift_samples_(0), |
| 111 was_stream_drift_set_(false), | 111 was_stream_drift_set_(false), |
| 112 stream_has_echo_(false), | 112 stream_has_echo_(false), |
| 113 delay_logging_enabled_(false), | 113 delay_logging_enabled_(false), |
| 114 extended_filter_enabled_(false), | 114 extended_filter_enabled_(false), |
| 115 delay_agnostic_enabled_(false), | 115 delay_agnostic_enabled_(false), |
| 116 aec3_enabled_(false), | 116 aec3_enabled_(false), |
| 117 refined_adaptive_filter_enabled_(false), |
| 117 render_queue_element_max_size_(0) { | 118 render_queue_element_max_size_(0) { |
| 118 RTC_DCHECK(crit_render); | 119 RTC_DCHECK(crit_render); |
| 119 RTC_DCHECK(crit_capture); | 120 RTC_DCHECK(crit_capture); |
| 120 } | 121 } |
| 121 | 122 |
| 122 EchoCancellationImpl::~EchoCancellationImpl() {} | 123 EchoCancellationImpl::~EchoCancellationImpl() {} |
| 123 | 124 |
| 124 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { | 125 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { |
| 125 rtc::CritScope cs_render(crit_render_); | 126 rtc::CritScope cs_render(crit_render_); |
| 126 if (!enabled_) { | 127 if (!enabled_) { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 406 bool EchoCancellationImpl::is_delay_agnostic_enabled() const { | 407 bool EchoCancellationImpl::is_delay_agnostic_enabled() const { |
| 407 rtc::CritScope cs(crit_capture_); | 408 rtc::CritScope cs(crit_capture_); |
| 408 return delay_agnostic_enabled_; | 409 return delay_agnostic_enabled_; |
| 409 } | 410 } |
| 410 | 411 |
| 411 bool EchoCancellationImpl::is_aec3_enabled() const { | 412 bool EchoCancellationImpl::is_aec3_enabled() const { |
| 412 rtc::CritScope cs(crit_capture_); | 413 rtc::CritScope cs(crit_capture_); |
| 413 return aec3_enabled_; | 414 return aec3_enabled_; |
| 414 } | 415 } |
| 415 | 416 |
| 417 bool EchoCancellationImpl::is_refined_adaptive_filter_enabled() const { |
| 418 rtc::CritScope cs(crit_capture_); |
| 419 return refined_adaptive_filter_enabled_; |
| 420 } |
| 421 |
| 416 bool EchoCancellationImpl::is_extended_filter_enabled() const { | 422 bool EchoCancellationImpl::is_extended_filter_enabled() const { |
| 417 rtc::CritScope cs(crit_capture_); | 423 rtc::CritScope cs(crit_capture_); |
| 418 return extended_filter_enabled_; | 424 return extended_filter_enabled_; |
| 419 } | 425 } |
| 420 | 426 |
| 421 // TODO(bjornv): How should we handle the multi-channel case? | 427 // TODO(bjornv): How should we handle the multi-channel case? |
| 422 int EchoCancellationImpl::GetDelayMetrics(int* median, int* std) { | 428 int EchoCancellationImpl::GetDelayMetrics(int* median, int* std) { |
| 423 rtc::CritScope cs(crit_capture_); | 429 rtc::CritScope cs(crit_capture_); |
| 424 float fraction_poor_delays = 0; | 430 float fraction_poor_delays = 0; |
| 425 return GetDelayMetrics(median, std, &fraction_poor_delays); | 431 return GetDelayMetrics(median, std, &fraction_poor_delays); |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 } else { | 528 } else { |
| 523 render_signal_queue_->Clear(); | 529 render_signal_queue_->Clear(); |
| 524 } | 530 } |
| 525 } | 531 } |
| 526 | 532 |
| 527 void EchoCancellationImpl::SetExtraOptions(const Config& config) { | 533 void EchoCancellationImpl::SetExtraOptions(const Config& config) { |
| 528 { | 534 { |
| 529 rtc::CritScope cs(crit_capture_); | 535 rtc::CritScope cs(crit_capture_); |
| 530 extended_filter_enabled_ = config.Get<ExtendedFilter>().enabled; | 536 extended_filter_enabled_ = config.Get<ExtendedFilter>().enabled; |
| 531 delay_agnostic_enabled_ = config.Get<DelayAgnostic>().enabled; | 537 delay_agnostic_enabled_ = config.Get<DelayAgnostic>().enabled; |
| 538 refined_adaptive_filter_enabled_ = |
| 539 config.Get<RefinedAdaptiveFilter>().enabled; |
| 532 aec3_enabled_ = config.Get<EchoCanceller3>().enabled; | 540 aec3_enabled_ = config.Get<EchoCanceller3>().enabled; |
| 533 } | 541 } |
| 534 Configure(); | 542 Configure(); |
| 535 } | 543 } |
| 536 | 544 |
| 537 int EchoCancellationImpl::Configure() { | 545 int EchoCancellationImpl::Configure() { |
| 538 rtc::CritScope cs_render(crit_render_); | 546 rtc::CritScope cs_render(crit_render_); |
| 539 rtc::CritScope cs_capture(crit_capture_); | 547 rtc::CritScope cs_capture(crit_capture_); |
| 540 AecConfig config; | 548 AecConfig config; |
| 541 config.metricsMode = metrics_enabled_; | 549 config.metricsMode = metrics_enabled_; |
| 542 config.nlpMode = MapSetting(suppression_level_); | 550 config.nlpMode = MapSetting(suppression_level_); |
| 543 config.skewMode = drift_compensation_enabled_; | 551 config.skewMode = drift_compensation_enabled_; |
| 544 config.delay_logging = delay_logging_enabled_; | 552 config.delay_logging = delay_logging_enabled_; |
| 545 | 553 |
| 546 int error = AudioProcessing::kNoError; | 554 int error = AudioProcessing::kNoError; |
| 547 for (auto& canceller : cancellers_) { | 555 for (auto& canceller : cancellers_) { |
| 548 WebRtcAec_enable_extended_filter(WebRtcAec_aec_core(canceller->state()), | 556 WebRtcAec_enable_extended_filter(WebRtcAec_aec_core(canceller->state()), |
| 549 extended_filter_enabled_ ? 1 : 0); | 557 extended_filter_enabled_ ? 1 : 0); |
| 550 WebRtcAec_enable_delay_agnostic(WebRtcAec_aec_core(canceller->state()), | 558 WebRtcAec_enable_delay_agnostic(WebRtcAec_aec_core(canceller->state()), |
| 551 delay_agnostic_enabled_ ? 1 : 0); | 559 delay_agnostic_enabled_ ? 1 : 0); |
| 552 WebRtcAec_enable_aec3(WebRtcAec_aec_core(canceller->state()), | 560 WebRtcAec_enable_aec3(WebRtcAec_aec_core(canceller->state()), |
| 553 aec3_enabled_ ? 1 : 0); | 561 aec3_enabled_ ? 1 : 0); |
| 562 WebRtcAec_enable_refined_adaptive_filter( |
| 563 WebRtcAec_aec_core(canceller->state()), |
| 564 refined_adaptive_filter_enabled_); |
| 554 const int handle_error = WebRtcAec_set_config(canceller->state(), config); | 565 const int handle_error = WebRtcAec_set_config(canceller->state(), config); |
| 555 if (handle_error != AudioProcessing::kNoError) { | 566 if (handle_error != AudioProcessing::kNoError) { |
| 556 error = AudioProcessing::kNoError; | 567 error = AudioProcessing::kNoError; |
| 557 } | 568 } |
| 558 } | 569 } |
| 559 return error; | 570 return error; |
| 560 } | 571 } |
| 561 | 572 |
| 562 size_t EchoCancellationImpl::NumCancellersRequired() const { | 573 size_t EchoCancellationImpl::NumCancellersRequired() const { |
| 563 RTC_DCHECK(stream_properties_); | 574 RTC_DCHECK(stream_properties_); |
| 564 return stream_properties_->num_output_channels * | 575 return stream_properties_->num_output_channels * |
| 565 stream_properties_->num_reverse_channels; | 576 stream_properties_->num_reverse_channels; |
| 566 } | 577 } |
| 567 | 578 |
| 568 } // namespace webrtc | 579 } // namespace webrtc |
| OLD | NEW |