rtpgstpay: Add support for force-keyunit events
This triggers immediate re-sending of the configuration data in-band.
https://bugzilla.gnome.org/show_bug.cgi?id=796877
diff --git a/gst/rtp/gstrtpgstdepay.c b/gst/rtp/gstrtpgstdepay.c
index 39028c9..6a03f7e 100644
--- a/gst/rtp/gstrtpgstdepay.c
+++ b/gst/rtp/gstrtpgstdepay.c
@@ -27,6 +27,8 @@
#include "gstrtpgstdepay.h"
#include "gstrtputils.h"
+#include <gst/video/video.h>
+
GST_DEBUG_CATEGORY_STATIC (rtpgstdepay_debug);
#define GST_CAT_DEFAULT (rtpgstdepay_debug)
@@ -558,6 +560,11 @@
{
GST_INFO_OBJECT (rtpgstdepay, "No caps received yet %u", CV);
gst_buffer_unref (outbuf);
+
+ gst_pad_push_event (GST_RTP_BASE_DEPAYLOAD_SINKPAD (rtpgstdepay),
+ gst_video_event_new_upstream_force_key_unit (GST_CLOCK_TIME_NONE,
+ TRUE, 0));
+
return NULL;
}
}
diff --git a/gst/rtp/gstrtpgstpay.c b/gst/rtp/gstrtpgstpay.c
index f5de410..f2cfb36 100644
--- a/gst/rtp/gstrtpgstpay.c
+++ b/gst/rtp/gstrtpgstpay.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <gst/rtp/gstrtpbuffer.h>
+#include <gst/video/video.h>
#include "gstrtpgstpay.h"
#include "gstrtputils.h"
@@ -96,6 +97,8 @@
GstBuffer * buffer);
static gboolean gst_rtp_gst_pay_sink_event (GstRTPBasePayload * payload,
GstEvent * event);
+static gboolean gst_rtp_gst_pay_src_event (GstRTPBasePayload * payload,
+ GstEvent * event);
#define gst_rtp_gst_pay_parent_class parent_class
G_DEFINE_TYPE (GstRtpGSTPay, gst_rtp_gst_pay, GST_TYPE_RTP_BASE_PAYLOAD);
@@ -139,6 +142,7 @@
gstrtpbasepayload_class->set_caps = gst_rtp_gst_pay_setcaps;
gstrtpbasepayload_class->handle_buffer = gst_rtp_gst_pay_handle_buffer;
gstrtpbasepayload_class->sink_event = gst_rtp_gst_pay_sink_event;
+ gstrtpbasepayload_class->src_event = gst_rtp_gst_pay_src_event;
GST_DEBUG_CATEGORY_INIT (gst_rtp_pay_debug, "rtpgstpay", 0,
"rtpgstpay element");
@@ -504,6 +508,10 @@
rtpgstpay = GST_RTP_GST_PAY (payload);
+ if (gst_video_event_is_force_key_unit (event)) {
+ g_atomic_int_set (&rtpgstpay->force_config, TRUE);
+ }
+
ret =
GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->sink_event (payload,
gst_event_ref (event));
@@ -572,6 +580,20 @@
return ret;
}
+static gboolean
+gst_rtp_gst_pay_src_event (GstRTPBasePayload * payload, GstEvent * event)
+{
+ GstRtpGSTPay *rtpgstpay;
+
+ rtpgstpay = GST_RTP_GST_PAY (payload);
+
+ if (gst_video_event_is_force_key_unit (event)) {
+ g_atomic_int_set (&rtpgstpay->force_config, TRUE);
+ }
+
+ return GST_RTP_BASE_PAYLOAD_CLASS (parent_class)->src_event (payload, event);
+}
+
static void
gst_rtp_gst_pay_send_config (GstRtpGSTPay * rtpgstpay,
GstClockTime running_time)
@@ -621,7 +643,9 @@
timestamp);
/* check if we need to send the caps and taglist now */
- if (rtpgstpay->config_interval > 0) {
+ if (rtpgstpay->config_interval > 0
+ || g_atomic_int_compare_and_exchange (&rtpgstpay->force_config, TRUE,
+ FALSE)) {
GST_DEBUG_OBJECT (rtpgstpay,
"running time %" GST_TIME_FORMAT ", last config %" GST_TIME_FORMAT,
GST_TIME_ARGS (running_time), GST_TIME_ARGS (rtpgstpay->last_config));
diff --git a/gst/rtp/gstrtpgstpay.h b/gst/rtp/gstrtpgstpay.h
index f3272b2..6625a4d 100644
--- a/gst/rtp/gstrtpgstpay.h
+++ b/gst/rtp/gstrtpgstpay.h
@@ -56,6 +56,7 @@
GstTagList *taglist;
guint config_interval;
GstClockTime last_config;
+ gboolean force_config;
};
struct _GstRtpGSTPayClass