1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: modules.h,v 1.42 2002/02/24 20:51:09 gbazin 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 10000
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 static __inline__ char *GetCapabilityName( unsigned int i_capa )
44 /* The sole purpose of this inline function and the ugly #defines
45 * around it is to avoid having two places to modify when adding a
47 static char *pp_capa[] =
50 #define MODULE_CAPABILITY_MAIN 0 /* Main */
52 #define MODULE_CAPABILITY_INTF 1 /* Interface */
54 #define MODULE_CAPABILITY_ACCESS 2 /* Input */
56 #define MODULE_CAPABILITY_INPUT 3 /* Input */
58 #define MODULE_CAPABILITY_DECAPS 4 /* Decaps */
60 #define MODULE_CAPABILITY_DECODER 5 /* Audio or video decoder */
62 #define MODULE_CAPABILITY_MOTION 6 /* Motion compensation */
64 #define MODULE_CAPABILITY_IDCT 7 /* IDCT transformation */
66 #define MODULE_CAPABILITY_AOUT 8 /* Audio output */
68 #define MODULE_CAPABILITY_VOUT 9 /* Video output */
69 "chroma transformation",
70 #define MODULE_CAPABILITY_CHROMA 10 /* colorspace conversion */
72 #define MODULE_CAPABILITY_IMDCT 11 /* IMDCT transformation */
74 #define MODULE_CAPABILITY_DOWNMIX 12 /* AC3 downmix */
76 #define MODULE_CAPABILITY_MEMCPY 13 /* memcpy */
78 #define MODULE_CAPABILITY_MAX 14 /* Total number of capabilities */
81 return pp_capa[ (i_capa) > MODULE_CAPABILITY_MAX ? MODULE_CAPABILITY_MAX :
85 /*****************************************************************************
86 * module_bank_t, p_module_bank (global variable)
87 *****************************************************************************
88 * This global variable is accessed by any function using modules.
89 *****************************************************************************/
92 struct module_s * first; /* First module in the bank */
93 int i_count; /* Number of allocated modules */
95 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful *
96 it is to design thread-safe linked lists */
99 extern module_bank_t *p_module_bank;
101 /*****************************************************************************
102 * Module description structure
103 *****************************************************************************/
104 typedef struct module_s
107 * Variables set by the module to identify itself
109 char *psz_name; /* Module _unique_ name */
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 struct module_functions_s *p_functions; /* Capability functions */
124 struct module_config_s *p_config; /* Module configuration structure */
125 int i_config_options; /* number of configuration options */
128 * Variables used internally by the module manager
130 boolean_t b_builtin; /* Set to true if the module is built in */
136 module_handle_t handle; /* Unique handle */
137 char * psz_filename; /* Module filename */
143 int ( *pf_deactivate ) ( struct module_s * );
149 int i_usage; /* Reference counter */
150 int i_unused_delay; /* Delay until module is unloaded */
152 struct module_s *next; /* Next module */
153 struct module_s *prev; /* Previous module */
156 * Symbol table we send to the module so that it can access vlc symbols
158 struct module_symbols_s *p_symbols;
162 /*****************************************************************************
163 * Module functions description structure
164 *****************************************************************************/
165 typedef struct function_list_s
169 /* Interface plugin */
172 int ( * pf_open ) ( struct intf_thread_s * );
173 void ( * pf_close )( struct intf_thread_s * );
174 void ( * pf_run ) ( struct intf_thread_s * );
180 int ( * pf_probe )( struct input_thread_s * );
181 void ( * pf_init ) ( struct input_thread_s * );
182 void ( * pf_open ) ( struct input_thread_s * );
183 void ( * pf_close )( struct input_thread_s * );
184 void ( * pf_end ) ( struct input_thread_s * );
185 void ( * pf_init_bit_stream ) ( struct bit_stream_s *,
186 struct decoder_fifo_s *,
187 void (* pf_bitstream_callback)( struct bit_stream_s *,
191 int ( * pf_read ) ( struct input_thread_s *,
192 struct data_packet_s ** );
193 void ( * pf_demux )( struct input_thread_s *,
194 struct data_packet_s * );
196 struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
197 struct pes_packet_s * ( * pf_new_pes ) ( void * );
198 void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
199 void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
201 int ( * pf_set_program ) ( struct input_thread_s *,
202 struct pgrm_descriptor_s * );
204 int ( * pf_set_area ) ( struct input_thread_s *,
205 struct input_area_s * );
206 int ( * pf_rewind ) ( struct input_thread_s * );
207 void ( * pf_seek ) ( struct input_thread_s *, off_t );
210 /* Audio output plugin */
213 int ( * pf_open ) ( struct aout_thread_s * );
214 int ( * pf_setformat ) ( struct aout_thread_s * );
215 long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
216 void ( * pf_play ) ( struct aout_thread_s *, byte_t *, int );
217 void ( * pf_close ) ( struct aout_thread_s * );
220 /* Video output plugin */
223 int ( * pf_create ) ( struct vout_thread_s * );
224 int ( * pf_init ) ( struct vout_thread_s * );
225 void ( * pf_end ) ( struct vout_thread_s * );
226 void ( * pf_destroy ) ( struct vout_thread_s * );
227 int ( * pf_manage ) ( struct vout_thread_s * );
228 void ( * pf_render ) ( struct vout_thread_s *,
229 struct picture_s * );
230 void ( * pf_display ) ( struct vout_thread_s *,
231 struct picture_s * );
234 /* Motion compensation plugin */
237 void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
244 void ( * pf_idct_init ) ( void ** );
245 void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
247 void ( * pf_idct_add ) ( dctelem_t *, yuv_data_t *, int,
249 void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
251 void ( * pf_idct_copy ) ( dctelem_t *, yuv_data_t *, int,
253 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
256 /* Chroma transformation plugin */
259 int ( * pf_init ) ( struct vout_thread_s * );
260 void ( * pf_end ) ( struct vout_thread_s * );
266 void ( * pf_imdct_init ) ( struct imdct_s * );
267 void ( * pf_imdct_256 ) ( struct imdct_s *,
268 float data[], float delay[] );
269 void ( * pf_imdct_256_nol )( struct imdct_s *,
270 float data[], float delay[] );
271 void ( * pf_imdct_512 ) ( struct imdct_s *,
272 float data[], float delay[] );
273 void ( * pf_imdct_512_nol )( struct imdct_s *,
274 float data[], float delay[] );
275 // void ( * pf_fft_64p ) ( struct complex_s * );
279 /* AC3 downmix plugin */
282 void ( * pf_downmix_3f_2r_to_2ch ) ( float *, struct dm_par_s * );
283 void ( * pf_downmix_3f_1r_to_2ch ) ( float *, struct dm_par_s * );
284 void ( * pf_downmix_2f_2r_to_2ch ) ( float *, struct dm_par_s * );
285 void ( * pf_downmix_2f_1r_to_2ch ) ( float *, struct dm_par_s * );
286 void ( * pf_downmix_3f_0r_to_2ch ) ( float *, struct dm_par_s * );
287 void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
288 void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
292 /* Decoder plugins */
295 int ( * pf_probe)( u8 * p_es );
296 int ( * pf_run ) ( struct decoder_config_s * p_config );
302 void* ( * pf_memcpy ) ( void *, const void *, size_t );
303 void* ( * pf_memset ) ( void *, int, size_t );
310 typedef struct module_functions_s
312 /* XXX: The order here has to be the same as above for the #defines */
313 function_list_t intf;
314 function_list_t access;
315 function_list_t input;
316 function_list_t decaps;
318 function_list_t motion;
319 function_list_t idct;
320 function_list_t aout;
321 function_list_t vout;
322 function_list_t chroma;
323 function_list_t imdct;
324 function_list_t downmix;
325 function_list_t memcpy;
327 } module_functions_t;
329 typedef struct module_functions_s * p_module_functions_t;
331 /*****************************************************************************
332 * Exported functions.
333 *****************************************************************************/
335 void module_InitBank ( void );
336 void module_LoadMain ( void );
337 void module_LoadBuiltins ( void );
338 void module_LoadPlugins ( void );
339 void module_EndBank ( void );
340 void module_ResetBank ( void );
341 void module_ManageBank ( void );
342 module_t * module_Need ( int, char *, void * );
343 void module_Unneed ( module_t * p_module );
346 # define module_Need p_symbols->module_Need
347 # define module_Unneed p_symbols->module_Unneed