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, 2003 VideoLAN
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
29 #include "vlc_block.h"
33 * Communication input -> interface
36 #define REQUESTED_MPEG 1
37 #define REQUESTED_A52 2
38 #define REQUESTED_LPCM 3
39 #define REQUESTED_DTS 4
40 #define REQUESTED_NOAUDIO 255
42 /*****************************************************************************
43 * es_descriptor_t: elementary stream descriptor
44 *****************************************************************************
45 * Describes an elementary stream, and includes fields required to handle and
46 * demultiplex this elementary stream.
47 *****************************************************************************/
48 struct es_descriptor_t
50 uint16_t i_id; /* stream ID for PS, PID for TS */
51 uint8_t i_stream_id; /* stream ID defined in the PES */
52 vlc_fourcc_t i_fourcc; /* stream type */
53 uint8_t i_cat; /* stream category (audio, video, spu) */
54 int i_demux_fd; /* used to store demux device
56 char *psz_desc; /* description of ES: audio language
57 * for instance ; NULL if not
60 /* Demultiplexer information */
61 es_sys_t * p_demux_data;
62 pgrm_descriptor_t * p_pgrm; /* very convenient in the demultiplexer */
64 /* PES parser information */
65 pes_packet_t * p_pes; /* Current PES */
66 unsigned int i_pes_real_size; /* as indicated by the header */
68 /* Decoder information */
70 void * p_waveformatex;
71 void * p_bitmapinfoheader;
76 count_t c_packets; /* total packets read */
77 count_t c_invalid_packets; /* invalid packets read */
79 /* XXX hack: to force a decoder instead of mode based on sout */
80 vlc_bool_t b_force_decoder;
83 /* Special PID values - note that the PID is only on 13 bits, and that values
84 * greater than 0x1fff have no meaning in a stream */
85 #define PROGRAM_ASSOCIATION_TABLE_PID 0x0000
86 #define CONDITIONNAL_ACCESS_TABLE_PID 0x0001 /* not used */
87 #define EMPTY_ID 0xffff /* empty record in a table */
89 /*****************************************************************************
91 *****************************************************************************
92 * Describes a program and list associated elementary streams. It is build by
93 * the PSI decoder upon the informations carried in program map sections
94 *****************************************************************************/
95 struct pgrm_descriptor_t
97 /* Program characteristics */
98 uint16_t i_number; /* program number */
99 uint8_t i_version; /* version number */
100 vlc_bool_t b_is_ok; /* Is the description up to date ? */
102 /* Service Descriptor (program name) - DVB extension */
106 /* Synchronization information */
108 mtime_t cr_ref, sysdate_ref;
109 mtime_t last_cr; /* reference to detect unexpected stream
112 count_t c_average_count;
113 /* counter used to compute dynamic average values */
116 /* Demultiplexer data */
117 pgrm_sys_t * p_demux_data;
119 unsigned int i_es_number; /* size of the following array */
120 es_descriptor_t ** pp_es; /* array of pointers to ES */
125 #define SYNCHRO_START 1
126 #define SYNCHRO_REINIT 2
128 /*****************************************************************************
130 *****************************************************************************
131 * Attributes for current area (title for DVD)
132 *****************************************************************************/
135 /* selected area attributes */
136 unsigned int i_id; /* identificator for area */
137 off_t i_start; /* start offset of area */
138 off_t i_size; /* total size of the area
139 * (in arbitrary units) */
141 /* navigation parameters */
142 off_t i_tell; /* actual location in the area
143 * (in arbitrary units) */
144 off_t i_seek; /* next requested location
145 * (changed by the interface thread */
147 /* area subdivision */
148 unsigned int i_part_nb; /* number of parts (chapter for DVD)*/
149 unsigned int i_part; /* currently selected part */
152 /* offset to plugin related data */
157 * \brief A list of info items.
159 * Composes a linked list of name/value pairs intended to inform the
160 * user about the current stream
163 struct input_info_t {
175 * Pointer to next item in list, or NULL it at end of list
177 input_info_t * p_next;
181 * \brief A list of info categories.
183 * Composes a NULL terminated linked list of categories in which to
184 * place info about the stream.
186 * \see input_InfoCategory
188 struct input_info_category_t {
190 * The name of this category
195 * first element of a linked list containing info items
197 input_info_t * p_info;
200 * Pointer to next element in this list, or NULL if at end of list
202 input_info_category_t * p_next;
205 /*****************************************************************************
206 * stream_descriptor_t
207 *****************************************************************************
208 * Describes a stream and list its associated programs. Build upon
209 * the information carried in program association sections (for instance)
210 *****************************************************************************/
211 struct stream_descriptor_t
213 uint16_t i_stream_id; /* stream id */
214 vlc_bool_t b_changed; /* if stream has been changed,
215 we have to inform the interface */
216 vlc_mutex_t stream_lock; /* to be taken every time you read
217 * or modify stream, pgrm or es */
219 /* Input method data */
220 unsigned int i_method; /* input method for stream: file,
222 vlc_bool_t b_pace_control; /* can we read when we want ? */
223 vlc_bool_t b_seekable; /* can we do lseek() ? */
225 /* if (b_seekable) : */
226 unsigned int i_area_nb;
227 input_area_t ** pp_areas; /* list of areas in stream == offset
228 * interval with own properties */
229 input_area_t * p_selected_area;
230 input_area_t * p_new_area; /* Newly selected area from
233 uint32_t i_mux_rate; /* the rate we read the stream (in
234 * units of 50 bytes/s) ; 0 if undef */
236 /* New status and rate requested by the interface */
237 unsigned int i_new_status, i_new_rate;
238 int b_new_mute; /* int because it can be -1 */
239 vlc_cond_t stream_wait; /* interface -> input in case of a
240 * status change request */
241 /* Demultiplexer data */
244 /* Programs descriptions */
245 unsigned int i_pgrm_number; /* size of the following array */
246 pgrm_descriptor_t ** pp_programs; /* array of pointers to pgrm */
247 pgrm_descriptor_t * p_selected_program; /* currently
249 pgrm_descriptor_t * p_new_program; /* Newly selected program */
250 /* ES descriptions */
251 unsigned int i_es_number;
252 es_descriptor_t ** pp_es; /* carried elementary streams */
253 unsigned int i_selected_es_number;
254 es_descriptor_t ** pp_selected_es; /* ES with a decoder */
255 es_descriptor_t * p_newly_selected_es; /* ES selected from
257 es_descriptor_t * p_removed_es; /* ES removed from the interface */
260 stream_ctrl_t control;
262 /* Optional stream output */
263 sout_instance_t * p_sout;
266 input_info_category_t * p_info;
269 count_t c_packets_read; /* packets read */
270 count_t c_packets_trashed; /* trashed packets */
273 /*****************************************************************************
275 *****************************************************************************
276 * Describes the current position in the stream.
277 *****************************************************************************/
278 struct stream_position_t
280 off_t i_tell; /* actual location in the area (in arbitrary units) */
281 off_t i_size; /* total size of the area (in arbitrary units) */
283 uint32_t i_mux_rate; /* the rate we read the stream (in
284 * units of 50 bytes/s) ; 0 if undef */
287 #define MUTE_NO_CHANGE -1
289 /*****************************************************************************
291 *****************************************************************************
292 * This structure includes all the local static variables of an input thread
293 *****************************************************************************/
294 struct input_thread_t
298 /* Thread properties */
300 vlc_bool_t b_out_pace_control;
304 ssize_t (* pf_read ) ( input_thread_t *, byte_t *, size_t );
305 int (* pf_set_program )( input_thread_t *, pgrm_descriptor_t * );
306 int (* pf_set_area )( input_thread_t *, input_area_t * );
307 void (* pf_seek ) ( input_thread_t *, off_t );
308 access_sys_t * p_access_data;
310 int i_pts_delay; /* internal caching */
318 int (* pf_demux ) ( input_thread_t * );
319 int (* pf_rewind ) ( input_thread_t * );
320 /* NULL if we don't support going *
321 * backwards (it's gonna be fun) */
322 int (* pf_demux_control ) ( input_thread_t *, int, va_list );
323 demux_sys_t * p_demux_data; /* data of the demux */
329 input_buffers_t *p_method_data; /* data of the packet manager */
330 data_buffer_t * p_data_buffer;
331 byte_t * p_current_data;
332 byte_t * p_last_data;
335 /* General stream description */
336 stream_descriptor_t stream;
340 char * psz_dupsource;
349 seekpoint_t **pp_bookmarks;
351 /* private, do not touch it */
352 input_thread_sys_t *p_sys;
356 /* The first figure is a general method that can be used in interface plugins ;
357 * The second figure is a detailed sub-method */
358 #define INPUT_METHOD_NONE 0x0 /* input thread is inactive */
359 #define INPUT_METHOD_FILE 0x10 /* stream is read from file p_source */
360 #define INPUT_METHOD_DISC 0x20 /* stream is read directly from disc */
361 #define INPUT_METHOD_DVD 0x21 /* stream is read from DVD */
362 #define INPUT_METHOD_VCD 0x22 /* stream is read from VCD */
363 #define INPUT_METHOD_CDDA 0x23 /* stream is read from CDDA */
364 #define INPUT_METHOD_NETWORK 0x30 /* stream is read from network */
365 #define INPUT_METHOD_UCAST 0x31 /* UDP unicast */
366 #define INPUT_METHOD_MCAST 0x32 /* UDP multicast */
367 #define INPUT_METHOD_BCAST 0x33 /* UDP broadcast */
368 #define INPUT_METHOD_VLAN_BCAST 0x34 /* UDP broadcast with VLANs */
369 #define INPUT_METHOD_SATELLITE 0x40 /* stream is read from a */
371 #define INPUT_METHOD_SLP 0x50 /* SLP stream */
373 /* Status changing methods */
374 #define INPUT_STATUS_END 0
375 #define INPUT_STATUS_PLAY 1
376 #define INPUT_STATUS_PAUSE 2
377 #define INPUT_STATUS_FASTER 3
378 #define INPUT_STATUS_SLOWER 4
381 #define INPUT_SEEK_SET 0x00
382 #define INPUT_SEEK_CUR 0x01
383 #define INPUT_SEEK_END 0x02
384 #define INPUT_SEEK_BYTES 0x00
385 #define INPUT_SEEK_SECONDS 0x10
386 #define INPUT_SEEK_PERCENT 0x20
388 /*****************************************************************************
390 *****************************************************************************/
391 #define input_CreateThread(a,b,c,d) __input_CreateThread(VLC_OBJECT(a),b,c,d)
392 VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, char *psz_uri, char **ppsz_options, int i_options ) );
393 VLC_EXPORT( void, input_StopThread, ( input_thread_t * ) );
394 VLC_EXPORT( void, input_DestroyThread, ( input_thread_t * ) );
396 #define input_SetStatus(a,b) __input_SetStatus(VLC_OBJECT(a),b)
397 VLC_EXPORT( void, __input_SetStatus, ( vlc_object_t *, int ) );
399 #define input_SetRate(a,b) __input_SetRate(VLC_OBJECT(a),b)
400 VLC_EXPORT( void, __input_SetRate, ( vlc_object_t *, int ) );
402 #define input_Seek(a,b,c) __input_Seek(VLC_OBJECT(a),b,c)
403 VLC_EXPORT( void, __input_Seek, ( vlc_object_t *, off_t, int ) );
405 #define input_Tell(a,b) __input_Tell(VLC_OBJECT(a),b)
406 VLC_EXPORT( void, __input_Tell, ( vlc_object_t *, stream_position_t * ) );
408 VLC_EXPORT( void, input_DumpStream, ( input_thread_t * ) );
409 VLC_EXPORT( char *, input_OffsetToTime, ( input_thread_t *, char *, off_t ) );
410 VLC_EXPORT( int, input_ToggleES, ( input_thread_t *, es_descriptor_t *, vlc_bool_t ) );
411 VLC_EXPORT( int, input_ChangeArea, ( input_thread_t *, input_area_t * ) );
412 VLC_EXPORT( int, input_ChangeProgram, ( input_thread_t *, uint16_t ) );
414 int input_ToggleGrayscale( input_thread_t * );
415 int input_ToggleMute ( input_thread_t * );
417 #endif /* "input_ext-intf.h" */