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

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

Issue 1861303002: NetEq::GetPlayoutTimestamp returns empty during CNG (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@neteq-set-audio-frame-ts
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 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 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 rtp_header.header.sequenceNumber = 0x1234; 659 rtp_header.header.sequenceNumber = 0x1234;
660 rtp_header.header.timestamp = 0x12345678; 660 rtp_header.header.timestamp = 0x12345678;
661 rtp_header.header.ssrc = 0x87654321; 661 rtp_header.header.ssrc = 0x87654321;
662 662
663 // Create a mock decoder object. 663 // Create a mock decoder object.
664 MockAudioDecoder mock_decoder; 664 MockAudioDecoder mock_decoder;
665 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); 665 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return());
666 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); 666 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1));
667 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) 667 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _))
668 .WillRepeatedly(Return(0)); 668 .WillRepeatedly(Return(0));
669 EXPECT_CALL(mock_decoder, PacketDuration(_, kPayloadLengthBytes))
hlundin-webrtc 2016/04/06 11:13:58 These new EXPEC_CALLs are unrelated to this CL, bu
670 .WillRepeatedly(Return(kPayloadLengthSamples));
671 // Packed duration when asking the decoder for more CNG data (without a new
672 // packet).
673 EXPECT_CALL(mock_decoder, PacketDuration(nullptr, 0))
674 .WillRepeatedly(Return(kPayloadLengthSamples));
669 675
670 // Pointee(x) verifies that first byte of the payload equals x, this makes it 676 // Pointee(x) verifies that first byte of the payload equals x, this makes it
671 // possible to verify that the correct payload is fed to Decode(). 677 // possible to verify that the correct payload is fed to Decode().
672 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(0), kPayloadLengthBytes, 678 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(0), kPayloadLengthBytes,
673 kSampleRateKhz * 1000, _, _)) 679 kSampleRateKhz * 1000, _, _))
674 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, 680 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output,
675 dummy_output + kPayloadLengthSamples), 681 dummy_output + kPayloadLengthSamples),
676 SetArgPointee<4>(AudioDecoder::kSpeech), 682 SetArgPointee<4>(AudioDecoder::kSpeech),
677 Return(kPayloadLengthSamples))); 683 Return(kPayloadLengthSamples)));
678 684
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); 719 neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
714 720
715 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz); 721 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz);
716 AudioFrame output; 722 AudioFrame output;
717 AudioFrame::SpeechType expected_type[8] = { 723 AudioFrame::SpeechType expected_type[8] = {
718 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech, 724 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech,
719 AudioFrame::kCNG, AudioFrame::kCNG, 725 AudioFrame::kCNG, AudioFrame::kCNG,
720 AudioFrame::kCNG, AudioFrame::kCNG, 726 AudioFrame::kCNG, AudioFrame::kCNG,
721 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech 727 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech
722 }; 728 };
723 int expected_timestamp_increment[8] = { 729 int expected_timestamp_increment[8] = {
minyue-webrtc 2016/04/06 13:39:42 Is there a better to change this.
hlundin-webrtc 2016/04/06 15:27:56 How about now?
724 -1, // will not be used. 730 -1, // will not be used.
725 10 * kSampleRateKhz, 731 10 * kSampleRateKhz,
726 0, 0, // timestamp does not increase during CNG mode. 732 0, 0, // timestamp does not increase during CNG mode.
727 0, 0, 733 0, 0,
728 50 * kSampleRateKhz, 10 * kSampleRateKhz 734 50 * kSampleRateKhz, 10 * kSampleRateKhz
729 }; 735 };
730 736
731 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); 737 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output));
732 rtc::Optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp(); 738 rtc::Optional<uint32_t> last_timestamp = neteq_->GetPlayoutTimestamp();
733 ASSERT_TRUE(last_timestamp); 739 ASSERT_TRUE(last_timestamp);
734 740
735 for (size_t i = 1; i < 6; ++i) { 741 for (size_t i = 1; i < 6; ++i) {
736 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); 742 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_);
737 EXPECT_EQ(1u, output.num_channels_); 743 EXPECT_EQ(1u, output.num_channels_);
738 EXPECT_EQ(expected_type[i - 1], output.speech_type_); 744 EXPECT_EQ(expected_type[i - 1], output.speech_type_);
745 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output));
739 rtc::Optional<uint32_t> timestamp = neteq_->GetPlayoutTimestamp(); 746 rtc::Optional<uint32_t> timestamp = neteq_->GetPlayoutTimestamp();
740 EXPECT_TRUE(timestamp); 747 if (output.speech_type_ == AudioFrame::kNormalSpeech) {
741 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output)); 748 ASSERT_TRUE(timestamp);
742 timestamp = neteq_->GetPlayoutTimestamp(); 749 EXPECT_EQ(*timestamp, *last_timestamp + expected_timestamp_increment[i]);
743 ASSERT_TRUE(timestamp); 750 last_timestamp = timestamp;
744 EXPECT_EQ(*timestamp, *last_timestamp + expected_timestamp_increment[i]); 751 } else {
745 last_timestamp = timestamp; 752 // Expect to get an empty timestamp value during CNG and PLC.
753 EXPECT_FALSE(timestamp);
754 }
746 } 755 }
747 756
748 // Insert third packet, which leaves a gap from last packet. 757 // Insert third packet, which leaves a gap from last packet.
749 payload[0] = 2; 758 payload[0] = 2;
750 rtp_header.header.sequenceNumber += 2; 759 rtp_header.header.sequenceNumber += 2;
751 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; 760 rtp_header.header.timestamp += 2 * kPayloadLengthSamples;
752 EXPECT_EQ(NetEq::kOK, 761 EXPECT_EQ(NetEq::kOK,
753 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); 762 neteq_->InsertPacket(rtp_header, payload, kReceiveTime));
754 763
755 for (size_t i = 6; i < 8; ++i) { 764 for (size_t i = 6; i < 8; ++i) {
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
1178 // Tests that the return value from last_output_sample_rate_hz() is equal to the 1187 // Tests that the return value from last_output_sample_rate_hz() is equal to the
1179 // configured inital sample rate. 1188 // configured inital sample rate.
1180 TEST_F(NetEqImplTest, InitialLastOutputSampleRate) { 1189 TEST_F(NetEqImplTest, InitialLastOutputSampleRate) {
1181 UseNoMocks(); 1190 UseNoMocks();
1182 config_.sample_rate_hz = 48000; 1191 config_.sample_rate_hz = 48000;
1183 CreateInstance(); 1192 CreateInstance();
1184 EXPECT_EQ(48000, neteq_->last_output_sample_rate_hz()); 1193 EXPECT_EQ(48000, neteq_->last_output_sample_rate_hz());
1185 } 1194 }
1186 1195
1187 }// namespace webrtc 1196 }// namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698