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 typedef unsigned char avgbmp_t;
29 #define CLIP(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
31 #define SRC_TYPE_NONE (0)
32 #define SRC_TYPE_DEVICE (1 << 0) /* Can capture from a device */
33 #define SRC_TYPE_FILE (1 << 1) /* Can capture from a file */
35 /* When updating the palette list remember to update src_palette[] in src.c */
37 #define SRC_PAL_ANY (-1)
38 #define SRC_PAL_PNG (0)
39 #define SRC_PAL_JPEG (1)
40 #define SRC_PAL_MJPEG (2)
41 #define SRC_PAL_S561 (3)
42 #define SRC_PAL_RGB32 (4)
43 #define SRC_PAL_BGR32 (5)
44 #define SRC_PAL_RGB24 (6)
45 #define SRC_PAL_BGR24 (7)
46 #define SRC_PAL_YUYV (8)
47 #define SRC_PAL_UYVY (9)
48 #define SRC_PAL_YUV420P (10)
49 #define SRC_PAL_NV12MB (11)
50 #define SRC_PAL_BAYER (12)
51 #define SRC_PAL_SGBRG8 (13)
52 #define SRC_PAL_SGRBG8 (14)
53 #define SRC_PAL_RGB565 (15)
54 #define SRC_PAL_RGB555 (16)
55 #define SRC_PAL_Y16 (17)
56 #define SRC_PAL_GREY (18)
58 #define SRC_LIST_INPUTS (1 << 1)
59 #define SRC_LIST_TUNERS (1 << 2)
60 #define SRC_LIST_FORMATS (1 << 3)
61 #define SRC_LIST_CONTROLS (1 << 4)
62 #define SRC_LIST_FRAMESIZES (1 << 5)
63 #define SRC_LIST_FRAMERATES (1 << 6)
65 /* The SCALE macro converts a value (sv) from one range (sf -> sr)
66 to another (df -> dr). */
67 #define SCALE(df, dr, sf, sr, sv) (((sv - sf) * (dr - df) / (sr - sf)) + df)
73 extern src_palette_t src_palette[];
88 /* Last captured image */
109 src_option_t **option;
111 /* For calculating capture FPS */
112 uint32_t captured_frames;
113 struct timeval tv_first;
114 struct timeval tv_last;
124 int (*open)(src_t *);
125 int (*close)(src_t *);
126 int (*grab)(src_t *);
127 const char *(*query)(src_t *, uint*, uint*, char **);
133 /* List of options. */
135 const struct option *long_opts;
137 /* When reading from the command line. */
140 /* When reading from a configuration file. */
154 /* General options. */
157 unsigned char background;
162 /* Capture start time. */
165 /* Device options. */
169 unsigned long frequency;
174 /* Image capture options. */
179 unsigned int skipframes;
181 src_option_t **option;
186 fswebcam_job_t **job;
188 /* Banner options. */
201 /* Overlay options. */
205 /* Output options. */
212 extern int src_open(src_t *src, char *source);
213 extern int src_close(src_t *src);
214 extern int src_grab(src_t *src);
215 extern const char *src_query(src_t *src, char *source, uint *width, uint *height, char **pixelformatdescription);
217 extern int src_set_option(src_option_t ***options, char *name, char *value);
218 extern int src_get_option_by_number(src_option_t **opt, int number, char **name, char **value);
219 extern int src_get_option_by_name(src_option_t **opt, char *name, char **value);
220 extern int src_free_options(src_option_t ***options);