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