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.4 2000/12/20 16:04:31 massiot Exp $
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 /*****************************************************************************
32 * es_descriptor_t: elementary stream descriptor
33 *****************************************************************************
34 * Describes an elementary stream, and includes fields required to handle and
35 * demultiplex this elementary stream.
36 *****************************************************************************/
37 struct decoder_fifo_s; /* defined in input_ext-dec.h */
38 struct pgrm_descriptor_s;
40 typedef struct es_descriptor_s
42 u16 i_id; /* stream ID for PS, PID for TS */
43 u8 i_stream_id; /* stream ID defined in the PES */
44 u8 i_type; /* stream type */
46 /* Demultiplexer information */
48 struct pgrm_descriptor_s *
49 p_pgrm; /* very convenient in the demultiplexer */
51 /* PES parser information */
52 struct pes_packet_s * p_pes; /* Current PES */
53 struct data_packet_s * p_last; /* The last packet gathered at present */
54 int i_pes_real_size; /* as indicated by the header */
55 boolean_t b_discontinuity; /* Stream changed */
57 /* Decoder information */
58 struct decoder_fifo_s * p_decoder_fifo;
59 vlc_thread_t thread_id; /* ID of the decoder */
62 count_t c_payload_bytes;/* total of payload useful bytes */
63 count_t c_packets; /* total packets read */
64 count_t c_invalid_packets; /* invalid packets read */
68 /* Special PID values - note that the PID is only on 13 bits, and that values
69 * greater than 0x1fff have no meaning in a stream */
70 #define PROGRAM_ASSOCIATION_TABLE_PID 0x0000
71 #define CONDITIONNAL_ACCESS_TABLE_PID 0x0001 /* not used */
72 #define EMPTY_ID 0xffff /* empty record in a table */
74 /* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers */
75 #define MPEG1_VIDEO_ES 0x01
76 #define MPEG2_VIDEO_ES 0x02
77 #define MPEG1_AUDIO_ES 0x03
78 #define MPEG2_AUDIO_ES 0x04
79 #define AC3_AUDIO_ES 0x81
80 /* These ones might violate the norm : */
81 #define DVD_SPU_ES 0x82
82 #define LPCM_AUDIO_ES 0x83
83 #define UNKNOWN_ES 0xFF
85 /*****************************************************************************
87 *****************************************************************************
88 * Describes a program and list associated elementary streams. It is build by
89 * the PSI decoder upon the informations carried in program map sections
90 *****************************************************************************/
91 typedef struct pgrm_descriptor_s
93 /* Program characteristics */
94 u16 i_number; /* program number */
95 u8 i_version; /* version number */
96 boolean_t b_is_ok; /* Is the description up to date ? */
98 /* Service Descriptor (program name) - DVB extension */
102 /* Synchronization information */
103 /* system_date = PTS_date + delta_cr + delta_absolute */
105 mtime_t delta_absolute;
107 count_t c_average_count;
108 /* counter used to compute dynamic average values */
110 boolean_t b_discontinuity;
112 /* Demultiplexer data */
115 /* Decoders control */
116 struct vout_thread_s * p_vout;
117 struct aout_thread_s * p_aout;
119 int i_es_number; /* size of the following array */
120 es_descriptor_t ** pp_es; /* array of pointers to ES */
125 #define SYNCHRO_NOT_STARTED 1
126 #define SYNCHRO_START 2
127 #define SYNCHRO_REINIT 3
129 /*****************************************************************************
130 * stream_descriptor_t
131 *****************************************************************************
132 * Describes a stream and list its associated programs. Build upon
133 * the information carried in program association sections (for instance)
134 *****************************************************************************/
135 typedef struct stream_descriptor_s
137 u16 i_stream_id; /* stream id */
138 vlc_mutex_t stream_lock; /* to be taken every time you read
139 * or modify stream, pgrm or es */
141 /* Input method data */
142 boolean_t b_pace_control; /* can we read when we want ? */
143 boolean_t b_seekable; /* can we do lseek() ? */
144 /* if (b_seekable) : */
145 off_t i_size; /* total size of the file (in bytes) */
146 off_t i_tell;/* actual location in the file (in bytes) */
148 /* Demultiplexer data */
151 /* Programs description */
152 int i_pgrm_number; /* size of the following array */
153 pgrm_descriptor_t ** pp_programs; /* array of pointers to pgrm */
156 stream_ctrl_t control;
157 } stream_descriptor_t;
159 /*****************************************************************************
161 *****************************************************************************
162 * This structure gives plugins pointers to the useful functions of input
163 *****************************************************************************/
164 struct input_thread_s;
165 struct data_packet_s;
166 struct es_descriptor_s;
168 typedef struct i_p_config_s
170 int (* pf_peek_stream)( struct input_thread_s *,
171 byte_t * buffer, size_t );
172 void (* pf_demux_pes)( struct input_thread_s *,
173 struct data_packet_s *,
174 struct es_descriptor_s *,
175 boolean_t b_unit_start,
176 boolean_t b_packet_lost );
179 /*****************************************************************************
181 *****************************************************************************
182 * This structure includes all the local static variables of an input thread
183 *****************************************************************************/
184 struct aout_thread_s;
185 struct vout_thread_s;
187 typedef struct input_thread_s
189 /* Thread properties and locks */
190 boolean_t b_die; /* 'die' flag */
192 vlc_thread_t thread_id; /* id for thread functions */
193 int * pi_status; /* temporary status flag */
195 struct input_config_s * p_config;
197 struct input_capabilities_s *
198 pp_plugins[INPUT_MAX_PLUGINS];/* list of plugins */
199 struct input_capabilities_s *
200 p_plugin; /* selected plugin */
201 i_p_config_t i_p_config; /* plugin configuration */
203 int i_handle; /* socket or file descriptor */
204 void * p_method_data;
206 /* General stream description */
207 stream_descriptor_t stream; /* PAT tables */
208 es_descriptor_t p_es[INPUT_MAX_ES];
209 /* carried elementary streams */
211 /* List of streams to demux */
212 es_descriptor_t * pp_selected_es[INPUT_MAX_SELECTED_ES];
214 /* For auto-launch of decoders */
215 struct aout_thread_s * p_default_aout;
216 struct vout_thread_s * p_default_vout;
220 count_t c_bytes; /* bytes read */
221 count_t c_payload_bytes; /* payload useful bytes */
222 count_t c_packets_read; /* packets read */
223 count_t c_packets_trashed; /* trashed packets */
229 * Communication interface -> input
232 /*****************************************************************************
234 *****************************************************************************
235 * This structure is given by the interface to an input thread
236 *****************************************************************************/
237 typedef struct input_config_s
239 /* Input method description */
240 int i_method; /* input method */
241 char * p_source; /* source */
243 /* For auto-launch of decoders */
244 struct aout_thread_s * p_default_aout;
245 struct vout_thread_s * p_default_vout;
249 #define INPUT_METHOD_NONE 0 /* input thread is inactive */
250 #define INPUT_METHOD_FILE 10 /* stream is read from file p_source */
251 #define INPUT_METHOD_UCAST 20 /* UDP unicast */
252 #define INPUT_METHOD_MCAST 21 /* UDP multicast */
253 #define INPUT_METHOD_BCAST 22 /* UDP broadcast */
254 #define INPUT_METHOD_VLAN_BCAST 32 /* UDP broadcast with VLANs */
256 /*****************************************************************************
258 *****************************************************************************/
259 struct input_thread_s * input_CreateThread( struct input_config_s *,
261 void input_DestroyThread( struct input_thread_s *,
263 void input_PauseProgram( struct input_thread_s *,
264 struct pgrm_descriptor_s * );
265 void input_PlayProgram( struct input_thread_s *,
266 struct pgrm_descriptor_s * );
267 void input_FFProgram( struct input_thread_s *,
268 struct pgrm_descriptor_s * );
269 void input_SMProgram( struct input_thread_s *,
270 struct pgrm_descriptor_s * );
271 void input_RewindProgram( struct input_thread_s *,
272 struct pgrm_descriptor_s * );