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 );
71 void ( * pf_init ) ( struct input_thread_s * );
72 void ( * pf_open ) ( struct input_thread_s * );
73 void ( * pf_close )( struct input_thread_s * );
74 void ( * pf_end ) ( struct input_thread_s * );
76 int ( * pf_read ) ( struct input_thread_s *,
77 struct data_packet_s *
79 void ( * pf_demux )( struct input_thread_s *,
80 struct data_packet_s * );
82 struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
83 struct pes_packet_s * ( * pf_new_pes ) ( void * );
84 void ( * pf_delete_packet ) ( void *, struct data_packet_s * );
85 void ( * pf_delete_pes ) ( void *, struct pes_packet_s * );
87 int ( * pf_rewind ) ( struct input_thread_s * );
88 int ( * pf_seek ) ( struct input_thread_s *, off_t );
91 /* Audio output plugin */
94 int ( * pf_open ) ( struct aout_thread_s * );
95 int ( * pf_setformat ) ( struct aout_thread_s * );
96 long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
97 void ( * pf_play ) ( struct aout_thread_s *, byte_t *, int );
98 void ( * pf_close ) ( struct aout_thread_s * );
101 /* Motion compensation plugin */
104 #define motion_functions( yuv ) \
105 void ( * pf_field_field_##yuv ) ( struct macroblock_s * ); \
106 void ( * pf_field_16x8_##yuv ) ( struct macroblock_s * ); \
107 void ( * pf_field_dmv_##yuv ) ( struct macroblock_s * ); \
108 void ( * pf_frame_field_##yuv ) ( struct macroblock_s * ); \
109 void ( * pf_frame_frame_##yuv ) ( struct macroblock_s * ); \
110 void ( * pf_frame_dmv_##yuv ) ( struct macroblock_s * );
111 motion_functions( 420 )
112 motion_functions( 422 )
113 motion_functions( 444 )
114 #undef motion_functions
120 void ( * pf_init ) ( struct vdec_thread_s * );
121 void ( * pf_sparse_idct ) ( struct vdec_thread_s *,
123 void ( * pf_idct ) ( struct vdec_thread_s *,
125 void ( * pf_norm_scan ) ( u8 ppi_scan[2][64] );
128 /* YUV transformation plugin */
131 int ( * pf_init ) ( struct vout_thread_s * );
132 int ( * pf_reset ) ( struct vout_thread_s * );
133 void ( * pf_end ) ( struct vout_thread_s * );
140 typedef struct module_functions_s
142 /* XXX: The order here has to be the same as above for the #defines */
143 function_list_t intf;
144 function_list_t access;
145 function_list_t input;
146 function_list_t decaps;
147 function_list_t adec;
148 function_list_t vdec;
149 function_list_t motion;
150 function_list_t idct;
151 function_list_t aout;
152 function_list_t vout;
157 } module_functions_t;
159 typedef struct module_functions_s * p_module_functions_t;
161 /*****************************************************************************
162 * Macros used to build the configuration structure.
163 *****************************************************************************/
165 /* Mandatory first and last parts of the structure */
166 #define MODULE_CONFIG_ITEM_START 0xdead /* The main window */
167 #define MODULE_CONFIG_ITEM_END 0xbeef /* End of the window */
169 /* Configuration widgets */
170 #define MODULE_CONFIG_ITEM_WINDOW 0x0001 /* The main window */
171 #define MODULE_CONFIG_ITEM_PANE 0x0002 /* A notebook pane */
172 #define MODULE_CONFIG_ITEM_FRAME 0x0003 /* A frame */
173 #define MODULE_CONFIG_ITEM_COMMENT 0x0004 /* A comment text */
174 #define MODULE_CONFIG_ITEM_STRING 0x0005 /* A string */
175 #define MODULE_CONFIG_ITEM_FILE 0x0006 /* A file selector */
176 #define MODULE_CONFIG_ITEM_CHECK 0x0007 /* A checkbox */
177 #define MODULE_CONFIG_ITEM_CHOOSE 0x0008 /* A choose box */
178 #define MODULE_CONFIG_ITEM_RADIO 0x0009 /* A radio box */
179 #define MODULE_CONFIG_ITEM_SCALE 0x000a /* A horizontal ruler */
180 #define MODULE_CONFIG_ITEM_SPIN 0x000b /* A numerical selector */
182 typedef struct module_config_s
184 int i_type; /* Configuration widget type */
185 char * psz_text; /* Text commenting or describing the widget */
186 char * psz_name; /* Variable name */
187 void * p_getlist; /* Function to call to get a choice list */
188 void * p_change; /* Function to call when commiting a change */
191 /*****************************************************************************
192 * Bank and module description structures
193 *****************************************************************************/
195 /* The module bank structure */
196 typedef struct module_bank_s
198 struct module_s * first; /* First module of the bank */
200 vlc_mutex_t lock; /* Global lock -- you can't imagine how awful it
201 is to design thread-safe linked lists. */
204 /* The module description structure */
205 typedef struct module_s
207 boolean_t b_builtin; /* Set to true if the module is built in */
209 module_handle_t handle; /* Unique handle to refer to the module */
210 char * psz_filename; /* Module filename */
212 char * psz_name; /* Module _unique_ name */
213 char * psz_longname; /* Module descriptive name */
214 char * psz_version; /* Module version */
216 int i_usage; /* Reference counter */
217 int i_unused_delay; /* Delay until module is unloaded */
219 struct module_s * next; /* Next module */
220 struct module_s * prev; /* Previous module */
222 module_config_t * p_config; /* Module configuration structure table */
224 u32 i_capabilities; /* Capability list */
225 p_module_functions_t p_functions; /* Capability functions */
229 /*****************************************************************************
230 * Exported functions.
231 *****************************************************************************/
232 module_bank_t * module_CreateBank ( void );
233 void module_InitBank ( module_bank_t * p_bank );
234 void module_DestroyBank ( module_bank_t * p_bank );
235 void module_ResetBank ( module_bank_t * p_bank );
236 void module_ManageBank ( module_bank_t * p_bank );
238 module_t * module_Need ( module_bank_t *p_bank,
239 int i_capabilities, void *p_data );
240 void module_Unneed ( module_bank_t * p_bank,
241 module_t * p_module );