Remove zero lower bound of estimated inter-arrival time.

When we offset the measured inter-arrival time due to packet loss, it will sometimes be less than zero. This is the correct value to use when calculating the relative packet arrival delay.

Bug: webrtc:10333
Change-Id: I14a68563a379fa0b9444684304362503a6f1bfca
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/127547
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Jakob Ivarsson‎ <jakobi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27164}
This commit is contained in:
Jakob Ivarsson
2019-03-18 16:48:15 +01:00
committed by Commit Bot
parent 59c8569ed9
commit 37b5662a5c

View File

@ -223,14 +223,11 @@ int DelayManager::Update(uint16_t sequence_number,
// Check for discontinuous packet sequence and re-ordering.
if (IsNewerSequenceNumber(sequence_number, last_seq_no_ + 1)) {
// Compensate for gap in the sequence numbers. Reduce IAT with the
// expected extra time due to lost packets, but ensure that the IAT is
// not negative.
// expected extra time due to lost packets.
int packet_offset =
static_cast<uint16_t>(sequence_number - last_seq_no_ - 1);
iat_packets -= packet_offset;
iat_packets = std::max(iat_packets, 0);
iat_ms -= packet_offset * packet_len_ms;
iat_ms = std::max(iat_ms, 0);
} else if (!IsNewerSequenceNumber(sequence_number, last_seq_no_)) {
int packet_offset =
static_cast<uint16_t>(last_seq_no_ + 1 - sequence_number);
@ -259,8 +256,9 @@ int DelayManager::Update(uint16_t sequence_number,
break;
}
case INTER_ARRIVAL_TIME: {
// Saturate IAT at maximum value.
iat_packets = std::min(iat_packets, histogram_->NumBuckets() - 1);
// Saturate IAT between 0 and maximum value.
iat_packets =
std::max(std::min(iat_packets, histogram_->NumBuckets() - 1), 0);
histogram_->Add(iat_packets);
break;
}