1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
6 * Authors: Samuel Hocevar <sam@zoy.org>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21 *****************************************************************************/
23 /* Number of tries before we unload an unused module */
24 #define MODULE_HIDE_DELAY 20
26 /* The module handle type. */
28 typedef int module_handle_t;
30 typedef void * module_handle_t;
33 /*****************************************************************************
34 * Module capabilities.
35 *****************************************************************************/
37 #define MODULE_CAPABILITY_NULL 0 /* The Module can't do anything */
38 #define MODULE_CAPABILITY_INTF 1 << 0 /* Interface */
39 #define MODULE_CAPABILITY_INPUT 1 << 1 /* Input */
40 #define MODULE_CAPABILITY_DECAPS 1 << 2 /* Decaps */
41 #define MODULE_CAPABILITY_ADEC 1 << 3 /* Audio decoder */
42 #define MODULE_CAPABILITY_VDEC 1 << 4 /* Video decoder */
43 #define MODULE_CAPABILITY_MOTION 1 << 5 /* Video decoder */
44 #define MODULE_CAPABILITY_IDCT 1 << 6 /* IDCT transformation */
45 #define MODULE_CAPABILITY_AOUT 1 << 7 /* Audio output */
46 #define MODULE_CAPABILITY_VOUT 1 << 8 /* Video output */
47 #define MODULE_CAPABILITY_YUV 1 << 9 /* YUV colorspace conversion */
48 #define MODULE_CAPABILITY_AFX 1 << 10 /* Audio effects */
49 #define MODULE_CAPABILITY_VFX 1 << 11 /* Video effects */
51 /* FIXME: not yet used */
52 typedef struct probedata_s
60 /* FIXME: find a nicer way to do this. */
61 typedef struct function_list_s
63 int ( * pf_probe ) ( probedata_t * p_data );
69 int ( * pf_open ) ( struct aout_thread_s * p_aout );
70 int ( * pf_setformat ) ( struct aout_thread_s * p_aout );
71 long ( * pf_getbufinfo ) ( struct aout_thread_s * p_aout,
73 void ( * pf_play ) ( struct aout_thread_s * p_aout,
74 byte_t *buffer, int i_size );
75 void ( * pf_close ) ( struct aout_thread_s * p_aout );
80 #define motion_functions( yuv ) \
81 void ( * pf_field_field_##yuv ) ( struct macroblock_s * ); \
82 void ( * pf_field_16x8_##yuv ) ( struct macroblock_s * ); \
83 void ( * pf_field_dmv_##yuv ) ( struct macroblock_s * ); \
84 void ( * pf_frame_field_##yuv ) ( struct macroblock_s * ); \
85 void ( * pf_frame_frame_##yuv ) ( struct macroblock_s * ); \
86 void ( * pf_frame_dmv_##yuv ) ( struct macroblock_s * );
87 motion_functions( 420 )
88 motion_functions( 422 )
89 motion_functions( 444 )
90 #undef motion_functions
95 void ( * pf_init ) ( struct vdec_thread_s * p_vdec );
96 void ( * pf_sparse_idct ) ( struct vdec_thread_s * p_vdec,
99 void ( * pf_idct ) ( struct vdec_thread_s * p_vdec,
102 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
107 int ( * pf_init ) ( struct vout_thread_s * p_vout );
108 int ( * pf_reset ) ( struct vout_thread_s * p_vout );
109 void ( * pf_end ) ( struct vout_thread_s * p_vout );
116 typedef struct module_functions_s
118 /* XXX: The order here has to be the same as above for the #defines */
119 function_list_t intf;
120 function_list_t input;
121 function_list_t decaps;
122 function_list_t adec;
123 function_list_t vdec;
124 function_list_t motion;
125 function_list_t idct;
126 function_list_t aout;
127 function_list_t vout;
132 } module_functions_t;
134 typedef struct module_functions_s * p_module_functions_t;
136 /*****************************************************************************
137 * Macros used to build the configuration structure.
138 *****************************************************************************/
140 /* Mandatory first and last parts of the structure */
141 #define MODULE_CONFIG_ITEM_START 0xdead /* The main window */
142 #define MODULE_CONFIG_ITEM_END 0xbeef /* End of the window */
144 /* Configuration widgets */
145 #define MODULE_CONFIG_ITEM_WINDOW 0x0001 /* The main window */
146 #define MODULE_CONFIG_ITEM_PANE 0x0002 /* A notebook pane */
147 #define MODULE_CONFIG_ITEM_FRAME 0x0003 /* A frame */
148 #define MODULE_CONFIG_ITEM_COMMENT 0x0004 /* A comment text */
149 #define MODULE_CONFIG_ITEM_STRING 0x0005 /* A string */
150 #define MODULE_CONFIG_ITEM_FILE 0x0006 /* A file selector */
151 #define MODULE_CONFIG_ITEM_CHECK 0x0007 /* A checkbox */
152 #define MODULE_CONFIG_ITEM_CHOOSE 0x0008 /* A choose box */
153 #define MODULE_CONFIG_ITEM_RADIO 0x0009 /* A radio box */
154 #define MODULE_CONFIG_ITEM_SCALE 0x000a /* A horizontal ruler */
155 #define MODULE_CONFIG_ITEM_SPIN 0x000b /* A numerical selector */
157 typedef struct module_config_s
159 int i_type; /* Configuration widget type */
160 char * psz_text; /* Text commenting or describing the widget */
161 char * psz_name; /* Variable name */
162 void * p_getlist; /* Function to call to get a choice list */
163 void * p_change; /* Function to call when commiting a change */
166 /*****************************************************************************
167 * Bank and module description structures
168 *****************************************************************************/
170 /* The module bank structure */
171 typedef struct module_bank_s
173 struct module_s * first; /* First module of the bank */
175 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful it
176 is to design thread-safe linked lists. */
179 /* The module description structure */
180 typedef struct module_s
182 boolean_t b_builtin; /* Set to true if the module is built in */
184 module_handle_t handle; /* Unique handle to refer to the module */
185 char * psz_filename; /* Module filename */
187 char * psz_name; /* Module _unique_ name */
188 char * psz_longname; /* Module descriptive name */
189 char * psz_version; /* Module version */
191 int i_usage; /* Reference counter */
192 int i_unused_delay; /* Delay until module is unloaded */
194 struct module_s * next; /* Next module */
195 struct module_s * prev; /* Previous module */
197 module_config_t * p_config; /* Module configuration structure table */
199 u32 i_capabilities; /* Capability list */
200 p_module_functions_t p_functions; /* Capability functions */
204 /*****************************************************************************
205 * Exported functions.
206 *****************************************************************************/
207 module_bank_t * module_CreateBank ( void );
208 void module_InitBank ( module_bank_t * p_bank );
209 void module_DestroyBank ( module_bank_t * p_bank );
210 void module_ResetBank ( module_bank_t * p_bank );
211 void module_ManageBank ( module_bank_t * p_bank );
213 module_t * module_Need ( module_bank_t *p_bank,
214 int i_capabilities, void *p_data );
215 void module_Unneed ( module_bank_t * p_bank,
216 module_t * p_module );