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