]> git.sesse.net Git - vlc/blob - include/modules.h
c1151ae2cb8b325bf6f93026921be774280818dc
[vlc] / include / modules.h
1 /*****************************************************************************
2  * modules.h : Module management functions.
3  *****************************************************************************
4  * Copyright (C) 2001 the VideoLAN team
5  * $Id$
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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Module #defines.
26  *****************************************************************************/
27
28 /* Number of tries before we unload an unused module */
29 #define MODULE_HIDE_DELAY 50
30 #define MODULE_SHORTCUT_MAX 50
31
32 /* The module handle type. */
33 #if defined(HAVE_DL_DYLD)
34 #   if defined (HAVE_MACH_O_DYLD_H)
35 #       include <mach-o/dyld.h>
36 #   endif
37 typedef NSModule module_handle_t;
38 #elif defined(HAVE_IMAGE_H)
39 typedef int module_handle_t;
40 #elif defined(WIN32) || defined(UNDER_CE)
41 typedef void * module_handle_t;
42 #elif defined(HAVE_DL_DLOPEN)
43 typedef void * module_handle_t;
44 #elif defined(HAVE_DL_SHL_LOAD)
45 typedef shl_t module_handle_t;
46 #endif
47
48 /*****************************************************************************
49  * module_bank_t: the module bank
50  *****************************************************************************
51  * This variable is accessed by any function using modules.
52  *****************************************************************************/
53 struct module_bank_t
54 {
55     VLC_COMMON_MEMBERS
56
57     int              i_usage;
58 #ifndef HAVE_SHARED_LIBVLC
59     module_symbols_t symbols;
60 #endif
61
62     vlc_bool_t       b_main;
63     vlc_bool_t       b_builtins;
64     vlc_bool_t       b_plugins;
65
66     /* Plugins cache */
67     vlc_bool_t     b_cache;
68     vlc_bool_t     b_cache_dirty;
69     vlc_bool_t     b_cache_delete;
70
71     int            i_cache;
72     module_cache_t **pp_cache;
73
74     int            i_loaded_cache;
75     module_cache_t **pp_loaded_cache;
76 };
77
78 /*****************************************************************************
79  * Module description structure
80  *****************************************************************************/
81 struct module_t
82 {
83     VLC_COMMON_MEMBERS
84
85     /*
86      * Variables set by the module to identify itself
87      */
88     const char *psz_shortname;                                /* Module name */
89     const char *psz_longname;                     /* Module descriptive name */
90     const char *psz_help;          /* Long help string for "special" modules */
91
92     /*
93      * Variables set by the module to tell us what it can do
94      */
95     const char *psz_program;  /* Program name which will activate the module */
96
97     const char *pp_shortcuts[ MODULE_SHORTCUT_MAX ]; /* Shortcuts to the module */
98
99     const char    *psz_capability;                             /* Capability */
100     int      i_score;                           /* Score for each capability */
101     uint32_t i_cpu;                             /* Required CPU capabilities */
102
103     vlc_bool_t b_unloadable;                          /* Can we be dlclosed? */
104     vlc_bool_t b_reentrant;                             /* Are we reentrant? */
105     vlc_bool_t b_submodule;                          /* Is this a submodule? */
106
107     /* Callbacks */
108     int  ( * pf_activate )   ( vlc_object_t * );
109     void ( * pf_deactivate ) ( vlc_object_t * );
110
111     /*
112      * Variables set by the module to store its config options
113      */
114     module_config_t *p_config;             /* Module configuration structure */
115     unsigned int     i_config_items;        /* number of configuration items */
116     unsigned int     i_bool_items;            /* number of bool config items */
117
118     /*
119      * Variables used internally by the module manager
120      */
121     /* Plugin-specific stuff */
122     module_handle_t     handle;                             /* Unique handle */
123     char *              psz_filename;                     /* Module filename */
124
125     vlc_bool_t          b_builtin;  /* Set to true if the module is built in */
126     vlc_bool_t          b_loaded;        /* Set to true if the dll is loaded */
127
128     /*
129      * Symbol table we send to the module so that it can access vlc symbols
130      */
131     module_symbols_t *p_symbols;
132 };
133
134 /*****************************************************************************
135  * Module cache description structure
136  *****************************************************************************/
137 struct module_cache_t
138 {
139     /* Mandatory cache entry header */
140     char       *psz_file;
141     int64_t    i_time;
142     int64_t    i_size;
143     vlc_bool_t b_junk;
144
145     /* Optional extra data */
146     module_t *p_module;
147 };
148
149 /*****************************************************************************
150  * Exported functions.
151  *****************************************************************************/
152 #define module_InitBank(a)     __module_InitBank(VLC_OBJECT(a))
153 void  __module_InitBank        ( vlc_object_t * );
154 #define module_LoadMain(a)     __module_LoadMain(VLC_OBJECT(a))
155 void  __module_LoadMain        ( vlc_object_t * );
156 #define module_LoadBuiltins(a) __module_LoadBuiltins(VLC_OBJECT(a))
157 void  __module_LoadBuiltins    ( vlc_object_t * );
158 #define module_LoadPlugins(a)  __module_LoadPlugins(VLC_OBJECT(a))
159 void  __module_LoadPlugins     ( vlc_object_t * );
160 #define module_EndBank(a)      __module_EndBank(VLC_OBJECT(a))
161 void  __module_EndBank         ( vlc_object_t * );
162 #define module_ResetBank(a)    __module_ResetBank(VLC_OBJECT(a))
163 void  __module_ResetBank       ( vlc_object_t * );
164
165 #define module_Need(a,b,c,d) __module_Need(VLC_OBJECT(a),b,c,d)
166 VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, const char *, const char *, vlc_bool_t ) );
167 #define module_Unneed(a,b) __module_Unneed(VLC_OBJECT(a),b)
168 VLC_EXPORT( void, __module_Unneed, ( vlc_object_t *, module_t * ) );
169