| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) { | 158 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) { |
| 159 return -1; | 159 return -1; |
| 160 } | 160 } |
| 161 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_, | 161 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_, |
| 162 &rtp_header_); | 162 &rtp_header_); |
| 163 return next_send_time; | 163 return next_send_time; |
| 164 } | 164 } |
| 165 | 165 |
| 166 void VerifyOutput(size_t num_samples) { | 166 void VerifyOutput(size_t num_samples) { |
| 167 for (size_t i = 0; i < num_samples; ++i) { | 167 for (size_t i = 0; i < num_samples; ++i) { |
| 168 for (int j = 0; j < num_channels_; ++j) { | 168 for (size_t j = 0; j < num_channels_; ++j) { |
| 169 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) << | 169 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) << |
| 170 "Diff in sample " << i << ", channel " << j << "."; | 170 "Diff in sample " << i << ", channel " << j << "."; |
| 171 } | 171 } |
| 172 } | 172 } |
| 173 } | 173 } |
| 174 | 174 |
| 175 virtual int GetArrivalTime(int send_time) { | 175 virtual int GetArrivalTime(int send_time) { |
| 176 int arrival_time = last_arrival_time_ + (send_time - last_send_time_); | 176 int arrival_time = last_arrival_time_ + (send_time - last_send_time_); |
| 177 last_send_time_ = send_time; | 177 last_send_time_ = send_time; |
| 178 last_arrival_time_ = arrival_time; | 178 last_arrival_time_ = arrival_time; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 207 // Get next input packets (mono and multi-channel). | 207 // Get next input packets (mono and multi-channel). |
| 208 do { | 208 do { |
| 209 next_send_time = GetNewPackets(); | 209 next_send_time = GetNewPackets(); |
| 210 ASSERT_NE(-1, next_send_time); | 210 ASSERT_NE(-1, next_send_time); |
| 211 next_arrival_time = GetArrivalTime(next_send_time); | 211 next_arrival_time = GetArrivalTime(next_send_time); |
| 212 } while (Lost()); // If lost, immediately read the next packet. | 212 } while (Lost()); // If lost, immediately read the next packet. |
| 213 } | 213 } |
| 214 NetEqOutputType output_type; | 214 NetEqOutputType output_type; |
| 215 // Get audio from mono instance. | 215 // Get audio from mono instance. |
| 216 size_t samples_per_channel; | 216 size_t samples_per_channel; |
| 217 int num_channels; | 217 size_t num_channels; |
| 218 EXPECT_EQ(NetEq::kOK, | 218 EXPECT_EQ(NetEq::kOK, |
| 219 neteq_mono_->GetAudio(kMaxBlockSize, output_, | 219 neteq_mono_->GetAudio(kMaxBlockSize, output_, |
| 220 &samples_per_channel, &num_channels, | 220 &samples_per_channel, &num_channels, |
| 221 &output_type)); | 221 &output_type)); |
| 222 EXPECT_EQ(1, num_channels); | 222 EXPECT_EQ(1u, num_channels); |
| 223 EXPECT_EQ(output_size_samples_, samples_per_channel); | 223 EXPECT_EQ(output_size_samples_, samples_per_channel); |
| 224 // Get audio from multi-channel instance. | 224 // Get audio from multi-channel instance. |
| 225 ASSERT_EQ(NetEq::kOK, | 225 ASSERT_EQ(NetEq::kOK, |
| 226 neteq_->GetAudio(kMaxBlockSize * num_channels_, | 226 neteq_->GetAudio(kMaxBlockSize * num_channels_, |
| 227 output_multi_channel_, | 227 output_multi_channel_, |
| 228 &samples_per_channel, &num_channels, | 228 &samples_per_channel, &num_channels, |
| 229 &output_type)); | 229 &output_type)); |
| 230 EXPECT_EQ(num_channels_, num_channels); | 230 EXPECT_EQ(num_channels_, num_channels); |
| 231 EXPECT_EQ(output_size_samples_, samples_per_channel); | 231 EXPECT_EQ(output_size_samples_, samples_per_channel); |
| 232 std::ostringstream ss; | 232 std::ostringstream ss; |
| 233 ss << "Lap number " << k << "."; | 233 ss << "Lap number " << k << "."; |
| 234 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 234 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
| 235 // Compare mono and multi-channel. | 235 // Compare mono and multi-channel. |
| 236 ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_)); | 236 ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_)); |
| 237 | 237 |
| 238 time_now += kTimeStepMs; | 238 time_now += kTimeStepMs; |
| 239 } | 239 } |
| 240 } | 240 } |
| 241 | 241 |
| 242 const int num_channels_; | 242 const size_t num_channels_; |
| 243 const int sample_rate_hz_; | 243 const int sample_rate_hz_; |
| 244 const int samples_per_ms_; | 244 const int samples_per_ms_; |
| 245 const int frame_size_ms_; | 245 const int frame_size_ms_; |
| 246 const size_t frame_size_samples_; | 246 const size_t frame_size_samples_; |
| 247 const size_t output_size_samples_; | 247 const size_t output_size_samples_; |
| 248 NetEq* neteq_mono_; | 248 NetEq* neteq_mono_; |
| 249 NetEq* neteq_; | 249 NetEq* neteq_; |
| 250 test::RtpGenerator rtp_generator_mono_; | 250 test::RtpGenerator rtp_generator_mono_; |
| 251 test::RtpGenerator rtp_generator_; | 251 test::RtpGenerator rtp_generator_; |
| 252 int16_t* input_; | 252 int16_t* input_; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 413 |
| 414 INSTANTIATE_TEST_CASE_P(MultiChannel, | 414 INSTANTIATE_TEST_CASE_P(MultiChannel, |
| 415 NetEqStereoTestDelays, | 415 NetEqStereoTestDelays, |
| 416 ::testing::ValuesIn(GetTestParameters())); | 416 ::testing::ValuesIn(GetTestParameters())); |
| 417 | 417 |
| 418 INSTANTIATE_TEST_CASE_P(MultiChannel, | 418 INSTANTIATE_TEST_CASE_P(MultiChannel, |
| 419 NetEqStereoTestLosses, | 419 NetEqStereoTestLosses, |
| 420 ::testing::ValuesIn(GetTestParameters())); | 420 ::testing::ValuesIn(GetTestParameters())); |
| 421 | 421 |
| 422 } // namespace webrtc | 422 } // namespace webrtc |
| OLD | NEW |