首先是
//四字符代码,为了标示视频数据流格式
//在次文件的下,比如大家熟悉的mjpeg
//#define V4L2_PIX_FMT_MJPEG v4l2_fourcc('M', 'J', 'P', 'G') /* Motion-JPEG */
/* Four-character-code (FOURCC) */
#define v4l2_fourcc(a, b, c, d)\
((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | ((__u32)(d) << 24))
/*
* F O R M A T E N U M E R A T I O N
*/
struct v4l2_fmtdesc {
__u32 index; /* Format number */ //格式索引
enum v4l2_buf_type type; /* buffer type */ //缓冲类型
/*
ioctl会根据这个type选择对应的函数,例如VIDIOC_ENUM_FMT时type为V4L2_BUF_TYPE_VIDEO_CAPTURE,
那么就会调用 int (*vidioc_enum_fmt_vid_cap)(struct file *file, void *fh, struct v4l2_fmtdesc *f);
enum v4l2_buf_type {
V4L2_BUF_TYPE_VIDEO_CAPTURE = 1,
V4L2_BUF_TYPE_VIDEO_OUTPUT = 2,
V4L2_BUF_TYPE_VIDEO_OVERLAY = 3,
V4L2_BUF_TYPE_VBI_CAPTURE = 4,
V4L2_BUF_TYPE_VBI_OUTPUT = 5,
V4L2_BUF_TYPE_SLICED_VBI_CAPTURE = 6,
V4L2_BUF_TYPE_SLICED_VBI_OUTPUT = 7,
V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY = 8,
V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE = 9,
V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE = 10,
V4L2_BUF_TYPE_PRIVATE = 0x80,
};
*/
__u32 flags;//标志
__u8 description[32]; /* Description string */ //描述
__u32 pixelformat; /* Format fourcc */ //用定义好的的宏v4l2_fourcc
__u32 reserved[4];
};
//经常在应用层使用VIDIOC_ENUM_FMT去获取支持的格式,主要就是获取这个结构体。有的