Commit 21c61586 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller
Browse files

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
parent 3d006f6d
...@@ -49,6 +49,8 @@ struct _GstRTPBasePayloadPrivate ...@@ -49,6 +49,8 @@ struct _GstRTPBasePayloadPrivate
gint64 prop_max_ptime; gint64 prop_max_ptime;
gint64 caps_max_ptime; gint64 caps_max_ptime;
gboolean negotiated;
}; };
/* RTPBasePayload signals and args */ /* RTPBasePayload signals and args */
...@@ -361,6 +363,8 @@ gst_rtp_base_payload_sink_event_default (GstRTPBasePayload * rtpbasepayload, ...@@ -361,6 +363,8 @@ gst_rtp_base_payload_sink_event_default (GstRTPBasePayload * rtpbasepayload,
else else
res = TRUE; res = TRUE;
rtpbasepayload->priv->negotiated = res;
gst_event_unref (event); gst_event_unref (event);
break; break;
} }
...@@ -467,6 +471,9 @@ gst_rtp_base_payload_chain (GstPad * pad, GstObject * parent, ...@@ -467,6 +471,9 @@ gst_rtp_base_payload_chain (GstPad * pad, GstObject * parent,
if (!rtpbasepayload_class->handle_buffer) if (!rtpbasepayload_class->handle_buffer)
goto no_function; goto no_function;
if (!rtpbasepayload->priv->negotiated)
goto not_negotiated;
ret = rtpbasepayload_class->handle_buffer (rtpbasepayload, buffer); ret = rtpbasepayload_class->handle_buffer (rtpbasepayload, buffer);
return ret; return ret;
...@@ -479,6 +486,14 @@ no_function: ...@@ -479,6 +486,14 @@ no_function:
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
return GST_FLOW_ERROR; 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, ...@@ -858,8 +873,8 @@ gst_rtp_base_payload_prepare_push (GstRTPBasePayload * payload,
(is_list) ? -1 : gst_buffer_get_size (GST_BUFFER (obj)), (is_list) ? -1 : gst_buffer_get_size (GST_BUFFER (obj)),
payload->seqnum, data.rtptime, GST_TIME_ARGS (data.pts)); payload->seqnum, data.rtptime, GST_TIME_ARGS (data.pts));
if (g_atomic_int_compare_and_exchange (&payload-> if (g_atomic_int_compare_and_exchange (&payload->priv->
priv->notified_first_timestamp, 1, 0)) { notified_first_timestamp, 1, 0)) {
g_object_notify (G_OBJECT (payload), "timestamp"); g_object_notify (G_OBJECT (payload), "timestamp");
g_object_notify (G_OBJECT (payload), "seqnum"); g_object_notify (G_OBJECT (payload), "seqnum");
} }
...@@ -1079,6 +1094,7 @@ gst_rtp_base_payload_change_state (GstElement * element, ...@@ -1079,6 +1094,7 @@ gst_rtp_base_payload_change_state (GstElement * element,
rtpbasepayload->timestamp = rtpbasepayload->ts_base; rtpbasepayload->timestamp = rtpbasepayload->ts_base;
g_atomic_int_set (&rtpbasepayload->priv->notified_first_timestamp, 1); g_atomic_int_set (&rtpbasepayload->priv->notified_first_timestamp, 1);
priv->base_offset = GST_BUFFER_OFFSET_NONE; priv->base_offset = GST_BUFFER_OFFSET_NONE;
priv->negotiated = FALSE;
break; break;
default: default:
break; break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment