<html><head><style>pre,code,address {
margin: 0px;
}
h1,h2,h3,h4,h5,h6 {
margin-top: 0.2em;
margin-bottom: 0.2em;
}
ol,ul {
margin-top: 0em;
margin-bottom: 0em;
}
blockquote {
margin-top: 0em;
margin-bottom: 0em;
}
</style></head><body><div>Le mardi 22 août 2023 à 12:14 +0300, Regine Issan via gstreamer-devel a écrit :</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr">Hello Everyone,<br><br>I have an app that captures frames from a video device using v4l2.<br>the app should support all i-o modes.<br>I am mostly interested in userptr mode.<br><br>when i run the code with physical camera it works (with userptr mode).<br>when i run the same code with v4l2loopback camera and gstreamer, <br>it fails. calling VIDIOC_REQBUFS with V4L2_MEMEORY_USERPTR returns not supported.<br><br><div>in in link: <a href="https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/1028">https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/1028</a><br> <a href="https://gitlab.freedesktop.org/ndufresne" class="gmail-author-name-link gmail-js-user-link gmail-gl-overflow-hidden gmail-gl-overflow-wrap-break"><span class="gmail-note-header-author-name gmail-gl-font-weight-bold">Nicolas Dufresne</span></a> pointed me out that v4l2loopback does not support userptr.<br></div><div>I find his anser very helpful and consider my next steps.<br><br><br></div><div>several questions:<br></div><div><br></div><div>1. can i count that gstreamer works with user ptr ?<br><p> the link below suggests it sohuld work, correct ?<br> <a href="https://developer.ridgerun.com/wiki/index.php/GStreamer1.0_and_V4L2_UserPtr" rel="nofollow noreferrer noopener" target="_blank">https://developer.ridgerun.com/wiki/index.php/GStreamer1.0_and_V4L2_UserPt<br><br></a></p></div><div><p>2. </p><p> clearly, i am looking for simple stable solution.<br></p><p> as much as I love code, clearly it is preferable to use existing tools<br></p><p> to get fast and stable simulator.<br></p><p> if you could please advise ,which of the following options would you recommend ?<br></p><p> option1: use gstreamer\v4l2sink without v4l2loopback<br></p><p> my question here: which tool can i use instead v4l2loopback ?</p></div></div></blockquote><div><br></div><div>For testing purpose, you can build vivid virtual driver, it sumulates a camera, and implements USRPTR.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div><p> which tool did v4l2sink develpers used to check the usertpr mode ? </p></div></div></blockquote><div>Its has been added over 15 years ago, so I cannot say for sure. These days we prefer DMABuf importation instead, though its not yet automatically using it. Validation is difficult and mistakes will lead to error and garbled images.</div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div><p><br></p><p> option2:any other gstreamer alternative for v4l2sink\v4l2loopback ?<br></p></div></div></blockquote><div>I'm not aware of equivalent of v4l2sink.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div> option3: changing v4l2loopback to support userptr <br> i am not video expert, in fact, quite new.<br> I wonder whyv4l2loopback did not support userptr mode<br></div><div> dou you think this is a hude task ?<br></div><div> can you see Any specific challenge ? I<br></div><div><br></div><div> PS: my userptr works with shared memeory<br></div><div> it should be accessible in user and kernel mode <br></div><div> (as the code worked with physical camera)</div></div></blockquote><div><br></div><div>v4l2loopback is an out of tree driver that does not use the videobuf2 helpers, so adding something like userptr is for sure a bit of work and you have to understand how strides and plane offset calculation works.</div><div><br></div><blockquote type="cite" style="margin:0 0 0 .8ex; border-left:2px #729fcf solid;padding-left:1ex"><div dir="ltr"><div><br> option4: writing a tool that replace v4l2loopback and gstramer </div><div> My single goal is to mimic A camera driver<br> that reads images from disk and writes it to v4l2 using userptr.</div><div>
<p dir="auto"> so maybe I should just write an app,<br> that declares the device and writes to v4l2 directly , just like driver do ?<br> </p></div></div></blockquote><div><br></div><div>Also seems like quite some coding, but if you go that way, have a look at libv4l2, you could make an LD_PRELOAD library that simulate a camera. Note that vivid have a "loop" control, which just like v4l2loopback allow passing data over. The only tricky bit is that the v4l2src needs to be configured to match the v4l2sink resolution and format, otherwise it will give you a test pattern.</div><div><br></div><div>Nicolas</div><div><span></span></div></body></html>