]> git.sesse.net Git - kdenlive/blob - src/v4l/src.h
Reorganise (again) the build system
[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 #ifndef INC_SRC_H
15 #define INC_SRC_H
16
17 #include <stdint.h>
18 #include <sys/time.h>
19 #include <stdio.h>
20 #include <stdlib.h>
21 #include <string.h>
22 #include <pthread.h>
23 #include <unistd.h>
24 #include <fcntl.h>
25
26 #include "videodev2.h"
27
28
29
30 typedef unsigned char avgbmp_t;
31
32
33 #define CLIP(val, min, max) (((val) > (max)) ? (max) : (((val) < (min)) ? (min) : (val)))
34
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 */
38
39 /* When updating the palette list remember to update src_palette[] in src.c */
40
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)
61
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)
68
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)
72
73 typedef struct {
74         char *name;
75         char *value;
76 } src_option_t;
77
78 typedef struct {
79         
80         /* Source Options */
81         char *source;
82         uint8_t type;
83         
84         void *state;
85         
86         /* Last captured image */
87         uint32_t length;
88         void *img;
89         
90         /* Input Options */
91         char    *input;
92         uint8_t  tuner;
93         uint32_t frequency;
94         uint32_t delay;
95         uint32_t timeout;
96         char     use_read;
97         
98         /* List Options */
99         uint8_t list;
100         
101         /* Image Options */
102         int palette;
103         uint32_t width;
104         uint32_t height;
105         uint32_t fps;
106         
107         src_option_t **option;
108         
109         /* For calculating capture FPS */
110         uint32_t captured_frames;
111         struct timeval tv_first;
112         struct timeval tv_last;
113         
114 } src_t;
115
116 typedef struct {
117         
118         /* List of options. */
119         char *opts;
120         const struct option *long_opts;
121         
122         /* When reading from the command line. */
123         int opt_index;
124         
125         /* When reading from a configuration file. */
126         char *filename;
127         FILE *f;
128         size_t line;
129         
130 } fswc_getopt_t;
131
132 typedef struct {
133         uint16_t id;
134         char    *options;
135 } fswebcam_job_t;
136
137 typedef struct {
138
139         /* General options. */
140         unsigned long loop;
141         signed long offset;
142         unsigned char background;
143         char *pidfile;
144         char *logfile;
145         char gmt;
146
147         /* Capture start time. */
148         time_t start;
149
150         /* Device options. */
151         char *device;
152         char *input;
153         unsigned char tuner;
154         unsigned long frequency;
155         unsigned long delay;
156         char use_read;
157         uint8_t list;
158
159         /* Image capture options. */
160         unsigned int width;
161         unsigned int height;
162         unsigned int frames;
163         unsigned int fps;
164         unsigned int skipframes;
165         int palette;
166         src_option_t **option;
167         char *dumpframe;
168
169         /* Job queue. */
170         uint8_t jobs;
171         fswebcam_job_t **job;
172
173         /* Banner options. */
174         char banner;
175         uint32_t bg_colour;
176         uint32_t bl_colour;
177         uint32_t fg_colour;
178         char *title;
179         char *subtitle;
180         char *timestamp;
181         char *info;
182         char *font;
183         int fontsize;
184         char shadow;
185
186         /* Overlay options. */
187         char *underlay;
188         char *overlay;
189
190         /* Output options. */
191         char *filename;
192         char format;
193         char compression;
194
195 } fswebcam_config_t;
196
197
198
199 typedef struct {
200         void *start;
201         size_t length;
202 } v4l2_buffer_t;
203
204 typedef struct {
205
206         int fd;
207         char map;
208
209         struct v4l2_capability cap;
210         struct v4l2_format fmt;
211         struct v4l2_requestbuffers req;
212         struct v4l2_buffer buf;
213
214         v4l2_buffer_t *buffer;
215
216         int pframe;
217
218 } src_v4l2_t;
219
220
221 const char *query_v4ldevice(src_t *src, char **pixelformatdescription);
222
223 #endif
224
225
226 #ifdef __cplusplus
227 }
228 #endif
229