OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include <stddef.h> // size_t | 11 #include <stddef.h> // size_t |
12 | 12 |
13 #include <memory> | 13 #include <memory> |
14 #include <string> | 14 #include <string> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
| 17 #include "webrtc/base/task_queue.h" |
17 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" | 18 #include "webrtc/modules/audio_coding/neteq/tools/resample_input_audio_file.h" |
| 19 #include "webrtc/modules/audio_processing/aec_dump/aec_dump_factory.h" |
18 #include "webrtc/modules/audio_processing/test/debug_dump_replayer.h" | 20 #include "webrtc/modules/audio_processing/test/debug_dump_replayer.h" |
19 #include "webrtc/modules/audio_processing/test/test_utils.h" | 21 #include "webrtc/modules/audio_processing/test/test_utils.h" |
20 #include "webrtc/test/gtest.h" | 22 #include "webrtc/test/gtest.h" |
21 #include "webrtc/test/testsupport/fileutils.h" | 23 #include "webrtc/test/testsupport/fileutils.h" |
22 | 24 |
23 | 25 |
24 namespace webrtc { | 26 namespace webrtc { |
25 namespace test { | 27 namespace test { |
26 | 28 |
27 namespace { | 29 namespace { |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Reverse file format. | 99 // Reverse file format. |
98 const std::string reverse_file_name_; | 100 const std::string reverse_file_name_; |
99 ResampleInputAudioFile reverse_audio_; | 101 ResampleInputAudioFile reverse_audio_; |
100 const int reverse_file_channels_; | 102 const int reverse_file_channels_; |
101 | 103 |
102 // Buffer for APM input/output. | 104 // Buffer for APM input/output. |
103 std::unique_ptr<ChannelBuffer<float>> input_; | 105 std::unique_ptr<ChannelBuffer<float>> input_; |
104 std::unique_ptr<ChannelBuffer<float>> reverse_; | 106 std::unique_ptr<ChannelBuffer<float>> reverse_; |
105 std::unique_ptr<ChannelBuffer<float>> output_; | 107 std::unique_ptr<ChannelBuffer<float>> output_; |
106 | 108 |
| 109 rtc::TaskQueue worker_queue_; |
107 std::unique_ptr<AudioProcessing> apm_; | 110 std::unique_ptr<AudioProcessing> apm_; |
108 | 111 |
109 const std::string dump_file_name_; | 112 const std::string dump_file_name_; |
110 }; | 113 }; |
111 | 114 |
112 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, | 115 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, |
113 int input_rate_hz, | 116 int input_rate_hz, |
114 int input_channels, | 117 int input_channels, |
115 const std::string& reverse_file_name, | 118 const std::string& reverse_file_name, |
116 int reverse_rate_hz, | 119 int reverse_rate_hz, |
117 int reverse_channels, | 120 int reverse_channels, |
118 const Config& config, | 121 const Config& config, |
119 const std::string& dump_file_name) | 122 const std::string& dump_file_name) |
120 : input_config_(input_rate_hz, input_channels), | 123 : input_config_(input_rate_hz, input_channels), |
121 reverse_config_(reverse_rate_hz, reverse_channels), | 124 reverse_config_(reverse_rate_hz, reverse_channels), |
122 output_config_(input_rate_hz, input_channels), | 125 output_config_(input_rate_hz, input_channels), |
123 input_audio_(input_file_name, input_rate_hz, input_rate_hz), | 126 input_audio_(input_file_name, input_rate_hz, input_rate_hz), |
124 input_file_channels_(input_channels), | 127 input_file_channels_(input_channels), |
125 reverse_audio_(reverse_file_name, reverse_rate_hz, reverse_rate_hz), | 128 reverse_audio_(reverse_file_name, reverse_rate_hz, reverse_rate_hz), |
126 reverse_file_channels_(reverse_channels), | 129 reverse_file_channels_(reverse_channels), |
127 input_(new ChannelBuffer<float>(input_config_.num_frames(), | 130 input_(new ChannelBuffer<float>(input_config_.num_frames(), |
128 input_config_.num_channels())), | 131 input_config_.num_channels())), |
129 reverse_(new ChannelBuffer<float>(reverse_config_.num_frames(), | 132 reverse_(new ChannelBuffer<float>(reverse_config_.num_frames(), |
130 reverse_config_.num_channels())), | 133 reverse_config_.num_channels())), |
131 output_(new ChannelBuffer<float>(output_config_.num_frames(), | 134 output_(new ChannelBuffer<float>(output_config_.num_frames(), |
132 output_config_.num_channels())), | 135 output_config_.num_channels())), |
| 136 worker_queue_("debug_dump_generator_worker_queue"), |
133 apm_(AudioProcessing::Create(config)), | 137 apm_(AudioProcessing::Create(config)), |
134 dump_file_name_(dump_file_name) { | 138 dump_file_name_(dump_file_name) {} |
135 } | |
136 | 139 |
137 DebugDumpGenerator::DebugDumpGenerator( | 140 DebugDumpGenerator::DebugDumpGenerator( |
138 const Config& config, | 141 const Config& config, |
139 const AudioProcessing::Config& apm_config) | 142 const AudioProcessing::Config& apm_config) |
140 : DebugDumpGenerator(ResourcePath("near32_stereo", "pcm"), | 143 : DebugDumpGenerator(ResourcePath("near32_stereo", "pcm"), |
141 32000, | 144 32000, |
142 2, | 145 2, |
143 ResourcePath("far32_stereo", "pcm"), | 146 ResourcePath("far32_stereo", "pcm"), |
144 32000, | 147 32000, |
145 2, | 148 2, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 output_config_.set_sample_rate_hz(rate_hz); | 183 output_config_.set_sample_rate_hz(rate_hz); |
181 MaybeResetBuffer(&output_, output_config_); | 184 MaybeResetBuffer(&output_, output_config_); |
182 } | 185 } |
183 | 186 |
184 void DebugDumpGenerator::SetOutputChannels(int channels) { | 187 void DebugDumpGenerator::SetOutputChannels(int channels) { |
185 output_config_.set_num_channels(channels); | 188 output_config_.set_num_channels(channels); |
186 MaybeResetBuffer(&output_, output_config_); | 189 MaybeResetBuffer(&output_, output_config_); |
187 } | 190 } |
188 | 191 |
189 void DebugDumpGenerator::StartRecording() { | 192 void DebugDumpGenerator::StartRecording() { |
190 apm_->StartDebugRecording(dump_file_name_.c_str(), -1); | 193 apm_->StartDebugRecording( |
| 194 AecDumpFactory::Create(dump_file_name_.c_str(), -1, &worker_queue_)); |
191 } | 195 } |
192 | 196 |
193 void DebugDumpGenerator::Process(size_t num_blocks) { | 197 void DebugDumpGenerator::Process(size_t num_blocks) { |
194 for (size_t i = 0; i < num_blocks; ++i) { | 198 for (size_t i = 0; i < num_blocks; ++i) { |
195 ReadAndDeinterleave(&reverse_audio_, reverse_file_channels_, | 199 ReadAndDeinterleave(&reverse_audio_, reverse_file_channels_, |
196 reverse_config_, reverse_->channels()); | 200 reverse_config_, reverse_->channels()); |
197 ReadAndDeinterleave(&input_audio_, input_file_channels_, input_config_, | 201 ReadAndDeinterleave(&input_audio_, input_file_channels_, input_config_, |
198 input_->channels()); | 202 input_->channels()); |
199 RTC_CHECK_EQ(AudioProcessing::kNoError, apm_->set_stream_delay_ms(100)); | 203 RTC_CHECK_EQ(AudioProcessing::kNoError, apm_->set_stream_delay_ms(100)); |
200 apm_->set_stream_key_pressed(i % 10 == 9); | 204 apm_->set_stream_key_pressed(i % 10 == 9); |
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
588 config.Set<ExperimentalNs>(new ExperimentalNs(true)); | 592 config.Set<ExperimentalNs>(new ExperimentalNs(true)); |
589 DebugDumpGenerator generator(config, AudioProcessing::Config()); | 593 DebugDumpGenerator generator(config, AudioProcessing::Config()); |
590 generator.StartRecording(); | 594 generator.StartRecording(); |
591 generator.Process(100); | 595 generator.Process(100); |
592 generator.StopRecording(); | 596 generator.StopRecording(); |
593 VerifyDebugDump(generator.dump_file_name()); | 597 VerifyDebugDump(generator.dump_file_name()); |
594 } | 598 } |
595 | 599 |
596 } // namespace test | 600 } // namespace test |
597 } // namespace webrtc | 601 } // namespace webrtc |
OLD | NEW |