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

Side by Side Diff: webrtc/modules/audio_processing/aec3/echo_remover_unittest.cc

Issue 2611223003: Adding second layer of the echo canceller 3 functionality. (Closed)
Patch Set: Changes in response to reviewer comments Created 3 years, 11 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
(Empty)
1 /*
2 * Copyright (c) 2017 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 "webrtc/modules/audio_processing/aec3/echo_remover.h"
12
13 #include <memory>
14 #include <sstream>
15 #include <string>
16
17 #include "webrtc/modules/audio_processing/aec3/aec3_constants.h"
18 #include "webrtc/modules/audio_processing/logging/apm_data_dumper.h"
19 #include "webrtc/test/gtest.h"
20
21 namespace webrtc {
22 namespace {
23
24 std::string ProduceDebugText(int sample_rate_hz) {
25 std::ostringstream ss;
26 ss << "Sample rate: " << sample_rate_hz;
27 return ss.str();
28 }
29
30 } // namespace
31
32 // Verifies the basic API call sequence
33 TEST(EchoRemover, BasicApiCalls) {
34 for (auto rate : {8000, 16000, 32000, 48000}) {
35 ProduceDebugText(rate);
36 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate));
37
38 std::vector<std::vector<float>> render(NumBandsForRate(rate),
39 std::vector<float>(kBlockSize, 0.f));
40 std::vector<std::vector<float>> capture(
41 NumBandsForRate(rate), std::vector<float>(kBlockSize, 0.f));
42 for (size_t k = 0; k < 100; ++k) {
43 EchoPathVariability echo_path_variability(k % 3 == 0 ? true : false,
44 k % 5 == 0 ? true : false);
45 rtc::Optional<size_t> echo_path_delay_samples =
46 (k % 6 == 0 ? rtc::Optional<size_t>(k * 10)
47 : rtc::Optional<size_t>());
48 remover->ProcessBlock(echo_path_delay_samples, echo_path_variability,
49 k % 2 == 0 ? true : false, render, &capture);
50 remover->UpdateEchoLeakageStatus(k % 7 == 0 ? true : false);
51 }
52 }
53 }
54
55 #if RTC_DCHECK_IS_ON && GTEST_HAS_DEATH_TEST && !defined(WEBRTC_ANDROID)
56
57 // Verifies the check for the samplerate.
58 TEST(EchoRemover, WrongSampleRate) {
59 EXPECT_DEATH(std::unique_ptr<EchoRemover>(EchoRemover::Create(8001)), "");
60 }
61
62 // Verifies the check for the render block size.
63 TEST(EchoRemover, WrongRenderBlockSize) {
64 for (auto rate : {8000, 16000, 32000, 48000}) {
65 ProduceDebugText(rate);
66 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate));
67
68 std::vector<std::vector<float>> render(
69 NumBandsForRate(rate), std::vector<float>(kBlockSize - 1, 0.f));
70 std::vector<std::vector<float>> capture(
71 NumBandsForRate(rate), std::vector<float>(kBlockSize, 0.f));
72 EchoPathVariability echo_path_variability(false, false);
73 rtc::Optional<size_t> echo_path_delay_samples;
74 EXPECT_DEATH(
75 remover->ProcessBlock(echo_path_delay_samples, echo_path_variability,
76 false, render, &capture),
77 "");
78 }
79 }
80
81 // Verifies the check for the capture block size.
82 TEST(EchoRemover, WrongCaptureBlockSize) {
83 for (auto rate : {8000, 16000, 32000, 48000}) {
84 ProduceDebugText(rate);
85 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate));
86
87 std::vector<std::vector<float>> render(NumBandsForRate(rate),
88 std::vector<float>(kBlockSize, 0.f));
89 std::vector<std::vector<float>> capture(
90 NumBandsForRate(rate), std::vector<float>(kBlockSize - 1, 0.f));
91 EchoPathVariability echo_path_variability(false, false);
92 rtc::Optional<size_t> echo_path_delay_samples;
93 EXPECT_DEATH(
94 remover->ProcessBlock(echo_path_delay_samples, echo_path_variability,
95 false, render, &capture),
96 "");
97 }
98 }
99
100 // Verifies the check for the number of render bands.
101 TEST(EchoRemover, WrongRenderNumBands) {
102 for (auto rate : {16000, 32000, 48000}) {
103 ProduceDebugText(rate);
104 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate));
105
106 std::vector<std::vector<float>> render(
107 NumBandsForRate(rate == 48000 ? 16000 : rate + 16000),
108 std::vector<float>(kBlockSize, 0.f));
109 std::vector<std::vector<float>> capture(
110 NumBandsForRate(rate), std::vector<float>(kBlockSize, 0.f));
111 EchoPathVariability echo_path_variability(false, false);
112 rtc::Optional<size_t> echo_path_delay_samples;
113 EXPECT_DEATH(
114 remover->ProcessBlock(echo_path_delay_samples, echo_path_variability,
115 false, render, &capture),
116 "");
117 }
118 }
119
120 // Verifies the check for the number of capture bands.
121 TEST(EchoRemover, WrongCaptureNumBands) {
122 for (auto rate : {16000, 32000, 48000}) {
123 ProduceDebugText(rate);
124 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(rate));
125
126 std::vector<std::vector<float>> render(NumBandsForRate(rate),
127 std::vector<float>(kBlockSize, 0.f));
128 std::vector<std::vector<float>> capture(
129 NumBandsForRate(rate == 48000 ? 16000 : rate + 16000),
130 std::vector<float>(kBlockSize, 0.f));
131 EchoPathVariability echo_path_variability(false, false);
132 rtc::Optional<size_t> echo_path_delay_samples;
133 EXPECT_DEATH(
134 remover->ProcessBlock(echo_path_delay_samples, echo_path_variability,
135 false, render, &capture),
136 "");
137 }
138 }
139
140 // Verifies the check for non-null capture block.
141 TEST(EchoRemover, NullCapture) {
142 std::unique_ptr<EchoRemover> remover(EchoRemover::Create(8000));
143
144 std::vector<std::vector<float>> render(NumBandsForRate(8000),
145 std::vector<float>(kBlockSize, 0.f));
146 EchoPathVariability echo_path_variability(false, false);
147 rtc::Optional<size_t> echo_path_delay_samples;
148 EXPECT_DEATH(
149 remover->ProcessBlock(echo_path_delay_samples, echo_path_variability,
150 false, render, nullptr),
151 "");
152 }
153
154 #endif
155
156 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698