video4linux user space library
Author: Hans de Goede
The Linux kernel offers an API to access a wide variety of video (input mostly) devices through the video4linux API, for example webcams, analog and digital tv -tuners. By offering a single API for all video input devices v4l makes it possible for applications to easily support a wide variety of devices.
Currently the v4l API is strictly a userspace kernelspace API, so there are no further support libraries for applications to access v4l devices. This means that applications need to support reading the frame data from the video device in a variety of video formats and then converting it to a video format suitable for their own use.
The out of kernel gspca usb webcam driver framework solved the video format problem by doing conversion from hardware specific compression formats (usb 1.1 bandwidth is too low to carry raw frames at a decent framerate) to generic formats as supported by most applications in the kernel. With the merging of the gspca driver into the mainline kernel, this conversion has been removed from gspca as video format conversion clearly does not belong in the kernel.
This made the video format problem much larger as gspca adds 8 different non standard videoformats, of which 3 feature complex compression algorithms. Implementing support for all these formats into all v4l applications is clearly not the way forward as this leads to much code duplication and maintainance issues. Hence libv4l2 a utility library for v4l2 applications doing format conversion was born.
The choice has been made with libv4l to 100% copy the application kernel interface for direct /dev/video access, except that now additional video formats can be requested (and will be granted), during video format negotiation and that (to the application transparent) conversion will happen from the raw video format given by the device to what the application wants. This choice was made to allow very easy porting of the numerous existing v4l2 applications to libv4l2, all that needs to be done is replace the open on /dev/video with v4l2_open and additional calls on the resulting fd like ioctl with v4l2_ioctl, etc.
As there are still quite a few applications out there which use the (obsolete) v4l1 API, and since the kernel v4l1 emulation is incomplete in many drivers (uvc and gspca for example), a v4l1 emulation library which does (transparent) format conversion and v4l1 emulation on top of v4l2 devices has been written, this lib is called libv4l1 and mimick the /dev/video v4l1 interface in the same way as libv4l2 mimicks the /dev/video v4l2 interface.
A joined effort between Fedora, Suse and Debian is underway to port all v4l2 applications in these distro's to libv4l, see: http://linuxtv.org/v4lwiki/index.php/Libv4l_Progress
Contents of the talk:
1) Short introduction of video4linux
2.1) The problem
2.2) Solution: a userspace format conversion library
2.3) Choices made
2.4) Results so far
3) Discussions surrounding the future of libv4l
3.1) Software autofocus ?
3.2) Pre processing (auto whitebalance, ...) ?
3.3) Scaling ?
3.4) Evaluate the choice to keep the API the same as the raw /dev/video API
3.5) Free discussion