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 <stddef.h> // size_t | |
12 #include <string> | |
13 #include <vector> | |
14 | |
15 #include "testing/gtest/include/gtest/gtest.h" | |
16 #include "webrtc/audio_processing/debug.pb.h" | |
17 #include "webrtc/base/checks.h" | |
18 #include "webrtc/base/scoped_ptr.h" | |
19 #include "webrtc/common_audio/channel_buffer.h" | |
20 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" | |
21 #include "webrtc/modules/audio_processing/include/audio_processing.h" | |
22 #include "webrtc/modules/audio_processing/test/protobuf_utils.h" | |
23 #include "webrtc/modules/audio_processing/test/test_utils.h" | |
24 #include "webrtc/test/testsupport/fileutils.h" | |
25 | |
26 namespace { | |
27 | |
28 using webrtc::ChannelBuffer; | |
29 using webrtc::Config; | |
30 using webrtc::StreamConfig; | |
31 using webrtc::test::ResampleInputAudioFile; | |
32 using webrtc::AudioProcessing; | |
33 | |
34 void MaybeResetBuffer(rtc::scoped_ptr<ChannelBuffer<float>>* buffer, | |
35 const StreamConfig& config) { | |
36 if (!(*buffer).get() || (*buffer)->num_frames() != config.num_frames() || | |
Andrew MacDonald
2015/10/30 16:26:07
Consider adding a local reference to avoid all the
| |
37 (*buffer)->num_channels() != config.num_channels()) { | |
38 (*buffer).reset(new webrtc::ChannelBuffer<float>(config.num_frames(), | |
Andrew MacDonald
2015/10/30 16:26:06
In any case, you have a using webrtc::ChannelBuffe
minyue-webrtc
2015/10/30 16:32:25
right. I found tried to place it all places and fe
| |
39 config.num_channels())); | |
40 } | |
41 } | |
42 | |
43 class DebugDumpGenerator { | |
44 public: | |
45 DebugDumpGenerator(const std::string& input_file_name, | |
46 int input_file_rate_hz, | |
47 int input_channels, | |
48 const std::string& reverse_file_name, | |
49 int reverse_file_rate_hz, | |
50 int reverse_channels, | |
51 const Config& config, | |
52 const std::string& dump_file_name); | |
53 | |
54 // Constructor that uses default input files. | |
55 explicit DebugDumpGenerator(const Config& config); | |
56 | |
57 ~DebugDumpGenerator(); | |
58 | |
59 // Changes the sample rate of the input audio to the APM. | |
60 void SetInputRate(int rate_hz); | |
61 | |
62 // Sets if converts stereo input signal to mono by discarding other channels. | |
63 void ForceInputMono(bool mono); | |
64 | |
65 // Changes the sample rate of the reverse audio to the APM. | |
66 void SetReverseRate(int rate_hz); | |
67 | |
68 // Sets if converts stereo reverse signal to mono by discarding other | |
69 // channels. | |
70 void ForceReverseMono(bool mono); | |
71 | |
72 // Sets the required sample rate of the APM output. | |
73 void SetOutputRate(int rate_hz); | |
74 | |
75 // Sets the required channels of the APM output. | |
76 void SetOutputChannels(int channels); | |
77 | |
78 std::string dump_file_name() const { return dump_file_name_; } | |
79 | |
80 void StartRecording(); | |
81 void Process(size_t num_blocks); | |
82 void StopRecording(); | |
83 AudioProcessing* apm() const { return apm_.get(); } | |
84 | |
85 private: | |
86 static void ReadAndDeinterleave(ResampleInputAudioFile* audio, int channels, | |
87 const StreamConfig& config, | |
88 float* const* buffer); | |
89 | |
90 // APM input/output settings. | |
91 StreamConfig input_config_; | |
92 StreamConfig reverse_config_; | |
93 StreamConfig output_config_; | |
94 | |
95 // Input file format. | |
96 const std::string input_file_name_; | |
97 ResampleInputAudioFile input_audio_; | |
98 const int input_file_channels_; | |
99 | |
100 // Reverse file format. | |
101 const std::string reverse_file_name_; | |
102 ResampleInputAudioFile reverse_audio_; | |
103 const int reverse_file_channels_; | |
104 | |
105 // Buffer for APM input/output. | |
106 rtc::scoped_ptr<ChannelBuffer<float>> input_; | |
107 rtc::scoped_ptr<ChannelBuffer<float>> reverse_; | |
108 rtc::scoped_ptr<ChannelBuffer<float>> output_; | |
109 | |
110 rtc::scoped_ptr<AudioProcessing> apm_; | |
111 | |
112 const std::string dump_file_name_; | |
113 }; | |
114 | |
115 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, | |
116 int input_rate_hz, | |
117 int input_channels, | |
118 const std::string& reverse_file_name, | |
119 int reverse_rate_hz, | |
120 int reverse_channels, | |
121 const Config& config, | |
122 const std::string& dump_file_name) | |
123 : input_config_(input_rate_hz, input_channels), | |
124 reverse_config_(reverse_rate_hz, reverse_channels), | |
125 output_config_(input_rate_hz, input_channels), | |
126 input_audio_(input_file_name, input_rate_hz, input_rate_hz), | |
127 input_file_channels_(input_channels), | |
128 reverse_audio_(reverse_file_name, reverse_rate_hz, reverse_rate_hz), | |
129 reverse_file_channels_(reverse_channels), | |
130 input_(new ChannelBuffer<float>(input_config_.num_frames(), | |
131 input_config_.num_channels())), | |
132 reverse_(new ChannelBuffer<float>(reverse_config_.num_frames(), | |
133 reverse_config_.num_channels())), | |
134 output_(new ChannelBuffer<float>(output_config_.num_frames(), | |
135 output_config_.num_channels())), | |
136 apm_(AudioProcessing::Create(config)), | |
137 dump_file_name_(dump_file_name) { | |
138 } | |
139 | |
140 DebugDumpGenerator::DebugDumpGenerator(const Config& config) | |
141 : DebugDumpGenerator( | |
142 webrtc::test::ResourcePath("near32_stereo", "pcm"), 32000, 2, | |
143 webrtc::test::ResourcePath("far32_stereo", "pcm"), 32000, 2, | |
144 config, | |
145 webrtc::test::TempFilename(webrtc::test::OutputPath(), "debug_aec")) { | |
146 } | |
147 | |
148 DebugDumpGenerator::~DebugDumpGenerator() { | |
149 remove(dump_file_name_.c_str()); | |
150 } | |
151 | |
152 void DebugDumpGenerator::SetInputRate(int rate_hz) { | |
153 input_audio_.set_output_rate_hz(rate_hz); | |
154 input_config_.set_sample_rate_hz(rate_hz); | |
155 MaybeResetBuffer(&input_, input_config_); | |
156 } | |
157 | |
158 void DebugDumpGenerator::ForceInputMono(bool mono) { | |
159 const int channels = mono ? 1 : input_file_channels_; | |
160 input_config_.set_num_channels(channels); | |
161 MaybeResetBuffer(&input_, input_config_); | |
162 } | |
163 | |
164 void DebugDumpGenerator::SetReverseRate(int rate_hz) { | |
165 reverse_audio_.set_output_rate_hz(rate_hz); | |
166 reverse_config_.set_sample_rate_hz(rate_hz); | |
167 MaybeResetBuffer(&reverse_, reverse_config_); | |
168 } | |
169 | |
170 void DebugDumpGenerator::ForceReverseMono(bool mono) { | |
171 const int channels = mono ? 1 : reverse_file_channels_; | |
172 reverse_config_.set_num_channels(channels); | |
173 MaybeResetBuffer(&reverse_, reverse_config_); | |
174 } | |
175 | |
176 void DebugDumpGenerator::SetOutputRate(int rate_hz) { | |
177 output_config_.set_sample_rate_hz(rate_hz); | |
178 MaybeResetBuffer(&output_, output_config_); | |
179 } | |
180 | |
181 void DebugDumpGenerator::SetOutputChannels(int channels) { | |
182 output_config_.set_num_channels(channels); | |
183 MaybeResetBuffer(&output_, output_config_); | |
184 } | |
185 | |
186 void DebugDumpGenerator::StartRecording() { | |
187 apm_->StartDebugRecording(dump_file_name_.c_str()); | |
188 } | |
189 | |
190 void DebugDumpGenerator::Process(size_t num_blocks) { | |
191 for (size_t i = 0; i < num_blocks; ++i) { | |
192 ReadAndDeinterleave(&reverse_audio_, reverse_file_channels_, | |
193 reverse_config_, reverse_->channels()); | |
194 ReadAndDeinterleave(&input_audio_, input_file_channels_, input_config_, | |
195 input_->channels()); | |
196 RTC_CHECK_EQ(AudioProcessing::kNoError, apm_->set_stream_delay_ms(100)); | |
197 apm_->set_stream_key_pressed(i % 10 == 9); | |
198 RTC_CHECK_EQ(AudioProcessing::kNoError, | |
199 apm_->ProcessStream(input_->channels(), input_config_, | |
200 output_config_, output_->channels())); | |
201 | |
202 RTC_CHECK_EQ(AudioProcessing::kNoError, | |
203 apm_->ProcessReverseStream(reverse_->channels(), | |
204 reverse_config_, | |
205 reverse_config_, | |
206 reverse_->channels())); | |
207 } | |
208 } | |
209 | |
210 void DebugDumpGenerator::StopRecording() { | |
211 apm_->StopDebugRecording(); | |
212 } | |
213 | |
214 void DebugDumpGenerator::ReadAndDeinterleave(ResampleInputAudioFile* audio, | |
215 int channels, | |
216 const StreamConfig& config, | |
217 float* const* buffer) { | |
218 const size_t num_frames = config.num_frames(); | |
219 const int out_channels = config.num_channels(); | |
220 | |
221 std::vector<int16_t> signal(channels * num_frames); | |
222 | |
223 audio->Read(num_frames * channels, &signal[0]); | |
224 | |
225 // We only allow reducing number of channels by discarding some channels. | |
226 RTC_CHECK_LE(out_channels, channels); | |
227 for (int channel = 0; channel < out_channels; ++channel) { | |
228 for (size_t i = 0; i < num_frames; ++i) { | |
229 buffer[channel][i] = webrtc::S16ToFloat(signal[i * channels + channel]); | |
230 } | |
231 } | |
232 } | |
233 | |
234 } // namespace | |
235 | |
236 namespace webrtc { | |
237 namespace test { | |
238 | |
239 class DebugDumpTest : public ::testing::Test { | |
240 public: | |
241 DebugDumpTest(); | |
242 | |
243 // VerifyDebugDump replays a debug dump using APM and verifies that the result | |
244 // is bit-exact-identical to the output channel in the dump. This is only | |
245 // guaranteed if the debug dump is started on the first frame. | |
246 void VerifyDebugDump(const std::string& dump_file_name); | |
247 | |
248 private: | |
249 // Following functions are facilities for replaying debug dumps. | |
250 void OnInitEvent(const webrtc::audioproc::Init& msg); | |
251 void OnStreamEvent(const webrtc::audioproc::Stream& msg); | |
252 void OnReverseStreamEvent(const webrtc::audioproc::ReverseStream& msg); | |
253 void OnConfigEvent(const webrtc::audioproc::Config& msg); | |
254 | |
255 void MaybeRecreateApm(const webrtc::audioproc::Config& msg); | |
256 void ConfigureApm(const webrtc::audioproc::Config& msg); | |
257 | |
258 // Buffer for APM input/output. | |
259 rtc::scoped_ptr<ChannelBuffer<float>> input_; | |
260 rtc::scoped_ptr<ChannelBuffer<float>> reverse_; | |
261 rtc::scoped_ptr<ChannelBuffer<float>> output_; | |
262 | |
263 rtc::scoped_ptr<AudioProcessing> apm_; | |
264 | |
265 StreamConfig input_config_; | |
266 StreamConfig reverse_config_; | |
267 StreamConfig output_config_; | |
268 }; | |
269 | |
270 DebugDumpTest::DebugDumpTest() | |
271 : input_(nullptr), // will be created upon usage. | |
272 reverse_(nullptr), | |
273 output_(nullptr), | |
274 apm_(nullptr) { | |
275 } | |
276 | |
277 void DebugDumpTest::VerifyDebugDump(const std::string& in_filename) { | |
278 FILE* in_file = fopen(in_filename.c_str(), "rb"); | |
279 ASSERT_TRUE(in_file); | |
280 audioproc::Event event_msg; | |
281 | |
282 while (ReadMessageFromFile(in_file, &event_msg)) { | |
283 switch (event_msg.type()) { | |
284 case audioproc::Event::INIT: | |
285 OnInitEvent(event_msg.init()); | |
286 break; | |
287 case audioproc::Event::STREAM: | |
288 OnStreamEvent(event_msg.stream()); | |
289 break; | |
290 case audioproc::Event::REVERSE_STREAM: | |
291 OnReverseStreamEvent(event_msg.reverse_stream()); | |
292 break; | |
293 case audioproc::Event::CONFIG: | |
294 OnConfigEvent(event_msg.config()); | |
295 break; | |
296 case audioproc::Event::UNKNOWN_EVENT: | |
297 // We do not expect receive UNKNOWN event currently. | |
298 FAIL(); | |
299 } | |
300 } | |
301 fclose(in_file); | |
302 } | |
303 | |
304 // OnInitEvent reset the input/output/reserve channel format. | |
305 void DebugDumpTest::OnInitEvent(const audioproc::Init& msg) { | |
306 ASSERT_TRUE(msg.has_num_input_channels()); | |
307 ASSERT_TRUE(msg.has_output_sample_rate()); | |
308 ASSERT_TRUE(msg.has_num_output_channels()); | |
309 ASSERT_TRUE(msg.has_reverse_sample_rate()); | |
310 ASSERT_TRUE(msg.has_num_reverse_channels()); | |
311 | |
312 input_config_ = StreamConfig(msg.sample_rate(), msg.num_input_channels()); | |
313 output_config_ = | |
314 StreamConfig(msg.output_sample_rate(), msg.num_output_channels()); | |
315 reverse_config_ = | |
316 StreamConfig(msg.reverse_sample_rate(), msg.num_reverse_channels()); | |
317 | |
318 MaybeResetBuffer(&input_, input_config_); | |
319 MaybeResetBuffer(&output_, output_config_); | |
320 MaybeResetBuffer(&reverse_, reverse_config_); | |
321 } | |
322 | |
323 // OnStreamEvent replays an input signal and verifies the output. | |
324 void DebugDumpTest::OnStreamEvent(const audioproc::Stream& msg) { | |
325 // APM should have been created. | |
326 ASSERT_TRUE(apm_.get()); | |
327 | |
328 EXPECT_NOERR(apm_->gain_control()->set_stream_analog_level(msg.level())); | |
329 EXPECT_NOERR(apm_->set_stream_delay_ms(msg.delay())); | |
330 apm_->echo_cancellation()->set_stream_drift_samples(msg.drift()); | |
331 if (msg.has_keypress()) | |
332 apm_->set_stream_key_pressed(msg.keypress()); | |
333 else | |
334 apm_->set_stream_key_pressed(true); | |
335 | |
336 ASSERT_EQ(input_config_.num_channels(), msg.input_channel_size()); | |
337 ASSERT_EQ(input_config_.num_frames() * sizeof(float), | |
338 msg.input_channel(0).size()); | |
339 | |
340 for (int i = 0; i < msg.input_channel_size(); ++i) { | |
341 memcpy(input_->channels()[i], msg.input_channel(i).data(), | |
342 msg.input_channel(i).size()); | |
343 } | |
344 | |
345 ASSERT_EQ(AudioProcessing::kNoError, | |
346 apm_->ProcessStream(input_->channels(), input_config_, | |
347 output_config_, output_->channels())); | |
348 | |
349 // Check that output of APM is bit-exact to the output in the dump. | |
350 ASSERT_EQ(output_config_.num_channels(), msg.output_channel_size()); | |
351 ASSERT_EQ(output_config_.num_frames() * sizeof(float), | |
352 msg.output_channel(0).size()); | |
353 for (int i = 0; i < msg.output_channel_size(); ++i) { | |
354 ASSERT_EQ(0, memcmp(output_->channels()[i], msg.output_channel(i).data(), | |
355 msg.output_channel(i).size())); | |
356 } | |
357 } | |
358 | |
359 void DebugDumpTest::OnReverseStreamEvent(const audioproc::ReverseStream& msg) { | |
360 // APM should have been created. | |
361 ASSERT_TRUE(apm_.get()); | |
362 | |
363 ASSERT_GT(msg.channel_size(), 0); | |
364 ASSERT_EQ(reverse_config_.num_channels(), msg.channel_size()); | |
365 ASSERT_EQ(reverse_config_.num_frames() * sizeof(float), | |
366 msg.channel(0).size()); | |
367 | |
368 for (int i = 0; i < msg.channel_size(); ++i) { | |
369 memcpy(reverse_->channels()[i], msg.channel(i).data(), | |
370 msg.channel(i).size()); | |
371 } | |
372 | |
373 ASSERT_EQ(AudioProcessing::kNoError, | |
374 apm_->ProcessReverseStream(reverse_->channels(), | |
375 reverse_config_, | |
376 reverse_config_, | |
377 reverse_->channels())); | |
378 } | |
379 | |
380 void DebugDumpTest::OnConfigEvent(const audioproc::Config& msg) { | |
381 MaybeRecreateApm(msg); | |
382 ConfigureApm(msg); | |
383 } | |
384 | |
385 void DebugDumpTest::MaybeRecreateApm(const audioproc::Config& msg) { | |
386 // These configurations cannot be changed on the fly. | |
387 Config config; | |
388 ASSERT_TRUE(msg.has_aec_delay_agnostic_enabled()); | |
389 config.Set<DelayAgnostic>( | |
390 new DelayAgnostic(msg.aec_delay_agnostic_enabled())); | |
391 | |
392 ASSERT_TRUE(msg.has_noise_robust_agc_enabled()); | |
393 config.Set<ExperimentalAgc>( | |
394 new ExperimentalAgc(msg.noise_robust_agc_enabled())); | |
395 | |
396 ASSERT_TRUE(msg.has_transient_suppression_enabled()); | |
397 config.Set<ExperimentalNs>( | |
398 new ExperimentalNs(msg.transient_suppression_enabled())); | |
399 | |
400 ASSERT_TRUE(msg.has_aec_extended_filter_enabled()); | |
401 config.Set<ExtendedFilter>(new ExtendedFilter( | |
402 msg.aec_extended_filter_enabled())); | |
403 | |
404 // We only create APM once, since changes on these fields should not | |
405 // happen in current implementation. | |
406 if (!apm_.get()) { | |
407 apm_.reset(AudioProcessing::Create(config)); | |
408 } | |
409 } | |
410 | |
411 void DebugDumpTest::ConfigureApm(const audioproc::Config& msg) { | |
412 // AEC configs. | |
413 ASSERT_TRUE(msg.has_aec_enabled()); | |
414 EXPECT_EQ(AudioProcessing::kNoError, | |
415 apm_->echo_cancellation()->Enable(msg.aec_enabled())); | |
416 | |
417 ASSERT_TRUE(msg.has_aec_drift_compensation_enabled()); | |
418 EXPECT_EQ(AudioProcessing::kNoError, | |
419 apm_->echo_cancellation()->enable_drift_compensation( | |
420 msg.aec_drift_compensation_enabled())); | |
421 | |
422 ASSERT_TRUE(msg.has_aec_suppression_level()); | |
423 EXPECT_EQ(AudioProcessing::kNoError, | |
424 apm_->echo_cancellation()->set_suppression_level( | |
425 static_cast<webrtc::EchoCancellation::SuppressionLevel>( | |
426 msg.aec_suppression_level()))); | |
427 | |
428 // AECM configs. | |
429 ASSERT_TRUE(msg.has_aecm_enabled()); | |
430 EXPECT_EQ(AudioProcessing::kNoError, | |
431 apm_->echo_control_mobile()->Enable(msg.aecm_enabled())); | |
432 | |
433 ASSERT_TRUE(msg.has_aecm_comfort_noise_enabled()); | |
434 EXPECT_EQ(AudioProcessing::kNoError, | |
435 apm_->echo_control_mobile()->enable_comfort_noise( | |
436 msg.aecm_comfort_noise_enabled())); | |
437 | |
438 ASSERT_TRUE(msg.has_aecm_routing_mode()); | |
439 EXPECT_EQ(AudioProcessing::kNoError, | |
440 apm_->echo_control_mobile()->set_routing_mode( | |
441 static_cast<webrtc::EchoControlMobile::RoutingMode>( | |
442 msg.aecm_routing_mode()))); | |
443 | |
444 // AGC configs. | |
445 ASSERT_TRUE(msg.has_agc_enabled()); | |
446 EXPECT_EQ(AudioProcessing::kNoError, | |
447 apm_->gain_control()->Enable(msg.agc_enabled())); | |
448 | |
449 ASSERT_TRUE(msg.has_agc_mode()); | |
450 EXPECT_EQ(AudioProcessing::kNoError, | |
451 apm_->gain_control()->set_mode( | |
452 static_cast<webrtc::GainControl::Mode>(msg.agc_mode()))); | |
453 | |
454 ASSERT_TRUE(msg.has_agc_limiter_enabled()); | |
455 EXPECT_EQ(AudioProcessing::kNoError, | |
456 apm_->gain_control()->enable_limiter(msg.agc_limiter_enabled())); | |
457 | |
458 // HPF configs. | |
459 ASSERT_TRUE(msg.has_hpf_enabled()); | |
460 EXPECT_EQ(AudioProcessing::kNoError, | |
461 apm_->high_pass_filter()->Enable(msg.hpf_enabled())); | |
462 | |
463 // NS configs. | |
464 ASSERT_TRUE(msg.has_ns_enabled()); | |
465 EXPECT_EQ(AudioProcessing::kNoError, | |
466 apm_->noise_suppression()->Enable(msg.ns_enabled())); | |
467 | |
468 ASSERT_TRUE(msg.has_ns_level()); | |
469 EXPECT_EQ(AudioProcessing::kNoError, | |
470 apm_->noise_suppression()->set_level( | |
471 static_cast<webrtc::NoiseSuppression::Level>(msg.ns_level()))); | |
472 } | |
473 | |
474 TEST_F(DebugDumpTest, SimpleCase) { | |
475 Config config; | |
476 DebugDumpGenerator generator(config); | |
477 generator.StartRecording(); | |
478 generator.Process(100); | |
479 generator.StopRecording(); | |
480 VerifyDebugDump(generator.dump_file_name()); | |
481 } | |
482 | |
483 TEST_F(DebugDumpTest, ChangeInputFormat) { | |
484 Config config; | |
485 DebugDumpGenerator generator(config); | |
486 generator.StartRecording(); | |
487 generator.Process(100); | |
488 generator.SetInputRate(48000); | |
489 | |
490 generator.ForceInputMono(true); | |
491 // Number of output channel should not be larger than that of input. APM will | |
492 // fail otherwise. | |
493 generator.SetOutputChannels(1); | |
494 | |
495 generator.Process(100); | |
496 generator.StopRecording(); | |
497 VerifyDebugDump(generator.dump_file_name()); | |
498 } | |
499 | |
500 TEST_F(DebugDumpTest, ChangeReverseFormat) { | |
501 Config config; | |
502 DebugDumpGenerator generator(config); | |
503 generator.StartRecording(); | |
504 generator.Process(100); | |
505 generator.SetReverseRate(48000); | |
506 generator.ForceReverseMono(true); | |
507 generator.Process(100); | |
508 generator.StopRecording(); | |
509 VerifyDebugDump(generator.dump_file_name()); | |
510 } | |
511 | |
512 TEST_F(DebugDumpTest, ChangeOutputFormat) { | |
513 Config config; | |
514 DebugDumpGenerator generator(config); | |
515 generator.StartRecording(); | |
516 generator.Process(100); | |
517 generator.SetOutputRate(48000); | |
518 generator.SetOutputChannels(1); | |
519 generator.Process(100); | |
520 generator.StopRecording(); | |
521 VerifyDebugDump(generator.dump_file_name()); | |
522 } | |
523 | |
524 TEST_F(DebugDumpTest, ToggleAec) { | |
525 Config config; | |
526 DebugDumpGenerator generator(config); | |
527 generator.StartRecording(); | |
528 generator.Process(100); | |
529 | |
530 EchoCancellation* aec = generator.apm()->echo_cancellation(); | |
531 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(!aec->is_enabled())); | |
532 | |
533 generator.Process(100); | |
534 generator.StopRecording(); | |
535 VerifyDebugDump(generator.dump_file_name()); | |
536 } | |
537 | |
538 TEST_F(DebugDumpTest, ToggleDelayAgnosticAec) { | |
539 Config config; | |
540 config.Set<DelayAgnostic>(new DelayAgnostic(true)); | |
541 DebugDumpGenerator generator(config); | |
542 generator.StartRecording(); | |
543 generator.Process(100); | |
544 | |
545 EchoCancellation* aec = generator.apm()->echo_cancellation(); | |
546 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(!aec->is_enabled())); | |
547 | |
548 generator.Process(100); | |
549 generator.StopRecording(); | |
550 VerifyDebugDump(generator.dump_file_name()); | |
551 } | |
552 | |
553 TEST_F(DebugDumpTest, ToggleAecLevel) { | |
554 Config config; | |
555 DebugDumpGenerator generator(config); | |
556 EchoCancellation* aec = generator.apm()->echo_cancellation(); | |
557 EXPECT_EQ(AudioProcessing::kNoError, aec->Enable(true)); | |
558 EXPECT_EQ(AudioProcessing::kNoError, | |
559 aec->set_suppression_level(EchoCancellation::kLowSuppression)); | |
560 generator.StartRecording(); | |
561 generator.Process(100); | |
562 | |
563 EXPECT_EQ(AudioProcessing::kNoError, | |
564 aec->set_suppression_level(EchoCancellation::kHighSuppression)); | |
565 generator.Process(100); | |
566 generator.StopRecording(); | |
567 VerifyDebugDump(generator.dump_file_name()); | |
568 } | |
569 | |
570 TEST_F(DebugDumpTest, ToggleAgc) { | |
571 Config config; | |
572 DebugDumpGenerator generator(config); | |
573 generator.StartRecording(); | |
574 generator.Process(100); | |
575 | |
576 GainControl* agc = generator.apm()->gain_control(); | |
577 EXPECT_EQ(AudioProcessing::kNoError, agc->Enable(!agc->is_enabled())); | |
578 | |
579 generator.Process(100); | |
580 generator.StopRecording(); | |
581 VerifyDebugDump(generator.dump_file_name()); | |
582 } | |
583 | |
584 TEST_F(DebugDumpTest, ToggleNs) { | |
585 Config config; | |
586 DebugDumpGenerator generator(config); | |
587 generator.StartRecording(); | |
588 generator.Process(100); | |
589 | |
590 NoiseSuppression* ns = generator.apm()->noise_suppression(); | |
591 EXPECT_EQ(AudioProcessing::kNoError, ns->Enable(!ns->is_enabled())); | |
592 | |
593 generator.Process(100); | |
594 generator.StopRecording(); | |
595 VerifyDebugDump(generator.dump_file_name()); | |
596 } | |
597 | |
598 TEST_F(DebugDumpTest, TransientSuppressionOn) { | |
599 Config config; | |
600 config.Set<ExperimentalNs>(new ExperimentalNs(true)); | |
601 DebugDumpGenerator generator(config); | |
602 generator.StartRecording(); | |
603 generator.Process(100); | |
604 generator.StopRecording(); | |
605 VerifyDebugDump(generator.dump_file_name()); | |
606 } | |
607 | |
608 } // namespace test | |
609 } // namespace webrtc | |
OLD | NEW |