diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-11 13:42:25 -0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-07-11 13:42:25 -0300 |
commit | 754f080bdf7412769906262dfad451a6f90f2077 (patch) | |
tree | 87e18e95a553b04c8836df604bf99edb5eaaa274 | |
parent | b884d16928248c316903c9b1f1483a3586228f65 (diff) | |
download | mediapointer-dvb-s2-754f080bdf7412769906262dfad451a6f90f2077.tar.gz mediapointer-dvb-s2-754f080bdf7412769906262dfad451a6f90f2077.tar.bz2 |
Adds the possibility of writing captured stream into a file
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
-rw-r--r-- | v4l2-apps/test/capture_example.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/v4l2-apps/test/capture_example.c b/v4l2-apps/test/capture_example.c index fda252b61..bbb0c4e57 100644 --- a/v4l2-apps/test/capture_example.c +++ b/v4l2-apps/test/capture_example.c @@ -45,6 +45,7 @@ static io_method io = IO_METHOD_MMAP; static int fd = -1; struct buffer * buffers = NULL; static unsigned int n_buffers = 0; +static int out_buf = 0; static void errno_exit (const char * s) @@ -69,9 +70,14 @@ xioctl (int fd, } static void -process_image (const void * p) +process_image (const void * p, + int size) { - fputc ('.', stdout); + if (!out_buf) + fputc ('.', stdout); + else + fwrite (p, size, 1, stdout); + fflush (stdout); } @@ -98,7 +104,7 @@ read_frame (void) } } - process_image (buffers[0].start); + process_image (buffers[0].start, buffers[0].length); break; @@ -125,7 +131,7 @@ read_frame (void) assert (buf.index < n_buffers); - process_image (buffers[buf.index].start); + process_image (buffers[buf.index].start, buffers[buf.index].length); if (-1 == xioctl (fd, VIDIOC_QBUF, &buf)) errno_exit ("VIDIOC_QBUF"); @@ -160,7 +166,7 @@ read_frame (void) assert (i < n_buffers); - process_image ((void *) buf.m.userptr); + process_image ((void *) buf.m.userptr, buf.length); if (-1 == xioctl (fd, VIDIOC_QBUF, &buf)) errno_exit ("VIDIOC_QBUF"); @@ -176,7 +182,7 @@ mainloop (void) { unsigned int count; - count = 100; + count = 1000; while (count-- > 0) { for (;;) { @@ -589,11 +595,12 @@ usage (FILE * fp, "-m | --mmap Use memory mapped buffers\n" "-r | --read Use read() calls\n" "-u | --userp Use application allocated buffers\n" + "-o | --output Outputs stream to stdout\n" "", argv[0]); } -static const char short_options [] = "d:hmru"; +static const char short_options [] = "d:hmruo"; static const struct option long_options [] = { @@ -602,6 +609,7 @@ long_options [] = { { "mmap", no_argument, NULL, 'm' }, { "read", no_argument, NULL, 'r' }, { "userp", no_argument, NULL, 'u' }, + { "output", no_argument, NULL, 'o' }, { 0, 0, 0, 0 } }; @@ -646,6 +654,10 @@ main (int argc, io = IO_METHOD_USERPTR; break; + case 'o': + out_buf++; + break; + default: usage (stderr, argc, argv); exit (EXIT_FAILURE); |