* ./BUGS: added a list of known bugs. Please add your findings!
[vlc.git] / include / modules.h
blob26e142c93d81620bcf871fc0634adc16fa9115ab
1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: modules.h,v 1.39 2002/01/04 14:01:34 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 /*****************************************************************************
25 * Module #defines.
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. */
33 #ifdef SYS_BEOS
34 typedef int module_handle_t;
35 #else
36 typedef void * module_handle_t;
37 #endif
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
46 * new capability. */
47 static char *pp_capa[] =
49 "interface",
50 #define MODULE_CAPABILITY_INTF 0 /* Interface */
51 "access",
52 #define MODULE_CAPABILITY_ACCESS 1 /* Input */
53 "input",
54 #define MODULE_CAPABILITY_INPUT 2 /* Input */
55 "decaps",
56 #define MODULE_CAPABILITY_DECAPS 3 /* Decaps */
57 "decoder",
58 #define MODULE_CAPABILITY_DECODER 4 /* Audio or video decoder */
59 "motion",
60 #define MODULE_CAPABILITY_MOTION 5 /* Motion compensation */
61 "iDCT",
62 #define MODULE_CAPABILITY_IDCT 6 /* IDCT transformation */
63 "audio output",
64 #define MODULE_CAPABILITY_AOUT 7 /* Audio output */
65 "video output",
66 #define MODULE_CAPABILITY_VOUT 8 /* Video output */
67 "chroma transformation",
68 #define MODULE_CAPABILITY_CHROMA 9 /* colorspace conversion */
69 "iMDCT",
70 #define MODULE_CAPABILITY_IMDCT 10 /* IMDCT transformation */
71 "downmix",
72 #define MODULE_CAPABILITY_DOWNMIX 11 /* AC3 downmix */
73 "memcpy",
74 #define MODULE_CAPABILITY_MEMCPY 12 /* memcpy */
75 "unknown"
76 #define MODULE_CAPABILITY_MAX 13 /* Total number of capabilities */
79 return pp_capa[ (i_capa) > MODULE_CAPABILITY_MAX ? MODULE_CAPABILITY_MAX :
80 (i_capa) ];
83 /*****************************************************************************
84 * module_bank_t, p_module_bank (global variable)
85 *****************************************************************************
86 * This global variable is accessed by any function using modules.
87 *****************************************************************************/
88 typedef struct
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 */
95 } module_bank_t;
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 */
129 union
131 struct
133 module_handle_t handle; /* Unique handle */
134 char * psz_filename; /* Module filename */
136 } plugin;
138 struct
140 int ( *pf_deactivate ) ( struct module_s * );
142 } builtin;
144 } is;
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;
157 } module_t;
159 /*****************************************
160 * FIXME
161 * FIXME Capabilities
162 * FIXME
163 *******************************************/
164 typedef struct memcpy_module_s
166 struct module_s *p_module;
168 void* ( *pf_memcpy ) ( void *, const void *, size_t );
170 } memcpy_module_t;
172 typedef struct probedata_s
174 u8 i_type;
176 struct
178 char * psz_data;
179 } aout;
181 struct
183 u32 i_chroma;
184 } vout;
186 struct
188 struct picture_heap_s* p_output;
189 struct picture_heap_s* p_render;
190 } chroma;
192 } probedata_t;
194 /* FIXME: find a nicer way to do this. */
195 typedef struct function_list_s
197 int ( * pf_probe ) ( probedata_t * p_data );
199 union
201 /* Interface plugin */
202 struct
204 int ( * pf_open ) ( struct intf_thread_s * );
205 void ( * pf_close )( struct intf_thread_s * );
206 void ( * pf_run ) ( struct intf_thread_s * );
207 } intf;
209 /* Input plugin */
210 struct
212 void ( * pf_init ) ( struct input_thread_s * );
213 void ( * pf_open ) ( struct input_thread_s * );
214 void ( * pf_close )( struct input_thread_s * );
215 void ( * pf_end ) ( struct input_thread_s * );
216 void ( * pf_init_bit_stream ) ( struct bit_stream_s *,
217 struct decoder_fifo_s *,
218 void (* pf_bitstream_callback)( struct bit_stream_s *,
219 boolean_t ),
220 void * );
222 int ( * pf_read ) ( struct input_thread_s *,
223 struct data_packet_s ** );
224 void ( * pf_demux )( struct input_thread_s *,
225 struct data_packet_s * );
227 struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
228 struct pes_packet_s * ( * pf_new_pes ) ( void * );
229 void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
230 void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
232 int ( * pf_set_program ) ( struct input_thread_s *,
233 struct pgrm_descriptor_s * );
235 int ( * pf_set_area ) ( struct input_thread_s *,
236 struct input_area_s * );
237 int ( * pf_rewind ) ( struct input_thread_s * );
238 void ( * pf_seek ) ( struct input_thread_s *, off_t );
239 } input;
241 /* Audio output plugin */
242 struct
244 int ( * pf_open ) ( struct aout_thread_s * );
245 int ( * pf_setformat ) ( struct aout_thread_s * );
246 long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
247 void ( * pf_play ) ( struct aout_thread_s *, byte_t *, int );
248 void ( * pf_close ) ( struct aout_thread_s * );
249 } aout;
251 /* Video output plugin */
252 struct
254 int ( * pf_create ) ( struct vout_thread_s * );
255 int ( * pf_init ) ( struct vout_thread_s * );
256 void ( * pf_end ) ( struct vout_thread_s * );
257 void ( * pf_destroy ) ( struct vout_thread_s * );
258 int ( * pf_manage ) ( struct vout_thread_s * );
259 void ( * pf_render ) ( struct vout_thread_s *,
260 struct picture_s * );
261 void ( * pf_display ) ( struct vout_thread_s *,
262 struct picture_s * );
263 void ( * pf_setpalette ) ( struct vout_thread_s *,
264 u16 *, u16 *, u16 * );
265 } vout;
267 /* Motion compensation plugin */
268 struct
270 void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
271 int, int );
272 } motion;
274 /* IDCT plugin */
275 struct
277 void ( * pf_idct_init ) ( void ** );
278 void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
279 void *, int );
280 void ( * pf_idct_add ) ( dctelem_t *, yuv_data_t *, int,
281 void *, int );
282 void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
283 void *, int );
284 void ( * pf_idct_copy ) ( dctelem_t *, yuv_data_t *, int,
285 void *, int );
286 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
287 } idct;
289 /* Chroma transformation plugin */
290 struct
292 int ( * pf_init ) ( struct vout_thread_s * );
293 void ( * pf_end ) ( struct vout_thread_s * );
294 } chroma;
296 /* IMDCT plugin */
297 struct
299 void ( * pf_imdct_init ) ( struct imdct_s * );
300 void ( * pf_imdct_256 ) ( struct imdct_s *,
301 float data[], float delay[] );
302 void ( * pf_imdct_256_nol )( struct imdct_s *,
303 float data[], float delay[] );
304 void ( * pf_imdct_512 ) ( struct imdct_s *,
305 float data[], float delay[] );
306 void ( * pf_imdct_512_nol )( struct imdct_s *,
307 float data[], float delay[] );
308 // void ( * pf_fft_64p ) ( struct complex_s * );
310 } imdct;
312 /* AC3 downmix plugin */
313 struct
315 void ( * pf_downmix_3f_2r_to_2ch ) ( float *, struct dm_par_s * );
316 void ( * pf_downmix_3f_1r_to_2ch ) ( float *, struct dm_par_s * );
317 void ( * pf_downmix_2f_2r_to_2ch ) ( float *, struct dm_par_s * );
318 void ( * pf_downmix_2f_1r_to_2ch ) ( float *, struct dm_par_s * );
319 void ( * pf_downmix_3f_0r_to_2ch ) ( float *, struct dm_par_s * );
320 void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
321 void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
323 } downmix;
325 /* Decoder plugins */
326 struct
328 int ( * pf_run ) ( struct decoder_config_s * p_config );
329 } dec;
331 /* memcpy plugins */
332 struct
334 void* ( * fast_memcpy ) ( void *, const void *, size_t );
335 } memcpy;
337 } functions;
339 } function_list_t;
341 typedef struct module_functions_s
343 /* XXX: The order here has to be the same as above for the #defines */
344 function_list_t intf;
345 function_list_t access;
346 function_list_t input;
347 function_list_t decaps;
348 function_list_t dec;
349 function_list_t motion;
350 function_list_t idct;
351 function_list_t aout;
352 function_list_t vout;
353 function_list_t chroma;
354 function_list_t imdct;
355 function_list_t downmix;
356 function_list_t memcpy;
358 } module_functions_t;
360 typedef struct module_functions_s * p_module_functions_t;
362 /*****************************************************************************
363 * Macros used to build the configuration structure.
364 *****************************************************************************/
366 /* Mandatory first and last parts of the structure */
367 #define MODULE_CONFIG_ITEM_START 0xdead /* The main window */
368 #define MODULE_CONFIG_ITEM_END 0xbeef /* End of the window */
370 /* Configuration widgets */
371 #define MODULE_CONFIG_ITEM_WINDOW 0x0001 /* The main window */
372 #define MODULE_CONFIG_ITEM_PANE 0x0002 /* A notebook pane */
373 #define MODULE_CONFIG_ITEM_FRAME 0x0003 /* A frame */
374 #define MODULE_CONFIG_ITEM_COMMENT 0x0004 /* A comment text */
375 #define MODULE_CONFIG_ITEM_STRING 0x0005 /* A string */
376 #define MODULE_CONFIG_ITEM_FILE 0x0006 /* A file selector */
377 #define MODULE_CONFIG_ITEM_CHECK 0x0007 /* A checkbox */
378 #define MODULE_CONFIG_ITEM_CHOOSE 0x0008 /* A choose box */
379 #define MODULE_CONFIG_ITEM_RADIO 0x0009 /* A radio box */
380 #define MODULE_CONFIG_ITEM_SCALE 0x000a /* A horizontal ruler */
381 #define MODULE_CONFIG_ITEM_SPIN 0x000b /* A numerical selector */
383 typedef struct module_config_s
385 int i_type; /* Configuration widget type */
386 char * psz_text; /* Text commenting or describing the widget */
387 char * psz_name; /* Variable name */
388 void * p_getlist; /* Function to call to get a choice list */
389 void * p_change; /* Function to call when commiting a change */
390 } module_config_t;
392 /*****************************************************************************
393 * Exported functions.
394 *****************************************************************************/
395 #ifndef PLUGIN
396 void module_InitBank ( void );
397 void module_EndBank ( void );
398 void module_ResetBank ( void );
399 void module_ManageBank ( void );
400 module_t * module_Need ( int, char *, probedata_t * );
401 void module_Unneed ( module_t * p_module );
403 int module_NeedMemcpy( memcpy_module_t * );
404 void module_UnneedMemcpy( memcpy_module_t * );
406 #else
407 # define module_Need p_symbols->module_Need
408 # define module_Unneed p_symbols->module_Unneed
409 #endif