]> git.sesse.net Git - kdenlive/blob - src/v4l/src.h
011a95191b861a0f2f20b9a46773632d05612b58
[kdenlive] / src / v4l / src.h
1 /* fswebcam - FireStorm.cx's webcam generator                 */
2 /*============================================================*/
3 /* Copyright (C)2005-2010 Philip Heron <phil@sanslogic.co.uk> */
4 /*                                                            */
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.                  */
9
10 #ifdef __cplusplus
11 extern "C" {
12  #endif
13
14 #include <stdint.h>
15 #include <sys/time.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <string.h>
19 #include <pthread.h>
20 #include <unistd.h>
21 #include <fcntl.h>
22
23 #ifndef INC_SRC_H
24 #define INC_SRC_H
25
26 #define SRC_TYPE_NONE   (0)
27 #define SRC_TYPE_DEVICE (1 << 0) /* Can capture from a device */
28 #define SRC_TYPE_FILE   (1 << 1) /* Can capture from a file */
29
30 /* When updating the palette list remember to update src_palette[] in src.c */
31
32 #define SRC_PAL_ANY     (-1)
33 #define SRC_PAL_PNG     (0)
34 #define SRC_PAL_JPEG    (1)
35 #define SRC_PAL_MJPEG   (2)
36 #define SRC_PAL_S561    (3)
37 #define SRC_PAL_RGB32   (4)
38 #define SRC_PAL_BGR32   (5)
39 #define SRC_PAL_RGB24   (6)
40 #define SRC_PAL_BGR24   (7)
41 #define SRC_PAL_YUYV    (8)
42 #define SRC_PAL_UYVY    (9)
43 #define SRC_PAL_YUV420P (10)
44 #define SRC_PAL_NV12MB  (11)
45 #define SRC_PAL_BAYER   (12)
46 #define SRC_PAL_SGBRG8  (13)
47 #define SRC_PAL_SGRBG8  (14)
48 #define SRC_PAL_RGB565  (15)
49 #define SRC_PAL_RGB555  (16)
50 #define SRC_PAL_Y16     (17)
51 #define SRC_PAL_GREY    (18)
52
53 #define SRC_LIST_INPUTS     (1 << 1)
54 #define SRC_LIST_TUNERS     (1 << 2)
55 #define SRC_LIST_FORMATS    (1 << 3)
56 #define SRC_LIST_CONTROLS   (1 << 4)
57 #define SRC_LIST_FRAMESIZES (1 << 5)
58 #define SRC_LIST_FRAMERATES (1 << 6)
59
60 /* The SCALE macro converts a value (sv) from one range (sf -> sr)
61    to another (df -> dr). */
62 #define SCALE(df, dr, sf, sr, sv) (((sv - sf) * (dr - df) / (sr - sf)) + df)
63
64 typedef struct {
65         char    *name;
66 } src_palette_t;
67
68 extern src_palette_t src_palette[];
69
70 typedef struct {
71         char *name;
72         char *value;
73 } src_option_t;
74
75 typedef struct {
76         
77         /* Source Options */
78         char *source;
79         uint8_t type;
80         
81         void *state;
82         
83         /* Last captured image */
84         uint32_t length;
85         void *img;
86         
87         /* Input Options */
88         char    *input;
89         uint8_t  tuner;
90         uint32_t frequency;
91         uint32_t delay;
92         uint32_t timeout;
93         char     use_read;
94         
95         /* List Options */
96         uint8_t list;
97         
98         /* Image Options */
99         int palette;
100         uint32_t width;
101         uint32_t height;
102         uint32_t fps;
103         
104         src_option_t **option;
105         
106         /* For calculating capture FPS */
107         uint32_t captured_frames;
108         struct timeval tv_first;
109         struct timeval tv_last;
110         
111 } src_t;
112
113 typedef struct {
114         
115         char *name;
116         
117         uint8_t flags;
118         
119         int (*open)(src_t *);
120         int (*close)(src_t *);
121         int (*grab)(src_t *);
122         const char *(*query)(src_t *, int*, int*);
123         
124 } src_mod_t;
125
126 typedef struct {
127         
128         /* List of options. */
129         char *opts;
130         const struct option *long_opts;
131         
132         /* When reading from the command line. */
133         int opt_index;
134         
135         /* When reading from a configuration file. */
136         char *filename;
137         FILE *f;
138         size_t line;
139         
140 } fswc_getopt_t;
141
142 typedef struct {
143         uint16_t id;
144         char    *options;
145 } fswebcam_job_t;
146
147 typedef struct {
148
149         /* General options. */
150         unsigned long loop;
151         signed long offset;
152         unsigned char background;
153         char *pidfile;
154         char *logfile;
155         char gmt;
156
157         /* Capture start time. */
158         time_t start;
159
160         /* Device options. */
161         char *device;
162         char *input;
163         unsigned char tuner;
164         unsigned long frequency;
165         unsigned long delay;
166         char use_read;
167         uint8_t list;
168
169         /* Image capture options. */
170         unsigned int width;
171         unsigned int height;
172         unsigned int frames;
173         unsigned int fps;
174         unsigned int skipframes;
175         int palette;
176         src_option_t **option;
177         char *dumpframe;
178
179         /* Job queue. */
180         uint8_t jobs;
181         fswebcam_job_t **job;
182
183         /* Banner options. */
184         char banner;
185         uint32_t bg_colour;
186         uint32_t bl_colour;
187         uint32_t fg_colour;
188         char *title;
189         char *subtitle;
190         char *timestamp;
191         char *info;
192         char *font;
193         int fontsize;
194         char shadow;
195
196         /* Overlay options. */
197         char *underlay;
198         char *overlay;
199
200         /* Output options. */
201         char *filename;
202         char format;
203         char compression;
204
205 } fswebcam_config_t;
206
207 extern int src_open(src_t *src, char *source);
208 extern int src_close(src_t *src);
209 extern int src_grab(src_t *src);
210 extern const char *src_query(src_t *src, char *source, int *width, int *height);
211
212 extern int src_set_option(src_option_t ***options, char *name, char *value);
213 extern int src_get_option_by_number(src_option_t **opt, int number, char **name, char **value);
214 extern int src_get_option_by_name(src_option_t **opt, char *name, char **value);
215 extern int src_free_options(src_option_t ***options);
216
217 #endif
218
219
220 #ifdef __cplusplus
221 }
222 #endif
223