1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: modules.h,v 1.56 2002/07/03 19:40:49 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_AOUT_FILTER 9 /* Audio output filter */
52 #define MODULE_CAPABILITY_VOUT 10 /* Video output */
53 #define MODULE_CAPABILITY_VOUT_FILTER 11 /* Video output filter */
54 #define MODULE_CAPABILITY_CHROMA 12 /* colorspace conversion */
55 #define MODULE_CAPABILITY_IMDCT 13 /* IMDCT transformation */
56 #define MODULE_CAPABILITY_DOWNMIX 14 /* AC3 downmix */
57 #define MODULE_CAPABILITY_MEMCPY 15 /* memcpy */
58 #define MODULE_CAPABILITY_MAX 16 /* Total number of capabilities */
60 #define DECLARE_MODULE_CAPABILITY_TABLE \
61 static const char *ppsz_capabilities[] = \
72 "audio output filter", \
74 "video output filter", \
75 "chroma transformation", \
82 #define MODULE_CAPABILITY( i_capa ) \
83 ppsz_capabilities[ ((i_capa) > MODULE_CAPABILITY_MAX) ? \
84 MODULE_CAPABILITY_MAX : (i_capa) ]
86 /*****************************************************************************
87 * module_bank_t: the module bank
88 *****************************************************************************
89 * This variable is accessed by any function using modules.
90 *****************************************************************************/
93 module_t * first; /* First module in the bank */
94 int i_count; /* Number of allocated modules */
96 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful *
97 it is to design thread-safe linked lists */
100 /*****************************************************************************
101 * Module description structure
102 *****************************************************************************/
108 * Variables set by the module to identify itself
110 char *psz_longname; /* Module descriptive name */
113 * Variables set by the module to tell us what it can do
115 char *psz_program; /* Program name which will activate the module */
116 char *pp_shortcuts[ MODULE_SHORTCUT_MAX ]; /* Shortcuts to the module */
118 u32 i_capabilities; /* Capability list */
119 int pi_score[ MODULE_CAPABILITY_MAX ]; /* Score for each capability */
121 u32 i_cpu_capabilities; /* Required CPU capabilities */
123 module_functions_t *p_functions; /* Capability functions */
126 * Variables set by the module to store its config options
128 module_config_t *p_config; /* Module configuration structure */
129 unsigned int i_config_items; /* number of configuration items */
130 unsigned int i_bool_items; /* number of bool config items */
133 * Variables used internally by the module manager
135 vlc_bool_t b_builtin; /* Set to true if the module is built in */
141 module_handle_t handle; /* Unique handle */
142 char * psz_filename; /* Module filename */
148 int ( *pf_deactivate ) ( module_t * );
154 int i_usage; /* Reference counter */
155 int i_unused_delay; /* Delay until module is unloaded */
157 module_t *next; /* Next module */
158 module_t *prev; /* Previous module */
161 * Symbol table we send to the module so that it can access vlc symbols
163 module_symbols_t *p_symbols;
166 /*****************************************************************************
167 * Module functions description structure
168 *****************************************************************************/
169 typedef struct function_list_s
173 /* Interface plugin */
176 int ( * pf_open ) ( intf_thread_t * );
177 void ( * pf_close )( intf_thread_t * );
178 void ( * pf_run ) ( intf_thread_t * );
184 int ( * pf_open ) ( input_thread_t * );
185 void ( * pf_close ) ( input_thread_t * );
186 ssize_t ( * pf_read ) ( input_thread_t *, byte_t *, size_t );
187 void ( * pf_seek ) ( input_thread_t *, off_t );
188 int ( * pf_set_program ) ( input_thread_t *, pgrm_descriptor_t * );
189 int ( * pf_set_area ) ( input_thread_t *, input_area_t * );
195 int ( * pf_init ) ( input_thread_t * );
196 void ( * pf_end ) ( input_thread_t * );
197 int ( * pf_demux ) ( input_thread_t * );
198 int ( * pf_rewind ) ( input_thread_t * );
204 int ( * pf_open ) ( vlc_object_t *, network_socket_t * );
207 /* Audio output plugin */
210 int ( * pf_open ) ( aout_thread_t * );
211 int ( * pf_setformat ) ( aout_thread_t * );
212 int ( * pf_getbufinfo ) ( aout_thread_t *, int );
213 void ( * pf_play ) ( aout_thread_t *, byte_t *, int );
214 void ( * pf_close ) ( aout_thread_t * );
217 /* Video output plugin */
220 int ( * pf_create ) ( vout_thread_t * );
221 int ( * pf_init ) ( vout_thread_t * );
222 void ( * pf_end ) ( vout_thread_t * );
223 void ( * pf_destroy ) ( vout_thread_t * );
224 int ( * pf_manage ) ( vout_thread_t * );
225 void ( * pf_render ) ( vout_thread_t *, picture_t * );
226 void ( * pf_display ) ( vout_thread_t *, picture_t * );
229 /* Motion compensation plugin */
232 void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
239 void ( * pf_idct_init ) ( void ** );
240 void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
242 void ( * pf_idct_add ) ( dctelem_t *, yuv_data_t *, int,
244 void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
246 void ( * pf_idct_copy ) ( dctelem_t *, yuv_data_t *, int,
248 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
251 /* Chroma transformation plugin */
254 int ( * pf_init ) ( vout_thread_t * );
255 void ( * pf_end ) ( vout_thread_t * );
261 void ( * pf_imdct_init ) ( imdct_t * );
262 void ( * pf_imdct_256 ) ( imdct_t *, float [], float [] );
263 void ( * pf_imdct_256_nol )( imdct_t *, float [], float [] );
264 void ( * pf_imdct_512 ) ( imdct_t *, float [], float [] );
265 void ( * pf_imdct_512_nol )( imdct_t *, float [], float [] );
266 // void ( * pf_fft_64p ) ( complex_t * );
270 /* AC3 downmix plugin */
273 void ( * pf_downmix_3f_2r_to_2ch ) ( float *, dm_par_t * );
274 void ( * pf_downmix_3f_1r_to_2ch ) ( float *, dm_par_t * );
275 void ( * pf_downmix_2f_2r_to_2ch ) ( float *, dm_par_t * );
276 void ( * pf_downmix_2f_1r_to_2ch ) ( float *, dm_par_t * );
277 void ( * pf_downmix_3f_0r_to_2ch ) ( float *, dm_par_t * );
278 void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
279 void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
283 /* Decoder plugins */
286 int ( * pf_probe)( u8 * p_es );
287 int ( * pf_run ) ( decoder_fifo_t * p_fifo );
293 void* ( * pf_memcpy ) ( void *, const void *, size_t );
294 void* ( * pf_memset ) ( void *, int, size_t );
301 struct module_functions_s
303 /* XXX: The order here has to be the same as above for the #defines */
304 function_list_t intf;
305 function_list_t access;
306 function_list_t demux;
307 function_list_t network;
309 function_list_t motion;
310 function_list_t idct;
311 function_list_t aout;
312 function_list_t vout;
313 function_list_t chroma;
314 function_list_t imdct;
315 function_list_t downmix;
316 function_list_t memcpy;
319 /*****************************************************************************
320 * Exported functions.
321 *****************************************************************************/
322 #define module_InitBank(a) __module_InitBank(CAST_TO_VLC_OBJECT(a))
323 void __module_InitBank ( vlc_object_t * );
324 #define module_LoadMain(a) __module_LoadMain(CAST_TO_VLC_OBJECT(a))
325 void __module_LoadMain ( vlc_object_t * );
326 #define module_LoadBuiltins(a) __module_LoadBuiltins(CAST_TO_VLC_OBJECT(a))
327 void __module_LoadBuiltins ( vlc_object_t * );
328 #define module_LoadPlugins(a) __module_LoadPlugins(CAST_TO_VLC_OBJECT(a))
329 void __module_LoadPlugins ( vlc_object_t * );
330 #define module_EndBank(a) __module_EndBank(CAST_TO_VLC_OBJECT(a))
331 void __module_EndBank ( vlc_object_t * );
332 #define module_ResetBank(a) __module_ResetBank(CAST_TO_VLC_OBJECT(a))
333 void __module_ResetBank ( vlc_object_t * );
334 #define module_ManageBank(a) __module_ManageBank(CAST_TO_VLC_OBJECT(a))
335 void __module_ManageBank ( vlc_object_t * );
337 #define module_Need(a,b,c,d) __module_Need(CAST_TO_VLC_OBJECT(a),b,c,d)
338 VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, int, const char *, void * ) );
339 VLC_EXPORT( void, module_Unneed, ( module_t * ) );