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