From 9a80cdbb40bfe4805b0cf81b34cc7613e8413675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 26 Jul 2018 16:43:28 +0300 Subject: [PATCH] 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 --- gst/rtp/gstrtpgstdepay.c | 7 +++++++ gst/rtp/gstrtpgstpay.c | 26 +++++++++++++++++++++++++- gst/rtp/gstrtpgstpay.h | 1 + 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/gst/rtp/gstrtpgstdepay.c b/gst/rtp/gstrtpgstdepay.c index 39028c9ceb..6a03f7ecb2 100644 --- a/gst/rtp/gstrtpgstdepay.c +++ b/gst/rtp/gstrtpgstdepay.c @@ -27,6 +27,8 @@ #include "gstrtpgstdepay.h" #include "gstrtputils.h" +#include + GST_DEBUG_CATEGORY_STATIC (rtpgstdepay_debug); #define GST_CAT_DEFAULT (rtpgstdepay_debug) @@ -558,6 +560,11 @@ missing_caps: { 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 f5de41041a..f2cfb36493 100644 --- a/gst/rtp/gstrtpgstpay.c +++ b/gst/rtp/gstrtpgstpay.c @@ -24,6 +24,7 @@ #include #include +#include #include "gstrtpgstpay.h" #include "gstrtputils.h" @@ -96,6 +97,8 @@ static GstFlowReturn gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * payload, 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 @@ gst_rtp_gst_pay_class_init (GstRtpGSTPayClass * klass) 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 @@ gst_rtp_gst_pay_sink_event (GstRTPBasePayload * payload, GstEvent * event) 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 @@ gst_rtp_gst_pay_sink_event (GstRTPBasePayload * payload, GstEvent * event) 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 @@ gst_rtp_gst_pay_handle_buffer (GstRTPBasePayload * basepayload, 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 f3272b20c7..6625a4dbca 100644 --- a/gst/rtp/gstrtpgstpay.h +++ b/gst/rtp/gstrtpgstpay.h @@ -56,6 +56,7 @@ struct _GstRtpGSTPay GstTagList *taglist; guint config_interval; GstClockTime last_config; + gboolean force_config; }; struct _GstRtpGSTPayClass