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., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
24 #ifndef __GST_PLUGIN_H__
25 #define __GST_PLUGIN_H__
27 #include <gst/gstconfig.h>
29 #include <time.h> /* time_t */
30 #include <sys/types.h> /* off_t */
31 #include <sys/stat.h> /* off_t */
33 #include <gst/gstobject.h>
34 #include <gst/gstmacros.h>
38 typedef struct _GstPlugin GstPlugin;
39 typedef struct _GstPluginClass GstPluginClass;
40 typedef struct _GstPluginPrivate GstPluginPrivate;
41 typedef struct _GstPluginDesc GstPluginDesc;
44 * gst_plugin_error_quark:
46 * Get the error quark.
48 * Returns: The error quark used in GError messages
50 GQuark gst_plugin_error_quark (void);
54 * The error message category quark
56 #define GST_PLUGIN_ERROR gst_plugin_error_quark ()
60 * @GST_PLUGIN_ERROR_MODULE: The plugin could not be loaded
61 * @GST_PLUGIN_ERROR_DEPENDENCIES: The plugin has unresolved dependencies
62 * @GST_PLUGIN_ERROR_NAME_MISMATCH: The plugin has already be loaded from a different file
64 * The plugin loading errors
68 GST_PLUGIN_ERROR_MODULE,
69 GST_PLUGIN_ERROR_DEPENDENCIES,
70 GST_PLUGIN_ERROR_NAME_MISMATCH
76 GST_PLUGIN_FLAG_CACHED = (1<<0)
80 * GstPluginDependencyFlags:
81 * @GST_PLUGIN_DEPENDENCY_FLAG_NONE : no special flags
82 * @GST_PLUGIN_DEPENDENCY_FLAG_RECURSE : recurse into subdirectories
83 * @GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY : use paths
84 * argument only if none of the environment variables is set
85 * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX : interpret
86 * filename argument as filter suffix and check all matching files in
89 * Flags used in connection with gst_plugin_add_dependency().
94 GST_PLUGIN_DEPENDENCY_FLAG_NONE = 0,
95 GST_PLUGIN_DEPENDENCY_FLAG_RECURSE = (1 << 0),
96 GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY = (1 << 1),
97 GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX = (1 << 2)
98 } GstPluginDependencyFlags;
102 * @plugin: The plugin object that can be used to register #GstPluginFeatures for this plugin.
104 * A plugin should provide a pointer to a function of this type in the
105 * plugin_desc struct.
106 * This function will be called by the loader at startup.
108 * Returns: %TRUE if plugin initialised successfully
110 typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin);
113 * GstPluginInitFullFunc:
114 * @plugin: The plugin object that can be used to register #GstPluginFeatures for this plugin.
115 * @user_data: The user data.
117 * A plugin should provide a pointer to a function of either #GstPluginInitFunc
118 * or this type in the plugin_desc struct.
119 * The function will be called by the loader at startup. This version allows
120 * user data to be passed to init function (useful for bindings).
122 * Returns: %TRUE if plugin initialised successfully
127 typedef gboolean (*GstPluginInitFullFunc) (GstPlugin *plugin, gpointer user_data);
131 * @major_version: the major version number of core that plugin was compiled for
132 * @minor_version: the minor version number of core that plugin was compiled for
133 * @name: a unique name of the plugin
134 * @description: description of plugin
135 * @plugin_init: pointer to the init function of this plugin.
136 * @version: version of the plugin
137 * @license: effective license of plugin
138 * @source: source module plugin belongs to
139 * @package: shipped package plugin belongs to
140 * @origin: URL to provider of plugin
141 * @_gst_reserved: private, for later expansion
143 * A plugin should export a variable of this type called plugin_desc. The plugin
144 * loader will use the data provided there to initialize the plugin.
146 * The @licence parameter must be one of: LGPL, GPL, QPL, GPL/QPL, MPL,
147 * BSD, MIT/X11, Proprietary, unknown.
149 struct _GstPluginDesc {
154 GstPluginInitFunc plugin_init;
155 const gchar *version;
156 const gchar *license;
158 const gchar *package;
161 gpointer _gst_reserved[GST_PADDING];
165 #define GST_TYPE_PLUGIN (gst_plugin_get_type())
166 #define GST_IS_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLUGIN))
167 #define GST_IS_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLUGIN))
168 #define GST_PLUGIN_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLUGIN, GstPluginClass))
169 #define GST_PLUGIN(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLUGIN, GstPlugin))
170 #define GST_PLUGIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLUGIN, GstPluginClass))
171 #define GST_PLUGIN_CAST(obj) ((GstPlugin*)(obj))
184 GstPluginDesc *orig_desc;
189 gchar * basename; /* base name (non-dir part) of plugin path */
191 GModule * module; /* contains the module if plugin is loaded */
195 gboolean registered; /* TRUE when the registry has seen a filename
196 * that matches the plugin's basename */
198 GstPluginPrivate *priv;
199 gpointer _gst_reserved[GST_PADDING - 1];
202 struct _GstPluginClass {
203 GstObjectClass object_class;
206 gpointer _gst_reserved[GST_PADDING];
211 * @major: major version number of the gstreamer-core that plugin was compiled for
212 * @minor: minor version number of the gstreamer-core that plugin was compiled for
213 * @name: short, but unique name of the plugin
214 * @description: information about the purpose of the plugin
215 * @init: function pointer to the plugin_init method with the signature of <code>static gboolean plugin_init (GstPlugin * plugin)</code>.
216 * @version: full version string (e.g. VERSION from config.h)
217 * @license: under which licence the package has been released, e.g. GPL, LGPL.
218 * @package: the package-name (e.g. PACKAGE_NAME from config.h)
219 * @origin: a description from where the package comes from (e.g. the homepage URL)
221 * This macro needs to be used to define the entry point and meta data of a
222 * plugin. One would use this macro to export a plugin, so that it can be used
223 * by other applications.
225 * The macro uses a define named PACKAGE for the #GstPluginDesc,source field.
227 #define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin) \
228 GST_PLUGIN_EXPORT GstPluginDesc gst_plugin_desc = { \
232 (gchar *) description, \
243 * GST_PLUGIN_DEFINE_STATIC:
244 * @major: major version number of the gstreamer-core that plugin was compiled for
245 * @minor: minor version number of the gstreamer-core that plugin was compiled for
246 * @name: short, but unique name of the plugin
247 * @description: information about the purpose of the plugin
248 * @init: function pointer to the plugin_init method with the signature of <code>static gboolean plugin_init (GstPlugin * plugin)</code>.
249 * @version: full version string (e.g. VERSION from config.h)
250 * @license: under which licence the package has been released, e.g. GPL, LGPL.
251 * @package: the package-name (e.g. PACKAGE_NAME from config.h)
252 * @origin: a description from where the package comes from (e.g. the homepage URL)
254 * This macro needs to be used to define the entry point and meta data of a
255 * local plugin. One would use this macro to define a local plugin that can only
256 * be used by the own application.
258 * The macro uses a define named PACKAGE for the #GstPluginDesc.source field.
260 * Deprecated: Use gst_plugin_register_static() instead. This macro was
261 * deprecated because it uses constructors, which is a compiler feature not
262 * available on all compilers.
265 /* We don't have deprecation guards here on purpose, it's enough to have
266 * deprecation guards around _gst_plugin_register_static(), and will result in
267 * much better error messages when compiling with -DGST_DISABLE_DEPRECATED */
268 #define GST_PLUGIN_DEFINE_STATIC(major,minor,name,description,init,version,license,package,origin) \
269 static void GST_GNUC_CONSTRUCTOR \
270 _gst_plugin_static_init__ ##init (void) \
272 static GstPluginDesc plugin_desc_ = { \
276 (gchar *) description, \
285 _gst_plugin_register_static (&plugin_desc_); \
289 * GST_LICENSE_UNKNOWN:
291 * To be used in GST_PLUGIN_DEFINE or GST_PLUGIN_DEFINE_STATIC if usure about
294 #define GST_LICENSE_UNKNOWN "unknown"
297 /* function for filters */
300 * @plugin: the plugin to check
301 * @user_data: the user_data that has been passed on e.g. gst_registry_plugin_filter()
303 * A function that can be used with e.g. gst_registry_plugin_filter()
304 * to get a list of plugins that match certain criteria.
306 * Returns: TRUE for a positive match, FALSE otherwise
308 typedef gboolean (*GstPluginFilter) (GstPlugin *plugin,
311 GType gst_plugin_get_type (void);
313 #ifndef GST_DISABLE_DEPRECATED
314 void _gst_plugin_register_static (GstPluginDesc *desc);
317 gboolean gst_plugin_register_static (gint major_version,
321 GstPluginInitFunc init_func,
322 const gchar *version,
323 const gchar *license,
325 const gchar *package,
326 const gchar *origin);
328 gboolean gst_plugin_register_static_full (gint major_version,
332 GstPluginInitFullFunc init_full_func,
333 const gchar *version,
334 const gchar *license,
336 const gchar *package,
340 G_CONST_RETURN gchar* gst_plugin_get_name (GstPlugin *plugin);
341 G_CONST_RETURN gchar* gst_plugin_get_description (GstPlugin *plugin);
342 G_CONST_RETURN gchar* gst_plugin_get_filename (GstPlugin *plugin);
343 G_CONST_RETURN gchar* gst_plugin_get_version (GstPlugin *plugin);
344 G_CONST_RETURN gchar* gst_plugin_get_license (GstPlugin *plugin);
345 G_CONST_RETURN gchar* gst_plugin_get_source (GstPlugin *plugin);
346 G_CONST_RETURN gchar* gst_plugin_get_package (GstPlugin *plugin);
347 G_CONST_RETURN gchar* gst_plugin_get_origin (GstPlugin *plugin);
348 GModule * gst_plugin_get_module (GstPlugin *plugin);
349 gboolean gst_plugin_is_loaded (GstPlugin *plugin);
351 gboolean gst_plugin_name_filter (GstPlugin *plugin, const gchar *name);
353 GstPlugin * gst_plugin_load_file (const gchar *filename, GError** error);
355 GstPlugin * gst_plugin_load (GstPlugin *plugin);
356 GstPlugin * gst_plugin_load_by_name (const gchar *name);
358 void gst_plugin_add_dependency (GstPlugin * plugin,
359 const gchar ** env_vars,
360 const gchar ** paths,
361 const gchar ** names,
362 GstPluginDependencyFlags flags);
364 void gst_plugin_add_dependency_simple (GstPlugin * plugin,
365 const gchar * env_vars,
368 GstPluginDependencyFlags flags);
370 void gst_plugin_list_free (GList *list);
374 #endif /* __GST_PLUGIN_H__ */