rtp: Add Packet Loss Indication (PLI) to statistics
authorSantiago Carot-Nemesio <sancane@gmail.com>
Tue, 3 Mar 2015 15:01:53 +0000 (16:01 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 4 Mar 2015 11:04:07 +0000 (12:04 +0100)
This is helpful to provide statistics in the format defined in
http://w3c.github.io/webrtc-stats/#dictionary-rtcrtpstreamstats-members.

https://bugzilla.gnome.org/show_bug.cgi?id=745587

gst/rtpmanager/rtpsession.c
gst/rtpmanager/rtpsource.c
gst/rtpmanager/rtpstats.h

index cc819fb..0203362 100644 (file)
@@ -2391,6 +2391,8 @@ rtp_session_process_pli (RTPSession * sess, guint32 sender_ssrc,
     return;
 
   rtp_session_request_local_key_unit (sess, src, FALSE, current_time);
+
+  src->stats.recv_pli_count++;
 }
 
 static void
@@ -3209,6 +3211,8 @@ session_pli (const gchar * key, RTPSource * source, ReportData * data)
 
   source->send_pli = FALSE;
   data->may_suppress = FALSE;
+
+  source->stats.sent_pli_count++;
 }
 
 /* construct NACK */
index 610d7ae..7c42205 100644 (file)
@@ -238,6 +238,8 @@ rtp_source_reset (RTPSource * src)
   src->stats.last_rtptime = GST_CLOCK_TIME_NONE;
   src->stats.last_rtcptime = GST_CLOCK_TIME_NONE;
   g_array_set_size (src->nacks, 0);
+
+  src->stats.sent_pli_count = 0;
 }
 
 static void
@@ -364,7 +366,9 @@ rtp_source_create_stats (RTPSource * src)
       "bitrate", G_TYPE_UINT64, src->bitrate,
       "packets-lost", G_TYPE_INT,
       (gint) rtp_stats_get_packets_lost (&src->stats), "jitter", G_TYPE_UINT,
-      (guint) (src->stats.jitter >> 4), NULL);
+      (guint) (src->stats.jitter >> 4),
+      "sent-pli-count", G_TYPE_UINT, src->stats.sent_pli_count,
+      "recv-pli-count", G_TYPE_UINT, src->stats.recv_pli_count, NULL);
 
   /* get the last SR. */
   have_sr = rtp_source_get_last_sr (src, &time, &ntptime, &rtptime,
@@ -942,6 +946,7 @@ init_seq (RTPSource * src, guint16 seq)
   src->stats.bytes_received = 0;
   src->stats.prev_received = 0;
   src->stats.prev_expected = 0;
+  src->stats.recv_pli_count = 0;
 
   GST_DEBUG ("base_seq %d", seq);
 }
index 137ece3..f2062e9 100644 (file)
@@ -135,6 +135,9 @@ typedef struct {
   guint64      packets_sent;
   guint64      octets_sent;
 
+  guint        sent_pli_count;
+  guint        recv_pli_count;
+
   /* when we received stuff */
   GstClockTime prev_rtptime;
   GstClockTime prev_rtcptime;