SDV Media enables the use of video cameras through the Linux V4L2 API. It is possible to use the V4L2 APIs directly, but application developers are encouraged to use userspace helper libraries. For example:
libv4l-rscrate for Rust (recommended),libv4l2for C++. This library is not provided by default in SDV Media.
Supported buffer modes
USERPTR buffer mode is considered deprecated by upstream V4L2 maintainers and is therefore not supported by SDV Media. Use MMAP or DMABUF mode instead.
Use cameras
Each video device (cameras, encoders, and decoders) exposed by the hypervisor
will appear as a separate device named /dev/videoN (with a numeric value of
N).
Applications can use VIDIOC_QUERYCAP ioctl to query capabilities of the
video devices. Camera devices report support for V4L2_CAP_VIDEO_CAPTURE
or V4L2_CAP_VIDEO_CAPTURE_MPLANE.
For details of the video capture flow, see Video for Linux API: Input/Output.
Consider these code samples:
- Rust:
libv4l-rsstream_capture_mmapexample, - C/C++: AAOS
VideoCaptureclass or Linux kernel Video Capture example.
Configure video loopback devices
For testing, SDV Media provides a v4l2loopback kernel module, which can be
used to emulate video cameras entirely within the guest VM. By default, it
initializes a single virtual camera device. To add more, pass the configuration
parameters to the module through the kernel command line. For example, to
initialize 4 devices add:
v4l2loopback.devices=4
To see a full list of available module options, see the v4l2loopback README or the module sources in the Android kernel repository.