help needed writing GstBaseSrc basic plugin for non generic capture card

pgousseau@hotmail.com pgousseau at hotmail.com
Fri Apr 22 10:53:23 PDT 2011


Hi All,


I have a non generic audio video capture device with multiple inputs and i am trying to integrate it as my first gstreamer plugin.

To start simple i am only aiming at creating an element with one video source. So I am extending GstBaseSrc.

The device provide mmap yuv buffers in either PAL or NTSC resolution through ioctl calls.

I have tried to take as an example the v4l2src source code.


i test it with the command

gst-launch-0.10 myfilter device="/dev/xecap0" video-mode=0 chan-bitmap=0xffff chan-select=0 ! fakesink


And get the following


/********************BEGIN**********************/


Setting pipeline to PAUSED ...

Pipeline is live and does not need PREROLL ...

Setting pipeline to PLAYING ...

New clock: GstSystemClock


(gst-launch-0.10:854): GStreamer-CRITICAL **: gst_pad_push: assertion `GST_IS_BUFFER (buffer)' failed

ERROR: from element /pipeline0/myfilter0: Internal data flow error.

Additional debug info:

gstbasesrc.c(2165): gst_base_src_loop (): /pipeline0/myfilter0:

streaming task paused, reason error (-5)

Execution ended after 426026 ns.

Setting pipeline to PAUSED ...

Setting pipeline to READY ...


(gst-launch-0.10:854): GStreamer-CRITICAL **: gst_mini_object_unref: assertion `mini_object->refcount > 0' failed

gst_myfilter_stopped

Setting pipeline to NULL ...

FREEING pipeline ...


/********************END***********************/


With gst-debug=*:3, everything seems fine until i get the following warning and the pipeline stops ...

/********************BEGIN**********************/

(gst-launch-0.10:796): GStreamer-CRITICAL **: gst_pad_push: assertion `GST_IS_BUFFER (buffer)' failed

0:00:00.211305419   796 0x929a770 INFO               basesrc gstbasesrc.c:2114:gst_base_src_loop:<myfilter0> pausing after gst_pad_push() = error

0:00:00.211320520   796 0x929a770 WARN               basesrc gstbasesrc.c:2165:gst_base_src_loop:<myfilter0> error: Internal data flow error.

0:00:00.211328857   796 0x929a770 WARN               basesrc gstbasesrc.c:2165:gst_base_src_loop:<myfilter0> error: streaming task paused, reason error (-5)

/********************END***********************/


I have implemented the following methods


gstbasesrc_class->set_caps = GST_DEBUG_FUNCPTR (gst_myfilter_set_caps);

gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_myfilter_start);

gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_myfilter_stop);

gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_myfilter_create);


I initialise the buffer in the set_caps method like this:


static gboolean

gst_myfilter_set_caps (GstBaseSrc * src, GstCaps * caps)

{

     .

     .

     .


     if (!gst_pad_set_caps (src->srcpad, caps))

    {

        GST_WARNING ("gst_myfilter_set_caps caps negotiation failed %" GST_PTR_FORMAT "from elem",

                caps, GST_ELEMENT_NAME(src));

        return FALSE;

    }


    .

    .

    .

    GST_BUFFER_DATA (filter->my_buffer) = (guchar*)dev_buf;

    GST_BUFFER_SIZE (filter->my_buffer) = (filter->video_mode == 0)?704*576*2:704*480*2;

    GST_BUFFER_FLAG_SET (filter->my_buffer, GST_BUFFER_FLAG_READONLY);

    gst_buffer_set_caps (GST_BUFFER (filter->my_buffer), caps);


   return TRUE;

}


Here is the create method, it always seems to get called 3 times ok untils the error shows which puzzle me the most.


static GstFlowReturn

gst_myfilter_create (GstBaseSrc * basesrc, guint64 offset, guint length,

    GstBuffer ** buffer)

{

    Gstmyfilter *src;


    GstState state = GST_STATE (basesrc);

    if(state != GST_STATE_PLAYING)

    {

        return GST_FLOW_WRONG_STATE;

    }


    src = GST_MYFILTER (basesrc);


    gchar * dev_buf = NULL;


    dev_error dev_ret = dev_get_framebuffer(src->chan_select, src->dev_handle, &dev_buf);


    if(dev_ret == DEV_ERROR || dev_buf == NULL)

    {

        return GST_FLOW_ERROR;

    }


    GST_BUFFER_OFFSET (src->my_buffer) = src->offset++;

    GST_BUFFER_OFFSET_END (src->my_buffer) = src->offset;

    GST_BUFFER_TIMESTAMP (src->my_buffer) = GST_CLOCK_TIME_NONE;


    GST_BUFFER_DATA (src->my_buffer) = (guint8*)dev_buf;


    *buffer = src->my_buffer;


    return GST_FLOW_OK;

}


Any ideas why the (gst-launch-0.10:796): GStreamer-CRITICAL **: gst_pad_push: assertion `GST_IS_BUFFER (buffer)' failed error shows up ?


Regards,


Pierre

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20110422/f5a2014a/attachment.htm>


More information about the gstreamer-devel mailing list