rtpstats: Keep number of nacks sent/received per source
authorSantiago Carot-Nemesio <scarot@twilio.com>
Mon, 2 Jan 2017 12:42:04 +0000 (13:42 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Tue, 24 Jan 2017 10:38:50 +0000 (12:38 +0200)
Currently, the nack packets sent or received are kept at session level,
which makes it impossible to distinguish how many of these packages were
sent/received per ssrc when several sources are in the same session. This
patch is aligned with the https://www.w3.org/TR/webrtc-stats/#dom-rtcrtpstreamstats

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

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

index 7db89e0..bcbc528 100644 (file)
@@ -2774,6 +2774,8 @@ rtp_session_process_feedback (RTPSession * sess, GstRTCPPacket * packet,
       case GST_RTCP_TYPE_RTPFB:
         switch (fbtype) {
           case GST_RTCP_RTPFB_TYPE_NACK:
+            if (src)
+              src->stats.recv_nack_count++;
             rtp_session_process_nack (sess, sender_ssrc, media_ssrc,
                 fci_data, fci_length, current_time);
             break;
@@ -3526,6 +3528,7 @@ session_nack (const gchar * key, RTPSource * source, ReportData * data)
 
   rtp_source_clear_nacks (source);
   data->may_suppress = FALSE;
+  source->stats.sent_nack_count += n_nacks;
 }
 
 /* perform cleanup of sources that timed out */
index b0177d4..3554e0d 100644 (file)
@@ -271,6 +271,8 @@ rtp_source_reset (RTPSource * src)
 
   src->stats.sent_pli_count = 0;
   src->stats.sent_fir_count = 0;
+  src->stats.sent_nack_count = 0;
+  src->stats.recv_nack_count = 0;
 }
 
 static void
@@ -400,7 +402,9 @@ rtp_source_create_stats (RTPSource * src)
       "sent-pli-count", G_TYPE_UINT, src->stats.sent_pli_count,
       "recv-pli-count", G_TYPE_UINT, src->stats.recv_pli_count,
       "sent-fir-count", G_TYPE_UINT, src->stats.sent_fir_count,
-      "recv-fir-count", G_TYPE_UINT, src->stats.recv_fir_count, NULL);
+      "recv-fir-count", G_TYPE_UINT, src->stats.recv_fir_count,
+      "sent-nack-count", G_TYPE_UINT, src->stats.sent_nack_count,
+      "recv-nack-count", G_TYPE_UINT, src->stats.recv_nack_count, NULL);
 
   /* get the last SR. */
   have_sr = rtp_source_get_last_sr (src, &time, &ntptime, &rtptime,
index 14ba9da..a7803b5 100644 (file)
@@ -142,6 +142,8 @@ typedef struct {
   guint        recv_pli_count;
   guint        sent_fir_count;
   guint        recv_fir_count;
+  guint        sent_nack_count;
+  guint        recv_nack_count;
 
   /* when we received stuff */
   GstClockTime prev_rtptime;