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.22 2001/02/19 19:08:59 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 *****************************************************************************/
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 /*****************************************************************************
37 * es_descriptor_t: elementary stream descriptor
38 *****************************************************************************
39 * Describes an elementary stream, and includes fields required to handle and
40 * demultiplex this elementary stream.
41 *****************************************************************************/
42 struct decoder_fifo_s; /* defined in input_ext-dec.h */
43 struct pgrm_descriptor_s;
45 typedef struct es_descriptor_s
47 u16 i_id; /* stream ID for PS, PID for TS */
48 u8 i_stream_id; /* stream ID defined in the PES */
49 u8 i_type; /* stream type */
50 boolean_t b_audio; /* is the stream an audio stream that
51 * will need to be discarded with
52 * fast forward and slow motion ? */
54 /* Demultiplexer information */
56 struct pgrm_descriptor_s *
57 p_pgrm; /* very convenient in the demultiplexer */
59 /* PES parser information */
60 struct pes_packet_s * p_pes; /* Current PES */
61 struct data_packet_s * p_last; /* The last packet gathered at present */
62 int i_pes_real_size; /* as indicated by the header */
64 /* Decoder information */
65 struct decoder_fifo_s * p_decoder_fifo;
66 vlc_thread_t thread_id; /* ID of the decoder */
69 count_t c_payload_bytes;/* total of payload useful bytes */
70 count_t c_packets; /* total packets read */
71 count_t c_invalid_packets; /* invalid packets read */
75 /* Special PID values - note that the PID is only on 13 bits, and that values
76 * greater than 0x1fff have no meaning in a stream */
77 #define PROGRAM_ASSOCIATION_TABLE_PID 0x0000
78 #define CONDITIONNAL_ACCESS_TABLE_PID 0x0001 /* not used */
79 #define EMPTY_ID 0xffff /* empty record in a table */
81 /* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers */
82 #define MPEG1_VIDEO_ES 0x01
83 #define MPEG2_VIDEO_ES 0x02
84 #define MPEG1_AUDIO_ES 0x03
85 #define MPEG2_AUDIO_ES 0x04
86 #define AC3_AUDIO_ES 0x81
87 /* These ones might violate the norm : */
88 #define DVD_SPU_ES 0x82
89 #define LPCM_AUDIO_ES 0x83
90 #define UNKNOWN_ES 0xFF
92 /*****************************************************************************
94 *****************************************************************************
95 * Describes a program and list associated elementary streams. It is build by
96 * the PSI decoder upon the informations carried in program map sections
97 *****************************************************************************/
98 typedef struct pgrm_descriptor_s
100 /* Program characteristics */
101 u16 i_number; /* program number */
102 u8 i_version; /* version number */
103 boolean_t b_is_ok; /* Is the description up to date ? */
105 /* Service Descriptor (program name) - DVB extension */
109 /* Synchronization information */
111 mtime_t cr_ref, sysdate_ref;
112 mtime_t last_cr; /* reference to detect unexpected stream
114 count_t c_average_count;
115 /* counter used to compute dynamic average values */
118 /* Demultiplexer data */
121 /* Decoders control */
122 struct vout_thread_s * p_vout;
123 struct aout_thread_s * p_aout;
125 int i_es_number; /* size of the following array */
126 es_descriptor_t ** pp_es; /* array of pointers to ES */
131 #define SYNCHRO_START 1
132 #define SYNCHRO_REINIT 2
134 /*****************************************************************************
135 * stream_descriptor_t
136 *****************************************************************************
137 * Describes a stream and list its associated programs. Build upon
138 * the information carried in program association sections (for instance)
139 *****************************************************************************/
140 typedef struct stream_descriptor_s
142 u16 i_stream_id; /* stream id */
143 vlc_mutex_t stream_lock; /* to be taken every time you read
144 * or modify stream, pgrm or es */
146 /* Input method data */
147 boolean_t b_pace_control; /* can we read when we want ? */
148 boolean_t b_seekable; /* can we do lseek() ? */
149 /* if (b_seekable) : */
150 off_t i_size; /* total size of the file
151 * (in arbitrary units) */
152 off_t i_tell; /* actual location in the file
153 * (in arbitrary units) */
154 off_t i_seek; /* next requested location (changed
155 * by the interface thread */
156 u32 i_mux_rate; /* the rate we read the stream (in
157 * units of 50 bytes/s) ; 0 if undef */
159 /* For DVD streams: */
161 int * pi_chapter; /* Number of chapter for each title */
162 char ** ppsz_audio; /* Audio language names */
163 char ** ppsz_spu; /* Sub-pictures names */
164 int i_title; /* selected title */
165 int i_chapter; /* selected chapter */
166 int i_audio; /* selected audio stream */
167 int i_spu; /* selected spu */
169 /* New status and rate requested by the interface */
170 int i_new_status, i_new_rate;
171 vlc_cond_t stream_wait; /* interface -> input in case of a
172 * status change request */
174 /* Demultiplexer data */
177 /* Programs descriptions */
178 int i_pgrm_number; /* size of the following array */
179 pgrm_descriptor_t ** pp_programs; /* array of pointers to pgrm */
181 /* ES descriptions */
183 es_descriptor_t ** pp_es; /* carried elementary streams */
184 int i_selected_es_number;
185 es_descriptor_t ** pp_selected_es; /* ES with a decoder */
188 stream_ctrl_t control;
189 } stream_descriptor_t;
191 /*****************************************************************************
193 *****************************************************************************
194 * This structure gives plugins pointers to the useful functions of input
195 *****************************************************************************/
196 struct input_thread_s;
197 struct data_packet_s;
198 struct es_descriptor_s;
200 typedef struct i_p_config_s
202 int (* pf_peek_stream)( struct input_thread_s *,
203 byte_t * buffer, size_t );
204 void (* pf_demux_pes)( struct input_thread_s *,
205 struct data_packet_s *,
206 struct es_descriptor_s *,
207 boolean_t b_unit_start,
208 boolean_t b_packet_lost );
211 /*****************************************************************************
213 *****************************************************************************
214 * This structure includes all the local static variables of an input thread
215 *****************************************************************************/
216 struct aout_thread_s;
217 struct vout_thread_s;
219 typedef struct input_thread_s
221 /* Thread properties and locks */
222 boolean_t b_die; /* 'die' flag */
225 vlc_thread_t thread_id; /* id for thread functions */
226 int * pi_status; /* temporary status flag */
229 struct module_s * p_input_module;
232 void (* pf_init)( struct input_thread_s * );
233 void (* pf_open)( struct input_thread_s * );
234 void (* pf_close)( struct input_thread_s * );
235 void (* pf_end)( struct input_thread_s * );
237 /* Read & Demultiplex */
238 int (* pf_read)( struct input_thread_s *,
239 struct data_packet_s * pp_packets[] );
240 void (* pf_demux)( struct input_thread_s *,
241 struct data_packet_s * );
243 /* Packet management facilities */
244 struct data_packet_s *(*pf_new_packet)( void *, size_t );
245 struct pes_packet_s *(* pf_new_pes)( void * );
246 void (* pf_delete_packet)( void *,
247 struct data_packet_s * );
248 void (* pf_delete_pes)( void *, struct pes_packet_s * );
250 /* Stream control capabilities */
251 int (* pf_rewind)( struct input_thread_s * );
252 /* NULL if we don't support going *
253 * backwards (it's gonna be fun) */
254 void (* pf_seek)( struct input_thread_s *, off_t );
256 i_p_config_t i_p_config; /* plugin configuration */
259 int i_handle; /* socket or file descriptor */
260 void * p_method_data; /* data of the packet manager */
261 void * p_plugin_data; /* data of the plugin */
263 /* General stream description */
264 stream_descriptor_t stream; /* PAT tables */
266 /* For auto-launch of decoders */
267 struct aout_thread_s * p_default_aout;
268 struct vout_thread_s * p_default_vout;
272 count_t c_bytes; /* bytes read */
273 count_t c_payload_bytes; /* payload useful bytes */
274 count_t c_packets_read; /* packets read */
275 count_t c_packets_trashed; /* trashed packets */
281 * Communication interface -> input
284 /*****************************************************************************
286 *****************************************************************************
287 * This structure is given by the interface to an input thread
288 *****************************************************************************/
289 typedef struct input_config_s
291 /* Input method description */
292 int i_method; /* input method */
293 char * p_source; /* source */
295 /* For auto-launch of decoders */
296 struct aout_thread_s * p_default_aout;
297 struct vout_thread_s * p_default_vout;
301 #define INPUT_METHOD_NONE 0 /* input thread is inactive */
302 #define INPUT_METHOD_FILE 10 /* stream is read from file p_source */
303 #define INPUT_METHOD_DVD 11 /* stream is read from dvd device */
304 #define INPUT_METHOD_UCAST 20 /* UDP unicast */
305 #define INPUT_METHOD_MCAST 21 /* UDP multicast */
306 #define INPUT_METHOD_BCAST 22 /* UDP broadcast */
307 #define INPUT_METHOD_VLAN_BCAST 32 /* UDP broadcast with VLANs */
309 /* Status changing methods */
310 #define INPUT_STATUS_END 0
311 #define INPUT_STATUS_PLAY 1
312 #define INPUT_STATUS_PAUSE 2
313 #define INPUT_STATUS_FASTER 3
314 #define INPUT_STATUS_SLOWER 4
316 /*****************************************************************************
318 *****************************************************************************/
319 struct input_thread_s * input_CreateThread ( struct playlist_item_s *,
321 void input_DestroyThread( struct input_thread_s *, int *pi_status );
323 void input_SetStatus( struct input_thread_s *, int );
324 void input_SetRate ( struct input_thread_s *, int );
325 void input_Seek ( struct input_thread_s *, off_t );