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