How can I set my custom memory buffer to v4l2src userptr?

Nicolas Dufresne nicolas at ndufresne.ca
Thu Mar 4 15:31:32 UTC 2021


Le jeudi 04 mars 2021 à 02:31 -0600, dongjin.ha a écrit :
> Hi all,
> 
> My c++ application runs the camera with
> gst_parse_launch("my_gst_command_string");
> For example, my command string is here.
> 
> "v4l2src device=/dev/video" + std::to_string(num) + " ! video/x-raw,
> format=UYVY, width=1920,height=1080 ! \
>         videoconvert ! video/x-raw, format=RGB !  appsink name=mysink"
> 
> Actually with this command, there's no problem.
> 
> But I want to allocate specific buffer and make my gst command use it.
> I could set v4l2src io-mode to userptr but I don't know how can I assign my
> buffer to my gstreamer pipeline in my application.
> Could you help or give some guide to assign my buffer to my gstreamer
> pipeline?

If you enable userptr, v4l2src will use downstream buffers as provided by pool
in the allocation query. If videoconvert is in active, videoconvert will be the
provider. With appsink, to handle the allocation query, you need to use a pad
probe, this is not very hard. An example, it's not offering any pool in this
case though, left as an exercise:

https://gitlab.freedesktop.org/mesa/kmscube/-/blob/master/gst-decoder.c#L242

WARNING, V4L2 drivers don't always operate with virtual memory. Drivers also
have limited support for user provided strides. Youre millage may vary from
platform to platform. Also, userptr requires bling cache flushing, as we cannot
assume if it will be used by CPU or Device. This has an important performance
impact. I'm not sure why you need this, but I'm sure it will be difficult and
you should handle a copy fallback.


> 
> Thanks in advance.
> 
> 
> 
> --
> Sent from: http://gstreamer-devel.966125.n4.nabble.com/
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel




More information about the gstreamer-devel mailing list