From be20ef789d7ac255ac72d17afe14e35b063cd2c1 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Thu, 6 Sep 2018 12:32:31 +0200 Subject: [PATCH] Adds maximum burst length to InterArrival class. This restricts the maximum burst length to receive times 100 ms apart. Currently packets will be considered part of the same burst as long as they are received within 5 ms from the previous packet. This can happen when recovering from large network buffers. Bug: webrtc:9718 Change-Id: I73027ddaae922cb7bb9a477cf29b4f0036ce6966 Reviewed-on: https://webrtc-review.googlesource.com/98280 Commit-Queue: Sebastian Jansson Reviewed-by: Stefan Holmer Cr-Commit-Position: refs/heads/master@{#24601} --- modules/remote_bitrate_estimator/inter_arrival.cc | 11 +++++++++-- modules/remote_bitrate_estimator/inter_arrival.h | 7 ++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/modules/remote_bitrate_estimator/inter_arrival.cc b/modules/remote_bitrate_estimator/inter_arrival.cc index b779e41797..3a0f579052 100644 --- a/modules/remote_bitrate_estimator/inter_arrival.cc +++ b/modules/remote_bitrate_estimator/inter_arrival.cc @@ -19,6 +19,7 @@ namespace webrtc { static const int kBurstDeltaThresholdMs = 5; +static const int kMaxBurstDurationMs = 100; InterArrival::InterArrival(uint32_t timestamp_group_length_ticks, double timestamp_to_ms_coeff, @@ -46,6 +47,7 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp, // have two frames of data to process. current_timestamp_group_.timestamp = timestamp; current_timestamp_group_.first_timestamp = timestamp; + current_timestamp_group_.first_arrival_ms = arrival_time_ms; } else if (!PacketInOrder(timestamp)) { return false; } else if (NewTimestampGroup(arrival_time_ms, timestamp)) { @@ -93,6 +95,7 @@ bool InterArrival::ComputeDeltas(uint32_t timestamp, // The new timestamp is now the current frame. current_timestamp_group_.first_timestamp = timestamp; current_timestamp_group_.timestamp = timestamp; + current_timestamp_group_.first_arrival_ms = arrival_time_ms; current_timestamp_group_.size = 0; } else { current_timestamp_group_.timestamp = @@ -147,8 +150,12 @@ bool InterArrival::BelongsToBurst(int64_t arrival_time_ms, if (ts_delta_ms == 0) return true; int propagation_delta_ms = arrival_time_delta_ms - ts_delta_ms; - return propagation_delta_ms < 0 && - arrival_time_delta_ms <= kBurstDeltaThresholdMs; + if (propagation_delta_ms < 0 && + arrival_time_delta_ms <= kBurstDeltaThresholdMs && + arrival_time_ms - current_timestamp_group_.first_arrival_ms < + kMaxBurstDurationMs) + return true; + return false; } void InterArrival::Reset() { diff --git a/modules/remote_bitrate_estimator/inter_arrival.h b/modules/remote_bitrate_estimator/inter_arrival.h index f46bf4425d..f2facd47c2 100644 --- a/modules/remote_bitrate_estimator/inter_arrival.h +++ b/modules/remote_bitrate_estimator/inter_arrival.h @@ -54,13 +54,18 @@ class InterArrival { private: struct TimestampGroup { TimestampGroup() - : size(0), first_timestamp(0), timestamp(0), complete_time_ms(-1) {} + : size(0), + first_timestamp(0), + timestamp(0), + first_arrival_ms(-1), + complete_time_ms(-1) {} bool IsFirstPacket() const { return complete_time_ms == -1; } size_t size; uint32_t first_timestamp; uint32_t timestamp; + int64_t first_arrival_ms; int64_t complete_time_ms; int64_t last_system_time_ms; };