]> git.sesse.net Git - vlc/blob - include/input_ext-intf.h
* ALL: got rid of p_object->p_this which is now useless.
[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.68 2002/06/01 18:04:48 sam 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_AC3          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_s
47 {
48     u16                     i_id;            /* stream ID for PS, PID for TS */
49     u8                      i_stream_id;     /* stream ID defined in the PES */
50     u8                      i_type;                           /* stream type */
51     vlc_bool_t              b_audio;      /* is the stream an audio stream that
52                                            * will need to be discarded with
53                                            * fast forward and slow motion ?  */
54     u8                      i_cat;        /* stream category: video, audio,
55                                            * spu, other */
56     int                     i_demux_fd;   /* used to store demux device
57                                              file handle */
58     char                    psz_desc[20]; /* description of ES: audio language
59                                            * for instance ; NULL if not
60                                            *  available */
61
62     /* Demultiplexer information */
63     void *                  p_demux_data;
64     pgrm_descriptor_t *     p_pgrm;  /* very convenient in the demultiplexer */
65
66     /* PES parser information */
67     pes_packet_t *          p_pes;                            /* Current PES */
68     int                     i_pes_real_size;   /* as indicated by the header */
69
70     /* Decoder information */
71     decoder_fifo_t *        p_decoder_fifo;
72     vlc_thread_t            thread_id;                  /* ID of the decoder */
73
74     count_t                 c_packets;                 /* total packets read */
75     count_t                 c_invalid_packets;       /* invalid packets read */
76
77     /* Module properties */
78     module_t *              p_module;
79 };
80
81 /* Special PID values - note that the PID is only on 13 bits, and that values
82  * greater than 0x1fff have no meaning in a stream */
83 #define PROGRAM_ASSOCIATION_TABLE_PID   0x0000
84 #define CONDITIONNAL_ACCESS_TABLE_PID   0x0001                   /* not used */
85 #define EMPTY_ID                        0xffff    /* empty record in a table */
86  
87
88 /* ES Categories to be used by interface plugins */
89 #define VIDEO_ES        0x00
90 #define AUDIO_ES        0x01
91 #define SPU_ES          0x02
92 #define NAV_ES          0x03
93 #define UNKNOWN_ES      0xFF
94
95 /*****************************************************************************
96  * pgrm_descriptor_t
97  *****************************************************************************
98  * Describes a program and list associated elementary streams. It is build by
99  * the PSI decoder upon the informations carried in program map sections
100  *****************************************************************************/
101 struct pgrm_descriptor_s
102 {
103     /* Program characteristics */
104     u16                     i_number;                      /* program number */
105     u8                      i_version;                     /* version number */
106     vlc_bool_t              b_is_ok;      /* Is the description up to date ? */
107
108     /* Service Descriptor (program name) - DVB extension */
109     u8                      i_srv_type;
110     char *                  psz_srv_name;
111
112     /* Synchronization information */
113     mtime_t                 delta_cr;
114     mtime_t                 cr_ref, sysdate_ref;
115     mtime_t                 last_cr; /* reference to detect unexpected stream
116                                       * discontinuities                      */
117     mtime_t                 last_syscr;
118     count_t                 c_average_count;
119                            /* counter used to compute dynamic average values */
120     int                     i_synchro_state;
121
122     /* Demultiplexer data */
123     void *                  p_demux_data;
124
125     int                     i_es_number;      /* size of the following array */
126     es_descriptor_t **      pp_es;                /* array of pointers to ES */
127 };
128
129 /* Synchro states */
130 #define SYNCHRO_OK          0
131 #define SYNCHRO_START       1
132 #define SYNCHRO_REINIT      2
133
134 /*****************************************************************************
135  * input_area_t
136  *****************************************************************************
137  * Attributes for current area (title for DVD)
138  *****************************************************************************/
139 struct input_area_s
140 {
141     /* selected area attributes */
142     int                     i_id;        /* identificator for area */
143     off_t                   i_start;     /* start offset of area */
144     off_t                   i_size;      /* total size of the area
145                                           * (in arbitrary units) */
146
147     /* navigation parameters */
148     off_t                   i_tell;      /* actual location in the area
149                                           * (in arbitrary units) */
150     off_t                   i_seek;      /* next requested location
151                                           * (changed by the interface thread */
152
153     /* area subdivision */
154     int                     i_part_nb;   /* number of parts (chapter for DVD)*/
155     int                     i_part;      /* currently selected part */
156
157
158     /* offset to plugin related data */
159     off_t                   i_plugin_data;
160 };
161
162 /*****************************************************************************
163  * stream_descriptor_t
164  *****************************************************************************
165  * Describes a stream and list its associated programs. Build upon
166  * the information carried in program association sections (for instance)
167  *****************************************************************************/
168 struct stream_descriptor_s
169 {
170     u16                     i_stream_id;                        /* stream id */
171     vlc_bool_t              b_changed;    /* if stream has been changed,
172                                              we have to inform the interface */
173     vlc_mutex_t             stream_lock;  /* to be taken every time you read
174                                            * or modify stream, pgrm or es    */
175
176     /* Input method data */
177     int                     i_method;       /* input method for stream: file,
178                                                disc or network */
179     vlc_bool_t              b_pace_control;    /* can we read when we want ? */
180     vlc_bool_t              b_seekable;               /* can we do lseek() ? */
181
182     /* if (b_seekable) : */
183     int                     i_area_nb;
184     input_area_t **         pp_areas;    /* list of areas in stream == offset
185                                           * interval with own properties */
186     input_area_t *          p_selected_area;
187     input_area_t *          p_new_area;  /* Newly selected area from
188                                           * the interface */
189
190     u32                     i_mux_rate; /* the rate we read the stream (in
191                                          * units of 50 bytes/s) ; 0 if undef */
192
193     /* New status and rate requested by the interface */
194     int                     i_new_status, i_new_rate;
195     int                     b_new_mute;          /* int because it can be -1 */
196     vlc_cond_t              stream_wait; /* interface -> input in case of a
197                                           * status change request            */
198
199     /* Demultiplexer data */
200     void *                  p_demux_data;
201
202     /* Programs descriptions */
203     int                     i_pgrm_number;    /* size of the following array */
204     pgrm_descriptor_t **    pp_programs;        /* array of pointers to pgrm */
205     pgrm_descriptor_t *     p_selected_program;   /* currently 
206                                                  selected program */
207     pgrm_descriptor_t *     p_new_program;        /* Newly selected program */
208     /* ES descriptions */
209     int                     i_es_number;
210     es_descriptor_t **      pp_es;             /* carried elementary streams */
211     int                     i_selected_es_number;
212     es_descriptor_t **      pp_selected_es;             /* ES with a decoder */
213     es_descriptor_t *       p_newly_selected_es;   /* ES selected from
214                                                     * the interface */
215     es_descriptor_t *       p_removed_es;   /* ES removed from the interface */
216     
217     /* Stream control */
218     stream_ctrl_t           control;
219
220     /* Statistics */
221     count_t                 c_packets_read;                  /* packets read */
222     count_t                 c_packets_trashed;            /* trashed packets */
223 };
224
225 /*****************************************************************************
226  * stream_position_t
227  *****************************************************************************
228  * Describes the current position in the stream.
229  *****************************************************************************/
230 struct stream_position_s
231 {
232     off_t    i_tell;     /* actual location in the area (in arbitrary units) */
233     off_t    i_size;          /* total size of the area (in arbitrary units) */
234
235     u32      i_mux_rate;                /* the rate we read the stream (in
236                                          * units of 50 bytes/s) ; 0 if undef */
237 };
238
239 #define MUTE_NO_CHANGE      -1
240
241 /*****************************************************************************
242  * input_thread_t
243  *****************************************************************************
244  * This structure includes all the local static variables of an input thread
245  *****************************************************************************/
246 struct input_thread_s
247 {
248     VLC_COMMON_MEMBERS
249
250     /* Thread properties and locks */
251     vlc_bool_t              b_eof;
252     int                     i_status;                         /* status flag */
253
254     /* Access module */
255     module_t *       p_access_module;
256     int           (* pf_open ) ( input_thread_t * );
257     void          (* pf_close )( input_thread_t * );
258     ssize_t       (* pf_read ) ( input_thread_t *, byte_t *, size_t );
259     int           (* pf_set_program )( input_thread_t *, pgrm_descriptor_t * );
260     int           (* pf_set_area )( input_thread_t *, input_area_t * );
261     void          (* pf_seek ) ( input_thread_t *, off_t );
262     void *           p_access_data;
263     size_t           i_mtu;
264
265     /* Demux module */
266     module_t *       p_demux_module;
267     int           (* pf_init )   ( input_thread_t * );
268     void          (* pf_end )    ( input_thread_t * );
269     int           (* pf_demux )  ( input_thread_t * );
270     int           (* pf_rewind ) ( input_thread_t * );
271                                            /* NULL if we don't support going *
272                                             * backwards (it's gonna be fun)  */
273     void *           p_demux_data;                      /* data of the demux */
274
275     /* Buffer manager */
276     input_buffers_t *p_method_data;     /* data of the packet manager */
277     data_buffer_t *  p_data_buffer;
278     byte_t *         p_current_data;
279     byte_t *         p_last_data;
280     size_t           i_bufsize;
281
282     /* General stream description */
283     stream_descriptor_t     stream;
284
285     /* Playlist item */
286     char *  psz_source;
287     char *  psz_access;
288     char *  psz_demux;
289     char *  psz_name;
290
291     count_t c_loops;
292 };
293
294 /* Input methods */
295 /* The first figure is a general method that can be used in interface plugins ;
296  * The second figure is a detailed sub-method */
297 #define INPUT_METHOD_NONE         0x0            /* input thread is inactive */
298 #define INPUT_METHOD_FILE        0x10   /* stream is read from file p_source */
299 #define INPUT_METHOD_DISC        0x20   /* stream is read directly from disc */
300 #define INPUT_METHOD_DVD         0x21             /* stream is read from DVD */
301 #define INPUT_METHOD_VCD         0x22             /* stream is read from VCD */
302 #define INPUT_METHOD_NETWORK     0x30         /* stream is read from network */
303 #define INPUT_METHOD_UCAST       0x31                         /* UDP unicast */
304 #define INPUT_METHOD_MCAST       0x32                       /* UDP multicast */
305 #define INPUT_METHOD_BCAST       0x33                       /* UDP broadcast */
306 #define INPUT_METHOD_VLAN_BCAST  0x34            /* UDP broadcast with VLANs */
307 #define INPUT_METHOD_SATELLITE   0x40               /* stream is read from a */
308                                                            /* satellite card */
309
310 /* Status changing methods */
311 #define INPUT_STATUS_END            0
312 #define INPUT_STATUS_PLAY           1
313 #define INPUT_STATUS_PAUSE          2
314 #define INPUT_STATUS_FASTER         3
315 #define INPUT_STATUS_SLOWER         4
316
317 /* Seek modes */
318 #define INPUT_SEEK_SET       0x00
319 #define INPUT_SEEK_CUR       0x01
320 #define INPUT_SEEK_END       0x02
321 #define INPUT_SEEK_BYTES     0x00
322 #define INPUT_SEEK_SECONDS   0x10
323 #define INPUT_SEEK_PERCENT   0x20
324
325 /*****************************************************************************
326  * Prototypes
327  *****************************************************************************/
328 #define input_CreateThread(a,b,c) __input_CreateThread(CAST_TO_VLC_OBJECT(a),b,c)
329 input_thread_t * __input_CreateThread ( vlc_object_t *,
330                                         playlist_item_t *, int * );
331 void   input_StopThread     ( input_thread_t *, int *pi_status );
332 void   input_DestroyThread  ( input_thread_t * );
333
334 #define input_SetStatus(a,b) __input_SetStatus(CAST_TO_VLC_OBJECT(a),b)
335 VLC_EXPORT( void, __input_SetStatus, ( vlc_object_t *, int ) );
336
337 #define input_Seek(a,b,c) __input_Seek(CAST_TO_VLC_OBJECT(a),b,c)
338 VLC_EXPORT( void, __input_Seek, ( vlc_object_t *, off_t, int ) );
339
340 #define input_Tell(a,b) __input_Tell(CAST_TO_VLC_OBJECT(a),b)
341 VLC_EXPORT( void, __input_Tell, ( vlc_object_t *, stream_position_t * ) );
342
343 VLC_EXPORT( void, input_DumpStream, ( input_thread_t * ) );
344 VLC_EXPORT( char *, input_OffsetToTime, ( input_thread_t *, char *, off_t ) );
345 VLC_EXPORT( int, input_ChangeES, ( input_thread_t *, es_descriptor_t *, u8 ) );
346 VLC_EXPORT( int, input_ToggleES, ( input_thread_t *, es_descriptor_t *, vlc_bool_t ) );
347 VLC_EXPORT( int, input_ChangeArea, ( input_thread_t *, input_area_t * ) );
348 VLC_EXPORT( int, input_ChangeProgram, ( input_thread_t *, u16 ) );
349
350 int    input_ToggleGrayscale( input_thread_t * );
351 int    input_ToggleMute     ( input_thread_t * );
352 int    input_SetSMP         ( input_thread_t *, int );
353
354 #endif /* "input_ext-intf.h" */