value: Handle serializing NULL GValueArray
[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
52 GST_EXPORT
53 GQuark gst_plugin_error_quark (void);
54 /**
55  * GST_PLUGIN_ERROR:
56  *
57  * The error message category quark
58  */
59 #define GST_PLUGIN_ERROR gst_plugin_error_quark ()
60
61 /**
62  * GstPluginError:
63  * @GST_PLUGIN_ERROR_MODULE: The plugin could not be loaded
64  * @GST_PLUGIN_ERROR_DEPENDENCIES: The plugin has unresolved dependencies
65  * @GST_PLUGIN_ERROR_NAME_MISMATCH: The plugin has already be loaded from a different file
66  *
67  * The plugin loading errors
68  */
69 typedef enum
70 {
71   GST_PLUGIN_ERROR_MODULE,
72   GST_PLUGIN_ERROR_DEPENDENCIES,
73   GST_PLUGIN_ERROR_NAME_MISMATCH
74 } GstPluginError;
75
76 /**
77  * GstPluginFlags:
78  * @GST_PLUGIN_FLAG_CACHED: Temporarily loaded plugins
79  * @GST_PLUGIN_FLAG_BLACKLISTED: The plugin won't be scanned (again)
80  *
81  * The plugin loading state
82  */
83 typedef enum
84 {
85   GST_PLUGIN_FLAG_CACHED      = (GST_OBJECT_FLAG_LAST << 0),
86   GST_PLUGIN_FLAG_BLACKLISTED = (GST_OBJECT_FLAG_LAST << 1)
87 } GstPluginFlags;
88
89 /**
90  * GstPluginDependencyFlags:
91  * @GST_PLUGIN_DEPENDENCY_FLAG_NONE : no special flags
92  * @GST_PLUGIN_DEPENDENCY_FLAG_RECURSE : recurse into subdirectories
93  * @GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY : use paths
94  *         argument only if none of the environment variables is set
95  * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX : interpret
96  *         filename argument as filter suffix and check all matching files in
97  *         the directory
98  * @GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX : interpret
99  *         filename argument as filter prefix and check all matching files in
100  *         the directory. Since 1.8.
101  *
102  * Flags used in connection with gst_plugin_add_dependency().
103  */
104 typedef enum {
105   GST_PLUGIN_DEPENDENCY_FLAG_NONE = 0,
106   GST_PLUGIN_DEPENDENCY_FLAG_RECURSE = (1 << 0),
107   GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY = (1 << 1),
108   GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX = (1 << 2),
109   GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_PREFIX = (1 << 3)
110 } GstPluginDependencyFlags;
111
112 /**
113  * GstPluginInitFunc:
114  * @plugin: The plugin object
115  *
116  * A plugin should provide a pointer to a function of this type in the
117  * plugin_desc struct.
118  * This function will be called by the loader at startup. One would then
119  * register each #GstPluginFeature.
120  *
121  * Returns: %TRUE if plugin initialised successfully
122  */
123 /* FIXME 0.11: Make return void */
124 typedef gboolean (*GstPluginInitFunc) (GstPlugin *plugin);
125
126 /**
127  * GstPluginInitFullFunc:
128  * @plugin: The plugin object
129  * @user_data: extra data
130  *
131  * A plugin should provide a pointer to a function of either #GstPluginInitFunc
132  * or this type in the plugin_desc struct.
133  * The function will be called by the loader at startup. One would then
134  * register each #GstPluginFeature. This version allows
135  * user data to be passed to init function (useful for bindings).
136  *
137  * Returns: %TRUE if plugin initialised successfully
138  */
139 /* FIXME 0.11: Merge with GstPluginInitFunc */
140 typedef gboolean (*GstPluginInitFullFunc) (GstPlugin *plugin, gpointer user_data);
141
142 /**
143  * GstPluginDesc:
144  * @major_version: the major version number of core that plugin was compiled for
145  * @minor_version: the minor version number of core that plugin was compiled for
146  * @name: a unique name of the plugin
147  * @description: description of plugin
148  * @plugin_init: pointer to the init function of this plugin.
149  * @version: version of the plugin
150  * @license: effective license of plugin
151  * @source: source module plugin belongs to
152  * @package: shipped package plugin belongs to
153  * @origin: URL to provider of plugin
154  * @release_datetime: (allow-none): date time string in ISO 8601
155  *     format (or rather, a subset thereof), or %NULL. Allowed are the
156  *     following formats: "YYYY-MM-DD" and "YYY-MM-DDTHH:MMZ" (with
157  *     'T' a separator and 'Z' indicating UTC/Zulu time). This field
158  *     should be set via the GST_PACKAGE_RELEASE_DATETIME
159  *     preprocessor macro.
160  *
161  * A plugin should export a variable of this type called plugin_desc. The plugin
162  * loader will use the data provided there to initialize the plugin.
163  *
164  * The @licence parameter must be one of: LGPL, GPL, QPL, GPL/QPL, MPL,
165  * BSD, MIT/X11, Proprietary, unknown.
166  */
167 struct _GstPluginDesc {
168   gint major_version;
169   gint minor_version;
170   const gchar *name;
171   const gchar *description;
172   GstPluginInitFunc plugin_init;
173   const gchar *version;
174   const gchar *license;
175   const gchar *source;
176   const gchar *package;
177   const gchar *origin;
178   const gchar *release_datetime;
179   /*< private >*/
180   gpointer _gst_reserved[GST_PADDING];
181 };
182
183
184 #define GST_TYPE_PLUGIN   (gst_plugin_get_type())
185 #define GST_IS_PLUGIN(obj)             (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_PLUGIN))
186 #define GST_IS_PLUGIN_CLASS(klass)     (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_PLUGIN))
187 #define GST_PLUGIN_GET_CLASS(obj)      (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_PLUGIN, GstPluginClass))
188 #define GST_PLUGIN(obj)                (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLUGIN, GstPlugin))
189 #define GST_PLUGIN_CLASS(klass)        (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLUGIN, GstPluginClass))
190 #define GST_PLUGIN_CAST(obj)           ((GstPlugin*)(obj))
191
192 #ifdef GST_PACKAGE_RELEASE_DATETIME
193 #define __GST_PACKAGE_RELEASE_DATETIME GST_PACKAGE_RELEASE_DATETIME
194 #else
195 #define __GST_PACKAGE_RELEASE_DATETIME NULL
196 #endif
197
198 /**
199  * GST_PLUGIN_STATIC_DECLARE:
200  * @name: short, but unique name of the plugin
201  *
202  * This macro can be used to initialize statically linked plugins. It is
203  * necessary to call this macro before the plugin can be used.
204  * It has to be used in combination with GST_PLUGIN_STATIC_REGISTER
205  * and must be placed outside any block to declare the plugin initialization
206  * function.
207  *
208  * Since: 1.2
209  */
210 #define GST_PLUGIN_STATIC_DECLARE(name) \
211   extern void G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void)
212
213 /**
214  * GST_PLUGIN_STATIC_REGISTER:
215  * @name: short, but unique name of the plugin
216  *
217  * This macro can be used to initialize statically linked plugins. It is
218  * necessary to call this macro before the plugin can be used.
219  * It has to be used in combination with GST_PLUGIN_STATIC_DECLARE and
220  * calls the plugin initialization function.
221  *
222  * Since: 1.2
223  */
224 #define GST_PLUGIN_STATIC_REGISTER(name) G_PASTE(gst_plugin_, G_PASTE(name, _register)) ()
225
226 /**
227  * GST_PLUGIN_DEFINE:
228  * @major: major version number of the gstreamer-core that plugin was compiled for
229  * @minor: minor version number of the gstreamer-core that plugin was compiled for
230  * @name: short, but unique name of the plugin
231  * @description: information about the purpose of the plugin
232  * @init: function pointer to the plugin_init method with the signature of <code>static gboolean plugin_init (GstPlugin * plugin)</code>.
233  * @version: full version string (e.g. VERSION from config.h)
234  * @license: under which licence the package has been released, e.g. GPL, LGPL.
235  * @package: the package-name (e.g. PACKAGE_NAME from config.h)
236  * @origin: a description from where the package comes from (e.g. the homepage URL)
237  *
238  * This macro needs to be used to define the entry point and meta data of a
239  * plugin. One would use this macro to export a plugin, so that it can be used
240  * by other applications.
241  *
242  * The macro uses a define named PACKAGE for the #GstPluginDesc,source field.
243  * When using autoconf, this is usually set automatically via the AC_INIT
244  * macro, and set in config.h. If you are not using autoconf, you will need to
245  * define PACKAGE yourself and set it to a short mnemonic string identifying
246  * your application/package, e.g. 'someapp' or 'my-plugins-foo.
247  *
248  * If defined, the GST_PACKAGE_RELEASE_DATETIME will also be used for the
249  * #GstPluginDesc,release_datetime field.
250  */
251 #define GST_PLUGIN_DEFINE(major,minor,name,description,init,version,license,package,origin) \
252 G_BEGIN_DECLS \
253 GST_PLUGIN_EXPORT const GstPluginDesc * G_PASTE(gst_plugin_, G_PASTE(name, _get_desc)) (void); \
254 GST_PLUGIN_EXPORT void G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void); \
255 \
256 static const GstPluginDesc gst_plugin_desc = { \
257   major, \
258   minor, \
259   G_STRINGIFY(name), \
260   (gchar *) description, \
261   init, \
262   version, \
263   license, \
264   PACKAGE, \
265   package, \
266   origin, \
267   __GST_PACKAGE_RELEASE_DATETIME, \
268   GST_PADDING_INIT \
269 };                                       \
270 \
271 const GstPluginDesc * \
272 G_PASTE(gst_plugin_, G_PASTE(name, _get_desc)) (void) \
273 { \
274     return &gst_plugin_desc; \
275 } \
276 \
277 void \
278 G_PASTE(gst_plugin_, G_PASTE(name, _register)) (void) \
279 { \
280   gst_plugin_register_static (major, minor, G_STRINGIFY(name), \
281       description, init, version, license, \
282       PACKAGE, package, origin); \
283 } \
284 G_END_DECLS
285
286 /**
287  * GST_LICENSE_UNKNOWN:
288  *
289  * To be used in GST_PLUGIN_DEFINE if unsure about the licence.
290  */
291 #define GST_LICENSE_UNKNOWN "unknown"
292
293
294 /* function for filters */
295 /**
296  * GstPluginFilter:
297  * @plugin: the plugin to check
298  * @user_data: the user_data that has been passed on e.g. gst_registry_plugin_filter()
299  *
300  * A function that can be used with e.g. gst_registry_plugin_filter()
301  * to get a list of plugins that match certain criteria.
302  *
303  * Returns: %TRUE for a positive match, %FALSE otherwise
304  */
305 typedef gboolean        (*GstPluginFilter)              (GstPlugin *plugin,
306                                                          gpointer user_data);
307
308 GST_EXPORT
309 GType                   gst_plugin_get_type             (void);
310
311 GST_EXPORT
312 gboolean                gst_plugin_register_static      (gint major_version,
313                                                          gint minor_version,
314                                                          const gchar *name,
315                                                          const gchar *description,
316                                                          GstPluginInitFunc init_func,
317                                                          const gchar *version,
318                                                          const gchar *license,
319                                                          const gchar *source,
320                                                          const gchar *package,
321                                                          const gchar *origin);
322 GST_EXPORT
323 gboolean                gst_plugin_register_static_full (gint major_version,
324                                                          gint minor_version,
325                                                          const gchar *name,
326                                                          const gchar *description,
327                                                          GstPluginInitFullFunc init_full_func,
328                                                          const gchar *version,
329                                                          const gchar *license,
330                                                          const gchar *source,
331                                                          const gchar *package,
332                                                          const gchar *origin,
333                                                          gpointer user_data);
334 GST_EXPORT
335 const gchar*            gst_plugin_get_name             (GstPlugin *plugin);
336
337 GST_EXPORT
338 const gchar*            gst_plugin_get_description      (GstPlugin *plugin);
339
340 GST_EXPORT
341 const gchar*            gst_plugin_get_filename         (GstPlugin *plugin);
342
343 GST_EXPORT
344 const gchar*            gst_plugin_get_version          (GstPlugin *plugin);
345
346 GST_EXPORT
347 const gchar*            gst_plugin_get_license          (GstPlugin *plugin);
348
349 GST_EXPORT
350 const gchar*            gst_plugin_get_source           (GstPlugin *plugin);
351
352 GST_EXPORT
353 const gchar*            gst_plugin_get_package          (GstPlugin *plugin);
354
355 GST_EXPORT
356 const gchar*            gst_plugin_get_origin           (GstPlugin *plugin);
357
358 GST_EXPORT
359 const gchar*            gst_plugin_get_release_date_string (GstPlugin *plugin);
360
361 GST_EXPORT
362 const GstStructure*     gst_plugin_get_cache_data       (GstPlugin * plugin);
363
364 GST_EXPORT
365 void                    gst_plugin_set_cache_data       (GstPlugin * plugin, GstStructure *cache_data);
366
367 GST_EXPORT
368 gboolean                gst_plugin_is_loaded            (GstPlugin *plugin);
369
370 GST_EXPORT
371 GstPlugin *             gst_plugin_load_file            (const gchar *filename, GError** error);
372
373 GST_EXPORT
374 GstPlugin *             gst_plugin_load                 (GstPlugin *plugin);
375
376 GST_EXPORT
377 GstPlugin *             gst_plugin_load_by_name         (const gchar *name);
378
379 GST_EXPORT
380 void                    gst_plugin_add_dependency        (GstPlugin    * plugin,
381                                                           const gchar ** env_vars,
382                                                           const gchar ** paths,
383                                                           const gchar ** names,
384                                                           GstPluginDependencyFlags flags);
385 GST_EXPORT
386 void                    gst_plugin_add_dependency_simple (GstPlugin   * plugin,
387                                                           const gchar * env_vars,
388                                                           const gchar * paths,
389                                                           const gchar * names,
390                                                           GstPluginDependencyFlags flags);
391 GST_EXPORT
392 void                    gst_plugin_list_free (GList *list);
393
394 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
395 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstPlugin, gst_object_unref)
396 #endif
397
398 G_END_DECLS
399
400 #endif /* __GST_PLUGIN_H__ */