Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(666)

Side by Side Diff: webrtc/modules/audio_processing/echo_cancellation_impl.cc

Issue 1151573021: Re-land r9378 "Rename APM Config DelayCorrection to ExtendedFilter" (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: New line Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // AEC_UNSPECIFIED_ERROR 50 // AEC_UNSPECIFIED_ERROR
51 // AEC_UNINITIALIZED_ERROR 51 // AEC_UNINITIALIZED_ERROR
52 // AEC_NULL_POINTER_ERROR 52 // AEC_NULL_POINTER_ERROR
53 return AudioProcessing::kUnspecifiedError; 53 return AudioProcessing::kUnspecifiedError;
54 } 54 }
55 } 55 }
56 } // namespace 56 } // namespace
57 57
58 EchoCancellationImpl::EchoCancellationImpl(const AudioProcessing* apm, 58 EchoCancellationImpl::EchoCancellationImpl(const AudioProcessing* apm,
59 CriticalSectionWrapper* crit) 59 CriticalSectionWrapper* crit)
60 : ProcessingComponent(), 60 : ProcessingComponent(),
61 apm_(apm), 61 apm_(apm),
62 crit_(crit), 62 crit_(crit),
63 drift_compensation_enabled_(false), 63 drift_compensation_enabled_(false),
64 metrics_enabled_(false), 64 metrics_enabled_(false),
65 suppression_level_(kModerateSuppression), 65 suppression_level_(kModerateSuppression),
66 stream_drift_samples_(0), 66 stream_drift_samples_(0),
67 was_stream_drift_set_(false), 67 was_stream_drift_set_(false),
68 stream_has_echo_(false), 68 stream_has_echo_(false),
69 delay_logging_enabled_(false), 69 delay_logging_enabled_(false),
70 delay_correction_enabled_(false), 70 extended_filter_enabled_(false),
71 reported_delay_enabled_(true) {} 71 reported_delay_enabled_(true) {
72 }
72 73
73 EchoCancellationImpl::~EchoCancellationImpl() {} 74 EchoCancellationImpl::~EchoCancellationImpl() {}
74 75
75 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) { 76 int EchoCancellationImpl::ProcessRenderAudio(const AudioBuffer* audio) {
76 if (!is_component_enabled()) { 77 if (!is_component_enabled()) {
77 return apm_->kNoError; 78 return apm_->kNoError;
78 } 79 }
79 80
80 assert(audio->num_frames_per_band() <= 160); 81 assert(audio->num_frames_per_band() <= 160);
81 assert(audio->num_channels() == apm_->num_reverse_channels()); 82 assert(audio->num_channels() == apm_->num_reverse_channels());
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 int EchoCancellationImpl::Initialize() { 321 int EchoCancellationImpl::Initialize() {
321 int err = ProcessingComponent::Initialize(); 322 int err = ProcessingComponent::Initialize();
322 if (err != apm_->kNoError || !is_component_enabled()) { 323 if (err != apm_->kNoError || !is_component_enabled()) {
323 return err; 324 return err;
324 } 325 }
325 326
326 return apm_->kNoError; 327 return apm_->kNoError;
327 } 328 }
328 329
329 void EchoCancellationImpl::SetExtraOptions(const Config& config) { 330 void EchoCancellationImpl::SetExtraOptions(const Config& config) {
330 delay_correction_enabled_ = config.Get<DelayCorrection>().enabled; 331 // Both ExtendedFilter and DelayCorrection are diabled by default. If any one
332 // of them is true, then the extended filter mode is enabled.
333 extended_filter_enabled_ = config.Get<ExtendedFilter>().enabled ||
334 config.Get<DelayCorrection>().enabled;
331 reported_delay_enabled_ = config.Get<ReportedDelay>().enabled; 335 reported_delay_enabled_ = config.Get<ReportedDelay>().enabled;
332 Configure(); 336 Configure();
333 } 337 }
334 338
335 void* EchoCancellationImpl::CreateHandle() const { 339 void* EchoCancellationImpl::CreateHandle() const {
336 Handle* handle = NULL; 340 Handle* handle = NULL;
337 if (WebRtcAec_Create(&handle) != apm_->kNoError) { 341 if (WebRtcAec_Create(&handle) != apm_->kNoError) {
338 handle = NULL; 342 handle = NULL;
339 } else { 343 } else {
340 assert(handle != NULL); 344 assert(handle != NULL);
(...skipping 18 matching lines...) Expand all
359 } 363 }
360 364
361 int EchoCancellationImpl::ConfigureHandle(void* handle) const { 365 int EchoCancellationImpl::ConfigureHandle(void* handle) const {
362 assert(handle != NULL); 366 assert(handle != NULL);
363 AecConfig config; 367 AecConfig config;
364 config.metricsMode = metrics_enabled_; 368 config.metricsMode = metrics_enabled_;
365 config.nlpMode = MapSetting(suppression_level_); 369 config.nlpMode = MapSetting(suppression_level_);
366 config.skewMode = drift_compensation_enabled_; 370 config.skewMode = drift_compensation_enabled_;
367 config.delay_logging = delay_logging_enabled_; 371 config.delay_logging = delay_logging_enabled_;
368 372
369 WebRtcAec_enable_delay_correction(WebRtcAec_aec_core( 373 WebRtcAec_enable_extended_filter(
370 static_cast<Handle*>(handle)), delay_correction_enabled_ ? 1 : 0); 374 WebRtcAec_aec_core(static_cast<Handle*>(handle)),
375 extended_filter_enabled_ ? 1 : 0);
371 WebRtcAec_enable_reported_delay(WebRtcAec_aec_core( 376 WebRtcAec_enable_reported_delay(WebRtcAec_aec_core(
372 static_cast<Handle*>(handle)), reported_delay_enabled_ ? 1 : 0); 377 static_cast<Handle*>(handle)), reported_delay_enabled_ ? 1 : 0);
373 return WebRtcAec_set_config(static_cast<Handle*>(handle), config); 378 return WebRtcAec_set_config(static_cast<Handle*>(handle), config);
374 } 379 }
375 380
376 int EchoCancellationImpl::num_handles_required() const { 381 int EchoCancellationImpl::num_handles_required() const {
377 return apm_->num_output_channels() * 382 return apm_->num_output_channels() *
378 apm_->num_reverse_channels(); 383 apm_->num_reverse_channels();
379 } 384 }
380 385
381 int EchoCancellationImpl::GetHandleError(void* handle) const { 386 int EchoCancellationImpl::GetHandleError(void* handle) const {
382 assert(handle != NULL); 387 assert(handle != NULL);
383 return MapError(WebRtcAec_get_error_code(static_cast<Handle*>(handle))); 388 return MapError(WebRtcAec_get_error_code(static_cast<Handle*>(handle)));
384 } 389 }
385 } // namespace webrtc 390 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698