plugin: fix name expansion for GST_PLUGIN_DEFINE macro
[platform/upstream/gstreamer.git] / gst / gstplugin.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstplugin.h: Header for plugin subsystem
6  *
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.
11  *
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.
16  *
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.
21  */
22
23
24 #ifndef __GST_PLUGIN_H__
25 #define __GST_PLUGIN_H__
26
27 #include <gst/gstconfig.h>
28
29 #include <gst/gstobject.h>
30 #include <gst/gstmacros.h>
31 #include <gst/gststructure.h>
32
33 G_BEGIN_DECLS
34
35 /**
36  * GstPlugin:
37  *
38  * The opaque plugin object
39  */
40 typedef struct _GstPlugin GstPlugin;
41 typedef struct _GstPluginClass GstPluginClass;
42 typedef struct _GstPluginDesc GstPluginDesc;
43
44 /**
45  * gst_plugin_error_quark:
46  *
47  * Get the error quark.
48  *
49  * Returns: The error quark used in GError messages
50  */
51 GQuark gst_plugin_error_quark (void);
52 /**
53  * GST_PLUGIN_ERROR:
54  *
55  * The error message category quark
56  */
57 #define GST_PLUGIN_ERROR gst_plugin_error_quark ()
58
59 /**
60  * GstPluginError:
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
64  *
65  * The plugin loading errors
66  */
67 typedef enum
68 {
69   GST_PLUGIN_ERROR_MODULE,
70   GST_PLUGIN_ERROR_DEPENDENCIES,
71   GST_PLUGIN_ERROR_NAME_MISMATCH
72 } GstPluginError;
73
74 /**
75  * GstPluginFlags:
76  * @GST_PLUGIN_FLAG_CACHED: Temporarily loaded plugins
77  * @GST_PLUGIN_FLAG_BLACKLISTED: The plugin won't be scanned (again)
78  *
79  * The plugin loading state
80  */
81 typedef enum
82 {
83   GST_PLUGIN_FLAG_CACHED      = (GST_OBJECT_FLAG_LAST << 0),
84   GST_PLUGIN_FLAG_BLACKLISTED = (GST_OBJECT_FLAG_LAST << 1)
85 } GstPluginFlags;
86
87 /**
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
95  *         the directory
96  *
97  * Flags used in connection with gst_plugin_add_dependency().
98  */
99 typedef enum {
100   GST_PLUGIN_DEPENDENCY_FLAG_NONE = 0,
101   GST_PLUGIN_DEPENDENCY_FLAG_RECURSE = (1 << 0),
102   GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY = (1 << 1),
103   GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX = (1 << 2)
104 } GstPluginDependencyFlags;
105
106 /**
107  * GstPluginInitFunc:
108  * @plugin: The plugin object
109  *
110  * A plugin should provide a pointer to a function of this type in the
111  * plugin_desc struct.
112  * This function will be called by the loader at startup. One would then
113  * register each #GstPluginFeature.
114  *
115  * Returns: %TRUE if plugin initialised successfully
116  */
117 /* FIXME 0.11: Make return void */
118 typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin);
119
120 /**
121  * GstPluginInitFullFunc:
122  * @plugin: The plugin object
123  * @user_data: extra data
124  *
125  * A plugin should provide a pointer to a function of either #GstPluginInitFunc
126  * or this type in the plugin_desc struct.
127  * The function will be called by the loader at startup. One would then
128  * register each #GstPluginFeature. This version allows
129  * user data to be passed to init function (useful for bindings).
130  *
131  * Returns: %TRUE if plugin initialised successfully
132  */
133 /* FIXME 0.11: Merge with GstPluginInitFunc */
134 typedef gboolean (*GstPluginInitFullFunc) (GstPlugin *plugin, gpointer user_data);
135
136 /**
137  * GstPluginDesc:
138  * @major_version: the major version number of core that plugin was compiled for
139  * @minor_version: the minor version number of core that plugin was compiled for
140  * @name: a unique name of the plugin
141  * @description: description of plugin
142  * @plugin_init: pointer to the init function of this plugin.
143  * @version: version of the plugin
144  * @license: effective license of plugin
145  * @source: source module plugin belongs to
146  * @package: shipped package plugin belongs to
147  * @origin: URL to provider of plugin
148  * @release_datetime: date time string in ISO 8601 format (or rather, a
149  *     subset thereof), or NULL. Allowed are the following formats:
150  *     "YYYY-MM-DD" and "YYY-MM-DDTHH:MMZ" (with 'T' a separator and 'Z'
151  *     indicating UTC/Zulu time). This field should be set via the
152  *     GST_PACKAGE_RELEASE_DATETIME preprocessor macro.
153  *
154  * A plugin should export a variable of this type called plugin_desc. The plugin
155  * loader will use the data provided there to initialize the plugin.
156  *
157  * The @licence parameter must be one of: LGPL, GPL, QPL, GPL/QPL, MPL,
158  * BSD, MIT/X11, Proprietary, unknown.
159  */
160 struct _GstPluginDesc {
161   gint major_version;
162   gint minor_version;
163   const gchar *name;
164   const gchar *description;
165   GstPluginInitFunc plugin_init;
166   const gchar *version;
167   const gchar *license;
168   const gchar *source;
169   const gchar *package;
170   const gchar *origin;
171   const gchar *release_datetime;
172   /*< private >*/
173   gpointer _gst_reserved[GST_PADDING];
174 };
175
176
177 #define GST_TYPE_PLUGIN   (gst_plugin_get_type())
178 #define GST_IS_PLUGIN(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLUGIN))
179 #define GST_IS_PLUGIN_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLUGIN))
180 #define GST_PLUGIN_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLUGIN, GstPluginClass))
181 #define GST_PLUGIN(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLUGIN, GstPlugin))
182 #define GST_PLUGIN_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLUGIN, GstPluginClass))
183 #define GST_PLUGIN_CAST(obj)           ((GstPlugin*)(obj))
184
185 #ifdef GST_PACKAGE_RELEASE_DATETIME
186 #define __GST_PACKAGE_RELEASE_DATETIME GST_PACKAGE_RELEASE_DATETIME
187 #else
188 #define __GST_PACKAGE_RELEASE_DATETIME NULL
189 #endif
190
191 /**
192  * GST_PLUGIN_DEFINE:
193  * @major: major version number of the gstreamer-core that plugin was compiled for
194  * @minor: minor version number of the gstreamer-core that plugin was compiled for
195  * @name: short, but unique name of the plugin
196  * @description: information about the purpose of the plugin
197  * @init: function pointer to the plugin_init method with the signature of <code>static gboolean plugin_init (GstPlugin * plugin)</code>.
198  * @version: full version string (e.g. VERSION from config.h)
199  * @license: under which licence the package has been released, e.g. GPL, LGPL.
200  * @package: the package-name (e.g. PACKAGE_NAME from config.h)
201  * @origin: a description from where the package comes from (e.g. the homepage URL)
202  *
203  * This macro needs to be used to define the entry point and meta data of a
204  * plugin. One would use this macro to export a plugin, so that it can be used
205  * by other applications.
206  *
207  * The macro uses a define named PACKAGE for the #GstPluginDesc,source field.
208  * When using autoconf, this is usually set automatically via the AC_INIT
209  * macro, and set in config.h. If you are not using autoconf, you will need to
210  * define PACKAGE yourself and set it to a short mnemonic string identifying
211  * your application/package, e.g. 'someapp' or 'my-plugins-foo.
212  *
213  * If defined, the GST_PACKAGE_RELEASE_DATETIME will also be used for the
214  * #GstPluginDesc,release_datetime field.
215  */
216 #define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin)     \
217 G_BEGIN_DECLS \
218 GST_PLUGIN_EXPORT GstPluginDesc gst_plugin_desc = {     \
219   major,                                                \
220   minor,                                                \
221   G_STRINGIFY(name),                                    \
222   (gchar *) description,                                \
223   init,                                                 \
224   version,                                              \
225   license,                                              \
226   PACKAGE,                                              \
227   package,                                              \
228   origin,                                               \
229   __GST_PACKAGE_RELEASE_DATETIME,                       \
230   GST_PADDING_INIT                                      \
231 }; \
232 G_END_DECLS
233
234 /**
235  * GST_LICENSE_UNKNOWN:
236  *
237  * To be used in GST_PLUGIN_DEFINE if usure about the licence.
238  */
239 #define GST_LICENSE_UNKNOWN "unknown"
240
241
242 /* function for filters */
243 /**
244  * GstPluginFilter:
245  * @plugin: the plugin to check
246  * @user_data: the user_data that has been passed on e.g. gst_registry_plugin_filter()
247  *
248  * A function that can be used with e.g. gst_registry_plugin_filter()
249  * to get a list of plugins that match certain criteria.
250  *
251  * Returns: TRUE for a positive match, FALSE otherwise
252  */
253 typedef gboolean        (*GstPluginFilter)              (GstPlugin *plugin,
254                                                          gpointer user_data);
255
256 GType                   gst_plugin_get_type             (void);
257
258 gboolean                gst_plugin_register_static      (gint major_version,
259                                                          gint minor_version,
260                                                          const gchar *name,
261                                                          const gchar *description,
262                                                          GstPluginInitFunc init_func,
263                                                          const gchar *version,
264                                                          const gchar *license,
265                                                          const gchar *source,
266                                                          const gchar *package,
267                                                          const gchar *origin);
268
269 gboolean                gst_plugin_register_static_full (gint major_version,
270                                                          gint minor_version,
271                                                          const gchar *name,
272                                                          const gchar *description,
273                                                          GstPluginInitFullFunc init_full_func,
274                                                          const gchar *version,
275                                                          const gchar *license,
276                                                          const gchar *source,
277                                                          const gchar *package,
278                                                          const gchar *origin,
279                                                          gpointer user_data);
280
281 const gchar*            gst_plugin_get_name             (GstPlugin *plugin);
282 const gchar*            gst_plugin_get_description      (GstPlugin *plugin);
283 const gchar*            gst_plugin_get_filename         (GstPlugin *plugin);
284 const gchar*            gst_plugin_get_version          (GstPlugin *plugin);
285 const gchar*            gst_plugin_get_license          (GstPlugin *plugin);
286 const gchar*            gst_plugin_get_source           (GstPlugin *plugin);
287 const gchar*            gst_plugin_get_package          (GstPlugin *plugin);
288 const gchar*            gst_plugin_get_origin           (GstPlugin *plugin);
289 const gchar*            gst_plugin_get_release_date_string (GstPlugin *plugin);
290 const GstStructure*     gst_plugin_get_cache_data       (GstPlugin * plugin);
291 void                    gst_plugin_set_cache_data       (GstPlugin * plugin, GstStructure *cache_data);
292
293 gboolean                gst_plugin_is_loaded            (GstPlugin *plugin);
294
295 GstPlugin *             gst_plugin_load_file            (const gchar *filename, GError** error);
296
297 GstPlugin *             gst_plugin_load                 (GstPlugin *plugin);
298 GstPlugin *             gst_plugin_load_by_name         (const gchar *name);
299
300 void                    gst_plugin_add_dependency        (GstPlugin    * plugin,
301                                                           const gchar ** env_vars,
302                                                           const gchar ** paths,
303                                                           const gchar ** names,
304                                                           GstPluginDependencyFlags flags);
305 void                    gst_plugin_add_dependency_simple (GstPlugin   * plugin,
306                                                           const gchar * env_vars,
307                                                           const gchar * paths,
308                                                           const gchar * names,
309                                                           GstPluginDependencyFlags flags);
310
311 void gst_plugin_list_free (GList *list);
312
313 G_END_DECLS
314
315 #endif /* __GST_PLUGIN_H__ */