andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 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 | |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 11 | #include <memory> |
| 12 | |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 13 | #include "webrtc/modules/audio_processing/aec/aec_core.h" |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 14 | #include "webrtc/modules/audio_processing/include/audio_processing.h" |
kwiberg | ac9f876 | 2016-09-30 22:29:43 -0700 | [diff] [blame] | 15 | #include "webrtc/test/gtest.h" |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 16 | |
| 17 | namespace webrtc { |
| 18 | |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 19 | TEST(EchoCancellationInternalTest, ExtendedFilter) { |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 20 | std::unique_ptr<AudioProcessing> ap(AudioProcessing::Create()); |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 21 | 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 Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 29 | EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core)); |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 30 | |
| 31 | Config config; |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 32 | config.Set<ExtendedFilter>(new ExtendedFilter(true)); |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 33 | ap->SetExtraOptions(config); |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 34 | EXPECT_EQ(1, WebRtcAec_extended_filter_enabled(aec_core)); |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 35 | |
| 36 | // Retains setting after initialization. |
| 37 | EXPECT_EQ(ap->kNoError, ap->Initialize()); |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 38 | EXPECT_EQ(1, WebRtcAec_extended_filter_enabled(aec_core)); |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 39 | |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 40 | config.Set<ExtendedFilter>(new ExtendedFilter(false)); |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 41 | ap->SetExtraOptions(config); |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 42 | EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core)); |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 43 | |
| 44 | // Retains setting after initialization. |
| 45 | EXPECT_EQ(ap->kNoError, ap->Initialize()); |
Henrik Lundin | 441f634 | 2015-06-09 16:03:13 +0200 | [diff] [blame] | 46 | EXPECT_EQ(0, WebRtcAec_extended_filter_enabled(aec_core)); |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 47 | } |
| 48 | |
henrik.lundin | 0f133b9 | 2015-07-02 00:17:55 -0700 | [diff] [blame] | 49 | TEST(EchoCancellationInternalTest, DelayAgnostic) { |
kwiberg | 88788ad | 2016-02-19 07:04:49 -0800 | [diff] [blame] | 50 | std::unique_ptr<AudioProcessing> ap(AudioProcessing::Create()); |
bjornv@webrtc.org | 3f83072 | 2014-06-11 04:48:11 +0000 | [diff] [blame] | 51 | 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.lundin | 0f133b9 | 2015-07-02 00:17:55 -0700 | [diff] [blame] | 59 | EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core)); |
bjornv@webrtc.org | 3f83072 | 2014-06-11 04:48:11 +0000 | [diff] [blame] | 60 | |
| 61 | Config config; |
henrik.lundin | 0f133b9 | 2015-07-02 00:17:55 -0700 | [diff] [blame] | 62 | config.Set<DelayAgnostic>(new DelayAgnostic(true)); |
bjornv@webrtc.org | 3f83072 | 2014-06-11 04:48:11 +0000 | [diff] [blame] | 63 | ap->SetExtraOptions(config); |
henrik.lundin | 0f133b9 | 2015-07-02 00:17:55 -0700 | [diff] [blame] | 64 | EXPECT_EQ(1, WebRtcAec_delay_agnostic_enabled(aec_core)); |
bjornv@webrtc.org | 3f83072 | 2014-06-11 04:48:11 +0000 | [diff] [blame] | 65 | |
| 66 | // Retains setting after initialization. |
| 67 | EXPECT_EQ(ap->kNoError, ap->Initialize()); |
henrik.lundin | 0f133b9 | 2015-07-02 00:17:55 -0700 | [diff] [blame] | 68 | EXPECT_EQ(1, WebRtcAec_delay_agnostic_enabled(aec_core)); |
bjornv@webrtc.org | 3f83072 | 2014-06-11 04:48:11 +0000 | [diff] [blame] | 69 | |
henrik.lundin | 0f133b9 | 2015-07-02 00:17:55 -0700 | [diff] [blame] | 70 | config.Set<DelayAgnostic>(new DelayAgnostic(false)); |
bjornv@webrtc.org | 3f83072 | 2014-06-11 04:48:11 +0000 | [diff] [blame] | 71 | ap->SetExtraOptions(config); |
henrik.lundin | 0f133b9 | 2015-07-02 00:17:55 -0700 | [diff] [blame] | 72 | EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core)); |
bjornv@webrtc.org | 3f83072 | 2014-06-11 04:48:11 +0000 | [diff] [blame] | 73 | |
| 74 | // Retains setting after initialization. |
| 75 | EXPECT_EQ(ap->kNoError, ap->Initialize()); |
henrik.lundin | 0f133b9 | 2015-07-02 00:17:55 -0700 | [diff] [blame] | 76 | EXPECT_EQ(0, WebRtcAec_delay_agnostic_enabled(aec_core)); |
bjornv@webrtc.org | 3f83072 | 2014-06-11 04:48:11 +0000 | [diff] [blame] | 77 | } |
| 78 | |
andrew@webrtc.org | 1760a17 | 2013-09-25 23:17:38 +0000 | [diff] [blame] | 79 | } // namespace webrtc |