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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 EXPECT_EQ(1u, output.num_channels_); | 471 EXPECT_EQ(1u, output.num_channels_); |
472 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 472 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
473 | 473 |
474 // Start with a simple check that the fake decoder is behaving as expected. | 474 // Start with a simple check that the fake decoder is behaving as expected. |
475 EXPECT_EQ(kPayloadLengthSamples, | 475 EXPECT_EQ(kPayloadLengthSamples, |
476 static_cast<size_t>(decoder_.next_value() - 1)); | 476 static_cast<size_t>(decoder_.next_value() - 1)); |
477 | 477 |
478 // The value of the last of the output samples is the same as the number of | 478 // The value of the last of the output samples is the same as the number of |
479 // samples played from the decoded packet. Thus, this number + the RTP | 479 // samples played from the decoded packet. Thus, this number + the RTP |
480 // timestamp should match the playout timestamp. | 480 // timestamp should match the playout timestamp. |
481 uint32_t timestamp = 0; | 481 // Wrap the expected value in an rtc::Optional to compare them as such. |
kwiberg-webrtc
2016/04/05 17:27:23
Not sure you need the comment, but OK.
| |
482 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(×tamp)); | 482 EXPECT_EQ( |
483 EXPECT_EQ(rtp_header.header.timestamp + | 483 rtc::Optional<uint32_t>(rtp_header.header.timestamp + |
484 output.data_[output.samples_per_channel_ - 1], | 484 output.data_[output.samples_per_channel_ - 1]), |
485 timestamp); | 485 neteq_->GetPlayoutTimestamp()); |
486 | 486 |
487 // Check the timestamp for the last value in the sync buffer. This should | 487 // Check the timestamp for the last value in the sync buffer. This should |
488 // be one full frame length ahead of the RTP timestamp. | 488 // be one full frame length ahead of the RTP timestamp. |
489 const SyncBuffer* sync_buffer = neteq_->sync_buffer_for_test(); | 489 const SyncBuffer* sync_buffer = neteq_->sync_buffer_for_test(); |
490 ASSERT_TRUE(sync_buffer != NULL); | 490 ASSERT_TRUE(sync_buffer != NULL); |
491 EXPECT_EQ(rtp_header.header.timestamp + kPayloadLengthSamples, | 491 EXPECT_EQ(rtp_header.header.timestamp + kPayloadLengthSamples, |
492 sync_buffer->end_timestamp()); | 492 sync_buffer->end_timestamp()); |
493 | 493 |
494 // Check that the number of samples still to play from the sync buffer add | 494 // Check that the number of samples still to play from the sync buffer add |
495 // up with what was already played out. | 495 // up with what was already played out. |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
707 | 707 |
708 // Insert second packet (decoder will return CNG). | 708 // Insert second packet (decoder will return CNG). |
709 payload[0] = 1; | 709 payload[0] = 1; |
710 rtp_header.header.sequenceNumber++; | 710 rtp_header.header.sequenceNumber++; |
711 rtp_header.header.timestamp += kPayloadLengthSamples; | 711 rtp_header.header.timestamp += kPayloadLengthSamples; |
712 EXPECT_EQ(NetEq::kOK, | 712 EXPECT_EQ(NetEq::kOK, |
713 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 713 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
714 | 714 |
715 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz); | 715 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz); |
716 AudioFrame output; | 716 AudioFrame output; |
717 uint32_t timestamp; | |
718 uint32_t last_timestamp; | |
719 AudioFrame::SpeechType expected_type[8] = { | 717 AudioFrame::SpeechType expected_type[8] = { |
720 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech, | 718 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech, |
721 AudioFrame::kCNG, AudioFrame::kCNG, | 719 AudioFrame::kCNG, AudioFrame::kCNG, |
722 AudioFrame::kCNG, AudioFrame::kCNG, | 720 AudioFrame::kCNG, AudioFrame::kCNG, |
723 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech | 721 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech |
724 }; | 722 }; |
725 int expected_timestamp_increment[8] = { | 723 int expected_timestamp_increment[8] = { |
726 -1, // will not be used. | 724 -1, // will not be used. |
727 10 * kSampleRateKhz, | 725 10 * kSampleRateKhz, |
728 0, 0, // timestamp does not increase during CNG mode. | 726 0, 0, // timestamp does not increase during CNG mode. |
729 0, 0, | 727 0, 0, |
730 50 * kSampleRateKhz, 10 * kSampleRateKhz | 728 50 * kSampleRateKhz, 10 * kSampleRateKhz |
731 }; | 729 }; |
732 | 730 |
733 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 731 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); |
734 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(&last_timestamp)); | 732 rtc::Optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp(); |
733 ASSERT_TRUE(last_timestamp); | |
735 | 734 |
736 for (size_t i = 1; i < 6; ++i) { | 735 for (size_t i = 1; i < 6; ++i) { |
737 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 736 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
738 EXPECT_EQ(1u, output.num_channels_); | 737 EXPECT_EQ(1u, output.num_channels_); |
739 EXPECT_EQ(expected_type[i - 1], output.speech_type_); | 738 EXPECT_EQ(expected_type[i - 1], output.speech_type_); |
740 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(×tamp)); | 739 rtc::Optional<uint32_t> timestamp = neteq_->GetPlayoutTimestamp(); |
740 EXPECT_TRUE(timestamp); | |
741 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 741 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); |
742 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(×tamp)); | 742 timestamp = neteq_->GetPlayoutTimestamp(); |
743 EXPECT_EQ(timestamp, last_timestamp + expected_timestamp_increment[i]); | 743 ASSERT_TRUE(timestamp); |
744 EXPECT_EQ(*timestamp, *last_timestamp + expected_timestamp_increment[i]); | |
744 last_timestamp = timestamp; | 745 last_timestamp = timestamp; |
745 } | 746 } |
746 | 747 |
747 // Insert third packet, which leaves a gap from last packet. | 748 // Insert third packet, which leaves a gap from last packet. |
748 payload[0] = 2; | 749 payload[0] = 2; |
749 rtp_header.header.sequenceNumber += 2; | 750 rtp_header.header.sequenceNumber += 2; |
750 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; | 751 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; |
751 EXPECT_EQ(NetEq::kOK, | 752 EXPECT_EQ(NetEq::kOK, |
752 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 753 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
753 | 754 |
754 for (size_t i = 6; i < 8; ++i) { | 755 for (size_t i = 6; i < 8; ++i) { |
755 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 756 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
756 EXPECT_EQ(1u, output.num_channels_); | 757 EXPECT_EQ(1u, output.num_channels_); |
757 EXPECT_EQ(expected_type[i - 1], output.speech_type_); | 758 EXPECT_EQ(expected_type[i - 1], output.speech_type_); |
758 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); | 759 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); |
759 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(×tamp)); | 760 rtc::Optional<uint32_t> timestamp = neteq_->GetPlayoutTimestamp(); |
760 EXPECT_EQ(timestamp, last_timestamp + expected_timestamp_increment[i]); | 761 ASSERT_TRUE(timestamp); |
762 EXPECT_EQ(*timestamp, *last_timestamp + expected_timestamp_increment[i]); | |
761 last_timestamp = timestamp; | 763 last_timestamp = timestamp; |
762 } | 764 } |
763 | 765 |
764 // Now check the packet buffer, and make sure it is empty. | 766 // Now check the packet buffer, and make sure it is empty. |
765 EXPECT_TRUE(packet_buffer_->Empty()); | 767 EXPECT_TRUE(packet_buffer_->Empty()); |
766 | 768 |
767 EXPECT_CALL(mock_decoder, Die()); | 769 EXPECT_CALL(mock_decoder, Die()); |
768 } | 770 } |
769 | 771 |
770 TEST_F(NetEqImplTest, UnsupportedDecoder) { | 772 TEST_F(NetEqImplTest, UnsupportedDecoder) { |
(...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1176 // Tests that the return value from last_output_sample_rate_hz() is equal to the | 1178 // Tests that the return value from last_output_sample_rate_hz() is equal to the |
1177 // configured inital sample rate. | 1179 // configured inital sample rate. |
1178 TEST_F(NetEqImplTest, InitialLastOutputSampleRate) { | 1180 TEST_F(NetEqImplTest, InitialLastOutputSampleRate) { |
1179 UseNoMocks(); | 1181 UseNoMocks(); |
1180 config_.sample_rate_hz = 48000; | 1182 config_.sample_rate_hz = 48000; |
1181 CreateInstance(); | 1183 CreateInstance(); |
1182 EXPECT_EQ(48000, neteq_->last_output_sample_rate_hz()); | 1184 EXPECT_EQ(48000, neteq_->last_output_sample_rate_hz()); |
1183 } | 1185 } |
1184 | 1186 |
1185 }// namespace webrtc | 1187 }// namespace webrtc |
OLD | NEW |