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 {
Sergey Silkin271812a2018-09-13 14:55:17 +000018
Henrik Lundin441f6342015-06-09 16:03:13 +020019TEST(EchoCancellationInternalTest, ExtendedFilter) {
Sergey Silkin271812a2018-09-13 14:55:17 +000020 std::unique_ptr<AudioProcessing> ap(AudioProcessingBuilder().Create());
21 EXPECT_TRUE(ap->echo_cancellation()->aec_core() == NULL);
andrew@webrtc.org1760a172013-09-25 23:17:38 +000022
Sergey Silkin271812a2018-09-13 14:55:17 +000023 EXPECT_EQ(ap->kNoError, ap->echo_cancellation()->Enable(true));
24 EXPECT_TRUE(ap->echo_cancellation()->is_enabled());
andrew@webrtc.org1760a172013-09-25 23:17:38 +000025
Sergey Silkin271812a2018-09-13 14:55:17 +000026 AecCore* aec_core = ap->echo_cancellation()->aec_core();
andrew@webrtc.org1760a172013-09-25 23:17:38 +000027 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));
Sergey Silkin271812a2018-09-13 14:55:17 +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.
Sergey Silkin271812a2018-09-13 14:55:17 +000037 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));
Sergey Silkin271812a2018-09-13 14:55:17 +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.
Sergey Silkin271812a2018-09-13 14:55:17 +000045 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) {
Sergey Silkin271812a2018-09-13 14:55:17 +000050 std::unique_ptr<AudioProcessing> ap(AudioProcessingBuilder().Create());
51 EXPECT_TRUE(ap->echo_cancellation()->aec_core() == NULL);
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000052
Sergey Silkin271812a2018-09-13 14:55:17 +000053 EXPECT_EQ(ap->kNoError, ap->echo_cancellation()->Enable(true));
54 EXPECT_TRUE(ap->echo_cancellation()->is_enabled());
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000055
Sergey Silkin271812a2018-09-13 14:55:17 +000056 AecCore* aec_core = ap->echo_cancellation()->aec_core();
bjornv@webrtc.org3f830722014-06-11 04:48:11 +000057 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));
Sergey Silkin271812a2018-09-13 14:55:17 +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.
Sergey Silkin271812a2018-09-13 14:55:17 +000067 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));
Sergey Silkin271812a2018-09-13 14:55:17 +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.
Sergey Silkin271812a2018-09-13 14:55:17 +000075 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