OLD | NEW |
---|---|
(Empty) | |
1 /* | |
2 * Copyright (c) 2015 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/test/debug_dump_test.h" | |
12 | |
13 #include "webrtc/base/checks.h" | |
14 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | |
15 #include "webrtc/modules/audio_processing/test/test_utils.h" | |
16 #include "webrtc/test/testsupport/fileutils.h" | |
17 | |
18 namespace webrtc { | |
19 namespace test { | |
20 | |
21 namespace { | |
Andrew MacDonald
2015/10/20 01:22:08
Blank space after this line.
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
22 const std::string input_file_name = | |
Andrew MacDonald
2015/10/20 01:22:08
No indent. Use git cl format.
These strings are n
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
23 test::ResourcePath("near32_stereo", "pcm"); | |
24 const int kInputFileRateHz = 32000; | |
25 const size_t kInputFileChannels = 2; | |
26 const std::string reverse_file_name = | |
27 test::ResourcePath("far32_stereo", "pcm"); | |
28 const int kReverseFileRateHz = 32000; | |
29 const size_t kReverseFileChannels = 2; | |
30 } | |
Andrew MacDonald
2015/10/20 01:22:08
Blank space before this line.
} // namespace
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
31 | |
32 DebugDumpGenerator::DebugDumpGenerator(std::string input_file_name, | |
33 int input_file_rate_hz, | |
34 size_t input_channels, | |
35 std::string reverse_file_name, | |
36 int reverse_file_rate_hz, | |
37 size_t reverse_channels, | |
38 const Config& config, | |
39 std::string dump_file_name) | |
40 : input_rate_hz_(input_file_rate_hz), | |
41 input_mono_(false), | |
42 reverse_rate_hz_(reverse_file_rate_hz), | |
43 reverse_mono_(false), | |
44 output_rate_hz_(input_file_rate_hz), | |
45 output_channels_(input_channels), | |
46 input_audio_(new ResampleInputAudioFile(input_file_name, | |
47 input_file_rate_hz, | |
48 input_rate_hz_)), | |
49 input_channels_(input_channels), | |
50 reverse_audio_(new ResampleInputAudioFile(reverse_file_name, | |
51 reverse_file_rate_hz, | |
52 reverse_rate_hz_)), | |
53 reverse_channels_(reverse_channels), | |
54 // Buffers will be created upon usage. | |
Andrew MacDonald
2015/10/20 01:22:08
You could trigger the same InitializeFormat or wha
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
| |
55 input_(nullptr), | |
56 reverse_(nullptr), | |
57 output_(nullptr), | |
58 apm_(AudioProcessing::Create(config)), | |
59 dump_file_name_(dump_file_name) { | |
60 } | |
61 | |
62 void DebugDumpGenerator::SetInputRate(int rate_hz) { | |
63 RTC_DCHECK(input_audio_.get()); | |
Andrew MacDonald
2015/10/20 01:22:08
This is created in the constructor, so no need for
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
| |
64 input_rate_hz_ = rate_hz; | |
65 input_audio_->set_output_rate_hz(input_rate_hz_); | |
66 } | |
67 | |
68 void DebugDumpGenerator::ForceInputMono(bool mono) { | |
69 input_mono_ = mono; | |
70 if (input_mono_) { | |
71 // Output channels is set since it should be no bigger than input channels. | |
72 output_channels_ = 1; | |
Andrew MacDonald
2015/10/20 01:22:08
What if ForceInputMono(false) is called?
minyue-webrtc
2015/10/23 08:44:45
yes agreed. I think it is better not to change the
| |
73 } | |
74 } | |
75 | |
76 void DebugDumpGenerator::SetReverseRate(int rate_hz) { | |
77 RTC_DCHECK(reverse_audio_.get()); | |
Andrew MacDonald
2015/10/20 01:22:08
Not needed.
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
| |
78 reverse_rate_hz_ = rate_hz; | |
79 reverse_audio_->set_output_rate_hz(reverse_rate_hz_); | |
80 } | |
81 | |
82 void DebugDumpGenerator::ForceReverseMono(bool mono) { | |
83 reverse_mono_ = mono; | |
84 } | |
85 | |
86 void DebugDumpGenerator::StartRecording() { | |
87 RTC_DCHECK(apm_.get()); | |
Andrew MacDonald
2015/10/20 01:22:08
Not needed.
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
| |
88 apm_->StartDebugRecording(dump_file_name_.c_str()); | |
89 } | |
90 | |
91 void DebugDumpGenerator::Process(size_t num_blocks) { | |
92 RTC_DCHECK(apm_.get()); | |
Andrew MacDonald
2015/10/20 01:22:08
Not needed.
minyue-webrtc
2015/10/23 08:44:45
Acknowledged.
| |
93 | |
94 const size_t apm_input_channels = input_mono_ ? 1 : input_channels_; | |
95 const size_t apm_rev_channels = reverse_mono_ ? 1 : reverse_channels_; | |
96 const size_t apm_input_frames = rtc::CheckedDivExact( | |
97 AudioProcessing::kChunkSizeMs * input_rate_hz_, 1000); | |
98 const size_t apm_rev_frames = rtc::CheckedDivExact( | |
99 AudioProcessing::kChunkSizeMs * reverse_rate_hz_, 1000); | |
100 | |
101 // The following enlarges buffers when necessary. | |
102 if (!input_.get() || input_->num_frames() < apm_input_frames || | |
Andrew MacDonald
2015/10/20 01:22:08
Since this is a test, we don't care about performa
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
103 input_->num_channels() < static_cast<int>(apm_input_channels)) { | |
104 input_.reset( | |
105 new ChannelBuffer<float>(apm_input_frames, apm_input_channels)); | |
106 } | |
107 | |
108 if (!reverse_.get() || reverse_->num_frames() < apm_rev_frames || | |
109 reverse_->num_channels() < static_cast<int>(apm_rev_channels)) { | |
110 reverse_.reset( | |
111 new ChannelBuffer<float>(apm_rev_frames, apm_rev_channels)); | |
112 } | |
113 | |
114 // The following effectively calculates | |
115 // ceil(apm_input_frames * output_rate_hz_ / input_rate_hz_). | |
116 const size_t apm_output_frames = (apm_input_frames * output_rate_hz_ + | |
117 input_rate_hz_ - 1) / input_rate_hz_; | |
118 | |
119 if (!output_.get() || output_->num_frames() < apm_output_frames || | |
120 output_->num_channels() < static_cast<int>(output_channels_)) { | |
121 output_.reset( | |
122 new ChannelBuffer<float>(apm_output_frames, output_channels_)); | |
123 } | |
124 | |
125 for (size_t i = 0; i < num_blocks; ++i) { | |
126 ReadAndDeinterleave(reverse_audio_.get(), reverse_channels_, apm_rev_frames, | |
127 reverse_mono_, reverse_->channels()); | |
128 ReadAndDeinterleave(input_audio_.get(), input_channels_, apm_input_frames, | |
129 input_mono_, input_->channels()); | |
130 | |
131 // Set a varying stream delay. | |
132 RTC_CHECK_EQ(AudioProcessing::kNoError, | |
133 apm_->set_stream_delay_ms(100 + i % 10)); | |
134 | |
135 // A key press event is added every 10th block. | |
136 apm_->set_stream_key_pressed(i % 10 == 9); | |
137 | |
138 RTC_CHECK_EQ(AudioProcessing::kNoError, | |
139 apm_->ProcessStream(input_->channels(), | |
140 apm_input_frames, | |
141 input_rate_hz_, | |
142 LayoutFromChannels(apm_input_channels), | |
143 output_rate_hz_, | |
144 LayoutFromChannels(output_channels_), | |
145 output_->channels())); | |
146 RTC_CHECK_EQ( | |
147 AudioProcessing::kNoError, | |
148 apm_->AnalyzeReverseStream(reverse_->channels(), | |
149 apm_rev_frames, | |
150 reverse_rate_hz_, | |
151 LayoutFromChannels(apm_rev_channels))); | |
152 } | |
153 } | |
154 | |
155 void DebugDumpGenerator::StopRecording() { | |
156 apm_->StopDebugRecording(); | |
157 } | |
158 | |
159 void DebugDumpGenerator::ReadAndDeinterleave( | |
160 ResampleInputAudioFile* audio, size_t channels, | |
161 size_t frames_per_channel, bool force_mono, float* const* buffer) { | |
162 // Make sure the buffer for reading the file is large enough. | |
163 if (channels * frames_per_channel > signal_.size()) { | |
164 signal_.resize(frames_per_channel * channels); | |
165 } | |
166 | |
167 audio->Read(frames_per_channel * channels, &signal_[0]); | |
168 | |
169 const size_t out_channels = force_mono ? 1 : channels; | |
170 for (size_t channel = 0; channel < out_channels; ++channel) { | |
171 for (size_t i = 0; i < frames_per_channel; ++i) { | |
172 buffer[channel][i] = S16ToFloat(signal_[i * channels + channel]); | |
173 } | |
174 } | |
175 } | |
176 | |
177 #ifdef WEBRTC_AUDIOPROC_DEBUG_DUMP | |
Andrew MacDonald
2015/10/20 01:22:08
This file should only be built when this is define
minyue-webrtc
2015/10/23 08:44:45
Ironically, the DebugDumpGenerator can still work,
Andrew MacDonald
2015/10/24 00:42:05
But this file is only compiled when enable_protobu
minyue-webrtc
2015/10/26 12:40:31
Now removed
| |
178 | |
179 DebugDumpTest::DebugDumpTest() | |
180 : input_rate_hz_(-1), | |
181 input_channels_(0), | |
182 output_rate_hz_(-1), | |
183 output_channels_(0), | |
184 reverse_rate_hz_(-1), | |
185 reverse_channels_(0), | |
186 // Buffers will be created upon usage. | |
187 input_(nullptr), | |
188 reverse_(nullptr), | |
189 output_(nullptr), | |
190 // APM will be created upon usage. | |
191 apm_(nullptr) { | |
192 } | |
193 | |
194 void DebugDumpTest::VerifyDebugDump(const std::string in_filename) { | |
Andrew MacDonald
2015/10/20 01:22:08
const std::string&
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
195 FILE* in_file = fopen(in_filename.c_str(), "rb"); | |
196 ASSERT_TRUE(in_file != NULL); | |
Andrew MacDonald
2015/10/20 01:22:08
nullptr
minyue-webrtc
2015/10/23 08:44:45
maybe better to remove !=NULL at all
| |
197 audioproc::Event event_msg; | |
198 | |
199 while (ReadMessageFromFile(in_file, &event_msg)) { | |
200 switch (event_msg.type()) { | |
201 case audioproc::Event::INIT: | |
202 OnInitEvent(event_msg.init()); | |
203 break; | |
204 case audioproc::Event::STREAM: | |
205 OnStreamEvent(event_msg.stream()); | |
206 break; | |
207 case audioproc::Event::REVERSE_STREAM: | |
208 OnReverseStreamEvent(event_msg.reverse_stream()); | |
209 break; | |
210 case audioproc::Event::CONFIG: | |
211 OnConfigEvent(event_msg.config()); | |
212 break; | |
213 case audioproc::Event::UNKNOWN_EVENT: | |
214 // We do not expect receive UNKNOWN event currently. | |
215 ASSERT_TRUE(false); | |
216 } | |
217 } | |
218 fclose(in_file); | |
219 } | |
220 | |
221 // OnInitEvent reset the input/output/reserve channel format. | |
222 void DebugDumpTest::OnInitEvent(const audioproc::Init& msg) { | |
223 input_rate_hz_ = msg.sample_rate(); | |
224 | |
225 ASSERT_TRUE(msg.has_num_input_channels()); | |
226 input_channels_ = msg.num_input_channels(); | |
227 | |
228 ASSERT_TRUE(msg.has_output_sample_rate()); | |
229 output_rate_hz_ = msg.output_sample_rate(); | |
230 | |
231 ASSERT_TRUE(msg.has_num_output_channels()); | |
232 output_channels_ = msg.num_output_channels(); | |
233 | |
234 ASSERT_TRUE(msg.has_reverse_sample_rate()); | |
235 reverse_rate_hz_ = msg.reverse_sample_rate(); | |
236 | |
237 ASSERT_TRUE(msg.has_num_reverse_channels()); | |
238 reverse_channels_ = msg.num_reverse_channels(); | |
239 } | |
240 | |
241 // OnStreamEvent replays an input signal and verifies the output. | |
242 void DebugDumpTest::OnStreamEvent(const audioproc::Stream& msg) { | |
243 // APM should have been created. | |
244 ASSERT_TRUE(apm_.get()); | |
245 | |
246 EXPECT_NOERR(apm_->gain_control()->set_stream_analog_level(msg.level())); | |
247 EXPECT_NOERR(apm_->set_stream_delay_ms(msg.delay())); | |
248 apm_->echo_cancellation()->set_stream_drift_samples(msg.drift()); | |
249 if (msg.has_keypress()) | |
250 apm_->set_stream_key_pressed(msg.keypress()); | |
251 else | |
252 apm_->set_stream_key_pressed(true); | |
253 | |
254 ASSERT_EQ(static_cast<int>(input_channels_), msg.input_channel_size()); | |
255 | |
256 const size_t frames_per_input_channel = | |
257 rtc::CheckedDivExact(msg.input_channel(0).size(), sizeof(float)); | |
258 | |
259 // The following effectively calculates | |
260 // ceil(frames_per_input_channel * output_rate_hz_ / input_rate_hz_). | |
261 const size_t frames_per_output_channel = (frames_per_input_channel * | |
262 output_rate_hz_ + input_rate_hz_ - 1) / input_rate_hz_; | |
263 | |
264 // Updates the buffers to make sure that the sizes are large enough. | |
265 if (!input_.get() || input_->num_frames() < frames_per_input_channel || | |
Andrew MacDonald
2015/10/20 01:22:08
An init event has to occur for these values to cha
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
266 input_->num_channels() < static_cast<int>(input_channels_)) { | |
267 input_.reset( | |
268 new ChannelBuffer<float>(frames_per_input_channel, input_channels_)); | |
269 } | |
270 | |
271 if (!output_.get() || output_->num_frames() < frames_per_output_channel || | |
272 output_->num_channels() < static_cast<int>(output_channels_)) { | |
273 output_.reset( | |
274 new ChannelBuffer<float>(frames_per_output_channel, output_channels_)); | |
275 } | |
276 | |
277 for (int i = 0; i < msg.input_channel_size(); ++i) { | |
278 memcpy(input_->channels()[i], msg.input_channel(i).data(), | |
279 msg.input_channel(i).size()); | |
280 } | |
281 ASSERT_EQ(AudioProcessing::kNoError, | |
282 apm_->ProcessStream(input_->channels(), | |
Andrew MacDonald
2015/10/20 01:22:08
Can you use the ProcessStream overload with Stream
minyue-webrtc
2015/10/23 08:44:45
ok
| |
283 frames_per_input_channel, | |
284 input_rate_hz_, | |
285 LayoutFromChannels(input_channels_), | |
286 output_rate_hz_, | |
287 LayoutFromChannels(output_channels_), | |
288 output_->channels())); | |
289 | |
290 // Check that output of APM is bit exact identical to the output in the dump. | |
Andrew MacDonald
2015/10/20 01:22:08
s/bit exact identical/bit-exact
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
291 ASSERT_EQ(static_cast<int>(output_channels_), msg.output_channel_size()); | |
292 ASSERT_EQ(msg.output_channel(0).size(), | |
293 frames_per_output_channel * sizeof(float)); | |
294 for (int i = 0; i < msg.output_channel_size(); ++i) { | |
295 ASSERT_EQ(0, memcmp(output_->channels()[i], msg.output_channel(i).data(), | |
296 msg.output_channel(i).size())); | |
297 } | |
298 } | |
299 | |
300 void DebugDumpTest::OnReverseStreamEvent(const audioproc::ReverseStream& msg) { | |
301 // APM should have been created. | |
302 ASSERT_TRUE(apm_.get()); | |
303 | |
304 ASSERT_GT(msg.channel_size(), 0); | |
305 ASSERT_EQ(static_cast<int>(reverse_channels_), msg.channel_size()); | |
306 | |
307 const size_t frames_per_channel = | |
308 rtc::CheckedDivExact(msg.channel(0).size(), sizeof(float)); | |
309 if (!reverse_.get() || reverse_->num_frames() < frames_per_channel || | |
Andrew MacDonald
2015/10/20 01:22:08
Same thing: recreate this directly upon init event
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
310 reverse_->num_channels() < static_cast<int>(reverse_channels_)) { | |
311 reverse_.reset( | |
312 new ChannelBuffer<float>(frames_per_channel, reverse_channels_)); | |
313 } | |
314 | |
315 for (int i = 0; i < msg.channel_size(); ++i) { | |
316 memcpy(reverse_->channels()[i], msg.channel(i).data(), | |
317 msg.channel(i).size()); | |
318 } | |
319 | |
320 ASSERT_EQ(AudioProcessing::kNoError, | |
321 apm_->AnalyzeReverseStream( | |
Andrew MacDonald
2015/10/20 01:22:08
Can you use ProcessReverseStream instead? This is
minyue-webrtc
2015/10/23 08:44:45
ok
| |
322 reverse_->channels(), | |
323 frames_per_channel, | |
324 reverse_rate_hz_, | |
325 LayoutFromChannels(reverse_channels_))); | |
326 } | |
327 | |
328 void DebugDumpTest::OnConfigEvent(const audioproc::Config& msg) { | |
329 MaybeRecreateApm(msg); | |
330 ConfigurateApm(msg); | |
331 } | |
332 | |
333 void DebugDumpTest::MaybeRecreateApm(const audioproc::Config& msg) { | |
334 if (apm_.get()) { | |
335 // We only create APM once, since changes on these fields should not | |
336 // happen in current implementation. | |
337 return; | |
338 } | |
339 | |
340 Config config; | |
341 ASSERT_TRUE(msg.has_aec_delay_agnostic_enabled()); | |
342 config.Set<DelayAgnostic>( | |
343 new DelayAgnostic(msg.aec_delay_agnostic_enabled())); | |
344 | |
345 ASSERT_TRUE(msg.has_noise_robust_agc_enabled()); | |
346 config.Set<ExperimentalAgc>( | |
347 new ExperimentalAgc(msg.noise_robust_agc_enabled())); | |
348 | |
349 ASSERT_TRUE(msg.has_transient_suppression_enabled()); | |
350 config.Set<ExperimentalNs>( | |
351 new ExperimentalNs(msg.transient_suppression_enabled())); | |
352 | |
353 ASSERT_TRUE(msg.has_aec_extended_filter_enabled()); | |
354 config.Set<ExtendedFilter>(new ExtendedFilter( | |
355 msg.aec_extended_filter_enabled())); | |
356 | |
357 apm_.reset(AudioProcessing::Create(config)); | |
358 } | |
359 | |
360 void DebugDumpTest::ConfigurateApm(const audioproc::Config& msg) { | |
Andrew MacDonald
2015/10/20 01:22:08
ConfigureApm
minyue-webrtc
2015/10/23 08:44:45
Done.
| |
361 // AEC configs. | |
362 ASSERT_TRUE(msg.has_aec_enabled()); | |
363 EXPECT_EQ(AudioProcessing::kNoError, | |
364 apm_->echo_cancellation()->Enable(msg.aec_enabled())); | |
365 | |
366 ASSERT_TRUE(msg.has_aec_drift_compensation_enabled()); | |
367 EXPECT_EQ(AudioProcessing::kNoError, | |
368 apm_->echo_cancellation()->enable_drift_compensation( | |
369 msg.aec_drift_compensation_enabled())); | |
370 | |
371 ASSERT_TRUE(msg.has_aec_suppression_level()); | |
372 EXPECT_EQ(AudioProcessing::kNoError, | |
373 apm_->echo_cancellation()->set_suppression_level( | |
374 static_cast<webrtc::EchoCancellation::SuppressionLevel>( | |
375 msg.aec_suppression_level()))); | |
376 | |
377 // AECM configs. | |
378 ASSERT_TRUE(msg.has_aecm_enabled()); | |
379 EXPECT_EQ(AudioProcessing::kNoError, | |
380 apm_->echo_control_mobile()->Enable(msg.aecm_enabled())); | |
381 | |
382 ASSERT_TRUE(msg.has_aecm_comfort_noise_enabled()); | |
383 EXPECT_EQ(AudioProcessing::kNoError, | |
384 apm_->echo_control_mobile()->enable_comfort_noise( | |
385 msg.aecm_comfort_noise_enabled())); | |
386 | |
387 ASSERT_TRUE(msg.has_aecm_routing_mode()); | |
388 EXPECT_EQ(AudioProcessing::kNoError, | |
389 apm_->echo_control_mobile()->set_routing_mode( | |
390 static_cast<webrtc::EchoControlMobile::RoutingMode>( | |
391 msg.aecm_routing_mode()))); | |
392 | |
393 // AGC configs. | |
394 ASSERT_TRUE(msg.has_agc_enabled()); | |
395 EXPECT_EQ(AudioProcessing::kNoError, | |
396 apm_->gain_control()->Enable(msg.agc_enabled())); | |
397 | |
398 ASSERT_TRUE(msg.has_agc_mode()); | |
399 EXPECT_EQ(AudioProcessing::kNoError, | |
400 apm_->gain_control()->set_mode( | |
401 static_cast<webrtc::GainControl::Mode>(msg.agc_mode()))); | |
402 | |
403 ASSERT_TRUE(msg.has_agc_limiter_enabled()); | |
404 EXPECT_EQ(AudioProcessing::kNoError, | |
405 apm_->gain_control()->enable_limiter(msg.agc_limiter_enabled())); | |
406 | |
407 // HPF configs. | |
408 ASSERT_TRUE(msg.has_hpf_enabled()); | |
409 EXPECT_EQ(AudioProcessing::kNoError, | |
410 apm_->high_pass_filter()->Enable(msg.hpf_enabled())); | |
411 | |
412 // NS configs. | |
413 ASSERT_TRUE(msg.has_ns_enabled()); | |
414 EXPECT_EQ(AudioProcessing::kNoError, | |
415 apm_->noise_suppression()->Enable(msg.ns_enabled())); | |
416 | |
417 ASSERT_TRUE(msg.has_ns_level()); | |
418 EXPECT_EQ(AudioProcessing::kNoError, | |
419 apm_->noise_suppression()->set_level( | |
420 static_cast<webrtc::NoiseSuppression::Level>(msg.ns_level()))); | |
421 } | |
422 | |
423 #endif // WEBRTC_AUDIOPROC_DEBUG_DUMP | |
424 | |
425 TEST_F(DebugDumpTest, SimpleCase) { | |
426 Config config; | |
Andrew MacDonald
2015/10/20 01:22:08
It looks like you never do anything with config in
minyue-webrtc
2015/10/23 08:44:45
There are tests with config modified. see Line 536
Andrew MacDonald
2015/10/24 00:42:05
Ah, OK.
| |
427 const std::string dump_file_name = | |
428 test::TempFilename(test::OutputPath(), "debug_aec"); | |
Andrew MacDonald
2015/10/20 01:22:08
You use the same name in every test. I'd make dump
minyue-webrtc
2015/10/23 08:44:45
I made dump_file_name_ a member in the generator c
| |
429 DebugDumpGenerator generator(input_file_name, | |
430 kInputFileRateHz, | |
431 kInputFileChannels, | |
432 reverse_file_name, | |
433 kReverseFileRateHz, | |
434 kReverseFileChannels, | |
435 config, | |
436 dump_file_name); | |
437 generator.StartRecording(); | |
438 generator.Process(100); | |
439 generator.StopRecording(); | |
440 VerifyDebugDump(dump_file_name); | |
441 remove(dump_file_name.c_str()); | |
442 } | |
443 | |
444 TEST_F(DebugDumpTest, ChangeInputFormat) { | |
445 Config config; | |
446 const std::string dump_file_name = | |
447 test::TempFilename(test::OutputPath(), "debug_aec"); | |
448 DebugDumpGenerator generator(input_file_name, | |
449 kInputFileRateHz, | |
450 kInputFileChannels, | |
451 reverse_file_name, | |
452 kReverseFileRateHz, | |
453 kReverseFileChannels, | |
454 config, | |
455 dump_file_name); | |
456 generator.StartRecording(); | |
457 generator.Process(100); | |
458 generator.SetInputRate(48000); | |
459 generator.ForceInputMono(true); | |
460 generator.Process(100); | |
461 generator.StopRecording(); | |
462 VerifyDebugDump(dump_file_name); | |
463 remove(dump_file_name.c_str()); | |
464 } | |
465 | |
466 TEST_F(DebugDumpTest, ChangeReverseFormat) { | |
467 Config config; | |
468 const std::string dump_file_name = | |
469 test::TempFilename(test::OutputPath(), "debug_aec"); | |
470 DebugDumpGenerator generator(input_file_name, | |
471 kInputFileRateHz, | |
472 kInputFileChannels, | |
473 reverse_file_name, | |
474 kReverseFileRateHz, | |
475 kReverseFileChannels, | |
476 config, | |
477 dump_file_name); | |
478 generator.StartRecording(); | |
479 generator.Process(100); | |
480 generator.SetReverseRate(48000); | |
481 generator.ForceReverseMono(true); | |
482 generator.Process(100); | |
483 generator.StopRecording(); | |
484 VerifyDebugDump(dump_file_name); | |
485 remove(dump_file_name.c_str()); | |
486 } | |
487 | |
488 TEST_F(DebugDumpTest, ChangeOutputFormat) { | |
489 Config config; | |
490 const std::string dump_file_name = | |
491 test::TempFilename(test::OutputPath(), "debug_aec"); | |
492 DebugDumpGenerator generator(input_file_name, | |
493 kInputFileRateHz, | |
494 kInputFileChannels, | |
495 reverse_file_name, | |
496 kReverseFileRateHz, | |
497 kReverseFileChannels, | |
498 config, | |
499 dump_file_name); | |
500 generator.StartRecording(); | |
501 generator.Process(100); | |
502 generator.set_output_rate_hz(48000); | |
503 generator.set_output_channels(1); | |
504 generator.Process(100); | |
505 generator.StopRecording(); | |
506 VerifyDebugDump(dump_file_name); | |
507 remove(dump_file_name.c_str()); | |
508 } | |
509 | |
510 TEST_F(DebugDumpTest, ToggleAec) { | |
511 Config config; | |
512 const std::string dump_file_name = | |
513 test::TempFilename(test::OutputPath(), "debug_aec"); | |
514 DebugDumpGenerator generator(input_file_name, | |
515 kInputFileRateHz, | |
516 kInputFileChannels, | |
517 reverse_file_name, | |
518 kReverseFileRateHz, | |
519 kReverseFileChannels, | |
520 config, | |
521 dump_file_name); | |
522 generator.StartRecording(); | |
523 generator.Process(100); | |
524 | |
525 EchoCancellation* aec = generator.apm()->echo_cancellation(); | |
526 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(!aec->is_enabled())); | |
527 | |
528 generator.Process(100); | |
529 generator.StopRecording(); | |
530 VerifyDebugDump(dump_file_name); | |
531 remove(dump_file_name.c_str()); | |
532 } | |
533 | |
534 TEST_F(DebugDumpTest, ToggleDelayAgnosticAec) { | |
535 Config config; | |
536 config.Set<DelayAgnostic>(new DelayAgnostic(true)); | |
537 const std::string dump_file_name = | |
538 test::TempFilename(test::OutputPath(), "debug_aec"); | |
539 DebugDumpGenerator generator(input_file_name, | |
540 kInputFileRateHz, | |
541 kInputFileChannels, | |
542 reverse_file_name, | |
543 kReverseFileRateHz, | |
544 kReverseFileChannels, | |
545 config, | |
546 dump_file_name); | |
547 generator.StartRecording(); | |
548 generator.Process(100); | |
549 | |
550 EchoCancellation* aec = generator.apm()->echo_cancellation(); | |
551 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(!aec->is_enabled())); | |
552 | |
553 generator.Process(100); | |
554 generator.StopRecording(); | |
555 VerifyDebugDump(dump_file_name); | |
556 remove(dump_file_name.c_str()); | |
557 } | |
558 | |
559 TEST_F(DebugDumpTest, ToggleAecLevel) { | |
560 Config config; | |
561 const std::string dump_file_name = | |
562 test::TempFilename(test::OutputPath(), "debug_aec"); | |
563 DebugDumpGenerator generator(input_file_name, | |
564 kInputFileRateHz, | |
565 kInputFileChannels, | |
566 reverse_file_name, | |
567 kReverseFileRateHz, | |
568 kReverseFileChannels, | |
569 config, | |
570 dump_file_name); | |
571 EchoCancellation* aec = generator.apm()->echo_cancellation(); | |
572 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(true)); | |
573 EXPECT_EQ(AudioProcessing::kNoError, | |
574 aec->set_suppression_level(EchoCancellation::kLowSuppression)); | |
575 generator.StartRecording(); | |
576 generator.Process(100); | |
577 | |
578 EXPECT_EQ(AudioProcessing::kNoError, | |
579 aec->set_suppression_level(EchoCancellation::kHighSuppression)); | |
580 generator.Process(100); | |
581 generator.StopRecording(); | |
582 VerifyDebugDump(dump_file_name); | |
583 remove(dump_file_name.c_str()); | |
584 } | |
585 | |
586 TEST_F(DebugDumpTest, ToggleAgc) { | |
587 Config config; | |
588 const std::string dump_file_name = | |
589 test::TempFilename(test::OutputPath(), "debug_aec"); | |
590 DebugDumpGenerator generator(input_file_name, | |
591 kInputFileRateHz, | |
592 kInputFileChannels, | |
593 reverse_file_name, | |
594 kReverseFileRateHz, | |
595 kReverseFileChannels, | |
596 config, | |
597 dump_file_name); | |
598 generator.StartRecording(); | |
599 generator.Process(100); | |
600 | |
601 GainControl* agc = generator.apm()->gain_control(); | |
602 EXPECT_EQ(AudioProcessing::kNoError, agc->Enable(!agc->is_enabled())); | |
603 | |
604 generator.Process(100); | |
605 generator.StopRecording(); | |
606 VerifyDebugDump(dump_file_name); | |
607 remove(dump_file_name.c_str()); | |
608 } | |
609 | |
610 TEST_F(DebugDumpTest, ToggleNs) { | |
611 Config config; | |
612 const std::string dump_file_name = | |
613 test::TempFilename(test::OutputPath(), "debug_aec"); | |
614 DebugDumpGenerator generator(input_file_name, | |
615 kInputFileRateHz, | |
616 kInputFileChannels, | |
617 reverse_file_name, | |
618 kReverseFileRateHz, | |
619 kReverseFileChannels, | |
620 config, | |
621 dump_file_name); | |
622 generator.StartRecording(); | |
623 generator.Process(100); | |
624 | |
625 NoiseSuppression* ns = generator.apm()->noise_suppression(); | |
626 EXPECT_EQ(AudioProcessing::kNoError, ns->Enable(!ns->is_enabled())); | |
627 | |
628 generator.Process(100); | |
629 generator.StopRecording(); | |
630 VerifyDebugDump(dump_file_name); | |
631 remove(dump_file_name.c_str()); | |
632 } | |
633 | |
634 TEST_F(DebugDumpTest, TransientSuppressionOn) { | |
635 Config config; | |
636 config.Set<ExperimentalNs>(new ExperimentalNs(true)); | |
637 const std::string dump_file_name = | |
638 test::TempFilename(test::OutputPath(), "debug_aec"); | |
639 DebugDumpGenerator generator(input_file_name, | |
640 kInputFileRateHz, | |
641 kInputFileChannels, | |
642 reverse_file_name, | |
643 kReverseFileRateHz, | |
644 kReverseFileChannels, | |
645 config, | |
646 dump_file_name); | |
647 generator.StartRecording(); | |
648 generator.Process(100); | |
649 generator.StopRecording(); | |
650 VerifyDebugDump(dump_file_name); | |
651 remove(dump_file_name.c_str()); | |
652 } | |
653 | |
654 } // namespace test | |
655 } // namespace webrtc | |
OLD | NEW |