diff options
author | Giorgio Vazzana <mywing81@gmail.com> | 2013-01-30 13:17:02 +0100 |
---|---|---|
committer | Stefano Sabatini <stefasab@gmail.com> | 2013-01-31 12:38:03 +0100 |
commit | ff23b76899b289855bb5a7e074673f3e07e5a7cf (patch) | |
tree | b7f5318cbc59788a4348b88b0acf127e7444f299 /libavdevice/v4l2.c | |
parent | dcfbe1e0b67bfdaf0827a0c54f3c736cdb7c9c1c (diff) | |
download | ffmpeg-ff23b76899b289855bb5a7e074673f3e07e5a7cf.tar.gz |
lavd/v4l2: add list_standards option
Since the user is expected to choose the standard by name (with -standard
option), add the possibility to list all the supported standards.
Signed-off-by: Stefano Sabatini <stefasab@gmail.com>
Diffstat (limited to 'libavdevice/v4l2.c')
-rw-r--r-- | libavdevice/v4l2.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c index 5f0102746d..76b6d64717 100644 --- a/libavdevice/v4l2.c +++ b/libavdevice/v4l2.c @@ -116,6 +116,7 @@ struct video_data { int channel; char *pixel_format; /**< Set by a private option. */ int list_format; /**< Set by a private option. */ + int list_standard; /**< Set by a private option. */ char *framerate; /**< Set by a private option. */ }; @@ -381,6 +382,30 @@ static void list_formats(AVFormatContext *ctx, int fd, int type) } } +static void list_standards(AVFormatContext *ctx) +{ + int ret; + struct video_data *s = ctx->priv_data; + struct v4l2_standard standard; + + if (s->std_id == 0) + return; + + for (standard.index = 0; ; standard.index++) { + ret = v4l2_ioctl(s->fd, VIDIOC_ENUMSTD, &standard); + if (ret < 0) { + if (errno == EINVAL) + break; + else { + av_log(ctx, AV_LOG_ERROR, "ioctl(VIDIOC_ENUMSTD): %s\n", strerror(errno)); + return; + } + } + av_log(ctx, AV_LOG_INFO, "%2d, %16llx, %s\n", + standard.index, standard.id, standard.name); + } +} + static int mmap_init(AVFormatContext *ctx) { int i, res; @@ -824,6 +849,11 @@ static int v4l2_read_header(AVFormatContext *s1) return AVERROR_EXIT; } + if (s->list_standard) { + list_standards(s1); + return AVERROR_EXIT; + } + avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ if (s->pixel_format) { @@ -952,6 +982,9 @@ static const AVOption options[] = { { "raw", "show only non-compressed formats", OFFSET(list_format), AV_OPT_TYPE_CONST, {.i64 = V4L_RAWFORMATS }, 0, INT_MAX, DEC, "list_formats" }, { "compressed", "show only compressed formats", OFFSET(list_format), AV_OPT_TYPE_CONST, {.i64 = V4L_COMPFORMATS }, 0, INT_MAX, DEC, "list_formats" }, + { "list_standards", "list supported standards and exit", OFFSET(list_standard), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 1, DEC, "list_standards" }, + { "all", "show all supported standards", OFFSET(list_standard), AV_OPT_TYPE_CONST, {.i64 = 1 }, 0, 0, DEC, "list_standards" }, + { "timestamps", "set type of timestamps for grabbed frames", OFFSET(ts_mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, DEC, "timestamps" }, { "ts", "set type of timestamps for grabbed frames", OFFSET(ts_mode), AV_OPT_TYPE_INT, {.i64 = 0 }, 0, 2, DEC, "timestamps" }, { "default", "use timestamps from the kernel", OFFSET(ts_mode), AV_OPT_TYPE_CONST, {.i64 = V4L_TS_DEFAULT }, 0, 2, DEC, "timestamps" }, |