ffmpegenc: ensure properly negotiated prior to processing

Doing so is even more pertinent in 0.11, since core assists much less
in setting up negotiation and feedback on handling caps event is more likely
to get lost.
This commit is contained in:
Mark Nauwelaerts 2011-06-30 09:18:42 +02:00
parent 1583b89942
commit bd5e3a51dd

View file

@ -752,6 +752,9 @@ gst_ffmpegenc_chain_video (GstPad * pad, GstBuffer * inbuf)
gint ret_size = 0, frame_size;
gboolean force_keyframe;
if (G_UNLIKELY (!ffmpegenc->opened))
goto not_negotiated;
GST_DEBUG_OBJECT (ffmpegenc,
"Received buffer of time %" GST_TIME_FORMAT,
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (inbuf)));
@ -835,6 +838,15 @@ gst_ffmpegenc_chain_video (GstPad * pad, GstBuffer * inbuf)
}
return gst_pad_push (ffmpegenc->srcpad, outbuf);
/* ERRORS */
not_negotiated:
{
GST_ELEMENT_ERROR (ffmpegenc, CORE, NEGOTIATION, (NULL),
("not configured to input format before data start"));
gst_buffer_unref (inbuf);
return GST_FLOW_NOT_NEGOTIATED;
}
}
static GstFlowReturn
@ -899,6 +911,9 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer * inbuf)
ffmpegenc = (GstFFMpegEnc *) (GST_OBJECT_PARENT (pad));
oclass = (GstFFMpegEncClass *) G_OBJECT_GET_CLASS (ffmpegenc);
if (G_UNLIKELY (!ffmpegenc->opened))
goto not_negotiated;
ctx = ffmpegenc->context;
size = gst_buffer_get_size (inbuf);
@ -1043,6 +1058,13 @@ gst_ffmpegenc_chain_audio (GstPad * pad, GstBuffer * inbuf)
return GST_FLOW_OK;
/* ERRORS */
not_negotiated:
{
GST_ELEMENT_ERROR (ffmpegenc, CORE, NEGOTIATION, (NULL),
("not configured to input format before data start"));
gst_buffer_unref (inbuf);
return GST_FLOW_NOT_NEGOTIATED;
}
push_failed:
{
GST_DEBUG_OBJECT (ffmpegenc, "Failed to push buffer %d (%s)", ret,