1/* 2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. 3 * 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 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11#include "testing/gtest/include/gtest/gtest.h" 12extern "C" { 13#include "webrtc/modules/audio_processing/aec/aec_core.h" 14} 15#include "webrtc/modules/audio_processing/include/audio_processing.h" 16#include "webrtc/system_wrappers/interface/scoped_ptr.h" 17#include "webrtc/test/testsupport/gtest_disable.h" 18 19namespace webrtc { 20 21TEST(EchoCancellationInternalTest, DelayCorrection) { 22 scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(0)); 23 EXPECT_TRUE(ap->echo_cancellation()->aec_core() == NULL); 24 25 EXPECT_EQ(ap->kNoError, ap->echo_cancellation()->Enable(true)); 26 EXPECT_TRUE(ap->echo_cancellation()->is_enabled()); 27 28 AecCore* aec_core = ap->echo_cancellation()->aec_core(); 29 ASSERT_TRUE(aec_core != NULL); 30 // Disabled by default. 31 EXPECT_EQ(0, WebRtcAec_delay_correction_enabled(aec_core)); 32 33 Config config; 34 config.Set<DelayCorrection>(new DelayCorrection(true)); 35 ap->SetExtraOptions(config); 36 EXPECT_EQ(1, WebRtcAec_delay_correction_enabled(aec_core)); 37 38 // Retains setting after initialization. 39 EXPECT_EQ(ap->kNoError, ap->Initialize()); 40 EXPECT_EQ(1, WebRtcAec_delay_correction_enabled(aec_core)); 41 42 config.Set<DelayCorrection>(new DelayCorrection(false)); 43 ap->SetExtraOptions(config); 44 EXPECT_EQ(0, WebRtcAec_delay_correction_enabled(aec_core)); 45 46 // Retains setting after initialization. 47 EXPECT_EQ(ap->kNoError, ap->Initialize()); 48 EXPECT_EQ(0, WebRtcAec_delay_correction_enabled(aec_core)); 49} 50 51TEST(EchoCancellationInternalTest, ReportedDelay) { 52 scoped_ptr<AudioProcessing> ap(AudioProcessing::Create(0)); 53 EXPECT_TRUE(ap->echo_cancellation()->aec_core() == NULL); 54 55 EXPECT_EQ(ap->kNoError, ap->echo_cancellation()->Enable(true)); 56 EXPECT_TRUE(ap->echo_cancellation()->is_enabled()); 57 58 AecCore* aec_core = ap->echo_cancellation()->aec_core(); 59 ASSERT_TRUE(aec_core != NULL); 60 // Enabled by default. 61 EXPECT_EQ(1, WebRtcAec_reported_delay_enabled(aec_core)); 62 63 Config config; 64 config.Set<ReportedDelay>(new ReportedDelay(false)); 65 ap->SetExtraOptions(config); 66 EXPECT_EQ(0, WebRtcAec_reported_delay_enabled(aec_core)); 67 68 // Retains setting after initialization. 69 EXPECT_EQ(ap->kNoError, ap->Initialize()); 70 EXPECT_EQ(0, WebRtcAec_reported_delay_enabled(aec_core)); 71 72 config.Set<ReportedDelay>(new ReportedDelay(true)); 73 ap->SetExtraOptions(config); 74 EXPECT_EQ(1, WebRtcAec_reported_delay_enabled(aec_core)); 75 76 // Retains setting after initialization. 77 EXPECT_EQ(ap->kNoError, ap->Initialize()); 78 EXPECT_EQ(1, WebRtcAec_reported_delay_enabled(aec_core)); 79} 80 81} // namespace webrtc 82