24 #include <linux/videodev2.h>
25 #include <sys/ioctl.h>
41 if (cap->capabilities & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT) &&
42 cap->capabilities & V4L2_CAP_STREAMING)
45 if (cap->capabilities & V4L2_CAP_VIDEO_M2M)
53 if (cap->capabilities & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_OUTPUT_MPLANE) &&
54 cap->capabilities & V4L2_CAP_STREAMING)
57 if (cap->capabilities & V4L2_CAP_VIDEO_M2M_MPLANE)
65 struct v4l2_capability cap;
74 memset(&cap, 0,
sizeof(cap));
75 ret = ioctl(s->
fd, VIDIOC_QUERYCAP, &cap);
82 s->
capture.
type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
83 s->
output.
type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
100 s->
fd = open(s->
devname, O_RDWR | O_NONBLOCK, 0);
121 if (close(s->
fd) < 0) {
133 void *log_ctx = s->
avctx;
136 s->
fd = open(s->
devname, O_RDWR | O_NONBLOCK, 0);
174 if (close(s->
fd) < 0) {
235 void *log_ctx = s->
avctx;
251 s->
fd = open(s->
devname, O_RDWR | O_NONBLOCK, 0);
304 if (close(s->
fd) < 0) {
336 if (close(s->
fd) < 0 )
347 struct dirent *entry;
354 dirp = opendir(
"/dev");
358 for (entry = readdir(dirp); entry; entry = readdir(dirp)) {
360 if (strncmp(entry->d_name,
"video", 5))
363 snprintf(node,
sizeof(node),
"/dev/%s", entry->d_name);
365 strncpy(s->
devname, node, strlen(node) + 1);
const struct AVCodec * codec
const char * name
context name.
int ff_v4l2_context_init(V4L2Context *ctx)
Initializes a V4L2Context.
void ff_v4l2_context_release(V4L2Context *ctx)
Releases a V4L2Context.
int ff_v4l2_m2m_codec_init(AVCodecContext *avctx)
Probes the video nodes looking for the required codec capabilities.
int ff_v4l2_context_set_format(V4L2Context *ctx)
Sets the V4L2Context format in the v4l2 driver.
int av_codec_is_decoder(const AVCodec *codec)
int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *s)
Reinitializes the V4L2m2mContext when the driver cant continue processing with the capture parameters...
int done
Either no more buffers available or an unrecoverable error was notified by the V4L2 kernel driver: on...
static int v4l2_probe_driver(V4L2m2mContext *s)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define atomic_load(object)
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define sem_destroy(psem)
int ff_v4l2_context_set_status(V4L2Context *ctx, int cmd)
Sets the status of a V4L2Context.
int ff_v4l2_m2m_codec_end(AVCodecContext *avctx)
Releases all the codec resources if all AVBufferRefs have been returned to the ctx.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
static void error(const char *err)
#define AV_LOG_INFO
Standard information.
Libavcodec external API header.
main external API structure.
static int v4l2_prepare_contexts(V4L2m2mContext *s)
int ff_v4l2_m2m_codec_full_reinit(V4L2m2mContext *s)
Reinitializes the V4L2m2mContext when the driver cant continue processing with the any of the current...
static int v4l2_configure_contexts(V4L2m2mContext *s)
static int v4l2_splane_video(struct v4l2_capability *cap)
common internal api header.
int ff_v4l2_context_get_format(V4L2Context *ctx)
Queries the driver for a valid v4l2 format and copies it to the context.
#define atomic_init(obj, value)
enum v4l2_buf_type type
Type of this buffer context.
static int v4l2_mplane_video(struct v4l2_capability *cap)