]> git.sesse.net Git - vlc/blob - include/input_ext-intf.h
* mp4: fixed width in tkhd. (at least I hope).
[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$
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 "vlc_block.h"
30 #include "ninput.h"
31
32 /*
33  * Communication input -> interface
34  */
35 /* FIXME ! */
36 #define REQUESTED_MPEG         1
37 #define REQUESTED_A52          2
38 #define REQUESTED_LPCM         3
39 #define REQUESTED_DTS          4
40 #define REQUESTED_NOAUDIO    255
41
42 /*****************************************************************************
43  * es_descriptor_t: elementary stream descriptor
44  *****************************************************************************
45  * Describes an elementary stream, and includes fields required to handle and
46  * demultiplex this elementary stream.
47  *****************************************************************************/
48 struct es_descriptor_t
49 {
50     uint16_t                i_id;            /* stream ID for PS, PID for TS */
51     uint8_t                 i_stream_id;     /* stream ID defined in the PES */
52     vlc_fourcc_t            i_fourcc;                         /* stream type */
53     uint8_t                 i_cat;    /* stream category (audio, video, spu) */
54     int                     i_demux_fd;   /* used to store demux device
55                                              file handle */
56     char                    *psz_desc;    /* description of ES: audio language
57                                            * for instance ; NULL if not
58                                            *  available */
59
60     /* Demultiplexer information */
61     es_sys_t *              p_demux_data;
62     pgrm_descriptor_t *     p_pgrm;  /* very convenient in the demultiplexer */
63
64     /* PES parser information */
65     pes_packet_t *          p_pes;                            /* Current PES */
66     unsigned int            i_pes_real_size;   /* as indicated by the header */
67
68     /* Decoder information */
69     es_format_t             fmt;
70     void *                  p_waveformatex;
71     void *                  p_bitmapinfoheader;
72     void *                  p_spuinfo;
73     /* Decoder */
74     decoder_t *             p_dec;
75
76     count_t                 c_packets;                 /* total packets read */
77     count_t                 c_invalid_packets;       /* invalid packets read */
78
79     /* XXX hack: to force a decoder instead of mode based on sout */
80     vlc_bool_t              b_force_decoder;
81 };
82
83 /*****************************************************************************
84  * pgrm_descriptor_t
85  *****************************************************************************
86  * Describes a program and list associated elementary streams. It is build by
87  * the PSI decoder upon the informations carried in program map sections
88  *****************************************************************************/
89 struct pgrm_descriptor_t
90 {
91     /* Program characteristics */
92     uint16_t                i_number;                      /* program number */
93     uint8_t                 i_version;                     /* version number */
94     vlc_bool_t              b_is_ok;      /* Is the description up to date ? */
95
96     /* Service Descriptor (program name) - DVB extension */
97     uint8_t                 i_srv_type;
98     char *                  psz_srv_name;
99
100     /* Synchronization information */
101     mtime_t                 delta_cr;
102     mtime_t                 cr_ref, sysdate_ref;
103     mtime_t                 last_cr; /* reference to detect unexpected stream
104                                       * discontinuities                      */
105     mtime_t                 last_pts;
106     count_t                 c_average_count;
107                            /* counter used to compute dynamic average values */
108     int                     i_synchro_state;
109
110     /* Demultiplexer data */
111     pgrm_sys_t *            p_demux_data;
112
113     unsigned int            i_es_number;      /* size of the following array */
114     es_descriptor_t **      pp_es;                /* array of pointers to ES */
115 };
116
117 /* Synchro states */
118 #define SYNCHRO_OK          0
119 #define SYNCHRO_START       1
120 #define SYNCHRO_REINIT      2
121
122 /*****************************************************************************
123  * input_area_t
124  *****************************************************************************
125  * Attributes for current area (title for DVD)
126  *****************************************************************************/
127 struct input_area_t
128 {
129     /* selected area attributes */
130     unsigned int            i_id;        /* identificator for area */
131     off_t                   i_start;     /* start offset of area */
132     off_t                   i_size;      /* total size of the area
133                                           * (in arbitrary units) */
134
135     /* navigation parameters */
136     off_t                   i_tell;      /* actual location in the area
137                                           * (in arbitrary units) */
138     off_t                   i_seek;      /* next requested location
139                                           * (changed by the interface thread */
140
141     /* area subdivision */
142     unsigned int            i_part_nb;   /* number of parts (chapter for DVD)*/
143     unsigned int            i_part;      /* currently selected part */
144
145
146     /* offset to plugin related data */
147     off_t                   i_plugin_data;
148 };
149
150 /*****************************************************************************
151  * stream_descriptor_t
152  *****************************************************************************
153  * Describes a stream and list its associated programs. Build upon
154  * the information carried in program association sections (for instance)
155  *****************************************************************************/
156 struct stream_descriptor_t
157 {
158     uint16_t                i_stream_id;                        /* stream id */
159     vlc_bool_t              b_changed;    /* if stream has been changed,
160                                              we have to inform the interface */
161     vlc_mutex_t             stream_lock;  /* to be taken every time you read
162                                            * or modify stream, pgrm or es    */
163
164     /* Input method data */
165     unsigned int            i_method;       /* input method for stream: file,
166                                                disc or network */
167     vlc_bool_t              b_pace_control;    /* can we read when we want ? */
168     vlc_bool_t              b_seekable;               /* can we do lseek() ? */
169
170     /* if (b_seekable) : */
171     unsigned int            i_area_nb;
172     input_area_t **         pp_areas;    /* list of areas in stream == offset
173                                           * interval with own properties */
174     input_area_t *          p_selected_area;
175     input_area_t *          p_new_area;  /* Newly selected area from
176                                           * the interface */
177
178     uint32_t                i_mux_rate; /* the rate we read the stream (in
179                                          * units of 50 bytes/s) ; 0 if undef */
180
181     /* New status and rate requested by the interface */
182     unsigned int            i_new_status, i_new_rate;
183     int                     b_new_mute;          /* int because it can be -1 */
184     vlc_cond_t              stream_wait; /* interface -> input in case of a
185                                           * status change request            */
186     /* Demultiplexer data */
187     void *                  p_demux_data;
188
189     /* Programs descriptions */
190     unsigned int            i_pgrm_number;    /* size of the following array */
191     pgrm_descriptor_t **    pp_programs;        /* array of pointers to pgrm */
192     pgrm_descriptor_t *     p_selected_program;   /* currently
193                                                  selected program */
194     pgrm_descriptor_t *     p_new_program;        /* Newly selected program */
195     /* ES descriptions */
196     unsigned int            i_es_number;
197     es_descriptor_t **      pp_es;             /* carried elementary streams */
198     unsigned int            i_selected_es_number;
199     es_descriptor_t **      pp_selected_es;             /* ES with a decoder */
200     es_descriptor_t *       p_newly_selected_es;   /* ES selected from
201                                                     * the interface */
202     es_descriptor_t *       p_removed_es;   /* ES removed from the interface */
203
204     /* Stream control */
205     stream_ctrl_t           control;
206
207     /* Optional stream output */
208     sout_instance_t *       p_sout;
209
210     /* Statistics */
211     count_t                 c_packets_read;                  /* packets read */
212     count_t                 c_packets_trashed;            /* trashed packets */
213 };
214
215 #define MUTE_NO_CHANGE      -1
216
217 /*****************************************************************************
218  * info_t
219  *****************************************************************************/
220
221 /**
222  * Info item
223  */
224
225 struct info_t
226 {
227     char *psz_name;            /**< Name of this info */
228     char *psz_value;           /**< Value of the info */
229 };
230
231 /**
232  * Info category
233  * \see info_t
234  */
235 struct info_category_t
236 {
237     char   *psz_name;      /**< Name of this category */
238     int    i_infos;        /**< Number of infos in the category */
239     struct info_t **pp_infos;     /**< Pointer to an array of infos */
240 };
241
242 /*****************************************************************************
243  * input_item_t
244  *****************************************************************************
245  * Describes an input and is used to spawn input_thread_t objects.
246  *****************************************************************************/
247 struct input_item_t
248 {
249     char       *psz_name;            /**< text describing this item */
250     char       *psz_uri;             /**< mrl of this item */
251
252     int        i_options;            /**< Number of input options */
253     char       **ppsz_options;       /**< Array of input options */
254
255     mtime_t    i_duration;           /**< A hint about the duration of this
256                                       * item, in milliseconds*/
257
258     int        i_categories;         /**< Number of info categories */
259     info_category_t **pp_categories; /**< Pointer to the first info category */
260
261     vlc_mutex_t lock;                /**< Item cannot be changed without this lock */
262 };
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     vlc_bool_t              b_out_pace_control;
276
277     /* Access module */
278     module_t *       p_access;
279     ssize_t       (* pf_read ) ( input_thread_t *, byte_t *, size_t );
280     int           (* pf_set_program )( input_thread_t *, pgrm_descriptor_t * );
281     int           (* pf_set_area )( input_thread_t *, input_area_t * );
282     void          (* pf_seek ) ( input_thread_t *, off_t );
283     int           (* pf_access_control )( input_thread_t *, int, va_list );
284     access_sys_t *   p_access_data;
285     size_t           i_mtu;
286     int              i_pts_delay;                        /* internal caching */
287     int              i_cr_average;
288
289     /* Stream */
290     stream_t        *s;
291
292     /* Demux module */
293     module_t *       p_demux;
294     int           (* pf_demux )  ( input_thread_t * );
295     int           (* pf_rewind ) ( input_thread_t * );
296                                            /* NULL if we don't support going *
297                                             * backwards (it's gonna be fun)  */
298     int           (* pf_demux_control ) ( input_thread_t *, int, va_list );
299     demux_sys_t *    p_demux_data;                      /* data of the demux */
300
301     /* es out */
302     es_out_t        *p_es_out;
303
304     /* Buffer manager */
305     input_buffers_t *p_method_data;     /* data of the packet manager */
306     data_buffer_t *  p_data_buffer;
307     byte_t *         p_current_data;
308     byte_t *         p_last_data;
309     size_t           i_bufsize;
310
311     /* General stream description */
312     stream_descriptor_t     stream;
313
314     /* Input item description */
315     input_item_t *p_item;
316
317     /* Playlist item */
318     char *  psz_source;
319     char *  psz_dupsource;
320     char *  psz_access;
321     char *  psz_demux;
322     char *  psz_name;
323
324     count_t c_loops;
325
326     /* User bookmarks */
327     int         i_bookmarks;
328     seekpoint_t **pp_bookmarks;
329
330     /* private, do not touch it */
331     input_thread_sys_t  *p_sys;
332 };
333
334 /* Input methods */
335 /* The first figure is a general method that can be used in interface plugins ;
336  * The second figure is a detailed sub-method */
337 #define INPUT_METHOD_NONE         0x0            /* input thread is inactive */
338 #define INPUT_METHOD_FILE        0x10   /* stream is read from file p_source */
339 #define INPUT_METHOD_DISC        0x20   /* stream is read directly from disc */
340 #define INPUT_METHOD_DVD         0x21             /* stream is read from DVD */
341 #define INPUT_METHOD_VCD         0x22             /* stream is read from VCD */
342 #define INPUT_METHOD_CDDA        0x23            /* stream is read from CDDA */
343 #define INPUT_METHOD_NETWORK     0x30         /* stream is read from network */
344 #define INPUT_METHOD_UCAST       0x31                         /* UDP unicast */
345 #define INPUT_METHOD_MCAST       0x32                       /* UDP multicast */
346 #define INPUT_METHOD_BCAST       0x33                       /* UDP broadcast */
347 #define INPUT_METHOD_VLAN_BCAST  0x34            /* UDP broadcast with VLANs */
348 #define INPUT_METHOD_SATELLITE   0x40               /* stream is read from a */
349                                                            /* satellite card */
350 #define INPUT_METHOD_SLP         0x50                          /* SLP stream */
351
352 /*****************************************************************************
353  * Prototypes
354  *****************************************************************************/
355 #define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
356 VLC_EXPORT( input_thread_t *, __input_CreateThread, ( vlc_object_t *, input_item_t * ) );
357 VLC_EXPORT( void,             input_StopThread,     ( input_thread_t * ) );
358 VLC_EXPORT( void,             input_DestroyThread,  ( input_thread_t * ) );
359
360 #endif /* "input_ext-intf.h" */