Ensures that packets_lost is always positive.

This is a quick fix to ensure that we don't wrap the value.  A proper
solution would be to ensure that the packets_lost field is signed and
handled as signed at all places it's used.

Bug: webrtc:9598
Change-Id: I3622f2a61aa3af57db6292ef4c0a8e97c4833aa4
Reviewed-on: https://webrtc-review.googlesource.com/92881
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Magnus Flodman <mflodman@webrtc.org>
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24212}
This commit is contained in:
Sebastian Jansson 2018-08-07 16:01:42 +02:00 committed by Commit Bot
parent f0d5fc9601
commit 5ca90f55ae

View File

@ -10,6 +10,8 @@
#include "video/report_block_stats.h"
#include <algorithm>
namespace webrtc {
namespace {
@ -33,7 +35,8 @@ void ReportBlockStats::Store(const RtcpStatistics& rtcp_stats,
uint32_t remote_ssrc,
uint32_t source_ssrc) {
RTCPReportBlock block;
block.packets_lost = rtcp_stats.packets_lost;
// TODO(srte): Remove this clamp when packets_lost is made signed.
block.packets_lost = std::max(0, rtcp_stats.packets_lost);
block.fraction_lost = rtcp_stats.fraction_lost;
block.extended_highest_sequence_number =
rtcp_stats.extended_highest_sequence_number;