diff --git a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc index c7bbfb0434..73cc8a3a1d 100644 --- a/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc +++ b/webrtc/modules/audio_coding/acm2/audio_coding_module_unittest.cc @@ -1426,8 +1426,8 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_Ilbc_30ms) { TEST_F(AcmSenderBitExactnessOldApi, MAYBE_G722_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("G722", 16000, 1, 9, 320, 160)); Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( - "7d759436f2533582950d148b5161a36c", - "7d759436f2533582950d148b5161a36c", "android_arm32_audio", + "e99c89be49a46325d03c0d990c292d68", + "e99c89be49a46325d03c0d990c292d68", "android_arm32_audio", "android_arm64_audio"), AcmReceiverBitExactnessOldApi::PlatformChecksum( "fc68a87e1380614e658087cb35d5ca10", @@ -1446,8 +1446,8 @@ TEST_F(AcmSenderBitExactnessOldApi, MAYBE_G722_20ms) { TEST_F(AcmSenderBitExactnessOldApi, MAYBE_G722_stereo_20ms) { ASSERT_NO_FATAL_FAILURE(SetUpTest("G722", 16000, 2, 119, 320, 160)); Run(AcmReceiverBitExactnessOldApi::PlatformChecksum( - "7190ee718ab3d80eca181e5f7140c210", - "7190ee718ab3d80eca181e5f7140c210", "android_arm32_audio", + "e280aed283e499d37091b481ca094807", + "e280aed283e499d37091b481ca094807", "android_arm32_audio", "android_arm64_audio"), AcmReceiverBitExactnessOldApi::PlatformChecksum( "66516152eeaa1e650ad94ff85f668dac", diff --git a/webrtc/modules/audio_coding/neteq/neteq_impl.cc b/webrtc/modules/audio_coding/neteq/neteq_impl.cc index 786cb84aa3..5015b7e9fe 100644 --- a/webrtc/modules/audio_coding/neteq/neteq_impl.cc +++ b/webrtc/modules/audio_coding/neteq/neteq_impl.cc @@ -594,9 +594,27 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header, return packet; }()); - bool update_sample_rate_and_channels = false; + bool update_sample_rate_and_channels = first_packet_ || + (rtp_header.header.ssrc != ssrc_); + + if (update_sample_rate_and_channels) { + // Reset timestamp scaling. + timestamp_scaler_->Reset(); + } + + if (!decoder_database_->IsRed(rtp_header.header.payloadType)) { + // Scale timestamp to internal domain (only for some codecs). + timestamp_scaler_->ToInternal(&packet_list); + } + + // Store these for later use, since the first packet may very well disappear + // before we need these values. + uint32_t main_timestamp = packet_list.front().timestamp; + uint8_t main_payload_type = packet_list.front().payload_type; + uint16_t main_sequence_number = packet_list.front().sequence_number; + // Reinitialize NetEq if it's needed (changed SSRC or first call). - if ((rtp_header.header.ssrc != ssrc_) || first_packet_) { + if (update_sample_rate_and_channels) { // Note: |first_packet_| will be cleared further down in this method, once // the packet has been successfully inserted into the packet buffer. @@ -610,17 +628,10 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header, ssrc_ = rtp_header.header.ssrc; // Update audio buffer timestamp. - sync_buffer_->IncreaseEndTimestamp(rtp_header.header.timestamp - - timestamp_); + sync_buffer_->IncreaseEndTimestamp(main_timestamp - timestamp_); // Update codecs. - timestamp_ = rtp_header.header.timestamp; - - // Reset timestamp scaling. - timestamp_scaler_->Reset(); - - // Trigger an update of sampling rate and the number of channels. - update_sample_rate_and_channels = true; + timestamp_ = main_timestamp; } // Update RTCP statistics, only for regular packets. @@ -652,14 +663,15 @@ int NetEqImpl::InsertPacketInternal(const WebRtcRTPHeader& rtp_header, } RTC_DCHECK(!packet_list.empty()); - // Store these for later use, since the first packet may very well disappear - // before we need these values. - const uint32_t main_timestamp = packet_list.front().timestamp; - const uint8_t main_payload_type = packet_list.front().payload_type; - const uint16_t main_sequence_number = packet_list.front().sequence_number; - // Scale timestamp to internal domain (only for some codecs). - timestamp_scaler_->ToInternal(&packet_list); + // Update main_timestamp, if new packets appear in the list + // after RED splitting. + if (decoder_database_->IsRed(rtp_header.header.payloadType)) { + timestamp_scaler_->ToInternal(&packet_list); + main_timestamp = packet_list.front().timestamp; + main_payload_type = packet_list.front().payload_type; + main_sequence_number = packet_list.front().sequence_number; + } // Process DTMF payloads. Cycle through the list of packets, and pick out any // DTMF payloads found.