OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2013 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 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" | 21 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" |
22 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" | 22 #include "webrtc/modules/audio_coding/neteq/tools/rtp_generator.h" |
23 #include "webrtc/test/testsupport/fileutils.h" | 23 #include "webrtc/test/testsupport/fileutils.h" |
24 #include "webrtc/test/testsupport/gtest_disable.h" | 24 #include "webrtc/test/testsupport/gtest_disable.h" |
25 | 25 |
26 namespace webrtc { | 26 namespace webrtc { |
27 | 27 |
28 struct TestParameters { | 28 struct TestParameters { |
29 int frame_size; | 29 int frame_size; |
30 int sample_rate; | 30 int sample_rate; |
31 int num_channels; | 31 size_t num_channels; |
32 }; | 32 }; |
33 | 33 |
34 // This is a parameterized test. The test parameters are supplied through a | 34 // This is a parameterized test. The test parameters are supplied through a |
35 // TestParameters struct, which is obtained through the GetParam() method. | 35 // TestParameters struct, which is obtained through the GetParam() method. |
36 // | 36 // |
37 // The objective of the test is to create a mono input signal and a | 37 // The objective of the test is to create a mono input signal and a |
38 // multi-channel input signal, where each channel is identical to the mono | 38 // multi-channel input signal, where each channel is identical to the mono |
39 // input channel. The two input signals are processed through their respective | 39 // input channel. The two input signals are processed through their respective |
40 // NetEq instances. After that, the output signals are compared. The expected | 40 // NetEq instances. After that, the output signals are compared. The expected |
41 // result is that each channel in the multi-channel output is identical to the | 41 // result is that each channel in the multi-channel output is identical to the |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) { | 157 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) { |
158 return -1; | 158 return -1; |
159 } | 159 } |
160 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_, | 160 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_, |
161 &rtp_header_); | 161 &rtp_header_); |
162 return next_send_time; | 162 return next_send_time; |
163 } | 163 } |
164 | 164 |
165 void VerifyOutput(size_t num_samples) { | 165 void VerifyOutput(size_t num_samples) { |
166 for (size_t i = 0; i < num_samples; ++i) { | 166 for (size_t i = 0; i < num_samples; ++i) { |
167 for (int j = 0; j < num_channels_; ++j) { | 167 for (size_t j = 0; j < num_channels_; ++j) { |
168 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) << | 168 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) << |
169 "Diff in sample " << i << ", channel " << j << "."; | 169 "Diff in sample " << i << ", channel " << j << "."; |
170 } | 170 } |
171 } | 171 } |
172 } | 172 } |
173 | 173 |
174 virtual int GetArrivalTime(int send_time) { | 174 virtual int GetArrivalTime(int send_time) { |
175 int arrival_time = last_arrival_time_ + (send_time - last_send_time_); | 175 int arrival_time = last_arrival_time_ + (send_time - last_send_time_); |
176 last_send_time_ = send_time; | 176 last_send_time_ = send_time; |
177 last_arrival_time_ = arrival_time; | 177 last_arrival_time_ = arrival_time; |
(...skipping 30 matching lines...) Expand all Loading... |
208 // Get next input packets (mono and multi-channel). | 208 // Get next input packets (mono and multi-channel). |
209 do { | 209 do { |
210 next_send_time = GetNewPackets(); | 210 next_send_time = GetNewPackets(); |
211 ASSERT_NE(-1, next_send_time); | 211 ASSERT_NE(-1, next_send_time); |
212 next_arrival_time = GetArrivalTime(next_send_time); | 212 next_arrival_time = GetArrivalTime(next_send_time); |
213 } while (Lost()); // If lost, immediately read the next packet. | 213 } while (Lost()); // If lost, immediately read the next packet. |
214 } | 214 } |
215 NetEqOutputType output_type; | 215 NetEqOutputType output_type; |
216 // Get audio from mono instance. | 216 // Get audio from mono instance. |
217 size_t samples_per_channel; | 217 size_t samples_per_channel; |
218 int num_channels; | 218 size_t num_channels; |
219 EXPECT_EQ(NetEq::kOK, | 219 EXPECT_EQ(NetEq::kOK, |
220 neteq_mono_->GetAudio(kMaxBlockSize, output_, | 220 neteq_mono_->GetAudio(kMaxBlockSize, output_, |
221 &samples_per_channel, &num_channels, | 221 &samples_per_channel, &num_channels, |
222 &output_type)); | 222 &output_type)); |
223 EXPECT_EQ(1, num_channels); | 223 EXPECT_EQ(1u, num_channels); |
224 EXPECT_EQ(output_size_samples_, samples_per_channel); | 224 EXPECT_EQ(output_size_samples_, samples_per_channel); |
225 // Get audio from multi-channel instance. | 225 // Get audio from multi-channel instance. |
226 ASSERT_EQ(NetEq::kOK, | 226 ASSERT_EQ(NetEq::kOK, |
227 neteq_->GetAudio(kMaxBlockSize * num_channels_, | 227 neteq_->GetAudio(kMaxBlockSize * num_channels_, |
228 output_multi_channel_, | 228 output_multi_channel_, |
229 &samples_per_channel, &num_channels, | 229 &samples_per_channel, &num_channels, |
230 &output_type)); | 230 &output_type)); |
231 EXPECT_EQ(num_channels_, num_channels); | 231 EXPECT_EQ(num_channels_, num_channels); |
232 EXPECT_EQ(output_size_samples_, samples_per_channel); | 232 EXPECT_EQ(output_size_samples_, samples_per_channel); |
233 std::ostringstream ss; | 233 std::ostringstream ss; |
234 ss << "Lap number " << k << "."; | 234 ss << "Lap number " << k << "."; |
235 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 235 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
236 // Compare mono and multi-channel. | 236 // Compare mono and multi-channel. |
237 ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_)); | 237 ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_)); |
238 | 238 |
239 time_now += kTimeStepMs; | 239 time_now += kTimeStepMs; |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 const int num_channels_; | 243 const size_t num_channels_; |
244 const int sample_rate_hz_; | 244 const int sample_rate_hz_; |
245 const int samples_per_ms_; | 245 const int samples_per_ms_; |
246 const int frame_size_ms_; | 246 const int frame_size_ms_; |
247 const size_t frame_size_samples_; | 247 const size_t frame_size_samples_; |
248 const size_t output_size_samples_; | 248 const size_t output_size_samples_; |
249 NetEq* neteq_mono_; | 249 NetEq* neteq_mono_; |
250 NetEq* neteq_; | 250 NetEq* neteq_; |
251 test::RtpGenerator rtp_generator_mono_; | 251 test::RtpGenerator rtp_generator_mono_; |
252 test::RtpGenerator rtp_generator_; | 252 test::RtpGenerator rtp_generator_; |
253 int16_t* input_; | 253 int16_t* input_; |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 414 |
415 INSTANTIATE_TEST_CASE_P(MultiChannel, | 415 INSTANTIATE_TEST_CASE_P(MultiChannel, |
416 NetEqStereoTestDelays, | 416 NetEqStereoTestDelays, |
417 ::testing::ValuesIn(GetTestParameters())); | 417 ::testing::ValuesIn(GetTestParameters())); |
418 | 418 |
419 INSTANTIATE_TEST_CASE_P(MultiChannel, | 419 INSTANTIATE_TEST_CASE_P(MultiChannel, |
420 NetEqStereoTestLosses, | 420 NetEqStereoTestLosses, |
421 ::testing::ValuesIn(GetTestParameters())); | 421 ::testing::ValuesIn(GetTestParameters())); |
422 | 422 |
423 } // namespace webrtc | 423 } // namespace webrtc |
OLD | NEW |