Help for creating a new source
Nicolas Dufresne
nicolas.dufresne at collabora.com
Thu Dec 11 12:50:01 PST 2014
Le 12/10/2014 11:06 AM, Ottavio Campana a écrit :
> # is there an example of a source that I can study? the GStreamer Plugin
> Writer's Guide refers to GstBaseSrc, but I am not able to understand
> chapter 23 well
Any source element, you could look at v4l2src.
> # what is the difference between finalize and dispose? Which one should I
> use when I close the pipeline to free my resources?
It's a GObject thing, dispose() should drop references
(g_object_unref()) and can be called multiple time, finalize should free
the rest (and will be called only once). Though in GStreamer most base
class have proper virtual method where to open and close HW handles, and
these are bound to the pipeline state. So very few things goes there in
fact.
> # if I have an error during the init function, what's the best way to fail?
You should never have an error during an instance init. Instead you
should be implementing base class start()/stop() virtual method to
initialize your HW. In the case of GstBaseSrc, these method have a
return value where FALSE mean failure. You must post an error on the bus
in order to let the application know why. See GST_ELEMENT_ERROR().
> # In the reference software that I have for my system , there is a loop
> that gets frames from the hardware. In which function do I have to put
> this code?
In the case of GstBaseSrc, the base class will run a thread for you, and
call the create() virtual method every time a should be produced. You
can block in that method, simply make sure it can be unblocked through
unlock() virtual method.
good luck,
Nicolas
More information about the gstreamer-devel
mailing list