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_ACCESS 1 << 1 /* Input */
40 #define MODULE_CAPABILITY_INPUT 1 << 2 /* Input */
41 #define MODULE_CAPABILITY_DECAPS 1 << 3 /* Decaps */
42 #define MODULE_CAPABILITY_ADEC 1 << 4 /* Audio decoder */
43 #define MODULE_CAPABILITY_VDEC 1 << 5 /* Video decoder */
44 #define MODULE_CAPABILITY_MOTION 1 << 6 /* Video decoder */
45 #define MODULE_CAPABILITY_IDCT 1 << 7 /* IDCT transformation */
46 #define MODULE_CAPABILITY_AOUT 1 << 8 /* Audio output */
47 #define MODULE_CAPABILITY_VOUT 1 << 9 /* Video output */
48 #define MODULE_CAPABILITY_YUV 1 << 10 /* YUV colorspace conversion */
49 #define MODULE_CAPABILITY_AFX 1 << 11 /* Audio effects */
50 #define MODULE_CAPABILITY_VFX 1 << 12 /* Video effects */
52 /* FIXME: not yet used */
53 typedef struct probedata_s
61 /* FIXME: find a nicer way to do this. */
62 typedef struct function_list_s
64 int ( * pf_probe ) ( probedata_t * p_data );
68 /* Interface plugin */
71 int ( * pf_open ) ( struct intf_thread_s * );
72 void ( * pf_close )( struct intf_thread_s * );
73 void ( * pf_run ) ( struct intf_thread_s * );
79 void ( * pf_init ) ( struct input_thread_s * );
80 void ( * pf_open ) ( struct input_thread_s * );
81 void ( * pf_close )( struct input_thread_s * );
82 void ( * pf_end ) ( struct input_thread_s * );
84 int ( * pf_set_area ) ( struct input_thread_s *,
87 int ( * pf_read ) ( struct input_thread_s *,
88 struct data_packet_s *
90 void ( * pf_demux )( struct input_thread_s *,
91 struct data_packet_s * );
93 struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
94 struct pes_packet_s * ( * pf_new_pes ) ( void * );
95 void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
96 void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
98 int ( * pf_rewind ) ( struct input_thread_s * );
99 void ( * pf_seek ) ( struct input_thread_s *, off_t );
102 /* Audio output plugin */
105 int ( * pf_open ) ( struct aout_thread_s * );
106 int ( * pf_setformat ) ( struct aout_thread_s * );
107 long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
108 void ( * pf_play ) ( struct aout_thread_s *, byte_t *, int );
109 void ( * pf_close ) ( struct aout_thread_s * );
112 /* Video output plugin */
115 int ( * pf_create ) ( struct vout_thread_s * );
116 int ( * pf_init ) ( struct vout_thread_s * );
117 void ( * pf_end ) ( struct vout_thread_s * );
118 void ( * pf_destroy ) ( struct vout_thread_s * );
119 int ( * pf_manage ) ( struct vout_thread_s * );
120 void ( * pf_display ) ( struct vout_thread_s * );
121 void ( * pf_setpalette ) ( struct vout_thread_s *, u16 *red,
122 u16 *green, u16 *blue, u16 *transp );
125 /* Motion compensation plugin */
128 #define motion_functions( yuv ) \
129 void ( * pf_field_field_##yuv ) ( struct macroblock_s * ); \
130 void ( * pf_field_16x8_##yuv ) ( struct macroblock_s * ); \
131 void ( * pf_field_dmv_##yuv ) ( struct macroblock_s * ); \
132 void ( * pf_frame_field_##yuv ) ( struct macroblock_s * ); \
133 void ( * pf_frame_frame_##yuv ) ( struct macroblock_s * ); \
134 void ( * pf_frame_dmv_##yuv ) ( struct macroblock_s * );
135 motion_functions( 420 )
136 motion_functions( 422 )
137 motion_functions( 444 )
138 #undef motion_functions
144 void ( * pf_init ) ( struct vdec_thread_s * );
145 void ( * pf_sparse_idct ) ( struct vdec_thread_s *,
147 void ( * pf_idct ) ( struct vdec_thread_s *,
149 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
152 /* YUV transformation plugin */
155 int ( * pf_init ) ( struct vout_thread_s * );
156 int ( * pf_reset ) ( struct vout_thread_s * );
157 void ( * pf_end ) ( struct vout_thread_s * );
164 typedef struct module_functions_s
166 /* XXX: The order here has to be the same as above for the #defines */
167 function_list_t intf;
168 function_list_t access;
169 function_list_t input;
170 function_list_t decaps;
171 function_list_t adec;
172 function_list_t vdec;
173 function_list_t motion;
174 function_list_t idct;
175 function_list_t aout;
176 function_list_t vout;
181 } module_functions_t;
183 typedef struct module_functions_s * p_module_functions_t;
185 /*****************************************************************************
186 * Macros used to build the configuration structure.
187 *****************************************************************************/
189 /* Mandatory first and last parts of the structure */
190 #define MODULE_CONFIG_ITEM_START 0xdead /* The main window */
191 #define MODULE_CONFIG_ITEM_END 0xbeef /* End of the window */
193 /* Configuration widgets */
194 #define MODULE_CONFIG_ITEM_WINDOW 0x0001 /* The main window */
195 #define MODULE_CONFIG_ITEM_PANE 0x0002 /* A notebook pane */
196 #define MODULE_CONFIG_ITEM_FRAME 0x0003 /* A frame */
197 #define MODULE_CONFIG_ITEM_COMMENT 0x0004 /* A comment text */
198 #define MODULE_CONFIG_ITEM_STRING 0x0005 /* A string */
199 #define MODULE_CONFIG_ITEM_FILE 0x0006 /* A file selector */
200 #define MODULE_CONFIG_ITEM_CHECK 0x0007 /* A checkbox */
201 #define MODULE_CONFIG_ITEM_CHOOSE 0x0008 /* A choose box */
202 #define MODULE_CONFIG_ITEM_RADIO 0x0009 /* A radio box */
203 #define MODULE_CONFIG_ITEM_SCALE 0x000a /* A horizontal ruler */
204 #define MODULE_CONFIG_ITEM_SPIN 0x000b /* A numerical selector */
206 typedef struct module_config_s
208 int i_type; /* Configuration widget type */
209 char * psz_text; /* Text commenting or describing the widget */
210 char * psz_name; /* Variable name */
211 void * p_getlist; /* Function to call to get a choice list */
212 void * p_change; /* Function to call when commiting a change */
215 /*****************************************************************************
216 * Bank and module description structures
217 *****************************************************************************/
219 /* The module bank structure */
220 typedef struct module_bank_s
222 struct module_s * first; /* First module of the bank */
224 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful it
225 is to design thread-safe linked lists. */
228 /* The module description structure */
229 typedef struct module_s
231 boolean_t b_builtin; /* Set to true if the module is built in */
233 module_handle_t handle; /* Unique handle to refer to the module */
234 char * psz_filename; /* Module filename */
236 char * psz_name; /* Module _unique_ name */
237 char * psz_longname; /* Module descriptive name */
238 char * psz_version; /* Module version */
240 int i_usage; /* Reference counter */
241 int i_unused_delay; /* Delay until module is unloaded */
243 struct module_s * next; /* Next module */
244 struct module_s * prev; /* Previous module */
246 module_config_t * p_config; /* Module configuration structure table */
248 u32 i_capabilities; /* Capability list */
249 p_module_functions_t p_functions; /* Capability functions */
253 /*****************************************************************************
254 * Exported functions.
255 *****************************************************************************/
256 module_bank_t * module_CreateBank ( void );
257 void module_InitBank ( module_bank_t * p_bank );
258 void module_DestroyBank ( module_bank_t * p_bank );
259 void module_ResetBank ( module_bank_t * p_bank );
260 void module_ManageBank ( module_bank_t * p_bank );
262 module_t * module_Need ( module_bank_t *p_bank,
263 int i_capabilities, void *p_data );
264 void module_Unneed ( module_bank_t * p_bank,
265 module_t * p_module );