Compare commits

...

4 Commits

Author SHA1 Message Date
tth
c74695d07e enumerate image formats 2019-07-27 04:03:57 +02:00
tth
bba944e055 added missing include 2019-07-27 00:02:28 +02:00
tth
d67e03c465 krkrkr 2019-07-24 17:47:40 +02:00
tth
0ba486dd1d correction d'un message 2019-07-24 17:47:28 +02:00
4 changed files with 51 additions and 5 deletions

View File

@ -8,7 +8,7 @@
#include <math.h>
#include <string.h>
#include <sys/ioctl.h>
#include <inttypes.h>
#include <linux/videodev2.h>
#include "funcs.h"

View File

@ -70,6 +70,19 @@ fprintf(FP, " capabilities 0x%X\n", ptr->capabilities);
pr_capabilities(ptr->capabilities);
fprintf(FP, " device caps 0x%X\n", ptr->device_caps);
return -1;
}
/* --------------------------------------------------------------------- */
int pr_v4l2_fmtdesc(char *txt, struct v4l2_fmtdesc *ptr)
{
fprintf(FP, "-- v4l2_fmtdesc, %-15s %p\n", txt, ptr);
fprintf(FP, " index %d\n", ptr->index);
fprintf(FP, " type %d\n", ptr->type); /* enum v4l2_buf_type */
fprintf(FP, " flags 0x%X\n", ptr->flags);
fprintf(FP, " description %s\n", ptr->description);
fprintf(FP, " pixel format 0x%X\n", ptr->pixelformat); /* FOURCC */
return -1;
}
/* --------------------------------------------------------------------- */

View File

@ -9,6 +9,7 @@ int pr_v4l2_capability(char *txt, struct v4l2_capability *ptr);
int pr_v4l2_input(char *txt, struct v4l2_input *ptr);
int pr_v4l2_format(char *txt, struct v4l2_format *ptr);
int pr_v4l2_requestbuffers(char *txt, struct v4l2_requestbuffers *ptr);
int pr_v4l2_fmtdesc(char *txt, struct v4l2_fmtdesc *ptr);
char *str_input_type(int t);
char *str_ctrl_type(int type);

View File

@ -19,6 +19,37 @@
int verbosity;
/* --------------------------------------------------------------------- */
int enum_image_formats(int fd, char *txt, int k)
{
int foo, idx;
struct v4l2_fmtdesc fmtd;
printf("-- image formats enumeration (%s)\n", txt);
idx = 0;
for (;;) {
memset(&fmtd, 0, sizeof(fmtd));
fmtd.index = idx;
fmtd.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
foo = ioctl(fd, VIDIOC_ENUM_FMT, &fmtd);
// fprintf(stderr, "B idx=%d, foo=%d, errno=%d\n", idx, foo, errno);
if (foo) {
if (EINVAL==errno) {
break;
}
else {
perror(__func__);
break;
}
}
pr_v4l2_fmtdesc(__func__, &fmtd);
idx++;
}
return -1;
}
/* --------------------------------------------------------------------- */
static int enum_inputs(int fd, char *txt, int k)
{
@ -103,7 +134,7 @@ int enum_extended_controls(int fd, char *txt, int k)
struct v4l2_queryctrl qctrl;
int idx;
printf("-- controls enumeration '%s'\n", txt);
printf("-- extended controls enumeration '%s'\n", txt);
memset(&qctrl, 0, sizeof(qctrl));
qctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
@ -124,7 +155,7 @@ while (0 == ioctl (fd, VIDIOC_QUERYCTRL, &qctrl)) {
return -1;
}
/* --------------------------------------------------------------------- */
int show_webcam_infos(char *devname, int k)
int show_webcam_infos(char *devname, char *title, int k)
{
int vfd, foo;
@ -162,8 +193,9 @@ if (-1 == ioctl(vfd, VIDIOC_ENUMINPUT, &input)) {
}
pr_v4l2_input("input 0", &input);
foo = enum_inputs(vfd, "is that working ?", 0);
foo = enum_inputs(vfd, "on peut voir quoi ?", 0);
foo = enum_image_formats(vfd, "Experimental", 0);
fputs("--\n", stderr);
foo = enum_controls(vfd, "is that working ?", 0);
@ -216,7 +248,7 @@ while ((opt = getopt(argc, argv, "d:hK:lv")) != -1) {
if (verbosity) fimg_print_version(0);
foo = show_webcam_infos(device, K);
foo = show_webcam_infos(device, "", K);
fprintf(stderr, "\n\tshow_webcam_infos -> %d\n", foo);
return 0;