<div><div dir="auto">Hello Nicolas !</div><div dir="auto">Thank you ,again , for your kind replay.</div><div dir="auto"><br></div><div dir="auto">Would you be so kind to see my comments/questions below (with “=>comment2 “ prefix)</div><div><br><div class="gmail_quote"></div></div></div><div><div><div><div><div dir="ltr" class="gmail_attr">On Tue, Aug 22, 2023 at 21:03 Nicolas Dufresne <<a href="mailto:nicolas@ndufresne.ca" target="_blank">nicolas@ndufresne.ca</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><div>Le mardi 22 août 2023 à 12:14 +0300, Regine Issan via gstreamer-devel a écrit :</div><blockquote type="cite" style="margin:0px 0px 0px 0.8ex;border-left-width:2px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(114,159,207)"><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" target="_blank">https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/1028</a><br> <a href="https://gitlab.freedesktop.org/ndufresne" target="_blank"><span>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></div></div></blockquote></div></div></div></div><div><div dir="auto"><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><br></span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)">=>comment2:begin<br> Thanks, that seems the simplest solution.</span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> I will have a look at vivid. </span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none">=>comment2:end</span></div> </span></div><br></div></div><div><div><div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><div><br></div><blockquote type="cite" style="margin:0px 0px 0px 0.8ex;border-left-width:2px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(114,159,207)"><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></div></blockquote><div dir="auto"><br></div></div></div></div></div><div><div dir="auto"><div dir="auto"><div><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"></span><div><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none">=>comment2:begin</span></div></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;color:rgb(0,0,0);display:inline!important"> I read about </span>DMABuf here</div><div dir="auto"><span style="font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;color:rgb(0,0,0);display:inline!important"> <span> </span><a href="https://stackoverflow.com/questions/66962795/what-is-the-use-of-mmap-userptr-and-dmabuf-in-video-streaming-using-v4l2-drive" style="color:rgb(66,133,244)" target="_blank">https://stackoverflow.com/questions/66962795/what-is-the-use-of-mmap-userptr-and-dmabuf-in-video-streaming-using-v4l2-drive</a></span></div></div><div dir="auto"><br></div><div dir="auto"> The consumer reading dmabufs must run</div><div dir="auto"> In kernel mode . Correct ?</div><div dir="auto"> </div><div dir="auto"> Vslidation using userptr and dmabufs</div><div dir="auto"> Are equally complicated ? </div></span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> </span></div><div dir="auto"> </div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none">=>comment2:end</span></div> </span></div><div dir="auto"><span style="font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important;color:rgb(0,0,0)"> </span></div></div></div><div dir="auto"><div><div><div class="gmail_quote"></div></div></div></div></div><div><div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><div dir="auto"></div><blockquote type="cite" style="margin:0px 0px 0px 0.8ex;border-left-width:2px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(114,159,207)"><div dir="ltr"><div><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:0px 0px 0px 0.8ex;border-left-width:2px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(114,159,207)"><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></div></div></blockquote></div></div><div><div dir="auto"><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none"><br></span></div><div><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none">=>comment2:begin</span></div><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none"> </span></div><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none"> I though the only difference </span></div><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none"> Between mmap and userptr </span></div><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none"> should only be </span></div><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none"> on requestbufs and cleanup .</span></div><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none"><div><meta charset="UTF-8"><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important">Mmmm…am I missing anything ?</span></div><div dir="auto" style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;float:none;display:inline!important"> </span> strides and plane offset ? </div></div><br></span></div></div><div dir="auto"><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none">=>comment2:end</span></div></div></div><div><div><div><div><div><div class="gmail_quote"><div dir="auto"><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><blockquote type="cite" style="margin:0px 0px 0px 0.8ex;border-left-width:2px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(114,159,207)"><div dir="ltr"><div><div><div dir="auto"> option4: writing a tool that replace v4l2loopback and gstramer <br></div></div></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></blockquote><div dir="auto"><div><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none">=>comment2:begin</span></div><div dir="auto">Thanks ! </div><div dir="auto">Perhaps I should dig into it if vivid won’t work.</div><div dir="auto"><span style="color:rgb(0,0,0);font-family:-apple-system,HelveticaNeue;font-size:16px;font-style:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;text-decoration:none;display:inline!important;float:none">=>comment2:end</span></div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div><div dir="auto"></div></div><div><div><br></div><div>Nicolas</div><div><span></span></div></div>
</blockquote></div></div>
</div>
</div>
</div>
</div>