Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(99)

Side by Side Diff: webrtc/modules/audio_coding/neteq/neteq_unittest.cc

Issue 1296633002: NetEq/ACM: Refactor how packet waiting times are calculated (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 // Pull out all data. 499 // Pull out all data.
500 for (size_t i = 0; i < num_frames; ++i) { 500 for (size_t i = 0; i < num_frames; ++i) {
501 int out_len; 501 int out_len;
502 int num_channels; 502 int num_channels;
503 NetEqOutputType type; 503 NetEqOutputType type;
504 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, 504 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
505 &num_channels, &type)); 505 &num_channels, &type));
506 ASSERT_EQ(kBlockSize16kHz, out_len); 506 ASSERT_EQ(kBlockSize16kHz, out_len);
507 } 507 }
508 508
509 std::vector<int> waiting_times; 509 NetEqNetworkStatistics stats;
510 neteq_->WaitingTimes(&waiting_times); 510 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats));
511 EXPECT_EQ(num_frames, waiting_times.size());
512 // Since all frames are dumped into NetEQ at once, but pulled out with 10 ms 511 // Since all frames are dumped into NetEQ at once, but pulled out with 10 ms
513 // spacing (per definition), we expect the delay to increase with 10 ms for 512 // spacing (per definition), we expect the delay to increase with 10 ms for
514 // each packet. 513 // each packet. Thus, we are calculating the statistics for a series from 10
515 for (size_t i = 0; i < waiting_times.size(); ++i) { 514 // to 300, in steps of 10 ms.
516 EXPECT_EQ(static_cast<int>(i + 1) * 10, waiting_times[i]); 515 EXPECT_EQ(155, stats.mean_waiting_time_ms);
517 } 516 EXPECT_EQ(155, stats.median_waiting_time_ms);
517 EXPECT_EQ(10, stats.min_waiting_time_ms);
518 EXPECT_EQ(300, stats.max_waiting_time_ms);
518 519
519 // Check statistics again and make sure it's been reset. 520 // Check statistics again and make sure it's been reset.
520 neteq_->WaitingTimes(&waiting_times); 521 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats));
521 int len = waiting_times.size(); 522 EXPECT_EQ(-1, stats.mean_waiting_time_ms);
522 EXPECT_EQ(0, len); 523 EXPECT_EQ(-1, stats.median_waiting_time_ms);
523 524 EXPECT_EQ(-1, stats.min_waiting_time_ms);
524 // Process > 100 frames, and make sure that that we get statistics 525 EXPECT_EQ(-1, stats.max_waiting_time_ms);
525 // only for 100 frames. Note the new SSRC, causing NetEQ to reset.
526 num_frames = 110;
527 for (size_t i = 0; i < num_frames; ++i) {
528 uint16_t payload[kSamples] = {0};
529 WebRtcRTPHeader rtp_info;
530 rtp_info.header.sequenceNumber = i;
531 rtp_info.header.timestamp = i * kSamples;
532 rtp_info.header.ssrc = 0x1235; // Just an arbitrary SSRC.
533 rtp_info.header.payloadType = 94; // PCM16b WB codec.
534 rtp_info.header.markerBit = 0;
535 ASSERT_EQ(0, neteq_->InsertPacket(
536 rtp_info,
537 reinterpret_cast<uint8_t*>(payload),
538 kPayloadBytes, 0));
539 int out_len;
540 int num_channels;
541 NetEqOutputType type;
542 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len,
543 &num_channels, &type));
544 ASSERT_EQ(kBlockSize16kHz, out_len);
545 }
546
547 neteq_->WaitingTimes(&waiting_times);
548 EXPECT_EQ(100u, waiting_times.size());
549 } 526 }
550 527
551 TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) { 528 TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimeNegative) {
552 const int kNumFrames = 3000; // Needed for convergence. 529 const int kNumFrames = 3000; // Needed for convergence.
553 int frame_index = 0; 530 int frame_index = 0;
554 const size_t kSamples = 10 * 16; 531 const size_t kSamples = 10 * 16;
555 const size_t kPayloadBytes = kSamples * 2; 532 const size_t kPayloadBytes = kSamples * 2;
556 while (frame_index < kNumFrames) { 533 while (frame_index < kNumFrames) {
557 // Insert one packet each time, except every 10th time where we insert two 534 // Insert one packet each time, except every 10th time where we insert two
558 // packets at once. This will create a negative clock-drift of approx. 10%. 535 // packets at once. This will create a negative clock-drift of approx. 10%.
(...skipping 974 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698