minor improvments
This commit is contained in:
parent
312f892576
commit
c48a3e4870
@ -18,10 +18,10 @@ v4l2_pr_structs.o: v4l2_pr_structs.c v4l2_pr_structs.h Makefile
|
||||
gcc ${COPT} -c $<
|
||||
|
||||
grabvidseq: grabvidseq.c ${DEPS} rgb2fimg.o
|
||||
gcc ${COPT} $< rgb2fimg.o ../libfloatimg.a -lz -lm -lv4l2 -o $@
|
||||
gcc ${COPT} $< rgb2fimg.o ../libfloatimg.a -lpnglite -lz -lm -lv4l2 -o $@
|
||||
|
||||
video-infos: video-infos.c Makefile funcs.o v4l2_pr_structs.o
|
||||
gcc -Wall -g $< funcs.o v4l2_pr_structs.o -o $@
|
||||
gcc -Wall -g $< funcs.o v4l2_pr_structs.o ../libfloatimg.a -o $@
|
||||
|
||||
|
||||
# ---------------
|
||||
|
24
v4l2/funcs.c
24
v4l2/funcs.c
@ -2,18 +2,22 @@
|
||||
* V4L2 functions - ugly source code
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <fcntl.h> /* low-level i/o */
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <fcntl.h> /* low-level i/o */
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#include <linux/videodev2.h>
|
||||
#include <linux/videodev2.h>
|
||||
|
||||
#include "../floatimg.h"
|
||||
|
||||
#include "funcs.h"
|
||||
|
||||
/* --------------------------------------------------------------------- */
|
||||
|
||||
@ -215,7 +219,7 @@ fprintf(stderr, ">>> %s ( %d )\n", __func__, notused);
|
||||
|
||||
if (-1 == xioctl(fd, VIDIOC_QUERYCAP, &cap)) {
|
||||
if (EINVAL == errno) {
|
||||
fprintf(stderr, "%s is no V4L2 device\n", dev_name);
|
||||
fprintf(stderr, "%s is not a V4L2 device\n", dev_name);
|
||||
exit(EXIT_FAILURE);
|
||||
} else {
|
||||
errno_exit("VIDIOC_QUERYCAP");
|
||||
|
@ -59,7 +59,7 @@ fputs("\n", FP);
|
||||
/* --------------------------------------------------------------------- */
|
||||
int pr_v4l2_capability(char *txt, struct v4l2_capability *ptr)
|
||||
{
|
||||
fprintf(FP, "-- v4l2_capability, %-15s %p\n", txt, ptr);
|
||||
fprintf(FP, "## v4l2_capability, %-15s %p\n", txt, ptr);
|
||||
|
||||
fprintf(FP, " driver %s\n", ptr->driver);
|
||||
fprintf(FP, " card %s\n", ptr->card);
|
||||
@ -115,7 +115,7 @@ return "???";
|
||||
/* --------------------------------------------------------------------- */
|
||||
int pr_v4l2_fmtdesc(char *txt, struct v4l2_fmtdesc *ptr)
|
||||
{
|
||||
fprintf(FP, "-- v4l2_fmtdesc, %-15s %p\n", txt, 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 */
|
||||
@ -170,7 +170,7 @@ if (st & V4L2_IN_CAP_NATIVE_SIZE) fputs("nativsz ", FP);
|
||||
/* --------------------------------------------------------------------- */
|
||||
int pr_v4l2_input(char *txt, struct v4l2_input *ptr)
|
||||
{
|
||||
fprintf(FP, "-- v4l2_input, %-15s %p\n", txt, ptr);
|
||||
fprintf(FP, "## v4l2_input, %-15s %p\n", txt, ptr);
|
||||
|
||||
fprintf(FP, " index %d\n", ptr->index);
|
||||
fprintf(FP, " name %s\n", ptr->name);
|
||||
@ -218,7 +218,7 @@ return "???";
|
||||
/* --------------------------------------------------------------------- */
|
||||
int pr_v4l2_format(char *txt, struct v4l2_format *ptr)
|
||||
{
|
||||
fprintf(FP, "-- v4l2_format, %-15s %p\n", txt, ptr);
|
||||
fprintf(FP, "## v4l2_format, %-15s %p\n", txt, ptr);
|
||||
fprintf(FP, " type %d %s\n", ptr->type,/* enum v4l2_buf_type */
|
||||
fmttype2str(ptr->type));
|
||||
|
||||
@ -250,7 +250,7 @@ return 0;
|
||||
/* --------------------------------------------------------------------- */
|
||||
int pr_v4l2_requestbuffers(char *txt, struct v4l2_requestbuffers *ptr)
|
||||
{
|
||||
fprintf(FP, "-- v4l2_requestbuffers, %s %p\n", txt, ptr);
|
||||
fprintf(FP, "## v4l2_requestbuffers, %s %p\n", txt, ptr);
|
||||
fprintf(FP, " type %d\n", ptr->type); /* enum v4l2_buf_type */
|
||||
|
||||
|
||||
|
@ -28,7 +28,7 @@ int enum_image_framesizes(int fd, char *txt, int k)
|
||||
int foo, idx;
|
||||
struct v4l2_frmsizeenum fmtsz;
|
||||
|
||||
printf("-- image framesizes enumeration (%s)\n", txt);
|
||||
printf("## image framesizes enumeration (%s)\n", txt);
|
||||
|
||||
for (idx=0; ; idx++) {
|
||||
memset(&fmtsz, 0, sizeof(fmtsz));
|
||||
@ -57,7 +57,7 @@ int enum_image_formats(int fd, char *txt, int k)
|
||||
int foo, idx;
|
||||
struct v4l2_fmtdesc fmtd;
|
||||
|
||||
printf("-- image formats enumeration (%s)\n", txt);
|
||||
printf("## image formats enumeration (%s)\n", txt);
|
||||
|
||||
idx = 0;
|
||||
for (;;) {
|
||||
@ -93,7 +93,7 @@ int index, foo;
|
||||
struct v4l2_input input;
|
||||
char ligne[50];
|
||||
|
||||
printf("-- inputs enumeration (%s)\n", txt);
|
||||
printf("## inputs enumeration (%s)\n", txt);
|
||||
|
||||
index = 0;
|
||||
for(;;) {
|
||||
@ -130,7 +130,7 @@ struct v4l2_queryctrl qctrl;
|
||||
int idx;
|
||||
|
||||
|
||||
printf("-- controls enumeration '%s'\n", txt);
|
||||
printf("## controls enumeration '%s'\n", txt);
|
||||
|
||||
memset (&qctrl, 0, sizeof (qctrl));
|
||||
|
||||
@ -148,7 +148,7 @@ for (idx=V4L2_CID_BASE; idx<V4L2_CID_LASTP1; idx++) {
|
||||
continue;
|
||||
}
|
||||
|
||||
printf(" %-32s %-10s [%d..%d]\n",
|
||||
printf(" %-40s %-10s [%d..%d]\n",
|
||||
qctrl.name,
|
||||
str_ctrl_type(qctrl.type),
|
||||
qctrl.minimum, qctrl.maximum);
|
||||
@ -179,7 +179,7 @@ int enum_extended_controls(int fd, char *txt, int k)
|
||||
struct v4l2_queryctrl qctrl;
|
||||
int idx;
|
||||
|
||||
printf("-- extended controls enumeration '%s'\n", txt);
|
||||
printf("##- extended controls enumeration '%s'\n", txt);
|
||||
|
||||
memset(&qctrl, 0, sizeof(qctrl));
|
||||
qctrl.id = V4L2_CTRL_FLAG_NEXT_CTRL;
|
||||
@ -200,7 +200,7 @@ while (0 == ioctl (fd, VIDIOC_QUERYCTRL, &qctrl)) {
|
||||
return -1;
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
int show_webcam_infos(char *devname, char *title, int k)
|
||||
int show_webcam_infos(char *devname, char *title, int k, int type)
|
||||
{
|
||||
int vfd, foo;
|
||||
char ligne[100];
|
||||
@ -213,7 +213,7 @@ struct v4l2_format fmt;
|
||||
// struct v4l2_requestbuffers reqbuf;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, devname, k);
|
||||
fprintf(stderr, ">>> %s ( '%s' %d %d)\n", __func__, devname, k, type);
|
||||
#endif
|
||||
|
||||
vfd = open_device(devname);
|
||||
@ -245,13 +245,17 @@ else {
|
||||
pr_v4l2_format("Experimental", &fmt);
|
||||
}
|
||||
|
||||
foo = enum_image_formats(vfd, "Experimental", 0);
|
||||
if (type) {
|
||||
|
||||
foo = enum_controls(vfd, "is that working ?", 0);
|
||||
;
|
||||
|
||||
foo = enum_extended_controls(vfd, "looking for extended", 0);
|
||||
|
||||
enum_image_framesizes(vfd, "code pas fini", 0);
|
||||
}
|
||||
else {
|
||||
foo = enum_image_formats(vfd, "Experimental", 0);
|
||||
foo = enum_controls(vfd, "is that working ?", 0);
|
||||
foo = enum_extended_controls(vfd, "looking for extended", 0);
|
||||
enum_image_framesizes(vfd, "code pas fini", 0);
|
||||
}
|
||||
|
||||
close(vfd);
|
||||
|
||||
@ -267,12 +271,15 @@ return -1;
|
||||
static void help(int k)
|
||||
{
|
||||
puts("Options :");
|
||||
puts("\t-e N\t\texamine that, please");
|
||||
puts("\t-d\t\tselect the video device");
|
||||
puts("\t-K\t\tset the K parameter");
|
||||
puts("\t-l\t\tlist video devices");
|
||||
puts("\t-T bla\t\tadd a title");
|
||||
puts("\t-v\t\tincrease verbosity");
|
||||
|
||||
// if (verbosity)
|
||||
{ puts(""); fimg_print_version(1); }
|
||||
exit(0);
|
||||
}
|
||||
/* --------------------------------------------------------------------- */
|
||||
@ -293,14 +300,15 @@ puts("\n");
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo, opt;
|
||||
|
||||
int etype = 0;
|
||||
char *device = "/dev/video0";
|
||||
char *title = NULL;
|
||||
int K = 0;
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:hK:lT:v")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "d:e:hK:lT:v")) != -1) {
|
||||
switch(opt) {
|
||||
case 'd': device = optarg; break;
|
||||
case 'e': etype = atol(optarg); break;
|
||||
case 'h': help(0); break;
|
||||
case 'K': K = atol(optarg); break;
|
||||
case 'l': liste_des_devices(0); break;
|
||||
@ -313,7 +321,7 @@ if (NULL != title) {
|
||||
print_title(title);
|
||||
}
|
||||
|
||||
foo = show_webcam_infos(device, "", K);
|
||||
foo = show_webcam_infos(device, "", K, etype);
|
||||
fprintf(stderr, "\n\tshow_webcam_infos -> %d\n", foo);
|
||||
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user