Limits reported cumulative packets lost to 0.

This ensures that we don't break clients that can't handle
negative values.

Bug: webrtc:9598
Change-Id: I33c3933982577752eceb738d7e0bd2a6825d2249
Reviewed-on: https://webrtc-review.googlesource.com/93020
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24230}
This commit is contained in:
Sebastian Jansson
2018-08-08 14:41:16 +02:00
committed by Commit Bot
parent 2a15267cb7
commit 436d036b62
2 changed files with 10 additions and 3 deletions

View File

@ -240,7 +240,10 @@ RtcpStatistics StreamStatisticianImpl::CalculateRtcpStatistics(
// Since cumulative loss is carried in a signed 24-bit field in RTCP, we may
// need to clamp it.
statistics.packets_lost = std::min(statistics.packets_lost, 0x7fffff);
statistics.packets_lost = std::max(statistics.packets_lost, -0x800000);
// TODO(bugs.webrtc.org/9598): This packets_lost should be signed according to
// RFC3550. However, old WebRTC implementations reads it as unsigned.
// Therefore we limit this to 0.
statistics.packets_lost = std::max(statistics.packets_lost, 0);
statistics.extended_highest_sequence_number = extended_seq_max;
// Note: internal jitter value is in Q4 and needs to be scaled by 1/16.
statistics.jitter = jitter_q4_ >> 4;