]> git.sesse.net Git - vlc/blob - include/modules.h
. all plugins now compile with -fPIC.
[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 50
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_INPUT    1<<1    /* Input */
40 #define MODULE_CAPABILITY_DECAPS   1<<2    /* Decaps */
41 #define MODULE_CAPABILITY_ADEC     1<<3    /* Audio decoder */
42 #define MODULE_CAPABILITY_VDEC     1<<4    /* Video decoder */
43 #define MODULE_CAPABILITY_AOUT     1<<5    /* Audio output */
44 #define MODULE_CAPABILITY_VOUT     1<<6    /* Video output */
45 #define MODULE_CAPABILITY_YUV      1<<7    /* YUV colorspace conversion */
46 #define MODULE_CAPABILITY_AFX      1<<8    /* Audio effects */
47 #define MODULE_CAPABILITY_VFX      1<<9    /* Video effects */
48
49 /* FIXME: not yet used */
50 typedef struct probedata_s
51 {
52     struct
53     {
54         char * psz_data;
55     } aout;
56 } probedata_t;
57
58 /* FIXME: find a nicer way to do this. */
59 typedef struct function_list_s
60 {
61     int ( * p_probe ) ( probedata_t * p_data );
62
63     union
64     {
65         struct
66         {
67             int  ( * p_open )       ( struct aout_thread_s * p_aout );
68             int  ( * p_setformat )  ( struct aout_thread_s * p_aout );
69             long ( * p_getbufinfo ) ( struct aout_thread_s * p_aout,
70                                       long l_buffer_info );
71             void ( * p_play )       ( struct aout_thread_s * p_aout,
72                                       byte_t *buffer, int i_size );
73             void ( * p_close )      ( struct aout_thread_s * p_aout );
74         } aout;
75
76     } functions;
77
78 } function_list_t;
79
80 typedef struct module_functions_s
81 {
82     /* The order here has to be the same as above for the #defines */
83     function_list_t intf;
84     function_list_t input;
85     function_list_t decaps;
86     function_list_t adec;
87     function_list_t vdec;
88     function_list_t aout;
89     function_list_t vout;
90     function_list_t yuv;
91     function_list_t afx;
92     function_list_t vfx;
93
94 } module_functions_t;
95
96 typedef struct module_functions_s * p_module_functions_t;
97
98 /*****************************************************************************
99  * Macros used to build the configuration structure.
100  *****************************************************************************/
101
102 /* Mandatory first and last parts of the structure */
103 #define MODULE_CONFIG_ITEM_START       0x01    /* The main window */
104 #define MODULE_CONFIG_ITEM_END         0x00    /* End of the window */
105
106 /* Configuration widgets */
107 #define MODULE_CONFIG_ITEM_PANE        0x02    /* A notebook pane */
108 #define MODULE_CONFIG_ITEM_FRAME       0x03    /* A frame */
109 #define MODULE_CONFIG_ITEM_COMMENT     0x04    /* A comment text */
110 #define MODULE_CONFIG_ITEM_STRING      0x05    /* A string */
111 #define MODULE_CONFIG_ITEM_FILE        0x06    /* A file selector */
112 #define MODULE_CONFIG_ITEM_CHECK       0x07    /* A checkbox */
113 #define MODULE_CONFIG_ITEM_CHOOSE      0x08    /* A choose box */
114 #define MODULE_CONFIG_ITEM_RADIO       0x09    /* A radio box */
115 #define MODULE_CONFIG_ITEM_SCALE       0x0a    /* A horizontal ruler */
116 #define MODULE_CONFIG_ITEM_SPIN        0x0b    /* A numerical selector */
117
118 typedef struct module_config_s
119 {
120     int         i_type;                         /* Configuration widget type */
121     char *      psz_text;        /* Text commenting or describing the widget */
122     char *      psz_name;                                   /* Variable name */
123     void *      p_getlist;          /* Function to call to get a choice list */
124     void *      p_change;        /* Function to call when commiting a change */
125 } module_config_t;
126
127 /*****************************************************************************
128  * Bank and module description structures
129  *****************************************************************************/
130
131 /* The module bank structure */
132 typedef struct module_bank_s
133 {
134     struct module_s *   first; /* First module of the bank */
135
136     vlc_mutex_t         lock;  /* Global lock -- you can't imagine how awful it
137                                   is to design thread-safe linked lists. */
138 } module_bank_t;
139
140 /* The module description structure */
141 typedef struct module_s
142 {
143     boolean_t           b_builtin;  /* Set to true if the module is built in */
144
145     module_handle_t     handle;      /* Unique handle to refer to the module */
146     char *              psz_filename;                     /* Module filename */
147
148     char *              psz_name;                    /* Module _unique_ name */
149     char *              psz_longname;             /* Module descriptive name */
150     char *              psz_version;                       /* Module version */
151
152     int                 i_usage;                        /* Reference counter */
153     int                 i_unused_delay;    /* Delay until module is unloaded */
154
155     struct module_s *   next;                                 /* Next module */
156     struct module_s *   prev;                             /* Previous module */
157
158     module_config_t *   p_config;    /* Module configuration structure table */
159
160     u32                     i_capabilities;               /* Capability list */
161     p_module_functions_t    p_functions;             /* Capability functions */
162
163 } module_t;
164
165 /*****************************************************************************
166  * Exported functions.
167  *****************************************************************************/
168 module_bank_t * module_CreateBank   ( void );
169 void            module_InitBank     ( module_bank_t * p_bank );
170 void            module_DestroyBank  ( module_bank_t * p_bank );
171 void            module_ResetBank    ( module_bank_t * p_bank );
172 void            module_ManageBank   ( module_bank_t * p_bank );
173
174 module_t *      module_Need         ( module_bank_t *p_bank,
175                                       int i_capabilities, void *p_data );
176 void            module_Unneed       ( module_bank_t * p_bank,
177                                       module_t * p_module );
178