rtp: Add Packet Loss Indication (PLI) to statistics
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
diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c
index cc819fb..0203362 100644
--- a/gst/rtpmanager/rtpsession.c
+++ b/gst/rtpmanager/rtpsession.c
@@ -2391,6 +2391,8 @@
return;
rtp_session_request_local_key_unit (sess, src, FALSE, current_time);
+
+ src->stats.recv_pli_count++;
}
static void
@@ -3209,6 +3211,8 @@
source->send_pli = FALSE;
data->may_suppress = FALSE;
+
+ source->stats.sent_pli_count++;
}
/* construct NACK */
diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c
index 610d7ae..7c42205 100644
--- a/gst/rtpmanager/rtpsource.c
+++ b/gst/rtpmanager/rtpsource.c
@@ -238,6 +238,8 @@
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 @@
"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 @@
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);
}
diff --git a/gst/rtpmanager/rtpstats.h b/gst/rtpmanager/rtpstats.h
index 137ece3..f2062e9 100644
--- a/gst/rtpmanager/rtpstats.h
+++ b/gst/rtpmanager/rtpstats.h
@@ -135,6 +135,9 @@
guint64 packets_sent;
guint64 octets_sent;
+ guint sent_pli_count;
+ guint recv_pli_count;
+
/* when we received stuff */
GstClockTime prev_rtptime;
GstClockTime prev_rtcptime;