| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 &decoder_, NetEqDecoder::kDecoderPCM16B, | 434 &decoder_, NetEqDecoder::kDecoderPCM16B, |
| 435 "dummy name", kPayloadType, kSampleRateHz)); | 435 "dummy name", kPayloadType, kSampleRateHz)); |
| 436 | 436 |
| 437 // Insert one packet. | 437 // Insert one packet. |
| 438 EXPECT_EQ(NetEq::kOK, | 438 EXPECT_EQ(NetEq::kOK, |
| 439 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 439 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 440 | 440 |
| 441 // Pull audio once. | 441 // Pull audio once. |
| 442 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 442 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 443 AudioFrame output; | 443 AudioFrame output; |
| 444 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 444 bool muted; |
| 445 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 446 ASSERT_FALSE(muted); |
| 445 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 447 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 446 EXPECT_EQ(1u, output.num_channels_); | 448 EXPECT_EQ(1u, output.num_channels_); |
| 447 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 449 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| 448 | 450 |
| 449 // Start with a simple check that the fake decoder is behaving as expected. | 451 // Start with a simple check that the fake decoder is behaving as expected. |
| 450 EXPECT_EQ(kPayloadLengthSamples, | 452 EXPECT_EQ(kPayloadLengthSamples, |
| 451 static_cast<size_t>(decoder_.next_value() - 1)); | 453 static_cast<size_t>(decoder_.next_value() - 1)); |
| 452 | 454 |
| 453 // The value of the last of the output samples is the same as the number of | 455 // The value of the last of the output samples is the same as the number of |
| 454 // samples played from the decoded packet. Thus, this number + the RTP | 456 // samples played from the decoded packet. Thus, this number + the RTP |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 513 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 512 "dummy name", kPayloadType, kSampleRateHz)); | 514 "dummy name", kPayloadType, kSampleRateHz)); |
| 513 | 515 |
| 514 // Insert one packet. | 516 // Insert one packet. |
| 515 EXPECT_EQ(NetEq::kOK, | 517 EXPECT_EQ(NetEq::kOK, |
| 516 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 518 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 517 | 519 |
| 518 // Pull audio once. | 520 // Pull audio once. |
| 519 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 521 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 520 AudioFrame output; | 522 AudioFrame output; |
| 521 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 523 bool muted; |
| 524 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 522 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 525 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 523 EXPECT_EQ(1u, output.num_channels_); | 526 EXPECT_EQ(1u, output.num_channels_); |
| 524 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 527 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| 525 | 528 |
| 526 // Insert two more packets. The first one is out of order, and is already too | 529 // Insert two more packets. The first one is out of order, and is already too |
| 527 // old, the second one is the expected next packet. | 530 // old, the second one is the expected next packet. |
| 528 rtp_header.header.sequenceNumber -= 1; | 531 rtp_header.header.sequenceNumber -= 1; |
| 529 rtp_header.header.timestamp -= kPayloadLengthSamples; | 532 rtp_header.header.timestamp -= kPayloadLengthSamples; |
| 530 payload[0] = 1; | 533 payload[0] = 1; |
| 531 EXPECT_EQ(NetEq::kOK, | 534 EXPECT_EQ(NetEq::kOK, |
| 532 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 535 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 533 rtp_header.header.sequenceNumber += 2; | 536 rtp_header.header.sequenceNumber += 2; |
| 534 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; | 537 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; |
| 535 payload[0] = 2; | 538 payload[0] = 2; |
| 536 EXPECT_EQ(NetEq::kOK, | 539 EXPECT_EQ(NetEq::kOK, |
| 537 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 540 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 538 | 541 |
| 539 // Expect only the second packet to be decoded (the one with "2" as the first | 542 // Expect only the second packet to be decoded (the one with "2" as the first |
| 540 // payload byte). | 543 // payload byte). |
| 541 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes, | 544 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes, |
| 542 kSampleRateHz, _, _)) | 545 kSampleRateHz, _, _)) |
| 543 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, | 546 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
| 544 dummy_output + kPayloadLengthSamples), | 547 dummy_output + kPayloadLengthSamples), |
| 545 SetArgPointee<4>(AudioDecoder::kSpeech), | 548 SetArgPointee<4>(AudioDecoder::kSpeech), |
| 546 Return(kPayloadLengthSamples))); | 549 Return(kPayloadLengthSamples))); |
| 547 | 550 |
| 548 // Pull audio once. | 551 // Pull audio once. |
| 549 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 552 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 550 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 553 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 551 EXPECT_EQ(1u, output.num_channels_); | 554 EXPECT_EQ(1u, output.num_channels_); |
| 552 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 555 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| 553 | 556 |
| 554 // Now check the packet buffer, and make sure it is empty, since the | 557 // Now check the packet buffer, and make sure it is empty, since the |
| 555 // out-of-order packet should have been discarded. | 558 // out-of-order packet should have been discarded. |
| 556 EXPECT_TRUE(packet_buffer_->Empty()); | 559 EXPECT_TRUE(packet_buffer_->Empty()); |
| 557 | 560 |
| 558 EXPECT_CALL(mock_decoder, Die()); | 561 EXPECT_CALL(mock_decoder, Die()); |
| 559 } | 562 } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 579 | 582 |
| 580 // Insert one packet. Note that we have not registered any payload type, so | 583 // Insert one packet. Note that we have not registered any payload type, so |
| 581 // this packet will be rejected. | 584 // this packet will be rejected. |
| 582 EXPECT_EQ(NetEq::kFail, | 585 EXPECT_EQ(NetEq::kFail, |
| 583 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 586 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 584 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); | 587 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
| 585 | 588 |
| 586 // Pull audio once. | 589 // Pull audio once. |
| 587 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 590 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 588 AudioFrame output; | 591 AudioFrame output; |
| 589 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 592 bool muted; |
| 593 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 590 ASSERT_LE(output.samples_per_channel_, kMaxOutputSize); | 594 ASSERT_LE(output.samples_per_channel_, kMaxOutputSize); |
| 591 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 595 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 592 EXPECT_EQ(1u, output.num_channels_); | 596 EXPECT_EQ(1u, output.num_channels_); |
| 593 EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); | 597 EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); |
| 594 | 598 |
| 595 // Register the payload type. | 599 // Register the payload type. |
| 596 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | 600 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 597 NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); | 601 NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); |
| 598 | 602 |
| 599 // Insert 10 packets. | 603 // Insert 10 packets. |
| 600 for (size_t i = 0; i < 10; ++i) { | 604 for (size_t i = 0; i < 10; ++i) { |
| 601 rtp_header.header.sequenceNumber++; | 605 rtp_header.header.sequenceNumber++; |
| 602 rtp_header.header.timestamp += kPayloadLengthSamples; | 606 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 603 EXPECT_EQ(NetEq::kOK, | 607 EXPECT_EQ(NetEq::kOK, |
| 604 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 608 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 605 EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); | 609 EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); |
| 606 } | 610 } |
| 607 | 611 |
| 608 // Pull audio repeatedly and make sure we get normal output, that is not PLC. | 612 // Pull audio repeatedly and make sure we get normal output, that is not PLC. |
| 609 for (size_t i = 0; i < 3; ++i) { | 613 for (size_t i = 0; i < 3; ++i) { |
| 610 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 614 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 611 ASSERT_LE(output.samples_per_channel_, kMaxOutputSize); | 615 ASSERT_LE(output.samples_per_channel_, kMaxOutputSize); |
| 612 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 616 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 613 EXPECT_EQ(1u, output.num_channels_); | 617 EXPECT_EQ(1u, output.num_channels_); |
| 614 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_) | 618 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_) |
| 615 << "NetEq did not decode the packets as expected."; | 619 << "NetEq did not decode the packets as expected."; |
| 616 } | 620 } |
| 617 } | 621 } |
| 618 | 622 |
| 619 // This test verifies that NetEq can handle comfort noise and enters/quits codec | 623 // This test verifies that NetEq can handle comfort noise and enters/quits codec |
| 620 // internal CNG mode properly. | 624 // internal CNG mode properly. |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech | 708 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech |
| 705 }; | 709 }; |
| 706 int expected_timestamp_increment[8] = { | 710 int expected_timestamp_increment[8] = { |
| 707 -1, // will not be used. | 711 -1, // will not be used. |
| 708 10 * kSampleRateKhz, | 712 10 * kSampleRateKhz, |
| 709 -1, -1, // timestamp will be empty during CNG mode; indicated by -1 here. | 713 -1, -1, // timestamp will be empty during CNG mode; indicated by -1 here. |
| 710 -1, -1, | 714 -1, -1, |
| 711 50 * kSampleRateKhz, 10 * kSampleRateKhz | 715 50 * kSampleRateKhz, 10 * kSampleRateKhz |
| 712 }; | 716 }; |
| 713 | 717 |
| 714 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 718 bool muted; |
| 719 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 715 rtc::Optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp(); | 720 rtc::Optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp(); |
| 716 ASSERT_TRUE(last_timestamp); | 721 ASSERT_TRUE(last_timestamp); |
| 717 | 722 |
| 718 // Lambda for verifying the timestamps. | 723 // Lambda for verifying the timestamps. |
| 719 auto verify_timestamp = [&last_timestamp, &expected_timestamp_increment]( | 724 auto verify_timestamp = [&last_timestamp, &expected_timestamp_increment]( |
| 720 rtc::Optional<uint32_t> ts, size_t i) { | 725 rtc::Optional<uint32_t> ts, size_t i) { |
| 721 if (expected_timestamp_increment[i] == -1) { | 726 if (expected_timestamp_increment[i] == -1) { |
| 722 // Expect to get an empty timestamp value during CNG and PLC. | 727 // Expect to get an empty timestamp value during CNG and PLC. |
| 723 EXPECT_FALSE(ts) << "i = " << i; | 728 EXPECT_FALSE(ts) << "i = " << i; |
| 724 } else { | 729 } else { |
| 725 ASSERT_TRUE(ts) << "i = " << i; | 730 ASSERT_TRUE(ts) << "i = " << i; |
| 726 EXPECT_EQ(*ts, *last_timestamp + expected_timestamp_increment[i]) | 731 EXPECT_EQ(*ts, *last_timestamp + expected_timestamp_increment[i]) |
| 727 << "i = " << i; | 732 << "i = " << i; |
| 728 last_timestamp = ts; | 733 last_timestamp = ts; |
| 729 } | 734 } |
| 730 }; | 735 }; |
| 731 | 736 |
| 732 for (size_t i = 1; i < 6; ++i) { | 737 for (size_t i = 1; i < 6; ++i) { |
| 733 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 738 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 734 EXPECT_EQ(1u, output.num_channels_); | 739 EXPECT_EQ(1u, output.num_channels_); |
| 735 EXPECT_EQ(expected_type[i - 1], output.speech_type_); | 740 EXPECT_EQ(expected_type[i - 1], output.speech_type_); |
| 736 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 741 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 737 SCOPED_TRACE(""); | 742 SCOPED_TRACE(""); |
| 738 verify_timestamp(neteq_->GetPlayoutTimestamp(), i); | 743 verify_timestamp(neteq_->GetPlayoutTimestamp(), i); |
| 739 } | 744 } |
| 740 | 745 |
| 741 // Insert third packet, which leaves a gap from last packet. | 746 // Insert third packet, which leaves a gap from last packet. |
| 742 payload[0] = 2; | 747 payload[0] = 2; |
| 743 rtp_header.header.sequenceNumber += 2; | 748 rtp_header.header.sequenceNumber += 2; |
| 744 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; | 749 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; |
| 745 EXPECT_EQ(NetEq::kOK, | 750 EXPECT_EQ(NetEq::kOK, |
| 746 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 751 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 747 | 752 |
| 748 for (size_t i = 6; i < 8; ++i) { | 753 for (size_t i = 6; i < 8; ++i) { |
| 749 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 754 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 750 EXPECT_EQ(1u, output.num_channels_); | 755 EXPECT_EQ(1u, output.num_channels_); |
| 751 EXPECT_EQ(expected_type[i - 1], output.speech_type_); | 756 EXPECT_EQ(expected_type[i - 1], output.speech_type_); |
| 752 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 757 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 753 SCOPED_TRACE(""); | 758 SCOPED_TRACE(""); |
| 754 verify_timestamp(neteq_->GetPlayoutTimestamp(), i); | 759 verify_timestamp(neteq_->GetPlayoutTimestamp(), i); |
| 755 } | 760 } |
| 756 | 761 |
| 757 // Now check the packet buffer, and make sure it is empty. | 762 // Now check the packet buffer, and make sure it is empty. |
| 758 EXPECT_TRUE(packet_buffer_->Empty()); | 763 EXPECT_TRUE(packet_buffer_->Empty()); |
| 759 | 764 |
| 760 EXPECT_CALL(mock_decoder, Die()); | 765 EXPECT_CALL(mock_decoder, Die()); |
| 761 } | 766 } |
| 762 | 767 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 // Insert another packet. | 839 // Insert another packet. |
| 835 payload[0] = kSecondPayloadValue; // This will make Decode() successful. | 840 payload[0] = kSecondPayloadValue; // This will make Decode() successful. |
| 836 rtp_header.header.sequenceNumber++; | 841 rtp_header.header.sequenceNumber++; |
| 837 // The second timestamp needs to be at least 30 ms after the first to make | 842 // The second timestamp needs to be at least 30 ms after the first to make |
| 838 // the second packet get decoded. | 843 // the second packet get decoded. |
| 839 rtp_header.header.timestamp += 3 * kPayloadLengthSamples; | 844 rtp_header.header.timestamp += 3 * kPayloadLengthSamples; |
| 840 EXPECT_EQ(NetEq::kOK, | 845 EXPECT_EQ(NetEq::kOK, |
| 841 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 846 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 842 | 847 |
| 843 AudioFrame output; | 848 AudioFrame output; |
| 849 bool muted; |
| 844 // First call to GetAudio will try to decode the "faulty" packet. | 850 // First call to GetAudio will try to decode the "faulty" packet. |
| 845 // Expect kFail return value... | 851 // Expect kFail return value... |
| 846 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&output)); | 852 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&output, &muted)); |
| 847 // ... and kOtherDecoderError error code. | 853 // ... and kOtherDecoderError error code. |
| 848 EXPECT_EQ(NetEq::kOtherDecoderError, neteq_->LastError()); | 854 EXPECT_EQ(NetEq::kOtherDecoderError, neteq_->LastError()); |
| 849 // Output size and number of channels should be correct. | 855 // Output size and number of channels should be correct. |
| 850 const size_t kExpectedOutputSize = 10 * (kSampleRateHz / 1000) * kChannels; | 856 const size_t kExpectedOutputSize = 10 * (kSampleRateHz / 1000) * kChannels; |
| 851 EXPECT_EQ(kExpectedOutputSize, output.samples_per_channel_ * kChannels); | 857 EXPECT_EQ(kExpectedOutputSize, output.samples_per_channel_ * kChannels); |
| 852 EXPECT_EQ(kChannels, output.num_channels_); | 858 EXPECT_EQ(kChannels, output.num_channels_); |
| 853 | 859 |
| 854 // Second call to GetAudio will decode the packet that is ok. No errors are | 860 // Second call to GetAudio will decode the packet that is ok. No errors are |
| 855 // expected. | 861 // expected. |
| 856 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 862 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 857 EXPECT_EQ(kExpectedOutputSize, output.samples_per_channel_ * kChannels); | 863 EXPECT_EQ(kExpectedOutputSize, output.samples_per_channel_ * kChannels); |
| 858 EXPECT_EQ(kChannels, output.num_channels_); | 864 EXPECT_EQ(kChannels, output.num_channels_); |
| 859 } | 865 } |
| 860 | 866 |
| 861 // This test inserts packets until the buffer is flushed. After that, it asks | 867 // This test inserts packets until the buffer is flushed. After that, it asks |
| 862 // NetEq for the network statistics. The purpose of the test is to make sure | 868 // NetEq for the network statistics. The purpose of the test is to make sure |
| 863 // that even though the buffer size increment is negative (which it becomes when | 869 // that even though the buffer size increment is negative (which it becomes when |
| 864 // the packet causing a flush is inserted), the packet length stored in the | 870 // the packet causing a flush is inserted), the packet length stored in the |
| 865 // decision logic remains valid. | 871 // decision logic remains valid. |
| 866 TEST_F(NetEqImplTest, FloodBufferAndGetNetworkStats) { | 872 TEST_F(NetEqImplTest, FloodBufferAndGetNetworkStats) { |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 939 | 945 |
| 940 // Insert one packet. | 946 // Insert one packet. |
| 941 EXPECT_EQ(NetEq::kOK, | 947 EXPECT_EQ(NetEq::kOK, |
| 942 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 948 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 943 | 949 |
| 944 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); | 950 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); |
| 945 | 951 |
| 946 // Pull audio once. | 952 // Pull audio once. |
| 947 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 953 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 948 AudioFrame output; | 954 AudioFrame output; |
| 949 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 955 bool muted; |
| 956 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 950 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 957 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 951 EXPECT_EQ(1u, output.num_channels_); | 958 EXPECT_EQ(1u, output.num_channels_); |
| 952 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 959 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| 953 | 960 |
| 954 EXPECT_CALL(mock_decoder, Die()); | 961 EXPECT_CALL(mock_decoder, Die()); |
| 955 } | 962 } |
| 956 | 963 |
| 957 // This test checks the behavior of NetEq when audio decoder fails. | 964 // This test checks the behavior of NetEq when audio decoder fails. |
| 958 TEST_F(NetEqImplTest, DecodingError) { | 965 TEST_F(NetEqImplTest, DecodingError) { |
| 959 UseNoMocks(); | 966 UseNoMocks(); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1031 for (int i = 0; i < 6; ++i) { | 1038 for (int i = 0; i < 6; ++i) { |
| 1032 rtp_header.header.sequenceNumber += 1; | 1039 rtp_header.header.sequenceNumber += 1; |
| 1033 rtp_header.header.timestamp += kFrameLengthSamples; | 1040 rtp_header.header.timestamp += kFrameLengthSamples; |
| 1034 EXPECT_EQ(NetEq::kOK, | 1041 EXPECT_EQ(NetEq::kOK, |
| 1035 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1042 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 1036 } | 1043 } |
| 1037 | 1044 |
| 1038 // Pull audio. | 1045 // Pull audio. |
| 1039 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 1046 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 1040 AudioFrame output; | 1047 AudioFrame output; |
| 1041 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 1048 bool muted; |
| 1049 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1042 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1050 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1043 EXPECT_EQ(1u, output.num_channels_); | 1051 EXPECT_EQ(1u, output.num_channels_); |
| 1044 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 1052 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| 1045 | 1053 |
| 1046 // Pull audio again. Decoder fails. | 1054 // Pull audio again. Decoder fails. |
| 1047 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&output)); | 1055 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&output, &muted)); |
| 1048 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); | 1056 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); |
| 1049 EXPECT_EQ(kDecoderErrorCode, neteq_->LastDecoderError()); | 1057 EXPECT_EQ(kDecoderErrorCode, neteq_->LastDecoderError()); |
| 1050 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1058 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1051 EXPECT_EQ(1u, output.num_channels_); | 1059 EXPECT_EQ(1u, output.num_channels_); |
| 1052 // We are not expecting anything for output.speech_type_, since an error was | 1060 // We are not expecting anything for output.speech_type_, since an error was |
| 1053 // returned. | 1061 // returned. |
| 1054 | 1062 |
| 1055 // Pull audio again, should continue an expansion. | 1063 // Pull audio again, should continue an expansion. |
| 1056 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 1064 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1057 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1065 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1058 EXPECT_EQ(1u, output.num_channels_); | 1066 EXPECT_EQ(1u, output.num_channels_); |
| 1059 EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); | 1067 EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); |
| 1060 | 1068 |
| 1061 // Pull audio again, should behave normal. | 1069 // Pull audio again, should behave normal. |
| 1062 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 1070 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1063 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1071 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1064 EXPECT_EQ(1u, output.num_channels_); | 1072 EXPECT_EQ(1u, output.num_channels_); |
| 1065 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 1073 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| 1066 | 1074 |
| 1067 EXPECT_CALL(mock_decoder, Die()); | 1075 EXPECT_CALL(mock_decoder, Die()); |
| 1068 } | 1076 } |
| 1069 | 1077 |
| 1070 // This test checks the behavior of NetEq when audio decoder fails during CNG. | 1078 // This test checks the behavior of NetEq when audio decoder fails during CNG. |
| 1071 TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) { | 1079 TEST_F(NetEqImplTest, DecodingErrorDuringInternalCng) { |
| 1072 UseNoMocks(); | 1080 UseNoMocks(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1140 for (int i = 0; i < 2; ++i) { | 1148 for (int i = 0; i < 2; ++i) { |
| 1141 rtp_header.header.sequenceNumber += 1; | 1149 rtp_header.header.sequenceNumber += 1; |
| 1142 rtp_header.header.timestamp += kFrameLengthSamples; | 1150 rtp_header.header.timestamp += kFrameLengthSamples; |
| 1143 EXPECT_EQ(NetEq::kOK, | 1151 EXPECT_EQ(NetEq::kOK, |
| 1144 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1152 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 1145 } | 1153 } |
| 1146 | 1154 |
| 1147 // Pull audio. | 1155 // Pull audio. |
| 1148 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 1156 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 1149 AudioFrame output; | 1157 AudioFrame output; |
| 1150 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 1158 bool muted; |
| 1159 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1151 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1160 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1152 EXPECT_EQ(1u, output.num_channels_); | 1161 EXPECT_EQ(1u, output.num_channels_); |
| 1153 EXPECT_EQ(AudioFrame::kCNG, output.speech_type_); | 1162 EXPECT_EQ(AudioFrame::kCNG, output.speech_type_); |
| 1154 | 1163 |
| 1155 // Pull audio again. Decoder fails. | 1164 // Pull audio again. Decoder fails. |
| 1156 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&output)); | 1165 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&output, &muted)); |
| 1157 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); | 1166 EXPECT_EQ(NetEq::kDecoderErrorCode, neteq_->LastError()); |
| 1158 EXPECT_EQ(kDecoderErrorCode, neteq_->LastDecoderError()); | 1167 EXPECT_EQ(kDecoderErrorCode, neteq_->LastDecoderError()); |
| 1159 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1168 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1160 EXPECT_EQ(1u, output.num_channels_); | 1169 EXPECT_EQ(1u, output.num_channels_); |
| 1161 // We are not expecting anything for output.speech_type_, since an error was | 1170 // We are not expecting anything for output.speech_type_, since an error was |
| 1162 // returned. | 1171 // returned. |
| 1163 | 1172 |
| 1164 // Pull audio again, should resume codec CNG. | 1173 // Pull audio again, should resume codec CNG. |
| 1165 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 1174 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1166 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1175 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1167 EXPECT_EQ(1u, output.num_channels_); | 1176 EXPECT_EQ(1u, output.num_channels_); |
| 1168 EXPECT_EQ(AudioFrame::kCNG, output.speech_type_); | 1177 EXPECT_EQ(AudioFrame::kCNG, output.speech_type_); |
| 1169 | 1178 |
| 1170 EXPECT_CALL(mock_decoder, Die()); | 1179 EXPECT_CALL(mock_decoder, Die()); |
| 1171 } | 1180 } |
| 1172 | 1181 |
| 1173 // Tests that the return value from last_output_sample_rate_hz() is equal to the | 1182 // Tests that the return value from last_output_sample_rate_hz() is equal to the |
| 1174 // configured inital sample rate. | 1183 // configured inital sample rate. |
| 1175 TEST_F(NetEqImplTest, InitialLastOutputSampleRate) { | 1184 TEST_F(NetEqImplTest, InitialLastOutputSampleRate) { |
| 1176 UseNoMocks(); | 1185 UseNoMocks(); |
| 1177 config_.sample_rate_hz = 48000; | 1186 config_.sample_rate_hz = 48000; |
| 1178 CreateInstance(); | 1187 CreateInstance(); |
| 1179 EXPECT_EQ(48000, neteq_->last_output_sample_rate_hz()); | 1188 EXPECT_EQ(48000, neteq_->last_output_sample_rate_hz()); |
| 1180 } | 1189 } |
| 1181 | 1190 |
| 1182 TEST_F(NetEqImplTest, TickTimerIncrement) { | 1191 TEST_F(NetEqImplTest, TickTimerIncrement) { |
| 1183 UseNoMocks(); | 1192 UseNoMocks(); |
| 1184 CreateInstance(); | 1193 CreateInstance(); |
| 1185 ASSERT_TRUE(tick_timer_); | 1194 ASSERT_TRUE(tick_timer_); |
| 1186 EXPECT_EQ(0u, tick_timer_->ticks()); | 1195 EXPECT_EQ(0u, tick_timer_->ticks()); |
| 1187 AudioFrame output; | 1196 AudioFrame output; |
| 1188 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 1197 bool muted; |
| 1198 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1189 EXPECT_EQ(1u, tick_timer_->ticks()); | 1199 EXPECT_EQ(1u, tick_timer_->ticks()); |
| 1190 } | 1200 } |
| 1191 | 1201 |
| 1192 class Decoder120ms : public AudioDecoder { | 1202 class Decoder120ms : public AudioDecoder { |
| 1193 public: | 1203 public: |
| 1194 Decoder120ms(SpeechType speech_type) | 1204 Decoder120ms(SpeechType speech_type) |
| 1195 : next_value_(1), | 1205 : next_value_(1), |
| 1196 speech_type_(speech_type) {} | 1206 speech_type_(speech_type) {} |
| 1197 | 1207 |
| 1198 int DecodeInternal(const uint8_t* encoded, | 1208 int DecodeInternal(const uint8_t* encoded, |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1233 CreateInstance(); | 1243 CreateInstance(); |
| 1234 } | 1244 } |
| 1235 | 1245 |
| 1236 uint32_t timestamp_diff_between_packets() const { | 1246 uint32_t timestamp_diff_between_packets() const { |
| 1237 return rtc::CheckedDivExact(kSamplingFreq_, 1000u) * 120; | 1247 return rtc::CheckedDivExact(kSamplingFreq_, 1000u) * 120; |
| 1238 } | 1248 } |
| 1239 | 1249 |
| 1240 uint32_t first_timestamp() const { return 10u; } | 1250 uint32_t first_timestamp() const { return 10u; } |
| 1241 | 1251 |
| 1242 void GetFirstPacket() { | 1252 void GetFirstPacket() { |
| 1253 bool muted; |
| 1243 for (int i = 0; i < 12; i++) { | 1254 for (int i = 0; i < 12; i++) { |
| 1244 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1255 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1256 EXPECT_FALSE(muted); |
| 1245 } | 1257 } |
| 1246 } | 1258 } |
| 1247 | 1259 |
| 1248 void InsertPacket(uint32_t timestamp) { | 1260 void InsertPacket(uint32_t timestamp) { |
| 1249 WebRtcRTPHeader rtp_header; | 1261 WebRtcRTPHeader rtp_header; |
| 1250 rtp_header.header.payloadType = kPayloadType; | 1262 rtp_header.header.payloadType = kPayloadType; |
| 1251 rtp_header.header.sequenceNumber = sequence_number_; | 1263 rtp_header.header.sequenceNumber = sequence_number_; |
| 1252 rtp_header.header.timestamp = timestamp; | 1264 rtp_header.header.timestamp = timestamp; |
| 1253 rtp_header.header.ssrc = 15; | 1265 rtp_header.header.ssrc = 15; |
| 1254 const size_t kPayloadLengthBytes = 1; // This can be arbitrary. | 1266 const size_t kPayloadLengthBytes = 1; // This can be arbitrary. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1273 }; | 1285 }; |
| 1274 | 1286 |
| 1275 TEST_F(NetEqImplTest120ms, AudioRepetition) { | 1287 TEST_F(NetEqImplTest120ms, AudioRepetition) { |
| 1276 config_.playout_mode = kPlayoutFax; | 1288 config_.playout_mode = kPlayoutFax; |
| 1277 CreateInstanceNoMocks(); | 1289 CreateInstanceNoMocks(); |
| 1278 Register120msCodec(AudioDecoder::kSpeech); | 1290 Register120msCodec(AudioDecoder::kSpeech); |
| 1279 | 1291 |
| 1280 InsertPacket(first_timestamp()); | 1292 InsertPacket(first_timestamp()); |
| 1281 GetFirstPacket(); | 1293 GetFirstPacket(); |
| 1282 | 1294 |
| 1283 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1295 bool muted; |
| 1296 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1284 EXPECT_EQ(kAudioRepetition, neteq_->last_operation_for_test()); | 1297 EXPECT_EQ(kAudioRepetition, neteq_->last_operation_for_test()); |
| 1285 } | 1298 } |
| 1286 | 1299 |
| 1287 TEST_F(NetEqImplTest120ms, AlternativePlc) { | 1300 TEST_F(NetEqImplTest120ms, AlternativePlc) { |
| 1288 config_.playout_mode = kPlayoutOff; | 1301 config_.playout_mode = kPlayoutOff; |
| 1289 CreateInstanceNoMocks(); | 1302 CreateInstanceNoMocks(); |
| 1290 Register120msCodec(AudioDecoder::kSpeech); | 1303 Register120msCodec(AudioDecoder::kSpeech); |
| 1291 | 1304 |
| 1292 InsertPacket(first_timestamp()); | 1305 InsertPacket(first_timestamp()); |
| 1293 GetFirstPacket(); | 1306 GetFirstPacket(); |
| 1294 | 1307 |
| 1295 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1308 bool muted; |
| 1309 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1296 EXPECT_EQ(kAlternativePlc, neteq_->last_operation_for_test()); | 1310 EXPECT_EQ(kAlternativePlc, neteq_->last_operation_for_test()); |
| 1297 } | 1311 } |
| 1298 | 1312 |
| 1299 TEST_F(NetEqImplTest120ms, CodecInternalCng) { | 1313 TEST_F(NetEqImplTest120ms, CodecInternalCng) { |
| 1300 CreateInstanceNoMocks(); | 1314 CreateInstanceNoMocks(); |
| 1301 Register120msCodec(AudioDecoder::kComfortNoise); | 1315 Register120msCodec(AudioDecoder::kComfortNoise); |
| 1302 | 1316 |
| 1303 InsertPacket(first_timestamp()); | 1317 InsertPacket(first_timestamp()); |
| 1304 GetFirstPacket(); | 1318 GetFirstPacket(); |
| 1305 | 1319 |
| 1306 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1320 bool muted; |
| 1321 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1307 EXPECT_EQ(kCodecInternalCng, neteq_->last_operation_for_test()); | 1322 EXPECT_EQ(kCodecInternalCng, neteq_->last_operation_for_test()); |
| 1308 } | 1323 } |
| 1309 | 1324 |
| 1310 TEST_F(NetEqImplTest120ms, Normal) { | 1325 TEST_F(NetEqImplTest120ms, Normal) { |
| 1311 CreateInstanceNoMocks(); | 1326 CreateInstanceNoMocks(); |
| 1312 Register120msCodec(AudioDecoder::kSpeech); | 1327 Register120msCodec(AudioDecoder::kSpeech); |
| 1313 | 1328 |
| 1314 InsertPacket(first_timestamp()); | 1329 InsertPacket(first_timestamp()); |
| 1315 GetFirstPacket(); | 1330 GetFirstPacket(); |
| 1316 | 1331 |
| 1317 EXPECT_EQ(kNormal, neteq_->last_operation_for_test()); | 1332 EXPECT_EQ(kNormal, neteq_->last_operation_for_test()); |
| 1318 } | 1333 } |
| 1319 | 1334 |
| 1320 TEST_F(NetEqImplTest120ms, Merge) { | 1335 TEST_F(NetEqImplTest120ms, Merge) { |
| 1321 CreateInstanceWithDelayManagerMock(); | 1336 CreateInstanceWithDelayManagerMock(); |
| 1322 | 1337 |
| 1323 Register120msCodec(AudioDecoder::kSpeech); | 1338 Register120msCodec(AudioDecoder::kSpeech); |
| 1324 InsertPacket(first_timestamp()); | 1339 InsertPacket(first_timestamp()); |
| 1325 | 1340 |
| 1326 GetFirstPacket(); | 1341 GetFirstPacket(); |
| 1327 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1342 bool muted; |
| 1343 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1328 | 1344 |
| 1329 InsertPacket(first_timestamp() + 2 * timestamp_diff_between_packets()); | 1345 InsertPacket(first_timestamp() + 2 * timestamp_diff_between_packets()); |
| 1330 | 1346 |
| 1331 // Delay manager reports a target level which should cause a Merge. | 1347 // Delay manager reports a target level which should cause a Merge. |
| 1332 EXPECT_CALL(*mock_delay_manager_, TargetLevel()).WillOnce(Return(-10)); | 1348 EXPECT_CALL(*mock_delay_manager_, TargetLevel()).WillOnce(Return(-10)); |
| 1333 | 1349 |
| 1334 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1350 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1335 EXPECT_EQ(kMerge, neteq_->last_operation_for_test()); | 1351 EXPECT_EQ(kMerge, neteq_->last_operation_for_test()); |
| 1336 } | 1352 } |
| 1337 | 1353 |
| 1338 TEST_F(NetEqImplTest120ms, Expand) { | 1354 TEST_F(NetEqImplTest120ms, Expand) { |
| 1339 CreateInstanceNoMocks(); | 1355 CreateInstanceNoMocks(); |
| 1340 Register120msCodec(AudioDecoder::kSpeech); | 1356 Register120msCodec(AudioDecoder::kSpeech); |
| 1341 | 1357 |
| 1342 InsertPacket(first_timestamp()); | 1358 InsertPacket(first_timestamp()); |
| 1343 GetFirstPacket(); | 1359 GetFirstPacket(); |
| 1344 | 1360 |
| 1345 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1361 bool muted; |
| 1362 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1346 EXPECT_EQ(kExpand, neteq_->last_operation_for_test()); | 1363 EXPECT_EQ(kExpand, neteq_->last_operation_for_test()); |
| 1347 } | 1364 } |
| 1348 | 1365 |
| 1349 TEST_F(NetEqImplTest120ms, FastAccelerate) { | 1366 TEST_F(NetEqImplTest120ms, FastAccelerate) { |
| 1350 CreateInstanceWithDelayManagerMock(); | 1367 CreateInstanceWithDelayManagerMock(); |
| 1351 Register120msCodec(AudioDecoder::kSpeech); | 1368 Register120msCodec(AudioDecoder::kSpeech); |
| 1352 | 1369 |
| 1353 InsertPacket(first_timestamp()); | 1370 InsertPacket(first_timestamp()); |
| 1354 GetFirstPacket(); | 1371 GetFirstPacket(); |
| 1355 InsertPacket(first_timestamp() + timestamp_diff_between_packets()); | 1372 InsertPacket(first_timestamp() + timestamp_diff_between_packets()); |
| 1356 | 1373 |
| 1357 // Delay manager report buffer limit which should cause a FastAccelerate. | 1374 // Delay manager report buffer limit which should cause a FastAccelerate. |
| 1358 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1375 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
| 1359 .Times(1) | 1376 .Times(1) |
| 1360 .WillOnce(DoAll(SetArgPointee<0>(0), SetArgPointee<1>(0))); | 1377 .WillOnce(DoAll(SetArgPointee<0>(0), SetArgPointee<1>(0))); |
| 1361 | 1378 |
| 1362 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1379 bool muted; |
| 1380 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1363 EXPECT_EQ(kFastAccelerate, neteq_->last_operation_for_test()); | 1381 EXPECT_EQ(kFastAccelerate, neteq_->last_operation_for_test()); |
| 1364 } | 1382 } |
| 1365 | 1383 |
| 1366 TEST_F(NetEqImplTest120ms, PreemptiveExpand) { | 1384 TEST_F(NetEqImplTest120ms, PreemptiveExpand) { |
| 1367 CreateInstanceWithDelayManagerMock(); | 1385 CreateInstanceWithDelayManagerMock(); |
| 1368 Register120msCodec(AudioDecoder::kSpeech); | 1386 Register120msCodec(AudioDecoder::kSpeech); |
| 1369 | 1387 |
| 1370 InsertPacket(first_timestamp()); | 1388 InsertPacket(first_timestamp()); |
| 1371 GetFirstPacket(); | 1389 GetFirstPacket(); |
| 1372 | 1390 |
| 1373 InsertPacket(first_timestamp() + timestamp_diff_between_packets()); | 1391 InsertPacket(first_timestamp() + timestamp_diff_between_packets()); |
| 1374 | 1392 |
| 1375 // Delay manager report buffer limit which should cause a PreemptiveExpand. | 1393 // Delay manager report buffer limit which should cause a PreemptiveExpand. |
| 1376 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1394 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
| 1377 .Times(1) | 1395 .Times(1) |
| 1378 .WillOnce(DoAll(SetArgPointee<0>(100), SetArgPointee<1>(100))); | 1396 .WillOnce(DoAll(SetArgPointee<0>(100), SetArgPointee<1>(100))); |
| 1379 | 1397 |
| 1380 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1398 bool muted; |
| 1399 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1381 EXPECT_EQ(kPreemptiveExpand, neteq_->last_operation_for_test()); | 1400 EXPECT_EQ(kPreemptiveExpand, neteq_->last_operation_for_test()); |
| 1382 } | 1401 } |
| 1383 | 1402 |
| 1384 TEST_F(NetEqImplTest120ms, Accelerate) { | 1403 TEST_F(NetEqImplTest120ms, Accelerate) { |
| 1385 CreateInstanceWithDelayManagerMock(); | 1404 CreateInstanceWithDelayManagerMock(); |
| 1386 Register120msCodec(AudioDecoder::kSpeech); | 1405 Register120msCodec(AudioDecoder::kSpeech); |
| 1387 | 1406 |
| 1388 InsertPacket(first_timestamp()); | 1407 InsertPacket(first_timestamp()); |
| 1389 GetFirstPacket(); | 1408 GetFirstPacket(); |
| 1390 | 1409 |
| 1391 InsertPacket(first_timestamp() + timestamp_diff_between_packets()); | 1410 InsertPacket(first_timestamp() + timestamp_diff_between_packets()); |
| 1392 | 1411 |
| 1393 // Delay manager report buffer limit which should cause a Accelerate. | 1412 // Delay manager report buffer limit which should cause a Accelerate. |
| 1394 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1413 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
| 1395 .Times(1) | 1414 .Times(1) |
| 1396 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); | 1415 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); |
| 1397 | 1416 |
| 1398 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_)); | 1417 bool muted; |
| 1418 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1399 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); | 1419 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); |
| 1400 } | 1420 } |
| 1401 | 1421 |
| 1402 }// namespace webrtc | 1422 }// namespace webrtc |
| OLD | NEW |