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" |
18 #include "webrtc/modules/audio_processing/test/debug_dump_replayer.h" | 19 #include "webrtc/modules/audio_processing/test/debug_dump_replayer.h" |
19 #include "webrtc/modules/audio_processing/test/test_utils.h" | 20 #include "webrtc/modules/audio_processing/test/test_utils.h" |
20 #include "webrtc/test/gtest.h" | 21 #include "webrtc/test/gtest.h" |
21 #include "webrtc/test/testsupport/fileutils.h" | 22 #include "webrtc/test/testsupport/fileutils.h" |
22 | 23 |
23 | 24 |
24 namespace webrtc { | 25 namespace webrtc { |
25 namespace test { | 26 namespace test { |
26 | 27 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 // Reverse file format. | 98 // Reverse file format. |
98 const std::string reverse_file_name_; | 99 const std::string reverse_file_name_; |
99 ResampleInputAudioFile reverse_audio_; | 100 ResampleInputAudioFile reverse_audio_; |
100 const int reverse_file_channels_; | 101 const int reverse_file_channels_; |
101 | 102 |
102 // Buffer for APM input/output. | 103 // Buffer for APM input/output. |
103 std::unique_ptr<ChannelBuffer<float>> input_; | 104 std::unique_ptr<ChannelBuffer<float>> input_; |
104 std::unique_ptr<ChannelBuffer<float>> reverse_; | 105 std::unique_ptr<ChannelBuffer<float>> reverse_; |
105 std::unique_ptr<ChannelBuffer<float>> output_; | 106 std::unique_ptr<ChannelBuffer<float>> output_; |
106 | 107 |
| 108 rtc::TaskQueue worker_queue_; |
107 std::unique_ptr<AudioProcessing> apm_; | 109 std::unique_ptr<AudioProcessing> apm_; |
108 | 110 |
109 const std::string dump_file_name_; | 111 const std::string dump_file_name_; |
110 }; | 112 }; |
111 | 113 |
112 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, | 114 DebugDumpGenerator::DebugDumpGenerator(const std::string& input_file_name, |
113 int input_rate_hz, | 115 int input_rate_hz, |
114 int input_channels, | 116 int input_channels, |
115 const std::string& reverse_file_name, | 117 const std::string& reverse_file_name, |
116 int reverse_rate_hz, | 118 int reverse_rate_hz, |
117 int reverse_channels, | 119 int reverse_channels, |
118 const Config& config, | 120 const Config& config, |
119 const std::string& dump_file_name) | 121 const std::string& dump_file_name) |
120 : input_config_(input_rate_hz, input_channels), | 122 : input_config_(input_rate_hz, input_channels), |
121 reverse_config_(reverse_rate_hz, reverse_channels), | 123 reverse_config_(reverse_rate_hz, reverse_channels), |
122 output_config_(input_rate_hz, input_channels), | 124 output_config_(input_rate_hz, input_channels), |
123 input_audio_(input_file_name, input_rate_hz, input_rate_hz), | 125 input_audio_(input_file_name, input_rate_hz, input_rate_hz), |
124 input_file_channels_(input_channels), | 126 input_file_channels_(input_channels), |
125 reverse_audio_(reverse_file_name, reverse_rate_hz, reverse_rate_hz), | 127 reverse_audio_(reverse_file_name, reverse_rate_hz, reverse_rate_hz), |
126 reverse_file_channels_(reverse_channels), | 128 reverse_file_channels_(reverse_channels), |
127 input_(new ChannelBuffer<float>(input_config_.num_frames(), | 129 input_(new ChannelBuffer<float>(input_config_.num_frames(), |
128 input_config_.num_channels())), | 130 input_config_.num_channels())), |
129 reverse_(new ChannelBuffer<float>(reverse_config_.num_frames(), | 131 reverse_(new ChannelBuffer<float>(reverse_config_.num_frames(), |
130 reverse_config_.num_channels())), | 132 reverse_config_.num_channels())), |
131 output_(new ChannelBuffer<float>(output_config_.num_frames(), | 133 output_(new ChannelBuffer<float>(output_config_.num_frames(), |
132 output_config_.num_channels())), | 134 output_config_.num_channels())), |
| 135 worker_queue_("debug_dump_generator_worker_queue"), |
133 apm_(AudioProcessing::Create(config)), | 136 apm_(AudioProcessing::Create(config)), |
134 dump_file_name_(dump_file_name) { | 137 dump_file_name_(dump_file_name) {} |
135 } | |
136 | 138 |
137 DebugDumpGenerator::DebugDumpGenerator( | 139 DebugDumpGenerator::DebugDumpGenerator( |
138 const Config& config, | 140 const Config& config, |
139 const AudioProcessing::Config& apm_config) | 141 const AudioProcessing::Config& apm_config) |
140 : DebugDumpGenerator(ResourcePath("near32_stereo", "pcm"), | 142 : DebugDumpGenerator(ResourcePath("near32_stereo", "pcm"), |
141 32000, | 143 32000, |
142 2, | 144 2, |
143 ResourcePath("far32_stereo", "pcm"), | 145 ResourcePath("far32_stereo", "pcm"), |
144 32000, | 146 32000, |
145 2, | 147 2, |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 output_config_.set_sample_rate_hz(rate_hz); | 182 output_config_.set_sample_rate_hz(rate_hz); |
181 MaybeResetBuffer(&output_, output_config_); | 183 MaybeResetBuffer(&output_, output_config_); |
182 } | 184 } |
183 | 185 |
184 void DebugDumpGenerator::SetOutputChannels(int channels) { | 186 void DebugDumpGenerator::SetOutputChannels(int channels) { |
185 output_config_.set_num_channels(channels); | 187 output_config_.set_num_channels(channels); |
186 MaybeResetBuffer(&output_, output_config_); | 188 MaybeResetBuffer(&output_, output_config_); |
187 } | 189 } |
188 | 190 |
189 void DebugDumpGenerator::StartRecording() { | 191 void DebugDumpGenerator::StartRecording() { |
190 apm_->StartDebugRecording(dump_file_name_.c_str(), -1); | 192 apm_->StartDebugRecording(dump_file_name_.c_str(), -1, &worker_queue_); |
191 } | 193 } |
192 | 194 |
193 void DebugDumpGenerator::Process(size_t num_blocks) { | 195 void DebugDumpGenerator::Process(size_t num_blocks) { |
194 for (size_t i = 0; i < num_blocks; ++i) { | 196 for (size_t i = 0; i < num_blocks; ++i) { |
195 ReadAndDeinterleave(&reverse_audio_, reverse_file_channels_, | 197 ReadAndDeinterleave(&reverse_audio_, reverse_file_channels_, |
196 reverse_config_, reverse_->channels()); | 198 reverse_config_, reverse_->channels()); |
197 ReadAndDeinterleave(&input_audio_, input_file_channels_, input_config_, | 199 ReadAndDeinterleave(&input_audio_, input_file_channels_, input_config_, |
198 input_->channels()); | 200 input_->channels()); |
199 RTC_CHECK_EQ(AudioProcessing::kNoError, apm_->set_stream_delay_ms(100)); | 201 RTC_CHECK_EQ(AudioProcessing::kNoError, apm_->set_stream_delay_ms(100)); |
200 apm_->set_stream_key_pressed(i % 10 == 9); | 202 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)); | 590 config.Set<ExperimentalNs>(new ExperimentalNs(true)); |
589 DebugDumpGenerator generator(config, AudioProcessing::Config()); | 591 DebugDumpGenerator generator(config, AudioProcessing::Config()); |
590 generator.StartRecording(); | 592 generator.StartRecording(); |
591 generator.Process(100); | 593 generator.Process(100); |
592 generator.StopRecording(); | 594 generator.StopRecording(); |
593 VerifyDebugDump(generator.dump_file_name()); | 595 VerifyDebugDump(generator.dump_file_name()); |
594 } | 596 } |
595 | 597 |
596 } // namespace test | 598 } // namespace test |
597 } // namespace webrtc | 599 } // namespace webrtc |
OLD | NEW |