2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstplugin.c: Plugin subsystem for loading elements, types, and libs
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.
25 * @short_description: Container for features loaded from a shared object module
26 * @see_also: #GstPluginFeature, #GstElementFactory
28 * GStreamer is extensible, so #GstElement instances can be loaded at runtime.
29 * A plugin system can provide one or more of the basic
30 * <application>GStreamer</application> #GstPluginFeature subclasses.
32 * A plugin should export a symbol <symbol>gst_plugin_desc</symbol> that is a
33 * struct of type #GstPluginDesc.
34 * the plugin loader will check the version of the core library the plugin was
35 * linked against and will create a new #GstPlugin. It will then call the
36 * #GstPluginInitFunc function that was provided in the
37 * <symbol>gst_plugin_desc</symbol>.
39 * Once you have a handle to a #GstPlugin (e.g. from the #GstRegistry), you
40 * can add any object that subclasses #GstPluginFeature.
42 * Usually plugins are always automaticlly loaded so you don't need to call
43 * gst_plugin_load() explicitly to bring it into memory. There are options to
44 * statically link plugins to an app or even use GStreamer without a plugin
45 * repository in which case gst_plugin_load() can be needed to bring the plugin
53 #include "gst_private.h"
55 #include <glib/gstdio.h>
56 #include <sys/types.h>
66 #include "glib-compat-private.h"
70 #define GST_CAT_DEFAULT GST_CAT_PLUGIN_LOADING
72 static guint _num_static_plugins; /* 0 */
73 static GstPluginDesc *_static_plugins; /* NULL */
74 static gboolean _gst_plugin_inited;
76 /* static variables for segfault handling of plugin loading */
77 static char *_gst_plugin_fault_handler_filename = NULL;
79 /* list of valid licenses.
80 * One of these must be specified or the plugin won't be loaded
81 * Contact gstreamer-devel@lists.sourceforge.net if your license should be
84 * GPL: http://www.gnu.org/copyleft/gpl.html
85 * LGPL: http://www.gnu.org/copyleft/lesser.html
86 * QPL: http://www.trolltech.com/licenses/qpl.html
87 * MPL: http://www.opensource.org/licenses/mozilla1.1.php
88 * MIT/X11: http://www.opensource.org/licenses/mit-license.php
89 * 3-clause BSD: http://www.opensource.org/licenses/bsd-license.php
91 static const gchar *valid_licenses[] = {
92 "LGPL", /* GNU Lesser General Public License */
93 "GPL", /* GNU General Public License */
94 "QPL", /* Trolltech Qt Public License */
95 "GPL/QPL", /* Combi-license of GPL + QPL */
96 "MPL", /* MPL 1.1 license */
97 "BSD", /* 3-clause BSD license */
98 "MIT/X11", /* MIT/X11 license */
99 "Proprietary", /* Proprietary license */
100 GST_LICENSE_UNKNOWN, /* some other license */
104 static GstPlugin *gst_plugin_register_func (GstPlugin * plugin,
105 const GstPluginDesc * desc, gpointer user_data);
106 static void gst_plugin_desc_copy (GstPluginDesc * dest,
107 const GstPluginDesc * src);
108 static void gst_plugin_desc_free (GstPluginDesc * desc);
110 static void gst_plugin_ext_dep_free (GstPluginDep * dep);
112 G_DEFINE_TYPE (GstPlugin, gst_plugin, GST_TYPE_OBJECT);
115 gst_plugin_init (GstPlugin * plugin)
118 G_TYPE_INSTANCE_GET_PRIVATE (plugin, GST_TYPE_PLUGIN, GstPluginPrivate);
122 gst_plugin_finalize (GObject * object)
124 GstPlugin *plugin = GST_PLUGIN_CAST (object);
125 GstRegistry *registry = gst_registry_get_default ();
128 GST_DEBUG ("finalizing plugin %" GST_PTR_FORMAT, plugin);
129 for (g = registry->plugins; g; g = g->next) {
130 if (g->data == (gpointer) plugin) {
131 g_warning ("removing plugin that is still in registry");
134 g_free (plugin->filename);
135 g_free (plugin->basename);
136 gst_plugin_desc_free (&plugin->desc);
138 g_list_foreach (plugin->priv->deps, (GFunc) gst_plugin_ext_dep_free, NULL);
139 g_list_free (plugin->priv->deps);
140 plugin->priv->deps = NULL;
142 if (plugin->priv->cache_data) {
143 gst_structure_free (plugin->priv->cache_data);
146 G_OBJECT_CLASS (gst_plugin_parent_class)->finalize (object);
150 gst_plugin_class_init (GstPluginClass * klass)
152 G_OBJECT_CLASS (klass)->finalize = gst_plugin_finalize;
154 g_type_class_add_private (klass, sizeof (GstPluginPrivate));
158 gst_plugin_error_quark (void)
160 static GQuark quark = 0;
163 quark = g_quark_from_static_string ("gst_plugin_error");
167 #ifndef GST_REMOVE_DEPRECATED
168 /* this function can be called in the GCC constructor extension, before
169 * the _gst_plugin_initialize() was called. In that case, we store the
170 * plugin description in a list to initialize it when we open the main
172 * When the main module is known, we can register the plugin right away.
175 _gst_plugin_register_static (GstPluginDesc * desc)
177 g_return_if_fail (desc != NULL);
179 if (!_gst_plugin_inited) {
180 /* We can't use any GLib functions here, since g_thread_init hasn't been
181 * called yet, and we can't call it here either, or programs that don't
182 * guard their g_thread_init calls in main() will just abort */
183 ++_num_static_plugins;
185 realloc (_static_plugins, _num_static_plugins * sizeof (GstPluginDesc));
186 /* assume strings in the GstPluginDesc are static const or live forever */
187 _static_plugins[_num_static_plugins - 1] = *desc;
189 gst_plugin_register_static (desc->major_version, desc->minor_version,
190 desc->name, desc->description, desc->plugin_init, desc->version,
191 desc->license, desc->source, desc->package, desc->origin);
197 * gst_plugin_register_static:
198 * @major_version: the major version number of the GStreamer core that the
199 * plugin was compiled for, you can just use GST_VERSION_MAJOR here
200 * @minor_version: the minor version number of the GStreamer core that the
201 * plugin was compiled for, you can just use GST_VERSION_MINOR here
202 * @name: a unique name of the plugin (ideally prefixed with an application- or
203 * library-specific namespace prefix in order to avoid name conflicts in
204 * case a similar plugin with the same name ever gets added to GStreamer)
205 * @description: description of the plugin
206 * @init_func: pointer to the init function of this plugin.
207 * @version: version string of the plugin
208 * @license: effective license of plugin. Must be one of the approved licenses
209 * (see #GstPluginDesc above) or the plugin will not be registered.
210 * @source: source module plugin belongs to
211 * @package: shipped package plugin belongs to
212 * @origin: URL to provider of plugin
214 * Registers a static plugin, ie. a plugin which is private to an application
215 * or library and contained within the application or library (as opposed to
216 * being shipped as a separate module file).
218 * You must make sure that GStreamer has been initialised (with gst_init() or
219 * via gst_init_get_option_group()) before calling this function.
221 * Returns: TRUE if the plugin was registered correctly, otherwise FALSE.
226 gst_plugin_register_static (gint major_version, gint minor_version,
227 const gchar * name, gchar * description, GstPluginInitFunc init_func,
228 const gchar * version, const gchar * license, const gchar * source,
229 const gchar * package, const gchar * origin)
231 GstPluginDesc desc = { major_version, minor_version, name, description,
232 init_func, version, license, source, package, origin,
235 gboolean res = FALSE;
237 g_return_val_if_fail (name != NULL, FALSE);
238 g_return_val_if_fail (description != NULL, FALSE);
239 g_return_val_if_fail (init_func != NULL, FALSE);
240 g_return_val_if_fail (version != NULL, FALSE);
241 g_return_val_if_fail (license != NULL, FALSE);
242 g_return_val_if_fail (source != NULL, FALSE);
243 g_return_val_if_fail (package != NULL, FALSE);
244 g_return_val_if_fail (origin != NULL, FALSE);
246 /* make sure gst_init() has been called */
247 g_return_val_if_fail (_gst_plugin_inited != FALSE, FALSE);
249 GST_LOG ("attempting to load static plugin \"%s\" now...", name);
250 plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
251 if (gst_plugin_register_func (plugin, &desc, NULL) != NULL) {
252 GST_INFO ("registered static plugin \"%s\"", name);
253 res = gst_default_registry_add_plugin (plugin);
254 GST_INFO ("added static plugin \"%s\", result: %d", name, res);
260 * gst_plugin_register_static_full:
261 * @major_version: the major version number of the GStreamer core that the
262 * plugin was compiled for, you can just use GST_VERSION_MAJOR here
263 * @minor_version: the minor version number of the GStreamer core that the
264 * plugin was compiled for, you can just use GST_VERSION_MINOR here
265 * @name: a unique name of the plugin (ideally prefixed with an application- or
266 * library-specific namespace prefix in order to avoid name conflicts in
267 * case a similar plugin with the same name ever gets added to GStreamer)
268 * @description: description of the plugin
269 * @init_full_func: pointer to the init function with user data of this plugin.
270 * @version: version string of the plugin
271 * @license: effective license of plugin. Must be one of the approved licenses
272 * (see #GstPluginDesc above) or the plugin will not be registered.
273 * @source: source module plugin belongs to
274 * @package: shipped package plugin belongs to
275 * @origin: URL to provider of plugin
276 * @user_data: gpointer to user data
278 * Registers a static plugin, ie. a plugin which is private to an application
279 * or library and contained within the application or library (as opposed to
280 * being shipped as a separate module file) with a #GstPluginInitFullFunc
281 * which allows user data to be passed to the callback function (useful
284 * You must make sure that GStreamer has been initialised (with gst_init() or
285 * via gst_init_get_option_group()) before calling this function.
287 * Returns: TRUE if the plugin was registered correctly, otherwise FALSE.
293 gst_plugin_register_static_full (gint major_version, gint minor_version,
294 const gchar * name, gchar * description,
295 GstPluginInitFullFunc init_full_func, const gchar * version,
296 const gchar * license, const gchar * source, const gchar * package,
297 const gchar * origin, gpointer user_data)
299 GstPluginDesc desc = { major_version, minor_version, name, description,
300 (GstPluginInitFunc) init_full_func, version, license, source, package,
304 gboolean res = FALSE;
306 g_return_val_if_fail (name != NULL, FALSE);
307 g_return_val_if_fail (description != NULL, FALSE);
308 g_return_val_if_fail (init_full_func != NULL, FALSE);
309 g_return_val_if_fail (version != NULL, FALSE);
310 g_return_val_if_fail (license != NULL, FALSE);
311 g_return_val_if_fail (source != NULL, FALSE);
312 g_return_val_if_fail (package != NULL, FALSE);
313 g_return_val_if_fail (origin != NULL, FALSE);
315 /* make sure gst_init() has been called */
316 g_return_val_if_fail (_gst_plugin_inited != FALSE, FALSE);
318 GST_LOG ("attempting to load static plugin \"%s\" now...", name);
319 plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
320 if (gst_plugin_register_func (plugin, &desc, user_data) != NULL) {
321 GST_INFO ("registered static plugin \"%s\"", name);
322 res = gst_default_registry_add_plugin (plugin);
323 GST_INFO ("added static plugin \"%s\", result: %d", name, res);
329 _gst_plugin_initialize (void)
333 _gst_plugin_inited = TRUE;
335 /* now register all static plugins */
336 GST_INFO ("registering %u static plugins", _num_static_plugins);
337 for (i = 0; i < _num_static_plugins; ++i) {
338 gst_plugin_register_static (_static_plugins[i].major_version,
339 _static_plugins[i].minor_version, _static_plugins[i].name,
340 _static_plugins[i].description, _static_plugins[i].plugin_init,
341 _static_plugins[i].version, _static_plugins[i].license,
342 _static_plugins[i].source, _static_plugins[i].package,
343 _static_plugins[i].origin);
346 if (_static_plugins) {
347 free (_static_plugins);
348 _static_plugins = NULL;
349 _num_static_plugins = 0;
353 /* this function could be extended to check if the plugin license matches the
354 * applications license (would require the app to register its license somehow).
355 * We'll wait for someone who's interested in it to code it :)
358 gst_plugin_check_license (const gchar * license)
360 const gchar **check_license = valid_licenses;
362 g_assert (check_license);
364 while (*check_license) {
365 if (strcmp (license, *check_license) == 0)
373 gst_plugin_check_version (gint major, gint minor)
375 /* return NULL if the major and minor version numbers are not compatible */
377 if (major != GST_VERSION_MAJOR || minor != GST_VERSION_MINOR)
384 gst_plugin_register_func (GstPlugin * plugin, const GstPluginDesc * desc,
387 if (!gst_plugin_check_version (desc->major_version, desc->minor_version)) {
389 GST_WARNING ("plugin \"%s\" has incompatible version, not loading",
394 if (!desc->license || !desc->description || !desc->source ||
395 !desc->package || !desc->origin) {
397 GST_WARNING ("plugin \"%s\" has incorrect GstPluginDesc, not loading",
402 if (!gst_plugin_check_license (desc->license)) {
404 GST_WARNING ("plugin \"%s\" has invalid license \"%s\", not loading",
405 plugin->filename, desc->license);
410 GST_LOG ("plugin \"%s\" looks good", GST_STR_NULL (plugin->filename));
412 gst_plugin_desc_copy (&plugin->desc, desc);
415 if (!(((GstPluginInitFullFunc) (desc->plugin_init)) (plugin, user_data))) {
417 GST_WARNING ("plugin \"%s\" failed to initialise", plugin->filename);
418 plugin->module = NULL;
422 if (!((desc->plugin_init) (plugin))) {
424 GST_WARNING ("plugin \"%s\" failed to initialise", plugin->filename);
425 plugin->module = NULL;
431 GST_LOG ("plugin \"%s\" initialised", GST_STR_NULL (plugin->filename));
436 #ifdef HAVE_SIGACTION
437 static struct sigaction oldaction;
438 static gboolean _gst_plugin_fault_handler_is_setup = FALSE;
441 * _gst_plugin_fault_handler_restore:
442 * segfault handler restorer
445 _gst_plugin_fault_handler_restore (void)
447 if (!_gst_plugin_fault_handler_is_setup)
450 _gst_plugin_fault_handler_is_setup = FALSE;
452 sigaction (SIGSEGV, &oldaction, NULL);
456 * _gst_plugin_fault_handler_sighandler:
457 * segfault handler implementation
460 _gst_plugin_fault_handler_sighandler (int signum)
462 /* We need to restore the fault handler or we'll keep getting it */
463 _gst_plugin_fault_handler_restore ();
467 g_print ("\nERROR: ");
468 g_print ("Caught a segmentation fault while loading plugin file:\n");
469 g_print ("%s\n\n", _gst_plugin_fault_handler_filename);
470 g_print ("Please either:\n");
471 g_print ("- remove it and restart.\n");
472 g_print ("- run with --gst-disable-segtrap and debug.\n");
476 g_print ("Caught unhandled signal on plugin loading\n");
482 * _gst_plugin_fault_handler_setup:
483 * sets up the segfault handler
486 _gst_plugin_fault_handler_setup (void)
488 struct sigaction action;
490 /* if asked to leave segfaults alone, just return */
491 if (!gst_segtrap_is_enabled ())
494 if (_gst_plugin_fault_handler_is_setup)
497 _gst_plugin_fault_handler_is_setup = TRUE;
499 memset (&action, 0, sizeof (action));
500 action.sa_handler = _gst_plugin_fault_handler_sighandler;
502 sigaction (SIGSEGV, &action, &oldaction);
504 #else /* !HAVE_SIGACTION */
506 _gst_plugin_fault_handler_restore (void)
511 _gst_plugin_fault_handler_setup (void)
514 #endif /* HAVE_SIGACTION */
516 static GStaticMutex gst_plugin_loading_mutex = G_STATIC_MUTEX_INIT;
518 #define CHECK_PLUGIN_DESC_FIELD(desc,field,fn) \
519 if (G_UNLIKELY ((desc)->field == NULL)) { \
520 GST_ERROR ("GstPluginDesc for '%s' has no %s", fn, G_STRINGIFY (field)); \
524 * gst_plugin_load_file:
525 * @filename: the plugin filename to load
526 * @error: pointer to a NULL-valued GError
528 * Loads the given plugin and refs it. Caller needs to unref after use.
530 * Returns: a reference to the existing loaded GstPlugin, a reference to the
531 * newly-loaded GstPlugin, or NULL if an error occurred.
534 gst_plugin_load_file (const gchar * filename, GError ** error)
540 struct stat file_status;
541 GstRegistry *registry;
542 gboolean new_plugin = TRUE;
544 g_return_val_if_fail (filename != NULL, NULL);
546 registry = gst_registry_get_default ();
547 g_static_mutex_lock (&gst_plugin_loading_mutex);
549 plugin = gst_registry_lookup (registry, filename);
551 if (plugin->module) {
553 g_static_mutex_unlock (&gst_plugin_loading_mutex);
556 /* load plugin and update fields */
561 GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"",
564 if (g_module_supported () == FALSE) {
565 GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "module loading not supported");
568 GST_PLUGIN_ERROR_MODULE, "Dynamic loading not supported");
572 if (g_stat (filename, &file_status)) {
573 GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "problem accessing file");
576 GST_PLUGIN_ERROR_MODULE, "Problem accessing file %s: %s", filename,
581 module = g_module_open (filename, G_MODULE_BIND_LOCAL);
582 if (module == NULL) {
583 GST_CAT_WARNING (GST_CAT_PLUGIN_LOADING, "module_open failed: %s",
586 GST_PLUGIN_ERROR, GST_PLUGIN_ERROR_MODULE, "Opening module failed: %s",
588 /* If we failed to open the shared object, then it's probably because a
589 * plugin is linked against the wrong libraries. Print out an easy-to-see
590 * message in this case. */
591 g_warning ("Failed to load plugin '%s': %s", filename, g_module_error ());
596 plugin = g_object_newv (GST_TYPE_PLUGIN, 0, NULL);
597 plugin->file_mtime = file_status.st_mtime;
598 plugin->file_size = file_status.st_size;
599 plugin->filename = g_strdup (filename);
600 plugin->basename = g_path_get_basename (filename);
602 plugin->module = module;
604 ret = g_module_symbol (module, "gst_plugin_desc", &ptr);
606 GST_DEBUG ("Could not find plugin entry point in \"%s\"", filename);
609 GST_PLUGIN_ERROR_MODULE,
610 "File \"%s\" is not a GStreamer plugin", filename);
611 g_module_close (module);
614 plugin->orig_desc = (GstPluginDesc *) ptr;
617 /* check plugin description: complain about bad values but accept them, to
618 * maintain backwards compatibility (FIXME: 0.11) */
619 CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, name, filename);
620 CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, description, filename);
621 CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, version, filename);
622 CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, license, filename);
623 CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, source, filename);
624 CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, package, filename);
625 CHECK_PLUGIN_DESC_FIELD (plugin->orig_desc, origin, filename);
627 /* this is overwritten by gst_plugin_register_func() */
628 g_free (plugin->desc.description);
631 GST_LOG ("Plugin %p for file \"%s\" prepared, calling entry function...",
634 /* this is where we load the actual .so, so let's trap SIGSEGV */
635 _gst_plugin_fault_handler_setup ();
636 _gst_plugin_fault_handler_filename = plugin->filename;
638 GST_LOG ("Plugin %p for file \"%s\" prepared, registering...",
641 if (!gst_plugin_register_func (plugin, plugin->orig_desc, NULL)) {
642 /* remove signal handler */
643 _gst_plugin_fault_handler_restore ();
644 GST_DEBUG ("gst_plugin_register_func failed for plugin \"%s\"", filename);
648 GST_PLUGIN_ERROR_MODULE,
649 "File \"%s\" appears to be a GStreamer plugin, but it failed to initialize",
651 g_module_close (module);
655 /* remove signal handler */
656 _gst_plugin_fault_handler_restore ();
657 _gst_plugin_fault_handler_filename = NULL;
658 GST_INFO ("plugin \"%s\" loaded", plugin->filename);
661 gst_object_ref (plugin);
662 gst_default_registry_add_plugin (plugin);
665 g_static_mutex_unlock (&gst_plugin_loading_mutex);
671 gst_object_unref (plugin);
672 g_static_mutex_unlock (&gst_plugin_loading_mutex);
678 gst_plugin_desc_copy (GstPluginDesc * dest, const GstPluginDesc * src)
680 dest->major_version = src->major_version;
681 dest->minor_version = src->minor_version;
682 dest->name = g_intern_string (src->name);
683 /* maybe intern the description too, just for convenience? */
684 dest->description = g_strdup (src->description);
685 dest->plugin_init = src->plugin_init;
686 dest->version = g_intern_string (src->version);
687 dest->license = g_intern_string (src->license);
688 dest->source = g_intern_string (src->source);
689 dest->package = g_intern_string (src->package);
690 dest->origin = g_intern_string (src->origin);
695 gst_plugin_desc_free (GstPluginDesc * desc)
697 g_free (desc->description);
698 memset (desc, 0, sizeof (GstPluginDesc));
702 * gst_plugin_get_name:
703 * @plugin: plugin to get the name of
705 * Get the short name of the plugin
707 * Returns: the name of the plugin
710 gst_plugin_get_name (GstPlugin * plugin)
712 g_return_val_if_fail (plugin != NULL, NULL);
714 return plugin->desc.name;
718 * gst_plugin_get_description:
719 * @plugin: plugin to get long name of
721 * Get the long descriptive name of the plugin
723 * Returns: the long name of the plugin
725 G_CONST_RETURN gchar *
726 gst_plugin_get_description (GstPlugin * plugin)
728 g_return_val_if_fail (plugin != NULL, NULL);
730 return plugin->desc.description;
734 * gst_plugin_get_filename:
735 * @plugin: plugin to get the filename of
737 * get the filename of the plugin
739 * Returns: the filename of the plugin
741 G_CONST_RETURN gchar *
742 gst_plugin_get_filename (GstPlugin * plugin)
744 g_return_val_if_fail (plugin != NULL, NULL);
746 return plugin->filename;
750 * gst_plugin_get_version:
751 * @plugin: plugin to get the version of
753 * get the version of the plugin
755 * Returns: the version of the plugin
757 G_CONST_RETURN gchar *
758 gst_plugin_get_version (GstPlugin * plugin)
760 g_return_val_if_fail (plugin != NULL, NULL);
762 return plugin->desc.version;
766 * gst_plugin_get_license:
767 * @plugin: plugin to get the license of
769 * get the license of the plugin
771 * Returns: the license of the plugin
773 G_CONST_RETURN gchar *
774 gst_plugin_get_license (GstPlugin * plugin)
776 g_return_val_if_fail (plugin != NULL, NULL);
778 return plugin->desc.license;
782 * gst_plugin_get_source:
783 * @plugin: plugin to get the source of
785 * get the source module the plugin belongs to.
787 * Returns: the source of the plugin
789 G_CONST_RETURN gchar *
790 gst_plugin_get_source (GstPlugin * plugin)
792 g_return_val_if_fail (plugin != NULL, NULL);
794 return plugin->desc.source;
798 * gst_plugin_get_package:
799 * @plugin: plugin to get the package of
801 * get the package the plugin belongs to.
803 * Returns: the package of the plugin
805 G_CONST_RETURN gchar *
806 gst_plugin_get_package (GstPlugin * plugin)
808 g_return_val_if_fail (plugin != NULL, NULL);
810 return plugin->desc.package;
814 * gst_plugin_get_origin:
815 * @plugin: plugin to get the origin of
817 * get the URL where the plugin comes from
819 * Returns: the origin of the plugin
821 G_CONST_RETURN gchar *
822 gst_plugin_get_origin (GstPlugin * plugin)
824 g_return_val_if_fail (plugin != NULL, NULL);
826 return plugin->desc.origin;
830 * gst_plugin_get_module:
831 * @plugin: plugin to query
833 * Gets the #GModule of the plugin. If the plugin isn't loaded yet, NULL is
836 * Returns: module belonging to the plugin or NULL if the plugin isn't
840 gst_plugin_get_module (GstPlugin * plugin)
842 g_return_val_if_fail (plugin != NULL, NULL);
844 return plugin->module;
848 * gst_plugin_is_loaded:
849 * @plugin: plugin to query
851 * queries if the plugin is loaded into memory
853 * Returns: TRUE is loaded, FALSE otherwise
856 gst_plugin_is_loaded (GstPlugin * plugin)
858 g_return_val_if_fail (plugin != NULL, FALSE);
860 return (plugin->module != NULL || plugin->filename == NULL);
864 * gst_plugin_get_cache_data:
867 * Gets the plugin specific data cache. If it is %NULL there is no cached data
868 * stored. This is the case when the registry is getting rebuilt.
870 * Returns: The cached data as a #GstStructure or %NULL.
874 G_CONST_RETURN GstStructure *
875 gst_plugin_get_cache_data (GstPlugin * plugin)
877 g_return_val_if_fail (GST_IS_PLUGIN (plugin), NULL);
879 return plugin->priv->cache_data;
883 * gst_plugin_set_cache_data:
885 * @cache_data: a structure containing the data to cache
887 * Adds plugin specific data to cache. Passes the ownership of the structure to
890 * The cache is flushed every time the registry is rebuilt.
895 gst_plugin_set_cache_data (GstPlugin * plugin, GstStructure * cache_data)
897 g_return_if_fail (GST_IS_PLUGIN (plugin));
898 g_return_if_fail (GST_IS_STRUCTURE (cache_data));
900 if (plugin->priv->cache_data) {
901 gst_structure_free (plugin->priv->cache_data);
903 plugin->priv->cache_data = cache_data;
908 * gst_plugin_feature_list:
909 * @plugin: plugin to query
910 * @filter: the filter to use
911 * @first: only return first match
912 * @user_data: user data passed to the filter function
914 * Runs a filter against all plugin features and returns a GList with
915 * the results. If the first flag is set, only the first match is
916 * returned (as a list with a single object).
918 * Returns: a GList of features, g_list_free after use.
921 gst_plugin_feature_filter (GstPlugin * plugin,
922 GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
927 list = gst_filter_run (plugin->features, (GstFilterFunc) filter, first,
929 for (g = list; g; g = g->next) {
930 gst_object_ref (plugin);
938 GstPluginFeatureFilter filter;
946 _feature_filter (GstPlugin * plugin, gpointer user_data)
949 FeatureFilterData *data = (FeatureFilterData *) user_data;
951 result = gst_plugin_feature_filter (plugin, data->filter, data->first,
954 data->result = g_list_concat (data->result, result);
961 * gst_plugin_list_feature_filter:
962 * @list: a #GList of plugins to query
963 * @filter: the filter function to use
964 * @first: only return first match
965 * @user_data: user data passed to the filter function
967 * Runs a filter against all plugin features of the plugins in the given
968 * list and returns a GList with the results.
969 * If the first flag is set, only the first match is
970 * returned (as a list with a single object).
972 * Returns: a GList of features, g_list_free after use.
975 gst_plugin_list_feature_filter (GList * list,
976 GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
978 FeatureFilterData data;
981 data.filter = filter;
983 data.user_data = user_data;
986 result = gst_filter_run (list, (GstFilterFunc) _feature_filter, first, &data);
987 g_list_free (result);
994 * gst_plugin_name_filter:
995 * @plugin: the plugin to check
996 * @name: the name of the plugin
998 * A standard filter that returns TRUE when the plugin is of the
1001 * Returns: TRUE if the plugin is of the given name.
1004 gst_plugin_name_filter (GstPlugin * plugin, const gchar * name)
1006 return (plugin->desc.name && !strcmp (plugin->desc.name, name));
1011 * gst_plugin_find_feature:
1012 * @plugin: plugin to get the feature from
1013 * @name: The name of the feature to find
1014 * @type: The type of the feature to find
1016 * Find a feature of the given name and type in the given plugin.
1018 * Returns: a GstPluginFeature or NULL if the feature was not found.
1021 gst_plugin_find_feature (GstPlugin * plugin, const gchar * name, GType type)
1024 GstPluginFeature *result = NULL;
1025 GstTypeNameData data;
1027 g_return_val_if_fail (name != NULL, NULL);
1032 walk = gst_filter_run (plugin->features,
1033 (GstFilterFunc) gst_plugin_feature_type_name_filter, TRUE, &data);
1036 result = GST_PLUGIN_FEATURE (walk->data);
1038 gst_object_ref (result);
1039 gst_plugin_feature_list_free (walk);
1048 gst_plugin_feature_name_filter (GstPluginFeature * feature, const gchar * name)
1050 return !strcmp (name, GST_PLUGIN_FEATURE_NAME (feature));
1056 * gst_plugin_find_feature_by_name:
1057 * @plugin: plugin to get the feature from
1058 * @name: The name of the feature to find
1060 * Find a feature of the given name in the given plugin.
1062 * Returns: a GstPluginFeature or NULL if the feature was not found.
1065 gst_plugin_find_feature_by_name (GstPlugin * plugin, const gchar * name)
1068 GstPluginFeature *result = NULL;
1070 g_return_val_if_fail (name != NULL, NULL);
1072 walk = gst_filter_run (plugin->features,
1073 (GstFilterFunc) gst_plugin_feature_name_filter, TRUE, (void *) name);
1076 result = GST_PLUGIN_FEATURE (walk->data);
1078 gst_object_ref (result);
1079 gst_plugin_feature_list_free (walk);
1087 * gst_plugin_load_by_name:
1088 * @name: name of plugin to load
1090 * Load the named plugin. Refs the plugin.
1092 * Returns: A reference to a loaded plugin, or NULL on error.
1095 gst_plugin_load_by_name (const gchar * name)
1097 GstPlugin *plugin, *newplugin;
1098 GError *error = NULL;
1100 GST_DEBUG ("looking up plugin %s in default registry", name);
1101 plugin = gst_registry_find_plugin (gst_registry_get_default (), name);
1103 GST_DEBUG ("loading plugin %s from file %s", name, plugin->filename);
1104 newplugin = gst_plugin_load_file (plugin->filename, &error);
1105 gst_object_unref (plugin);
1108 GST_WARNING ("load_plugin error: %s", error->message);
1109 g_error_free (error);
1112 /* newplugin was reffed by load_file */
1116 GST_DEBUG ("Could not find plugin %s in registry", name);
1122 * @plugin: plugin to load
1124 * Loads @plugin. Note that the *return value* is the loaded plugin; @plugin is
1125 * untouched. The normal use pattern of this function goes like this:
1128 * GstPlugin *loaded_plugin;
1129 * loaded_plugin = gst_plugin_load (plugin);
1130 * // presumably, we're no longer interested in the potentially-unloaded plugin
1131 * gst_object_unref (plugin);
1132 * plugin = loaded_plugin;
1135 * Returns: A reference to a loaded plugin, or NULL on error.
1138 gst_plugin_load (GstPlugin * plugin)
1140 GError *error = NULL;
1141 GstPlugin *newplugin;
1143 if (gst_plugin_is_loaded (plugin)) {
1147 if (!(newplugin = gst_plugin_load_file (plugin->filename, &error)))
1154 GST_WARNING ("load_plugin error: %s", error->message);
1155 g_error_free (error);
1161 * gst_plugin_list_free:
1162 * @list: list of #GstPlugin
1164 * Unrefs each member of @list, then frees the list.
1167 gst_plugin_list_free (GList * list)
1171 for (g = list; g; g = g->next) {
1172 gst_object_unref (GST_PLUGIN_CAST (g->data));
1177 /* ===== plugin dependencies ===== */
1180 * ENV + xyz where ENV can contain multiple values separated by SEPARATOR
1181 * xyz may be "" (if ENV contains path to file rather than dir)
1182 * ENV + *xyz same as above, but xyz acts as suffix filter
1183 * ENV + xyz* same as above, but xyz acts as prefix filter (is this needed?)
1184 * ENV + *xyz* same as above, but xyz acts as strstr filter (is this needed?)
1186 * same as above, with additional paths hard-coded at compile-time:
1187 * - only check paths + ... if ENV is not set or yields not paths
1188 * - always check paths + ... in addition to ENV
1190 * When user specifies set of environment variables, he/she may also use e.g.
1191 * "HOME/.mystuff/plugins", and we'll expand the content of $HOME with the
1195 /* we store in registry:
1198 * - environment variables (array of strings)
1199 * - last hash of env variable contents (uint) (so we can avoid doing stats
1200 * if one of the env vars has changed; premature optimisation galore)
1201 * - hard-coded paths (array of strings)
1202 * - xyz filename/suffix/prefix strings (array of strings)
1204 * - last hash of file/dir stats (int)
1206 * (= struct GstPluginDep)
1210 gst_plugin_ext_dep_get_env_vars_hash (GstPlugin * plugin, GstPluginDep * dep)
1215 /* there's no deeper logic to what we do here; all we want to know (when
1216 * checking if the plugin needs to be rescanned) is whether the content of
1217 * one of the environment variables in the list is different from when it
1218 * was last scanned */
1220 for (e = dep->env_vars; e != NULL && *e != NULL; ++e) {
1224 /* order matters: "val",NULL needs to yield a different hash than
1225 * NULL,"val", so do a shift here whether the var is set or not */
1228 /* want environment variable at beginning of string */
1229 if (!g_ascii_isalnum (**e)) {
1230 GST_WARNING_OBJECT (plugin, "string prefix is not a valid environment "
1231 "variable string: %s", *e);
1235 /* user is allowed to specify e.g. "HOME/.pitivi/plugins" */
1236 g_strlcpy (env_var, *e, sizeof (env_var));
1237 g_strdelimit (env_var, "/\\", '\0');
1239 if ((val = g_getenv (env_var)))
1240 hash += g_str_hash (val);
1247 _priv_plugin_deps_env_vars_changed (GstPlugin * plugin)
1251 for (l = plugin->priv->deps; l != NULL; l = l->next) {
1252 GstPluginDep *dep = l->data;
1254 if (dep->env_hash != gst_plugin_ext_dep_get_env_vars_hash (plugin, dep))
1262 gst_plugin_ext_dep_extract_env_vars_paths (GstPlugin * plugin,
1266 GList *paths = NULL;
1268 for (evars = dep->env_vars; evars != NULL && *evars != NULL; ++evars) {
1272 /* want environment variable at beginning of string */
1273 if (!g_ascii_isalnum (**evars)) {
1274 GST_WARNING_OBJECT (plugin, "string prefix is not a valid environment "
1275 "variable string: %s", *evars);
1279 /* user is allowed to specify e.g. "HOME/.pitivi/plugins", which we want to
1280 * split into the env_var name component and the path component */
1281 components = g_strsplit_set (*evars, "/\\", 2);
1282 g_assert (components != NULL);
1284 e = g_getenv (components[0]);
1285 GST_LOG_OBJECT (plugin, "expanding %s = '%s' (path suffix: %s)",
1286 components[0], GST_STR_NULL (e), GST_STR_NULL (components[1]));
1288 if (components[1] != NULL) {
1289 g_strdelimit (components[1], "/\\", G_DIR_SEPARATOR);
1292 if (e != NULL && *e != '\0') {
1296 arr = g_strsplit (e, G_SEARCHPATH_SEPARATOR_S, -1);
1298 for (i = 0; arr != NULL && arr[i] != NULL; ++i) {
1301 if (!g_path_is_absolute (arr[i])) {
1302 GST_INFO_OBJECT (plugin, "ignoring environment variable content '%s'"
1303 ": either not an absolute path or not a path at all", arr[i]);
1307 if (components[1] != NULL) {
1308 full_path = g_build_filename (arr[i], components[1], NULL);
1310 full_path = g_strdup (arr[i]);
1313 if (!g_list_find_custom (paths, full_path, (GCompareFunc) strcmp)) {
1314 GST_LOG_OBJECT (plugin, "path: '%s'", full_path);
1315 paths = g_list_prepend (paths, full_path);
1318 GST_LOG_OBJECT (plugin, "path: '%s' (duplicate,ignoring)", full_path);
1326 g_strfreev (components);
1329 GST_LOG_OBJECT (plugin, "Extracted %d paths from environment",
1330 g_list_length (paths));
1336 gst_plugin_ext_dep_get_hash_from_stat_entry (struct stat *s)
1338 if (!(s->st_mode & (S_IFDIR | S_IFREG)))
1341 /* completely random formula */
1342 return ((s->st_size << 3) + (s->st_mtime << 5)) ^ s->st_ctime;
1346 gst_plugin_ext_dep_direntry_matches (GstPlugin * plugin, const gchar * entry,
1347 const gchar ** filenames, GstPluginDependencyFlags flags)
1349 /* no filenames specified, match all entries for now (could probably
1350 * optimise by just taking the dir stat hash or so) */
1351 if (filenames == NULL || *filenames == NULL || **filenames == '\0')
1354 while (*filenames != NULL) {
1356 if (((flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX)) &&
1357 g_str_has_suffix (entry, *filenames)) {
1359 /* else it's an exact match that's needed */
1360 } else if (strcmp (entry, *filenames) == 0) {
1363 GST_LOG ("%s does not match %s, flags=0x%04x", entry, *filenames, flags);
1370 gst_plugin_ext_dep_scan_dir_and_match_names (GstPlugin * plugin,
1371 const gchar * path, const gchar ** filenames,
1372 GstPluginDependencyFlags flags, int depth)
1375 gboolean recurse_dirs;
1380 recurse_dirs = !!(flags & GST_PLUGIN_DEPENDENCY_FLAG_RECURSE);
1382 dir = g_dir_open (path, 0, &err);
1384 GST_DEBUG_OBJECT (plugin, "g_dir_open(%s) failed: %s", path, err->message);
1389 /* FIXME: we're assuming here that we always get the directory entries in
1390 * the same order, and not in a random order */
1391 while ((entry = g_dir_read_name (dir))) {
1392 gboolean have_match;
1398 gst_plugin_ext_dep_direntry_matches (plugin, entry, filenames, flags);
1400 /* avoid the stat if possible */
1401 if (!have_match && !recurse_dirs)
1404 full_path = g_build_filename (path, entry, NULL);
1405 if (g_stat (full_path, &s) < 0) {
1406 fhash = (guint) - 1;
1407 GST_LOG_OBJECT (plugin, "stat: %s (error: %s)", full_path,
1408 g_strerror (errno));
1409 } else if (have_match) {
1410 fhash = gst_plugin_ext_dep_get_hash_from_stat_entry (&s);
1411 GST_LOG_OBJECT (plugin, "stat: %s (result: %u)", full_path, fhash);
1412 } else if ((s.st_mode & (S_IFDIR))) {
1413 fhash = gst_plugin_ext_dep_scan_dir_and_match_names (plugin, full_path,
1414 filenames, flags, depth + 1);
1416 /* it's not a name match, we want to recurse, but it's not a directory */
1421 hash = (hash + fhash) << 1;
1430 gst_plugin_ext_dep_scan_path_with_filenames (GstPlugin * plugin,
1431 const gchar * path, const gchar ** filenames,
1432 GstPluginDependencyFlags flags)
1434 const gchar *empty_filenames[] = { "", NULL };
1435 gboolean recurse_into_dirs, partial_names;
1438 /* to avoid special-casing below (FIXME?) */
1439 if (filenames == NULL || *filenames == NULL)
1440 filenames = empty_filenames;
1442 recurse_into_dirs = !!(flags & GST_PLUGIN_DEPENDENCY_FLAG_RECURSE);
1443 partial_names = !!(flags & GST_PLUGIN_DEPENDENCY_FLAG_FILE_NAME_IS_SUFFIX);
1445 /* if we can construct the exact paths to check with the data we have, just
1446 * stat them one by one; this is more efficient than opening the directory
1447 * and going through each entry to see if it matches one of our filenames. */
1448 if (!recurse_into_dirs && !partial_names) {
1449 for (i = 0; filenames[i] != NULL; ++i) {
1454 full_path = g_build_filename (path, filenames[i], NULL);
1455 if (g_stat (full_path, &s) < 0) {
1456 fhash = (guint) - 1;
1457 GST_LOG_OBJECT (plugin, "stat: %s (error: %s)", full_path,
1458 g_strerror (errno));
1460 fhash = gst_plugin_ext_dep_get_hash_from_stat_entry (&s);
1461 GST_LOG_OBJECT (plugin, "stat: %s (result: %08x)", full_path, fhash);
1463 hash = (hash + fhash) << 1;
1467 hash = gst_plugin_ext_dep_scan_dir_and_match_names (plugin, path,
1468 filenames, flags, 0);
1475 gst_plugin_ext_dep_get_stat_hash (GstPlugin * plugin, GstPluginDep * dep)
1477 gboolean paths_are_default_only;
1479 guint scan_hash = 0;
1481 GST_LOG_OBJECT (plugin, "start");
1483 paths_are_default_only =
1484 dep->flags & GST_PLUGIN_DEPENDENCY_FLAG_PATHS_ARE_DEFAULT_ONLY;
1486 scan_paths = gst_plugin_ext_dep_extract_env_vars_paths (plugin, dep);
1488 if (scan_paths == NULL || !paths_are_default_only) {
1491 for (paths = dep->paths; paths != NULL && *paths != NULL; ++paths) {
1492 const gchar *path = *paths;
1494 if (!g_list_find_custom (scan_paths, path, (GCompareFunc) strcmp)) {
1495 GST_LOG_OBJECT (plugin, "path: '%s'", path);
1496 scan_paths = g_list_prepend (scan_paths, g_strdup (path));
1498 GST_LOG_OBJECT (plugin, "path: '%s' (duplicate, ignoring)", path);
1503 /* not that the order really matters, but it makes debugging easier */
1504 scan_paths = g_list_reverse (scan_paths);
1506 while (scan_paths != NULL) {
1507 const gchar *path = scan_paths->data;
1509 scan_hash += gst_plugin_ext_dep_scan_path_with_filenames (plugin, path,
1510 (const gchar **) dep->names, dep->flags);
1511 scan_hash = scan_hash << 1;
1513 g_free (scan_paths->data);
1514 scan_paths = g_list_delete_link (scan_paths, scan_paths);
1517 GST_LOG_OBJECT (plugin, "done, scan_hash: %08x", scan_hash);
1522 _priv_plugin_deps_files_changed (GstPlugin * plugin)
1526 for (l = plugin->priv->deps; l != NULL; l = l->next) {
1527 GstPluginDep *dep = l->data;
1529 if (dep->stat_hash != gst_plugin_ext_dep_get_stat_hash (plugin, dep))
1537 gst_plugin_ext_dep_free (GstPluginDep * dep)
1539 g_strfreev (dep->env_vars);
1540 g_strfreev (dep->paths);
1541 g_strfreev (dep->names);
1546 gst_plugin_ext_dep_strv_equal (gchar ** arr1, gchar ** arr2)
1550 if (arr1 == NULL || arr2 == NULL)
1552 for (; *arr1 != NULL && *arr2 != NULL; ++arr1, ++arr2) {
1553 if (strcmp (*arr1, *arr2) != 0)
1556 return (*arr1 == *arr2);
1560 gst_plugin_ext_dep_equals (GstPluginDep * dep, const gchar ** env_vars,
1561 const gchar ** paths, const gchar ** names, GstPluginDependencyFlags flags)
1563 if (dep->flags != flags)
1566 return gst_plugin_ext_dep_strv_equal (dep->env_vars, (gchar **) env_vars) &&
1567 gst_plugin_ext_dep_strv_equal (dep->paths, (gchar **) paths) &&
1568 gst_plugin_ext_dep_strv_equal (dep->names, (gchar **) names);
1572 * gst_plugin_add_dependency:
1573 * @plugin: a #GstPlugin
1574 * @env_vars: NULL-terminated array of environent variables affecting the
1575 * feature set of the plugin (e.g. an environment variable containing
1576 * paths where to look for additional modules/plugins of a library),
1577 * or NULL. Environment variable names may be followed by a path component
1578 * which will be added to the content of the environment variable, e.g.
1579 * "HOME/.mystuff/plugins".
1580 * @paths: NULL-terminated array of directories/paths where dependent files
1582 * @names: NULL-terminated array of file names (or file name suffixes,
1583 * depending on @flags) to be used in combination with the paths from
1584 * @paths and/or the paths extracted from the environment variables in
1585 * @env_vars, or NULL.
1586 * @flags: optional flags, or #GST_PLUGIN_DEPENDENCY_FLAG_NONE
1588 * Make GStreamer aware of external dependencies which affect the feature
1589 * set of this plugin (ie. the elements or typefinders associated with it).
1591 * GStreamer will re-inspect plugins with external dependencies whenever any
1592 * of the external dependencies change. This is useful for plugins which wrap
1593 * other plugin systems, e.g. a plugin which wraps a plugin-based visualisation
1594 * library and makes visualisations available as GStreamer elements, or a
1595 * codec loader which exposes elements and/or caps dependent on what external
1596 * codec libraries are currently installed.
1601 gst_plugin_add_dependency (GstPlugin * plugin, const gchar ** env_vars,
1602 const gchar ** paths, const gchar ** names, GstPluginDependencyFlags flags)
1607 g_return_if_fail (GST_IS_PLUGIN (plugin));
1609 if ((env_vars == NULL || env_vars[0] == NULL) &&
1610 (paths == NULL || paths[0] == NULL)) {
1611 GST_DEBUG_OBJECT (plugin,
1612 "plugin registered empty dependency set. Ignoring");
1616 for (l = plugin->priv->deps; l != NULL; l = l->next) {
1617 if (gst_plugin_ext_dep_equals (l->data, env_vars, paths, names, flags)) {
1618 GST_LOG_OBJECT (plugin, "dependency already registered");
1623 dep = g_new0 (GstPluginDep, 1);
1625 dep->env_vars = g_strdupv ((gchar **) env_vars);
1626 dep->paths = g_strdupv ((gchar **) paths);
1627 dep->names = g_strdupv ((gchar **) names);
1630 dep->env_hash = gst_plugin_ext_dep_get_env_vars_hash (plugin, dep);
1631 dep->stat_hash = gst_plugin_ext_dep_get_stat_hash (plugin, dep);
1633 plugin->priv->deps = g_list_append (plugin->priv->deps, dep);
1635 GST_DEBUG_OBJECT (plugin, "added dependency:");
1636 for (; env_vars != NULL && *env_vars != NULL; ++env_vars)
1637 GST_DEBUG_OBJECT (plugin, " evar: %s", *env_vars);
1638 for (; paths != NULL && *paths != NULL; ++paths)
1639 GST_DEBUG_OBJECT (plugin, " path: %s", *paths);
1640 for (; names != NULL && *names != NULL; ++names)
1641 GST_DEBUG_OBJECT (plugin, " name: %s", *names);
1645 * gst_plugin_add_dependency_simple:
1646 * @plugin: the #GstPlugin
1647 * @env_vars: one or more environent variables (separated by ':', ';' or ','),
1648 * or NULL. Environment variable names may be followed by a path component
1649 * which will be added to the content of the environment variable, e.g.
1650 * "HOME/.mystuff/plugins:MYSTUFF_PLUGINS_PATH"
1651 * @paths: one ore more directory paths (separated by ':' or ';' or ','),
1652 * or NULL. Example: "/usr/lib/mystuff/plugins"
1653 * @names: one or more file names or file name suffixes (separated by commas),
1655 * @flags: optional flags, or #GST_PLUGIN_DEPENDENCY_FLAG_NONE
1657 * Make GStreamer aware of external dependencies which affect the feature
1658 * set of this plugin (ie. the elements or typefinders associated with it).
1660 * GStreamer will re-inspect plugins with external dependencies whenever any
1661 * of the external dependencies change. This is useful for plugins which wrap
1662 * other plugin systems, e.g. a plugin which wraps a plugin-based visualisation
1663 * library and makes visualisations available as GStreamer elements, or a
1664 * codec loader which exposes elements and/or caps dependent on what external
1665 * codec libraries are currently installed.
1667 * Convenience wrapper function for gst_plugin_add_dependency() which
1668 * takes simple strings as arguments instead of string arrays, with multiple
1669 * arguments separated by predefined delimiters (see above).
1674 gst_plugin_add_dependency_simple (GstPlugin * plugin,
1675 const gchar * env_vars, const gchar * paths, const gchar * names,
1676 GstPluginDependencyFlags flags)
1678 gchar **a_evars = NULL;
1679 gchar **a_paths = NULL;
1680 gchar **a_names = NULL;
1683 a_evars = g_strsplit_set (env_vars, ":;,", -1);
1685 a_paths = g_strsplit_set (paths, ":;,", -1);
1687 a_names = g_strsplit_set (names, ",", -1);
1689 gst_plugin_add_dependency (plugin, (const gchar **) a_evars,
1690 (const gchar **) a_paths, (const gchar **) a_names, flags);
1693 g_strfreev (a_evars);
1695 g_strfreev (a_paths);
1697 g_strfreev (a_names);