]> git.sesse.net Git - vlc/blob - include/modules.h
ee8783d507232f8c9cb1d9763df0f1ab3acaa08e
[vlc] / include / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: modules.h,v 1.56 2002/07/03 19:40:49 sam Exp $
6  *
7  * Authors: Samuel Hocevar <sam@zoy.org>
8  *
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.
13  * 
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.
18  *
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  *****************************************************************************/
23
24 /*****************************************************************************
25  * Module #defines.
26  *****************************************************************************/
27
28 /* Number of tries before we unload an unused module */
29 #define MODULE_HIDE_DELAY 50
30 #define MODULE_SHORTCUT_MAX 10
31
32 /* The module handle type. */
33 #ifdef SYS_BEOS
34 typedef int     module_handle_t;
35 #else
36 typedef void *  module_handle_t;
37 #endif
38
39 /*****************************************************************************
40  * Module capabilities.
41  *****************************************************************************/
42 #define MODULE_CAPABILITY_MAIN             0  /* Main */
43 #define MODULE_CAPABILITY_INTF             1  /* Interface */
44 #define MODULE_CAPABILITY_ACCESS           2  /* Input */
45 #define MODULE_CAPABILITY_DEMUX            3  /* Input */
46 #define MODULE_CAPABILITY_NETWORK          4  /* Network */
47 #define MODULE_CAPABILITY_DECODER          5  /* Audio or video decoder */
48 #define MODULE_CAPABILITY_MOTION           6  /* Motion compensation */
49 #define MODULE_CAPABILITY_IDCT             7  /* IDCT transformation */
50 #define MODULE_CAPABILITY_AOUT             8  /* Audio output */
51 #define MODULE_CAPABILITY_AOUT_FILTER      9  /* Audio output filter */
52 #define MODULE_CAPABILITY_VOUT            10  /* Video output */
53 #define MODULE_CAPABILITY_VOUT_FILTER     11  /* Video output filter */
54 #define MODULE_CAPABILITY_CHROMA          12  /* colorspace conversion */
55 #define MODULE_CAPABILITY_IMDCT           13  /* IMDCT transformation */
56 #define MODULE_CAPABILITY_DOWNMIX         14  /* AC3 downmix */
57 #define MODULE_CAPABILITY_MEMCPY          15  /* memcpy */
58 #define MODULE_CAPABILITY_MAX             16  /* Total number of capabilities */
59
60 #define DECLARE_MODULE_CAPABILITY_TABLE \
61     static const char *ppsz_capabilities[] = \
62     { \
63         "main", \
64         "interface", \
65         "access", \
66         "demux", \
67         "network", \
68         "decoder", \
69         "motion", \
70         "iDCT", \
71         "audio output", \
72         "audio output filter", \
73         "video output", \
74         "video output filter", \
75         "chroma transformation", \
76         "iMDCT", \
77         "downmix", \
78         "memcpy", \
79         "unknown" \
80     }
81
82 #define MODULE_CAPABILITY( i_capa ) \
83     ppsz_capabilities[ ((i_capa) > MODULE_CAPABILITY_MAX) ? \
84                           MODULE_CAPABILITY_MAX : (i_capa) ]
85
86 /*****************************************************************************
87  * module_bank_t: the module bank
88  *****************************************************************************
89  * This variable is accessed by any function using modules.
90  *****************************************************************************/
91 struct module_bank_s
92 {
93     module_t *   first;                          /* First module in the bank */
94     int          i_count;                     /* Number of allocated modules */
95
96     vlc_mutex_t  lock;         /* Global lock -- you can't imagine how awful *
97                                     it is to design thread-safe linked lists */
98 };
99
100 /*****************************************************************************
101  * Module description structure
102  *****************************************************************************/
103 struct module_s
104 {
105     VLC_COMMON_MEMBERS
106
107     /*
108      * Variables set by the module to identify itself
109      */
110     char *psz_longname;                           /* Module descriptive name */
111
112     /*
113      * Variables set by the module to tell us what it can do
114      */
115     char *psz_program;        /* Program name which will activate the module */
116     char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];    /* Shortcuts to the module */
117
118     u32   i_capabilities;                                 /* Capability list */
119     int   pi_score[ MODULE_CAPABILITY_MAX ];    /* Score for each capability */
120
121     u32   i_cpu_capabilities;                   /* Required CPU capabilities */
122
123     module_functions_t *p_functions;                 /* Capability functions */
124
125     /*
126      * Variables set by the module to store its config options
127      */
128     module_config_t *p_config;             /* Module configuration structure */
129     unsigned int     i_config_items;        /* number of configuration items */
130     unsigned int     i_bool_items;            /* number of bool config items */
131
132     /*
133      * Variables used internally by the module manager
134      */
135     vlc_bool_t          b_builtin;  /* Set to true if the module is built in */
136
137     union
138     {
139         struct
140         {
141             module_handle_t     handle;                     /* Unique handle */
142             char *              psz_filename;             /* Module filename */
143
144         } plugin;
145
146         struct
147         {
148             int ( *pf_deactivate ) ( module_t * );
149
150         } builtin;
151
152     } is;
153
154     int   i_usage;                                      /* Reference counter */
155     int   i_unused_delay;                  /* Delay until module is unloaded */
156
157     module_t *next;                                           /* Next module */
158     module_t *prev;                                       /* Previous module */
159
160     /*
161      * Symbol table we send to the module so that it can access vlc symbols
162      */
163     module_symbols_t *p_symbols;
164 };
165
166 /*****************************************************************************
167  * Module functions description structure
168  *****************************************************************************/
169 typedef struct function_list_s
170 {
171     union
172     {
173         /* Interface plugin */
174         struct
175         {
176             int  ( * pf_open ) ( intf_thread_t * );
177             void ( * pf_close )( intf_thread_t * );
178             void ( * pf_run )  ( intf_thread_t * );
179         } intf;
180
181         /* Access plugin */
182         struct
183         {
184             int  ( * pf_open )        ( input_thread_t * );
185             void ( * pf_close )       ( input_thread_t * );
186             ssize_t ( * pf_read )     ( input_thread_t *, byte_t *, size_t );
187             void ( * pf_seek )        ( input_thread_t *, off_t );
188             int  ( * pf_set_program ) ( input_thread_t *, pgrm_descriptor_t * );
189             int  ( * pf_set_area )    ( input_thread_t *, input_area_t * );
190         } access;
191
192         /* Demux plugin */
193         struct
194         {
195             int  ( * pf_init )   ( input_thread_t * );
196             void ( * pf_end )    ( input_thread_t * );
197             int  ( * pf_demux )  ( input_thread_t * );
198             int  ( * pf_rewind ) ( input_thread_t * );
199         } demux;
200
201         /* Network plugin */
202         struct
203         {
204             int  ( * pf_open ) ( vlc_object_t *, network_socket_t * );
205         } network;
206
207         /* Audio output plugin */
208         struct
209         {
210             int  ( * pf_open )       ( aout_thread_t * );
211             int  ( * pf_setformat )  ( aout_thread_t * );
212             int  ( * pf_getbufinfo ) ( aout_thread_t *, int );
213             void ( * pf_play )       ( aout_thread_t *, byte_t *, int );
214             void ( * pf_close )      ( aout_thread_t * );
215         } aout;
216
217         /* Video output plugin */
218         struct
219         {
220             int  ( * pf_create )     ( vout_thread_t * );
221             int  ( * pf_init )       ( vout_thread_t * );
222             void ( * pf_end )        ( vout_thread_t * );
223             void ( * pf_destroy )    ( vout_thread_t * );
224             int  ( * pf_manage )     ( vout_thread_t * );
225             void ( * pf_render )     ( vout_thread_t *, picture_t * );
226             void ( * pf_display )    ( vout_thread_t *, picture_t * );
227         } vout;
228
229         /* Motion compensation plugin */
230         struct
231         {
232             void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
233                                                int, int );
234         } motion;
235
236         /* IDCT plugin */
237         struct
238         {
239             void ( * pf_idct_init )    ( void ** );
240             void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
241                                          void *, int );
242             void ( * pf_idct_add )     ( dctelem_t *, yuv_data_t *, int,
243                                          void *, int );
244             void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
245                                          void *, int );
246             void ( * pf_idct_copy )    ( dctelem_t *, yuv_data_t *, int,
247                                          void *, int );
248             void ( * pf_norm_scan )    ( u8 ppi_scan[2][64] );
249         } idct;
250
251         /* Chroma transformation plugin */
252         struct
253         {
254             int  ( * pf_init )         ( vout_thread_t * );
255             void ( * pf_end )          ( vout_thread_t * );
256         } chroma;
257
258         /* IMDCT plugin */
259         struct
260         {
261             void ( * pf_imdct_init )   ( imdct_t * );
262             void ( * pf_imdct_256 )    ( imdct_t *, float [], float [] );
263             void ( * pf_imdct_256_nol )( imdct_t *, float [], float [] );
264             void ( * pf_imdct_512 )    ( imdct_t *, float [], float [] );
265             void ( * pf_imdct_512_nol )( imdct_t *, float [], float [] );
266 //            void ( * pf_fft_64p )      ( complex_t * );
267
268         } imdct;
269
270         /* AC3 downmix plugin */
271         struct
272         {
273             void ( * pf_downmix_3f_2r_to_2ch ) ( float *, dm_par_t * );
274             void ( * pf_downmix_3f_1r_to_2ch ) ( float *, dm_par_t * );
275             void ( * pf_downmix_2f_2r_to_2ch ) ( float *, dm_par_t * );
276             void ( * pf_downmix_2f_1r_to_2ch ) ( float *, dm_par_t * );
277             void ( * pf_downmix_3f_0r_to_2ch ) ( float *, dm_par_t * );
278             void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
279             void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
280
281         } downmix;
282
283         /* Decoder plugins */
284         struct
285         {
286             int  ( * pf_probe)( u8 * p_es );
287             int  ( * pf_run ) ( decoder_fifo_t * p_fifo );
288         } dec;
289
290         /* memcpy plugins */
291         struct
292         {
293             void* ( * pf_memcpy ) ( void *, const void *, size_t );
294             void* ( * pf_memset ) ( void *, int, size_t );
295         } memcpy;
296
297     } functions;
298
299 } function_list_t;
300
301 struct module_functions_s
302 {
303     /* XXX: The order here has to be the same as above for the #defines */
304     function_list_t intf;
305     function_list_t access;
306     function_list_t demux;
307     function_list_t network;
308     function_list_t dec;
309     function_list_t motion;
310     function_list_t idct;
311     function_list_t aout;
312     function_list_t vout;
313     function_list_t chroma;
314     function_list_t imdct;
315     function_list_t downmix;
316     function_list_t memcpy;
317 };
318
319 /*****************************************************************************
320  * Exported functions.
321  *****************************************************************************/
322 #define module_InitBank(a)     __module_InitBank(CAST_TO_VLC_OBJECT(a))
323 void  __module_InitBank        ( vlc_object_t * );
324 #define module_LoadMain(a)     __module_LoadMain(CAST_TO_VLC_OBJECT(a))
325 void  __module_LoadMain        ( vlc_object_t * );
326 #define module_LoadBuiltins(a) __module_LoadBuiltins(CAST_TO_VLC_OBJECT(a))
327 void  __module_LoadBuiltins    ( vlc_object_t * );
328 #define module_LoadPlugins(a)  __module_LoadPlugins(CAST_TO_VLC_OBJECT(a))
329 void  __module_LoadPlugins     ( vlc_object_t * );
330 #define module_EndBank(a)      __module_EndBank(CAST_TO_VLC_OBJECT(a))
331 void  __module_EndBank         ( vlc_object_t * );
332 #define module_ResetBank(a)    __module_ResetBank(CAST_TO_VLC_OBJECT(a))
333 void  __module_ResetBank       ( vlc_object_t * );
334 #define module_ManageBank(a)   __module_ManageBank(CAST_TO_VLC_OBJECT(a))
335 void  __module_ManageBank      ( vlc_object_t * );
336
337 #define module_Need(a,b,c,d) __module_Need(CAST_TO_VLC_OBJECT(a),b,c,d)
338 VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, int, const char *, void * ) );
339 VLC_EXPORT( void, module_Unneed, ( module_t * ) );
340