1 /* fswebcam - FireStorm.cx's webcam generator */
2 /*============================================================*/
3 /* Copyright (C)2005-2010 Philip Heron <phil@sanslogic.co.uk> */
5 /* This program is distributed under the terms of the GNU */
6 /* General Public License, version 2. You may use, modify, */
7 /* and redistribute it under the terms of this license. A */
8 /* copy should be included with this source. */
26 #include "videodev2.h"
30 typedef unsigned char avgbmp_t;
33 #define CLIP(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
35 #define SRC_TYPE_NONE (0)
36 #define SRC_TYPE_DEVICE (1 << 0) /* Can capture from a device */
37 #define SRC_TYPE_FILE (1 << 1) /* Can capture from a file */
39 /* When updating the palette list remember to update src_palette[] in src.c */
41 #define SRC_PAL_ANY (-1)
42 #define SRC_PAL_PNG (0)
43 #define SRC_PAL_JPEG (1)
44 #define SRC_PAL_MJPEG (2)
45 #define SRC_PAL_S561 (3)
46 #define SRC_PAL_RGB32 (4)
47 #define SRC_PAL_BGR32 (5)
48 #define SRC_PAL_RGB24 (6)
49 #define SRC_PAL_BGR24 (7)
50 #define SRC_PAL_YUYV (8)
51 #define SRC_PAL_UYVY (9)
52 #define SRC_PAL_YUV420P (10)
53 #define SRC_PAL_NV12MB (11)
54 #define SRC_PAL_BAYER (12)
55 #define SRC_PAL_SGBRG8 (13)
56 #define SRC_PAL_SGRBG8 (14)
57 #define SRC_PAL_RGB565 (15)
58 #define SRC_PAL_RGB555 (16)
59 #define SRC_PAL_Y16 (17)
60 #define SRC_PAL_GREY (18)
62 #define SRC_LIST_INPUTS (1 << 1)
63 #define SRC_LIST_TUNERS (1 << 2)
64 #define SRC_LIST_FORMATS (1 << 3)
65 #define SRC_LIST_CONTROLS (1 << 4)
66 #define SRC_LIST_FRAMESIZES (1 << 5)
67 #define SRC_LIST_FRAMERATES (1 << 6)
69 /* The SCALE macro converts a value (sv) from one range (sf -> sr)
70 to another (df -> dr). */
71 #define SCALE(df, dr, sf, sr, sv) (((sv - sf) * (dr - df) / (sr - sf)) + df)
77 extern src_palette_t src_palette[];
92 /* Last captured image */
113 src_option_t **option;
115 /* For calculating capture FPS */
116 uint32_t captured_frames;
117 struct timeval tv_first;
118 struct timeval tv_last;
124 /* List of options. */
126 const struct option *long_opts;
128 /* When reading from the command line. */
131 /* When reading from a configuration file. */
145 /* General options. */
148 unsigned char background;
153 /* Capture start time. */
156 /* Device options. */
160 unsigned long frequency;
165 /* Image capture options. */
170 unsigned int skipframes;
172 src_option_t **option;
177 fswebcam_job_t **job;
179 /* Banner options. */
192 /* Overlay options. */
196 /* Output options. */
215 struct v4l2_capability cap;
216 struct v4l2_format fmt;
217 struct v4l2_requestbuffers req;
218 struct v4l2_buffer buf;
220 v4l2_buffer_t *buffer;
227 const char *query_v4ldevice(src_t *src, char **pixelformatdescription);