FPS option part 2
[fswebcam.git] / src.h
blob5fa39da4e9a1aa21e1a7753f79012c317f18a9f0
1 /* fswebcam - FireStorm.cx's webcam generator */
2 /*===========================================================*/
3 /* Copyright (C)2005 Philip Heron <phil@firestorm.cx> */
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. */
10 #include <stdint.h>
11 #include <sys/time.h>
13 #ifndef INC_SRC_H
14 #define INC_SRC_H
16 #define SRC_TYPE_NONE (0)
17 #define SRC_TYPE_DEVICE (1 << 0) /* Can capture from a device */
18 #define SRC_TYPE_FILE (1 << 1) /* Can capture from a file */
20 /* When updating the palette list remember to update src_palette[] in src.c */
22 #define SRC_PAL_ANY (-1)
23 #define SRC_PAL_PNG (0)
24 #define SRC_PAL_JPEG (1)
25 #define SRC_PAL_MJPEG (2)
26 #define SRC_PAL_RGB32 (3)
27 #define SRC_PAL_BGR32 (4)
28 #define SRC_PAL_RGB24 (5)
29 #define SRC_PAL_BGR24 (6)
30 #define SRC_PAL_YUYV (7)
31 #define SRC_PAL_UYVY (8)
32 #define SRC_PAL_YUV420P (9)
33 #define SRC_PAL_NV12MB (10)
34 #define SRC_PAL_BAYER (11)
35 #define SRC_PAL_SGBRG8 (12)
36 #define SRC_PAL_RGB565 (13)
37 #define SRC_PAL_RGB555 (14)
38 #define SRC_PAL_GREY (15)
40 #define SRC_LIST_INPUTS (1 << 1)
41 #define SRC_LIST_TUNERS (1 << 2)
42 #define SRC_LIST_FORMATS (1 << 3)
43 #define SRC_LIST_CONTROLS (1 << 4)
44 #define SRC_LIST_FRAMESIZES (1 << 5)
45 #define SRC_LIST_FRAMERATES (1 << 6)
47 /* The SCALE macro converts a value (sv) from one range (sf -> sr)
48 to another (df -> dr). */
49 #define SCALE(df, dr, sf, sr, sv) (((sv - sf) * (dr - df) / (sr - sf)) + df)
51 typedef struct {
52 char *name;
53 } src_palette_t;
55 extern src_palette_t src_palette[];
57 typedef struct {
58 char *name;
59 char *value;
60 } src_option_t;
62 typedef struct {
64 /* Source Options */
65 char *source;
66 uint8_t type;
68 void *state;
70 /* Last captured image */
71 uint32_t length;
72 void *img;
74 /* Input Options */
75 char *input;
76 uint8_t tuner;
77 uint32_t frequency;
78 uint32_t delay;
79 uint32_t timeout;
80 char use_read;
82 /* List Options */
83 uint8_t list;
85 /* Image Options */
86 int palette;
87 uint32_t width;
88 uint32_t height;
89 uint32_t fps;
91 src_option_t **option;
93 /* For calculating capture FPS */
94 uint32_t captured_frames;
95 struct timeval tv_first;
96 struct timeval tv_last;
98 } src_t;
100 typedef struct {
102 char *name;
104 uint8_t flags;
106 int (*open)(src_t *);
107 int (*close)(src_t *);
108 int (*grab)(src_t *);
110 } src_mod_t;
112 extern int src_open(src_t *src, char *source);
113 extern int src_close(src_t *src);
114 extern int src_grab(src_t *src);
116 extern int src_set_option(src_option_t ***options, char *name, char *value);
117 extern int src_get_option_by_number(src_option_t **opt, int number, char **name, char **value);
118 extern int src_get_option_by_name(src_option_t **opt, char *name, char **value);
119 extern int src_free_options(src_option_t ***options);
121 #endif