VLC 4.0.0-dev
Loading...
Searching...
No Matches
modules.h
Go to the documentation of this file.
1/*****************************************************************************
2 * modules.h : Module management functions.
3 *****************************************************************************
4 * Copyright (C) 2001-2016 VLC authors and VideoLAN
5 *
6 * Authors: Samuel Hocevar <sam@zoy.org>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Lesser General Public License as published by
10 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this program; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
21 *****************************************************************************/
22
23#ifndef LIBVLC_MODULES_H
24# define LIBVLC_MODULES_H 1
25
26# include <stdatomic.h>
27# include <vlc_plugin.h>
28
29struct vlc_param;
30
31/** VLC plugin */
32typedef struct vlc_plugin_t
33{
35 module_t *module;
36 unsigned modules_count;
37
38 const char *textdomain; /**< gettext domain (or NULL) */
39
40 /**
41 * Variables set by the module to store its config options
42 */
43 struct
44 {
45 struct vlc_param *params; /**< Table of configuration items */
46 size_t size; /**< Total count of all items */
47 size_t count; /**< Count of real options (excludes hints) */
48 size_t booleans; /**< Count of options that are of boolean type */
50
51#ifdef HAVE_DYNAMIC_PLUGINS
52 bool unloadable; /**< Whether the plug-in can be unloaded safely */
53 atomic_uintptr_t handle; /**< Run-time linker handle (or nul) */
54 char *abspath; /**< Absolute path */
55
56 char *path; /**< Relative path (within plug-in directory) */
57 int64_t mtime; /**< Last modification time */
58 uint64_t size; /**< File size */
59#endif
61
62/**
63 * List of all plug-ins.
64 */
65extern struct vlc_plugin_t *vlc_plugins;
66
67#define MODULE_SHORTCUT_MAX 20
68
69/** Plugin deactivation callback */
71
72/**
73 * Internal module descriptor
74 */
76{
77 vlc_plugin_t *plugin; /**< Plug-in/library containing the module */
79
80 /** Shortcuts to the module */
81 unsigned i_shortcuts;
82 const char **pp_shortcuts;
83
84 /*
85 * Variables set by the module to identify itself
86 */
87 const char *psz_shortname; /**< Module name */
88 const char *psz_longname; /**< Module descriptive name */
89 const char *psz_help; /**< Long help plain string for "special" modules */
90 const char *psz_help_html; /**< Long help HTML string, shown instead of the plain help where it makes sense to render HTML.
91 Supports only a limited HTML4 subset, see https://doc.qt.io/qt-6/richtext-html-subset.html */
92
93 const char *psz_capability; /**< Capability */
94 int i_score; /**< Score for the capability */
95
96 /* Callbacks */
97 const char *activate_name;
98 const char *deactivate_name;
101};
102
107
110
111void module_InitBank (void);
113void module_EndBank (bool);
114int vlc_plugin_Map(struct vlc_logger *, vlc_plugin_t *);
115void *vlc_plugin_Symbol(struct vlc_logger *, vlc_plugin_t *, const char *name);
116
117/**
118 * Lists of all VLC modules with a given capability.
119 *
120 * This functions returns a table of all VLC modules whose capability
121 * matches the supplied capability name. Entries are sorted by decreasing
122 * module score.
123 *
124 * \note This function cannot fail. It returns zero if, and only if, no
125 * modules match the requested capability inside the module bank.
126 *
127 * @param tab pointer to the table of modules [OUT]
128 * @param name capability nul-terminated string (cannot be NULL)
129 * @return the number of entries in the table
130 */
131size_t module_list_cap(module_t *const **tab, const char *name);
132
133int vlc_bindtextdomain (const char *);
134
135/* Low-level OS-dependent handler */
136
137/**
138 * Loads a dynamically linked library.
139 *
140 * \param path library file path
141 * \param lazy whether to resolve the symbols lazily
142 * \return a module handle on success, or NULL on error.
143 */
144void *vlc_dlopen(const char *path, bool) VLC_USED;
145
146/**
147 * Unloads a dynamic library.
148 *
149 * This function unloads a previously opened dynamically linked library
150 * using a system dependent method.
151 * \param handle handle of the library
152 * \retval 0 on success
153 * \retval -1 on error (none are defined though)
154 */
155int vlc_dlclose(void *);
156
157/**
158 * Looks up a symbol from a dynamically loaded library
159 *
160 * This function looks for a named symbol within a loaded library.
161 *
162 * \param handle handle to the library
163 * \param name function name
164 * \return the address of the symbol on success, or NULL on error
165 *
166 * \note If the symbol address is NULL, errors cannot be detected. However,
167 * normal symbols such as function or global variables cannot have NULL as
168 * their address.
169 */
170void *vlc_dlsym(void *handle, const char *name) VLC_USED;
171
172/**
173 * Formats an error message for vlc_dlopen() or vlc_dlsym().
174 *
175 * \return a heap-allocated nul-terminated error string, or NULL.
176 */
177char *vlc_dlerror(void) VLC_USED;
178
179/* Plugins cache */
182
183void CacheSave(libvlc_int_t *, const char *, vlc_plugin_t *const *, size_t);
184
185#endif /* !LIBVLC_MODULES_H */
#define VLC_USED
Definition fourcc_gen.c:32
const char name[16]
Definition httpd.c:1298
char * vlc_dlerror(void)
Formats an error message for vlc_dlopen() or vlc_dlsym().
Definition plugin.c:65
int vlc_plugin_Map(struct vlc_logger *, vlc_plugin_t *)
Definition bank.c:699
vlc_plugin_t * vlc_cache_load(libvlc_int_t *, const char *, block_t **)
vlc_plugin_t * vlc_cache_lookup(vlc_plugin_t **, const char *relpath)
module_t * vlc_module_create(vlc_plugin_t *)
Definition entry.c:42
void * vlc_dlsym(void *handle, const char *name)
Looks up a symbol from a dynamically loaded library.
Definition plugin.c:57
struct vlc_plugin_t * vlc_plugins
List of all plug-ins.
Definition bank.c:106
vlc_plugin_t * vlc_plugin_describe(vlc_plugin_cb)
Runs a plug-in descriptor.
Definition entry.c:492
int vlc_dlclose(void *)
Unloads a dynamic library.
Definition plugin.c:52
vlc_plugin_t * vlc_plugin_create(void)
Definition entry.c:97
void * vlc_plugin_Symbol(struct vlc_logger *, vlc_plugin_t *, const char *name)
Definition bank.c:710
void module_LoadPlugins(libvlc_int_t *)
Loads module descriptions for all available plugins.
Definition bank.c:803
void * vlc_dlopen(const char *path, bool)
Loads a dynamically linked library.
Definition plugin.c:40
void module_InitBank(void)
Init bank.
Definition bank.c:724
void vlc_plugin_destroy(vlc_plugin_t *)
Destroys a plug-in.
Definition entry.c:125
void module_EndBank(bool)
Unloads all unused plugin modules and empties the module bank in case of success.
Definition bank.c:756
void(* vlc_deactivate_cb)(vlc_object_t *)
Plugin deactivation callback.
Definition modules.h:70
void CacheSave(libvlc_int_t *, const char *, vlc_plugin_t *const *, size_t)
void vlc_module_destroy(module_t *)
Destroys a module.
Definition entry.c:85
int vlc_plugin_resolve(vlc_plugin_t *, vlc_plugin_cb)
Definition entry.c:630
size_t module_list_cap(module_t *const **tab, const char *name)
Lists of all VLC modules with a given capability.
int vlc_bindtextdomain(const char *)
Definition textdomain.c:34
Definition vlc_objects.h:103
Internal module descriptor.
Definition modules.h:76
const char * psz_longname
Module descriptive name.
Definition modules.h:88
const char * psz_shortname
Module name.
Definition modules.h:87
module_t * next
Definition modules.h:78
const char ** pp_shortcuts
Definition modules.h:82
const char * psz_help
Long help plain string for "special" modules.
Definition modules.h:89
const char * psz_help_html
Long help HTML string, shown instead of the plain help where it makes sense to render HTML.
Definition modules.h:90
void * pf_activate
Definition modules.h:99
unsigned i_shortcuts
Shortcuts to the module.
Definition modules.h:81
const char * deactivate_name
Definition modules.h:98
int i_score
Score for the capability.
Definition modules.h:94
vlc_plugin_t * plugin
Plug-in/library containing the module.
Definition modules.h:77
const char * psz_capability
Capability.
Definition modules.h:93
const char * activate_name
Definition modules.h:97
vlc_deactivate_cb deactivate
Definition modules.h:100
Definition vlc_frame.h:123
Definition messages.c:85
VLC object common members.
Definition vlc_objects.h:53
Definition configuration.h:30
VLC plugin.
Definition modules.h:33
struct vlc_plugin_t * next
Definition modules.h:34
size_t size
Total count of all items.
Definition modules.h:46
size_t booleans
Count of options that are of boolean type.
Definition modules.h:48
struct vlc_plugin_t::@103 conf
Variables set by the module to store its config options.
module_t *unsigned modules_count
Definition modules.h:36
size_t count
Count of real options (excludes hints)
Definition modules.h:47
struct vlc_param * params
Table of configuration items.
Definition modules.h:45
const char * textdomain
gettext domain (or NULL)
Definition modules.h:38
This file implements plugin (module) macros used to define a vlc module.
int(* vlc_plugin_cb)(vlc_set_cb, void *)
Plugin entry point prototype.
Definition vlc_plugin.h:294