diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc index d5bd97d459..c9163a15d8 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc @@ -85,12 +85,12 @@ void NetEqReplacementInput::ReplacePacket() { rtc::Optional next_hdr = source_->NextHeader(); RTC_DCHECK(next_hdr); uint8_t payload[12]; - uint32_t input_frame_size_timestamps = - next_hdr->timestamp - packet_->header.header.timestamp; - if (next_hdr->sequenceNumber != packet_->header.header.sequenceNumber + 1) { - // Gap in packet sequence. Cannot estimate payload length based on timestamp - // difference. - input_frame_size_timestamps = 0; + uint32_t input_frame_size_timestamps = last_frame_size_timestamps_; + if (next_hdr->sequenceNumber == packet_->header.header.sequenceNumber + 1) { + // Packets are in order. + input_frame_size_timestamps = + next_hdr->timestamp - packet_->header.header.timestamp; + last_frame_size_timestamps_ = input_frame_size_timestamps; } FakeDecodeFromFile::PrepareEncoded(packet_->header.header.timestamp, input_frame_size_timestamps, diff --git a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.h b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.h index 07153dbb76..ee1e4ae66e 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.h +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.h @@ -11,6 +11,7 @@ #ifndef WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_REPLACEMENT_INPUT_H_ #define WEBRTC_MODULES_AUDIO_CODING_NETEQ_TOOLS_NETEQ_REPLACEMENT_INPUT_H_ +#include #include #include "webrtc/modules/audio_coding/neteq/tools/neteq_input.h" @@ -42,6 +43,7 @@ class NetEqReplacementInput : public NetEqInput { const std::set comfort_noise_types_; const std::set forbidden_types_; std::unique_ptr packet_; // The next packet to deliver. + uint32_t last_frame_size_timestamps_ = 960; // Initial guess: 20 ms @ 48 kHz. }; } // namespace test