Fixing NetEqReplacementInput for reordered and missing packets

With this CL, the NetEqReplacementInput class handles reordered and
missing packets in a better way than before, by storing the last
confirmed packet size and using that when the next packet size cannot
be calculated.

NOTRY=True

Review-Url: https://codereview.webrtc.org/2319553003
Cr-Commit-Position: refs/heads/master@{#14122}
This commit is contained in:
henrik.lundin
2016-09-08 02:14:28 -07:00
committed by Commit bot
parent ac398f2a4c
commit 243c0e8066
2 changed files with 8 additions and 6 deletions

View File

@ -85,12 +85,12 @@ void NetEqReplacementInput::ReplacePacket() {
rtc::Optional<RTPHeader> 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,

View File

@ -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 <memory>
#include <set>
#include "webrtc/modules/audio_coding/neteq/tools/neteq_input.h"
@ -42,6 +43,7 @@ class NetEqReplacementInput : public NetEqInput {
const std::set<uint8_t> comfort_noise_types_;
const std::set<uint8_t> forbidden_types_;
std::unique_ptr<PacketData> packet_; // The next packet to deliver.
uint32_t last_frame_size_timestamps_ = 960; // Initial guess: 20 ms @ 48 kHz.
};
} // namespace test