]> git.sesse.net Git - vlc/blob - include/vlc_modules.h
Cosmetic
[vlc] / include / vlc_modules.h
1 /*****************************************************************************
2  * modules.h : Module descriptor and load 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 #if !defined( __LIBVLC__ )
25   #error You are not libvlc or one of its plugins. You cannot include this file
26 #endif
27
28 #if 1
29 /* FIXME: scheduled for privatization */
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 descriptor
50  */
51 struct module_t
52 {
53     VLC_COMMON_MEMBERS
54
55     /*
56      * Variables set by the module to identify itself
57      */
58     const char *psz_shortname;                              /**< Module name */
59     const char *psz_longname;                   /**< Module descriptive name */
60     const char *psz_help;        /**< Long help string for "special" modules */
61
62     /** Shortcuts to the module */
63     const char *pp_shortcuts[ MODULE_SHORTCUT_MAX ];
64
65     char    *psz_capability;                                 /**< Capability */
66     int      i_score;                          /**< Score for the capability */
67     uint32_t i_cpu;                           /**< Required CPU capabilities */
68
69     vlc_bool_t b_unloadable;                        /**< Can we be dlclosed? */
70     vlc_bool_t b_reentrant;                           /**< Are we reentrant? */
71     vlc_bool_t b_submodule;                        /**< Is this a submodule? */
72
73     /* Callbacks */
74     int  ( * pf_activate )   ( vlc_object_t * );
75     void ( * pf_deactivate ) ( vlc_object_t * );
76
77     /*
78      * Variables set by the module to store its config options
79      */
80     module_config_t *p_config;             /* Module configuration structure */
81     size_t           confsize;            /* Number of module_config_t items */
82     unsigned int     i_config_items;        /* number of configuration items */
83     unsigned int     i_bool_items;            /* number of bool config items */
84
85     /*
86      * Variables used internally by the module manager
87      */
88     /* Plugin-specific stuff */
89     module_handle_t     handle;                             /* Unique handle */
90     char *              psz_filename;                     /* Module filename */
91
92     vlc_bool_t          b_builtin;  /* Set to true if the module is built in */
93     vlc_bool_t          b_loaded;        /* Set to true if the dll is loaded */
94 };
95 #endif
96
97 /*****************************************************************************
98  * Exported functions.
99  *****************************************************************************/
100 #define module_Need(a,b,c,d) __module_Need(VLC_OBJECT(a),b,c,d)
101 VLC_EXPORT( module_t *, __module_Need, ( vlc_object_t *, const char *, const char *, vlc_bool_t ) );
102 #define module_Unneed(a,b) __module_Unneed(VLC_OBJECT(a),b)
103 VLC_EXPORT( void, __module_Unneed, ( vlc_object_t *, module_t * ) );
104 #define module_Exists(a,b) __module_Exists(VLC_OBJECT(a),b)
105 VLC_EXPORT( vlc_bool_t,  __module_Exists, ( vlc_object_t *, const char * ) );
106
107 /* Use only if you know what you're doing... */
108 #define module_FindName(a,b) __module_FindName(VLC_OBJECT(a),b)
109 VLC_EXPORT( module_t *, __module_FindName, ( vlc_object_t *, const char * ) );
110
111 /* Return a NULL terminated array with the names of the modules that have a
112  * certain capability.
113  * Free after uses both the string and the table. */
114  #define module_GetModulesNamesForCapability(a,b,c) \
115                     __module_GetModulesNamesForCapability(VLC_OBJECT(a),b,c)
116 VLC_EXPORT(char **, __module_GetModulesNamesForCapability,
117                     ( vlc_object_t *p_this, const char * psz_capability,
118                       char ***psz_longname ) );
119
120 VLC_EXPORT( module_t *, vlc_module_create, ( vlc_object_t * ) );
121 VLC_EXPORT( module_t *, vlc_submodule_create, ( module_t * ) );
122 VLC_EXPORT( int, vlc_module_set, (module_t *module, int propid, void *value) );
123
124 enum vlc_module_properties
125 {
126     /* DO NOT EVER REMOVE, INSERT OR REPLACE ANY ITEM! It would break the ABI!
127      * Append new items at the end ONLY. */
128     VLC_MODULE_CPU_REQUIREMENT,
129     VLC_MODULE_SHORTCUT,
130     VLC_MODULE_SHORTNAME,
131     VLC_MODULE_DESCRIPTION,
132     VLC_MODULE_HELP,
133     VLC_MODULE_CAPABILITY,
134     VLC_MODULE_SCORE,
135     VLC_MODULE_PROGRAM,
136     VLC_MODULE_CB_OPEN,
137     VLC_MODULE_CB_CLOSE,
138     VLC_MODULE_UNLOADABLE,
139     VLC_MODULE_NAME
140 };
141
142 VLC_EXPORT( vlc_bool_t, module_IsCapable, ( const module_t *m, const char *cap ) );
143 VLC_EXPORT( const char *, module_GetObjName, ( const module_t *m ) );
144 VLC_EXPORT( const char *, module_GetName, ( const module_t *m, vlc_bool_t long_name ) );
145 #define module_GetLongName( m ) module_GetName( m, VLC_TRUE )
146 VLC_EXPORT( const char *, module_GetHelp, ( const module_t *m ) );