[gst-devel] Error handing in custom plugin
t.i.m at zen.co.uk
Fri Apr 11 10:35:29 CEST 2008
On Fri, 2008-04-11 at 11:10 +0400, AlannY wrote:
> I'm writing a custom plugin (still newbie) and I need some error
> handling, but I really not understand how to do it. In the _chain()
> function I have statement:
> int ret = gst_pad_push (filter->srcpad, buffer);
You should probably use GstFlowReturn ret here.
> When running ret is -5 which means GST_FLOW_ERROR. How to determine
> where error occurred? What GST_FLOW_ERROR means.
You don't have to know really. The downstream element should have posted
an error message on the bus already. All your plugin has to do is to
pass the flow return upstream as quickly as possible.
> static GstFlowReturn
> gst_myplugin_chain (GstPad * pad, GstBuffer * buf)
> Gstmyplugin *plugin = GST_MYPLUGIN (GST_OBJECT_PARENT (pad));
> GstBuffer *buffer;
> gst_pad_alloc_buffer_and_set_caps (plugin->srcpad,
> GST_BUFFER_OFFSET_NONE, plugin->width*plugin->height*3, GST_PAD_CAPS
> (pad), &buffer);
You must check the return value of gst_pad_alloc_buffer_*() here.
> gst_buffer_copy_metadata(buffer, buf, GST_BUFFER_COPY_ALL);
> memcpy(buffer->data, buf->data, buf->size);
> int ret = gst_pad_push (plugin->srcpad, buffer);
> g_print("%d\n", ret);
> return ret;
More information about the gstreamer-devel