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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 input_multi_channel_, frame_size_samples_ * num_channels_, | 154 input_multi_channel_, frame_size_samples_ * num_channels_, |
155 encoded_multi_channel_); | 155 encoded_multi_channel_); |
156 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) { | 156 if (frame_size_samples_ * 2 * num_channels_ != multi_payload_size_bytes_) { |
157 return -1; | 157 return -1; |
158 } | 158 } |
159 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_, | 159 rtp_generator_.GetRtpHeader(kPayloadTypeMulti, frame_size_samples_, |
160 &rtp_header_); | 160 &rtp_header_); |
161 return next_send_time; | 161 return next_send_time; |
162 } | 162 } |
163 | 163 |
164 void VerifyOutput(size_t num_samples) { | 164 virtual void VerifyOutput(size_t num_samples) { |
165 for (size_t i = 0; i < num_samples; ++i) { | 165 for (size_t i = 0; i < num_samples; ++i) { |
166 for (size_t j = 0; j < num_channels_; ++j) { | 166 for (size_t j = 0; j < num_channels_; ++j) { |
167 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) << | 167 ASSERT_EQ(output_[i], output_multi_channel_[i * num_channels_ + j]) << |
168 "Diff in sample " << i << ", channel " << j << "."; | 168 "Diff in sample " << i << ", channel " << j << "."; |
169 } | 169 } |
170 } | 170 } |
171 } | 171 } |
172 | 172 |
173 virtual int GetArrivalTime(int send_time) { | 173 virtual int GetArrivalTime(int send_time) { |
174 int arrival_time = last_arrival_time_ + (send_time - last_send_time_); | 174 int arrival_time = last_arrival_time_ + (send_time - last_send_time_); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 protected: | 268 protected: |
269 NetEqStereoTestNoJitter() | 269 NetEqStereoTestNoJitter() |
270 : NetEqStereoTest() { | 270 : NetEqStereoTest() { |
271 // 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. |
272 // This is to avoid doing preemptive expand early in the test. | 272 // This is to avoid doing preemptive expand early in the test. |
273 // TODO(hlundin): Mock the decision making instead to control the modes. | 273 // TODO(hlundin): Mock the decision making instead to control the modes. |
274 last_arrival_time_ = -100; | 274 last_arrival_time_ = -100; |
275 } | 275 } |
276 }; | 276 }; |
277 | 277 |
278 #if defined(WEBRTC_ANDROID) | 278 TEST_P(NetEqStereoTestNoJitter, RunTest) { |
279 #define MAYBE_RunTest DISABLED_RunTest | |
280 #else | |
281 #define MAYBE_RunTest RunTest | |
282 #endif | |
283 TEST_P(NetEqStereoTestNoJitter, MAYBE_RunTest) { | |
284 RunTest(8); | 279 RunTest(8); |
285 } | 280 } |
286 | 281 |
287 class NetEqStereoTestPositiveDrift : public NetEqStereoTest { | 282 class NetEqStereoTestPositiveDrift : public NetEqStereoTest { |
288 protected: | 283 protected: |
289 NetEqStereoTestPositiveDrift() | 284 NetEqStereoTestPositiveDrift() |
290 : NetEqStereoTest(), | 285 : NetEqStereoTest(), |
291 drift_factor(0.9) { | 286 drift_factor(0.9) { |
292 // Start the sender 100 ms before the receiver to pre-fill the buffer. | 287 // Start the sender 100 ms before the receiver to pre-fill the buffer. |
293 // This is to avoid doing preemptive expand early in the test. | 288 // This is to avoid doing preemptive expand early in the test. |
294 // TODO(hlundin): Mock the decision making instead to control the modes. | 289 // TODO(hlundin): Mock the decision making instead to control the modes. |
295 last_arrival_time_ = -100; | 290 last_arrival_time_ = -100; |
296 } | 291 } |
297 virtual int GetArrivalTime(int send_time) { | 292 virtual int GetArrivalTime(int send_time) { |
298 int arrival_time = last_arrival_time_ + | 293 int arrival_time = last_arrival_time_ + |
299 drift_factor * (send_time - last_send_time_); | 294 drift_factor * (send_time - last_send_time_); |
300 last_send_time_ = send_time; | 295 last_send_time_ = send_time; |
301 last_arrival_time_ = arrival_time; | 296 last_arrival_time_ = arrival_time; |
302 return arrival_time; | 297 return arrival_time; |
303 } | 298 } |
304 | 299 |
305 double drift_factor; | 300 double drift_factor; |
306 }; | 301 }; |
307 | 302 |
308 TEST_P(NetEqStereoTestPositiveDrift, MAYBE_RunTest) { | 303 TEST_P(NetEqStereoTestPositiveDrift, RunTest) { |
309 RunTest(100); | 304 RunTest(100); |
310 } | 305 } |
311 | 306 |
312 class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift { | 307 class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift { |
313 protected: | 308 protected: |
314 NetEqStereoTestNegativeDrift() | 309 NetEqStereoTestNegativeDrift() |
315 : NetEqStereoTestPositiveDrift() { | 310 : NetEqStereoTestPositiveDrift() { |
316 drift_factor = 1.1; | 311 drift_factor = 1.1; |
317 last_arrival_time_ = 0; | 312 last_arrival_time_ = 0; |
318 } | 313 } |
319 }; | 314 }; |
320 | 315 |
321 TEST_P(NetEqStereoTestNegativeDrift, MAYBE_RunTest) { | 316 TEST_P(NetEqStereoTestNegativeDrift, RunTest) { |
322 RunTest(100); | 317 RunTest(100); |
323 } | 318 } |
324 | 319 |
325 class NetEqStereoTestDelays : public NetEqStereoTest { | 320 class NetEqStereoTestDelays : public NetEqStereoTest { |
326 protected: | 321 protected: |
327 static const int kDelayInterval = 10; | 322 static const int kDelayInterval = 10; |
328 static const int kDelay = 1000; | 323 static const int kDelay = 1000; |
329 NetEqStereoTestDelays() | 324 NetEqStereoTestDelays() |
330 : NetEqStereoTest(), | 325 : NetEqStereoTest(), |
331 frame_index_(0) { | 326 frame_index_(0) { |
332 } | 327 } |
333 | 328 |
334 virtual int GetArrivalTime(int send_time) { | 329 virtual int GetArrivalTime(int send_time) { |
335 // Deliver immediately, unless we have a back-log. | 330 // Deliver immediately, unless we have a back-log. |
336 int arrival_time = std::min(last_arrival_time_, send_time); | 331 int arrival_time = std::min(last_arrival_time_, send_time); |
337 if (++frame_index_ % kDelayInterval == 0) { | 332 if (++frame_index_ % kDelayInterval == 0) { |
338 // Delay this packet. | 333 // Delay this packet. |
339 arrival_time += kDelay; | 334 arrival_time += kDelay; |
340 } | 335 } |
341 last_send_time_ = send_time; | 336 last_send_time_ = send_time; |
342 last_arrival_time_ = arrival_time; | 337 last_arrival_time_ = arrival_time; |
343 return arrival_time; | 338 return arrival_time; |
344 } | 339 } |
345 | 340 |
346 int frame_index_; | 341 int frame_index_; |
347 }; | 342 }; |
348 | 343 |
349 TEST_P(NetEqStereoTestDelays, MAYBE_RunTest) { | 344 TEST_P(NetEqStereoTestDelays, RunTest) { |
350 RunTest(1000); | 345 RunTest(1000); |
351 } | 346 } |
352 | 347 |
353 class NetEqStereoTestLosses : public NetEqStereoTest { | 348 class NetEqStereoTestLosses : public NetEqStereoTest { |
354 protected: | 349 protected: |
355 static const int kLossInterval = 10; | 350 static const int kLossInterval = 10; |
356 NetEqStereoTestLosses() | 351 NetEqStereoTestLosses() |
357 : NetEqStereoTest(), | 352 : NetEqStereoTest(), |
358 frame_index_(0) { | 353 frame_index_(0) { |
359 } | 354 } |
360 | 355 |
361 virtual bool Lost() { | 356 virtual bool Lost() { |
362 return (++frame_index_) % kLossInterval == 0; | 357 return (++frame_index_) % kLossInterval == 0; |
363 } | 358 } |
364 | 359 |
| 360 // TODO(hlundin): NetEq is not giving bitexact results for these cases. |
| 361 virtual void VerifyOutput(size_t num_samples) { |
| 362 for (size_t i = 0; i < num_samples; ++i) { |
| 363 auto first_channel_sample = output_multi_channel_[i * num_channels_]; |
| 364 for (size_t j = 0; j < num_channels_; ++j) { |
| 365 const int kErrorMargin = 200; |
| 366 EXPECT_NEAR(output_[i], output_multi_channel_[i * num_channels_ + j], |
| 367 kErrorMargin) |
| 368 << "Diff in sample " << i << ", channel " << j << "."; |
| 369 EXPECT_EQ(first_channel_sample, |
| 370 output_multi_channel_[i * num_channels_ + j]); |
| 371 } |
| 372 } |
| 373 } |
| 374 |
365 int frame_index_; | 375 int frame_index_; |
366 }; | 376 }; |
367 | 377 |
368 // TODO(pbos): Enable on non-Android, this went failing while being accidentally | 378 TEST_P(NetEqStereoTestLosses, RunTest) { |
369 // disabled on all platforms and not just Android. | |
370 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5387 | |
371 TEST_P(NetEqStereoTestLosses, DISABLED_RunTest) { | |
372 RunTest(100); | 379 RunTest(100); |
373 } | 380 } |
374 | 381 |
375 | 382 |
376 // Creates a list of parameter sets. | 383 // Creates a list of parameter sets. |
377 std::list<TestParameters> GetTestParameters() { | 384 std::list<TestParameters> GetTestParameters() { |
378 std::list<TestParameters> l; | 385 std::list<TestParameters> l; |
379 const int sample_rates[] = {8000, 16000, 32000}; | 386 const int sample_rates[] = {8000, 16000, 32000}; |
380 const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]); | 387 const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]); |
381 // Loop through sample rates. | 388 // Loop through sample rates. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 | 428 |
422 INSTANTIATE_TEST_CASE_P(MultiChannel, | 429 INSTANTIATE_TEST_CASE_P(MultiChannel, |
423 NetEqStereoTestDelays, | 430 NetEqStereoTestDelays, |
424 ::testing::ValuesIn(GetTestParameters())); | 431 ::testing::ValuesIn(GetTestParameters())); |
425 | 432 |
426 INSTANTIATE_TEST_CASE_P(MultiChannel, | 433 INSTANTIATE_TEST_CASE_P(MultiChannel, |
427 NetEqStereoTestLosses, | 434 NetEqStereoTestLosses, |
428 ::testing::ValuesIn(GetTestParameters())); | 435 ::testing::ValuesIn(GetTestParameters())); |
429 | 436 |
430 } // namespace webrtc | 437 } // namespace webrtc |
OLD | NEW |