Prevent updating state in the delay manager if the packet was reordered.
Currently, if the last packet was reordered (e.g. due to retransmission) then the next packet's inter-arrival time will be estimated incorrectly due to the jump in sequence numbers. This change prevents that by not resetting the stopwatch on reordered packets. This will also better estimate inter-arrival times when we have multiple reordered packets in a burst. Currently we would only measure the iat of the first reordered packet correctly and not the ones coming after it. There is a slight risk introducing this: If we would receive an out of order packet far into the future (in sequence numbers) and then continue getting packets in the normal order, then we would not update the current sequence number for these and incorrectly estimate their inter-arrival times since they would all be considered reordered. Change-Id: Ic938a37cbddf1cb9c30b610218f56794568d3d01 Bug: webrtc:10178 Reviewed-on: https://webrtc-review.googlesource.com/c/119949 Reviewed-by: Minyue Li <minyue@webrtc.org> Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org> Commit-Queue: Jakob Ivarsson <jakobi@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26572}
This commit is contained in:
committed by
Commit Bot
parent
9025bd5142
commit
e98954c35e
@ -34,6 +34,8 @@ constexpr int kCumulativeSumDrift = 2; // Drift term for cumulative sum
|
||||
// Steady-state forgetting factor for |iat_vector_|, 0.9993 in Q15.
|
||||
constexpr int kIatFactor_ = 32745;
|
||||
constexpr int kMaxIat = 64; // Max inter-arrival time to register.
|
||||
constexpr int kMaxReorderedPackets =
|
||||
10; // Max number of consecutive reordered packets.
|
||||
|
||||
absl::optional<int> GetForcedLimitProbability() {
|
||||
constexpr char kForceTargetDelayPercentileFieldTrial[] =
|
||||
@ -63,6 +65,7 @@ namespace webrtc {
|
||||
|
||||
DelayManager::DelayManager(size_t max_packets_in_buffer,
|
||||
int base_min_target_delay_ms,
|
||||
bool enable_rtx_handling,
|
||||
DelayPeakDetector* peak_detector,
|
||||
const TickTimer* tick_timer)
|
||||
: first_packet_received_(false),
|
||||
@ -85,7 +88,8 @@ DelayManager::DelayManager(size_t max_packets_in_buffer,
|
||||
last_pack_cng_or_dtmf_(1),
|
||||
frame_length_change_experiment_(
|
||||
field_trial::IsEnabled("WebRTC-Audio-NetEqFramelengthExperiment")),
|
||||
forced_limit_probability_(GetForcedLimitProbability()) {
|
||||
forced_limit_probability_(GetForcedLimitProbability()),
|
||||
enable_rtx_handling_(enable_rtx_handling) {
|
||||
assert(peak_detector); // Should never be NULL.
|
||||
RTC_DCHECK_GE(base_min_target_delay_ms_, 0);
|
||||
RTC_DCHECK_LE(minimum_delay_ms_, maximum_delay_ms_);
|
||||
@ -146,6 +150,7 @@ int DelayManager::Update(uint16_t sequence_number,
|
||||
rtc::saturated_cast<int>(1000 * packet_len_samp / sample_rate_hz);
|
||||
}
|
||||
|
||||
bool reordered = false;
|
||||
if (packet_len_ms > 0) {
|
||||
// Cannot update statistics unless |packet_len_ms| is valid.
|
||||
// Calculate inter-arrival time (IAT) in integer "packet times"
|
||||
@ -158,7 +163,6 @@ int DelayManager::Update(uint16_t sequence_number,
|
||||
}
|
||||
|
||||
// Check for discontinuous packet sequence and re-ordering.
|
||||
bool reordered = false;
|
||||
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
|
||||
@ -183,6 +187,12 @@ int DelayManager::Update(uint16_t sequence_number,
|
||||
LimitTargetLevel();
|
||||
} // End if (packet_len_ms > 0).
|
||||
|
||||
if (enable_rtx_handling_ && reordered &&
|
||||
num_reordered_packets_ < kMaxReorderedPackets) {
|
||||
++num_reordered_packets_;
|
||||
return 0;
|
||||
}
|
||||
num_reordered_packets_ = 0;
|
||||
// Prepare for next packet arrival.
|
||||
packet_iat_stopwatch_ = tick_timer_->GetNewStopwatch();
|
||||
last_seq_no_ = sequence_number;
|
||||
|
||||
Reference in New Issue
Block a user