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