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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
336 rtp_source_.reset(test::RtpFileSource::Create(rtp_file)); | 336 rtp_source_.reset(test::RtpFileSource::Create(rtp_file)); |
337 } | 337 } |
338 | 338 |
339 void NetEqDecodingTest::Process(size_t* out_len) { | 339 void NetEqDecodingTest::Process(size_t* out_len) { |
340 // Check if time to receive. | 340 // Check if time to receive. |
341 while (packet_ && sim_clock_ >= packet_->time_ms()) { | 341 while (packet_ && sim_clock_ >= packet_->time_ms()) { |
342 if (packet_->payload_length_bytes() > 0) { | 342 if (packet_->payload_length_bytes() > 0) { |
343 WebRtcRTPHeader rtp_header; | 343 WebRtcRTPHeader rtp_header; |
344 packet_->ConvertHeader(&rtp_header); | 344 packet_->ConvertHeader(&rtp_header); |
345 ASSERT_EQ(0, neteq_->InsertPacket( | 345 ASSERT_EQ(0, neteq_->InsertPacket( |
346 rtp_header, packet_->payload(), | 346 rtp_header, |
347 packet_->payload_length_bytes(), | 347 rtc::ArrayView<const uint8_t>( |
348 static_cast<uint32_t>( | 348 packet_->payload(), packet_->payload_length_bytes()), |
349 packet_->time_ms() * (output_sample_rate_ / 1000)))); | 349 static_cast<uint32_t>(packet_->time_ms() * |
| 350 (output_sample_rate_ / 1000)))); |
350 } | 351 } |
351 // Get next packet. | 352 // Get next packet. |
352 packet_.reset(rtp_source_->NextPacket()); | 353 packet_.reset(rtp_source_->NextPacket()); |
353 } | 354 } |
354 | 355 |
355 // Get audio from NetEq. | 356 // Get audio from NetEq. |
356 NetEqOutputType type; | 357 NetEqOutputType type; |
357 int num_channels; | 358 int num_channels; |
358 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, out_len, | 359 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, out_len, |
359 &num_channels, &type)); | 360 &num_channels, &type)); |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
488 config_.playout_mode = kPlayoutFax; | 489 config_.playout_mode = kPlayoutFax; |
489 } | 490 } |
490 }; | 491 }; |
491 | 492 |
492 TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { | 493 TEST_F(NetEqDecodingTestFaxMode, TestFrameWaitingTimeStatistics) { |
493 // Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio. | 494 // Insert 30 dummy packets at once. Each packet contains 10 ms 16 kHz audio. |
494 size_t num_frames = 30; | 495 size_t num_frames = 30; |
495 const size_t kSamples = 10 * 16; | 496 const size_t kSamples = 10 * 16; |
496 const size_t kPayloadBytes = kSamples * 2; | 497 const size_t kPayloadBytes = kSamples * 2; |
497 for (size_t i = 0; i < num_frames; ++i) { | 498 for (size_t i = 0; i < num_frames; ++i) { |
498 uint16_t payload[kSamples] = {0}; | 499 const uint8_t payload[kPayloadBytes] = {0}; |
499 WebRtcRTPHeader rtp_info; | 500 WebRtcRTPHeader rtp_info; |
500 rtp_info.header.sequenceNumber = i; | 501 rtp_info.header.sequenceNumber = i; |
501 rtp_info.header.timestamp = i * kSamples; | 502 rtp_info.header.timestamp = i * kSamples; |
502 rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC. | 503 rtp_info.header.ssrc = 0x1234; // Just an arbitrary SSRC. |
503 rtp_info.header.payloadType = 94; // PCM16b WB codec. | 504 rtp_info.header.payloadType = 94; // PCM16b WB codec. |
504 rtp_info.header.markerBit = 0; | 505 rtp_info.header.markerBit = 0; |
505 ASSERT_EQ(0, neteq_->InsertPacket( | 506 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
506 rtp_info, | |
507 reinterpret_cast<uint8_t*>(payload), | |
508 kPayloadBytes, 0)); | |
509 } | 507 } |
510 // Pull out all data. | 508 // Pull out all data. |
511 for (size_t i = 0; i < num_frames; ++i) { | 509 for (size_t i = 0; i < num_frames; ++i) { |
512 size_t out_len; | 510 size_t out_len; |
513 int num_channels; | 511 int num_channels; |
514 NetEqOutputType type; | 512 NetEqOutputType type; |
515 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 513 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
516 &num_channels, &type)); | 514 &num_channels, &type)); |
517 ASSERT_EQ(kBlockSize16kHz, out_len); | 515 ASSERT_EQ(kBlockSize16kHz, out_len); |
518 } | 516 } |
(...skipping 23 matching lines...) Expand all Loading... |
542 const size_t kSamples = 10 * 16; | 540 const size_t kSamples = 10 * 16; |
543 const size_t kPayloadBytes = kSamples * 2; | 541 const size_t kPayloadBytes = kSamples * 2; |
544 while (frame_index < kNumFrames) { | 542 while (frame_index < kNumFrames) { |
545 // Insert one packet each time, except every 10th time where we insert two | 543 // Insert one packet each time, except every 10th time where we insert two |
546 // packets at once. This will create a negative clock-drift of approx. 10%. | 544 // packets at once. This will create a negative clock-drift of approx. 10%. |
547 int num_packets = (frame_index % 10 == 0 ? 2 : 1); | 545 int num_packets = (frame_index % 10 == 0 ? 2 : 1); |
548 for (int n = 0; n < num_packets; ++n) { | 546 for (int n = 0; n < num_packets; ++n) { |
549 uint8_t payload[kPayloadBytes] = {0}; | 547 uint8_t payload[kPayloadBytes] = {0}; |
550 WebRtcRTPHeader rtp_info; | 548 WebRtcRTPHeader rtp_info; |
551 PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); | 549 PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
552 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | 550 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
553 ++frame_index; | 551 ++frame_index; |
554 } | 552 } |
555 | 553 |
556 // Pull out data once. | 554 // Pull out data once. |
557 size_t out_len; | 555 size_t out_len; |
558 int num_channels; | 556 int num_channels; |
559 NetEqOutputType type; | 557 NetEqOutputType type; |
560 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 558 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
561 &num_channels, &type)); | 559 &num_channels, &type)); |
562 ASSERT_EQ(kBlockSize16kHz, out_len); | 560 ASSERT_EQ(kBlockSize16kHz, out_len); |
(...skipping 10 matching lines...) Expand all Loading... |
573 const size_t kSamples = 10 * 16; | 571 const size_t kSamples = 10 * 16; |
574 const size_t kPayloadBytes = kSamples * 2; | 572 const size_t kPayloadBytes = kSamples * 2; |
575 for (int i = 0; i < kNumFrames; ++i) { | 573 for (int i = 0; i < kNumFrames; ++i) { |
576 // Insert one packet each time, except every 10th time where we don't insert | 574 // Insert one packet each time, except every 10th time where we don't insert |
577 // any packet. This will create a positive clock-drift of approx. 11%. | 575 // any packet. This will create a positive clock-drift of approx. 11%. |
578 int num_packets = (i % 10 == 9 ? 0 : 1); | 576 int num_packets = (i % 10 == 9 ? 0 : 1); |
579 for (int n = 0; n < num_packets; ++n) { | 577 for (int n = 0; n < num_packets; ++n) { |
580 uint8_t payload[kPayloadBytes] = {0}; | 578 uint8_t payload[kPayloadBytes] = {0}; |
581 WebRtcRTPHeader rtp_info; | 579 WebRtcRTPHeader rtp_info; |
582 PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); | 580 PopulateRtpInfo(frame_index, frame_index * kSamples, &rtp_info); |
583 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | 581 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
584 ++frame_index; | 582 ++frame_index; |
585 } | 583 } |
586 | 584 |
587 // Pull out data once. | 585 // Pull out data once. |
588 size_t out_len; | 586 size_t out_len; |
589 int num_channels; | 587 int num_channels; |
590 NetEqOutputType type; | 588 NetEqOutputType type; |
591 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 589 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
592 &num_channels, &type)); | 590 &num_channels, &type)); |
593 ASSERT_EQ(kBlockSize16kHz, out_len); | 591 ASSERT_EQ(kBlockSize16kHz, out_len); |
(...skipping 22 matching lines...) Expand all Loading... |
616 | 614 |
617 // Insert speech for 5 seconds. | 615 // Insert speech for 5 seconds. |
618 const int kSpeechDurationMs = 5000; | 616 const int kSpeechDurationMs = 5000; |
619 for (t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { | 617 for (t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { |
620 // Each turn in this for loop is 10 ms. | 618 // Each turn in this for loop is 10 ms. |
621 while (next_input_time_ms <= t_ms) { | 619 while (next_input_time_ms <= t_ms) { |
622 // Insert one 30 ms speech frame. | 620 // Insert one 30 ms speech frame. |
623 uint8_t payload[kPayloadBytes] = {0}; | 621 uint8_t payload[kPayloadBytes] = {0}; |
624 WebRtcRTPHeader rtp_info; | 622 WebRtcRTPHeader rtp_info; |
625 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 623 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
626 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | 624 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
627 ++seq_no; | 625 ++seq_no; |
628 timestamp += kSamples; | 626 timestamp += kSamples; |
629 next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor; | 627 next_input_time_ms += static_cast<double>(kFrameSizeMs) * drift_factor; |
630 } | 628 } |
631 // Pull out data once. | 629 // Pull out data once. |
632 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 630 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
633 &num_channels, &type)); | 631 &num_channels, &type)); |
634 ASSERT_EQ(kBlockSize16kHz, out_len); | 632 ASSERT_EQ(kBlockSize16kHz, out_len); |
635 } | 633 } |
636 | 634 |
637 EXPECT_EQ(kOutputNormal, type); | 635 EXPECT_EQ(kOutputNormal, type); |
638 int32_t delay_before = timestamp - PlayoutTimestamp(); | 636 int32_t delay_before = timestamp - PlayoutTimestamp(); |
639 | 637 |
640 // Insert CNG for 1 minute (= 60000 ms). | 638 // Insert CNG for 1 minute (= 60000 ms). |
641 const int kCngPeriodMs = 100; | 639 const int kCngPeriodMs = 100; |
642 const int kCngPeriodSamples = kCngPeriodMs * 16; // Period in 16 kHz samples. | 640 const int kCngPeriodSamples = kCngPeriodMs * 16; // Period in 16 kHz samples. |
643 const int kCngDurationMs = 60000; | 641 const int kCngDurationMs = 60000; |
644 for (; t_ms < kSpeechDurationMs + kCngDurationMs; t_ms += 10) { | 642 for (; t_ms < kSpeechDurationMs + kCngDurationMs; t_ms += 10) { |
645 // Each turn in this for loop is 10 ms. | 643 // Each turn in this for loop is 10 ms. |
646 while (next_input_time_ms <= t_ms) { | 644 while (next_input_time_ms <= t_ms) { |
647 // Insert one CNG frame each 100 ms. | 645 // Insert one CNG frame each 100 ms. |
648 uint8_t payload[kPayloadBytes]; | 646 uint8_t payload[kPayloadBytes]; |
649 size_t payload_len; | 647 size_t payload_len; |
650 WebRtcRTPHeader rtp_info; | 648 WebRtcRTPHeader rtp_info; |
651 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); | 649 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
652 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); | 650 ASSERT_EQ(0, neteq_->InsertPacket( |
| 651 rtp_info, |
| 652 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
653 ++seq_no; | 653 ++seq_no; |
654 timestamp += kCngPeriodSamples; | 654 timestamp += kCngPeriodSamples; |
655 next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor; | 655 next_input_time_ms += static_cast<double>(kCngPeriodMs) * drift_factor; |
656 } | 656 } |
657 // Pull out data once. | 657 // Pull out data once. |
658 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 658 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
659 &num_channels, &type)); | 659 &num_channels, &type)); |
660 ASSERT_EQ(kBlockSize16kHz, out_len); | 660 ASSERT_EQ(kBlockSize16kHz, out_len); |
661 } | 661 } |
662 | 662 |
(...skipping 26 matching lines...) Expand all Loading... |
689 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); | 689 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); |
690 ASSERT_EQ(kBlockSize16kHz, out_len); | 690 ASSERT_EQ(kBlockSize16kHz, out_len); |
691 EXPECT_EQ(kOutputCNG, type); | 691 EXPECT_EQ(kOutputCNG, type); |
692 t_ms += 10; | 692 t_ms += 10; |
693 } | 693 } |
694 // Insert one CNG frame each 100 ms. | 694 // Insert one CNG frame each 100 ms. |
695 uint8_t payload[kPayloadBytes]; | 695 uint8_t payload[kPayloadBytes]; |
696 size_t payload_len; | 696 size_t payload_len; |
697 WebRtcRTPHeader rtp_info; | 697 WebRtcRTPHeader rtp_info; |
698 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); | 698 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
699 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); | 699 ASSERT_EQ(0, neteq_->InsertPacket( |
| 700 rtp_info, |
| 701 rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
700 ++seq_no; | 702 ++seq_no; |
701 timestamp += kCngPeriodSamples; | 703 timestamp += kCngPeriodSamples; |
702 next_input_time_ms += kCngPeriodMs * drift_factor; | 704 next_input_time_ms += kCngPeriodMs * drift_factor; |
703 } | 705 } |
704 } | 706 } |
705 | 707 |
706 // Insert speech again until output type is speech. | 708 // Insert speech again until output type is speech. |
707 double speech_restart_time_ms = t_ms; | 709 double speech_restart_time_ms = t_ms; |
708 while (type != kOutputNormal) { | 710 while (type != kOutputNormal) { |
709 // Each turn in this for loop is 10 ms. | 711 // Each turn in this for loop is 10 ms. |
710 while (next_input_time_ms <= t_ms) { | 712 while (next_input_time_ms <= t_ms) { |
711 // Insert one 30 ms speech frame. | 713 // Insert one 30 ms speech frame. |
712 uint8_t payload[kPayloadBytes] = {0}; | 714 uint8_t payload[kPayloadBytes] = {0}; |
713 WebRtcRTPHeader rtp_info; | 715 WebRtcRTPHeader rtp_info; |
714 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 716 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
715 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | 717 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
716 ++seq_no; | 718 ++seq_no; |
717 timestamp += kSamples; | 719 timestamp += kSamples; |
718 next_input_time_ms += kFrameSizeMs * drift_factor; | 720 next_input_time_ms += kFrameSizeMs * drift_factor; |
719 } | 721 } |
720 // Pull out data once. | 722 // Pull out data once. |
721 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 723 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
722 &num_channels, &type)); | 724 &num_channels, &type)); |
723 ASSERT_EQ(kBlockSize16kHz, out_len); | 725 ASSERT_EQ(kBlockSize16kHz, out_len); |
724 // Increase clock. | 726 // Increase clock. |
725 t_ms += 10; | 727 t_ms += 10; |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 kDelayToleranceMs, | 818 kDelayToleranceMs, |
817 kMaxTimeToSpeechMs); | 819 kMaxTimeToSpeechMs); |
818 } | 820 } |
819 | 821 |
820 TEST_F(NetEqDecodingTest, UnknownPayloadType) { | 822 TEST_F(NetEqDecodingTest, UnknownPayloadType) { |
821 const size_t kPayloadBytes = 100; | 823 const size_t kPayloadBytes = 100; |
822 uint8_t payload[kPayloadBytes] = {0}; | 824 uint8_t payload[kPayloadBytes] = {0}; |
823 WebRtcRTPHeader rtp_info; | 825 WebRtcRTPHeader rtp_info; |
824 PopulateRtpInfo(0, 0, &rtp_info); | 826 PopulateRtpInfo(0, 0, &rtp_info); |
825 rtp_info.header.payloadType = 1; // Not registered as a decoder. | 827 rtp_info.header.payloadType = 1; // Not registered as a decoder. |
826 EXPECT_EQ(NetEq::kFail, | 828 EXPECT_EQ(NetEq::kFail, neteq_->InsertPacket(rtp_info, payload, 0)); |
827 neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | |
828 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); | 829 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
829 } | 830 } |
830 | 831 |
831 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) | 832 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
832 #define IF_ISAC(x) x | 833 #define IF_ISAC(x) x |
833 #else | 834 #else |
834 #define IF_ISAC(x) DISABLED_##x | 835 #define IF_ISAC(x) DISABLED_##x |
835 #endif | 836 #endif |
836 | 837 |
837 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(IF_ISAC(DecoderError))) { | 838 TEST_F(NetEqDecodingTest, DISABLED_ON_ANDROID(IF_ISAC(DecoderError))) { |
838 const size_t kPayloadBytes = 100; | 839 const size_t kPayloadBytes = 100; |
839 uint8_t payload[kPayloadBytes] = {0}; | 840 uint8_t payload[kPayloadBytes] = {0}; |
840 WebRtcRTPHeader rtp_info; | 841 WebRtcRTPHeader rtp_info; |
841 PopulateRtpInfo(0, 0, &rtp_info); | 842 PopulateRtpInfo(0, 0, &rtp_info); |
842 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. | 843 rtp_info.header.payloadType = 103; // iSAC, but the payload is invalid. |
843 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | 844 EXPECT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
844 NetEqOutputType type; | 845 NetEqOutputType type; |
845 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call | 846 // Set all of |out_data_| to 1, and verify that it was set to 0 by the call |
846 // to GetAudio. | 847 // to GetAudio. |
847 for (size_t i = 0; i < kMaxBlockSize; ++i) { | 848 for (size_t i = 0; i < kMaxBlockSize; ++i) { |
848 out_data_[i] = 1; | 849 out_data_[i] = 1; |
849 } | 850 } |
850 int num_channels; | 851 int num_channels; |
851 size_t samples_per_channel; | 852 size_t samples_per_channel; |
852 EXPECT_EQ(NetEq::kFail, | 853 EXPECT_EQ(NetEq::kFail, |
853 neteq_->GetAudio(kMaxBlockSize, out_data_, | 854 neteq_->GetAudio(kMaxBlockSize, out_data_, |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
940 uint32_t receive_timestamp = 0; | 941 uint32_t receive_timestamp = 0; |
941 for (int n = 0; n < 10; ++n) { // Insert few packets and get audio. | 942 for (int n = 0; n < 10; ++n) { // Insert few packets and get audio. |
942 auto block = input.GetNextBlock(); | 943 auto block = input.GetNextBlock(); |
943 ASSERT_EQ(expected_samples_per_channel, block.size()); | 944 ASSERT_EQ(expected_samples_per_channel, block.size()); |
944 size_t enc_len_bytes = | 945 size_t enc_len_bytes = |
945 WebRtcPcm16b_Encode(block.data(), block.size(), payload); | 946 WebRtcPcm16b_Encode(block.data(), block.size(), payload); |
946 ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); | 947 ASSERT_EQ(enc_len_bytes, expected_samples_per_channel * 2); |
947 | 948 |
948 number_channels = 0; | 949 number_channels = 0; |
949 samples_per_channel = 0; | 950 samples_per_channel = 0; |
950 ASSERT_EQ(0, | 951 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, rtc::ArrayView<const uint8_t>( |
951 neteq_->InsertPacket(rtp_info, payload, enc_len_bytes, | 952 payload, enc_len_bytes), |
952 receive_timestamp)); | 953 receive_timestamp)); |
953 ASSERT_EQ(0, | 954 ASSERT_EQ(0, |
954 neteq_->GetAudio(kBlockSize32kHz, | 955 neteq_->GetAudio(kBlockSize32kHz, |
955 output, | 956 output, |
956 &samples_per_channel, | 957 &samples_per_channel, |
957 &number_channels, | 958 &number_channels, |
958 &type)); | 959 &type)); |
959 ASSERT_EQ(1, number_channels); | 960 ASSERT_EQ(1, number_channels); |
960 ASSERT_EQ(expected_samples_per_channel, samples_per_channel); | 961 ASSERT_EQ(expected_samples_per_channel, samples_per_channel); |
961 ASSERT_EQ(kOutputNormal, type); | 962 ASSERT_EQ(kOutputNormal, type); |
962 | 963 |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1101 | 1102 |
1102 PopulateRtpInfo(0, 0, &rtp_info); | 1103 PopulateRtpInfo(0, 0, &rtp_info); |
1103 rtp_info.header.payloadType = kPcm16WbPayloadType; | 1104 rtp_info.header.payloadType = kPcm16WbPayloadType; |
1104 | 1105 |
1105 // The first packet injected cannot be sync-packet. | 1106 // The first packet injected cannot be sync-packet. |
1106 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); | 1107 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
1107 | 1108 |
1108 // Payload length of 10 ms PCM16 16 kHz. | 1109 // Payload length of 10 ms PCM16 16 kHz. |
1109 const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); | 1110 const size_t kPayloadBytes = kBlockSize16kHz * sizeof(int16_t); |
1110 uint8_t payload[kPayloadBytes] = {0}; | 1111 uint8_t payload[kPayloadBytes] = {0}; |
1111 ASSERT_EQ(0, neteq_->InsertPacket( | 1112 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
1112 rtp_info, payload, kPayloadBytes, receive_timestamp)); | |
1113 | 1113 |
1114 // Next packet. Last packet contained 10 ms audio. | 1114 // Next packet. Last packet contained 10 ms audio. |
1115 rtp_info.header.sequenceNumber++; | 1115 rtp_info.header.sequenceNumber++; |
1116 rtp_info.header.timestamp += kBlockSize16kHz; | 1116 rtp_info.header.timestamp += kBlockSize16kHz; |
1117 receive_timestamp += kBlockSize16kHz; | 1117 receive_timestamp += kBlockSize16kHz; |
1118 | 1118 |
1119 // Unacceptable payload types CNG, AVT (DTMF), RED. | 1119 // Unacceptable payload types CNG, AVT (DTMF), RED. |
1120 rtp_info.header.payloadType = kCngNbPayloadType; | 1120 rtp_info.header.payloadType = kCngNbPayloadType; |
1121 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); | 1121 EXPECT_EQ(-1, neteq_->InsertSyncPacket(rtp_info, receive_timestamp)); |
1122 | 1122 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 for (size_t n = 0; n < kPayloadBytes; ++n) { | 1164 for (size_t n = 0; n < kPayloadBytes; ++n) { |
1165 payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence. | 1165 payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence. |
1166 } | 1166 } |
1167 // Insert some packets which decode to noise. We are not interested in | 1167 // Insert some packets which decode to noise. We are not interested in |
1168 // actual decoded values. | 1168 // actual decoded values. |
1169 NetEqOutputType output_type; | 1169 NetEqOutputType output_type; |
1170 int num_channels; | 1170 int num_channels; |
1171 size_t samples_per_channel; | 1171 size_t samples_per_channel; |
1172 uint32_t receive_timestamp = 0; | 1172 uint32_t receive_timestamp = 0; |
1173 for (int n = 0; n < 100; ++n) { | 1173 for (int n = 0; n < 100; ++n) { |
1174 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, | 1174 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
1175 receive_timestamp)); | |
1176 ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded, | 1175 ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded, |
1177 &samples_per_channel, &num_channels, | 1176 &samples_per_channel, &num_channels, |
1178 &output_type)); | 1177 &output_type)); |
1179 ASSERT_EQ(kBlockSize16kHz, samples_per_channel); | 1178 ASSERT_EQ(kBlockSize16kHz, samples_per_channel); |
1180 ASSERT_EQ(1, num_channels); | 1179 ASSERT_EQ(1, num_channels); |
1181 | 1180 |
1182 rtp_info.header.sequenceNumber++; | 1181 rtp_info.header.sequenceNumber++; |
1183 rtp_info.header.timestamp += kBlockSize16kHz; | 1182 rtp_info.header.timestamp += kBlockSize16kHz; |
1184 receive_timestamp += kBlockSize16kHz; | 1183 receive_timestamp += kBlockSize16kHz; |
1185 } | 1184 } |
(...skipping 14 matching lines...) Expand all Loading... |
1200 EXPECT_TRUE(IsAllZero(decoded, samples_per_channel * num_channels)); | 1199 EXPECT_TRUE(IsAllZero(decoded, samples_per_channel * num_channels)); |
1201 } | 1200 } |
1202 rtp_info.header.sequenceNumber++; | 1201 rtp_info.header.sequenceNumber++; |
1203 rtp_info.header.timestamp += kBlockSize16kHz; | 1202 rtp_info.header.timestamp += kBlockSize16kHz; |
1204 receive_timestamp += kBlockSize16kHz; | 1203 receive_timestamp += kBlockSize16kHz; |
1205 } | 1204 } |
1206 | 1205 |
1207 // We insert regular packets, if sync packet are not correctly buffered then | 1206 // We insert regular packets, if sync packet are not correctly buffered then |
1208 // network statistics would show some packet loss. | 1207 // network statistics would show some packet loss. |
1209 for (int n = 0; n <= algorithmic_frame_delay + 10; ++n) { | 1208 for (int n = 0; n <= algorithmic_frame_delay + 10; ++n) { |
1210 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, | 1209 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
1211 receive_timestamp)); | |
1212 ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded, | 1210 ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded, |
1213 &samples_per_channel, &num_channels, | 1211 &samples_per_channel, &num_channels, |
1214 &output_type)); | 1212 &output_type)); |
1215 if (n >= algorithmic_frame_delay + 1) { | 1213 if (n >= algorithmic_frame_delay + 1) { |
1216 // Expect that this frame contain samples from regular RTP. | 1214 // Expect that this frame contain samples from regular RTP. |
1217 EXPECT_TRUE(IsAllNonZero(decoded, samples_per_channel * num_channels)); | 1215 EXPECT_TRUE(IsAllNonZero(decoded, samples_per_channel * num_channels)); |
1218 } | 1216 } |
1219 rtp_info.header.sequenceNumber++; | 1217 rtp_info.header.sequenceNumber++; |
1220 rtp_info.header.timestamp += kBlockSize16kHz; | 1218 rtp_info.header.timestamp += kBlockSize16kHz; |
1221 receive_timestamp += kBlockSize16kHz; | 1219 receive_timestamp += kBlockSize16kHz; |
(...skipping 21 matching lines...) Expand all Loading... |
1243 payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence. | 1241 payload[n] = (rand() & 0xF0) + 1; // Non-zero random sequence. |
1244 } | 1242 } |
1245 // Insert some packets which decode to noise. We are not interested in | 1243 // Insert some packets which decode to noise. We are not interested in |
1246 // actual decoded values. | 1244 // actual decoded values. |
1247 NetEqOutputType output_type; | 1245 NetEqOutputType output_type; |
1248 int num_channels; | 1246 int num_channels; |
1249 size_t samples_per_channel; | 1247 size_t samples_per_channel; |
1250 uint32_t receive_timestamp = 0; | 1248 uint32_t receive_timestamp = 0; |
1251 int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1; | 1249 int algorithmic_frame_delay = algorithmic_delay_ms_ / 10 + 1; |
1252 for (int n = 0; n < algorithmic_frame_delay; ++n) { | 1250 for (int n = 0; n < algorithmic_frame_delay; ++n) { |
1253 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, | 1251 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
1254 receive_timestamp)); | |
1255 ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded, | 1252 ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded, |
1256 &samples_per_channel, &num_channels, | 1253 &samples_per_channel, &num_channels, |
1257 &output_type)); | 1254 &output_type)); |
1258 ASSERT_EQ(kBlockSize16kHz, samples_per_channel); | 1255 ASSERT_EQ(kBlockSize16kHz, samples_per_channel); |
1259 ASSERT_EQ(1, num_channels); | 1256 ASSERT_EQ(1, num_channels); |
1260 rtp_info.header.sequenceNumber++; | 1257 rtp_info.header.sequenceNumber++; |
1261 rtp_info.header.timestamp += kBlockSize16kHz; | 1258 rtp_info.header.timestamp += kBlockSize16kHz; |
1262 receive_timestamp += kBlockSize16kHz; | 1259 receive_timestamp += kBlockSize16kHz; |
1263 } | 1260 } |
1264 const int kNumSyncPackets = 10; | 1261 const int kNumSyncPackets = 10; |
(...skipping 11 matching lines...) Expand all Loading... |
1276 NetEqNetworkStatistics network_stats; | 1273 NetEqNetworkStatistics network_stats; |
1277 ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); | 1274 ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
1278 EXPECT_EQ(kNumSyncPackets * 10 + algorithmic_delay_ms_, | 1275 EXPECT_EQ(kNumSyncPackets * 10 + algorithmic_delay_ms_, |
1279 network_stats.current_buffer_size_ms); | 1276 network_stats.current_buffer_size_ms); |
1280 | 1277 |
1281 // Rewind |rtp_info| to that of the first sync packet. | 1278 // Rewind |rtp_info| to that of the first sync packet. |
1282 memcpy(&rtp_info, &first_sync_packet_rtp_info, sizeof(rtp_info)); | 1279 memcpy(&rtp_info, &first_sync_packet_rtp_info, sizeof(rtp_info)); |
1283 | 1280 |
1284 // Insert. | 1281 // Insert. |
1285 for (int n = 0; n < kNumSyncPackets; ++n) { | 1282 for (int n = 0; n < kNumSyncPackets; ++n) { |
1286 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, | 1283 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
1287 receive_timestamp)); | |
1288 rtp_info.header.sequenceNumber++; | 1284 rtp_info.header.sequenceNumber++; |
1289 rtp_info.header.timestamp += kBlockSize16kHz; | 1285 rtp_info.header.timestamp += kBlockSize16kHz; |
1290 receive_timestamp += kBlockSize16kHz; | 1286 receive_timestamp += kBlockSize16kHz; |
1291 } | 1287 } |
1292 | 1288 |
1293 // Decode. | 1289 // Decode. |
1294 for (int n = 0; n < kNumSyncPackets; ++n) { | 1290 for (int n = 0; n < kNumSyncPackets; ++n) { |
1295 ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded, | 1291 ASSERT_EQ(0, neteq_->GetAudio(kBlockSize16kHz, decoded, |
1296 &samples_per_channel, &num_channels, | 1292 &samples_per_channel, &num_channels, |
1297 &output_type)); | 1293 &output_type)); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 for (double t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { | 1325 for (double t_ms = 0; t_ms < kSpeechDurationMs; t_ms += 10) { |
1330 // Each turn in this for loop is 10 ms. | 1326 // Each turn in this for loop is 10 ms. |
1331 while (next_input_time_ms <= t_ms) { | 1327 while (next_input_time_ms <= t_ms) { |
1332 // Insert one 30 ms speech frame. | 1328 // Insert one 30 ms speech frame. |
1333 uint8_t payload[kPayloadBytes] = {0}; | 1329 uint8_t payload[kPayloadBytes] = {0}; |
1334 WebRtcRTPHeader rtp_info; | 1330 WebRtcRTPHeader rtp_info; |
1335 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 1331 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
1336 if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) { | 1332 if (drop_seq_numbers.find(seq_no) == drop_seq_numbers.end()) { |
1337 // This sequence number was not in the set to drop. Insert it. | 1333 // This sequence number was not in the set to drop. Insert it. |
1338 ASSERT_EQ(0, | 1334 ASSERT_EQ(0, |
1339 neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, | 1335 neteq_->InsertPacket(rtp_info, payload, receive_timestamp)); |
1340 receive_timestamp)); | |
1341 ++packets_inserted; | 1336 ++packets_inserted; |
1342 } | 1337 } |
1343 NetEqNetworkStatistics network_stats; | 1338 NetEqNetworkStatistics network_stats; |
1344 ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); | 1339 ASSERT_EQ(0, neteq_->NetworkStatistics(&network_stats)); |
1345 | 1340 |
1346 // Due to internal NetEq logic, preferred buffer-size is about 4 times the | 1341 // Due to internal NetEq logic, preferred buffer-size is about 4 times the |
1347 // packet size for first few packets. Therefore we refrain from checking | 1342 // packet size for first few packets. Therefore we refrain from checking |
1348 // the criteria. | 1343 // the criteria. |
1349 if (packets_inserted > 4) { | 1344 if (packets_inserted > 4) { |
1350 // Expect preferred and actual buffer size to be no more than 2 frames. | 1345 // 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... |
1418 algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); | 1413 algorithmic_delay_ms_ * kSampleRateKhz, 5 * kSampleRateKhz / 8); |
1419 // Insert three speech packets. Three are needed to get the frame length | 1414 // Insert three speech packets. Three are needed to get the frame length |
1420 // correct. | 1415 // correct. |
1421 size_t out_len; | 1416 size_t out_len; |
1422 int num_channels; | 1417 int num_channels; |
1423 NetEqOutputType type; | 1418 NetEqOutputType type; |
1424 uint8_t payload[kPayloadBytes] = {0}; | 1419 uint8_t payload[kPayloadBytes] = {0}; |
1425 WebRtcRTPHeader rtp_info; | 1420 WebRtcRTPHeader rtp_info; |
1426 for (int i = 0; i < 3; ++i) { | 1421 for (int i = 0; i < 3; ++i) { |
1427 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 1422 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
1428 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | 1423 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
1429 ++seq_no; | 1424 ++seq_no; |
1430 timestamp += kSamples; | 1425 timestamp += kSamples; |
1431 | 1426 |
1432 // Pull audio once. | 1427 // Pull audio once. |
1433 ASSERT_EQ(0, | 1428 ASSERT_EQ(0, |
1434 neteq_->GetAudio( | 1429 neteq_->GetAudio( |
1435 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); | 1430 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); |
1436 ASSERT_EQ(kBlockSize16kHz, out_len); | 1431 ASSERT_EQ(kBlockSize16kHz, out_len); |
1437 } | 1432 } |
1438 // Verify speech output. | 1433 // Verify speech output. |
1439 EXPECT_EQ(kOutputNormal, type); | 1434 EXPECT_EQ(kOutputNormal, type); |
1440 | 1435 |
1441 // Insert same CNG packet twice. | 1436 // Insert same CNG packet twice. |
1442 const int kCngPeriodMs = 100; | 1437 const int kCngPeriodMs = 100; |
1443 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; | 1438 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; |
1444 size_t payload_len; | 1439 size_t payload_len; |
1445 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); | 1440 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
1446 // This is the first time this CNG packet is inserted. | 1441 // This is the first time this CNG packet is inserted. |
1447 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); | 1442 ASSERT_EQ( |
| 1443 0, neteq_->InsertPacket( |
| 1444 rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
1448 | 1445 |
1449 // Pull audio once and make sure CNG is played. | 1446 // Pull audio once and make sure CNG is played. |
1450 ASSERT_EQ(0, | 1447 ASSERT_EQ(0, |
1451 neteq_->GetAudio( | 1448 neteq_->GetAudio( |
1452 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); | 1449 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); |
1453 ASSERT_EQ(kBlockSize16kHz, out_len); | 1450 ASSERT_EQ(kBlockSize16kHz, out_len); |
1454 EXPECT_EQ(kOutputCNG, type); | 1451 EXPECT_EQ(kOutputCNG, type); |
1455 EXPECT_EQ(timestamp - algorithmic_delay_samples, PlayoutTimestamp()); | 1452 EXPECT_EQ(timestamp - algorithmic_delay_samples, PlayoutTimestamp()); |
1456 | 1453 |
1457 // Insert the same CNG packet again. Note that at this point it is old, since | 1454 // Insert the same CNG packet again. Note that at this point it is old, since |
1458 // we have already decoded the first copy of it. | 1455 // we have already decoded the first copy of it. |
1459 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); | 1456 ASSERT_EQ( |
| 1457 0, neteq_->InsertPacket( |
| 1458 rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
1460 | 1459 |
1461 // Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since | 1460 // Pull audio until we have played |kCngPeriodMs| of CNG. Start at 10 ms since |
1462 // we have already pulled out CNG once. | 1461 // we have already pulled out CNG once. |
1463 for (int cng_time_ms = 10; cng_time_ms < kCngPeriodMs; cng_time_ms += 10) { | 1462 for (int cng_time_ms = 10; cng_time_ms < kCngPeriodMs; cng_time_ms += 10) { |
1464 ASSERT_EQ(0, | 1463 ASSERT_EQ(0, |
1465 neteq_->GetAudio( | 1464 neteq_->GetAudio( |
1466 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); | 1465 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); |
1467 ASSERT_EQ(kBlockSize16kHz, out_len); | 1466 ASSERT_EQ(kBlockSize16kHz, out_len); |
1468 EXPECT_EQ(kOutputCNG, type); | 1467 EXPECT_EQ(kOutputCNG, type); |
1469 EXPECT_EQ(timestamp - algorithmic_delay_samples, | 1468 EXPECT_EQ(timestamp - algorithmic_delay_samples, |
1470 PlayoutTimestamp()); | 1469 PlayoutTimestamp()); |
1471 } | 1470 } |
1472 | 1471 |
1473 // Insert speech again. | 1472 // Insert speech again. |
1474 ++seq_no; | 1473 ++seq_no; |
1475 timestamp += kCngPeriodSamples; | 1474 timestamp += kCngPeriodSamples; |
1476 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 1475 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
1477 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | 1476 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
1478 | 1477 |
1479 // Pull audio once and verify that the output is speech again. | 1478 // Pull audio once and verify that the output is speech again. |
1480 ASSERT_EQ(0, | 1479 ASSERT_EQ(0, |
1481 neteq_->GetAudio( | 1480 neteq_->GetAudio( |
1482 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); | 1481 kMaxBlockSize, out_data_, &out_len, &num_channels, &type)); |
1483 ASSERT_EQ(kBlockSize16kHz, out_len); | 1482 ASSERT_EQ(kBlockSize16kHz, out_len); |
1484 EXPECT_EQ(kOutputNormal, type); | 1483 EXPECT_EQ(kOutputNormal, type); |
1485 EXPECT_EQ(timestamp + kSamples - algorithmic_delay_samples, | 1484 EXPECT_EQ(timestamp + kSamples - algorithmic_delay_samples, |
1486 PlayoutTimestamp()); | 1485 PlayoutTimestamp()); |
1487 } | 1486 } |
(...skipping 14 matching lines...) Expand all Loading... |
1502 const int kSamples = kFrameSizeMs * kSampleRateKhz; | 1501 const int kSamples = kFrameSizeMs * kSampleRateKhz; |
1503 const int kPayloadBytes = kSamples * 2; | 1502 const int kPayloadBytes = kSamples * 2; |
1504 const int kCngPeriodMs = 100; | 1503 const int kCngPeriodMs = 100; |
1505 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; | 1504 const int kCngPeriodSamples = kCngPeriodMs * kSampleRateKhz; |
1506 size_t payload_len; | 1505 size_t payload_len; |
1507 | 1506 |
1508 uint8_t payload[kPayloadBytes] = {0}; | 1507 uint8_t payload[kPayloadBytes] = {0}; |
1509 WebRtcRTPHeader rtp_info; | 1508 WebRtcRTPHeader rtp_info; |
1510 | 1509 |
1511 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); | 1510 PopulateCng(seq_no, timestamp, &rtp_info, payload, &payload_len); |
1512 ASSERT_EQ(NetEq::kOK, | 1511 ASSERT_EQ( |
1513 neteq_->InsertPacket(rtp_info, payload, payload_len, 0)); | 1512 NetEq::kOK, |
| 1513 neteq_->InsertPacket( |
| 1514 rtp_info, rtc::ArrayView<const uint8_t>(payload, payload_len), 0)); |
1514 ++seq_no; | 1515 ++seq_no; |
1515 timestamp += kCngPeriodSamples; | 1516 timestamp += kCngPeriodSamples; |
1516 | 1517 |
1517 // Pull audio once and make sure CNG is played. | 1518 // Pull audio once and make sure CNG is played. |
1518 size_t out_len; | 1519 size_t out_len; |
1519 int num_channels; | 1520 int num_channels; |
1520 NetEqOutputType type; | 1521 NetEqOutputType type; |
1521 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 1522 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
1522 &num_channels, &type)); | 1523 &num_channels, &type)); |
1523 ASSERT_EQ(kBlockSize16kHz, out_len); | 1524 ASSERT_EQ(kBlockSize16kHz, out_len); |
1524 EXPECT_EQ(kOutputCNG, type); | 1525 EXPECT_EQ(kOutputCNG, type); |
1525 | 1526 |
1526 // Insert some speech packets. | 1527 // Insert some speech packets. |
1527 for (int i = 0; i < 3; ++i) { | 1528 for (int i = 0; i < 3; ++i) { |
1528 PopulateRtpInfo(seq_no, timestamp, &rtp_info); | 1529 PopulateRtpInfo(seq_no, timestamp, &rtp_info); |
1529 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, kPayloadBytes, 0)); | 1530 ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); |
1530 ++seq_no; | 1531 ++seq_no; |
1531 timestamp += kSamples; | 1532 timestamp += kSamples; |
1532 | 1533 |
1533 // Pull audio once. | 1534 // Pull audio once. |
1534 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, | 1535 ASSERT_EQ(0, neteq_->GetAudio(kMaxBlockSize, out_data_, &out_len, |
1535 &num_channels, &type)); | 1536 &num_channels, &type)); |
1536 ASSERT_EQ(kBlockSize16kHz, out_len); | 1537 ASSERT_EQ(kBlockSize16kHz, out_len); |
1537 } | 1538 } |
1538 // Verify speech output. | 1539 // Verify speech output. |
1539 EXPECT_EQ(kOutputNormal, type); | 1540 EXPECT_EQ(kOutputNormal, type); |
1540 } | 1541 } |
1541 | 1542 |
1542 } // namespace webrtc | 1543 } // namespace webrtc |
OLD | NEW |