aboutsummaryrefslogtreecommitdiffstats
path: root/src/videoinput.h
blob: b639b8582d7bb88afc10555e270fd08bb9bf29ca (plain)
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/**
 * Copyright (C) 2001, 2002, 2003 Billy Biggs <vektor@dumbterm.net>.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#ifndef VIDEOINPUT_H_INCLUDED
#define VIDEOINPUT_H_INCLUDED

#if defined (__SVR4) && defined (__sun)
# include <sys/int_types.h>
#else
# include <stdint.h>
#endif

#ifdef __cplusplus
extern "C" {
#endif

/**
 * This object represents a video4linux capture device.  Frames are
 * returned as packed Y'CbCr image maps with 4:2:2 encoding.  The scheme
 * used is also known as 'YUY2'.  Currently we only deal in frames and
 * assume that they are interlaced, and we only deal with sources that
 * can provide full frame height: 480 scanlines for NTSC, 576 for PAL.
 *
 * Note: it's arguable that we should try and get 486 scanlines for
 * NTSC.  However, since the bt8x8 only gives 480 scanlines, and this is
 * standard sampling for standards like MPEG-2 etc, I'll stick with 480
 * for now.  As long as I get an interlaced frame, everything is happy.
 */
typedef struct videoinput_s videoinput_t;

/**
 * Possible TV norms we support.
 */
#define VIDEOINPUT_NTSC    0
#define VIDEOINPUT_PAL     1
#define VIDEOINPUT_SECAM   2
#define VIDEOINPUT_PAL_NC  3
#define VIDEOINPUT_PAL_M   4
#define VIDEOINPUT_PAL_N   5
#define VIDEOINPUT_NTSC_JP 6
#define VIDEOINPUT_PAL_60  7

/** 
 * Possible tuner signal states.
 */
#define TUNER_STATE_HAS_SIGNAL      0
#define TUNER_STATE_SIGNAL_DETECTED 1
#define TUNER_STATE_SIGNAL_LOST     2
#define TUNER_STATE_NO_SIGNAL       3

/**
 * Possible audio modes.
 */
#define VIDEOINPUT_MONO    1
#define VIDEOINPUT_STEREO  2
#define VIDEOINPUT_LANG1   4
#define VIDEOINPUT_LANG2   8

/**
 * Returns a text version of the norm.
 */
const char *videoinput_get_norm_name( int norm );

/**
 * Returns the integer version of the norm from its name.
 */
int videoinput_get_norm_number( const char *name );

/**
 * Returns the time per field in microseconds.
 */
int videoinput_get_time_per_field( int norm );

/**
 * Returns a text version of the audio mode.
 */
const char *videoinput_get_audio_mode_name( videoinput_t *vidin, int mode );

/**
 * Create a new input device from the given device name and which input
 * number (cable, composite1, composite2, etc) to use.
 *
 * The capwidth provided is how many samples to ask for per scanline.
 * The height will always be full frame of 480 or 576.
 *
 * The verbose flag indicates we should print to stderr when things go
 * bad, and maybe for some helpful information messages.
 */
videoinput_t *videoinput_new( const char *v4l_device, int capwidth,
                              int volume, int norm, int verbose );

/**
 * Shut down the capture device.
 */
void videoinput_delete( videoinput_t *vidin );

/**
 * Returns the width of the input images.
 */
int videoinput_get_width( videoinput_t *vidin );

/**
 * Returns the height of the input images.
 */
int videoinput_get_height( videoinput_t *vidin );

/**
 * Returns the maximum horizontal resolution for input images.
 */
int videoinput_get_maxwidth( videoinput_t *vidin );

/**
 * Returns the current TV norm.
 */
int videoinput_get_norm( videoinput_t *vidin );

/**
 * Returns true if this input is a BT8x8-based card.
 */
int videoinput_is_bttv( videoinput_t *vidin );

/**
 * Returns true if this input provides UYVY ordered data instead
 * of YUYV ordered data.
 */
int videoinput_is_uyvy( videoinput_t *vidin );

/**
 * Returns true if this input is a V4l2 device.
 */
int videoinput_is_v4l2( videoinput_t *vidin );

/**
 * Returns a pointer to the next image buffer.  Also returns the last field
 * number captured.
 */
uint8_t *videoinput_next_frame( videoinput_t *vidin, int *frameid );

/**
 * Signal to the videoinput device that we're done reading the last frame, to
 * allow the hardware to use the buffer.
 */
void videoinput_free_frame( videoinput_t *vidin, int frameid );

int videoinput_buffer_invalid( videoinput_t *vidin, int frameid );

int videoinput_get_numframes( videoinput_t *vidin );

/**
 * Returns true if this input has a tuner.
 */
int videoinput_has_tuner( videoinput_t *vidin );

/**
 * Controls...
 */
int videoinput_get_hue( videoinput_t *vidin );
void videoinput_set_hue( videoinput_t *vidin, int newhue );
void videoinput_set_hue_relative( videoinput_t *vidin, int offset );
int videoinput_get_brightness( videoinput_t *vidin );
void videoinput_set_brightness( videoinput_t *vidin, int newbright );
void videoinput_set_brightness_relative( videoinput_t *vidin, int offset );
int videoinput_get_contrast( videoinput_t *vidin );
void videoinput_set_contrast( videoinput_t *vidin, int newcont );
void videoinput_set_contrast_relative( videoinput_t *vidin, int offset );
int videoinput_get_saturation( videoinput_t *vidin );
void videoinput_set_saturation( videoinput_t *vidin, int newcolour );
void videoinput_set_saturation_relative( videoinput_t *vidin, int offset );

/**
 * Sets the frequency to tune in to. (ie. the station to watch)
 * Since frequencies.c specifies all freqs in KHz, we take that as input.
 * If the card expects frequency in MHz, this function handles that.
 */
void videoinput_set_tuner_freq( videoinput_t *vidin, int freqKHz );

/**
 * Returns the currently tuned frequency in KHz
 */
int videoinput_get_tuner_freq( videoinput_t *vidin );

/**
 * Returns 1 if the frequency tuned to is a decent picture
 */
int videoinput_freq_present( videoinput_t *vidin );

/**
 * Returns how many inputs are available.
 */
int videoinput_get_num_inputs( videoinput_t *vidin );

/**
 * Returns the current input number.
 */
int videoinput_get_input_num( videoinput_t *vidin );

/**
 * Returns the name of the current input.
 */
const char *videoinput_get_input_name( videoinput_t *vidin );

/**
 * Returns the current audio mode.
 */
int videoinput_get_audio_mode( videoinput_t *vidin );

/**
 * Sets the current audio mode.
 */
void videoinput_set_audio_mode( videoinput_t *vidin, int mode );

/**
 * Mute the mixer if mute != 0
 */
void videoinput_mute( videoinput_t *vidin, int mute );

/**
 * Returns whether the volume is muted.
 */
int videoinput_get_muted( videoinput_t *vidin );

/**
 * Sets the current input.
 */
void videoinput_set_input_num( videoinput_t *vidin, int inputnum );

/**
 * Returns the current tuner state.
 */
int videoinput_check_for_signal( videoinput_t *vidin, int check_freq_present );

/**
 * Switches to the next 'compatible' norm.
 */
void videoinput_toggle_pal_secam( videoinput_t *vidin );

/**
 * Switches to a specific norm.
 */
void videoinput_switch_pal_secam( videoinput_t *vidin, int norm );

/**
 * Whether or not to use PAL_DK mode. Only applies to V4L2.
 */
void videoinput_set_pal_audio_mode( videoinput_t *vidin, int dkmode );

/**
 * Get pal_dk mode current value.
 */
int videoinput_get_pal_audio_mode( videoinput_t *vidin );

/**
 * Returns the name of the capture card driver.
 */
const char *videoinput_get_driver_name( videoinput_t *vidin );

/**
 * Sets the capture card volume to use as a percentage from 0-100.
 * If the value is negative, the capture card volume will remain unset.
 */
void videoinput_set_capture_volume( videoinput_t *vidin, int volume );

#ifdef __cplusplus
};
#endif
#endif /* VIDEOINPUT_H_INCLUDED */

Privacy Policy