24#include <linux/videodev2.h>
42 if (cap->capabilities & (V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VIDEO_OUTPUT) &&
43 cap->capabilities & V4L2_CAP_STREAMING)
46 if (cap->capabilities & V4L2_CAP_VIDEO_M2M)
54 if (cap->capabilities & (V4L2_CAP_VIDEO_CAPTURE_MPLANE | V4L2_CAP_VIDEO_OUTPUT_MPLANE) &&
55 cap->capabilities & V4L2_CAP_STREAMING)
58 if (cap->capabilities & V4L2_CAP_VIDEO_M2M_MPLANE)
66 struct v4l2_capability cap;
67 void *log_ctx =
s->avctx;
70 s->capture.done =
s->output.done = 0;
71 s->capture.name =
"capture";
72 s->output.name =
"output";
76 memset(&cap, 0,
sizeof(cap));
77 ret = ioctl(
s->fd, VIDIOC_QUERYCAP, &cap);
82 "driver '%s' on card '%s' in %s mode\n", cap.driver, cap.card,
87 s->capture.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE;
88 s->output.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE;
93 s->capture.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
94 s->output.type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
103 void *log_ctx =
s->avctx;
106 s->fd = open(
s->devname, O_RDWR | O_NONBLOCK, 0);
139 void *log_ctx =
s->avctx;
141 struct v4l2_format ofmt, cfmt;
143 s->fd = open(
s->devname, O_RDWR | O_NONBLOCK, 0);
151 ofmt =
s->output.format;
152 cfmt =
s->capture.format;
155 ofmt.fmt.pix_mp.pixelformat :
156 ofmt.fmt.pix.pixelformat),
159 cfmt.fmt.pix_mp.pixelformat :
160 cfmt.fmt.pix.pixelformat),
210 void *log_ctx =
s->avctx;
226 while(
sem_wait(&
s->refsync) == -1 && errno == EINTR);
293 struct dirent *
entry;
298 dirp = opendir(
"/dev");
304 if (strncmp(
entry->d_name,
"video", 5))
318 memset(
s->devname, 0,
sizeof(
s->devname));
static int probe(const AVProbeData *p)
static av_cold void close(AVCodecParserContext *s)
Libavcodec external API header.
#define atomic_load(object)
#define atomic_init(obj, value)
int av_codec_is_decoder(const AVCodec *codec)
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
#define AV_LOG_INFO
Standard information.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define av_fourcc2str(fourcc)
Memory handling functions.
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
void av_refstruct_unref(void *objp)
Decrement the reference count of the underlying object and automatically free the object if there are...
static void * av_refstruct_alloc_ext(size_t size, unsigned flags, void *opaque, void(*free_cb)(AVRefStructOpaque opaque, void *obj))
A wrapper around av_refstruct_alloc_ext_c() for the common case of a non-const qualified opaque.
#define sem_destroy(psem)
int num_buffers
Readonly after init.
struct V4L2m2mContext * self_ref
V4L2m2mContext * context
RefStruct reference.
static void error(const char *err)
RefStruct is an API for creating reference-counted objects with minimal overhead.
void ff_v4l2_context_release(V4L2Context *ctx)
Releases a V4L2Context.
int ff_v4l2_context_get_format(V4L2Context *ctx, int probe)
Queries the driver for a valid v4l2 format and copies it to the context.
int ff_v4l2_context_set_status(V4L2Context *ctx, uint32_t cmd)
Sets the status of a V4L2Context.
int ff_v4l2_context_set_format(V4L2Context *ctx)
Sets the V4L2Context format in the v4l2 driver.
int ff_v4l2_context_init(V4L2Context *ctx)
Initializes a V4L2Context.
static av_cold int v4l2_configure_contexts(V4L2m2mContext *s)
av_cold int ff_v4l2_m2m_codec_init(V4L2m2mPriv *priv)
Probes the video nodes looking for the required codec capabilities.
static void v4l2_m2m_destroy_context(AVRefStructOpaque unused, void *context)
int ff_v4l2_m2m_create_context(V4L2m2mPriv *priv, V4L2m2mContext **s)
Allocate a new context and references for a V4L2 M2M instance.
static int v4l2_prepare_contexts(V4L2m2mContext *s, int probe)
av_cold int ff_v4l2_m2m_codec_end(V4L2m2mPriv *priv)
Releases all the codec resources if all AVBufferRefs have been returned to the ctx.
static int v4l2_splane_video(struct v4l2_capability *cap)
static int v4l2_mplane_video(struct v4l2_capability *cap)
int ff_v4l2_m2m_codec_reinit(V4L2m2mContext *s)
Reinitializes the V4L2m2mContext when the driver cannot continue processing with the capture paramete...
static int v4l2_probe_driver(V4L2m2mContext *s)