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