OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 // Pull out all data. | 500 // Pull out all data. |
501 for (size_t i = 0; i < num_frames; ++i) { | 501 for (size_t i = 0; i < num_frames; ++i) { |
502 size_t out_len; | 502 size_t out_len; |
503 int num_channels; | 503 int num_channels; |
504 NetEqOutputType type; | 504 NetEqOutputType type; |
505 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 505 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
506 &num_channels, &type)); | 506 &num_channels, &type)); |
507 ASSERT_EQ(kBlockSize16kHz, out_len); | 507 ASSERT_EQ(kBlockSize16kHz, out_len); |
508 } | 508 } |
509 | 509 |
510 std::vector<int> waiting_times; | 510 NetEqNetworkStatistics stats; |
511 neteq_->WaitingTimes(&waiting_times); | 511 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); |
512 EXPECT_EQ(num_frames, waiting_times.size()); | |
513 // Since all frames are dumped into NetEQ at once, but pulled out with 10 ms | 512 // Since all frames are dumped into NetEQ at once, but pulled out with 10 ms |
514 // spacing (per definition), we expect the delay to increase with 10 ms for | 513 // spacing (per definition), we expect the delay to increase with 10 ms for |
515 // each packet. | 514 // each packet. Thus, we are calculating the statistics for a series from 10 |
516 for (size_t i = 0; i < waiting_times.size(); ++i) { | 515 // to 300, in steps of 10 ms. |
517 EXPECT_EQ(static_cast<int>(i + 1) * 10, waiting_times[i]); | 516 EXPECT_EQ(155, stats.mean_waiting_time_ms); |
518 } | 517 EXPECT_EQ(155, stats.median_waiting_time_ms); |
| 518 EXPECT_EQ(10, stats.min_waiting_time_ms); |
| 519 EXPECT_EQ(300, stats.max_waiting_time_ms); |
519 | 520 |
520 // Check statistics again and make sure it's been reset. | 521 // Check statistics again and make sure it's been reset. |
521 neteq_->WaitingTimes(&waiting_times); | 522 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); |
522 int len = waiting_times.size(); | 523 EXPECT_EQ(-1, stats.mean_waiting_time_ms); |
523 EXPECT_EQ(0, len); | 524 EXPECT_EQ(-1, stats.median_waiting_time_ms); |
524 | 525 EXPECT_EQ(-1, stats.min_waiting_time_ms); |
525 // Process > 100 frames, and make sure that that we get statistics | 526 EXPECT_EQ(-1, stats.max_waiting_time_ms); |
526 // only for 100 frames. Note the new SSRC, causing NetEQ to reset. | |
527 num_frames = 110; | |
528 for (size_t i = 0; i < num_frames; ++i) { | |
529 uint16_t payload[kSamples] = {0}; | |
530 WebRtcRTPHeader rtp_info; | |
531 rtp_info.header.sequenceNumber = i; | |
532 rtp_info.header.timestamp = i * kSamples; | |
533 rtp_info.header.ssrc = 0x1235; // Just an arbitrary SSRC. | |
534 rtp_info.header.payloadType = 94; // PCM16b WB codec. | |
535 rtp_info.header.markerBit = 0; | |
536 ASSERT_EQ(0, neteq_->InsertPacket( | |
537 rtp_info, | |
538 reinterpret_cast<uint8_t*>(payload), | |
539 kPayloadBytes, 0)); | |
540 size_t out_len; | |
541 int num_channels; | |
542 NetEqOutputType type; | |
543 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | |
544 &num_channels, &type)); | |
545 ASSERT_EQ(kBlockSize16kHz, out_len); | |
546 } | |
547 | |
548 neteq_->WaitingTimes(&waiting_times); | |
549 EXPECT_EQ(100u, waiting_times.size()); | |
550 } | 527 } |
551 | 528 |
552 TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { | 529 TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { |
553 const int kNumFrames = 3000; // Needed for convergence. | 530 const int kNumFrames = 3000; // Needed for convergence. |
554 int frame_index = 0; | 531 int frame_index = 0; |
555 const size_t kSamples = 10 * 16; | 532 const size_t kSamples = 10 * 16; |
556 const size_t kPayloadBytes = kSamples * 2; | 533 const size_t kPayloadBytes = kSamples * 2; |
557 while (frame_index < kNumFrames) { | 534 while (frame_index < kNumFrames) { |
558 // Insert one packet each time, except every 10th time where we insert two | 535 // Insert one packet each time, except every 10th time where we insert two |
559 // packets at once. This will create a negative clock-drift of approx. 10%. | 536 // packets at once. This will create a negative clock-drift of approx. 10%. |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1533 // Pull audio once. | 1510 // Pull audio once. |
1534 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 1511 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
1535 &num_channels, &type)); | 1512 &num_channels, &type)); |
1536 ASSERT_EQ(kBlockSize16kHz, out_len); | 1513 ASSERT_EQ(kBlockSize16kHz, out_len); |
1537 } | 1514 } |
1538 // Verify speech output. | 1515 // Verify speech output. |
1539 EXPECT_EQ(kOutputNormal, type); | 1516 EXPECT_EQ(kOutputNormal, type); |
1540 } | 1517 } |
1541 | 1518 |
1542 } // namespace webrtc | 1519 } // namespace webrtc |
OLD | NEW |