]> git.sesse.net Git - vlc/blob - include/modules.h
* Fixed some win32 64-bit issues.
[vlc] / include / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 VideoLAN
5  * $Id: modules.h,v 1.30 2001/11/08 01:48:09 jlj 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_bank_t, p_module_bank (global variable)
26  *****************************************************************************
27  * This global variable is accessed by any function using modules.
28  *****************************************************************************/
29 typedef struct
30 {
31     struct module_s *   first; /* First module of the bank */
32
33     vlc_mutex_t         lock;  /* Global lock -- you can't imagine how awful it
34                                   is to design thread-safe linked lists. */
35 } module_bank_t;
36
37 extern module_bank_t *p_module_bank;
38
39 /*****************************************************************************
40  * Module #defines.
41  *****************************************************************************/
42
43 /* Number of tries before we unload an unused module */
44 #define MODULE_HIDE_DELAY 100
45
46 /* The module handle type. */
47 #ifdef SYS_BEOS
48 typedef int     module_handle_t;
49 #else
50 typedef void *  module_handle_t;
51 #endif
52
53 /*****************************************************************************
54  * Module capabilities.
55  *****************************************************************************/
56
57 #define MODULE_CAPABILITY_NULL     0        /* The Module can't do anything */
58 #define MODULE_CAPABILITY_INTF     1 <<  0  /* Interface */
59 #define MODULE_CAPABILITY_ACCESS   1 <<  1  /* Input */
60 #define MODULE_CAPABILITY_INPUT    1 <<  2  /* Input */
61 #define MODULE_CAPABILITY_DECAPS   1 <<  3  /* Decaps */
62 #define MODULE_CAPABILITY_ADEC     1 <<  4  /* Audio decoder */
63 #define MODULE_CAPABILITY_VDEC     1 <<  5  /* Video decoder */
64 #define MODULE_CAPABILITY_MOTION   1 <<  6  /* Motion compensation */
65 #define MODULE_CAPABILITY_IDCT     1 <<  7  /* IDCT transformation */
66 #define MODULE_CAPABILITY_AOUT     1 <<  8  /* Audio output */
67 #define MODULE_CAPABILITY_VOUT     1 <<  9  /* Video output */
68 #define MODULE_CAPABILITY_YUV      1 << 10  /* YUV colorspace conversion */
69 #define MODULE_CAPABILITY_IMDCT    1 << 11  /* IMDCT transformation */
70 #define MODULE_CAPABILITY_DOWNMIX  1 << 12  /* AC3 downmix */
71
72 /* FIXME: kludge */
73 struct input_area_s;
74 struct imdct_s;
75 struct complex_s;
76 struct dm_par_s;
77 struct bit_stream_s;
78 struct decoder_fifo_s;
79
80 /* FIXME: not yet used */
81 typedef struct probedata_s
82 {
83     struct
84     {
85         char * psz_data;
86     } aout;
87 } probedata_t;
88
89 /* FIXME: find a nicer way to do this. */
90 typedef struct function_list_s
91 {
92     int ( * pf_probe ) ( probedata_t * p_data );
93
94     union
95     {
96         /* Interface plugin */
97         struct
98         {
99             int  ( * pf_open ) ( struct intf_thread_s * );
100             void ( * pf_close )( struct intf_thread_s * );
101             void ( * pf_run )  ( struct intf_thread_s * );
102         } intf;
103
104         /* Input plugin */
105         struct
106         {
107             void ( * pf_init ) ( struct input_thread_s * );
108             void ( * pf_open ) ( struct input_thread_s * );
109             void ( * pf_close )( struct input_thread_s * );
110             void ( * pf_end )  ( struct input_thread_s * );
111             void ( * pf_init_bit_stream ) ( struct bit_stream_s *,
112                                             struct decoder_fifo_s *,
113                       void (* pf_bitstream_callback)( struct bit_stream_s *,
114                                                       boolean_t ),
115                                            void * );
116
117             int  ( * pf_read ) ( struct input_thread_s *,
118                                  struct data_packet_s *
119                                         pp_packets[] );
120             void ( * pf_demux )( struct input_thread_s *,
121                                  struct data_packet_s * );
122
123             struct data_packet_s * ( * pf_new_packet ) ( void *, size_t );
124             struct pes_packet_s *  ( * pf_new_pes )    ( void * );
125             void ( * pf_delete_packet )  ( void *, struct data_packet_s * );
126             void ( * pf_delete_pes )     ( void *, struct pes_packet_s * );
127
128
129             int  ( * pf_set_area ) ( struct input_thread_s *,
130                                      struct input_area_s * );
131             int  ( * pf_rewind )   ( struct input_thread_s * );
132             void ( * pf_seek )     ( struct input_thread_s *, off_t );
133         } input;
134
135         /* Audio output plugin */
136         struct
137         {
138             int  ( * pf_open )       ( struct aout_thread_s * );
139             int  ( * pf_setformat )  ( struct aout_thread_s * );
140             long ( * pf_getbufinfo ) ( struct aout_thread_s *, long );
141             void ( * pf_play )       ( struct aout_thread_s *, byte_t *, int );
142             void ( * pf_close )      ( struct aout_thread_s * );
143         } aout;
144
145         /* Video output plugin */
146         struct
147         {
148             int  ( * pf_create )     ( struct vout_thread_s * );
149             int  ( * pf_init )       ( struct vout_thread_s * );
150             void ( * pf_end )        ( struct vout_thread_s * );
151             void ( * pf_destroy )    ( struct vout_thread_s * );
152             int  ( * pf_manage )     ( struct vout_thread_s * );
153             void ( * pf_display )    ( struct vout_thread_s * );
154             void ( * pf_setpalette ) ( struct vout_thread_s *, u16 *red,
155                                        u16 *green, u16 *blue, u16 *transp );
156         } vout;
157
158         /* Motion compensation plugin */
159         struct
160         {
161             void ( * ppppf_motion[2][2][4] ) ( yuv_data_t *, yuv_data_t *,
162                                                int, int );
163         } motion;
164
165         /* IDCT plugin */
166         struct
167         {
168             void ( * pf_idct_init )    ( void ** );
169             void ( * pf_sparse_idct_add )( dctelem_t *, yuv_data_t *, int,
170                                          void *, int );
171             void ( * pf_idct_add )     ( dctelem_t *, yuv_data_t *, int,
172                                          void *, int );
173             void ( * pf_sparse_idct_copy )( dctelem_t *, yuv_data_t *, int,
174                                          void *, int );
175             void ( * pf_idct_copy )    ( dctelem_t *, yuv_data_t *, int,
176                                          void *, int );
177             void ( * pf_norm_scan )    ( u8 ppi_scan[2][64] );
178         } idct;
179
180         /* YUV transformation plugin */
181         struct
182         {
183             int  ( * pf_init )         ( struct vout_thread_s * );
184             int  ( * pf_reset )        ( struct vout_thread_s * );
185             void ( * pf_end )          ( struct vout_thread_s * );
186         } yuv;
187
188         /* IMDCT plugin */
189         struct
190         {
191             void ( * pf_imdct_init )   ( struct imdct_s * );
192             void ( * pf_imdct_256 )    ( struct imdct_s *,
193                                          float data[], float delay[] );
194             void ( * pf_imdct_256_nol )( struct imdct_s *,
195                                          float data[], float delay[] );
196             void ( * pf_imdct_512 )    ( struct imdct_s *,
197                                          float data[], float delay[] );
198             void ( * pf_imdct_512_nol )( struct imdct_s *,
199                                          float data[], float delay[] );
200 //            void ( * pf_fft_64p )      ( struct complex_s * );
201
202         } imdct;
203
204         /* AC3 downmix plugin */
205         struct
206         {
207             void ( * pf_downmix_3f_2r_to_2ch ) ( float *, struct dm_par_s * );
208             void ( * pf_downmix_3f_1r_to_2ch ) ( float *, struct dm_par_s * );
209             void ( * pf_downmix_2f_2r_to_2ch ) ( float *, struct dm_par_s * );
210             void ( * pf_downmix_2f_1r_to_2ch ) ( float *, struct dm_par_s * );
211             void ( * pf_downmix_3f_0r_to_2ch ) ( float *, struct dm_par_s * );
212             void ( * pf_stream_sample_2ch_to_s16 ) ( s16 *, float *, float * );
213             void ( * pf_stream_sample_1ch_to_s16 ) ( s16 *, float * );
214
215         } downmix;
216
217     } functions;
218
219 } function_list_t;
220
221 typedef struct module_functions_s
222 {
223     /* XXX: The order here has to be the same as above for the #defines */
224     function_list_t intf;
225     function_list_t access;
226     function_list_t input;
227     function_list_t decaps;
228     function_list_t adec;
229     function_list_t vdec;
230     function_list_t motion;
231     function_list_t idct;
232     function_list_t aout;
233     function_list_t vout;
234     function_list_t yuv;
235     function_list_t imdct;
236     function_list_t downmix;
237
238 } module_functions_t;
239
240 typedef struct module_functions_s * p_module_functions_t;
241
242 /*****************************************************************************
243  * Macros used to build the configuration structure.
244  *****************************************************************************/
245
246 /* Mandatory first and last parts of the structure */
247 #define MODULE_CONFIG_ITEM_START       0xdead  /* The main window */
248 #define MODULE_CONFIG_ITEM_END         0xbeef  /* End of the window */
249
250 /* Configuration widgets */
251 #define MODULE_CONFIG_ITEM_WINDOW      0x0001  /* The main window */
252 #define MODULE_CONFIG_ITEM_PANE        0x0002  /* A notebook pane */
253 #define MODULE_CONFIG_ITEM_FRAME       0x0003  /* A frame */
254 #define MODULE_CONFIG_ITEM_COMMENT     0x0004  /* A comment text */
255 #define MODULE_CONFIG_ITEM_STRING      0x0005  /* A string */
256 #define MODULE_CONFIG_ITEM_FILE        0x0006  /* A file selector */
257 #define MODULE_CONFIG_ITEM_CHECK       0x0007  /* A checkbox */
258 #define MODULE_CONFIG_ITEM_CHOOSE      0x0008  /* A choose box */
259 #define MODULE_CONFIG_ITEM_RADIO       0x0009  /* A radio box */
260 #define MODULE_CONFIG_ITEM_SCALE       0x000a  /* A horizontal ruler */
261 #define MODULE_CONFIG_ITEM_SPIN        0x000b  /* A numerical selector */
262
263 typedef struct module_config_s
264 {
265     int         i_type;                         /* Configuration widget type */
266     char *      psz_text;        /* Text commenting or describing the widget */
267     char *      psz_name;                                   /* Variable name */
268     void *      p_getlist;          /* Function to call to get a choice list */
269     void *      p_change;        /* Function to call when commiting a change */
270 } module_config_t;
271
272 /*****************************************************************************
273  * Bank and module description structures
274  *****************************************************************************/
275
276 /* The module description structure */
277 typedef struct module_s
278 {
279     boolean_t           b_builtin;  /* Set to true if the module is built in */
280
281     union
282     {
283         struct
284         {
285             module_handle_t     handle;                     /* Unique handle */
286             char *              psz_filename;             /* Module filename */
287
288         } plugin;
289
290         struct
291         {
292             int ( *pf_deactivate ) ( struct module_s * );
293
294         } builtin;
295
296     } is;
297
298     char *              psz_name;                    /* Module _unique_ name */
299     char *              psz_longname;             /* Module descriptive name */
300     char *              psz_version;                       /* Module version */
301
302     int                 i_usage;                        /* Reference counter */
303     int                 i_unused_delay;    /* Delay until module is unloaded */
304
305     struct module_s *   next;                                 /* Next module */
306     struct module_s *   prev;                             /* Previous module */
307
308     module_config_t         *p_config;     /* Module configuration structure */
309     struct module_symbols_s *p_symbols;
310
311     u32                      i_capabilities;              /* Capability list */
312     p_module_functions_t     p_functions;            /* Capability functions */
313
314 } module_t;
315
316 /*****************************************************************************
317  * Exported functions.
318  *****************************************************************************/
319 void            module_InitBank     ( void );
320 void            module_EndBank      ( void );
321 void            module_ResetBank    ( void );
322 void            module_ManageBank   ( void );
323 module_t *      module_Need         ( int i_capabilities, void *p_data );
324 void            module_Unneed       ( module_t * p_module );
325