]> git.sesse.net Git - vlc/blob - include/modules.h
All decoders (audio, video, subtitles) are now modules.
[vlc] / include / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: modules.h,v 1.31 2001/11/13 12:09:17 henri Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  * 
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * module_bank_t, p_module_bank (global variable)
26  *****************************************************************************
27  * This global variable is accessed by any function using modules.
28  *****************************************************************************/
29 typedef struct
30 {
31     struct module_s *   first; /* First module of the bank */
32
33     vlc_mutex_t         lock;  /* Global lock -- you can't imagine how awful it
34                                   is to design thread-safe linked lists. */
35 } module_bank_t;
36
37 extern module_bank_t *p_module_bank;
38
39 /*****************************************************************************
40  * Module #defines.
41  *****************************************************************************/
42
43 /* Number of tries before we unload an unused module */
44 #define MODULE_HIDE_DELAY 100
45
46 /* The module handle type. */
47 #ifdef SYS_BEOS
48 typedef int     module_handle_t;
49 #else
50 typedef void *  module_handle_t;
51 #endif
52
53 /*****************************************************************************
54  * Module capabilities.
55  *****************************************************************************/
56
57 #define MODULE_CAPABILITY_NULL     0        /* The Module can't do anything */
58 #define MODULE_CAPABILITY_INTF     1 <<  0  /* Interface */
59 #define MODULE_CAPABILITY_ACCESS   1 <<  1  /* Input */
60 #define MODULE_CAPABILITY_INPUT    1 <<  2  /* Input */
61 #define MODULE_CAPABILITY_DECAPS   1 <<  3  /* Decaps */
62 #define MODULE_CAPABILITY_DEC      1 <<  4  /* Video decoder */
63 #define MODULE_CAPABILITY_MOTION   1 <<  5  /* Motion compensation */
64 #define MODULE_CAPABILITY_IDCT     1 <<  6  /* IDCT transformation */
65 #define MODULE_CAPABILITY_AOUT     1 <<  7  /* Audio output */
66 #define MODULE_CAPABILITY_VOUT     1 <<  8  /* Video output */
67 #define MODULE_CAPABILITY_YUV      1 <<  9  /* YUV colorspace conversion */
68 #define MODULE_CAPABILITY_IMDCT    1 << 10  /* IMDCT transformation */
69 #define MODULE_CAPABILITY_DOWNMIX  1 << 11  /* AC3 downmix */
70
71 /* FIXME: kludge */
72 struct input_area_s;
73 struct imdct_s;
74 struct complex_s;
75 struct dm_par_s;
76 struct bit_stream_s;
77 struct decoder_fifo_s;
78
79 struct decoder_config_s;
80
81 /* FIXME: not yet used */
82 typedef struct probedata_s
83 {
84     u8  i_type;
85     struct
86     {
87         char * psz_data;
88     } aout;
89 } probedata_t;
90
91 /* FIXME: find a nicer way to do this. */
92 typedef struct function_list_s
93 {
94     int ( * pf_probe ) ( probedata_t * p_data );
95
96     union
97     {
98         /* Interface plugin */
99         struct
100         {
101             int  ( * pf_open ) ( struct intf_thread_s * );
102             void ( * pf_close )( struct intf_thread_s * );
103             void ( * pf_run )  ( struct intf_thread_s * );
104         } intf;
105
106         /* Input plugin */
107         struct
108         {
109             void ( * pf_init ) ( struct input_thread_s * );
110             void ( * pf_open ) ( struct input_thread_s * );
111             void ( * pf_close )( struct input_thread_s * );
112             void ( * pf_end )  ( struct input_thread_s * );
113             void ( * pf_init_bit_stream ) ( struct bit_stream_s *,
114                                             struct decoder_fifo_s *,
115                       void (* pf_bitstream_callback)( struct bit_stream_s *,
116                                                       boolean_t ),
117                                            void * );
118
119             int  ( * pf_read ) ( struct input_thread_s *,
120                                  struct data_packet_s *
121                                         pp_packets[] );
122             void ( * pf_demux )( struct input_thread_s *,
123                                  struct data_packet_s * );
124
125             struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
126             struct pes_packet_s *  ( * pf_new_pes )    ( void * );
127             void ( * pf_delete_packet )  ( void *, struct data_packet_s * );
128             void ( * pf_delete_pes )     ( void *, struct pes_packet_s * );
129
130
131             int  ( * pf_set_area ) ( struct input_thread_s *,
132                                      struct input_area_s * );
133             int  ( * pf_rewind )   ( struct input_thread_s * );
134             void ( * pf_seek )     ( struct input_thread_s *, off_t );
135         } input;
136
137         /* Audio output plugin */
138         struct
139         {
140             int  ( * pf_open )       ( struct aout_thread_s * );
141             int  ( * pf_setformat )  ( struct aout_thread_s * );
142             long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
143             void ( * pf_play )       ( struct aout_thread_s *, byte_t *, int );
144             void ( * pf_close )      ( struct aout_thread_s * );
145         } aout;
146
147         /* Video output plugin */
148         struct
149         {
150             int  ( * pf_create )     ( struct vout_thread_s * );
151             int  ( * pf_init )       ( struct vout_thread_s * );
152             void ( * pf_end )        ( struct vout_thread_s * );
153             void ( * pf_destroy )    ( struct vout_thread_s * );
154             int  ( * pf_manage )     ( struct vout_thread_s * );
155             void ( * pf_display )    ( struct vout_thread_s * );
156             void ( * pf_setpalette ) ( struct vout_thread_s *, u16 *red,
157                                        u16 *green, u16 *blue, u16 *transp );
158         } vout;
159
160         /* Motion compensation plugin */
161         struct
162         {
163             void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
164                                                int, int );
165         } motion;
166
167         /* IDCT plugin */
168         struct
169         {
170             void ( * pf_idct_init )    ( void ** );
171             void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
172                                          void *, int );
173             void ( * pf_idct_add )     ( dctelem_t *, yuv_data_t *, int,
174                                          void *, int );
175             void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
176                                          void *, int );
177             void ( * pf_idct_copy )    ( dctelem_t *, yuv_data_t *, int,
178                                          void *, int );
179             void ( * pf_norm_scan )    ( u8 ppi_scan[2][64] );
180         } idct;
181
182         /* YUV transformation plugin */
183         struct
184         {
185             int  ( * pf_init )         ( struct vout_thread_s * );
186             int  ( * pf_reset )        ( struct vout_thread_s * );
187             void ( * pf_end )          ( struct vout_thread_s * );
188         } yuv;
189
190         /* IMDCT plugin */
191         struct
192         {
193             void ( * pf_imdct_init )   ( struct imdct_s * );
194             void ( * pf_imdct_256 )    ( struct imdct_s *,
195                                          float data[], float delay[] );
196             void ( * pf_imdct_256_nol )( struct imdct_s *,
197                                          float data[], float delay[] );
198             void ( * pf_imdct_512 )    ( struct imdct_s *,
199                                          float data[], float delay[] );
200             void ( * pf_imdct_512_nol )( struct imdct_s *,
201                                          float data[], float delay[] );
202 //            void ( * pf_fft_64p )      ( struct complex_s * );
203
204         } imdct;
205
206         /* AC3 downmix plugin */
207         struct
208         {
209             void ( * pf_downmix_3f_2r_to_2ch ) ( float *, struct dm_par_s * );
210             void ( * pf_downmix_3f_1r_to_2ch ) ( float *, struct dm_par_s * );
211             void ( * pf_downmix_2f_2r_to_2ch ) ( float *, struct dm_par_s * );
212             void ( * pf_downmix_2f_1r_to_2ch ) ( float *, struct dm_par_s * );
213             void ( * pf_downmix_3f_0r_to_2ch ) ( float *, struct dm_par_s * );
214             void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
215             void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
216
217         } downmix;
218
219         /* Decoder plugins */
220         struct
221         {
222             int  ( * pf_RunThread ) ( struct decoder_config_s * p_config );
223         } dec;
224
225     } functions;
226
227 } function_list_t;
228
229 typedef struct module_functions_s
230 {
231     /* XXX: The order here has to be the same as above for the #defines */
232     function_list_t intf;
233     function_list_t access;
234     function_list_t input;
235     function_list_t decaps;
236     function_list_t dec;
237     function_list_t motion;
238     function_list_t idct;
239     function_list_t aout;
240     function_list_t vout;
241     function_list_t yuv;
242     function_list_t imdct;
243     function_list_t downmix;
244
245 } module_functions_t;
246
247 typedef struct module_functions_s * p_module_functions_t;
248
249 /*****************************************************************************
250  * Macros used to build the configuration structure.
251  *****************************************************************************/
252
253 /* Mandatory first and last parts of the structure */
254 #define MODULE_CONFIG_ITEM_START       0xdead  /* The main window */
255 #define MODULE_CONFIG_ITEM_END         0xbeef  /* End of the window */
256
257 /* Configuration widgets */
258 #define MODULE_CONFIG_ITEM_WINDOW      0x0001  /* The main window */
259 #define MODULE_CONFIG_ITEM_PANE        0x0002  /* A notebook pane */
260 #define MODULE_CONFIG_ITEM_FRAME       0x0003  /* A frame */
261 #define MODULE_CONFIG_ITEM_COMMENT     0x0004  /* A comment text */
262 #define MODULE_CONFIG_ITEM_STRING      0x0005  /* A string */
263 #define MODULE_CONFIG_ITEM_FILE        0x0006  /* A file selector */
264 #define MODULE_CONFIG_ITEM_CHECK       0x0007  /* A checkbox */
265 #define MODULE_CONFIG_ITEM_CHOOSE      0x0008  /* A choose box */
266 #define MODULE_CONFIG_ITEM_RADIO       0x0009  /* A radio box */
267 #define MODULE_CONFIG_ITEM_SCALE       0x000a  /* A horizontal ruler */
268 #define MODULE_CONFIG_ITEM_SPIN        0x000b  /* A numerical selector */
269
270 typedef struct module_config_s
271 {
272     int         i_type;                         /* Configuration widget type */
273     char *      psz_text;        /* Text commenting or describing the widget */
274     char *      psz_name;                                   /* Variable name */
275     void *      p_getlist;          /* Function to call to get a choice list */
276     void *      p_change;        /* Function to call when commiting a change */
277 } module_config_t;
278
279 /*****************************************************************************
280  * Bank and module description structures
281  *****************************************************************************/
282
283 /* The module description structure */
284 typedef struct module_s
285 {
286     boolean_t           b_builtin;  /* Set to true if the module is built in */
287
288     union
289     {
290         struct
291         {
292             module_handle_t     handle;                     /* Unique handle */
293             char *              psz_filename;             /* Module filename */
294
295         } plugin;
296
297         struct
298         {
299             int ( *pf_deactivate ) ( struct module_s * );
300
301         } builtin;
302
303     } is;
304
305     char *              psz_name;                    /* Module _unique_ name */
306     char *              psz_longname;             /* Module descriptive name */
307     char *              psz_version;                       /* Module version */
308
309     int                 i_usage;                        /* Reference counter */
310     int                 i_unused_delay;    /* Delay until module is unloaded */
311
312     struct module_s *   next;                                 /* Next module */
313     struct module_s *   prev;                             /* Previous module */
314
315     module_config_t         *p_config;     /* Module configuration structure */
316     struct module_symbols_s *p_symbols;
317
318     u32                      i_capabilities;              /* Capability list */
319     p_module_functions_t     p_functions;            /* Capability functions */
320
321 } module_t;
322
323 /*****************************************************************************
324  * Exported functions.
325  *****************************************************************************/
326 void            module_InitBank     ( void );
327 void            module_EndBank      ( void );
328 void            module_ResetBank    ( void );
329 void            module_ManageBank   ( void );
330 module_t *      module_Need         ( int i_capabilities, void *p_data );
331 void            module_Unneed       ( module_t * p_module );
332