Generate signed packets_lost in WebRTC-stats
Bug: webrtc:8626
Change-Id: Ibeca29c5bb01e57c87fbf6a3c8589eb4e03089d5
Reviewed-on: https://webrtc-review.googlesource.com/32660
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21241}diff --git a/api/stats/rtcstats_objects.h b/api/stats/rtcstats_objects.h
index b0cf3d0..a052c17 100644
--- a/api/stats/rtcstats_objects.h
+++ b/api/stats/rtcstats_objects.h
@@ -361,7 +361,7 @@
RTCStatsMember<uint32_t> packets_received;
RTCStatsMember<uint64_t> bytes_received;
- RTCStatsMember<uint32_t> packets_lost;
+ RTCStatsMember<int32_t> packets_lost; // Signed per RFC 3550
// TODO(hbos): Collect and populate this value for both "audio" and "video",
// currently not collected for "video". https://bugs.webrtc.org/7065
RTCStatsMember<double> jitter;
diff --git a/pc/rtcstats_integrationtest.cc b/pc/rtcstats_integrationtest.cc
index b6c92f3..158d54b 100644
--- a/pc/rtcstats_integrationtest.cc
+++ b/pc/rtcstats_integrationtest.cc
@@ -633,7 +633,9 @@
}
verifier.TestMemberIsNonNegative<uint32_t>(inbound_stream.packets_received);
verifier.TestMemberIsNonNegative<uint64_t>(inbound_stream.bytes_received);
- verifier.TestMemberIsNonNegative<uint32_t>(inbound_stream.packets_lost);
+ // packets_lost is defined as signed, but this should never happen in
+ // this test. See RFC 3550.
+ verifier.TestMemberIsNonNegative<int32_t>(inbound_stream.packets_lost);
if (inbound_stream.media_type.is_defined() &&
*inbound_stream.media_type == "video") {
verifier.TestMemberIsUndefined(inbound_stream.jitter);
diff --git a/pc/rtcstatscollector.cc b/pc/rtcstatscollector.cc
index aa90179..915aabf 100644
--- a/pc/rtcstatscollector.cc
+++ b/pc/rtcstatscollector.cc
@@ -224,7 +224,7 @@
inbound_stats->bytes_received =
static_cast<uint64_t>(media_receiver_info.bytes_rcvd);
inbound_stats->packets_lost =
- static_cast<uint32_t>(media_receiver_info.packets_lost);
+ static_cast<int32_t>(media_receiver_info.packets_lost);
inbound_stats->fraction_lost =
static_cast<double>(media_receiver_info.fraction_lost);
}
diff --git a/pc/rtcstatscollector_unittest.cc b/pc/rtcstatscollector_unittest.cc
index 413b13b..8047dde 100644
--- a/pc/rtcstatscollector_unittest.cc
+++ b/pc/rtcstatscollector_unittest.cc
@@ -1817,7 +1817,7 @@
voice_media_info.receivers[0].local_stats.push_back(
cricket::SsrcReceiverInfo());
voice_media_info.receivers[0].local_stats[0].ssrc = 1;
- voice_media_info.receivers[0].packets_lost = 42;
+ voice_media_info.receivers[0].packets_lost = -1; // Signed per RFC3550
voice_media_info.receivers[0].packets_rcvd = 2;
voice_media_info.receivers[0].bytes_rcvd = 3;
voice_media_info.receivers[0].codec_payload_type = 42;
@@ -1867,7 +1867,7 @@
expected_audio.codec_id = "RTCCodec_InboundAudio_42";
expected_audio.packets_received = 2;
expected_audio.bytes_received = 3;
- expected_audio.packets_lost = 42;
+ expected_audio.packets_lost = -1;
expected_audio.jitter = 4.5;
expected_audio.fraction_lost = 5.5;