1 /*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001 the VideoLAN team
7 * Authors: Samuel Hocevar <sam@zoy.org>
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.
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.
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 *****************************************************************************/
24 #if defined(__PLUGIN__) || defined(__BUILTIN__) || !defined(__LIBVLC__)
25 # error This header file can only be included from LibVLC.
28 #ifndef __LIBVLC_MODULES_H
29 # define __LIBVLC_MODULES_H 1
32 /* Number of tries before we unload an unused module */
33 #define MODULE_HIDE_DELAY 50
35 /*****************************************************************************
36 * module_bank_t: the module bank
37 *****************************************************************************
38 * This variable is accessed by any function using modules.
39 *****************************************************************************/
49 module_cache_t **pp_cache;
52 module_cache_t **pp_loaded_cache;
57 /*****************************************************************************
58 * Module cache description structure
59 *****************************************************************************/
62 /* Mandatory cache entry header */
68 /* Optional extra data */
74 #define MODULE_SHORTCUT_MAX 50
76 /* The module handle type. */
77 #if defined(HAVE_DL_DYLD) && !defined(__x86_64__)
78 # if defined (HAVE_MACH_O_DYLD_H)
79 # include <mach-o/dyld.h>
81 typedef NSModule module_handle_t;
82 #elif defined(HAVE_IMAGE_H)
83 typedef int module_handle_t;
84 #elif defined(WIN32) || defined(UNDER_CE)
85 typedef void * module_handle_t;
86 #elif defined(HAVE_DL_DLOPEN)
87 typedef void * module_handle_t;
88 #elif defined(HAVE_DL_SHL_LOAD)
89 typedef shl_t module_handle_t;
93 * Internal module descriptor
97 char *psz_object_name;
101 unsigned submodule_count;
102 gc_object_t vlc_gc_data;
105 * Variables set by the module to identify itself
107 char *psz_shortname; /**< Module name */
108 char *psz_longname; /**< Module descriptive name */
109 char *psz_help; /**< Long help string for "special" modules */
111 /** Shortcuts to the module */
112 char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];
114 char *psz_capability; /**< Capability */
115 int i_score; /**< Score for the capability */
117 bool b_unloadable; /**< Can we be dlclosed? */
118 bool b_submodule; /**< Is this a submodule? */
121 int ( * pf_activate ) ( vlc_object_t * );
122 void ( * pf_deactivate ) ( vlc_object_t * );
125 * Variables set by the module to store its config options
127 module_config_t *p_config; /* Module configuration structure */
128 size_t confsize; /* Number of module_config_t items */
129 unsigned int i_config_items; /* number of configuration items */
130 unsigned int i_bool_items; /* number of bool config items */
133 * Variables used internally by the module manager
135 /* Plugin-specific stuff */
136 module_handle_t handle; /* Unique handle */
137 char * psz_filename; /* Module filename */
139 bool b_builtin; /* Set to true if the module is built in */
140 bool b_loaded; /* Set to true if the dll is loaded */
143 module_t *vlc_module_create (vlc_object_t *);
144 module_t *vlc_submodule_create (module_t *module);
146 #define module_InitBank(a) __module_InitBank(VLC_OBJECT(a))
147 void __module_InitBank ( vlc_object_t * );
148 void module_LoadPlugins( vlc_object_t *, bool );
149 #define module_LoadPlugins(a,b) module_LoadPlugins(VLC_OBJECT(a),b)
150 void module_EndBank( vlc_object_t *, bool );
151 #define module_EndBank(a,b) module_EndBank(VLC_OBJECT(a), b)
153 /* Low-level OS-dependent handler */
154 int module_Load (vlc_object_t *, const char *, module_handle_t *);
155 int module_Call (vlc_object_t *obj, module_t *);
156 void module_Unload (module_handle_t);
159 void CacheMerge (vlc_object_t *, module_t *, module_t *);
160 void CacheLoad (vlc_object_t *, module_bank_t *, bool);
161 void CacheSave (vlc_object_t *, module_bank_t *);
162 module_cache_t * CacheFind (module_bank_t *, const char *, int64_t, int64_t);
164 #endif /* !__LIBVLC_MODULES_H */