blob: ec30abc2a6d957dc70a6e42739df2fe12686e912 [file] [log] [blame]
andrew@webrtc.org1760a172013-09-25 23:17:38 +00001/*
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
kwiberg88788ad2016-02-19 07:04:49 -080011#include <memory>
12
Mirko Bonadei92ea95e2017-09-15 06:47:31 +020013#include "modules/audio_processing/aec/aec_core.h"
14#include "modules/audio_processing/include/audio_processing.h"
15#include "test/gtest.h"
andrew@webrtc.org1760a172013-09-25 23:17:38 +000016
17namespace webrtc {
18
Henrik Lundin441f6342015-06-09 16:03:13 +020019TEST(EchoCancellationInternalTest, ExtendedFilter) {
Ivo Creusen62337e52018-01-09 14:17:33 +010020 std::unique_ptr<AudioProcessing> ap(AudioProcessingBuilder().Create());
andrew@webrtc.org1760a172013-09-25 23:17:38 +000021 EXPECT_TRUE(ap->echo_cancellation()->aec_core() == NULL);
22
23 EXPECT_EQ(ap->kNoError, ap->echo_cancellation()->Enable(true));
24 EXPECT_TRUE(ap->echo_cancellation()->is_enabled());
25
26 AecCore* aec_core = ap->echo_cancellation()->aec_core();
27 ASSERT_TRUE(aec_core != NULL);
28 // Disabled by default.
Henrik Lundin441f6342015-06-09 16:03:13 +020029 EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core));
andrew@webrtc.org1760a172013-09-25 23:17:38 +000030
31 Config config;
Henrik Lundin441f6342015-06-09 16:03:13 +020032 config.Set<ExtendedFilter>(new ExtendedFilter(true));
andrew@webrtc.org1760a172013-09-25 23:17:38 +000033 ap->SetExtraOptions(config);
Henrik Lundin441f6342015-06-09 16:03:13 +020034 EXPECT_EQ(1, WebRtcAec_extended_filter_enabled(aec_core));
andrew@webrtc.org1760a172013-09-25 23:17:38 +000035
36 // Retains setting after initialization.
37 EXPECT_EQ(ap->kNoError, ap->Initialize());
Henrik Lundin441f6342015-06-09 16:03:13 +020038 EXPECT_EQ(1, WebRtcAec_extended_filter_enabled(aec_core));
andrew@webrtc.org1760a172013-09-25 23:17:38 +000039
Henrik Lundin441f6342015-06-09 16:03:13 +020040 config.Set<ExtendedFilter>(new ExtendedFilter(false));
andrew@webrtc.org1760a172013-09-25 23:17:38 +000041 ap->SetExtraOptions(config);
Henrik Lundin441f6342015-06-09 16:03:13 +020042 EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core));
andrew@webrtc.org1760a172013-09-25 23:17:38 +000043
44 // Retains setting after initialization.
45 EXPECT_EQ(ap->kNoError, ap->Initialize());
Henrik Lundin441f6342015-06-09 16:03:13 +020046 EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core));
andrew@webrtc.org1760a172013-09-25 23:17:38 +000047}
48
henrik.lundin0f133b92015-07-02 00:17:55 -070049TEST(EchoCancellationInternalTest, DelayAgnostic) {
Ivo Creusen62337e52018-01-09 14:17:33 +010050 std::unique_ptr<AudioProcessing> ap(AudioProcessingBuilder().Create());
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000051 EXPECT_TRUE(ap->echo_cancellation()->aec_core() == NULL);
52
53 EXPECT_EQ(ap->kNoError, ap->echo_cancellation()->Enable(true));
54 EXPECT_TRUE(ap->echo_cancellation()->is_enabled());
55
56 AecCore* aec_core = ap->echo_cancellation()->aec_core();
57 ASSERT_TRUE(aec_core != NULL);
58 // Enabled by default.
henrik.lundin0f133b92015-07-02 00:17:55 -070059 EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core));
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000060
61 Config config;
henrik.lundin0f133b92015-07-02 00:17:55 -070062 config.Set<DelayAgnostic>(new DelayAgnostic(true));
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000063 ap->SetExtraOptions(config);
henrik.lundin0f133b92015-07-02 00:17:55 -070064 EXPECT_EQ(1, WebRtcAec_delay_agnostic_enabled(aec_core));
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000065
66 // Retains setting after initialization.
67 EXPECT_EQ(ap->kNoError, ap->Initialize());
henrik.lundin0f133b92015-07-02 00:17:55 -070068 EXPECT_EQ(1, WebRtcAec_delay_agnostic_enabled(aec_core));
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000069
henrik.lundin0f133b92015-07-02 00:17:55 -070070 config.Set<DelayAgnostic>(new DelayAgnostic(false));
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000071 ap->SetExtraOptions(config);
henrik.lundin0f133b92015-07-02 00:17:55 -070072 EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core));
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000073
74 // Retains setting after initialization.
75 EXPECT_EQ(ap->kNoError, ap->Initialize());
henrik.lundin0f133b92015-07-02 00:17:55 -070076 EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core));
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000077}
78
andrew@webrtc.org1760a172013-09-25 23:17:38 +000079} // namespace webrtc