forked from fsphil/fswebcam
-
Notifications
You must be signed in to change notification settings - Fork 0
/
src.h
125 lines (96 loc) · 3.02 KB
/
src.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/* fswebcam - FireStorm.cx's webcam generator */
/*============================================================*/
/* Copyright (C)2005-2010 Philip Heron <[email protected]> */
/* */
/* This program is distributed under the terms of the GNU */
/* General Public License, version 2. You may use, modify, */
/* and redistribute it under the terms of this license. A */
/* copy should be included with this source. */
#include <stdint.h>
#include <sys/time.h>
#ifndef INC_SRC_H
#define INC_SRC_H
#define SRC_TYPE_NONE (0)
#define SRC_TYPE_DEVICE (1 << 0) /* Can capture from a device */
#define SRC_TYPE_FILE (1 << 1) /* Can capture from a file */
/* When updating the palette list remember to update src_palette[] in src.c */
#define SRC_PAL_ANY (-1)
#define SRC_PAL_PNG (0)
#define SRC_PAL_JPEG (1)
#define SRC_PAL_MJPEG (2)
#define SRC_PAL_S561 (3)
#define SRC_PAL_RGB32 (4)
#define SRC_PAL_BGR32 (5)
#define SRC_PAL_RGB24 (6)
#define SRC_PAL_BGR24 (7)
#define SRC_PAL_YUYV (8)
#define SRC_PAL_UYVY (9)
#define SRC_PAL_YUV420P (10)
#define SRC_PAL_NV12MB (11)
#define SRC_PAL_BAYER (12)
#define SRC_PAL_SGBRG8 (13)
#define SRC_PAL_SGRBG8 (14)
#define SRC_PAL_RGB565 (15)
#define SRC_PAL_RGB555 (16)
#define SRC_PAL_Y16 (17)
#define SRC_PAL_GREY (18)
#define SRC_LIST_INPUTS (1 << 1)
#define SRC_LIST_TUNERS (1 << 2)
#define SRC_LIST_FORMATS (1 << 3)
#define SRC_LIST_CONTROLS (1 << 4)
#define SRC_LIST_FRAMESIZES (1 << 5)
#define SRC_LIST_FRAMERATES (1 << 6)
/* The SCALE macro converts a value (sv) from one range (sf -> sr)
to another (df -> dr). */
#define SCALE(df, dr, sf, sr, sv) (((sv - sf) * (dr - df) / (sr - sf)) + df)
typedef struct {
char *name;
} src_palette_t;
extern src_palette_t src_palette[];
typedef struct {
char *name;
char *value;
} src_option_t;
typedef struct {
/* Source Options */
char *source;
uint8_t type;
void *state;
/* Last captured image */
uint32_t length;
void *img;
/* Input Options */
char *input;
uint8_t tuner;
uint32_t frequency;
uint32_t delay;
uint32_t timeout;
char use_read;
/* List Options */
uint8_t list;
/* Image Options */
int palette;
uint32_t width;
uint32_t height;
uint32_t fps;
src_option_t **option;
/* For calculating capture FPS */
uint32_t captured_frames;
struct timeval tv_first;
struct timeval tv_last;
} src_t;
typedef struct {
char *name;
uint8_t flags;
int (*open)(src_t *);
int (*close)(src_t *);
int (*grab)(src_t *);
} src_mod_t;
extern int src_open(src_t *src, char *source);
extern int src_close(src_t *src);
extern int src_grab(src_t *src);
extern int src_set_option(src_option_t ***options, char *name, char *value);
extern int src_get_option_by_number(src_option_t **opt, int number, char **name, char **value);
extern int src_get_option_by_name(src_option_t **opt, char *name, char **value);
extern int src_free_options(src_option_t ***options);
#endif