From 65881de6c81cf3f33b0f2f5f8f4a19716ee93fdc Mon Sep 17 00:00:00 2001 From: "henrik.lundin" Date: Wed, 26 Apr 2017 08:23:35 -0700 Subject: [PATCH] NetEq: Limit payload size for replacement audio input With this fix, the size of the fake encoded payload is limited to 120 ms at 48000 samples/second. BUG=webrtc:7467 Review-Url: https://codereview.webrtc.org/2838353002 Cr-Commit-Position: refs/heads/master@{#17891} --- .../neteq/tools/neteq_replacement_input.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) 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 9b550cbb2b..b2c3eef9f0 100644 --- a/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc +++ b/webrtc/modules/audio_coding/neteq/tools/neteq_replacement_input.cc @@ -85,13 +85,18 @@ void NetEqReplacementInput::ReplacePacket() { rtc::Optional next_hdr = source_->NextHeader(); RTC_DCHECK(next_hdr); uint8_t payload[12]; + RTC_DCHECK_LE(last_frame_size_timestamps_, 120 * 48); uint32_t input_frame_size_timestamps = last_frame_size_timestamps_; - if (next_hdr->sequenceNumber == packet_->header.sequenceNumber + 1) { - // Packets are in order. - input_frame_size_timestamps = - next_hdr->timestamp - packet_->header.timestamp; + const uint32_t timestamp_diff = + next_hdr->timestamp - packet_->header.timestamp; + if (next_hdr->sequenceNumber == packet_->header.sequenceNumber + 1 && + timestamp_diff <= 120 * 48) { + // Packets are in order and the timestamp diff is less than 5760 samples. + // Accept the timestamp diff as a valid frame size. + input_frame_size_timestamps = timestamp_diff; last_frame_size_timestamps_ = input_frame_size_timestamps; } + RTC_DCHECK_LE(input_frame_size_timestamps, 120 * 48); FakeDecodeFromFile::PrepareEncoded(packet_->header.timestamp, input_frame_size_timestamps, packet_->payload.size(), payload);