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