Error handing in custom plugin

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Error handing in custom plugin

AlannY-2
Hi there, my name is Alan and I have a problems with GStreamer.

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);

When running ret is -5 which means GST_FLOW_ERROR. How to determine
where error occurred? What GST_FLOW_ERROR means.

(example code)
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);
   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;
}

Thank you.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error handing in custom plugin

Julien Isorce
Hi,

It seems that the negociate caps are not what you expected.
So check the negociate caps using -v option:
gst-launch-0.10 -v .....
The video size negociated should be printed.

Julien

2008/4/11, AlannY <[hidden email]>:
Hi there, my name is Alan and I have a problems with GStreamer.

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);

When running ret is -5 which means GST_FLOW_ERROR. How to determine
where error occurred? What GST_FLOW_ERROR means.

(example code)
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);
   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;
}

Thank you.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error handing in custom plugin

Tim-Philipp Müller-2
In reply to this post by AlannY-2
On Fri, 2008-04-11 at 11:10 +0400, AlannY wrote:

Hi,

> 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;
> }

Cheers
 -Tim



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Error handing in custom plugin

Tim-Philipp Müller-2
In reply to this post by Julien Isorce
On Fri, 2008-04-11 at 10:33 +0200, Julien Isorce wrote:

> It seems that the negotiated caps are not what you expected.

In that case you would/should usually get a NOT_NEGOTIATED flow return.

Cheers
 -Tim


-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel