]> git.sesse.net Git - vlc/blob - include/modules.h
f7b72a618d14bbe7afc47f883eca98ec9648474e
[vlc] / include / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: modules.h,v 1.34 2001/12/07 16:47:47 jobi 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 10000
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 #define MODULE_CAPABILITY_MEMCPY   1 << 12  /* memcpy */
71
72 /* FIXME: kludge */
73 struct input_area_s;
74 struct imdct_s;
75 struct complex_s;
76 struct dm_par_s;
77 struct bit_stream_s;
78 struct decoder_fifo_s;
79
80 struct decoder_config_s;
81
82 /* FIXME: not yet used */
83 typedef struct probedata_s
84 {
85     u8  i_type;
86     struct
87     {
88         char * psz_data;
89     } aout;
90 } probedata_t;
91
92 /* FIXME: find a nicer way to do this. */
93 typedef struct function_list_s
94 {
95     int ( * pf_probe ) ( probedata_t * p_data );
96
97     union
98     {
99         /* Interface plugin */
100         struct
101         {
102             int  ( * pf_open ) ( struct intf_thread_s * );
103             void ( * pf_close )( struct intf_thread_s * );
104             void ( * pf_run )  ( struct intf_thread_s * );
105         } intf;
106
107         /* Input plugin */
108         struct
109         {
110             void ( * pf_init ) ( struct input_thread_s * );
111             void ( * pf_open ) ( struct input_thread_s * );
112             void ( * pf_close )( struct input_thread_s * );
113             void ( * pf_end )  ( struct input_thread_s * );
114             void ( * pf_init_bit_stream ) ( struct bit_stream_s *,
115                                             struct decoder_fifo_s *,
116                       void (* pf_bitstream_callback)( struct bit_stream_s *,
117                                                       boolean_t ),
118                                            void * );
119
120             int  ( * pf_read ) ( struct input_thread_s *,
121                                  struct data_packet_s *
122                                         pp_packets[] );
123             void ( * pf_demux )( struct input_thread_s *,
124                                  struct data_packet_s * );
125
126             struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
127             struct pes_packet_s *  ( * pf_new_pes )    ( void * );
128             void ( * pf_delete_packet )  ( void *, struct data_packet_s * );
129             void ( * pf_delete_pes )     ( void *, struct pes_packet_s * );
130
131             int  ( * pf_set_program ) ( struct input_thread_s *,
132                                      struct pgrm_descriptor_s * );
133
134             int  ( * pf_set_area ) ( struct input_thread_s *,
135                                      struct input_area_s * );
136             int  ( * pf_rewind )   ( struct input_thread_s * );
137             void ( * pf_seek )     ( struct input_thread_s *, off_t );
138         } input;
139
140         /* Audio output plugin */
141         struct
142         {
143             int  ( * pf_open )       ( struct aout_thread_s * );
144             int  ( * pf_setformat )  ( struct aout_thread_s * );
145             long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
146             void ( * pf_play )       ( struct aout_thread_s *, byte_t *, int );
147             void ( * pf_close )      ( struct aout_thread_s * );
148         } aout;
149
150         /* Video output plugin */
151         struct
152         {
153             int  ( * pf_create )     ( struct vout_thread_s * );
154             int  ( * pf_init )       ( struct vout_thread_s * );
155             void ( * pf_end )        ( struct vout_thread_s * );
156             void ( * pf_destroy )    ( struct vout_thread_s * );
157             int  ( * pf_manage )     ( struct vout_thread_s * );
158             void ( * pf_display )    ( struct vout_thread_s * );
159             void ( * pf_setpalette ) ( struct vout_thread_s *, u16 *red,
160                                        u16 *green, u16 *blue, u16 *transp );
161         } vout;
162
163         /* Motion compensation plugin */
164         struct
165         {
166             void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
167                                                int, int );
168         } motion;
169
170         /* IDCT plugin */
171         struct
172         {
173             void ( * pf_idct_init )    ( void ** );
174             void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
175                                          void *, int );
176             void ( * pf_idct_add )     ( dctelem_t *, yuv_data_t *, int,
177                                          void *, int );
178             void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
179                                          void *, int );
180             void ( * pf_idct_copy )    ( dctelem_t *, yuv_data_t *, int,
181                                          void *, int );
182             void ( * pf_norm_scan )    ( u8 ppi_scan[2][64] );
183         } idct;
184
185         /* YUV transformation plugin */
186         struct
187         {
188             int  ( * pf_init )         ( struct vout_thread_s * );
189             int  ( * pf_reset )        ( struct vout_thread_s * );
190             void ( * pf_end )          ( struct vout_thread_s * );
191         } yuv;
192
193         /* IMDCT plugin */
194         struct
195         {
196             void ( * pf_imdct_init )   ( struct imdct_s * );
197             void ( * pf_imdct_256 )    ( struct imdct_s *,
198                                          float data[], float delay[] );
199             void ( * pf_imdct_256_nol )( struct imdct_s *,
200                                          float data[], float delay[] );
201             void ( * pf_imdct_512 )    ( struct imdct_s *,
202                                          float data[], float delay[] );
203             void ( * pf_imdct_512_nol )( struct imdct_s *,
204                                          float data[], float delay[] );
205 //            void ( * pf_fft_64p )      ( struct complex_s * );
206
207         } imdct;
208
209         /* AC3 downmix plugin */
210         struct
211         {
212             void ( * pf_downmix_3f_2r_to_2ch ) ( float *, struct dm_par_s * );
213             void ( * pf_downmix_3f_1r_to_2ch ) ( float *, struct dm_par_s * );
214             void ( * pf_downmix_2f_2r_to_2ch ) ( float *, struct dm_par_s * );
215             void ( * pf_downmix_2f_1r_to_2ch ) ( float *, struct dm_par_s * );
216             void ( * pf_downmix_3f_0r_to_2ch ) ( float *, struct dm_par_s * );
217             void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
218             void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
219
220         } downmix;
221
222         /* Decoder plugins */
223         struct
224         {
225             int  ( * pf_run ) ( struct decoder_config_s * p_config );
226         } dec;
227
228         /* memcpy plugins */
229         struct
230         {
231             void* ( * pf_fast_memcpy ) ( void *, const void *, size_t );
232         } memcpy;
233
234     } functions;
235
236 } function_list_t;
237
238 typedef struct module_functions_s
239 {
240     /* XXX: The order here has to be the same as above for the #defines */
241     function_list_t intf;
242     function_list_t access;
243     function_list_t input;
244     function_list_t decaps;
245     function_list_t dec;
246     function_list_t motion;
247     function_list_t idct;
248     function_list_t aout;
249     function_list_t vout;
250     function_list_t yuv;
251     function_list_t imdct;
252     function_list_t downmix;
253     function_list_t memcpy;
254
255 } module_functions_t;
256
257 typedef struct module_functions_s * p_module_functions_t;
258
259 /*****************************************************************************
260  * Macros used to build the configuration structure.
261  *****************************************************************************/
262
263 /* Mandatory first and last parts of the structure */
264 #define MODULE_CONFIG_ITEM_START       0xdead  /* The main window */
265 #define MODULE_CONFIG_ITEM_END         0xbeef  /* End of the window */
266
267 /* Configuration widgets */
268 #define MODULE_CONFIG_ITEM_WINDOW      0x0001  /* The main window */
269 #define MODULE_CONFIG_ITEM_PANE        0x0002  /* A notebook pane */
270 #define MODULE_CONFIG_ITEM_FRAME       0x0003  /* A frame */
271 #define MODULE_CONFIG_ITEM_COMMENT     0x0004  /* A comment text */
272 #define MODULE_CONFIG_ITEM_STRING      0x0005  /* A string */
273 #define MODULE_CONFIG_ITEM_FILE        0x0006  /* A file selector */
274 #define MODULE_CONFIG_ITEM_CHECK       0x0007  /* A checkbox */
275 #define MODULE_CONFIG_ITEM_CHOOSE      0x0008  /* A choose box */
276 #define MODULE_CONFIG_ITEM_RADIO       0x0009  /* A radio box */
277 #define MODULE_CONFIG_ITEM_SCALE       0x000a  /* A horizontal ruler */
278 #define MODULE_CONFIG_ITEM_SPIN        0x000b  /* A numerical selector */
279
280 typedef struct module_config_s
281 {
282     int         i_type;                         /* Configuration widget type */
283     char *      psz_text;        /* Text commenting or describing the widget */
284     char *      psz_name;                                   /* Variable name */
285     void *      p_getlist;          /* Function to call to get a choice list */
286     void *      p_change;        /* Function to call when commiting a change */
287 } module_config_t;
288
289 /*****************************************************************************
290  * Bank and module description structures
291  *****************************************************************************/
292
293 /* The module description structure */
294 typedef struct module_s
295 {
296     boolean_t           b_builtin;  /* Set to true if the module is built in */
297
298     union
299     {
300         struct
301         {
302             module_handle_t     handle;                     /* Unique handle */
303             char *              psz_filename;             /* Module filename */
304
305         } plugin;
306
307         struct
308         {
309             int ( *pf_deactivate ) ( struct module_s * );
310
311         } builtin;
312
313     } is;
314
315     char *              psz_name;                    /* Module _unique_ name */
316     char *              psz_longname;             /* Module descriptive name */
317     char *              psz_version;                       /* Module version */
318
319     int                 i_usage;                        /* Reference counter */
320     int                 i_unused_delay;    /* Delay until module is unloaded */
321
322     struct module_s *   next;                                 /* Next module */
323     struct module_s *   prev;                             /* Previous module */
324
325     module_config_t         *p_config;     /* Module configuration structure */
326     struct module_symbols_s *p_symbols;
327
328     u32                      i_capabilities;              /* Capability list */
329     p_module_functions_t     p_functions;            /* Capability functions */
330
331 } module_t;
332
333 /*****************************************************************************
334  * Exported functions.
335  *****************************************************************************/
336 void            module_InitBank     ( void );
337 void            module_EndBank      ( void );
338 void            module_ResetBank    ( void );
339 void            module_ManageBank   ( void );
340 module_t *      module_Need         ( int i_capabilities, void *p_data );
341 void            module_Unneed       ( module_t * p_module );
342