]> git.sesse.net Git - vlc/blob - include/input_ext-intf.h
7e1edd9b855cef91ecbe67c874c5b5df535f41c8
[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.82 2002/12/31 01:54:35 massiot 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_NOAUDIO    255
37
38 #define OFFSETTOTIME_MAX_SIZE       10
39
40 /*****************************************************************************
41  * es_descriptor_t: elementary stream descriptor
42  *****************************************************************************
43  * Describes an elementary stream, and includes fields required to handle and
44  * demultiplex this elementary stream.
45  *****************************************************************************/
46 struct es_descriptor_t
47 {
48     uint16_t                i_id;            /* stream ID for PS, PID for TS */
49     uint8_t                 i_stream_id;     /* stream ID defined in the PES */
50     vlc_fourcc_t            i_fourcc;                         /* stream type */
51     uint8_t                 i_cat;    /* stream category (audio, video, spu) */
52     int                     i_demux_fd;   /* used to store demux device
53                                              file handle */
54     char                    psz_desc[20]; /* description of ES: audio language
55                                            * for instance ; NULL if not
56                                            *  available */
57
58     /* Demultiplexer information */
59     es_sys_t *              p_demux_data;
60     pgrm_descriptor_t *     p_pgrm;  /* very convenient in the demultiplexer */
61
62     /* PES parser information */
63     pes_packet_t *          p_pes;                            /* Current PES */
64     unsigned int            i_pes_real_size;   /* as indicated by the header */
65
66     /* Decoder information */
67     decoder_fifo_t *        p_decoder_fifo;
68
69     count_t                 c_packets;                 /* total packets read */
70     count_t                 c_invalid_packets;       /* invalid packets read */
71 };
72
73 /* Special PID values - note that the PID is only on 13 bits, and that values
74  * greater than 0x1fff have no meaning in a stream */
75 #define PROGRAM_ASSOCIATION_TABLE_PID   0x0000
76 #define CONDITIONNAL_ACCESS_TABLE_PID   0x0001                   /* not used */
77 #define EMPTY_ID                        0xffff    /* empty record in a table */
78
79
80 /* ES Categories to be used by interface plugins */
81 #define UNKNOWN_ES      0x00
82 #define VIDEO_ES        0x01
83 #define AUDIO_ES        0x02
84 #define SPU_ES          0x03
85 #define NAV_ES          0x04
86
87 /*****************************************************************************
88  * pgrm_descriptor_t
89  *****************************************************************************
90  * Describes a program and list associated elementary streams. It is build by
91  * the PSI decoder upon the informations carried in program map sections
92  *****************************************************************************/
93 struct pgrm_descriptor_t
94 {
95     /* Program characteristics */
96     uint16_t                i_number;                      /* program number */
97     uint8_t                 i_version;                     /* version number */
98     vlc_bool_t              b_is_ok;      /* Is the description up to date ? */
99
100     /* Service Descriptor (program name) - DVB extension */
101     uint8_t                 i_srv_type;
102     char *                  psz_srv_name;
103
104     /* Synchronization information */
105     mtime_t                 delta_cr;
106     mtime_t                 cr_ref, sysdate_ref;
107     mtime_t                 last_cr; /* reference to detect unexpected stream
108                                       * discontinuities                      */
109     mtime_t                 last_syscr;
110     count_t                 c_average_count;
111                            /* counter used to compute dynamic average values */
112     int                     i_synchro_state;
113
114     /* Demultiplexer data */
115     pgrm_sys_t *            p_demux_data;
116
117     unsigned int            i_es_number;      /* size of the following array */
118     es_descriptor_t **      pp_es;                /* array of pointers to ES */
119 };
120
121 /* Synchro states */
122 #define SYNCHRO_OK          0
123 #define SYNCHRO_START       1
124 #define SYNCHRO_REINIT      2
125
126 /*****************************************************************************
127  * input_area_t
128  *****************************************************************************
129  * Attributes for current area (title for DVD)
130  *****************************************************************************/
131 struct input_area_t
132 {
133     /* selected area attributes */
134     unsigned int            i_id;        /* identificator for area */
135     off_t                   i_start;     /* start offset of area */
136     off_t                   i_size;      /* total size of the area
137                                           * (in arbitrary units) */
138
139     /* navigation parameters */
140     off_t                   i_tell;      /* actual location in the area
141                                           * (in arbitrary units) */
142     off_t                   i_seek;      /* next requested location
143                                           * (changed by the interface thread */
144
145     /* area subdivision */
146     unsigned int            i_part_nb;   /* number of parts (chapter for DVD)*/
147     unsigned int            i_part;      /* currently selected part */
148
149
150     /* offset to plugin related data */
151     off_t                   i_plugin_data;
152 };
153
154 /**
155  * \brief A list of info items.
156  *
157  * Composes a linked list of name/value pairs intended to inform the
158  * user about the current stream
159  * \see input_AddInfo
160  */
161 struct input_info_t {
162     /**
163      * Name of this item
164      */
165     char *         psz_name;
166
167     /**
168      * Value of this item
169      */
170     char *         psz_value;
171
172     /**
173      * Pointer to next item in list, or NULL it at end of list
174      */
175     input_info_t * p_next;
176 };
177
178 /**
179  * \brief A list of info categories.
180  *
181  * Composes a NULL terminated linked list of categories in which to
182  * place info about the stream.
183  *
184  * \see input_InfoCategory
185  */
186 struct input_info_category_t {
187     /**
188      * The name of this category
189      */
190     char *                  psz_name;
191
192     /**
193      * first element of a linked list containing info items
194      */
195     input_info_t *          p_info;
196
197     /**
198      * Pointer to next element in this list, or NULL if at end of list
199      */
200     input_info_category_t * p_next;
201 };
202
203 /*****************************************************************************
204 * stream_descriptor_t
205  *****************************************************************************
206  * Describes a stream and list its associated programs. Build upon
207  * the information carried in program association sections (for instance)
208  *****************************************************************************/
209 struct stream_descriptor_t
210 {
211     uint16_t                i_stream_id;                        /* stream id */
212     vlc_bool_t              b_changed;    /* if stream has been changed,
213                                              we have to inform the interface */
214     vlc_mutex_t             stream_lock;  /* to be taken every time you read
215                                            * or modify stream, pgrm or es    */
216
217     /* Input method data */
218     unsigned int            i_method;       /* input method for stream: file,
219                                                disc or network */
220     vlc_bool_t              b_pace_control;    /* can we read when we want ? */
221     vlc_bool_t              b_seekable;               /* can we do lseek() ? */
222     vlc_bool_t              b_connected;     /* does read() == 0 imply EOF ? */
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
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     demux_sys_t *    p_demux_data;                      /* data of the demux */
318
319     /* Buffer manager */
320     input_buffers_t *p_method_data;     /* data of the packet manager */
321     data_buffer_t *  p_data_buffer;
322     byte_t *         p_current_data;
323     byte_t *         p_last_data;
324     size_t           i_bufsize;
325
326     /* General stream description */
327     stream_descriptor_t     stream;
328
329     /* Playlist item */
330     char *  psz_source;
331     char *  psz_access;
332     char *  psz_demux;
333     char *  psz_name;
334
335     count_t c_loops;
336 };
337
338 /* Input methods */
339 /* The first figure is a general method that can be used in interface plugins ;
340  * The second figure is a detailed sub-method */
341 #define INPUT_METHOD_NONE         0x0            /* input thread is inactive */
342 #define INPUT_METHOD_FILE        0x10   /* stream is read from file p_source */
343 #define INPUT_METHOD_DISC        0x20   /* stream is read directly from disc */
344 #define INPUT_METHOD_DVD         0x21             /* stream is read from DVD */
345 #define INPUT_METHOD_VCD         0x22             /* stream is read from VCD */
346 #define INPUT_METHOD_NETWORK     0x30         /* stream is read from network */
347 #define INPUT_METHOD_UCAST       0x31                         /* UDP unicast */
348 #define INPUT_METHOD_MCAST       0x32                       /* UDP multicast */
349 #define INPUT_METHOD_BCAST       0x33                       /* UDP broadcast */
350 #define INPUT_METHOD_VLAN_BCAST  0x34            /* UDP broadcast with VLANs */
351 #define INPUT_METHOD_SATELLITE   0x40               /* stream is read from a */
352                                                            /* satellite card */
353
354 /* Status changing methods */
355 #define INPUT_STATUS_END            0
356 #define INPUT_STATUS_PLAY           1
357 #define INPUT_STATUS_PAUSE          2
358 #define INPUT_STATUS_FASTER         3
359 #define INPUT_STATUS_SLOWER         4
360
361 /* Seek modes */
362 #define INPUT_SEEK_SET       0x00
363 #define INPUT_SEEK_CUR       0x01
364 #define INPUT_SEEK_END       0x02
365 #define INPUT_SEEK_BYTES     0x00
366 #define INPUT_SEEK_SECONDS   0x10
367 #define INPUT_SEEK_PERCENT   0x20
368
369 /*****************************************************************************
370  * Prototypes
371  *****************************************************************************/
372 #define input_CreateThread(a,b) __input_CreateThread(VLC_OBJECT(a),b)
373 input_thread_t * __input_CreateThread ( vlc_object_t *, playlist_item_t * );
374 void   input_StopThread     ( input_thread_t * );
375 void   input_DestroyThread  ( input_thread_t * );
376
377 #define input_SetStatus(a,b) __input_SetStatus(VLC_OBJECT(a),b)
378 VLC_EXPORT( void, __input_SetStatus, ( vlc_object_t *, int ) );
379
380 #define input_Seek(a,b,c) __input_Seek(VLC_OBJECT(a),b,c)
381 VLC_EXPORT( void, __input_Seek, ( vlc_object_t *, off_t, int ) );
382
383 #define input_Tell(a,b) __input_Tell(VLC_OBJECT(a),b)
384 VLC_EXPORT( void, __input_Tell, ( vlc_object_t *, stream_position_t * ) );
385
386 VLC_EXPORT( void, input_DumpStream, ( input_thread_t * ) );
387 VLC_EXPORT( char *, input_OffsetToTime, ( input_thread_t *, char *, off_t ) );
388 VLC_EXPORT( int, input_ToggleES, ( input_thread_t *, es_descriptor_t *, vlc_bool_t ) );
389 VLC_EXPORT( int, input_ChangeArea, ( input_thread_t *, input_area_t * ) );
390 VLC_EXPORT( int, input_ChangeProgram, ( input_thread_t *, uint16_t ) );
391
392 int    input_ToggleGrayscale( input_thread_t * );
393 int    input_ToggleMute     ( input_thread_t * );
394
395 #endif /* "input_ext-intf.h" */