]> git.sesse.net Git - vlc/blob - include/input_ext-intf.h
d2253f52cd2b50caada0eb5173d19ad161fdc227
[vlc] / include / input_ext-intf.h
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.72 2002/07/23 00:39:16 sam Exp $
8  *
9  * Authors: Christophe Massiot <massiot@via.ecp.fr>
10  *
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.
15  * 
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.
20  *
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  *****************************************************************************/
25
26 #ifndef _VLC_INPUT_EXT_INTF_H
27 #define _VLC_INPUT_EXT_INTF_H 1
28
29 /*
30  * Communication input -> interface
31  */
32 /* FIXME ! */
33 #define REQUESTED_MPEG         1
34 #define REQUESTED_AC3          2
35 #define REQUESTED_LPCM         3
36 #define REQUESTED_NOAUDIO    255
37
38 #define OFFSETTOTIME_MAX_SIZE       10
39
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
47 {
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
53                                              file handle */
54     char                    psz_desc[20]; /* description of ES: audio language
55                                            * for instance ; NULL if not
56                                            *  available */
57
58     /* Demultiplexer information */
59     void *                  p_demux_data;
60     pgrm_descriptor_t *     p_pgrm;  /* very convenient in the demultiplexer */
61
62     /* PES parser information */
63     pes_packet_t *          p_pes;                            /* Current PES */
64     int                     i_pes_real_size;   /* as indicated by the header */
65
66     /* Decoder information */
67     decoder_fifo_t *        p_decoder_fifo;
68     vlc_thread_t            thread_id;                  /* ID of the decoder */
69
70     count_t                 c_packets;                 /* total packets read */
71     count_t                 c_invalid_packets;       /* invalid packets read */
72
73     /* Module properties */
74     module_t *              p_module;
75 };
76
77 /* Special PID values - note that the PID is only on 13 bits, and that values
78  * greater than 0x1fff have no meaning in a stream */
79 #define PROGRAM_ASSOCIATION_TABLE_PID   0x0000
80 #define CONDITIONNAL_ACCESS_TABLE_PID   0x0001                   /* not used */
81 #define EMPTY_ID                        0xffff    /* empty record in a table */
82  
83
84 /* ES Categories to be used by interface plugins */
85 #define UNKNOWN_ES      0x00
86 #define VIDEO_ES        0x01
87 #define AUDIO_ES        0x02
88 #define SPU_ES          0x03
89 #define NAV_ES          0x04
90
91 /*****************************************************************************
92  * pgrm_descriptor_t
93  *****************************************************************************
94  * Describes a program and list associated elementary streams. It is build by
95  * the PSI decoder upon the informations carried in program map sections
96  *****************************************************************************/
97 struct pgrm_descriptor_t
98 {
99     /* Program characteristics */
100     u16                     i_number;                      /* program number */
101     u8                      i_version;                     /* version number */
102     vlc_bool_t              b_is_ok;      /* Is the description up to date ? */
103
104     /* Service Descriptor (program name) - DVB extension */
105     u8                      i_srv_type;
106     char *                  psz_srv_name;
107
108     /* Synchronization information */
109     mtime_t                 delta_cr;
110     mtime_t                 cr_ref, sysdate_ref;
111     mtime_t                 last_cr; /* reference to detect unexpected stream
112                                       * discontinuities                      */
113     mtime_t                 last_syscr;
114     count_t                 c_average_count;
115                            /* counter used to compute dynamic average values */
116     int                     i_synchro_state;
117
118     /* Demultiplexer data */
119     void *                  p_demux_data;
120
121     int                     i_es_number;      /* size of the following array */
122     es_descriptor_t **      pp_es;                /* array of pointers to ES */
123 };
124
125 /* Synchro states */
126 #define SYNCHRO_OK          0
127 #define SYNCHRO_START       1
128 #define SYNCHRO_REINIT      2
129
130 /*****************************************************************************
131  * input_area_t
132  *****************************************************************************
133  * Attributes for current area (title for DVD)
134  *****************************************************************************/
135 struct input_area_t
136 {
137     /* selected area attributes */
138     int                     i_id;        /* identificator for area */
139     off_t                   i_start;     /* start offset of area */
140     off_t                   i_size;      /* total size of the area
141                                           * (in arbitrary units) */
142
143     /* navigation parameters */
144     off_t                   i_tell;      /* actual location in the area
145                                           * (in arbitrary units) */
146     off_t                   i_seek;      /* next requested location
147                                           * (changed by the interface thread */
148
149     /* area subdivision */
150     int                     i_part_nb;   /* number of parts (chapter for DVD)*/
151     int                     i_part;      /* currently selected part */
152
153
154     /* offset to plugin related data */
155     off_t                   i_plugin_data;
156 };
157
158 /*****************************************************************************
159  * input_info_t
160  *****************************************************************************
161  * Composes a linked list of name/value pairs intended to inform the
162  * user about the current stream
163  *****************************************************************************/
164 struct input_info_t {
165   char *         psz_name;
166   char *         psz_value;
167   input_info_t * p_next;
168 };
169
170 /*****************************************************************************
171  * input_info_category_t
172  *****************************************************************************
173  * Composes a linked list of categories in which to place info about
174  * the stream.
175  *****************************************************************************/
176 struct input_info_category_t {
177   char *                  psz_name;
178   input_info_t *          p_info;
179   input_info_category_t * p_next;
180 };
181
182 /*****************************************************************************
183 * stream_descriptor_t
184  *****************************************************************************
185  * Describes a stream and list its associated programs. Build upon
186  * the information carried in program association sections (for instance)
187  *****************************************************************************/
188 struct stream_descriptor_t
189 {
190     u16                     i_stream_id;                        /* stream id */
191     vlc_bool_t              b_changed;    /* if stream has been changed,
192                                              we have to inform the interface */
193     vlc_mutex_t             stream_lock;  /* to be taken every time you read
194                                            * or modify stream, pgrm or es    */
195
196     /* Input method data */
197     int                     i_method;       /* input method for stream: file,
198                                                disc or network */
199     vlc_bool_t              b_pace_control;    /* can we read when we want ? */
200     vlc_bool_t              b_seekable;               /* can we do lseek() ? */
201
202     /* if (b_seekable) : */
203     int                     i_area_nb;
204     input_area_t **         pp_areas;    /* list of areas in stream == offset
205                                           * interval with own properties */
206     input_area_t *          p_selected_area;
207     input_area_t *          p_new_area;  /* Newly selected area from
208                                           * the interface */
209
210     u32                     i_mux_rate; /* the rate we read the stream (in
211                                          * units of 50 bytes/s) ; 0 if undef */
212
213     /* New status and rate requested by the interface */
214     int                     i_new_status, i_new_rate;
215     int                     b_new_mute;          /* int because it can be -1 */
216     vlc_cond_t              stream_wait; /* interface -> input in case of a
217                                           * status change request            */
218
219     /* Demultiplexer data */
220     void *                  p_demux_data;
221
222     /* Programs descriptions */
223     int                     i_pgrm_number;    /* size of the following array */
224     pgrm_descriptor_t **    pp_programs;        /* array of pointers to pgrm */
225     pgrm_descriptor_t *     p_selected_program;   /* currently 
226                                                  selected program */
227     pgrm_descriptor_t *     p_new_program;        /* Newly selected program */
228     /* ES descriptions */
229     int                     i_es_number;
230     es_descriptor_t **      pp_es;             /* carried elementary streams */
231     int                     i_selected_es_number;
232     es_descriptor_t **      pp_selected_es;             /* ES with a decoder */
233     es_descriptor_t *       p_newly_selected_es;   /* ES selected from
234                                                     * the interface */
235     es_descriptor_t *       p_removed_es;   /* ES removed from the interface */
236     
237     /* Stream control */
238     stream_ctrl_t           control;
239
240     /* Input info */
241     input_info_category_t * p_info;
242     
243     /* Statistics */
244     count_t                 c_packets_read;                  /* packets read */
245     count_t                 c_packets_trashed;            /* trashed packets */
246 };
247
248 /*****************************************************************************
249  * stream_position_t
250  *****************************************************************************
251  * Describes the current position in the stream.
252  *****************************************************************************/
253 struct stream_position_t
254 {
255     off_t    i_tell;     /* actual location in the area (in arbitrary units) */
256     off_t    i_size;          /* total size of the area (in arbitrary units) */
257
258     u32      i_mux_rate;                /* the rate we read the stream (in
259                                          * units of 50 bytes/s) ; 0 if undef */
260 };
261
262 #define MUTE_NO_CHANGE      -1
263
264 /*****************************************************************************
265  * input_thread_t
266  *****************************************************************************
267  * This structure includes all the local static variables of an input thread
268  *****************************************************************************/
269 struct input_thread_t
270 {
271     VLC_COMMON_MEMBERS
272
273     /* Thread properties */
274     vlc_bool_t              b_eof;
275
276     /* Access module */
277     module_t *       p_access_module;
278     int           (* pf_open ) ( input_thread_t * );
279     void          (* pf_close )( input_thread_t * );
280     ssize_t       (* pf_read ) ( input_thread_t *, byte_t *, size_t );
281     int           (* pf_set_program )( input_thread_t *, pgrm_descriptor_t * );
282     int           (* pf_set_area )( input_thread_t *, input_area_t * );
283     void          (* pf_seek ) ( input_thread_t *, off_t );
284     void *           p_access_data;
285     size_t           i_mtu;
286
287     /* Demux module */
288     module_t *       p_demux_module;
289     int           (* pf_init )   ( input_thread_t * );
290     void          (* pf_end )    ( input_thread_t * );
291     int           (* pf_demux )  ( input_thread_t * );
292     int           (* pf_rewind ) ( input_thread_t * );
293                                            /* NULL if we don't support going *
294                                             * backwards (it's gonna be fun)  */
295     void *           p_demux_data;                      /* data of the demux */
296
297     /* Buffer manager */
298     input_buffers_t *p_method_data;     /* data of the packet manager */
299     data_buffer_t *  p_data_buffer;
300     byte_t *         p_current_data;
301     byte_t *         p_last_data;
302     size_t           i_bufsize;
303
304     /* General stream description */
305     stream_descriptor_t     stream;
306
307     /* Playlist item */
308     char *  psz_source;
309     char *  psz_access;
310     char *  psz_demux;
311     char *  psz_name;
312
313     count_t c_loops;
314 };
315
316 /* Input methods */
317 /* The first figure is a general method that can be used in interface plugins ;
318  * The second figure is a detailed sub-method */
319 #define INPUT_METHOD_NONE         0x0            /* input thread is inactive */
320 #define INPUT_METHOD_FILE        0x10   /* stream is read from file p_source */
321 #define INPUT_METHOD_DISC        0x20   /* stream is read directly from disc */
322 #define INPUT_METHOD_DVD         0x21             /* stream is read from DVD */
323 #define INPUT_METHOD_VCD         0x22             /* stream is read from VCD */
324 #define INPUT_METHOD_NETWORK     0x30         /* stream is read from network */
325 #define INPUT_METHOD_UCAST       0x31                         /* UDP unicast */
326 #define INPUT_METHOD_MCAST       0x32                       /* UDP multicast */
327 #define INPUT_METHOD_BCAST       0x33                       /* UDP broadcast */
328 #define INPUT_METHOD_VLAN_BCAST  0x34            /* UDP broadcast with VLANs */
329 #define INPUT_METHOD_SATELLITE   0x40               /* stream is read from a */
330                                                            /* satellite card */
331
332 /* Status changing methods */
333 #define INPUT_STATUS_END            0
334 #define INPUT_STATUS_PLAY           1
335 #define INPUT_STATUS_PAUSE          2
336 #define INPUT_STATUS_FASTER         3
337 #define INPUT_STATUS_SLOWER         4
338
339 /* Seek modes */
340 #define INPUT_SEEK_SET       0x00
341 #define INPUT_SEEK_CUR       0x01
342 #define INPUT_SEEK_END       0x02
343 #define INPUT_SEEK_BYTES     0x00
344 #define INPUT_SEEK_SECONDS   0x10
345 #define INPUT_SEEK_PERCENT   0x20
346
347 /*****************************************************************************
348  * Prototypes
349  *****************************************************************************/
350 #define input_CreateThread(a,b,c) __input_CreateThread(CAST_TO_VLC_OBJECT(a),b,c)
351 input_thread_t * __input_CreateThread ( vlc_object_t *,
352                                         playlist_item_t *, int * );
353 void   input_StopThread     ( input_thread_t * );
354 void   input_DestroyThread  ( input_thread_t * );
355
356 #define input_SetStatus(a,b) __input_SetStatus(CAST_TO_VLC_OBJECT(a),b)
357 VLC_EXPORT( void, __input_SetStatus, ( vlc_object_t *, int ) );
358
359 #define input_Seek(a,b,c) __input_Seek(CAST_TO_VLC_OBJECT(a),b,c)
360 VLC_EXPORT( void, __input_Seek, ( vlc_object_t *, off_t, int ) );
361
362 #define input_Tell(a,b) __input_Tell(CAST_TO_VLC_OBJECT(a),b)
363 VLC_EXPORT( void, __input_Tell, ( vlc_object_t *, stream_position_t * ) );
364
365 VLC_EXPORT( void, input_DumpStream, ( input_thread_t * ) );
366 VLC_EXPORT( char *, input_OffsetToTime, ( input_thread_t *, char *, off_t ) );
367 VLC_EXPORT( int, input_ToggleES, ( input_thread_t *, es_descriptor_t *, vlc_bool_t ) );
368 VLC_EXPORT( int, input_ChangeArea, ( input_thread_t *, input_area_t * ) );
369 VLC_EXPORT( int, input_ChangeProgram, ( input_thread_t *, u16 ) );
370
371 int    input_ToggleGrayscale( input_thread_t * );
372 int    input_ToggleMute     ( input_thread_t * );
373 int    input_SetSMP         ( input_thread_t *, int );
374
375 #endif /* "input_ext-intf.h" */