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 25 matching lines...) Expand all Loading... |
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 |
42 // mono output. | 42 // mono output. |
43 class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> { | 43 class NetEqStereoTest : public ::testing::TestWithParam<TestParameters> { |
44 protected: | 44 protected: |
45 static const int kTimeStepMs = 10; | 45 static const int kTimeStepMs = 10; |
46 static const int kMaxBlockSize = 480; // 10 ms @ 48 kHz. | 46 static const size_t kMaxBlockSize = 480; // 10 ms @ 48 kHz. |
47 static const uint8_t kPayloadTypeMono = 95; | 47 static const uint8_t kPayloadTypeMono = 95; |
48 static const uint8_t kPayloadTypeMulti = 96; | 48 static const uint8_t kPayloadTypeMulti = 96; |
49 | 49 |
50 NetEqStereoTest() | 50 NetEqStereoTest() |
51 : num_channels_(GetParam().num_channels), | 51 : num_channels_(GetParam().num_channels), |
52 sample_rate_hz_(GetParam().sample_rate), | 52 sample_rate_hz_(GetParam().sample_rate), |
53 samples_per_ms_(sample_rate_hz_ / 1000), | 53 samples_per_ms_(sample_rate_hz_ / 1000), |
54 frame_size_ms_(GetParam().frame_size), | 54 frame_size_ms_(GetParam().frame_size), |
55 frame_size_samples_(frame_size_ms_ * samples_per_ms_), | 55 frame_size_samples_( |
| 56 static_cast<size_t>(frame_size_ms_ * samples_per_ms_)), |
56 output_size_samples_(10 * samples_per_ms_), | 57 output_size_samples_(10 * samples_per_ms_), |
57 rtp_generator_mono_(samples_per_ms_), | 58 rtp_generator_mono_(samples_per_ms_), |
58 rtp_generator_(samples_per_ms_), | 59 rtp_generator_(samples_per_ms_), |
59 payload_size_bytes_(0), | 60 payload_size_bytes_(0), |
60 multi_payload_size_bytes_(0), | 61 multi_payload_size_bytes_(0), |
61 last_send_time_(0), | 62 last_send_time_(0), |
62 last_arrival_time_(0) { | 63 last_arrival_time_(0) { |
63 NetEq::Config config; | 64 NetEq::Config config; |
64 config.sample_rate_hz = sample_rate_hz_; | 65 config.sample_rate_hz = sample_rate_hz_; |
65 neteq_mono_ = NetEq::Create(config); | 66 neteq_mono_ = NetEq::Create(config); |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 next_arrival_time)); | 206 next_arrival_time)); |
206 // Get next input packets (mono and multi-channel). | 207 // Get next input packets (mono and multi-channel). |
207 do { | 208 do { |
208 next_send_time = GetNewPackets(); | 209 next_send_time = GetNewPackets(); |
209 ASSERT_NE(-1, next_send_time); | 210 ASSERT_NE(-1, next_send_time); |
210 next_arrival_time = GetArrivalTime(next_send_time); | 211 next_arrival_time = GetArrivalTime(next_send_time); |
211 } while (Lost()); // If lost, immediately read the next packet. | 212 } while (Lost()); // If lost, immediately read the next packet. |
212 } | 213 } |
213 NetEqOutputType output_type; | 214 NetEqOutputType output_type; |
214 // Get audio from mono instance. | 215 // Get audio from mono instance. |
215 int samples_per_channel; | 216 size_t samples_per_channel; |
216 int num_channels; | 217 int num_channels; |
217 EXPECT_EQ(NetEq::kOK, | 218 EXPECT_EQ(NetEq::kOK, |
218 neteq_mono_->GetAudio(kMaxBlockSize, output_, | 219 neteq_mono_->GetAudio(kMaxBlockSize, output_, |
219 &samples_per_channel, &num_channels, | 220 &samples_per_channel, &num_channels, |
220 &output_type)); | 221 &output_type)); |
221 EXPECT_EQ(1, num_channels); | 222 EXPECT_EQ(1, num_channels); |
222 EXPECT_EQ(output_size_samples_, samples_per_channel); | 223 EXPECT_EQ(output_size_samples_, samples_per_channel); |
223 // Get audio from multi-channel instance. | 224 // Get audio from multi-channel instance. |
224 ASSERT_EQ(NetEq::kOK, | 225 ASSERT_EQ(NetEq::kOK, |
225 neteq_->GetAudio(kMaxBlockSize * num_channels_, | 226 neteq_->GetAudio(kMaxBlockSize * num_channels_, |
226 output_multi_channel_, | 227 output_multi_channel_, |
227 &samples_per_channel, &num_channels, | 228 &samples_per_channel, &num_channels, |
228 &output_type)); | 229 &output_type)); |
229 EXPECT_EQ(num_channels_, num_channels); | 230 EXPECT_EQ(num_channels_, num_channels); |
230 EXPECT_EQ(output_size_samples_, samples_per_channel); | 231 EXPECT_EQ(output_size_samples_, samples_per_channel); |
231 std::ostringstream ss; | 232 std::ostringstream ss; |
232 ss << "Lap number " << k << "."; | 233 ss << "Lap number " << k << "."; |
233 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. | 234 SCOPED_TRACE(ss.str()); // Print out the parameter values on failure. |
234 // Compare mono and multi-channel. | 235 // Compare mono and multi-channel. |
235 ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_)); | 236 ASSERT_NO_FATAL_FAILURE(VerifyOutput(output_size_samples_)); |
236 | 237 |
237 time_now += kTimeStepMs; | 238 time_now += kTimeStepMs; |
238 } | 239 } |
239 } | 240 } |
240 | 241 |
241 const int num_channels_; | 242 const int num_channels_; |
242 const int sample_rate_hz_; | 243 const int sample_rate_hz_; |
243 const int samples_per_ms_; | 244 const int samples_per_ms_; |
244 const int frame_size_ms_; | 245 const int frame_size_ms_; |
245 const int frame_size_samples_; | 246 const size_t frame_size_samples_; |
246 const int output_size_samples_; | 247 const size_t output_size_samples_; |
247 NetEq* neteq_mono_; | 248 NetEq* neteq_mono_; |
248 NetEq* neteq_; | 249 NetEq* neteq_; |
249 test::RtpGenerator rtp_generator_mono_; | 250 test::RtpGenerator rtp_generator_mono_; |
250 test::RtpGenerator rtp_generator_; | 251 test::RtpGenerator rtp_generator_; |
251 int16_t* input_; | 252 int16_t* input_; |
252 int16_t* input_multi_channel_; | 253 int16_t* input_multi_channel_; |
253 uint8_t* encoded_; | 254 uint8_t* encoded_; |
254 uint8_t* encoded_multi_channel_; | 255 uint8_t* encoded_multi_channel_; |
255 int16_t output_[kMaxBlockSize]; | 256 int16_t output_[kMaxBlockSize]; |
256 int16_t* output_multi_channel_; | 257 int16_t* output_multi_channel_; |
257 WebRtcRTPHeader rtp_header_mono_; | 258 WebRtcRTPHeader rtp_header_mono_; |
258 WebRtcRTPHeader rtp_header_; | 259 WebRtcRTPHeader rtp_header_; |
259 int payload_size_bytes_; | 260 size_t payload_size_bytes_; |
260 int multi_payload_size_bytes_; | 261 size_t multi_payload_size_bytes_; |
261 int last_send_time_; | 262 int last_send_time_; |
262 int last_arrival_time_; | 263 int last_arrival_time_; |
263 rtc::scoped_ptr<test::InputAudioFile> input_file_; | 264 rtc::scoped_ptr<test::InputAudioFile> input_file_; |
264 }; | 265 }; |
265 | 266 |
266 class NetEqStereoTestNoJitter : public NetEqStereoTest { | 267 class NetEqStereoTestNoJitter : public NetEqStereoTest { |
267 protected: | 268 protected: |
268 NetEqStereoTestNoJitter() | 269 NetEqStereoTestNoJitter() |
269 : NetEqStereoTest() { | 270 : NetEqStereoTest() { |
270 // Start the sender 100 ms before the receiver to pre-fill the buffer. | 271 // Start the sender 100 ms before the receiver to pre-fill the buffer. |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
412 | 413 |
413 INSTANTIATE_TEST_CASE_P(MultiChannel, | 414 INSTANTIATE_TEST_CASE_P(MultiChannel, |
414 NetEqStereoTestDelays, | 415 NetEqStereoTestDelays, |
415 ::testing::ValuesIn(GetTestParameters())); | 416 ::testing::ValuesIn(GetTestParameters())); |
416 | 417 |
417 INSTANTIATE_TEST_CASE_P(MultiChannel, | 418 INSTANTIATE_TEST_CASE_P(MultiChannel, |
418 NetEqStereoTestLosses, | 419 NetEqStereoTestLosses, |
419 ::testing::ValuesIn(GetTestParameters())); | 420 ::testing::ValuesIn(GetTestParameters())); |
420 | 421 |
421 } // namespace webrtc | 422 } // namespace webrtc |
OLD | NEW |