1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 VideoLAN
5 * $Id: modules.h,v 1.21 2001/04/28 03:36:25 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 *****************************************************************************/
25 #include <sys/types.h> /* off_t */
28 /* Number of tries before we unload an unused module */
29 #define MODULE_HIDE_DELAY 100
31 /* The module handle type. */
33 typedef int module_handle_t;
35 typedef void * module_handle_t;
38 /*****************************************************************************
39 * Module capabilities.
40 *****************************************************************************/
42 #define MODULE_CAPABILITY_NULL 0 /* The Module can't do anything */
43 #define MODULE_CAPABILITY_INTF 1 << 0 /* Interface */
44 #define MODULE_CAPABILITY_ACCESS 1 << 1 /* Input */
45 #define MODULE_CAPABILITY_INPUT 1 << 2 /* Input */
46 #define MODULE_CAPABILITY_DECAPS 1 << 3 /* Decaps */
47 #define MODULE_CAPABILITY_ADEC 1 << 4 /* Audio decoder */
48 #define MODULE_CAPABILITY_VDEC 1 << 5 /* Video decoder */
49 #define MODULE_CAPABILITY_MOTION 1 << 6 /* Video decoder */
50 #define MODULE_CAPABILITY_IDCT 1 << 7 /* IDCT transformation */
51 #define MODULE_CAPABILITY_AOUT 1 << 8 /* Audio output */
52 #define MODULE_CAPABILITY_VOUT 1 << 9 /* Video output */
53 #define MODULE_CAPABILITY_YUV 1 << 10 /* YUV colorspace conversion */
54 #define MODULE_CAPABILITY_AFX 1 << 11 /* Audio effects */
55 #define MODULE_CAPABILITY_VFX 1 << 12 /* Video effects */
60 /* FIXME: not yet used */
61 typedef struct probedata_s
69 /* FIXME: find a nicer way to do this. */
70 typedef struct function_list_s
72 int ( * pf_probe ) ( probedata_t * p_data );
76 /* Interface plugin */
79 int ( * pf_open ) ( struct intf_thread_s * );
80 void ( * pf_close )( struct intf_thread_s * );
81 void ( * pf_run ) ( struct intf_thread_s * );
87 void ( * pf_init ) ( struct input_thread_s * );
88 void ( * pf_open ) ( struct input_thread_s * );
89 void ( * pf_close )( struct input_thread_s * );
90 void ( * pf_end ) ( struct input_thread_s * );
92 int ( * pf_read ) ( struct input_thread_s *,
93 struct data_packet_s *
95 void ( * pf_demux )( struct input_thread_s *,
96 struct data_packet_s * );
98 struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
99 struct pes_packet_s * ( * pf_new_pes ) ( void * );
100 void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
101 void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
104 int ( * pf_set_area ) ( struct input_thread_s *,
105 struct input_area_s * );
106 int ( * pf_rewind ) ( struct input_thread_s * );
107 void ( * pf_seek ) ( struct input_thread_s *, off_t );
110 /* Audio output plugin */
113 int ( * pf_open ) ( struct aout_thread_s * );
114 int ( * pf_setformat ) ( struct aout_thread_s * );
115 long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
116 void ( * pf_play ) ( struct aout_thread_s *, byte_t *, int );
117 void ( * pf_close ) ( struct aout_thread_s * );
120 /* Video output plugin */
123 int ( * pf_create ) ( struct vout_thread_s * );
124 int ( * pf_init ) ( struct vout_thread_s * );
125 void ( * pf_end ) ( struct vout_thread_s * );
126 void ( * pf_destroy ) ( struct vout_thread_s * );
127 int ( * pf_manage ) ( struct vout_thread_s * );
128 void ( * pf_display ) ( struct vout_thread_s * );
129 void ( * pf_setpalette ) ( struct vout_thread_s *, u16 *red,
130 u16 *green, u16 *blue, u16 *transp );
133 /* Motion compensation plugin */
136 #define motion_functions( yuv ) \
137 void ( * pf_field_field_##yuv ) ( struct macroblock_s * ); \
138 void ( * pf_field_16x8_##yuv ) ( struct macroblock_s * ); \
139 void ( * pf_field_dmv_##yuv ) ( struct macroblock_s * ); \
140 void ( * pf_frame_field_##yuv ) ( struct macroblock_s * ); \
141 void ( * pf_frame_frame_##yuv ) ( struct macroblock_s * ); \
142 void ( * pf_frame_dmv_##yuv ) ( struct macroblock_s * );
143 motion_functions( 420 )
144 motion_functions( 422 )
145 motion_functions( 444 )
146 #undef motion_functions
152 void ( * pf_init ) ( struct vdec_thread_s * );
153 void ( * pf_sparse_idct ) ( struct vdec_thread_s *,
155 void ( * pf_idct ) ( struct vdec_thread_s *,
157 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
160 /* YUV transformation plugin */
163 int ( * pf_init ) ( struct vout_thread_s * );
164 int ( * pf_reset ) ( struct vout_thread_s * );
165 void ( * pf_end ) ( struct vout_thread_s * );
172 typedef struct module_functions_s
174 /* XXX: The order here has to be the same as above for the #defines */
175 function_list_t intf;
176 function_list_t access;
177 function_list_t input;
178 function_list_t decaps;
179 function_list_t adec;
180 function_list_t vdec;
181 function_list_t motion;
182 function_list_t idct;
183 function_list_t aout;
184 function_list_t vout;
189 } module_functions_t;
191 typedef struct module_functions_s * p_module_functions_t;
193 /*****************************************************************************
194 * Macros used to build the configuration structure.
195 *****************************************************************************/
197 /* Mandatory first and last parts of the structure */
198 #define MODULE_CONFIG_ITEM_START 0xdead /* The main window */
199 #define MODULE_CONFIG_ITEM_END 0xbeef /* End of the window */
201 /* Configuration widgets */
202 #define MODULE_CONFIG_ITEM_WINDOW 0x0001 /* The main window */
203 #define MODULE_CONFIG_ITEM_PANE 0x0002 /* A notebook pane */
204 #define MODULE_CONFIG_ITEM_FRAME 0x0003 /* A frame */
205 #define MODULE_CONFIG_ITEM_COMMENT 0x0004 /* A comment text */
206 #define MODULE_CONFIG_ITEM_STRING 0x0005 /* A string */
207 #define MODULE_CONFIG_ITEM_FILE 0x0006 /* A file selector */
208 #define MODULE_CONFIG_ITEM_CHECK 0x0007 /* A checkbox */
209 #define MODULE_CONFIG_ITEM_CHOOSE 0x0008 /* A choose box */
210 #define MODULE_CONFIG_ITEM_RADIO 0x0009 /* A radio box */
211 #define MODULE_CONFIG_ITEM_SCALE 0x000a /* A horizontal ruler */
212 #define MODULE_CONFIG_ITEM_SPIN 0x000b /* A numerical selector */
214 typedef struct module_config_s
216 int i_type; /* Configuration widget type */
217 char * psz_text; /* Text commenting or describing the widget */
218 char * psz_name; /* Variable name */
219 void * p_getlist; /* Function to call to get a choice list */
220 void * p_change; /* Function to call when commiting a change */
223 /*****************************************************************************
224 * Bank and module description structures
225 *****************************************************************************/
227 /* The module bank structure */
228 typedef struct module_bank_s
230 struct module_s * first; /* First module of the bank */
232 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful it
233 is to design thread-safe linked lists. */
236 /* The module description structure */
237 typedef struct module_s
239 boolean_t b_builtin; /* Set to true if the module is built in */
245 module_handle_t handle; /* Unique handle */
246 char * psz_filename; /* Module filename */
252 int ( *pf_deactivate ) ( struct module_s * );
258 char * psz_name; /* Module _unique_ name */
259 char * psz_longname; /* Module descriptive name */
260 char * psz_version; /* Module version */
262 int i_usage; /* Reference counter */
263 int i_unused_delay; /* Delay until module is unloaded */
265 struct module_s * next; /* Next module */
266 struct module_s * prev; /* Previous module */
268 module_config_t * p_config; /* Module configuration structure table */
270 u32 i_capabilities; /* Capability list */
271 p_module_functions_t p_functions; /* Capability functions */
275 /*****************************************************************************
276 * Exported functions.
277 *****************************************************************************/
278 module_bank_t * module_CreateBank ( void );
279 void module_InitBank ( module_bank_t * p_bank );
280 void module_DestroyBank ( module_bank_t * p_bank );
281 void module_ResetBank ( module_bank_t * p_bank );
282 void module_ManageBank ( module_bank_t * p_bank );
284 module_t * module_Need ( module_bank_t *p_bank,
285 int i_capabilities, void *p_data );
286 void module_Unneed ( module_bank_t * p_bank,
287 module_t * p_module );