1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: modules.h,v 1.38 2001/12/30 07:09:54 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 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_INTF 0 /* Interface */
52 #define MODULE_CAPABILITY_ACCESS 1 /* Input */
54 #define MODULE_CAPABILITY_INPUT 2 /* Input */
56 #define MODULE_CAPABILITY_DECAPS 3 /* Decaps */
58 #define MODULE_CAPABILITY_DECODER 4 /* Audio or video decoder */
60 #define MODULE_CAPABILITY_MOTION 5 /* Motion compensation */
62 #define MODULE_CAPABILITY_IDCT 6 /* IDCT transformation */
64 #define MODULE_CAPABILITY_AOUT 7 /* Audio output */
66 #define MODULE_CAPABILITY_VOUT 8 /* Video output */
67 "chroma transformation",
68 #define MODULE_CAPABILITY_CHROMA 9 /* colorspace conversion */
70 #define MODULE_CAPABILITY_IMDCT 10 /* IMDCT transformation */
72 #define MODULE_CAPABILITY_DOWNMIX 11 /* AC3 downmix */
74 #define MODULE_CAPABILITY_MEMCPY 12 /* memcpy */
76 #define MODULE_CAPABILITY_MAX 13 /* Total number of capabilities */
79 return pp_capa[ (i_capa) > MODULE_CAPABILITY_MAX ? MODULE_CAPABILITY_MAX :
83 /*****************************************************************************
84 * module_bank_t, p_module_bank (global variable)
85 *****************************************************************************
86 * This global variable is accessed by any function using modules.
87 *****************************************************************************/
90 struct module_s * first; /* First module in the bank */
91 int i_count; /* Number of allocated modules */
93 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful *
94 it is to design thread-safe linked lists */
97 extern module_bank_t *p_module_bank;
99 /*****************************************************************************
100 * Module description structure
101 *****************************************************************************/
102 typedef struct module_s
105 * Variables set by the module to identify itself
107 char *psz_name; /* Module _unique_ name */
108 char *psz_longname; /* Module descriptive name */
111 * Variables set by the module to tell us what it can do
113 char *psz_program; /* Program name which will activate the module */
114 char *pp_shortcuts[ MODULE_SHORTCUT_MAX ]; /* Shortcuts to the module */
116 u32 i_capabilities; /* Capability list */
117 int pi_score[ MODULE_CAPABILITY_MAX ]; /* Score for each capability */
119 u32 i_cpu_capabilities; /* Required CPU capabilities */
121 struct module_functions_s *p_functions; /* Capability functions */
122 struct module_config_s *p_config; /* Module configuration structure */
125 * Variables used internally by the module manager
127 boolean_t b_builtin; /* Set to true if the module is built in */
133 module_handle_t handle; /* Unique handle */
134 char * psz_filename; /* Module filename */
140 int ( *pf_deactivate ) ( struct module_s * );
146 int i_usage; /* Reference counter */
147 int i_unused_delay; /* Delay until module is unloaded */
149 struct module_s *next; /* Next module */
150 struct module_s *prev; /* Previous module */
153 * Symbol table we send to the module so that it can access vlc symbols
155 struct module_symbols_s *p_symbols;
159 /*****************************************
163 *******************************************/
164 typedef struct memcpy_module_s
166 struct module_s *p_module;
168 void* ( *pf_memcpy ) ( void *, const void *, size_t );
172 /* FIXME: not yet used */
173 typedef struct probedata_s
183 struct picture_heap_s* p_output;
184 struct picture_heap_s* p_render;
189 /* FIXME: find a nicer way to do this. */
190 typedef struct function_list_s
192 int ( * pf_probe ) ( probedata_t * p_data );
196 /* Interface plugin */
199 int ( * pf_open ) ( struct intf_thread_s * );
200 void ( * pf_close )( struct intf_thread_s * );
201 void ( * pf_run ) ( struct intf_thread_s * );
207 void ( * pf_init ) ( struct input_thread_s * );
208 void ( * pf_open ) ( struct input_thread_s * );
209 void ( * pf_close )( struct input_thread_s * );
210 void ( * pf_end ) ( struct input_thread_s * );
211 void ( * pf_init_bit_stream ) ( struct bit_stream_s *,
212 struct decoder_fifo_s *,
213 void (* pf_bitstream_callback)( struct bit_stream_s *,
217 int ( * pf_read ) ( struct input_thread_s *,
218 struct data_packet_s ** );
219 void ( * pf_demux )( struct input_thread_s *,
220 struct data_packet_s * );
222 struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
223 struct pes_packet_s * ( * pf_new_pes ) ( void * );
224 void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
225 void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
227 int ( * pf_set_program ) ( struct input_thread_s *,
228 struct pgrm_descriptor_s * );
230 int ( * pf_set_area ) ( struct input_thread_s *,
231 struct input_area_s * );
232 int ( * pf_rewind ) ( struct input_thread_s * );
233 void ( * pf_seek ) ( struct input_thread_s *, off_t );
236 /* Audio output plugin */
239 int ( * pf_open ) ( struct aout_thread_s * );
240 int ( * pf_setformat ) ( struct aout_thread_s * );
241 long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
242 void ( * pf_play ) ( struct aout_thread_s *, byte_t *, int );
243 void ( * pf_close ) ( struct aout_thread_s * );
246 /* Video output plugin */
249 int ( * pf_create ) ( struct vout_thread_s * );
250 int ( * pf_init ) ( struct vout_thread_s * );
251 void ( * pf_end ) ( struct vout_thread_s * );
252 void ( * pf_destroy ) ( struct vout_thread_s * );
253 int ( * pf_manage ) ( struct vout_thread_s * );
254 void ( * pf_display ) ( struct vout_thread_s *,
255 struct picture_s * );
256 void ( * pf_setpalette ) ( struct vout_thread_s *,
257 u16 *, u16 *, u16 * );
260 /* Motion compensation plugin */
263 void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
270 void ( * pf_idct_init ) ( void ** );
271 void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
273 void ( * pf_idct_add ) ( dctelem_t *, yuv_data_t *, int,
275 void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
277 void ( * pf_idct_copy ) ( dctelem_t *, yuv_data_t *, int,
279 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
282 /* Chroma transformation plugin */
285 int ( * pf_init ) ( struct vout_thread_s * );
286 void ( * pf_end ) ( struct vout_thread_s * );
292 void ( * pf_imdct_init ) ( struct imdct_s * );
293 void ( * pf_imdct_256 ) ( struct imdct_s *,
294 float data[], float delay[] );
295 void ( * pf_imdct_256_nol )( struct imdct_s *,
296 float data[], float delay[] );
297 void ( * pf_imdct_512 ) ( struct imdct_s *,
298 float data[], float delay[] );
299 void ( * pf_imdct_512_nol )( struct imdct_s *,
300 float data[], float delay[] );
301 // void ( * pf_fft_64p ) ( struct complex_s * );
305 /* AC3 downmix plugin */
308 void ( * pf_downmix_3f_2r_to_2ch ) ( float *, struct dm_par_s * );
309 void ( * pf_downmix_3f_1r_to_2ch ) ( float *, struct dm_par_s * );
310 void ( * pf_downmix_2f_2r_to_2ch ) ( float *, struct dm_par_s * );
311 void ( * pf_downmix_2f_1r_to_2ch ) ( float *, struct dm_par_s * );
312 void ( * pf_downmix_3f_0r_to_2ch ) ( float *, struct dm_par_s * );
313 void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
314 void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
318 /* Decoder plugins */
321 int ( * pf_run ) ( struct decoder_config_s * p_config );
327 void* ( * fast_memcpy ) ( void *, const void *, size_t );
334 typedef struct module_functions_s
336 /* XXX: The order here has to be the same as above for the #defines */
337 function_list_t intf;
338 function_list_t access;
339 function_list_t input;
340 function_list_t decaps;
342 function_list_t motion;
343 function_list_t idct;
344 function_list_t aout;
345 function_list_t vout;
346 function_list_t chroma;
347 function_list_t imdct;
348 function_list_t downmix;
349 function_list_t memcpy;
351 } module_functions_t;
353 typedef struct module_functions_s * p_module_functions_t;
355 /*****************************************************************************
356 * Macros used to build the configuration structure.
357 *****************************************************************************/
359 /* Mandatory first and last parts of the structure */
360 #define MODULE_CONFIG_ITEM_START 0xdead /* The main window */
361 #define MODULE_CONFIG_ITEM_END 0xbeef /* End of the window */
363 /* Configuration widgets */
364 #define MODULE_CONFIG_ITEM_WINDOW 0x0001 /* The main window */
365 #define MODULE_CONFIG_ITEM_PANE 0x0002 /* A notebook pane */
366 #define MODULE_CONFIG_ITEM_FRAME 0x0003 /* A frame */
367 #define MODULE_CONFIG_ITEM_COMMENT 0x0004 /* A comment text */
368 #define MODULE_CONFIG_ITEM_STRING 0x0005 /* A string */
369 #define MODULE_CONFIG_ITEM_FILE 0x0006 /* A file selector */
370 #define MODULE_CONFIG_ITEM_CHECK 0x0007 /* A checkbox */
371 #define MODULE_CONFIG_ITEM_CHOOSE 0x0008 /* A choose box */
372 #define MODULE_CONFIG_ITEM_RADIO 0x0009 /* A radio box */
373 #define MODULE_CONFIG_ITEM_SCALE 0x000a /* A horizontal ruler */
374 #define MODULE_CONFIG_ITEM_SPIN 0x000b /* A numerical selector */
376 typedef struct module_config_s
378 int i_type; /* Configuration widget type */
379 char * psz_text; /* Text commenting or describing the widget */
380 char * psz_name; /* Variable name */
381 void * p_getlist; /* Function to call to get a choice list */
382 void * p_change; /* Function to call when commiting a change */
385 /*****************************************************************************
386 * Exported functions.
387 *****************************************************************************/
389 void module_InitBank ( void );
390 void module_EndBank ( void );
391 void module_ResetBank ( void );
392 void module_ManageBank ( void );
393 module_t * module_Need ( int, char *, probedata_t * );
394 void module_Unneed ( module_t * p_module );
396 int module_NeedMemcpy( memcpy_module_t * );
397 void module_UnneedMemcpy( memcpy_module_t * );
400 # define module_Need p_symbols->module_Need
401 # define module_Unneed p_symbols->module_Unneed