| 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 #define MAYBE_RunTest DISABLED_RunTest |
| 280 #else |
| 281 #define MAYBE_RunTest RunTest |
| 282 #endif |
| 283 TEST_P(NetEqStereoTestNoJitter, MAYBE_RunTest) { |
| 280 RunTest(8); | 284 RunTest(8); |
| 281 } | 285 } |
| 282 | 286 |
| 283 class NetEqStereoTestPositiveDrift : public NetEqStereoTest { | 287 class NetEqStereoTestPositiveDrift : public NetEqStereoTest { |
| 284 protected: | 288 protected: |
| 285 NetEqStereoTestPositiveDrift() | 289 NetEqStereoTestPositiveDrift() |
| 286 : NetEqStereoTest(), | 290 : NetEqStereoTest(), |
| 287 drift_factor(0.9) { | 291 drift_factor(0.9) { |
| 288 // Start the sender 100 ms before the receiver to pre-fill the buffer. | 292 // 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. | 293 // This is to avoid doing preemptive expand early in the test. |
| 290 // TODO(hlundin): Mock the decision making instead to control the modes. | 294 // TODO(hlundin): Mock the decision making instead to control the modes. |
| 291 last_arrival_time_ = -100; | 295 last_arrival_time_ = -100; |
| 292 } | 296 } |
| 293 virtual int GetArrivalTime(int send_time) { | 297 virtual int GetArrivalTime(int send_time) { |
| 294 int arrival_time = last_arrival_time_ + | 298 int arrival_time = last_arrival_time_ + |
| 295 drift_factor * (send_time - last_send_time_); | 299 drift_factor * (send_time - last_send_time_); |
| 296 last_send_time_ = send_time; | 300 last_send_time_ = send_time; |
| 297 last_arrival_time_ = arrival_time; | 301 last_arrival_time_ = arrival_time; |
| 298 return arrival_time; | 302 return arrival_time; |
| 299 } | 303 } |
| 300 | 304 |
| 301 double drift_factor; | 305 double drift_factor; |
| 302 }; | 306 }; |
| 303 | 307 |
| 304 TEST_P(NetEqStereoTestPositiveDrift, DISABLED_ON_ANDROID(RunTest)) { | 308 TEST_P(NetEqStereoTestPositiveDrift, MAYBE_RunTest) { |
| 305 RunTest(100); | 309 RunTest(100); |
| 306 } | 310 } |
| 307 | 311 |
| 308 class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift { | 312 class NetEqStereoTestNegativeDrift : public NetEqStereoTestPositiveDrift { |
| 309 protected: | 313 protected: |
| 310 NetEqStereoTestNegativeDrift() | 314 NetEqStereoTestNegativeDrift() |
| 311 : NetEqStereoTestPositiveDrift() { | 315 : NetEqStereoTestPositiveDrift() { |
| 312 drift_factor = 1.1; | 316 drift_factor = 1.1; |
| 313 last_arrival_time_ = 0; | 317 last_arrival_time_ = 0; |
| 314 } | 318 } |
| 315 }; | 319 }; |
| 316 | 320 |
| 317 TEST_P(NetEqStereoTestNegativeDrift, DISABLED_ON_ANDROID(RunTest)) { | 321 TEST_P(NetEqStereoTestNegativeDrift, MAYBE_RunTest) { |
| 318 RunTest(100); | 322 RunTest(100); |
| 319 } | 323 } |
| 320 | 324 |
| 321 class NetEqStereoTestDelays : public NetEqStereoTest { | 325 class NetEqStereoTestDelays : public NetEqStereoTest { |
| 322 protected: | 326 protected: |
| 323 static const int kDelayInterval = 10; | 327 static const int kDelayInterval = 10; |
| 324 static const int kDelay = 1000; | 328 static const int kDelay = 1000; |
| 325 NetEqStereoTestDelays() | 329 NetEqStereoTestDelays() |
| 326 : NetEqStereoTest(), | 330 : NetEqStereoTest(), |
| 327 frame_index_(0) { | 331 frame_index_(0) { |
| 328 } | 332 } |
| 329 | 333 |
| 330 virtual int GetArrivalTime(int send_time) { | 334 virtual int GetArrivalTime(int send_time) { |
| 331 // Deliver immediately, unless we have a back-log. | 335 // Deliver immediately, unless we have a back-log. |
| 332 int arrival_time = std::min(last_arrival_time_, send_time); | 336 int arrival_time = std::min(last_arrival_time_, send_time); |
| 333 if (++frame_index_ % kDelayInterval == 0) { | 337 if (++frame_index_ % kDelayInterval == 0) { |
| 334 // Delay this packet. | 338 // Delay this packet. |
| 335 arrival_time += kDelay; | 339 arrival_time += kDelay; |
| 336 } | 340 } |
| 337 last_send_time_ = send_time; | 341 last_send_time_ = send_time; |
| 338 last_arrival_time_ = arrival_time; | 342 last_arrival_time_ = arrival_time; |
| 339 return arrival_time; | 343 return arrival_time; |
| 340 } | 344 } |
| 341 | 345 |
| 342 int frame_index_; | 346 int frame_index_; |
| 343 }; | 347 }; |
| 344 | 348 |
| 345 TEST_P(NetEqStereoTestDelays, DISABLED_ON_ANDROID(RunTest)) { | 349 TEST_P(NetEqStereoTestDelays, MAYBE_RunTest) { |
| 346 RunTest(1000); | 350 RunTest(1000); |
| 347 } | 351 } |
| 348 | 352 |
| 349 class NetEqStereoTestLosses : public NetEqStereoTest { | 353 class NetEqStereoTestLosses : public NetEqStereoTest { |
| 350 protected: | 354 protected: |
| 351 static const int kLossInterval = 10; | 355 static const int kLossInterval = 10; |
| 352 NetEqStereoTestLosses() | 356 NetEqStereoTestLosses() |
| 353 : NetEqStereoTest(), | 357 : NetEqStereoTest(), |
| 354 frame_index_(0) { | 358 frame_index_(0) { |
| 355 } | 359 } |
| 356 | 360 |
| 357 virtual bool Lost() { | 361 virtual bool Lost() { |
| 358 return (++frame_index_) % kLossInterval == 0; | 362 return (++frame_index_) % kLossInterval == 0; |
| 359 } | 363 } |
| 360 | 364 |
| 361 int frame_index_; | 365 int frame_index_; |
| 362 }; | 366 }; |
| 363 | 367 |
| 364 TEST_P(NetEqStereoTestLosses, DISABLED_ON_ANDROID(RunTest)) { | 368 // TODO(pbos): Enable on non-Android, this went failing while being accidentally |
| 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) { |
| 365 RunTest(100); | 372 RunTest(100); |
| 366 } | 373 } |
| 367 | 374 |
| 368 | 375 |
| 369 // Creates a list of parameter sets. | 376 // Creates a list of parameter sets. |
| 370 std::list<TestParameters> GetTestParameters() { | 377 std::list<TestParameters> GetTestParameters() { |
| 371 std::list<TestParameters> l; | 378 std::list<TestParameters> l; |
| 372 const int sample_rates[] = {8000, 16000, 32000}; | 379 const int sample_rates[] = {8000, 16000, 32000}; |
| 373 const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]); | 380 const int num_rates = sizeof(sample_rates) / sizeof(sample_rates[0]); |
| 374 // Loop through sample rates. | 381 // Loop through sample rates. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 | 421 |
| 415 INSTANTIATE_TEST_CASE_P(MultiChannel, | 422 INSTANTIATE_TEST_CASE_P(MultiChannel, |
| 416 NetEqStereoTestDelays, | 423 NetEqStereoTestDelays, |
| 417 ::testing::ValuesIn(GetTestParameters())); | 424 ::testing::ValuesIn(GetTestParameters())); |
| 418 | 425 |
| 419 INSTANTIATE_TEST_CASE_P(MultiChannel, | 426 INSTANTIATE_TEST_CASE_P(MultiChannel, |
| 420 NetEqStereoTestLosses, | 427 NetEqStereoTestLosses, |
| 421 ::testing::ValuesIn(GetTestParameters())); | 428 ::testing::ValuesIn(GetTestParameters())); |
| 422 | 429 |
| 423 } // namespace webrtc | 430 } // namespace webrtc |
| OLD | NEW |