not a good day...
This commit is contained in:
parent
4fec59ec64
commit
14062a9586
12
v4l2/funcs.c
12
v4l2/funcs.c
|
@ -34,7 +34,8 @@ extern int verbosity;
|
|||
size_t length;
|
||||
};
|
||||
|
||||
static char *dev_name;
|
||||
static char *dev_name;
|
||||
|
||||
static enum io_method io = IO_METHOD_MMAP;
|
||||
static int fd = -1;
|
||||
struct buffer *buffers;
|
||||
|
@ -48,10 +49,12 @@ static void errno_exit(const char *s)
|
|||
fprintf(stderr, "%s error %d, %s\n", s, errno, strerror(errno));
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
static int xioctl(int fh, int request, void *arg)
|
||||
{
|
||||
int r;
|
||||
|
||||
/* PLEASE EXPLAIN THAT CODE */
|
||||
do {
|
||||
r = ioctl(fh, request, arg);
|
||||
} while (-1 == r && EINTR == errno);
|
||||
|
@ -225,10 +228,11 @@ if (-1 == xioctl(fd, VIDIOC_QUERYCAP, &cap)) {
|
|||
if (EINVAL == errno) {
|
||||
fprintf(stderr, "%s is not a V4L2 device\n", dev_name);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
errno_exit("VIDIOC_QUERYCAP");
|
||||
}
|
||||
}
|
||||
else {
|
||||
errno_exit("VIDIOC_QUERYCAP");
|
||||
}
|
||||
}
|
||||
|
||||
if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
|
||||
fprintf(stderr, "%s is no video capture device\n", dev_name);
|
||||
|
|
|
@ -25,13 +25,55 @@ void help(int n)
|
|||
|
||||
puts("camera controls");
|
||||
puts("\t-d bla\t\tselect video device");
|
||||
|
||||
puts("\t-e nnn\t\tset 'etype'");
|
||||
puts("\t-K nnn\t\tinteger parameter");
|
||||
puts("\t-n bla\t\tset title");
|
||||
exit(0);
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int init_screen(char *title)
|
||||
{
|
||||
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, title);
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int preparation(char *devname, int param)
|
||||
{
|
||||
int fd, foo;
|
||||
struct v4l2_capability cap;
|
||||
|
||||
fd = open_device(devname);
|
||||
if (fd < 0) {
|
||||
fprintf(stderr, "err %d on %s opening\n", errno, devname);
|
||||
return -2;
|
||||
}
|
||||
|
||||
/* est-ce un device qui permet la capture video */
|
||||
foo = ioctl(fd, VIDIOC_QUERYCAP, &cap);
|
||||
if (-1 == foo) {
|
||||
perror("VIDIOC_QUERYCAP");
|
||||
return -2;
|
||||
}
|
||||
if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
|
||||
fprintf(stderr, "%s is not a video capture device\n", devname);
|
||||
return -3;
|
||||
}
|
||||
|
||||
return fd;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int interactive(int fd, int notused)
|
||||
{
|
||||
|
||||
init_screen("prototype");
|
||||
|
||||
fprintf(stderr, "file descriptor = %d\n", fd);
|
||||
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt;
|
||||
int foo, opt, devnum;
|
||||
int etype = 0;
|
||||
char *device = "/dev/video0";
|
||||
char *title = NULL;
|
||||
|
@ -44,11 +86,18 @@ while ((opt = getopt(argc, argv, "d:e:hK:lT:v")) != -1) {
|
|||
case 'h': help(0); break;
|
||||
case 'K': K = atol(optarg); break;
|
||||
// case 'l': liste_des_devices(0); break;
|
||||
case 't': title = optarg;
|
||||
case 'v': verbosity++; break;
|
||||
}
|
||||
}
|
||||
|
||||
devnum = preparation(device, K);
|
||||
if (devnum < 0) {
|
||||
fprintf(stderr, "%s : erreur init video device\n", argv[0]);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foo = interactive(devnum, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue