1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: modules.h,v 1.19 2001/03/21 13:42:33 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 /* Number of tries before we unload an unused module */
25 #define MODULE_HIDE_DELAY 100
27 /* The module handle type. */
29 typedef int module_handle_t;
31 typedef void * module_handle_t;
34 /*****************************************************************************
35 * Module capabilities.
36 *****************************************************************************/
38 #define MODULE_CAPABILITY_NULL 0 /* The Module can't do anything */
39 #define MODULE_CAPABILITY_INTF 1 << 0 /* Interface */
40 #define MODULE_CAPABILITY_ACCESS 1 << 1 /* Input */
41 #define MODULE_CAPABILITY_INPUT 1 << 2 /* Input */
42 #define MODULE_CAPABILITY_DECAPS 1 << 3 /* Decaps */
43 #define MODULE_CAPABILITY_ADEC 1 << 4 /* Audio decoder */
44 #define MODULE_CAPABILITY_VDEC 1 << 5 /* Video decoder */
45 #define MODULE_CAPABILITY_MOTION 1 << 6 /* Video decoder */
46 #define MODULE_CAPABILITY_IDCT 1 << 7 /* IDCT transformation */
47 #define MODULE_CAPABILITY_AOUT 1 << 8 /* Audio output */
48 #define MODULE_CAPABILITY_VOUT 1 << 9 /* Video output */
49 #define MODULE_CAPABILITY_YUV 1 << 10 /* YUV colorspace conversion */
50 #define MODULE_CAPABILITY_AFX 1 << 11 /* Audio effects */
51 #define MODULE_CAPABILITY_VFX 1 << 12 /* Video effects */
56 /* FIXME: not yet used */
57 typedef struct probedata_s
65 /* FIXME: find a nicer way to do this. */
66 typedef struct function_list_s
68 int ( * pf_probe ) ( probedata_t * p_data );
72 /* Interface plugin */
75 int ( * pf_open ) ( struct intf_thread_s * );
76 void ( * pf_close )( struct intf_thread_s * );
77 void ( * pf_run ) ( struct intf_thread_s * );
83 void ( * pf_init ) ( struct input_thread_s * );
84 void ( * pf_open ) ( struct input_thread_s * );
85 void ( * pf_close )( struct input_thread_s * );
86 void ( * pf_end ) ( struct input_thread_s * );
88 int ( * pf_read ) ( struct input_thread_s *,
89 struct data_packet_s *
91 void ( * pf_demux )( struct input_thread_s *,
92 struct data_packet_s * );
94 struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
95 struct pes_packet_s * ( * pf_new_pes ) ( void * );
96 void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
97 void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
100 int ( * pf_set_area ) ( struct input_thread_s *,
101 struct input_area_s * );
102 int ( * pf_rewind ) ( struct input_thread_s * );
103 void ( * pf_seek ) ( struct input_thread_s *, off_t );
106 /* Audio output plugin */
109 int ( * pf_open ) ( struct aout_thread_s * );
110 int ( * pf_setformat ) ( struct aout_thread_s * );
111 long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
112 void ( * pf_play ) ( struct aout_thread_s *, byte_t *, int );
113 void ( * pf_close ) ( struct aout_thread_s * );
116 /* Video output plugin */
119 int ( * pf_create ) ( struct vout_thread_s * );
120 int ( * pf_init ) ( struct vout_thread_s * );
121 void ( * pf_end ) ( struct vout_thread_s * );
122 void ( * pf_destroy ) ( struct vout_thread_s * );
123 int ( * pf_manage ) ( struct vout_thread_s * );
124 void ( * pf_display ) ( struct vout_thread_s * );
125 void ( * pf_setpalette ) ( struct vout_thread_s *, u16 *red,
126 u16 *green, u16 *blue, u16 *transp );
129 /* Motion compensation plugin */
132 #define motion_functions( yuv ) \
133 void ( * pf_field_field_##yuv ) ( struct macroblock_s * ); \
134 void ( * pf_field_16x8_##yuv ) ( struct macroblock_s * ); \
135 void ( * pf_field_dmv_##yuv ) ( struct macroblock_s * ); \
136 void ( * pf_frame_field_##yuv ) ( struct macroblock_s * ); \
137 void ( * pf_frame_frame_##yuv ) ( struct macroblock_s * ); \
138 void ( * pf_frame_dmv_##yuv ) ( struct macroblock_s * );
139 motion_functions( 420 )
140 motion_functions( 422 )
141 motion_functions( 444 )
142 #undef motion_functions
148 void ( * pf_init ) ( struct vdec_thread_s * );
149 void ( * pf_sparse_idct ) ( struct vdec_thread_s *,
151 void ( * pf_idct ) ( struct vdec_thread_s *,
153 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
156 /* YUV transformation plugin */
159 int ( * pf_init ) ( struct vout_thread_s * );
160 int ( * pf_reset ) ( struct vout_thread_s * );
161 void ( * pf_end ) ( struct vout_thread_s * );
168 typedef struct module_functions_s
170 /* XXX: The order here has to be the same as above for the #defines */
171 function_list_t intf;
172 function_list_t access;
173 function_list_t input;
174 function_list_t decaps;
175 function_list_t adec;
176 function_list_t vdec;
177 function_list_t motion;
178 function_list_t idct;
179 function_list_t aout;
180 function_list_t vout;
185 } module_functions_t;
187 typedef struct module_functions_s * p_module_functions_t;
189 /*****************************************************************************
190 * Macros used to build the configuration structure.
191 *****************************************************************************/
193 /* Mandatory first and last parts of the structure */
194 #define MODULE_CONFIG_ITEM_START 0xdead /* The main window */
195 #define MODULE_CONFIG_ITEM_END 0xbeef /* End of the window */
197 /* Configuration widgets */
198 #define MODULE_CONFIG_ITEM_WINDOW 0x0001 /* The main window */
199 #define MODULE_CONFIG_ITEM_PANE 0x0002 /* A notebook pane */
200 #define MODULE_CONFIG_ITEM_FRAME 0x0003 /* A frame */
201 #define MODULE_CONFIG_ITEM_COMMENT 0x0004 /* A comment text */
202 #define MODULE_CONFIG_ITEM_STRING 0x0005 /* A string */
203 #define MODULE_CONFIG_ITEM_FILE 0x0006 /* A file selector */
204 #define MODULE_CONFIG_ITEM_CHECK 0x0007 /* A checkbox */
205 #define MODULE_CONFIG_ITEM_CHOOSE 0x0008 /* A choose box */
206 #define MODULE_CONFIG_ITEM_RADIO 0x0009 /* A radio box */
207 #define MODULE_CONFIG_ITEM_SCALE 0x000a /* A horizontal ruler */
208 #define MODULE_CONFIG_ITEM_SPIN 0x000b /* A numerical selector */
210 typedef struct module_config_s
212 int i_type; /* Configuration widget type */
213 char * psz_text; /* Text commenting or describing the widget */
214 char * psz_name; /* Variable name */
215 void * p_getlist; /* Function to call to get a choice list */
216 void * p_change; /* Function to call when commiting a change */
219 /*****************************************************************************
220 * Bank and module description structures
221 *****************************************************************************/
223 /* The module bank structure */
224 typedef struct module_bank_s
226 struct module_s * first; /* First module of the bank */
228 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful it
229 is to design thread-safe linked lists. */
232 /* The module description structure */
233 typedef struct module_s
235 boolean_t b_builtin; /* Set to true if the module is built in */
237 module_handle_t handle; /* Unique handle to refer to the module */
238 char * psz_filename; /* Module filename */
240 char * psz_name; /* Module _unique_ name */
241 char * psz_longname; /* Module descriptive name */
242 char * psz_version; /* Module version */
244 int i_usage; /* Reference counter */
245 int i_unused_delay; /* Delay until module is unloaded */
247 struct module_s * next; /* Next module */
248 struct module_s * prev; /* Previous module */
250 module_config_t * p_config; /* Module configuration structure table */
252 u32 i_capabilities; /* Capability list */
253 p_module_functions_t p_functions; /* Capability functions */
257 /*****************************************************************************
258 * Exported functions.
259 *****************************************************************************/
260 module_bank_t * module_CreateBank ( void );
261 void module_InitBank ( module_bank_t * p_bank );
262 void module_DestroyBank ( module_bank_t * p_bank );
263 void module_ResetBank ( module_bank_t * p_bank );
264 void module_ManageBank ( module_bank_t * p_bank );
266 module_t * module_Need ( module_bank_t *p_bank,
267 int i_capabilities, void *p_data );
268 void module_Unneed ( module_bank_t * p_bank,
269 module_t * p_module );