2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstplugin.h: Header for plugin subsystem
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
24 #ifndef __GST_PLUGIN_H__
25 #define __GST_PLUGIN_H__
27 #include <gst/gstconfig.h>
29 #include <gst/gstobject.h>
30 #include <gst/gstmacros.h>
31 #include <gst/gststructure.h>
38 * The opaque plugin object
40 typedef struct _GstPlugin GstPlugin;
41 typedef struct _GstPluginClass GstPluginClass;
42 typedef struct _GstPluginDesc GstPluginDesc;
45 * gst_plugin_error_quark:
47 * Get the error quark.
49 * Returns: The error quark used in GError messages
51 GQuark gst_plugin_error_quark (void);
55 * The error message category quark
57 #define GST_PLUGIN_ERROR gst_plugin_error_quark ()
61 * @GST_PLUGIN_ERROR_MODULE: The plugin could not be loaded
62 * @GST_PLUGIN_ERROR_DEPENDENCIES: The plugin has unresolved dependencies
63 * @GST_PLUGIN_ERROR_NAME_MISMATCH: The plugin has already be loaded from a different file
65 * The plugin loading errors
69 GST_PLUGIN_ERROR_MODULE,
70 GST_PLUGIN_ERROR_DEPENDENCIES,
71 GST_PLUGIN_ERROR_NAME_MISMATCH
76 * @GST_PLUGIN_FLAG_CACHED: Temporarily loaded plugins
77 * @GST_PLUGIN_FLAG_BLACKLISTED: The plugin won't be scanned (again)
79 * The plugin loading state
83 GST_PLUGIN_FLAG_CACHED = (GST_OBJECT_FLAG_LAST << 0),
84 GST_PLUGIN_FLAG_BLACKLISTED = (GST_OBJECT_FLAG_LAST << 1)
88 * GstPluginDependencyFlags:
89 * @GST_PLUGIN_DEPENDENCY_FLAG_NONE : no special flags
90 * @GST_PLUGIN_DEPENDENCY_FLAG_RECURSE : recurse into subdirectories
91 * @GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY : use paths
92 * argument only if none of the environment variables is set
93 * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX : interpret
94 * filename argument as filter suffix and check all matching files in
96 * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX : interpret
97 * filename argument as filter prefix and check all matching files in
98 * the directory. Since 1.8.
100 * Flags used in connection with gst_plugin_add_dependency().
103 GST_PLUGIN_DEPENDENCY_FLAG_NONE = 0,
104 GST_PLUGIN_DEPENDENCY_FLAG_RECURSE = (1 << 0),
105 GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY = (1 << 1),
106 GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX = (1 << 2),
107 GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX = (1 << 3)
108 } GstPluginDependencyFlags;
112 * @plugin: The plugin object
114 * A plugin should provide a pointer to a function of this type in the
115 * plugin_desc struct.
116 * This function will be called by the loader at startup. One would then
117 * register each #GstPluginFeature.
119 * Returns: %TRUE if plugin initialised successfully
121 /* FIXME 0.11: Make return void */
122 typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin);
125 * GstPluginInitFullFunc:
126 * @plugin: The plugin object
127 * @user_data: extra data
129 * A plugin should provide a pointer to a function of either #GstPluginInitFunc
130 * or this type in the plugin_desc struct.
131 * The function will be called by the loader at startup. One would then
132 * register each #GstPluginFeature. This version allows
133 * user data to be passed to init function (useful for bindings).
135 * Returns: %TRUE if plugin initialised successfully
137 /* FIXME 0.11: Merge with GstPluginInitFunc */
138 typedef gboolean (*GstPluginInitFullFunc) (GstPlugin *plugin, gpointer user_data);
142 * @major_version: the major version number of core that plugin was compiled for
143 * @minor_version: the minor version number of core that plugin was compiled for
144 * @name: a unique name of the plugin
145 * @description: description of plugin
146 * @plugin_init: pointer to the init function of this plugin.
147 * @version: version of the plugin
148 * @license: effective license of plugin
149 * @source: source module plugin belongs to
150 * @package: shipped package plugin belongs to
151 * @origin: URL to provider of plugin
152 * @release_datetime: (allow-none): date time string in ISO 8601
153 * format (or rather, a subset thereof), or %NULL. Allowed are the
154 * following formats: "YYYY-MM-DD" and "YYY-MM-DDTHH:MMZ" (with
155 * 'T' a separator and 'Z' indicating UTC/Zulu time). This field
156 * should be set via the GST_PACKAGE_RELEASE_DATETIME
157 * preprocessor macro.
159 * A plugin should export a variable of this type called plugin_desc. The plugin
160 * loader will use the data provided there to initialize the plugin.
162 * The @licence parameter must be one of: LGPL, GPL, QPL, GPL/QPL, MPL,
163 * BSD, MIT/X11, Proprietary, unknown.
165 struct _GstPluginDesc {
169 const gchar *description;
170 GstPluginInitFunc plugin_init;
171 const gchar *version;
172 const gchar *license;
174 const gchar *package;
176 const gchar *release_datetime;
178 gpointer _gst_reserved[GST_PADDING];
182 #define GST_TYPE_PLUGIN (gst_plugin_get_type())
183 #define GST_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLUGIN))
184 #define GST_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLUGIN))
185 #define GST_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLUGIN, GstPluginClass))
186 #define GST_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLUGIN, GstPlugin))
187 #define GST_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLUGIN, GstPluginClass))
188 #define GST_PLUGIN_CAST(obj) ((GstPlugin*)(obj))
190 #ifdef GST_PACKAGE_RELEASE_DATETIME
191 #define __GST_PACKAGE_RELEASE_DATETIME GST_PACKAGE_RELEASE_DATETIME
193 #define __GST_PACKAGE_RELEASE_DATETIME NULL
197 * GST_PLUGIN_STATIC_DECLARE:
198 * @name: short, but unique name of the plugin
200 * This macro can be used to initialize statically linked plugins. It is
201 * necessary to call this macro before the plugin can be used.
202 * It has to be used in combination with GST_PLUGIN_STATIC_REGISTER
203 * and must be placed outside any block to declare the plugin initialization
208 #define GST_PLUGIN_STATIC_DECLARE(name) \
209 extern void G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void)
212 * GST_PLUGIN_STATIC_REGISTER:
213 * @name: short, but unique name of the plugin
215 * This macro can be used to initialize statically linked plugins. It is
216 * necessary to call this macro before the plugin can be used.
217 * It has to be used in combination with GST_PLUGIN_STATIC_DECLARE and
218 * calls the plugin initialization function.
222 #define GST_PLUGIN_STATIC_REGISTER(name) G_PASTE(gst_plugin_, G_PASTE(name, _register)) ()
226 * @major: major version number of the gstreamer-core that plugin was compiled for
227 * @minor: minor version number of the gstreamer-core that plugin was compiled for
228 * @name: short, but unique name of the plugin
229 * @description: information about the purpose of the plugin
230 * @init: function pointer to the plugin_init method with the signature of <code>static gboolean plugin_init (GstPlugin * plugin)</code>.
231 * @version: full version string (e.g. VERSION from config.h)
232 * @license: under which licence the package has been released, e.g. GPL, LGPL.
233 * @package: the package-name (e.g. PACKAGE_NAME from config.h)
234 * @origin: a description from where the package comes from (e.g. the homepage URL)
236 * This macro needs to be used to define the entry point and meta data of a
237 * plugin. One would use this macro to export a plugin, so that it can be used
238 * by other applications.
240 * The macro uses a define named PACKAGE for the #GstPluginDesc,source field.
241 * When using autoconf, this is usually set automatically via the AC_INIT
242 * macro, and set in config.h. If you are not using autoconf, you will need to
243 * define PACKAGE yourself and set it to a short mnemonic string identifying
244 * your application/package, e.g. 'someapp' or 'my-plugins-foo.
246 * If defined, the GST_PACKAGE_RELEASE_DATETIME will also be used for the
247 * #GstPluginDesc,release_datetime field.
249 #ifdef GST_PLUGIN_BUILD_STATIC
250 #define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin) \
252 GST_PLUGIN_EXPORT void G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void); \
255 G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void) \
257 gst_plugin_register_static (major, minor, G_STRINGIFY(name), \
258 description, init, version, license, \
259 PACKAGE, package, origin); \
262 #else /* !GST_PLUGIN_BUILD_STATIC */
263 #define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin) \
265 GST_PLUGIN_EXPORT GstPluginDesc gst_plugin_desc = { \
269 (gchar *) description, \
276 __GST_PACKAGE_RELEASE_DATETIME, \
280 #endif /* GST_PLUGIN_BUILD_STATIC */
283 * GST_LICENSE_UNKNOWN:
285 * To be used in GST_PLUGIN_DEFINE if unsure about the licence.
287 #define GST_LICENSE_UNKNOWN "unknown"
290 /* function for filters */
293 * @plugin: the plugin to check
294 * @user_data: the user_data that has been passed on e.g. gst_registry_plugin_filter()
296 * A function that can be used with e.g. gst_registry_plugin_filter()
297 * to get a list of plugins that match certain criteria.
299 * Returns: %TRUE for a positive match, %FALSE otherwise
301 typedef gboolean (*GstPluginFilter) (GstPlugin *plugin,
304 GType gst_plugin_get_type (void);
306 gboolean gst_plugin_register_static (gint major_version,
309 const gchar *description,
310 GstPluginInitFunc init_func,
311 const gchar *version,
312 const gchar *license,
314 const gchar *package,
315 const gchar *origin);
317 gboolean gst_plugin_register_static_full (gint major_version,
320 const gchar *description,
321 GstPluginInitFullFunc init_full_func,
322 const gchar *version,
323 const gchar *license,
325 const gchar *package,
329 const gchar* gst_plugin_get_name (GstPlugin *plugin);
330 const gchar* gst_plugin_get_description (GstPlugin *plugin);
331 const gchar* gst_plugin_get_filename (GstPlugin *plugin);
332 const gchar* gst_plugin_get_version (GstPlugin *plugin);
333 const gchar* gst_plugin_get_license (GstPlugin *plugin);
334 const gchar* gst_plugin_get_source (GstPlugin *plugin);
335 const gchar* gst_plugin_get_package (GstPlugin *plugin);
336 const gchar* gst_plugin_get_origin (GstPlugin *plugin);
337 const gchar* gst_plugin_get_release_date_string (GstPlugin *plugin);
338 const GstStructure* gst_plugin_get_cache_data (GstPlugin * plugin);
339 void gst_plugin_set_cache_data (GstPlugin * plugin, GstStructure *cache_data);
341 gboolean gst_plugin_is_loaded (GstPlugin *plugin);
343 GstPlugin * gst_plugin_load_file (const gchar *filename, GError** error);
345 GstPlugin * gst_plugin_load (GstPlugin *plugin);
346 GstPlugin * gst_plugin_load_by_name (const gchar *name);
348 void gst_plugin_add_dependency (GstPlugin * plugin,
349 const gchar ** env_vars,
350 const gchar ** paths,
351 const gchar ** names,
352 GstPluginDependencyFlags flags);
353 void gst_plugin_add_dependency_simple (GstPlugin * plugin,
354 const gchar * env_vars,
357 GstPluginDependencyFlags flags);
359 void gst_plugin_list_free (GList *list);
361 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
362 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPlugin, gst_object_unref)
367 #endif /* __GST_PLUGIN_H__ */