]> git.sesse.net Git - vlc/blob - include/input_ext-intf.h
* Splitted up p_method_data/p_plugin_data ;
[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.7 2000/12/21 15:01:08 massiot Exp $
8  *
9  * Authors:
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 /*
27  * Communication input -> interface
28  */
29 #define INPUT_MAX_PLUGINS   1
30 /* FIXME ! */
31 #define REQUESTED_MPEG         0
32 #define REQUESTED_AC3          1
33 #define REQUESTED_LPCM         2
34 #define REQUESTED_NOAUDIO    255
35
36 /*****************************************************************************
37  * es_descriptor_t: elementary stream descriptor
38  *****************************************************************************
39  * Describes an elementary stream, and includes fields required to handle and
40  * demultiplex this elementary stream.
41  *****************************************************************************/
42 struct decoder_fifo_s;                         /* defined in input_ext-dec.h */
43 struct pgrm_descriptor_s;
44
45 typedef struct es_descriptor_s
46 {
47     u16                     i_id;            /* stream ID for PS, PID for TS */
48     u8                      i_stream_id;     /* stream ID defined in the PES */
49     u8                      i_type;                           /* stream type */
50
51     /* Demultiplexer information */
52     void *                  p_demux_data;
53     struct pgrm_descriptor_s *
54                             p_pgrm;  /* very convenient in the demultiplexer */
55
56     /* PES parser information */
57     struct pes_packet_s *   p_pes;                            /* Current PES */
58     struct data_packet_s *  p_last;   /* The last packet gathered at present */
59     int                     i_pes_real_size;   /* as indicated by the header */
60     boolean_t               b_discontinuity;               /* Stream changed */
61
62     /* Decoder information */
63     struct decoder_fifo_s * p_decoder_fifo;
64     vlc_thread_t            thread_id;                  /* ID of the decoder */
65
66 #ifdef STATS
67     count_t                 c_payload_bytes;/* total of payload useful bytes */
68     count_t                 c_packets;                 /* total packets read */
69     count_t                 c_invalid_packets;       /* invalid packets read */
70 #endif
71 } es_descriptor_t;
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 /* ES streams types - see ISO/IEC 13818-1 table 2-29 numbers */
80 #define MPEG1_VIDEO_ES      0x01
81 #define MPEG2_VIDEO_ES      0x02
82 #define MPEG1_AUDIO_ES      0x03
83 #define MPEG2_AUDIO_ES      0x04
84 #define AC3_AUDIO_ES        0x81
85 /* These ones might violate the norm : */
86 #define DVD_SPU_ES          0x82
87 #define LPCM_AUDIO_ES       0x83
88 #define UNKNOWN_ES         0xFF
89
90 /*****************************************************************************
91  * pgrm_descriptor_t
92  *****************************************************************************
93  * Describes a program and list associated elementary streams. It is build by
94  * the PSI decoder upon the informations carried in program map sections
95  *****************************************************************************/
96 typedef struct pgrm_descriptor_s
97 {
98     /* Program characteristics */
99     u16                     i_number;                      /* program number */
100     u8                      i_version;                     /* version number */
101     boolean_t               b_is_ok;      /* Is the description up to date ? */
102
103     /* Service Descriptor (program name) - DVB extension */
104     u8                      i_srv_type;
105     char *                  psz_srv_name;
106
107     /* Synchronization information */
108     /* system_date = PTS_date + delta_cr + delta_absolute */
109     mtime_t                 delta_cr;
110     mtime_t                 delta_absolute;
111     mtime_t                 last_cr;
112     count_t                 c_average_count;
113                            /* counter used to compute dynamic average values */
114     int                     i_synchro_state;
115     boolean_t               b_discontinuity;
116
117     /* Demultiplexer data */
118     void *                  p_demux_data;
119
120     /* Decoders control */
121     struct vout_thread_s *  p_vout;
122     struct aout_thread_s *  p_aout;
123
124     int                     i_es_number;      /* size of the following array */
125     es_descriptor_t **      pp_es;                /* array of pointers to ES */
126 } pgrm_descriptor_t;
127
128 /* Synchro states */
129 #define SYNCHRO_OK          0
130 #define SYNCHRO_NOT_STARTED 1
131 #define SYNCHRO_START       2
132 #define SYNCHRO_REINIT      3
133
134 /*****************************************************************************
135  * stream_descriptor_t
136  *****************************************************************************
137  * Describes a stream and list its associated programs. Build upon
138  * the information carried in program association sections (for instance)
139  *****************************************************************************/
140 typedef struct stream_descriptor_s
141 {
142     u16                     i_stream_id;                        /* stream id */
143     vlc_mutex_t             stream_lock;  /* to be taken every time you read
144                                            * or modify stream, pgrm or es    */
145
146     /* Input method data */
147     boolean_t               b_pace_control;    /* can we read when we want ? */
148     boolean_t               b_seekable;               /* can we do lseek() ? */
149     /* if (b_seekable) : */
150     off_t                   i_size;     /* total size of the file (in bytes) */
151     off_t                   i_tell;/* actual location in the file (in bytes) */
152
153     /* Demultiplexer data */
154     void *                  p_demux_data;
155
156     /* Programs description */
157     int                     i_pgrm_number;    /* size of the following array */
158     pgrm_descriptor_t **    pp_programs;        /* array of pointers to pgrm */
159
160     /* Stream control */
161     stream_ctrl_t           control;
162 } stream_descriptor_t;
163
164 /*****************************************************************************
165  * i_p_config_t
166  *****************************************************************************
167  * This structure gives plugins pointers to the useful functions of input
168  *****************************************************************************/
169 struct input_thread_s;
170 struct data_packet_s;
171 struct es_descriptor_s;
172
173 typedef struct i_p_config_s
174 {
175     int                 (* pf_peek_stream)( struct input_thread_s *,
176                                             byte_t * buffer, size_t );
177     void                (* pf_demux_pes)( struct input_thread_s *,
178                                           struct data_packet_s *,
179                                           struct es_descriptor_s *,
180                                           boolean_t b_unit_start,
181                                           boolean_t b_packet_lost );
182 } i_p_config_t;
183
184 /*****************************************************************************
185  * input_thread_t
186  *****************************************************************************
187  * This structure includes all the local static variables of an input thread
188  *****************************************************************************/
189 struct aout_thread_s;
190 struct vout_thread_s;
191
192 typedef struct input_thread_s
193 {
194     /* Thread properties and locks */
195     boolean_t               b_die;                             /* 'die' flag */
196     boolean_t               b_error;
197     vlc_thread_t            thread_id;            /* id for thread functions */
198     int *                   pi_status;              /* temporary status flag */
199
200     struct input_config_s * p_config;
201
202     struct input_capabilities_s *
203                             pp_plugins[INPUT_MAX_PLUGINS];/* list of plugins */
204     struct input_capabilities_s *
205                             p_plugin;                     /* selected plugin */
206     i_p_config_t            i_p_config;              /* plugin configuration */
207
208     int                     i_handle;           /* socket or file descriptor */
209     void *                  p_method_data;     /* data of the packet manager */
210     void *                  p_plugin_data;             /* data of the plugin */
211
212     /* General stream description */
213     stream_descriptor_t     stream;                            /* PAT tables */
214     es_descriptor_t **      pp_es;             /* carried elementary streams */
215     int                     i_es_number;
216
217     /* List of streams to demux */
218     es_descriptor_t **      pp_selected_es;
219     int                     i_selected_es_number;
220
221     /* For auto-launch of decoders */
222     struct aout_thread_s *  p_default_aout;
223     struct vout_thread_s *  p_default_vout;
224
225 #ifdef STATS
226     count_t                 c_loops;
227     count_t                 c_bytes;                           /* bytes read */
228     count_t                 c_payload_bytes;         /* payload useful bytes */
229     count_t                 c_packets_read;                  /* packets read */
230     count_t                 c_packets_trashed;            /* trashed packets */
231 #endif
232 } input_thread_t;
233
234
235 /*
236  * Communication interface -> input
237  */
238
239 /*****************************************************************************
240  * input_config_t
241  *****************************************************************************
242  * This structure is given by the interface to an input thread
243  *****************************************************************************/
244 typedef struct input_config_s
245 {
246     /* Input method description */
247     int                         i_method;                    /* input method */
248     char *                      p_source;                          /* source */
249
250     /* For auto-launch of decoders */
251     struct aout_thread_s *      p_default_aout;
252     struct vout_thread_s *      p_default_vout;
253 } input_config_t;
254
255 /* Input methods */
256 #define INPUT_METHOD_NONE           0            /* input thread is inactive */
257 #define INPUT_METHOD_FILE          10   /* stream is read from file p_source */
258 #define INPUT_METHOD_UCAST         20                         /* UDP unicast */
259 #define INPUT_METHOD_MCAST         21                       /* UDP multicast */
260 #define INPUT_METHOD_BCAST         22                       /* UDP broadcast */
261 #define INPUT_METHOD_VLAN_BCAST    32            /* UDP broadcast with VLANs */
262
263 /*****************************************************************************
264  * Prototypes
265  *****************************************************************************/
266 struct input_thread_s * input_CreateThread( struct input_config_s *,
267                                             int *pi_status );
268 void                    input_DestroyThread( struct input_thread_s *,
269                                              int *pi_status );
270 void                    input_PauseProgram( struct input_thread_s *,
271                                             struct pgrm_descriptor_s * );
272 void                    input_PlayProgram( struct input_thread_s *,
273                                            struct pgrm_descriptor_s * );
274 void                    input_FFProgram( struct input_thread_s *,
275                                          struct pgrm_descriptor_s * );
276 void                    input_SMProgram( struct input_thread_s *,
277                                            struct pgrm_descriptor_s * );
278 void                    input_RewindProgram( struct input_thread_s *,
279                                              struct pgrm_descriptor_s * );