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