From 549d80b979158a3535af299ee6277e77ca0873ca Mon Sep 17 00:00:00 2001 From: "henrik.lundin" Date: Thu, 25 Aug 2016 00:44:24 -0700 Subject: [PATCH] NetEq: only update current_rtp_payload_type_ when validated The current_rtp_payload_type_ should only be updated when the packet is actually inserted into the packet buffer, since then the payload type has been validated. This CL removes an unvalidated setting of this value that happened after SSRC change or upon first packet. BUG=webrtc:5447 Review-Url: https://codereview.webrtc.org/2270793003 Cr-Commit-Position: refs/heads/master@{#13910} --- webrtc/modules/audio_coding/neteq/neteq_impl.cc | 12 ++++-------- webrtc/modules/audio_coding/neteq/neteq_unittest.cc | 7 +++++-- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc index e65466f6d8..78e3112184 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc @@ -598,7 +598,6 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header, // Update codecs. timestamp_ = main_header.timestamp; - current_rtp_payload_type_ = main_header.payloadType; // Reset timestamp scaling. timestamp_scaler_->Reset(); @@ -744,13 +743,10 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header, new_codec_ = true; } - if (current_rtp_payload_type_ != 0xFF) { - const DecoderDatabase::DecoderInfo* dec_info = - decoder_database_->GetDecoderInfo(current_rtp_payload_type_); - if (!dec_info) { - assert(false); // Already checked that the payload type is known. - } - } + RTC_DCHECK(current_rtp_payload_type_ == 0xFF || + decoder_database_->GetDecoderInfo(current_rtp_payload_type_)) + << "Payload type " << static_cast(current_rtp_payload_type_) + << " is unknown where it shouldn't be"; if (update_sample_rate_and_channels && !packet_buffer_->Empty()) { // We do not use |current_rtp_payload_type_| to |set payload_type|, but diff --git a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc index b59046ae24..976c685b2b 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_unittest.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_unittest.cc @@ -1521,7 +1521,10 @@ TEST_F(NetEqDecodingTest, CngFirst) { EXPECT_EQ(AudioFrame::kCNG, out_frame_.speech_type_); // Insert some speech packets. - for (int i = 0; i < 3; ++i) { + const uint32_t first_speech_timestamp = timestamp; + int timeout_counter = 0; + do { + ASSERT_LT(timeout_counter++, 20) << "Test timed out"; PopulateRtpInfo(seq_no, timestamp, &rtp_info); ASSERT_EQ(0, neteq_->InsertPacket(rtp_info, payload, 0)); ++seq_no; @@ -1530,7 +1533,7 @@ TEST_F(NetEqDecodingTest, CngFirst) { // Pull audio once. ASSERT_EQ(0, neteq_->GetAudio(&out_frame_, &muted)); ASSERT_EQ(kBlockSize16kHz, out_frame_.samples_per_channel_); - } + } while (!IsNewerTimestamp(out_frame_.timestamp_, first_speech_timestamp)); // Verify speech output. EXPECT_EQ(AudioFrame::kNormalSpeech, out_frame_.speech_type_); }