diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-12-01 15:33:59 -0200 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-12-01 15:33:59 -0200 |
commit | 1de05f2d88e6e1fb2926caa368cf2544c65f86f0 (patch) | |
tree | 857cee9ed3ca2360735106c9443492a70cedadb7 /v4l2-apps/test | |
parent | 655f032b6b86ac96cefcefe344e181d83d197c87 (diff) | |
download | mediapointer-dvb-s2-1de05f2d88e6e1fb2926caa368cf2544c65f86f0.tar.gz mediapointer-dvb-s2-1de05f2d88e6e1fb2926caa368cf2544c65f86f0.tar.bz2 |
Implement mmapped streaming reception
From: Mauro Carvalho Chehab <mchehab@infradead.org>
Add capabilities to the library and to the driver to receive video streams.
Library will use a callback, called every time a new buffer is reported by
dqbuf.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'v4l2-apps/test')
-rw-r--r-- | v4l2-apps/test/driver-test.c | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/v4l2-apps/test/driver-test.c b/v4l2-apps/test/driver-test.c index 32b676836..61f6b812a 100644 --- a/v4l2-apps/test/driver-test.c +++ b/v4l2-apps/test/driver-test.c @@ -18,11 +18,19 @@ #include <stdio.h> #include <string.h> #include <unistd.h> +#include <errno.h> + +int recebe_buffer (struct v4l2_buffer *v4l2_buf, struct v4l2_t_buf *buf) +{ + + return 0; +} int main(void) { struct v4l2_driver drv; struct drv_list *cur; + unsigned int count = 10, i; if (v4l2_open ("/dev/video0", 1,&drv)<0) { perror("open"); @@ -76,12 +84,42 @@ int main(void) v4l2_mmap_bufs(&drv, 2); -// v4l2_start_streaming(&drv); + v4l2_start_streaming(&drv); + + printf("Waiting for frames...\n"); + + for (i=0;i<count;i++) { + fd_set fds; + struct timeval tv; + int r; -//sleep (1); + FD_ZERO (&fds); + FD_SET (drv.fd, &fds); -// v4l2_stop_streaming(&drv); + /* Timeout. */ + tv.tv_sec = 2; + tv.tv_usec = 0; + + r = select (drv.fd + 1, &fds, NULL, NULL, &tv); + if (-1 == r) { + if (EINTR == errno) + continue; + + perror ("select"); + return errno; + } + + if (0 == r) { + fprintf (stderr, "select timeout\n"); + return errno; + } + + if (v4l2_rcvbuf(&drv, recebe_buffer)) + break; + } + printf("stopping streaming\n"); + v4l2_stop_streaming(&drv); if (v4l2_close (&drv)<0) { perror("close"); |