This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/v4l-utils.git tree:
Subject: v4l2-ctl: add streaming options. Author: Hans Verkuil <[email protected]> Date: Thu Jul 26 15:16:56 2012 +0200 Currently the only available options query the buffers. But this will be extended over time. Signed-off-by: Hans Verkuil <[email protected]> (cherry picked from commit d40d15f698613811f5b047c2dab81603c13c66e6) Signed-off-by: Gregor Jasny <[email protected]> utils/v4l2-ctl/Makefile | 2 +- utils/v4l2-ctl/v4l2-ctl-streaming.cpp | 177 +++++++++++++++++++++++++++++++++ utils/v4l2-ctl/v4l2-ctl.cpp | 13 +++- utils/v4l2-ctl/v4l2-ctl.h | 15 +++ 4 files changed, 205 insertions(+), 2 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=b83d02cf08d2ca28c0f5997871ab59ab00f9190f diff --git a/utils/v4l2-ctl/Makefile b/utils/v4l2-ctl/Makefile index 150688d..ce3cd90 100644 --- a/utils/v4l2-ctl/Makefile +++ b/utils/v4l2-ctl/Makefile @@ -12,7 +12,7 @@ cx18-ctl: cx18-ctl.o ivtv-ctl: ivtv-ctl.o $(CC) $(LDFLAGS) -o $@ $^ -lm -v4l2-ctl: v4l2-ctl.o v4l2-ctl-common.o v4l2-ctl-tuner.o v4l2-ctl-io.o v4l2-ctl-stds.o v4l2-ctl-vidcap.o v4l2-ctl-vidout.o v4l2-ctl-overlay.o v4l2-ctl-vbi.o v4l2-ctl-selection.o v4l2-ctl-misc.o +v4l2-ctl: v4l2-ctl.o v4l2-ctl-common.o v4l2-ctl-tuner.o v4l2-ctl-io.o v4l2-ctl-stds.o v4l2-ctl-vidcap.o v4l2-ctl-vidout.o v4l2-ctl-overlay.o v4l2-ctl-vbi.o v4l2-ctl-selection.o v4l2-ctl-misc.o v4l2-ctl-streaming.o $(CXX) $(LDFLAGS) -o $@ $^ -lv4l2 -lv4lconvert -lrt install: $(TARGETS) diff --git a/utils/v4l2-ctl/v4l2-ctl-streaming.cpp b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp new file mode 100644 index 0000000..a0ecf3d --- /dev/null +++ b/utils/v4l2-ctl/v4l2-ctl-streaming.cpp @@ -0,0 +1,177 @@ +#include <unistd.h> +#include <stdlib.h> +#include <stdio.h> +#include <string.h> +#include <inttypes.h> +#include <getopt.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <ctype.h> +#include <errno.h> +#include <sys/ioctl.h> +#include <sys/time.h> +#include <dirent.h> +#include <math.h> + +#include <linux/videodev2.h> +#include <libv4l2.h> +#include <string> + +#include "v4l2-ctl.h" + +void streaming_usage(void) +{ + printf("\nVideo Streaming options:\n" + " --list-buffers list all video buffers [VIDIOC_QUERYBUF]\n" + " --list-buffers-mplane\n" + " list all multi-planar video buffers [VIDIOC_QUERYBUF]\n" + " --list-buffers-out list all video output buffers [VIDIOC_QUERYBUF]\n" + " --list-buffers-out-mplane\n" + " list all multi-planar video output buffers [VIDIOC_QUERYBUF]\n" + " --list-buffers-vbi list all VBI buffers [VIDIOC_QUERYBUF]\n" + " --list-buffers-vbi-out\n" + " list all VBI output buffers [VIDIOC_QUERYBUF]\n" + " --list-buffers-sliced-vbi\n" + " list all sliced VBI buffers [VIDIOC_QUERYBUF]\n" + " --list-buffers-sliced-vbi-out\n" + " list all sliced VBI output buffers [VIDIOC_QUERYBUF]\n" + ); +} + +static const flag_def flags_def[] = { + { V4L2_BUF_FLAG_MAPPED, "mapped" }, + { V4L2_BUF_FLAG_QUEUED, "queued" }, + { V4L2_BUF_FLAG_DONE, "done" }, + { V4L2_BUF_FLAG_KEYFRAME, "keyframe" }, + { V4L2_BUF_FLAG_PFRAME, "P-frame" }, + { V4L2_BUF_FLAG_BFRAME, "B-frame" }, + { V4L2_BUF_FLAG_ERROR, "error" }, + { V4L2_BUF_FLAG_TIMECODE, "timecode" }, + { V4L2_BUF_FLAG_INPUT, "input" }, + { V4L2_BUF_FLAG_PREPARED, "prepared" }, + { V4L2_BUF_FLAG_NO_CACHE_INVALIDATE, "no-cache-invalidate" }, + { V4L2_BUF_FLAG_NO_CACHE_CLEAN, "no-cache-clean" }, + { 0, NULL } +}; + +static const flag_def tc_flags_def[] = { + { V4L2_TC_FLAG_DROPFRAME, "dropframe" }, + { V4L2_TC_FLAG_COLORFRAME, "colorframe" }, + { V4L2_TC_USERBITS_field, "userbits-field" }, + { V4L2_TC_USERBITS_USERDEFINED, "userbits-userdefined" }, + { V4L2_TC_USERBITS_8BITCHARS, "userbits-8bitchars" }, + { 0, NULL } +}; + +static void print_buffer(struct v4l2_buffer &buf) +{ + printf("\tIndex : %d\n", buf.index); + printf("\tType : %s\n", buftype2s(buf.type).c_str()); + printf("\tFlags : %s\n", flags2s(buf.flags, flags_def).c_str()); + printf("\tField : %s\n", field2s(buf.field).c_str()); + printf("\tSequence : %u\n", buf.sequence); + printf("\tLength : %u\n", buf.length); + printf("\tBytesused: %u\n", buf.bytesused); + printf("\tTimestamp: %lu.%06lus\n", buf.timestamp.tv_sec, buf.timestamp.tv_usec); + if (buf.flags & V4L2_BUF_FLAG_TIMECODE) { + static const int fps_types[] = { 0, 24, 25, 30, 50, 60 }; + int fps = buf.timecode.type; + + if (fps > 5) + fps = 0; + printf("\tTimecode : %dfps %s %dh %dm %ds %df (0x%02x 0x%02x 0x%02x 0x%02x)\n", + fps_types[fps], + flags2s(buf.timecode.flags, tc_flags_def).c_str(), + buf.timecode.hours, buf.timecode.minutes, + buf.timecode.seconds, buf.timecode.frames, + buf.timecode.userbits[0], buf.timecode.userbits[1], + buf.timecode.userbits[2], buf.timecode.userbits[3]); + } + if (buf.type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE || + buf.type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + for (unsigned i = 0; i < buf.length; i++) { + struct v4l2_plane *p = buf.m.planes + i; + + printf("\tPlane : %d\n", i); + printf("\t\tLength : %u\n", p->length); + printf("\t\tBytesused : %u\n", p->bytesused); + printf("\t\tData Offset: %u\n", p->data_offset); + } + } + + printf("\n"); +} + +static void list_buffers(int fd, unsigned buftype) +{ + int i; + + for (i = 0; i < VIDEO_MAX_FRAME; i++) { + struct v4l2_plane planes[VIDEO_MAX_PLANES]; + struct v4l2_buffer buf; + + buf.type = buftype; + buf.index = i; + buf.reserved = 0; + if (buftype == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE || + buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { + buf.m.planes = planes; + memset(planes, 0, sizeof(planes)); + } + if (ioctl(fd, VIDIOC_QUERYBUF, &buf)) + break; + if (i == 0) + printf("VIDIOC_QUERYBUF:\n"); + print_buffer(buf); + } +} + +void streaming_cmd(int ch, char *optarg) +{ + switch (ch) { + } +} + +void streaming_set(int fd) +{ +} + +void streaming_get(int fd) +{ +} + +void streaming_list(int fd) +{ + if (options[OptListBuffers]) { + list_buffers(fd, V4L2_BUF_TYPE_VIDEO_CAPTURE); + } + + if (options[OptListBuffersMplane]) { + list_buffers(fd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); + } + + if (options[OptListBuffersOut]) { + list_buffers(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT); + } + + if (options[OptListBuffersMplaneOut]) { + list_buffers(fd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); + } + + if (options[OptListBuffersVbi]) { + list_buffers(fd, V4L2_BUF_TYPE_VBI_CAPTURE); + } + + if (options[OptListBuffersSlicedVbi]) { + list_buffers(fd, V4L2_BUF_TYPE_SLICED_VBI_CAPTURE); + } + + if (options[OptListBuffersVbiOut]) { + list_buffers(fd, V4L2_BUF_TYPE_VBI_OUTPUT); + } + + if (options[OptListBuffersSlicedVbiOut]) { + list_buffers(fd, V4L2_BUF_TYPE_SLICED_VBI_OUTPUT); + } +} diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index 696c282..507eefc 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -184,6 +184,14 @@ static struct option long_options[] = { {"decoder-cmd", required_argument, 0, OptDecoderCmd}, {"try-decoder-cmd", required_argument, 0, OptTryDecoderCmd}, {"tuner-index", required_argument, 0, OptTunerIndex}, + {"list-buffers", no_argument, 0, OptListBuffers}, + {"list-buffers-mplane", no_argument, 0, OptListBuffersMplane}, + {"list-buffers-out", no_argument, 0, OptListBuffersOut}, + {"list-buffers-mplane-out", no_argument, 0, OptListBuffersMplaneOut}, + {"list-buffers-vbi", no_argument, 0, OptListBuffersVbi}, + {"list-buffers-sliced-vbi", no_argument, 0, OptListBuffersSlicedVbi}, + {"list-buffers-vbi-out", no_argument, 0, OptListBuffersVbiOut}, + {"list-buffers-sliced-vbi-out", no_argument, 0, OptListBuffersSlicedVbiOut}, {0, 0, 0, 0} }; @@ -199,6 +207,7 @@ static void usage_all(void) vbi_usage(); selection_usage(); misc_usage(); + streaming_usage(); } static int test_open(const char *file, int oflag) @@ -283,7 +292,7 @@ std::string fcc2s(unsigned int val) return s; } -static std::string field2s(int val) +std::string field2s(int val) { switch (val) { case V4L2_FIELD_ANY: @@ -838,6 +847,7 @@ int main(int argc, char **argv) vbi_cmd(ch, optarg); selection_cmd(ch, optarg); misc_cmd(ch, optarg); + streaming_cmd(ch, optarg); break; } } @@ -963,6 +973,7 @@ int main(int argc, char **argv) vidout_list(fd); overlay_list(fd); vbi_list(fd); + streaming_list(fd); if (options[OptWaitForEvent]) { struct v4l2_event_subscription sub; diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index 6928b76..4d0fc4f 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -131,6 +131,14 @@ enum Option { OptDecoderCmd, OptTryDecoderCmd, OptTunerIndex, + OptListBuffers, + OptListBuffersMplane, + OptListBuffersOut, + OptListBuffersMplaneOut, + OptListBuffersVbi, + OptListBuffersSlicedVbi, + OptListBuffersVbiOut, + OptListBuffersSlicedVbiOut, OptHelpTuner, OptHelpIO, OptHelpStds, @@ -174,6 +182,7 @@ std::string fcc2s(unsigned int val); std::string fmtdesc2s(unsigned flags); std::string colorspace2s(int val); std::string service2s(unsigned service); +std::string field2s(int val); void print_v4lstd(v4l2_std_id std); int parse_fmt(char *optarg, __u32 &width, __u32 &height, __u32 &pixelformat); __u32 find_pixel_format(int fd, unsigned index, bool mplane); @@ -252,5 +261,11 @@ void misc_cmd(int ch, char *optarg); void misc_set(int fd); void misc_get(int fd); +// v4l2-ctl-streaming.cpp +void streaming_usage(void); +void streaming_cmd(int ch, char *optarg); +void streaming_set(int fd); +void streaming_get(int fd); +void streaming_list(int fd); #endif _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
