webrtcstats: Unify 'packets-lost' data type to int64 86/273286/2
authorSangchul Lee <sc11.lee@samsung.com>
Mon, 28 Mar 2022 12:25:50 +0000 (21:25 +0900)
committerSangchul Lee <sc11.lee@samsung.com>
Fri, 1 Apr 2022 13:38:21 +0000 (22:38 +0900)
Previously, 'packets-lost' member of RTCReceivedRtpStreamStats had
a value of G_TYPE_INT from rtpsource or a value of G_TYPE_UINT64
from rtpjitterbuffer.
Because of the negative value of estimated amount of packets lost
in rtpsource as well as the description in
https://www.w3.org/TR/webrtc-stats/#dom-rtcreceivedrtpstreamstats
it is fixed to set this value with G_TYPE_INT64.

Change-Id: Ife744ab6d039fda1647c893089d1cacbc04a508a
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/2049>

subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcbin.c
subprojects/gst-plugins-bad/ext/webrtc/gstwebrtcstats.c
subprojects/gst-plugins-bad/tests/check/elements/webrtcbin.c

index 71f3591e35590428b3eff2b64757d44ac6e9b730..d172e97b292f21721bcc4586abeb6b36dd22fbb8 100644 (file)
@@ -7899,7 +7899,7 @@ gst_webrtc_bin_class_init (GstWebRTCBinClass * klass)
    * RTCReceivedStreamStats supported fields (https://w3c.github.io/webrtc-stats/#receivedrtpstats-dict*)
    *
    *  "packets-received"    G_TYPE_UINT64               number of packets received (only for local inbound)
-   *  "packets-lost"        G_TYPE_UINT64               number of packets lost
+   *  "packets-lost"        G_TYPE_INT64                number of packets lost
    *  "packets-discarded"   G_TYPE_UINT64               number of packets discarded
    *  "packets-repaired"    G_TYPE_UINT64               number of packets repaired
    *  "jitter"              G_TYPE_DOUBLE               packet jitter measured in seconds
index 3d31b4a0c38d94970935b25a00c7e548b6e5337a..04fc453c6af681677a60221b6c8a7299f2b2fc3d 100644 (file)
@@ -142,7 +142,7 @@ _get_stats_from_remote_rtp_source_stats (GstWebRTCBin * webrtc,
   /* RTCReceivedRtpStreamStats */
 
   if (gst_structure_get_int (source_stats, "rb-packetslost", &lost))
-    gst_structure_set (r_in, "packets-lost", G_TYPE_INT, lost, NULL);
+    gst_structure_set (r_in, "packets-lost", G_TYPE_INT64, (gint64) lost, NULL);
 
   if (clock_rate && gst_structure_get_uint (source_stats, "rb-jitter", &jitter))
     gst_structure_set (r_in, "jitter", G_TYPE_DOUBLE,
@@ -358,8 +358,11 @@ _get_stats_from_rtp_source_stats (GstWebRTCBin * webrtc,
 
     if (gst_structure_get_uint64 (source_stats, "packets-received", &packets))
       gst_structure_set (in, "packets-received", G_TYPE_UINT64, packets, NULL);
-    if (jb_stats)
-      gst_structure_set (in, "packets-lost", G_TYPE_UINT64, jb_lost, NULL);
+    if (jb_stats) {
+      gint64 packets_lost = jb_lost > G_MAXINT64 ?
+          G_MAXINT64 : (gint64) jb_lost;
+      gst_structure_set (in, "packets-lost", G_TYPE_INT64, packets_lost, NULL);
+    }
     if (gst_structure_get_uint (source_stats, "jitter", &jitter))
       gst_structure_set (in, "jitter", G_TYPE_DOUBLE,
           CLOCK_RATE_VALUE_TO_SECONDS (jitter, clock_rate), NULL);
index 9ed6937adef35be8b0e0c64f51f7811cef594cb5..ae0d4501d186a66c3b4618ad7c78d153bbb27956 100644 (file)
@@ -1395,7 +1395,7 @@ static void
 validate_inbound_rtp_stats (const GstStructure * s, const GstStructure * stats)
 {
   guint ssrc, fir, pli, nack;
-  gint packets_lost;
+  gint64 packets_lost;
   guint64 packets_received, bytes_received;
   double jitter;
   gchar *remote_id;
@@ -1412,8 +1412,8 @@ validate_inbound_rtp_stats (const GstStructure * s, const GstStructure * stats)
   fail_unless (gst_structure_get (s, "bytes-received", G_TYPE_UINT64,
           &bytes_received, NULL));
   fail_unless (gst_structure_get (s, "jitter", G_TYPE_DOUBLE, &jitter, NULL));
-  fail_unless (gst_structure_get (s, "packets-lost", G_TYPE_INT, &packets_lost,
-          NULL));
+  fail_unless (gst_structure_get (s, "packets-lost", G_TYPE_INT64,
+          &packets_lost, NULL));
   fail_unless (gst_structure_get (s, "remote-id", G_TYPE_STRING, &remote_id,
           NULL));
   fail_unless (gst_structure_get (stats, remote_id, GST_TYPE_STRUCTURE, &remote,
@@ -1429,7 +1429,7 @@ validate_remote_inbound_rtp_stats (const GstStructure * s,
     const GstStructure * stats)
 {
   guint ssrc;
-  gint packets_lost;
+  gint64 packets_lost;
   double jitter, rtt;
   gchar *local_id;
   GstStructure *local;
@@ -1438,8 +1438,8 @@ validate_remote_inbound_rtp_stats (const GstStructure * s,
 
   fail_unless (gst_structure_get (s, "ssrc", G_TYPE_UINT, &ssrc, NULL));
   fail_unless (gst_structure_get (s, "jitter", G_TYPE_DOUBLE, &jitter, NULL));
-  fail_unless (gst_structure_get (s, "packets-lost", G_TYPE_INT, &packets_lost,
-          NULL));
+  fail_unless (gst_structure_get (s, "packets-lost", G_TYPE_INT64,
+          &packets_lost, NULL));
   fail_unless (gst_structure_get (s, "round-trip-time", G_TYPE_DOUBLE, &rtt,
           NULL));
   fail_unless (gst_structure_get (s, "local-id", G_TYPE_STRING, &local_id,