v4l2-compliance: reworked the (c)v4l-helpers.h headers
These headers were designed to easy coding for the V4L2 API, in particular
hiding the complexity relating to single and multiplanar formats.
These reworked headers resolve a number of design issues and they are now ready
to be used elsewhere.
As an example, the C++ code below works for single and multiplanar video capture and
output, vbi capture and output and sdr capture. By replacing V4L2_MEMORY_MMAP with
_USERPTR it will work with userptr streaming as well. But note that the code is
missing error handling, so a real application will need to do a bit more.
int main(int argc, char **argv)
{
cv4l_fd fd;
unsigned cnt = 0;
fd.open(argc >= 2 ? argv[1] : "/dev/video0");
cv4l_queue q(fd.g_type(), V4L2_MEMORY_MMAP);
q.reqbufs(&fd, 4);
q.obtain_bufs(&fd);
q.queue_all(&fd);
fd.streamon();
cv4l_buffer buf(q);
while (fd.dqbuf(buf) == 0) {
printf("seqnr: %u bytesused[0]: %u bytesused[1]: %u\n", buf.g_sequence(),
buf.g_bytesused(0), buf.g_bytesused(1));
fd.qbuf(buf);
if (cnt++ >= 60)
break;
}
q.free(&fd);
fd.close();
}
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>