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