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