Gstreamer dev : custom source based on basesrc
Edgar Thier
edgar.thier at theimagingsource.com
Tue Jan 22 10:01:45 UTC 2019
Hi,
Gstreamer Buffer management consists out of multiple parts:
- The GstBufferPool - It contains all buffers that will be used by your src. Unless you have a good
reason to implement it, use the default implementation, like you already are.
- The single GstBuffer - consisting out of MetaData, timestamps and a pointer to GstMemory,
aka you actual image.
- Your image buffer - This can be allocated be gstreamer or externally, depending on your setup.
Most sources i have seen (usb/firewire/network) allocate buffers in their backend and give
a pointer to the buffer to gstreamer.
As is documented
(https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer-libs/html/GstPushSrc.html)
default sources will call create, which implicitly calls alloc and then fill.
That means you do not have to overwrite all functions.
By overwriting create the default implementations for alloc/fill will not be called.
You will have to call them manually or implement their functionality in create itself.
Depending on your setup you can call `gst_buffer_new_wrapped_full` for your existing buffer.
This will use the GstBuffer from the GstBufferPool that you receive in create and use
the image pointer you provide for the pipeline.
Examples for this would be:
https://github.com/AravisProject/aravis/blob/master/gst/gstaravis.c#L351
https://github.com/TheImagingSource/tiscamera/blob/master/src/gstreamer-1.0/gsttcamsrc.cpp#L1351
Both execute extra steps that can be ignored. And both allocate their image buffer externally in
their backends.
The other way would be to have gstreamer allocate a buffer for you by calling alloc,
filling that buffer with an image and delivering that. I have not worked with this method as of yet,
so I cannot offer you details or examples.
If I got any details wrong, please feel free to correct me.
-Edgar
More information about the gstreamer-devel
mailing list