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.46 2001/11/11 18:15:41 sam 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 *****************************************************************************/
27 * Communication input -> interface
29 #define INPUT_MAX_PLUGINS 1
31 #define REQUESTED_MPEG 1
32 #define REQUESTED_AC3 2
33 #define REQUESTED_LPCM 3
34 #define REQUESTED_NOAUDIO 255
36 #define OFFSETTOTIME_MAX_SIZE 10
38 /*****************************************************************************
39 * es_descriptor_t: elementary stream descriptor
40 *****************************************************************************
41 * Describes an elementary stream, and includes fields required to handle and
42 * demultiplex this elementary stream.
43 *****************************************************************************/
44 struct decoder_fifo_s; /* defined in input_ext-dec.h */
45 struct pgrm_descriptor_s;
47 typedef struct es_descriptor_s
49 u16 i_id; /* stream ID for PS, PID for TS */
50 u8 i_stream_id; /* stream ID defined in the PES */
51 u8 i_type; /* stream type */
52 boolean_t b_audio; /* is the stream an audio stream that
53 * will need to be discarded with
54 * fast forward and slow motion ? */
55 u8 i_cat; /* stream category: video, audio,
58 char psz_desc[20]; /* description of ES: audio language
59 * for instance ; NULL if not
62 /* Demultiplexer information */
64 struct pgrm_descriptor_s *
65 p_pgrm; /* very convenient in the demultiplexer */
67 /* PES parser information */
68 struct pes_packet_s * p_pes; /* Current PES */
69 struct data_packet_s * p_last; /* The last packet gathered at present */
70 int i_pes_real_size; /* as indicated by the header */
72 /* Decoder information */
73 struct decoder_fifo_s * p_decoder_fifo;
74 vlc_thread_t thread_id; /* ID of the decoder */
76 count_t c_packets; /* total packets read */
77 count_t c_invalid_packets; /* invalid packets read */
80 /* Special PID values - note that the PID is only on 13 bits, and that values
81 * greater than 0x1fff have no meaning in a stream */
82 #define PROGRAM_ASSOCIATION_TABLE_PID 0x0000
83 #define CONDITIONNAL_ACCESS_TABLE_PID 0x0001 /* not used */
84 #define EMPTY_ID 0xffff /* empty record in a table */
86 /* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers */
87 #define MPEG1_VIDEO_ES 0x01
88 #define MPEG2_VIDEO_ES 0x02
89 #define MPEG1_AUDIO_ES 0x03
90 #define MPEG2_AUDIO_ES 0x04
91 #define AC3_AUDIO_ES 0x81
92 /* These ones might violate the norm : */
93 #define DVD_SPU_ES 0x82
94 #define LPCM_AUDIO_ES 0x83
95 #define UNKNOWN_ES 0xFF
97 /* ES Categories to be used by interface plugins */
102 #define UNKNOWN_ES 0xFF
103 /*****************************************************************************
105 *****************************************************************************
106 * Describes a program and list associated elementary streams. It is build by
107 * the PSI decoder upon the informations carried in program map sections
108 *****************************************************************************/
109 typedef struct pgrm_descriptor_s
111 /* Program characteristics */
112 u16 i_number; /* program number */
113 u8 i_version; /* version number */
114 boolean_t b_is_ok; /* Is the description up to date ? */
116 /* Service Descriptor (program name) - DVB extension */
120 /* Synchronization information */
122 mtime_t cr_ref, sysdate_ref;
123 mtime_t last_cr; /* reference to detect unexpected stream
126 count_t c_average_count;
127 /* counter used to compute dynamic average values */
130 /* Demultiplexer data */
133 int i_es_number; /* size of the following array */
134 es_descriptor_t ** pp_es; /* array of pointers to ES */
139 #define SYNCHRO_START 1
140 #define SYNCHRO_REINIT 2
142 /*****************************************************************************
144 *****************************************************************************
145 * Attributes for current area (title for DVD)
146 *****************************************************************************/
147 typedef struct input_area_s
149 /* selected area attributes */
150 int i_id; /* identificator for area */
151 off_t i_start; /* start offset of area */
152 off_t i_size; /* total size of the area
153 * (in arbitrary units) */
155 /* navigation parameters */
156 off_t i_tell; /* actual location in the area
157 * (in arbitrary units) */
158 off_t i_seek; /* next requested location
159 * (changed by the interface thread */
161 /* area subdivision */
162 int i_part_nb; /* number of parts (chapter for DVD)*/
163 int i_part; /* currently selected part */
165 int i_angle_nb; /* number of angles/title units */
168 /* offset to plugin related data */
172 /*****************************************************************************
173 * stream_descriptor_t
174 *****************************************************************************
175 * Describes a stream and list its associated programs. Build upon
176 * the information carried in program association sections (for instance)
177 *****************************************************************************/
178 typedef struct stream_descriptor_s
180 u16 i_stream_id; /* stream id */
181 boolean_t b_changed; /* if stream has been changed,
182 we have to inform the interface */
183 vlc_mutex_t stream_lock; /* to be taken every time you read
184 * or modify stream, pgrm or es */
186 /* Input method data */
187 int i_method; /* input method for stream: file,
189 boolean_t b_pace_control; /* can we read when we want ? */
190 boolean_t b_seekable; /* can we do lseek() ? */
192 /* if (b_seekable) : */
194 input_area_t ** pp_areas; /* list of areas in stream == offset
195 * interval with own properties */
196 input_area_t * p_selected_area;
197 input_area_t * p_new_area; /* Newly selected area from
200 u32 i_mux_rate; /* the rate we read the stream (in
201 * units of 50 bytes/s) ; 0 if undef */
203 /* New status and rate requested by the interface */
204 int i_new_status, i_new_rate;
205 int b_new_mute; /* int because it can be -1 */
206 vlc_cond_t stream_wait; /* interface -> input in case of a
207 * status change request */
209 /* Demultiplexer data */
212 /* Programs descriptions */
213 int i_pgrm_number; /* size of the following array */
214 pgrm_descriptor_t ** pp_programs; /* array of pointers to pgrm */
216 /* ES descriptions */
218 es_descriptor_t ** pp_es; /* carried elementary streams */
219 int i_selected_es_number;
220 es_descriptor_t ** pp_selected_es; /* ES with a decoder */
221 es_descriptor_t * p_newly_selected_es; /* ES selected from
223 es_descriptor_t * p_removed_es; /* ES removed from the interface */
227 stream_ctrl_t control;
230 count_t c_packets_read; /* packets read */
231 count_t c_packets_trashed; /* trashed packets */
232 } stream_descriptor_t;
234 #define MUTE_NO_CHANGE -1
236 /*****************************************************************************
238 *****************************************************************************
239 * This structure includes all the local static variables of an input thread
240 *****************************************************************************/
241 struct vout_thread_s;
244 typedef struct input_thread_s
246 /* Thread properties and locks */
247 boolean_t b_die; /* 'die' flag */
250 vlc_thread_t thread_id; /* id for thread functions */
251 int * pi_status; /* temporary status flag */
254 struct module_s * p_input_module;
257 void (* pf_init)( struct input_thread_s * );
258 void (* pf_open)( struct input_thread_s * );
259 void (* pf_close)( struct input_thread_s * );
260 void (* pf_end)( struct input_thread_s * );
261 void (* pf_init_bit_stream)( struct bit_stream_s *,
262 struct decoder_fifo_s *,
263 void (* pf_bitstream_callback)( struct bit_stream_s *,
267 /* Read & Demultiplex */
268 int (* pf_read)( struct input_thread_s *,
269 struct data_packet_s * pp_packets[] );
270 void (* pf_demux)( struct input_thread_s *,
271 struct data_packet_s * );
273 /* Packet management facilities */
274 struct data_packet_s *(*pf_new_packet)( void *, size_t );
275 struct pes_packet_s *(* pf_new_pes)( void * );
276 void (* pf_delete_packet)( void *,
277 struct data_packet_s * );
278 void (* pf_delete_pes)( void *, struct pes_packet_s * );
280 /* Stream control capabilities */
281 int (* pf_set_area)( struct input_thread_s *,
282 struct input_area_s * );
283 int (* pf_rewind)( struct input_thread_s * );
284 /* NULL if we don't support going *
285 * backwards (it's gonna be fun) */
286 void (* pf_seek)( struct input_thread_s *, off_t );
290 int i_handle; /* socket or file descriptor */
291 FILE * p_stream; /* if applicable */
292 void * p_handle; /* if i_handle isn't suitable */
293 int i_read_once; /* number of packet read by
295 void * p_method_data; /* data of the packet manager */
296 void * p_plugin_data; /* data of the plugin */
298 /* General stream description */
299 stream_descriptor_t stream; /* PAT tables */
305 /* The first figure is a general method that can be used in interface plugins ;
306 * The second figure is a detailed sub-method */
307 #define INPUT_METHOD_NONE 0x0 /* input thread is inactive */
308 #define INPUT_METHOD_FILE 0x10 /* stream is read from file p_source */
309 #define INPUT_METHOD_DISC 0x20 /* stream is read directly from disc */
310 #define INPUT_METHOD_DVD 0x21 /* stream is read from DVD */
311 #define INPUT_METHOD_VCD 0x22 /* stream is read from VCD */
312 #define INPUT_METHOD_NETWORK 0x30 /* stream is read from network */
313 #define INPUT_METHOD_UCAST 0x31 /* UDP unicast */
314 #define INPUT_METHOD_MCAST 0x32 /* UDP multicast */
315 #define INPUT_METHOD_BCAST 0x33 /* UDP broadcast */
316 #define INPUT_METHOD_VLAN_BCAST 0x34 /* UDP broadcast with VLANs */
319 /* Status changing methods */
320 #define INPUT_STATUS_END 0
321 #define INPUT_STATUS_PLAY 1
322 #define INPUT_STATUS_PAUSE 2
323 #define INPUT_STATUS_FASTER 3
324 #define INPUT_STATUS_SLOWER 4
326 /*****************************************************************************
328 *****************************************************************************/
329 struct input_thread_s * input_CreateThread ( struct playlist_item_s *,
331 void input_DestroyThread( struct input_thread_s *, int *pi_status );
333 void input_SetStatus( struct input_thread_s *, int );
334 void input_Seek ( struct input_thread_s *, off_t );
335 void input_DumpStream( struct input_thread_s * );
336 char * input_OffsetToTime( struct input_thread_s *, char * psz_buffer, off_t );
337 int input_ChangeES ( struct input_thread_s *, struct es_descriptor_s *, u8 );
338 int input_ToggleES ( struct input_thread_s *,
339 struct es_descriptor_s *,
341 int input_ChangeArea( struct input_thread_s *, struct input_area_s * );
342 int input_ToggleGrayscale( struct input_thread_s * );
343 int input_ToggleMute( struct input_thread_s * );
344 int input_SetSMP( struct input_thread_s *, int );