diff options
author | Marton Balint <cus@passwd.hu> | 2017-12-29 23:29:52 +0100 |
---|---|---|
committer | Marton Balint <cus@passwd.hu> | 2018-01-28 23:06:43 +0100 |
commit | 4bb04098204afadc8604af0113294f8ecc63a2de (patch) | |
tree | d2dc31c31b76f9e61f503e465f4ab7bde9169f16 /libavdevice/v4l2.c | |
parent | 25a2d269bdd919e633e202b67927c3c72f9f0dd5 (diff) | |
download | ffmpeg-4bb04098204afadc8604af0113294f8ecc63a2de.tar.gz |
avdevice: migrate to AVFormatContext->url
Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavdevice/v4l2.c')
-rw-r--r-- | libavdevice/v4l2.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index f087badf5c..10a0ff0dd6 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -106,7 +106,7 @@ struct buff_data { int index; }; -static int device_open(AVFormatContext *ctx) +static int device_open(AVFormatContext *ctx, const char* device_path) { struct video_data *s = ctx->priv_data; struct v4l2_capability cap; @@ -147,11 +147,11 @@ static int device_open(AVFormatContext *ctx) flags |= O_NONBLOCK; } - fd = v4l2_open(ctx->filename, flags, 0); + fd = v4l2_open(device_path, flags, 0); if (fd < 0) { err = AVERROR(errno); av_log(ctx, AV_LOG_ERROR, "Cannot open video device %s: %s\n", - ctx->filename, av_err2str(err)); + device_path, av_err2str(err)); return err; } @@ -840,7 +840,7 @@ static int v4l2_read_header(AVFormatContext *ctx) v4l2_log_file = fopen("/dev/null", "w"); #endif - s->fd = device_open(ctx); + s->fd = device_open(ctx, ctx->url); if (s->fd < 0) return s->fd; @@ -1042,11 +1042,13 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l return ret; } while ((entry = readdir(dir))) { + char device_name[256]; + if (!v4l2_is_v4l_dev(entry->d_name)) continue; - snprintf(ctx->filename, sizeof(ctx->filename), "/dev/%s", entry->d_name); - if ((s->fd = device_open(ctx)) < 0) + snprintf(device_name, sizeof(device_name), "/dev/%s", entry->d_name); + if ((s->fd = device_open(ctx, device_name)) < 0) continue; if (v4l2_ioctl(s->fd, VIDIOC_QUERYCAP, &cap) < 0) { @@ -1060,7 +1062,7 @@ static int v4l2_get_device_list(AVFormatContext *ctx, AVDeviceInfoList *device_l ret = AVERROR(ENOMEM); goto fail; } - device->device_name = av_strdup(ctx->filename); + device->device_name = av_strdup(device_name); device->device_description = av_strdup(cap.card); if (!device->device_name || !device->device_description) { ret = AVERROR(ENOMEM); |