| 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 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 void NetEqDecodingTest::Process() { | 317 void NetEqDecodingTest::Process() { |
| 318 // Check if time to receive. | 318 // Check if time to receive. |
| 319 while (packet_ && sim_clock_ >= packet_->time_ms()) { | 319 while (packet_ && sim_clock_ >= packet_->time_ms()) { |
| 320 if (packet_->payload_length_bytes() > 0) { | 320 if (packet_->payload_length_bytes() > 0) { |
| 321 WebRtcRTPHeader rtp_header; | 321 WebRtcRTPHeader rtp_header; |
| 322 packet_->ConvertHeader(&rtp_header); | 322 packet_->ConvertHeader(&rtp_header); |
| 323 #ifndef WEBRTC_CODEC_ISAC | 323 #ifndef WEBRTC_CODEC_ISAC |
| 324 // Ignore payload type 104 (iSAC-swb) if ISAC is not supported. | 324 // Ignore payload type 104 (iSAC-swb) if ISAC is not supported. |
| 325 if (rtp_header.header.payloadType != 104) | 325 if (rtp_header.header.payloadType != 104) |
| 326 #endif | 326 #endif |
| 327 ASSERT_EQ(0, | 327 ASSERT_EQ(0, neteq_->InsertPacket( |
| 328 neteq_->InsertPacket( | 328 rtp_header, |
| 329 rtp_header.header, | 329 rtc::ArrayView<const uint8_t>( |
| 330 rtc::ArrayView<const uint8_t>( | 330 packet_->payload(), packet_->payload_length_bytes()), |
| 331 packet_->payload(), packet_->payload_length_bytes()), | 331 static_cast<uint32_t>(packet_->time_ms() * |
| 332 static_cast<uint32_t>(packet_->time_ms() * | 332 (output_sample_rate_ / 1000)))); |
| 333 (output_sample_rate_ / 1000)))); | |
| 334 } | 333 } |
| 335 // Get next packet. | 334 // Get next packet. |
| 336 packet_ = rtp_source_->NextPacket(); | 335 packet_ = rtp_source_->NextPacket(); |
| 337 } | 336 } |
| 338 | 337 |
| 339 // Get audio from NetEq. | 338 // Get audio from NetEq. |
| 340 bool muted; | 339 bool muted; |
| 341 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 340 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 342 ASSERT_FALSE(muted); | 341 ASSERT_FALSE(muted); |
| 343 ASSERT_TRUE((out_frame_.samples_per_channel_ == kBlockSize8kHz) || | 342 ASSERT_TRUE((out_frame_.samples_per_channel_ == kBlockSize8kHz) || |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 const size_t kSamples = 10 * 16; | 519 const size_t kSamples = 10 * 16; |
| 521 const size_t kPayloadBytes = kSamples * 2; | 520 const size_t kPayloadBytes = kSamples * 2; |
| 522 for (size_t i = 0; i < num_frames; ++i) { | 521 for (size_t i = 0; i < num_frames; ++i) { |
| 523 const uint8_t payload[kPayloadBytes] = {0}; | 522 const uint8_t payload[kPayloadBytes] = {0}; |
| 524 WebRtcRTPHeader rtp_info; | 523 WebRtcRTPHeader rtp_info; |
| 525 rtp_info.header.sequenceNumber = i; | 524 rtp_info.header.sequenceNumber = i; |
| 526 rtp_info.header.timestamp = i * kSamples; | 525 rtp_info.header.timestamp = i * kSamples; |
| 527 rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC. | 526 rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC. |
| 528 rtp_info.header.payloadType = 94; // PCM16b WB codec. | 527 rtp_info.header.payloadType = 94; // PCM16b WB codec. |
| 529 rtp_info.header.markerBit = 0; | 528 rtp_info.header.markerBit = 0; |
| 530 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 529 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 531 } | 530 } |
| 532 // Pull out all data. | 531 // Pull out all data. |
| 533 for (size_t i = 0; i < num_frames; ++i) { | 532 for (size_t i = 0; i < num_frames; ++i) { |
| 534 bool muted; | 533 bool muted; |
| 535 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 534 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 536 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 535 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 537 } | 536 } |
| 538 | 537 |
| 539 NetEqNetworkStatistics stats; | 538 NetEqNetworkStatistics stats; |
| 540 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); | 539 EXPECT_EQ(0, neteq_->NetworkStatistics(&stats)); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 561 const size_t kSamples = 10 * 16; | 560 const size_t kSamples = 10 * 16; |
| 562 const size_t kPayloadBytes = kSamples * 2; | 561 const size_t kPayloadBytes = kSamples * 2; |
| 563 while (frame_index < kNumFrames) { | 562 while (frame_index < kNumFrames) { |
| 564 // Insert one packet each time, except every 10th time where we insert two | 563 // Insert one packet each time, except every 10th time where we insert two |
| 565 // packets at once. This will create a negative clock-drift of approx. 10%. | 564 // packets at once. This will create a negative clock-drift of approx. 10%. |
| 566 int num_packets = (frame_index % 10 == 0 ? 2 : 1); | 565 int num_packets = (frame_index % 10 == 0 ? 2 : 1); |
| 567 for (int n = 0; n < num_packets; ++n) { | 566 for (int n = 0; n < num_packets; ++n) { |
| 568 uint8_t payload[kPayloadBytes] = {0}; | 567 uint8_t payload[kPayloadBytes] = {0}; |
| 569 WebRtcRTPHeader rtp_info; | 568 WebRtcRTPHeader rtp_info; |
| 570 PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); | 569 PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
| 571 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 570 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 572 ++frame_index; | 571 ++frame_index; |
| 573 } | 572 } |
| 574 | 573 |
| 575 // Pull out data once. | 574 // Pull out data once. |
| 576 bool muted; | 575 bool muted; |
| 577 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 576 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 578 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 577 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 579 } | 578 } |
| 580 | 579 |
| 581 NetEqNetworkStatistics network_stats; | 580 NetEqNetworkStatistics network_stats; |
| 582 ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); | 581 ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
| 583 EXPECT_EQ(-103192, network_stats.clockdrift_ppm); | 582 EXPECT_EQ(-103192, network_stats.clockdrift_ppm); |
| 584 } | 583 } |
| 585 | 584 |
| 586 TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) { | 585 TEST_F(NetEqDecodingTest, TestAverageInterArrivalTimePositive) { |
| 587 const int kNumFrames = 5000; // Needed for convergence. | 586 const int kNumFrames = 5000; // Needed for convergence. |
| 588 int frame_index = 0; | 587 int frame_index = 0; |
| 589 const size_t kSamples = 10 * 16; | 588 const size_t kSamples = 10 * 16; |
| 590 const size_t kPayloadBytes = kSamples * 2; | 589 const size_t kPayloadBytes = kSamples * 2; |
| 591 for (int i = 0; i < kNumFrames; ++i) { | 590 for (int i = 0; i < kNumFrames; ++i) { |
| 592 // Insert one packet each time, except every 10th time where we don't insert | 591 // Insert one packet each time, except every 10th time where we don't insert |
| 593 // any packet. This will create a positive clock-drift of approx. 11%. | 592 // any packet. This will create a positive clock-drift of approx. 11%. |
| 594 int num_packets = (i % 10 == 9 ? 0 : 1); | 593 int num_packets = (i % 10 == 9 ? 0 : 1); |
| 595 for (int n = 0; n < num_packets; ++n) { | 594 for (int n = 0; n < num_packets; ++n) { |
| 596 uint8_t payload[kPayloadBytes] = {0}; | 595 uint8_t payload[kPayloadBytes] = {0}; |
| 597 WebRtcRTPHeader rtp_info; | 596 WebRtcRTPHeader rtp_info; |
| 598 PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); | 597 PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
| 599 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 598 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 600 ++frame_index; | 599 ++frame_index; |
| 601 } | 600 } |
| 602 | 601 |
| 603 // Pull out data once. | 602 // Pull out data once. |
| 604 bool muted; | 603 bool muted; |
| 605 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 604 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 606 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 605 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 607 } | 606 } |
| 608 | 607 |
| 609 NetEqNetworkStatistics network_stats; | 608 NetEqNetworkStatistics network_stats; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 627 | 626 |
| 628 // Insert speech for 5 seconds. | 627 // Insert speech for 5 seconds. |
| 629 const int kSpeechDurationMs = 5000; | 628 const int kSpeechDurationMs = 5000; |
| 630 for (t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { | 629 for (t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { |
| 631 // Each turn in this for loop is 10 ms. | 630 // Each turn in this for loop is 10 ms. |
| 632 while (next_input_time_ms <= t_ms) { | 631 while (next_input_time_ms <= t_ms) { |
| 633 // Insert one 30 ms speech frame. | 632 // Insert one 30 ms speech frame. |
| 634 uint8_t payload[kPayloadBytes] = {0}; | 633 uint8_t payload[kPayloadBytes] = {0}; |
| 635 WebRtcRTPHeader rtp_info; | 634 WebRtcRTPHeader rtp_info; |
| 636 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 635 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
| 637 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 636 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 638 ++seq_no; | 637 ++seq_no; |
| 639 timestamp += kSamples; | 638 timestamp += kSamples; |
| 640 next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor; | 639 next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor; |
| 641 } | 640 } |
| 642 // Pull out data once. | 641 // Pull out data once. |
| 643 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 642 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 644 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 643 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 645 } | 644 } |
| 646 | 645 |
| 647 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); | 646 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
| 648 rtc::Optional<uint32_t> playout_timestamp = PlayoutTimestamp(); | 647 rtc::Optional<uint32_t> playout_timestamp = PlayoutTimestamp(); |
| 649 ASSERT_TRUE(playout_timestamp); | 648 ASSERT_TRUE(playout_timestamp); |
| 650 int32_t delay_before = timestamp - *playout_timestamp; | 649 int32_t delay_before = timestamp - *playout_timestamp; |
| 651 | 650 |
| 652 // Insert CNG for 1 minute (= 60000 ms). | 651 // Insert CNG for 1 minute (= 60000 ms). |
| 653 const int kCngPeriodMs = 100; | 652 const int kCngPeriodMs = 100; |
| 654 const int kCngPeriodSamples = kCngPeriodMs * 16; // Period in 16 kHz samples. | 653 const int kCngPeriodSamples = kCngPeriodMs * 16; // Period in 16 kHz samples. |
| 655 const int kCngDurationMs = 60000; | 654 const int kCngDurationMs = 60000; |
| 656 for (; t_ms < kSpeechDurationMs + kCngDurationMs; t_ms += 10) { | 655 for (; t_ms < kSpeechDurationMs + kCngDurationMs; t_ms += 10) { |
| 657 // Each turn in this for loop is 10 ms. | 656 // Each turn in this for loop is 10 ms. |
| 658 while (next_input_time_ms <= t_ms) { | 657 while (next_input_time_ms <= t_ms) { |
| 659 // Insert one CNG frame each 100 ms. | 658 // Insert one CNG frame each 100 ms. |
| 660 uint8_t payload[kPayloadBytes]; | 659 uint8_t payload[kPayloadBytes]; |
| 661 size_t payload_len; | 660 size_t payload_len; |
| 662 WebRtcRTPHeader rtp_info; | 661 WebRtcRTPHeader rtp_info; |
| 663 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); | 662 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
| 664 ASSERT_EQ(0, neteq_->InsertPacket( | 663 ASSERT_EQ(0, neteq_->InsertPacket( |
| 665 rtp_info.header, | 664 rtp_info, |
| 666 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); | 665 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
| 667 ++seq_no; | 666 ++seq_no; |
| 668 timestamp += kCngPeriodSamples; | 667 timestamp += kCngPeriodSamples; |
| 669 next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor; | 668 next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor; |
| 670 } | 669 } |
| 671 // Pull out data once. | 670 // Pull out data once. |
| 672 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 671 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 673 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 672 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 674 } | 673 } |
| 675 | 674 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 698 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 697 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 699 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); | 698 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
| 700 t_ms += 10; | 699 t_ms += 10; |
| 701 } | 700 } |
| 702 // Insert one CNG frame each 100 ms. | 701 // Insert one CNG frame each 100 ms. |
| 703 uint8_t payload[kPayloadBytes]; | 702 uint8_t payload[kPayloadBytes]; |
| 704 size_t payload_len; | 703 size_t payload_len; |
| 705 WebRtcRTPHeader rtp_info; | 704 WebRtcRTPHeader rtp_info; |
| 706 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); | 705 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
| 707 ASSERT_EQ(0, neteq_->InsertPacket( | 706 ASSERT_EQ(0, neteq_->InsertPacket( |
| 708 rtp_info.header, | 707 rtp_info, |
| 709 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); | 708 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
| 710 ++seq_no; | 709 ++seq_no; |
| 711 timestamp += kCngPeriodSamples; | 710 timestamp += kCngPeriodSamples; |
| 712 next_input_time_ms += kCngPeriodMs * drift_factor; | 711 next_input_time_ms += kCngPeriodMs * drift_factor; |
| 713 } | 712 } |
| 714 } | 713 } |
| 715 | 714 |
| 716 // Insert speech again until output type is speech. | 715 // Insert speech again until output type is speech. |
| 717 double speech_restart_time_ms = t_ms; | 716 double speech_restart_time_ms = t_ms; |
| 718 while (out_frame_.speech_type_ != AudioFrame::kNormalSpeech) { | 717 while (out_frame_.speech_type_ != AudioFrame::kNormalSpeech) { |
| 719 // Each turn in this for loop is 10 ms. | 718 // Each turn in this for loop is 10 ms. |
| 720 while (next_input_time_ms <= t_ms) { | 719 while (next_input_time_ms <= t_ms) { |
| 721 // Insert one 30 ms speech frame. | 720 // Insert one 30 ms speech frame. |
| 722 uint8_t payload[kPayloadBytes] = {0}; | 721 uint8_t payload[kPayloadBytes] = {0}; |
| 723 WebRtcRTPHeader rtp_info; | 722 WebRtcRTPHeader rtp_info; |
| 724 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 723 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
| 725 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 724 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 726 ++seq_no; | 725 ++seq_no; |
| 727 timestamp += kSamples; | 726 timestamp += kSamples; |
| 728 next_input_time_ms += kFrameSizeMs * drift_factor; | 727 next_input_time_ms += kFrameSizeMs * drift_factor; |
| 729 } | 728 } |
| 730 // Pull out data once. | 729 // Pull out data once. |
| 731 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 730 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 732 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 731 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 733 // Increase clock. | 732 // Increase clock. |
| 734 t_ms += 10; | 733 t_ms += 10; |
| 735 } | 734 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 kDelayToleranceMs, | 826 kDelayToleranceMs, |
| 828 kMaxTimeToSpeechMs); | 827 kMaxTimeToSpeechMs); |
| 829 } | 828 } |
| 830 | 829 |
| 831 TEST_F(NetEqDecodingTest, UnknownPayloadType) { | 830 TEST_F(NetEqDecodingTest, UnknownPayloadType) { |
| 832 const size_t kPayloadBytes = 100; | 831 const size_t kPayloadBytes = 100; |
| 833 uint8_t payload[kPayloadBytes] = {0}; | 832 uint8_t payload[kPayloadBytes] = {0}; |
| 834 WebRtcRTPHeader rtp_info; | 833 WebRtcRTPHeader rtp_info; |
| 835 PopulateRtpInfo(0, 0, &rtp_info); | 834 PopulateRtpInfo(0, 0, &rtp_info); |
| 836 rtp_info.header.payloadType = 1; // Not registered as a decoder. | 835 rtp_info.header.payloadType = 1; // Not registered as a decoder. |
| 837 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 836 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 838 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); | 837 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
| 839 } | 838 } |
| 840 | 839 |
| 841 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) | 840 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
| 842 #define MAYBE_DecoderError DecoderError | 841 #define MAYBE_DecoderError DecoderError |
| 843 #else | 842 #else |
| 844 #define MAYBE_DecoderError DISABLED_DecoderError | 843 #define MAYBE_DecoderError DISABLED_DecoderError |
| 845 #endif | 844 #endif |
| 846 | 845 |
| 847 TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { | 846 TEST_F(NetEqDecodingTest, MAYBE_DecoderError) { |
| 848 const size_t kPayloadBytes = 100; | 847 const size_t kPayloadBytes = 100; |
| 849 uint8_t payload[kPayloadBytes] = {0}; | 848 uint8_t payload[kPayloadBytes] = {0}; |
| 850 WebRtcRTPHeader rtp_info; | 849 WebRtcRTPHeader rtp_info; |
| 851 PopulateRtpInfo(0, 0, &rtp_info); | 850 PopulateRtpInfo(0, 0, &rtp_info); |
| 852 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. | 851 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. |
| 853 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 852 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 854 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call | 853 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
| 855 // to GetAudio. | 854 // to GetAudio. |
| 856 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { | 855 for (size_t i = 0; i < AudioFrame::kMaxDataSizeSamples; ++i) { |
| 857 out_frame_.data_[i] = 1; | 856 out_frame_.data_[i] = 1; |
| 858 } | 857 } |
| 859 bool muted; | 858 bool muted; |
| 860 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&out_frame_, &muted)); | 859 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&out_frame_, &muted)); |
| 861 ASSERT_FALSE(muted); | 860 ASSERT_FALSE(muted); |
| 862 // Verify that there is a decoder error to check. | 861 // Verify that there is a decoder error to check. |
| 863 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); | 862 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 | 949 |
| 951 uint32_t receive_timestamp = 0; | 950 uint32_t receive_timestamp = 0; |
| 952 bool muted; | 951 bool muted; |
| 953 for (int n = 0; n < 10; ++n) { // Insert few packets and get audio. | 952 for (int n = 0; n < 10; ++n) { // Insert few packets and get audio. |
| 954 auto block = input.GetNextBlock(); | 953 auto block = input.GetNextBlock(); |
| 955 ASSERT_EQ(expected_samples_per_channel, block.size()); | 954 ASSERT_EQ(expected_samples_per_channel, block.size()); |
| 956 size_t enc_len_bytes = | 955 size_t enc_len_bytes = |
| 957 WebRtcPcm16b_Encode(block.data(), block.size(), payload); | 956 WebRtcPcm16b_Encode(block.data(), block.size(), payload); |
| 958 ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); | 957 ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); |
| 959 | 958 |
| 960 ASSERT_EQ(0, neteq_->InsertPacket( | 959 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, rtc::ArrayView<const uint8_t>( |
| 961 rtp_info.header, | 960 payload, enc_len_bytes), |
| 962 rtc::ArrayView<const uint8_t>(payload, enc_len_bytes), | 961 receive_timestamp)); |
| 963 receive_timestamp)); | |
| 964 output.Reset(); | 962 output.Reset(); |
| 965 ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); | 963 ASSERT_EQ(0, neteq_->GetAudio(&output, &muted)); |
| 966 ASSERT_EQ(1u, output.num_channels_); | 964 ASSERT_EQ(1u, output.num_channels_); |
| 967 ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); | 965 ASSERT_EQ(expected_samples_per_channel, output.samples_per_channel_); |
| 968 ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 966 ASSERT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| 969 | 967 |
| 970 // Next packet. | 968 // Next packet. |
| 971 rtp_info.header.timestamp += expected_samples_per_channel; | 969 rtp_info.header.timestamp += expected_samples_per_channel; |
| 972 rtp_info.header.sequenceNumber++; | 970 rtp_info.header.sequenceNumber++; |
| 973 receive_timestamp += expected_samples_per_channel; | 971 receive_timestamp += expected_samples_per_channel; |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1087 bool seq_no_wrapped = false; | 1085 bool seq_no_wrapped = false; |
| 1088 for (double t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { | 1086 for (double t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { |
| 1089 // Each turn in this for loop is 10 ms. | 1087 // Each turn in this for loop is 10 ms. |
| 1090 while (next_input_time_ms <= t_ms) { | 1088 while (next_input_time_ms <= t_ms) { |
| 1091 // Insert one 30 ms speech frame. | 1089 // Insert one 30 ms speech frame. |
| 1092 uint8_t payload[kPayloadBytes] = {0}; | 1090 uint8_t payload[kPayloadBytes] = {0}; |
| 1093 WebRtcRTPHeader rtp_info; | 1091 WebRtcRTPHeader rtp_info; |
| 1094 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 1092 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
| 1095 if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) { | 1093 if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) { |
| 1096 // This sequence number was not in the set to drop. Insert it. | 1094 // This sequence number was not in the set to drop. Insert it. |
| 1097 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, | 1095 ASSERT_EQ(0, |
| 1098 receive_timestamp)); | 1096 neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
| 1099 ++packets_inserted; | 1097 ++packets_inserted; |
| 1100 } | 1098 } |
| 1101 NetEqNetworkStatistics network_stats; | 1099 NetEqNetworkStatistics network_stats; |
| 1102 ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); | 1100 ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
| 1103 | 1101 |
| 1104 // Due to internal NetEq logic, preferred buffer-size is about 4 times the | 1102 // Due to internal NetEq logic, preferred buffer-size is about 4 times the |
| 1105 // packet size for first few packets. Therefore we refrain from checking | 1103 // packet size for first few packets. Therefore we refrain from checking |
| 1106 // the criteria. | 1104 // the criteria. |
| 1107 if (packets_inserted > 4) { | 1105 if (packets_inserted > 4) { |
| 1108 // Expect preferred and actual buffer size to be no more than 2 frames. | 1106 // Expect preferred and actual buffer size to be no more than 2 frames. |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1176 | 1174 |
| 1177 const int algorithmic_delay_samples = std::max( | 1175 const int algorithmic_delay_samples = std::max( |
| 1178 algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); | 1176 algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); |
| 1179 // Insert three speech packets. Three are needed to get the frame length | 1177 // Insert three speech packets. Three are needed to get the frame length |
| 1180 // correct. | 1178 // correct. |
| 1181 uint8_t payload[kPayloadBytes] = {0}; | 1179 uint8_t payload[kPayloadBytes] = {0}; |
| 1182 WebRtcRTPHeader rtp_info; | 1180 WebRtcRTPHeader rtp_info; |
| 1183 bool muted; | 1181 bool muted; |
| 1184 for (int i = 0; i < 3; ++i) { | 1182 for (int i = 0; i < 3; ++i) { |
| 1185 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 1183 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
| 1186 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 1184 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1187 ++seq_no; | 1185 ++seq_no; |
| 1188 timestamp += kSamples; | 1186 timestamp += kSamples; |
| 1189 | 1187 |
| 1190 // Pull audio once. | 1188 // Pull audio once. |
| 1191 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 1189 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1192 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 1190 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 1193 } | 1191 } |
| 1194 // Verify speech output. | 1192 // Verify speech output. |
| 1195 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); | 1193 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
| 1196 | 1194 |
| 1197 // Insert same CNG packet twice. | 1195 // Insert same CNG packet twice. |
| 1198 const int kCngPeriodMs = 100; | 1196 const int kCngPeriodMs = 100; |
| 1199 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; | 1197 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; |
| 1200 size_t payload_len; | 1198 size_t payload_len; |
| 1201 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); | 1199 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
| 1202 // This is the first time this CNG packet is inserted. | 1200 // This is the first time this CNG packet is inserted. |
| 1203 ASSERT_EQ(0, neteq_->InsertPacket( | 1201 ASSERT_EQ( |
| 1204 rtp_info.header, | 1202 0, neteq_->InsertPacket( |
| 1205 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); | 1203 rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
| 1206 | 1204 |
| 1207 // Pull audio once and make sure CNG is played. | 1205 // Pull audio once and make sure CNG is played. |
| 1208 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 1206 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1209 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 1207 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 1210 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); | 1208 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
| 1211 EXPECT_FALSE(PlayoutTimestamp()); // Returns empty value during CNG. | 1209 EXPECT_FALSE(PlayoutTimestamp()); // Returns empty value during CNG. |
| 1212 EXPECT_EQ(timestamp - algorithmic_delay_samples, | 1210 EXPECT_EQ(timestamp - algorithmic_delay_samples, |
| 1213 out_frame_.timestamp_ + out_frame_.samples_per_channel_); | 1211 out_frame_.timestamp_ + out_frame_.samples_per_channel_); |
| 1214 | 1212 |
| 1215 // Insert the same CNG packet again. Note that at this point it is old, since | 1213 // Insert the same CNG packet again. Note that at this point it is old, since |
| 1216 // we have already decoded the first copy of it. | 1214 // we have already decoded the first copy of it. |
| 1217 ASSERT_EQ(0, neteq_->InsertPacket( | 1215 ASSERT_EQ( |
| 1218 rtp_info.header, | 1216 0, neteq_->InsertPacket( |
| 1219 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); | 1217 rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
| 1220 | 1218 |
| 1221 // Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since | 1219 // Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since |
| 1222 // we have already pulled out CNG once. | 1220 // we have already pulled out CNG once. |
| 1223 for (int cng_time_ms = 10; cng_time_ms < kCngPeriodMs; cng_time_ms += 10) { | 1221 for (int cng_time_ms = 10; cng_time_ms < kCngPeriodMs; cng_time_ms += 10) { |
| 1224 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 1222 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1225 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 1223 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 1226 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); | 1224 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
| 1227 EXPECT_FALSE(PlayoutTimestamp()); // Returns empty value during CNG. | 1225 EXPECT_FALSE(PlayoutTimestamp()); // Returns empty value during CNG. |
| 1228 EXPECT_EQ(timestamp - algorithmic_delay_samples, | 1226 EXPECT_EQ(timestamp - algorithmic_delay_samples, |
| 1229 out_frame_.timestamp_ + out_frame_.samples_per_channel_); | 1227 out_frame_.timestamp_ + out_frame_.samples_per_channel_); |
| 1230 } | 1228 } |
| 1231 | 1229 |
| 1232 // Insert speech again. | 1230 // Insert speech again. |
| 1233 ++seq_no; | 1231 ++seq_no; |
| 1234 timestamp += kCngPeriodSamples; | 1232 timestamp += kCngPeriodSamples; |
| 1235 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 1233 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
| 1236 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 1234 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1237 | 1235 |
| 1238 // Pull audio once and verify that the output is speech again. | 1236 // Pull audio once and verify that the output is speech again. |
| 1239 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 1237 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1240 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 1238 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 1241 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); | 1239 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
| 1242 rtc::Optional<uint32_t> playout_timestamp = PlayoutTimestamp(); | 1240 rtc::Optional<uint32_t> playout_timestamp = PlayoutTimestamp(); |
| 1243 ASSERT_TRUE(playout_timestamp); | 1241 ASSERT_TRUE(playout_timestamp); |
| 1244 EXPECT_EQ(timestamp + kSamples - algorithmic_delay_samples, | 1242 EXPECT_EQ(timestamp + kSamples - algorithmic_delay_samples, |
| 1245 *playout_timestamp); | 1243 *playout_timestamp); |
| 1246 } | 1244 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1259 const int kSamples = kFrameSizeMs * kSampleRateKhz; | 1257 const int kSamples = kFrameSizeMs * kSampleRateKhz; |
| 1260 const int kPayloadBytes = kSamples * 2; | 1258 const int kPayloadBytes = kSamples * 2; |
| 1261 const int kCngPeriodMs = 100; | 1259 const int kCngPeriodMs = 100; |
| 1262 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; | 1260 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; |
| 1263 size_t payload_len; | 1261 size_t payload_len; |
| 1264 | 1262 |
| 1265 uint8_t payload[kPayloadBytes] = {0}; | 1263 uint8_t payload[kPayloadBytes] = {0}; |
| 1266 WebRtcRTPHeader rtp_info; | 1264 WebRtcRTPHeader rtp_info; |
| 1267 | 1265 |
| 1268 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); | 1266 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
| 1269 ASSERT_EQ(NetEq::kOK, | 1267 ASSERT_EQ( |
| 1270 neteq_->InsertPacket( | 1268 NetEq::kOK, |
| 1271 rtp_info.header, | 1269 neteq_->InsertPacket( |
| 1272 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); | 1270 rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
| 1273 ++seq_no; | 1271 ++seq_no; |
| 1274 timestamp += kCngPeriodSamples; | 1272 timestamp += kCngPeriodSamples; |
| 1275 | 1273 |
| 1276 // Pull audio once and make sure CNG is played. | 1274 // Pull audio once and make sure CNG is played. |
| 1277 bool muted; | 1275 bool muted; |
| 1278 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 1276 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1279 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 1277 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 1280 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); | 1278 EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); |
| 1281 | 1279 |
| 1282 // Insert some speech packets. | 1280 // Insert some speech packets. |
| 1283 const uint32_t first_speech_timestamp = timestamp; | 1281 const uint32_t first_speech_timestamp = timestamp; |
| 1284 int timeout_counter = 0; | 1282 int timeout_counter = 0; |
| 1285 do { | 1283 do { |
| 1286 ASSERT_LT(timeout_counter++, 20) << "Test timed out"; | 1284 ASSERT_LT(timeout_counter++, 20) << "Test timed out"; |
| 1287 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 1285 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
| 1288 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 1286 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1289 ++seq_no; | 1287 ++seq_no; |
| 1290 timestamp += kSamples; | 1288 timestamp += kSamples; |
| 1291 | 1289 |
| 1292 // Pull audio once. | 1290 // Pull audio once. |
| 1293 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 1291 ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1294 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); | 1292 ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); |
| 1295 } while (!IsNewerTimestamp(out_frame_.timestamp_, first_speech_timestamp)); | 1293 } while (!IsNewerTimestamp(out_frame_.timestamp_, first_speech_timestamp)); |
| 1296 // Verify speech output. | 1294 // Verify speech output. |
| 1297 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); | 1295 EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); |
| 1298 } | 1296 } |
| 1299 | 1297 |
| 1300 class NetEqDecodingTestWithMutedState : public NetEqDecodingTest { | 1298 class NetEqDecodingTestWithMutedState : public NetEqDecodingTest { |
| 1301 public: | 1299 public: |
| 1302 NetEqDecodingTestWithMutedState() : NetEqDecodingTest() { | 1300 NetEqDecodingTestWithMutedState() : NetEqDecodingTest() { |
| 1303 config_.enable_muted_state = true; | 1301 config_.enable_muted_state = true; |
| 1304 } | 1302 } |
| 1305 | 1303 |
| 1306 protected: | 1304 protected: |
| 1307 static constexpr size_t kSamples = 10 * 16; | 1305 static constexpr size_t kSamples = 10 * 16; |
| 1308 static constexpr size_t kPayloadBytes = kSamples * 2; | 1306 static constexpr size_t kPayloadBytes = kSamples * 2; |
| 1309 | 1307 |
| 1310 void InsertPacket(uint32_t rtp_timestamp) { | 1308 void InsertPacket(uint32_t rtp_timestamp) { |
| 1311 uint8_t payload[kPayloadBytes] = {0}; | 1309 uint8_t payload[kPayloadBytes] = {0}; |
| 1312 WebRtcRTPHeader rtp_info; | 1310 WebRtcRTPHeader rtp_info; |
| 1313 PopulateRtpInfo(0, rtp_timestamp, &rtp_info); | 1311 PopulateRtpInfo(0, rtp_timestamp, &rtp_info); |
| 1314 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 1312 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1315 } | 1313 } |
| 1316 | 1314 |
| 1317 void InsertCngPacket(uint32_t rtp_timestamp) { | 1315 void InsertCngPacket(uint32_t rtp_timestamp) { |
| 1318 uint8_t payload[kPayloadBytes] = {0}; | 1316 uint8_t payload[kPayloadBytes] = {0}; |
| 1319 WebRtcRTPHeader rtp_info; | 1317 WebRtcRTPHeader rtp_info; |
| 1320 size_t payload_len; | 1318 size_t payload_len; |
| 1321 PopulateCng(0, rtp_timestamp, &rtp_info, payload, &payload_len); | 1319 PopulateCng(0, rtp_timestamp, &rtp_info, payload, &payload_len); |
| 1322 EXPECT_EQ(NetEq::kOK, | 1320 EXPECT_EQ( |
| 1323 neteq_->InsertPacket( | 1321 NetEq::kOK, |
| 1324 rtp_info.header, | 1322 neteq_->InsertPacket( |
| 1325 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); | 1323 rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
| 1326 } | 1324 } |
| 1327 | 1325 |
| 1328 bool GetAudioReturnMuted() { | 1326 bool GetAudioReturnMuted() { |
| 1329 bool muted; | 1327 bool muted; |
| 1330 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); | 1328 EXPECT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); |
| 1331 return muted; | 1329 return muted; |
| 1332 } | 1330 } |
| 1333 | 1331 |
| 1334 void GetAudioUntilMuted() { | 1332 void GetAudioUntilMuted() { |
| 1335 while (!GetAudioReturnMuted()) { | 1333 while (!GetAudioReturnMuted()) { |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1540 ASSERT_FALSE(config_.enable_muted_state); | 1538 ASSERT_FALSE(config_.enable_muted_state); |
| 1541 config2_.enable_muted_state = true; | 1539 config2_.enable_muted_state = true; |
| 1542 CreateSecondInstance(); | 1540 CreateSecondInstance(); |
| 1543 | 1541 |
| 1544 // Insert one speech packet into both NetEqs. | 1542 // Insert one speech packet into both NetEqs. |
| 1545 const size_t kSamples = 10 * 16; | 1543 const size_t kSamples = 10 * 16; |
| 1546 const size_t kPayloadBytes = kSamples * 2; | 1544 const size_t kPayloadBytes = kSamples * 2; |
| 1547 uint8_t payload[kPayloadBytes] = {0}; | 1545 uint8_t payload[kPayloadBytes] = {0}; |
| 1548 WebRtcRTPHeader rtp_info; | 1546 WebRtcRTPHeader rtp_info; |
| 1549 PopulateRtpInfo(0, 0, &rtp_info); | 1547 PopulateRtpInfo(0, 0, &rtp_info); |
| 1550 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 1548 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1551 EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info.header, payload, 0)); | 1549 EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, 0)); |
| 1552 | 1550 |
| 1553 AudioFrame out_frame1, out_frame2; | 1551 AudioFrame out_frame1, out_frame2; |
| 1554 bool muted; | 1552 bool muted; |
| 1555 for (int i = 0; i < 1000; ++i) { | 1553 for (int i = 0; i < 1000; ++i) { |
| 1556 std::ostringstream ss; | 1554 std::ostringstream ss; |
| 1557 ss << "i = " << i; | 1555 ss << "i = " << i; |
| 1558 SCOPED_TRACE(ss.str()); // Print out the loop iterator on failure. | 1556 SCOPED_TRACE(ss.str()); // Print out the loop iterator on failure. |
| 1559 EXPECT_EQ(0, neteq_->GetAudio(&out_frame1, &muted)); | 1557 EXPECT_EQ(0, neteq_->GetAudio(&out_frame1, &muted)); |
| 1560 EXPECT_FALSE(muted); | 1558 EXPECT_FALSE(muted); |
| 1561 EXPECT_EQ(0, neteq2_->GetAudio(&out_frame2, &muted)); | 1559 EXPECT_EQ(0, neteq2_->GetAudio(&out_frame2, &muted)); |
| 1562 if (muted) { | 1560 if (muted) { |
| 1563 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); | 1561 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); |
| 1564 } else { | 1562 } else { |
| 1565 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); | 1563 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); |
| 1566 } | 1564 } |
| 1567 } | 1565 } |
| 1568 EXPECT_TRUE(muted); | 1566 EXPECT_TRUE(muted); |
| 1569 | 1567 |
| 1570 // Insert new data. Timestamp is corrected for the time elapsed since the last | 1568 // Insert new data. Timestamp is corrected for the time elapsed since the last |
| 1571 // packet. | 1569 // packet. |
| 1572 PopulateRtpInfo(0, kSamples * 1000, &rtp_info); | 1570 PopulateRtpInfo(0, kSamples * 1000, &rtp_info); |
| 1573 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info.header, payload, 0)); | 1571 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
| 1574 EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info.header, payload, 0)); | 1572 EXPECT_EQ(0, neteq2_->InsertPacket(rtp_info, payload, 0)); |
| 1575 | 1573 |
| 1576 int counter = 0; | 1574 int counter = 0; |
| 1577 while (out_frame1.speech_type_ != AudioFrame::kNormalSpeech) { | 1575 while (out_frame1.speech_type_ != AudioFrame::kNormalSpeech) { |
| 1578 ASSERT_LT(counter++, 1000) << "Test timed out"; | 1576 ASSERT_LT(counter++, 1000) << "Test timed out"; |
| 1579 std::ostringstream ss; | 1577 std::ostringstream ss; |
| 1580 ss << "counter = " << counter; | 1578 ss << "counter = " << counter; |
| 1581 SCOPED_TRACE(ss.str()); // Print out the loop iterator on failure. | 1579 SCOPED_TRACE(ss.str()); // Print out the loop iterator on failure. |
| 1582 EXPECT_EQ(0, neteq_->GetAudio(&out_frame1, &muted)); | 1580 EXPECT_EQ(0, neteq_->GetAudio(&out_frame1, &muted)); |
| 1583 EXPECT_FALSE(muted); | 1581 EXPECT_FALSE(muted); |
| 1584 EXPECT_EQ(0, neteq2_->GetAudio(&out_frame2, &muted)); | 1582 EXPECT_EQ(0, neteq2_->GetAudio(&out_frame2, &muted)); |
| 1585 if (muted) { | 1583 if (muted) { |
| 1586 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); | 1584 EXPECT_TRUE(AudioFramesEqualExceptData(out_frame1, out_frame2)); |
| 1587 } else { | 1585 } else { |
| 1588 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); | 1586 EXPECT_TRUE(AudioFramesEqual(out_frame1, out_frame2)); |
| 1589 } | 1587 } |
| 1590 } | 1588 } |
| 1591 EXPECT_FALSE(muted); | 1589 EXPECT_FALSE(muted); |
| 1592 } | 1590 } |
| 1593 | 1591 |
| 1594 } // namespace webrtc | 1592 } // namespace webrtc |
| OLD | NEW |