Introduction to V4L2 from user space
The main purpose of writing device drivers is to ease the control and usage of the underlying device by the application. There are two ways for user space to deal with V4L2 devices: either by using all-in-one utilities such as GStreamer
and its gst-*
tools or by writing a dedicated application using user space V4L2 APIs. In this chapter, we only deal with the code, thus we will cover how to write applications that use the V4L2 API.
The V4L2 user space API
The V4L2 user space API has a reduced number of functions and a lot of data structures, all defined in include/uapi/linux/videodev2.h
. In this section, we will try to describe the most important of them—or, better said, the most commonly used. Your code should include the following header:
#include <linux/videodev2.h>
This API relies on the following functions:
open()
: To open a video deviceclose()
: To close a video deviceioctl()
: To send ioctl commands...