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