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 |
11 // Test to verify correct stereo and multi-channel operation. | 11 // Test to verify correct stereo and multi-channel operation. |
12 | 12 |
13 #include <algorithm> | 13 #include <algorithm> |
14 #include <string> | 14 #include <string> |
15 #include <list> | 15 #include <list> |
16 | 16 |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "webrtc/base/scoped_ptr.h" | 18 #include "webrtc/base/scoped_ptr.h" |
19 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" | 19 #include "webrtc/modules/audio_coding/codecs/pcm16b/pcm16b.h" |
20 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" | 20 #include "webrtc/modules/audio_coding/neteq/include/neteq.h" |
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" | |
25 | 24 |
26 namespace webrtc { | 25 namespace webrtc { |
27 | 26 |
28 struct TestParameters { | 27 struct TestParameters { |
29 int frame_size; | 28 int frame_size; |
30 int sample_rate; | 29 int sample_rate; |
31 int num_channels; | 30 int num_channels; |
32 }; | 31 }; |
33 | 32 |
34 // This is a parameterized test. The test parameters are supplied through a | 33 // This is a parameterized test. The test parameters are supplied through a |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 protected: | 268 protected: |
270 NetEqStereoTestNoJitter() | 269 NetEqStereoTestNoJitter() |
271 : NetEqStereoTest() { | 270 : NetEqStereoTest() { |
272 // 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. |
273 // This is to avoid doing preemptive expand early in the test. | 272 // This is to avoid doing preemptive expand early in the test. |
274 // TODO(hlundin): Mock the decision making instead to control the modes. | 273 // TODO(hlundin): Mock the decision making instead to control the modes. |
275 last_arrival_time_ = -100; | 274 last_arrival_time_ = -100; |
276 } | 275 } |
277 }; | 276 }; |
278 | 277 |
279 TEST_P(NetEqStereoTestNoJitter, DISABLED_ON_ANDROID(RunTest)) { | 278 #if defined(WEBRTC_ANDROID) |
| 279 TEST_P(NetEqStereoTestNoJitter, DISABLED_RunTest) { |
| 280 #else |
| 281 TEST_P(NetEqStereoTestNoJitter, RunTest) { |
| 282 #endif |
280 RunTest(8); | 283 RunTest(8); |
281 } | 284 } |
282 | 285 |
283 class NetEqStereoTestPositiveDrift : public NetEqStereoTest { | 286 class NetEqStereoTestPositiveDrift : public NetEqStereoTest { |
284 protected: | 287 protected: |
285 NetEqStereoTestPositiveDrift() | 288 NetEqStereoTestPositiveDrift() |
286 : NetEqStereoTest(), | 289 : NetEqStereoTest(), |
287 drift_factor(0.9) { | 290 drift_factor(0.9) { |
288 // Start the sender 100 ms before the receiver to pre-fill the buffer. | 291 // Start the sender 100 ms before the receiver to pre-fill the buffer. |
289 // This is to avoid doing preemptive expand early in the test. | 292 // This is to avoid doing preemptive expand early in the test. |
290 // TODO(hlundin): Mock the decision making instead to control the modes. | 293 // TODO(hlundin): Mock the decision making instead to control the modes. |
291 last_arrival_time_ = -100; | 294 last_arrival_time_ = -100; |
292 } | 295 } |
293 virtual int GetArrivalTime(int send_time) { | 296 virtual int GetArrivalTime(int send_time) { |
294 int arrival_time = last_arrival_time_ + | 297 int arrival_time = last_arrival_time_ + |
295 drift_factor * (send_time - last_send_time_); | 298 drift_factor * (send_time - last_send_time_); |
296 last_send_time_ = send_time; | 299 last_send_time_ = send_time; |
297 last_arrival_time_ = arrival_time; | 300 last_arrival_time_ = arrival_time; |
298 return arrival_time; | 301 return arrival_time; |
299 } | 302 } |
300 | 303 |
301 double drift_factor; | 304 double drift_factor; |
302 }; | 305 }; |
303 | 306 |
304 TEST_P(NetEqStereoTestPositiveDrift, DISABLED_ON_ANDROID(RunTest)) { | 307 #if defined(WEBRTC_ANDROID) |
| 308 TEST_P(NetEqStereoTestPositiveDrift, DISABLED_RunTest) { |
| 309 #else |
| 310 TEST_P(NetEqStereoTestPositiveDrift, RunTest) { |
| 311 #endif |
305 RunTest(100); | 312 RunTest(100); |
306 } | 313 } |
307 | 314 |
308 class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift { | 315 class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift { |
309 protected: | 316 protected: |
310 NetEqStereoTestNegativeDrift() | 317 NetEqStereoTestNegativeDrift() |
311 : NetEqStereoTestPositiveDrift() { | 318 : NetEqStereoTestPositiveDrift() { |
312 drift_factor = 1.1; | 319 drift_factor = 1.1; |
313 last_arrival_time_ = 0; | 320 last_arrival_time_ = 0; |
314 } | 321 } |
315 }; | 322 }; |
316 | 323 |
317 TEST_P(NetEqStereoTestNegativeDrift, DISABLED_ON_ANDROID(RunTest)) { | 324 #if defined(WEBRTC_ANDROID) |
| 325 TEST_P(NetEqStereoTestNegativeDrift, DISABLED_RunTest) { |
| 326 #else |
| 327 TEST_P(NetEqStereoTestNegativeDrift, RunTest) { |
| 328 #endif |
318 RunTest(100); | 329 RunTest(100); |
319 } | 330 } |
320 | 331 |
321 class NetEqStereoTestDelays : public NetEqStereoTest { | 332 class NetEqStereoTestDelays : public NetEqStereoTest { |
322 protected: | 333 protected: |
323 static const int kDelayInterval = 10; | 334 static const int kDelayInterval = 10; |
324 static const int kDelay = 1000; | 335 static const int kDelay = 1000; |
325 NetEqStereoTestDelays() | 336 NetEqStereoTestDelays() |
326 : NetEqStereoTest(), | 337 : NetEqStereoTest(), |
327 frame_index_(0) { | 338 frame_index_(0) { |
328 } | 339 } |
329 | 340 |
330 virtual int GetArrivalTime(int send_time) { | 341 virtual int GetArrivalTime(int send_time) { |
331 // Deliver immediately, unless we have a back-log. | 342 // Deliver immediately, unless we have a back-log. |
332 int arrival_time = std::min(last_arrival_time_, send_time); | 343 int arrival_time = std::min(last_arrival_time_, send_time); |
333 if (++frame_index_ % kDelayInterval == 0) { | 344 if (++frame_index_ % kDelayInterval == 0) { |
334 // Delay this packet. | 345 // Delay this packet. |
335 arrival_time += kDelay; | 346 arrival_time += kDelay; |
336 } | 347 } |
337 last_send_time_ = send_time; | 348 last_send_time_ = send_time; |
338 last_arrival_time_ = arrival_time; | 349 last_arrival_time_ = arrival_time; |
339 return arrival_time; | 350 return arrival_time; |
340 } | 351 } |
341 | 352 |
342 int frame_index_; | 353 int frame_index_; |
343 }; | 354 }; |
344 | 355 |
345 TEST_P(NetEqStereoTestDelays, DISABLED_ON_ANDROID(RunTest)) { | 356 #if defined(WEBRTC_ANDROID) |
| 357 TEST_P(NetEqStereoTestDelays, DISABLED_RunTest) { |
| 358 #else |
| 359 TEST_P(NetEqStereoTestDelays, RunTest) { |
| 360 #endif |
346 RunTest(1000); | 361 RunTest(1000); |
347 } | 362 } |
348 | 363 |
349 class NetEqStereoTestLosses : public NetEqStereoTest { | 364 class NetEqStereoTestLosses : public NetEqStereoTest { |
350 protected: | 365 protected: |
351 static const int kLossInterval = 10; | 366 static const int kLossInterval = 10; |
352 NetEqStereoTestLosses() | 367 NetEqStereoTestLosses() |
353 : NetEqStereoTest(), | 368 : NetEqStereoTest(), |
354 frame_index_(0) { | 369 frame_index_(0) { |
355 } | 370 } |
356 | 371 |
357 virtual bool Lost() { | 372 virtual bool Lost() { |
358 return (++frame_index_) % kLossInterval == 0; | 373 return (++frame_index_) % kLossInterval == 0; |
359 } | 374 } |
360 | 375 |
361 int frame_index_; | 376 int frame_index_; |
362 }; | 377 }; |
363 | 378 |
364 TEST_P(NetEqStereoTestLosses, DISABLED_ON_ANDROID(RunTest)) { | 379 #if defined(WEBRTC_ANDROID) |
| 380 TEST_P(NetEqStereoTestLosses, DISABLED_RunTest) { |
| 381 #else |
| 382 // TODO(pbos): Enable on non-Android, this went failing while being accidentally |
| 383 // disabled on all platforms and not just Android. |
| 384 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5387 |
| 385 TEST_P(NetEqStereoTestLosses, DISABLED_RunTest) { |
| 386 #endif |
365 RunTest(100); | 387 RunTest(100); |
366 } | 388 } |
367 | 389 |
368 | 390 |
369 // Creates a list of parameter sets. | 391 // Creates a list of parameter sets. |
370 std::list<TestParameters> GetTestParameters() { | 392 std::list<TestParameters> GetTestParameters() { |
371 std::list<TestParameters> l; | 393 std::list<TestParameters> l; |
372 const int sample_rates[] = {8000, 16000, 32000}; | 394 const int sample_rates[] = {8000, 16000, 32000}; |
373 const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]); | 395 const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]); |
374 // Loop through sample rates. | 396 // Loop through sample rates. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 | 436 |
415 INSTANTIATE_TEST_CASE_P(MultiChannel, | 437 INSTANTIATE_TEST_CASE_P(MultiChannel, |
416 NetEqStereoTestDelays, | 438 NetEqStereoTestDelays, |
417 ::testing::ValuesIn(GetTestParameters())); | 439 ::testing::ValuesIn(GetTestParameters())); |
418 | 440 |
419 INSTANTIATE_TEST_CASE_P(MultiChannel, | 441 INSTANTIATE_TEST_CASE_P(MultiChannel, |
420 NetEqStereoTestLosses, | 442 NetEqStereoTestLosses, |
421 ::testing::ValuesIn(GetTestParameters())); | 443 ::testing::ValuesIn(GetTestParameters())); |
422 | 444 |
423 } // namespace webrtc | 445 } // namespace webrtc |
OLD | NEW |