1 /*****************************************************************************
2 * input_ext-intf.h: structures of the input exported to the interface
3 * This header provides structures to read the stream descriptors and
4 * control the pace of reading.
5 *****************************************************************************
6 * Copyright (C) 1999, 2000 VideoLAN
7 * $Id: input_ext-intf.h,v 1.76 2002/08/12 22:12:50 massiot Exp $
9 * Authors: Christophe Massiot <massiot@via.ecp.fr>
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
24 *****************************************************************************/
26 #ifndef _VLC_INPUT_EXT_INTF_H
27 #define _VLC_INPUT_EXT_INTF_H 1
30 * Communication input -> interface
33 #define REQUESTED_MPEG 1
34 #define REQUESTED_A52 2
35 #define REQUESTED_LPCM 3
36 #define REQUESTED_NOAUDIO 255
38 #define OFFSETTOTIME_MAX_SIZE 10
40 /*****************************************************************************
41 * es_descriptor_t: elementary stream descriptor
42 *****************************************************************************
43 * Describes an elementary stream, and includes fields required to handle and
44 * demultiplex this elementary stream.
45 *****************************************************************************/
46 struct es_descriptor_t
48 u16 i_id; /* stream ID for PS, PID for TS */
49 u8 i_stream_id; /* stream ID defined in the PES */
50 vlc_fourcc_t i_fourcc; /* stream type */
51 u8 i_cat; /* stream category (audio, video, spu) */
52 int i_demux_fd; /* used to store demux device
54 char psz_desc[20]; /* description of ES: audio language
55 * for instance ; NULL if not
58 /* Demultiplexer information */
59 es_sys_t * p_demux_data;
60 pgrm_descriptor_t * p_pgrm; /* very convenient in the demultiplexer */
62 /* PES parser information */
63 pes_packet_t * p_pes; /* Current PES */
64 int i_pes_real_size; /* as indicated by the header */
66 /* Decoder information */
67 decoder_fifo_t * p_decoder_fifo;
69 count_t c_packets; /* total packets read */
70 count_t c_invalid_packets; /* invalid packets read */
73 /* Special PID values - note that the PID is only on 13 bits, and that values
74 * greater than 0x1fff have no meaning in a stream */
75 #define PROGRAM_ASSOCIATION_TABLE_PID 0x0000
76 #define CONDITIONNAL_ACCESS_TABLE_PID 0x0001 /* not used */
77 #define EMPTY_ID 0xffff /* empty record in a table */
80 /* ES Categories to be used by interface plugins */
81 #define UNKNOWN_ES 0x00
87 /*****************************************************************************
89 *****************************************************************************
90 * Describes a program and list associated elementary streams. It is build by
91 * the PSI decoder upon the informations carried in program map sections
92 *****************************************************************************/
93 struct pgrm_descriptor_t
95 /* Program characteristics */
96 u16 i_number; /* program number */
97 u8 i_version; /* version number */
98 vlc_bool_t b_is_ok; /* Is the description up to date ? */
100 /* Service Descriptor (program name) - DVB extension */
104 /* Synchronization information */
106 mtime_t cr_ref, sysdate_ref;
107 mtime_t last_cr; /* reference to detect unexpected stream
110 count_t c_average_count;
111 /* counter used to compute dynamic average values */
114 /* Demultiplexer data */
115 pgrm_sys_t * p_demux_data;
117 int i_es_number; /* size of the following array */
118 es_descriptor_t ** pp_es; /* array of pointers to ES */
123 #define SYNCHRO_START 1
124 #define SYNCHRO_REINIT 2
126 /*****************************************************************************
128 *****************************************************************************
129 * Attributes for current area (title for DVD)
130 *****************************************************************************/
133 /* selected area attributes */
134 int i_id; /* identificator for area */
135 off_t i_start; /* start offset of area */
136 off_t i_size; /* total size of the area
137 * (in arbitrary units) */
139 /* navigation parameters */
140 off_t i_tell; /* actual location in the area
141 * (in arbitrary units) */
142 off_t i_seek; /* next requested location
143 * (changed by the interface thread */
145 /* area subdivision */
146 int i_part_nb; /* number of parts (chapter for DVD)*/
147 int i_part; /* currently selected part */
150 /* offset to plugin related data */
154 /*****************************************************************************
156 *****************************************************************************
157 * Composes a linked list of name/value pairs intended to inform the
158 * user about the current stream
159 *****************************************************************************/
160 struct input_info_t {
163 input_info_t * p_next;
166 /*****************************************************************************
167 * input_info_category_t
168 *****************************************************************************
169 * Composes a linked list of categories in which to place info about
171 *****************************************************************************/
172 struct input_info_category_t {
174 input_info_t * p_info;
175 input_info_category_t * p_next;
178 /*****************************************************************************
179 * stream_descriptor_t
180 *****************************************************************************
181 * Describes a stream and list its associated programs. Build upon
182 * the information carried in program association sections (for instance)
183 *****************************************************************************/
184 struct stream_descriptor_t
186 u16 i_stream_id; /* stream id */
187 vlc_bool_t b_changed; /* if stream has been changed,
188 we have to inform the interface */
189 vlc_mutex_t stream_lock; /* to be taken every time you read
190 * or modify stream, pgrm or es */
192 /* Input method data */
193 int i_method; /* input method for stream: file,
195 vlc_bool_t b_pace_control; /* can we read when we want ? */
196 vlc_bool_t b_seekable; /* can we do lseek() ? */
198 /* if (b_seekable) : */
200 input_area_t ** pp_areas; /* list of areas in stream == offset
201 * interval with own properties */
202 input_area_t * p_selected_area;
203 input_area_t * p_new_area; /* Newly selected area from
206 u32 i_mux_rate; /* the rate we read the stream (in
207 * units of 50 bytes/s) ; 0 if undef */
209 /* New status and rate requested by the interface */
210 int i_new_status, i_new_rate;
211 int b_new_mute; /* int because it can be -1 */
212 vlc_cond_t stream_wait; /* interface -> input in case of a
213 * status change request */
215 /* Demultiplexer data */
216 stream_sys_t * p_demux_data;
218 /* Programs descriptions */
219 int i_pgrm_number; /* size of the following array */
220 pgrm_descriptor_t ** pp_programs; /* array of pointers to pgrm */
221 pgrm_descriptor_t * p_selected_program; /* currently
223 pgrm_descriptor_t * p_new_program; /* Newly selected program */
224 /* ES descriptions */
226 es_descriptor_t ** pp_es; /* carried elementary streams */
227 int i_selected_es_number;
228 es_descriptor_t ** pp_selected_es; /* ES with a decoder */
229 es_descriptor_t * p_newly_selected_es; /* ES selected from
231 es_descriptor_t * p_removed_es; /* ES removed from the interface */
234 stream_ctrl_t control;
236 /* Optional stream output */
237 sout_instance_t * p_sout;
240 input_info_category_t * p_info;
243 count_t c_packets_read; /* packets read */
244 count_t c_packets_trashed; /* trashed packets */
247 /*****************************************************************************
249 *****************************************************************************
250 * Describes the current position in the stream.
251 *****************************************************************************/
252 struct stream_position_t
254 off_t i_tell; /* actual location in the area (in arbitrary units) */
255 off_t i_size; /* total size of the area (in arbitrary units) */
257 u32 i_mux_rate; /* the rate we read the stream (in
258 * units of 50 bytes/s) ; 0 if undef */
261 #define MUTE_NO_CHANGE -1
263 /*****************************************************************************
265 *****************************************************************************
266 * This structure includes all the local static variables of an input thread
267 *****************************************************************************/
268 struct input_thread_t
272 /* Thread properties */
277 ssize_t (* pf_read ) ( input_thread_t *, byte_t *, size_t );
278 int (* pf_set_program )( input_thread_t *, pgrm_descriptor_t * );
279 int (* pf_set_area )( input_thread_t *, input_area_t * );
280 void (* pf_seek ) ( input_thread_t *, off_t );
281 access_sys_t * p_access_data;
286 int (* pf_demux ) ( input_thread_t * );
287 int (* pf_rewind ) ( input_thread_t * );
288 /* NULL if we don't support going *
289 * backwards (it's gonna be fun) */
290 demux_sys_t * p_demux_data; /* data of the demux */
293 input_buffers_t *p_method_data; /* data of the packet manager */
294 data_buffer_t * p_data_buffer;
295 byte_t * p_current_data;
296 byte_t * p_last_data;
299 /* General stream description */
300 stream_descriptor_t stream;
312 /* The first figure is a general method that can be used in interface plugins ;
313 * The second figure is a detailed sub-method */
314 #define INPUT_METHOD_NONE 0x0 /* input thread is inactive */
315 #define INPUT_METHOD_FILE 0x10 /* stream is read from file p_source */
316 #define INPUT_METHOD_DISC 0x20 /* stream is read directly from disc */
317 #define INPUT_METHOD_DVD 0x21 /* stream is read from DVD */
318 #define INPUT_METHOD_VCD 0x22 /* stream is read from VCD */
319 #define INPUT_METHOD_NETWORK 0x30 /* stream is read from network */
320 #define INPUT_METHOD_UCAST 0x31 /* UDP unicast */
321 #define INPUT_METHOD_MCAST 0x32 /* UDP multicast */
322 #define INPUT_METHOD_BCAST 0x33 /* UDP broadcast */
323 #define INPUT_METHOD_VLAN_BCAST 0x34 /* UDP broadcast with VLANs */
324 #define INPUT_METHOD_SATELLITE 0x40 /* stream is read from a */
327 /* Status changing methods */
328 #define INPUT_STATUS_END 0
329 #define INPUT_STATUS_PLAY 1
330 #define INPUT_STATUS_PAUSE 2
331 #define INPUT_STATUS_FASTER 3
332 #define INPUT_STATUS_SLOWER 4
335 #define INPUT_SEEK_SET 0x00
336 #define INPUT_SEEK_CUR 0x01
337 #define INPUT_SEEK_END 0x02
338 #define INPUT_SEEK_BYTES 0x00
339 #define INPUT_SEEK_SECONDS 0x10
340 #define INPUT_SEEK_PERCENT 0x20
342 /*****************************************************************************
344 *****************************************************************************/
345 #define input_CreateThread(a,b,c) __input_CreateThread(VLC_OBJECT(a),b,c)
346 input_thread_t * __input_CreateThread ( vlc_object_t *,
347 playlist_item_t *, int * );
348 void input_StopThread ( input_thread_t * );
349 void input_DestroyThread ( input_thread_t * );
351 #define input_SetStatus(a,b) __input_SetStatus(VLC_OBJECT(a),b)
352 VLC_EXPORT( void, __input_SetStatus, ( vlc_object_t *, int ) );
354 #define input_Seek(a,b,c) __input_Seek(VLC_OBJECT(a),b,c)
355 VLC_EXPORT( void, __input_Seek, ( vlc_object_t *, off_t, int ) );
357 #define input_Tell(a,b) __input_Tell(VLC_OBJECT(a),b)
358 VLC_EXPORT( void, __input_Tell, ( vlc_object_t *, stream_position_t * ) );
360 VLC_EXPORT( void, input_DumpStream, ( input_thread_t * ) );
361 VLC_EXPORT( char *, input_OffsetToTime, ( input_thread_t *, char *, off_t ) );
362 VLC_EXPORT( int, input_ToggleES, ( input_thread_t *, es_descriptor_t *, vlc_bool_t ) );
363 VLC_EXPORT( int, input_ChangeArea, ( input_thread_t *, input_area_t * ) );
364 VLC_EXPORT( int, input_ChangeProgram, ( input_thread_t *, u16 ) );
366 int input_ToggleGrayscale( input_thread_t * );
367 int input_ToggleMute ( input_thread_t * );
369 #endif /* "input_ext-intf.h" */