From 21c61586ad374a69f155b5bb29581fa2b367646d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim-Philipp=20M=C3=BCller?= Date: Thu, 6 Sep 2012 18:16:54 +0100 Subject: [PATCH] rtpbasepayload: error out if no CAPS event was received before buffers Most payloaders set/send their own output format from the setcaps function, so if we don't get input caps, things probably wont' work right, even if the input format is fixed (as in the case of the mpeg-ts payloader for example). https://bugzilla.gnome.org/show_bug.cgi?id=683428 --- gst-libs/gst/rtp/gstrtpbasepayload.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/gst-libs/gst/rtp/gstrtpbasepayload.c b/gst-libs/gst/rtp/gstrtpbasepayload.c index a07e98b7d5..edad0690d2 100644 --- a/gst-libs/gst/rtp/gstrtpbasepayload.c +++ b/gst-libs/gst/rtp/gstrtpbasepayload.c @@ -49,6 +49,8 @@ struct _GstRTPBasePayloadPrivate gint64 prop_max_ptime; gint64 caps_max_ptime; + + gboolean negotiated; }; /* RTPBasePayload signals and args */ @@ -361,6 +363,8 @@ gst_rtp_base_payload_sink_event_default (GstRTPBasePayload * rtpbasepayload, else res = TRUE; + rtpbasepayload->priv->negotiated = res; + gst_event_unref (event); break; } @@ -467,6 +471,9 @@ gst_rtp_base_payload_chain (GstPad * pad, GstObject * parent, if (!rtpbasepayload_class->handle_buffer) goto no_function; + if (!rtpbasepayload->priv->negotiated) + goto not_negotiated; + ret = rtpbasepayload_class->handle_buffer (rtpbasepayload, buffer); return ret; @@ -479,6 +486,14 @@ no_function: gst_buffer_unref (buffer); return GST_FLOW_ERROR; } +not_negotiated: + { + GST_ELEMENT_ERROR (rtpbasepayload, CORE, NEGOTIATION, (NULL), + ("No input format was negotiated, i.e. no caps event was received. " + "Perhaps you need a parser or typefind element before the payloader")); + gst_buffer_unref (buffer); + return GST_FLOW_NOT_NEGOTIATED; + } } /** @@ -858,8 +873,8 @@ gst_rtp_base_payload_prepare_push (GstRTPBasePayload * payload, (is_list) ? -1 : gst_buffer_get_size (GST_BUFFER (obj)), payload->seqnum, data.rtptime, GST_TIME_ARGS (data.pts)); - if (g_atomic_int_compare_and_exchange (&payload-> - priv->notified_first_timestamp, 1, 0)) { + if (g_atomic_int_compare_and_exchange (&payload->priv-> + notified_first_timestamp, 1, 0)) { g_object_notify (G_OBJECT (payload), "timestamp"); g_object_notify (G_OBJECT (payload), "seqnum"); } @@ -1079,6 +1094,7 @@ gst_rtp_base_payload_change_state (GstElement * element, rtpbasepayload->timestamp = rtpbasepayload->ts_base; g_atomic_int_set (&rtpbasepayload->priv->notified_first_timestamp, 1); priv->base_offset = GST_BUFFER_OFFSET_NONE; + priv->negotiated = FALSE; break; default: break;