-
Notifications
You must be signed in to change notification settings - Fork 87
/
src.h
129 lines (100 loc) · 3.13 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
125
126
127
128
/* fswebcam - FireStorm.cx's webcam generator */
/*============================================================*/
/* Copyright (C)2005-2011 Philip Heron <phil@sanslogic.co.uk> */
/* */
/* 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_ABGR32 (6)
#define SRC_PAL_RGB24 (7)
#define SRC_PAL_BGR24 (8)
#define SRC_PAL_YUYV (9)
#define SRC_PAL_UYVY (10)
#define SRC_PAL_VYUY (11)
#define SRC_PAL_YUV420P (12)
#define SRC_PAL_NV12MB (13)
#define SRC_PAL_BAYER (14)
#define SRC_PAL_SBGGR8 (15)
#define SRC_PAL_SRGGB8 (16)
#define SRC_PAL_SGBRG8 (17)
#define SRC_PAL_SGRBG8 (18)
#define SRC_PAL_RGB565 (19)
#define SRC_PAL_RGB555 (20)
#define SRC_PAL_Y16 (21)
#define SRC_PAL_GREY (22)
#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