Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f90c3c0b authored by Simon Harrison's avatar Simon Harrison Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (10210): Fix a bug on v4lgrab.c



v4lgrab  breaks the fputc macro on some systems, because of #defined
FILE.

Also, I also added comments because it was not at all clear that to get gspca
cameras to work with this application you need v4l1compat.

Signed-off-by: default avatarSimon Harrison <si1356@yahoo.co.uk>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 3e478c06
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -11,6 +11,15 @@
 *	Copied from http://www.tazenda.demon.co.uk/phil/vgrabber.c
 *	with minor modifications (Dave Forrest, drf5n@virginia.edu).
 *
 *
 *	For some cameras you may need to pre-load libv4l to perform
 *	the necessary decompression, e.g.:
 *
 *	export LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so
 *	./v4lgrab >image.ppm
 *
 *	see http://hansdegoede.livejournal.com/3636.html for details.
 *
 */

#include <unistd.h>
@@ -24,7 +33,7 @@
#include <linux/types.h>
#include <linux/videodev.h>

#define FILE "/dev/video0"
#define VIDEO_DEV "/dev/video0"

/* Stole this from tvset.c */

@@ -90,7 +99,7 @@ int get_brightness_adj(unsigned char *image, long size, int *brightness) {

int main(int argc, char ** argv)
{
  int fd = open(FILE, O_RDONLY), f;
  int fd = open(VIDEO_DEV, O_RDONLY), f;
  struct video_capability cap;
  struct video_window win;
  struct video_picture vpic;
@@ -100,13 +109,13 @@ int main(int argc, char ** argv)
  unsigned int i, src_depth;

  if (fd < 0) {
    perror(FILE);
    perror(VIDEO_DEV);
    exit(1);
  }

  if (ioctl(fd, VIDIOCGCAP, &cap) < 0) {
    perror("VIDIOGCAP");
    fprintf(stderr, "(" FILE " not a video4linux device?)\n");
    fprintf(stderr, "(" VIDEO_DEV " not a video4linux device?)\n");
    close(fd);
    exit(1);
  }