1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: modules.h,v 1.53 2002/06/01 18:04:48 sam Exp $
7 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
28 /* Number of tries before we unload an unused module */
29 #define MODULE_HIDE_DELAY 50
30 #define MODULE_SHORTCUT_MAX 10
32 /* The module handle type. */
34 typedef int module_handle_t;
36 typedef void * module_handle_t;
39 /*****************************************************************************
40 * Module capabilities.
41 *****************************************************************************/
42 #define MODULE_CAPABILITY_MAIN 0 /* Main */
43 #define MODULE_CAPABILITY_INTF 1 /* Interface */
44 #define MODULE_CAPABILITY_ACCESS 2 /* Input */
45 #define MODULE_CAPABILITY_DEMUX 3 /* Input */
46 #define MODULE_CAPABILITY_NETWORK 4 /* Network */
47 #define MODULE_CAPABILITY_DECODER 5 /* Audio or video decoder */
48 #define MODULE_CAPABILITY_MOTION 6 /* Motion compensation */
49 #define MODULE_CAPABILITY_IDCT 7 /* IDCT transformation */
50 #define MODULE_CAPABILITY_AOUT 8 /* Audio output */
51 #define MODULE_CAPABILITY_VOUT 9 /* Video output */
52 #define MODULE_CAPABILITY_CHROMA 10 /* colorspace conversion */
53 #define MODULE_CAPABILITY_IMDCT 11 /* IMDCT transformation */
54 #define MODULE_CAPABILITY_DOWNMIX 12 /* AC3 downmix */
55 #define MODULE_CAPABILITY_MEMCPY 13 /* memcpy */
56 #define MODULE_CAPABILITY_MAX 14 /* Total number of capabilities */
58 #define DECLARE_MODULE_CAPABILITY_TABLE \
59 static const char *ppsz_capabilities[] = \
71 "chroma transformation", \
78 #define MODULE_CAPABILITY( i_capa ) \
79 ppsz_capabilities[ ((i_capa) > MODULE_CAPABILITY_MAX) ? \
80 MODULE_CAPABILITY_MAX : (i_capa) ]
82 /*****************************************************************************
83 * module_bank_t: the module bank
84 *****************************************************************************
85 * This variable is accessed by any function using modules.
86 *****************************************************************************/
89 module_t * first; /* First module in the bank */
90 int i_count; /* Number of allocated modules */
92 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful *
93 it is to design thread-safe linked lists */
96 /*****************************************************************************
97 * Module description structure
98 *****************************************************************************/
104 * Variables set by the module to identify itself
106 char *psz_longname; /* Module descriptive name */
109 * Variables set by the module to tell us what it can do
111 char *psz_program; /* Program name which will activate the module */
112 char *pp_shortcuts[ MODULE_SHORTCUT_MAX ]; /* Shortcuts to the module */
114 u32 i_capabilities; /* Capability list */
115 int pi_score[ MODULE_CAPABILITY_MAX ]; /* Score for each capability */
117 u32 i_cpu_capabilities; /* Required CPU capabilities */
119 module_functions_t *p_functions; /* Capability functions */
122 * Variables set by the module to store its config options
124 module_config_t *p_config; /* Module configuration structure */
125 vlc_mutex_t config_lock; /* lock used to modify the config */
126 unsigned int i_config_items; /* number of configuration items */
127 unsigned int i_bool_items; /* number of bool config items */
130 * Variables used internally by the module manager
132 vlc_bool_t b_builtin; /* Set to true if the module is built in */
138 module_handle_t handle; /* Unique handle */
139 char * psz_filename; /* Module filename */
145 int ( *pf_deactivate ) ( module_t * );
151 int i_usage; /* Reference counter */
152 int i_unused_delay; /* Delay until module is unloaded */
154 module_t *next; /* Next module */
155 module_t *prev; /* Previous module */
158 * Symbol table we send to the module so that it can access vlc symbols
160 module_symbols_t *p_symbols;
163 /*****************************************************************************
164 * Module functions description structure
165 *****************************************************************************/
166 typedef struct function_list_s
170 /* Interface plugin */
173 int ( * pf_open ) ( intf_thread_t * );
174 void ( * pf_close )( intf_thread_t * );
175 void ( * pf_run ) ( intf_thread_t * );
181 int ( * pf_open ) ( input_thread_t * );
182 void ( * pf_close ) ( input_thread_t * );
183 ssize_t ( * pf_read ) ( input_thread_t *, byte_t *, size_t );
184 void ( * pf_seek ) ( input_thread_t *, off_t );
185 int ( * pf_set_program ) ( input_thread_t *, pgrm_descriptor_t * );
186 int ( * pf_set_area ) ( input_thread_t *, input_area_t * );
192 int ( * pf_init ) ( input_thread_t * );
193 void ( * pf_end ) ( input_thread_t * );
194 int ( * pf_demux ) ( input_thread_t * );
195 int ( * pf_rewind ) ( input_thread_t * );
201 int ( * pf_open ) ( vlc_object_t *, network_socket_t * );
204 /* Audio output plugin */
207 int ( * pf_open ) ( aout_thread_t * );
208 int ( * pf_setformat ) ( aout_thread_t * );
209 int ( * pf_getbufinfo ) ( aout_thread_t *, int );
210 void ( * pf_play ) ( aout_thread_t *, byte_t *, int );
211 void ( * pf_close ) ( aout_thread_t * );
214 /* Video output plugin */
217 int ( * pf_create ) ( vout_thread_t * );
218 int ( * pf_init ) ( vout_thread_t * );
219 void ( * pf_end ) ( vout_thread_t * );
220 void ( * pf_destroy ) ( vout_thread_t * );
221 int ( * pf_manage ) ( vout_thread_t * );
222 void ( * pf_render ) ( vout_thread_t *, picture_t * );
223 void ( * pf_display ) ( vout_thread_t *, picture_t * );
226 /* Motion compensation plugin */
229 void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
236 void ( * pf_idct_init ) ( void ** );
237 void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
239 void ( * pf_idct_add ) ( dctelem_t *, yuv_data_t *, int,
241 void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
243 void ( * pf_idct_copy ) ( dctelem_t *, yuv_data_t *, int,
245 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
248 /* Chroma transformation plugin */
251 int ( * pf_init ) ( vout_thread_t * );
252 void ( * pf_end ) ( vout_thread_t * );
258 void ( * pf_imdct_init ) ( imdct_t * );
259 void ( * pf_imdct_256 ) ( imdct_t *, float [], float [] );
260 void ( * pf_imdct_256_nol )( imdct_t *, float [], float [] );
261 void ( * pf_imdct_512 ) ( imdct_t *, float [], float [] );
262 void ( * pf_imdct_512_nol )( imdct_t *, float [], float [] );
263 // void ( * pf_fft_64p ) ( complex_t * );
267 /* AC3 downmix plugin */
270 void ( * pf_downmix_3f_2r_to_2ch ) ( float *, dm_par_t * );
271 void ( * pf_downmix_3f_1r_to_2ch ) ( float *, dm_par_t * );
272 void ( * pf_downmix_2f_2r_to_2ch ) ( float *, dm_par_t * );
273 void ( * pf_downmix_2f_1r_to_2ch ) ( float *, dm_par_t * );
274 void ( * pf_downmix_3f_0r_to_2ch ) ( float *, dm_par_t * );
275 void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
276 void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
280 /* Decoder plugins */
283 int ( * pf_probe)( u8 * p_es );
284 int ( * pf_run ) ( decoder_fifo_t * p_fifo );
290 void* ( * pf_memcpy ) ( void *, const void *, size_t );
291 void* ( * pf_memset ) ( void *, int, size_t );
298 struct module_functions_s
300 /* XXX: The order here has to be the same as above for the #defines */
301 function_list_t intf;
302 function_list_t access;
303 function_list_t demux;
304 function_list_t network;
306 function_list_t motion;
307 function_list_t idct;
308 function_list_t aout;
309 function_list_t vout;
310 function_list_t chroma;
311 function_list_t imdct;
312 function_list_t downmix;
313 function_list_t memcpy;
316 /*****************************************************************************
317 * Exported functions.
318 *****************************************************************************/
319 #define module_InitBank(a) __module_InitBank(CAST_TO_VLC_OBJECT(a))
320 void __module_InitBank ( vlc_object_t * );
321 #define module_LoadMain(a) __module_LoadMain(CAST_TO_VLC_OBJECT(a))
322 void __module_LoadMain ( vlc_object_t * );
323 #define module_LoadBuiltins(a) __module_LoadBuiltins(CAST_TO_VLC_OBJECT(a))
324 void __module_LoadBuiltins ( vlc_object_t * );
325 #define module_LoadPlugins(a) __module_LoadPlugins(CAST_TO_VLC_OBJECT(a))
326 void __module_LoadPlugins ( vlc_object_t * );
327 #define module_EndBank(a) __module_EndBank(CAST_TO_VLC_OBJECT(a))
328 void __module_EndBank ( vlc_object_t * );
329 #define module_ResetBank(a) __module_ResetBank(CAST_TO_VLC_OBJECT(a))
330 void __module_ResetBank ( vlc_object_t * );
331 #define module_ManageBank(a) __module_ManageBank(CAST_TO_VLC_OBJECT(a))
332 void __module_ManageBank ( vlc_object_t * );
334 #define module_Need(a,b,c,d) __module_Need(CAST_TO_VLC_OBJECT(a),b,c,d)
335 VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, int, char *, void * ) );
336 VLC_EXPORT( void, module_Unneed, ( module_t * ) );