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