2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
4 * 2005 David A. Schleef <ds@schleef.org>
6 * gstregistry.c: handle registry
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Library General Public License for more details.
18 * You should have received a copy of the GNU Library General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
26 * @short_description: Abstract base class for management of #GstPlugin objects
27 * @see_also: #GstPlugin, #GstPluginFeature
29 * One registry holds the metadata of a set of plugins.
31 * <emphasis role="bold">Design:</emphasis>
33 * The #GstRegistry object is a list of plugins and some functions for dealing
34 * with them. Each #GstPlugin is matched 1-1 with a file on disk, and may or may
35 * not be loaded at a given time. There may be multiple #GstRegistry objects,
36 * but the "default registry" is the only object that has any meaning to the
39 * The registry.xml file is actually a cache of plugin information. This is
40 * unlike versions prior to 0.10, where the registry file was the primary source
41 * of plugin information, and was created by the gst-register command.
43 * The primary source, at all times, of plugin information is each plugin file
44 * itself. Thus, if an application wants information about a particular plugin,
45 * or wants to search for a feature that satisfies given criteria, the primary
46 * means of doing so is to load every plugin and look at the resulting
47 * information that is gathered in the default registry. Clearly, this is a time
48 * consuming process, so we cache information in the registry.xml file.
50 * On startup, plugins are searched for in the plugin search path. This path can
51 * be set directly using the GST_PLUGIN_PATH environment variable. The registry
52 * file is loaded from ~/.gstreamer-$GST_MAJORMINOR/registry-$ARCH.xml or the
53 * file listed in the GST_REGISTRY env var. The only reason to change the
54 * registry location is for testing.
56 * For each plugin that is found in the plugin search path, there could be 3
57 * possibilities for cached information:
60 * <para>the cache may not contain information about a given file.</para>
63 * <para>the cache may have stale information.</para>
66 * <para>the cache may have current information.</para>
70 * In the first two cases, the plugin is loaded and the cache updated. In
71 * addition to these cases, the cache may have entries for plugins that are not
72 * relevant to the current process. These are marked as not available to the
73 * current process. If the cache is updated for whatever reason, it is marked
76 * A dirty cache is written out at the end of initialization. Each entry is
77 * checked to make sure the information is minimally valid. If not, the entry is
80 * <emphasis role="bold">Implementation notes:</emphasis>
82 * The "cache" and "default registry" are different concepts and can represent
83 * different sets of plugins. For various reasons, at init time, the cache is
84 * stored in the default registry, and plugins not relevant to the current
85 * process are marked with the %GST_PLUGIN_FLAG_CACHED bit. These plugins are
86 * removed at the end of intitialization.
92 #include "gstconfig.h"
93 #include "gst_private.h"
95 #include <sys/types.h>
105 #include <glib/gstdio.h>
108 #include "gsterror.h"
109 #include "gstregistry.h"
110 #include "gstmarshal.h"
111 #include "gstfilter.h"
113 #include "gstpluginloader.h"
115 #include "gst-i18n-lib.h"
121 extern HMODULE _priv_gst_dll_handle;
124 #define GST_CAT_DEFAULT GST_CAT_REGISTRY
126 struct _GstRegistryPrivate
128 /* updated whenever the feature list changes */
130 /* speedup for searching features */
131 GList *element_factory_list;
133 GList *typefind_factory_list;
137 /* the one instance of the default registry and the mutex protecting the
139 static GStaticMutex _gst_registry_mutex = G_STATIC_MUTEX_INIT;
140 static GstRegistry *_gst_registry_default = NULL;
143 #define DEFAULT_FORK TRUE
145 /* control the behaviour of registry rebuild */
146 static gboolean _gst_enable_registry_fork = DEFAULT_FORK;
147 /* List of plugins that need preloading/reloading after scanning registry */
148 extern GSList *_priv_gst_preload_plugins;
150 #ifndef GST_DISABLE_REGISTRY
151 /*set to TRUE when registry needn't to be updated */
152 gboolean _priv_gst_disable_registry_update = FALSE;
153 extern GList *_priv_gst_plugin_paths;
155 /* Set to TRUE when the registry cache should be disabled */
156 gboolean _gst_disable_registry_cache = FALSE;
159 /* Element signals and args */
167 static void gst_registry_finalize (GObject * object);
169 static guint gst_registry_signals[LAST_SIGNAL] = { 0 };
171 static GstPluginFeature *gst_registry_lookup_feature_locked (GstRegistry *
172 registry, const char *name);
173 static GstPlugin *gst_registry_lookup_bn_locked (GstRegistry * registry,
174 const char *basename);
176 G_DEFINE_TYPE (GstRegistry, gst_registry, GST_TYPE_OBJECT);
177 static GstObjectClass *parent_class = NULL;
180 gst_registry_class_init (GstRegistryClass * klass)
182 GObjectClass *gobject_class;
184 gobject_class = (GObjectClass *) klass;
186 parent_class = g_type_class_peek_parent (klass);
187 g_type_class_add_private (klass, sizeof (GstRegistryPrivate));
190 * GstRegistry::plugin-added:
191 * @registry: the registry that emitted the signal
192 * @plugin: the plugin that has been added
194 * Signals that a plugin has been added to the registry (possibly
195 * replacing a previously-added one by the same name)
197 gst_registry_signals[PLUGIN_ADDED] =
198 g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass),
199 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL,
200 NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
203 * GstRegistry::feature-added:
204 * @registry: the registry that emitted the signal
205 * @feature: the feature that has been added
207 * Signals that a feature has been added to the registry (possibly
208 * replacing a previously-added one by the same name)
210 gst_registry_signals[FEATURE_ADDED] =
211 g_signal_new ("feature-added", G_TYPE_FROM_CLASS (klass),
212 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, feature_added),
213 NULL, NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
215 gobject_class->finalize = gst_registry_finalize;
219 gst_registry_init (GstRegistry * registry)
221 registry->feature_hash = g_hash_table_new (g_str_hash, g_str_equal);
222 registry->basename_hash = g_hash_table_new (g_str_hash, g_str_equal);
224 G_TYPE_INSTANCE_GET_PRIVATE (registry, GST_TYPE_REGISTRY,
229 gst_registry_finalize (GObject * object)
231 GstRegistry *registry = GST_REGISTRY (object);
235 plugins = registry->plugins;
236 registry->plugins = NULL;
238 GST_DEBUG_OBJECT (registry, "registry finalize");
241 GstPlugin *plugin = p->data;
244 GST_LOG_OBJECT (registry, "removing plugin %s",
245 gst_plugin_get_name (plugin));
246 gst_object_unref (plugin);
250 g_list_free (plugins);
252 features = registry->features;
253 registry->features = NULL;
257 GstPluginFeature *feature = f->data;
260 GST_LOG_OBJECT (registry, "removing feature %p (%s)",
261 feature, gst_plugin_feature_get_name (feature));
262 gst_object_unref (feature);
266 g_list_free (features);
268 g_hash_table_destroy (registry->feature_hash);
269 registry->feature_hash = NULL;
270 g_hash_table_destroy (registry->basename_hash);
271 registry->basename_hash = NULL;
273 if (registry->priv->element_factory_list) {
274 GST_DEBUG_OBJECT (registry, "Cleaning up cached element factory list");
275 gst_plugin_feature_list_free (registry->priv->element_factory_list);
278 if (registry->priv->typefind_factory_list) {
279 GST_DEBUG_OBJECT (registry, "Cleaning up cached typefind factory list");
280 gst_plugin_feature_list_free (registry->priv->typefind_factory_list);
283 G_OBJECT_CLASS (parent_class)->finalize (object);
287 * gst_registry_get_default:
289 * Retrieves the default registry. The caller does not own a reference on the
290 * registry, as it is alive as long as GStreamer is initialized.
292 * Returns: The default #GstRegistry.
295 gst_registry_get_default (void)
297 GstRegistry *registry;
299 g_static_mutex_lock (&_gst_registry_mutex);
300 if (G_UNLIKELY (!_gst_registry_default)) {
301 _gst_registry_default = g_object_newv (GST_TYPE_REGISTRY, 0, NULL);
302 gst_object_ref_sink (GST_OBJECT_CAST (_gst_registry_default));
304 registry = _gst_registry_default;
305 g_static_mutex_unlock (&_gst_registry_mutex);
311 * gst_registry_add_path:
312 * @registry: the registry to add the path to
313 * @path: the path to add to the registry
315 * Add the given path to the registry. The syntax of the
316 * path is specific to the registry. If the path has already been
320 gst_registry_add_path (GstRegistry * registry, const gchar * path)
322 g_return_if_fail (GST_IS_REGISTRY (registry));
323 g_return_if_fail (path != NULL);
325 if (strlen (path) == 0)
328 GST_OBJECT_LOCK (registry);
329 if (g_list_find_custom (registry->paths, path, (GCompareFunc) strcmp))
332 GST_INFO ("Adding plugin path: \"%s\"", path);
333 registry->paths = g_list_append (registry->paths, g_strdup (path));
334 GST_OBJECT_UNLOCK (registry);
340 GST_INFO ("Ignoring empty plugin path");
345 g_warning ("path %s already added to registry", path);
346 GST_OBJECT_UNLOCK (registry);
352 * gst_registry_get_path_list:
353 * @registry: the registry to get the pathlist of
355 * Get the list of paths for the given registry.
357 * Returns: A Glist of paths as strings. g_list_free after use.
362 gst_registry_get_path_list (GstRegistry * registry)
366 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
368 GST_OBJECT_LOCK (registry);
369 /* We don't need to copy the strings, because they won't be deleted
370 * as long as the GstRegistry is around */
371 list = g_list_copy (registry->paths);
372 GST_OBJECT_UNLOCK (registry);
379 * gst_registry_add_plugin:
380 * @registry: the registry to add the plugin to
381 * @plugin: the plugin to add
383 * Add the plugin to the registry. The plugin-added signal will be emitted.
384 * This function will sink @plugin.
386 * Returns: TRUE on success.
391 gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
393 GstPlugin *existing_plugin;
395 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
396 g_return_val_if_fail (GST_IS_PLUGIN (plugin), FALSE);
398 GST_OBJECT_LOCK (registry);
399 if (G_LIKELY (plugin->basename)) {
400 /* we have a basename, see if we find the plugin */
402 gst_registry_lookup_bn_locked (registry, plugin->basename);
403 if (existing_plugin) {
404 GST_DEBUG_OBJECT (registry,
405 "Replacing existing plugin %p with new plugin %p for filename \"%s\"",
406 existing_plugin, plugin, GST_STR_NULL (plugin->filename));
407 registry->plugins = g_list_remove (registry->plugins, existing_plugin);
408 if (G_LIKELY (existing_plugin->basename))
409 g_hash_table_remove (registry->basename_hash,
410 existing_plugin->basename);
411 gst_object_unref (existing_plugin);
415 GST_DEBUG_OBJECT (registry, "adding plugin %p for filename \"%s\"",
416 plugin, GST_STR_NULL (plugin->filename));
418 registry->plugins = g_list_prepend (registry->plugins, plugin);
419 if (G_LIKELY (plugin->basename))
420 g_hash_table_replace (registry->basename_hash, plugin->basename, plugin);
422 gst_object_ref_sink (plugin);
423 GST_OBJECT_UNLOCK (registry);
425 GST_LOG_OBJECT (registry, "emitting plugin-added for filename \"%s\"",
426 GST_STR_NULL (plugin->filename));
427 g_signal_emit (registry, gst_registry_signals[PLUGIN_ADDED], 0, plugin);
433 gst_registry_remove_features_for_plugin_unlocked (GstRegistry * registry,
439 g_return_if_fail (GST_IS_REGISTRY (registry));
440 g_return_if_fail (GST_IS_PLUGIN (plugin));
442 name = gst_plugin_get_name (plugin);
444 /* Remove all features for this plugin */
445 f = registry->features;
447 GList *next = g_list_next (f);
448 GstPluginFeature *feature = f->data;
450 if (G_UNLIKELY (feature && !strcmp (feature->plugin_name, name))) {
451 GST_DEBUG_OBJECT (registry, "removing feature %p (%s) for plugin %s",
452 feature, gst_plugin_feature_get_name (feature), name);
454 registry->features = g_list_delete_link (registry->features, f);
455 g_hash_table_remove (registry->feature_hash, feature->name);
456 gst_object_unref (feature);
460 registry->priv->cookie++;
464 * gst_registry_remove_plugin:
465 * @registry: the registry to remove the plugin from
466 * @plugin: the plugin to remove
468 * Remove the plugin from the registry.
473 gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin)
475 g_return_if_fail (GST_IS_REGISTRY (registry));
476 g_return_if_fail (GST_IS_PLUGIN (plugin));
478 GST_DEBUG_OBJECT (registry, "removing plugin %p (%s)",
479 plugin, gst_plugin_get_name (plugin));
481 GST_OBJECT_LOCK (registry);
482 registry->plugins = g_list_remove (registry->plugins, plugin);
483 if (G_LIKELY (plugin->basename))
484 g_hash_table_remove (registry->basename_hash, plugin->basename);
485 gst_registry_remove_features_for_plugin_unlocked (registry, plugin);
486 GST_OBJECT_UNLOCK (registry);
487 gst_object_unref (plugin);
491 * gst_registry_add_feature:
492 * @registry: the registry to add the plugin to
493 * @feature: the feature to add
495 * Add the feature to the registry. The feature-added signal will be emitted.
496 * This function sinks @feature.
498 * Returns: TRUE on success.
503 gst_registry_add_feature (GstRegistry * registry, GstPluginFeature * feature)
505 GstPluginFeature *existing_feature;
507 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
508 g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
509 g_return_val_if_fail (feature->name != NULL, FALSE);
510 g_return_val_if_fail (feature->plugin_name != NULL, FALSE);
512 GST_OBJECT_LOCK (registry);
513 existing_feature = gst_registry_lookup_feature_locked (registry,
515 if (G_UNLIKELY (existing_feature)) {
516 GST_DEBUG_OBJECT (registry, "replacing existing feature %p (%s)",
517 existing_feature, feature->name);
518 /* Remove the existing feature from the list now, before we insert the new
519 * one, but don't unref yet because the hash is still storing a reference to
521 registry->features = g_list_remove (registry->features, existing_feature);
524 GST_DEBUG_OBJECT (registry, "adding feature %p (%s)", feature, feature->name);
526 registry->features = g_list_prepend (registry->features, feature);
527 g_hash_table_replace (registry->feature_hash, feature->name, feature);
529 if (G_UNLIKELY (existing_feature)) {
530 /* We unref now. No need to remove the feature name from the hash table, it
531 * got replaced by the new feature */
532 gst_object_unref (existing_feature);
535 gst_object_ref_sink (feature);
537 registry->priv->cookie++;
538 GST_OBJECT_UNLOCK (registry);
540 GST_LOG_OBJECT (registry, "emitting feature-added for %s", feature->name);
541 g_signal_emit (registry, gst_registry_signals[FEATURE_ADDED], 0, feature);
547 * gst_registry_remove_feature:
548 * @registry: the registry to remove the feature from
549 * @feature: the feature to remove
551 * Remove the feature from the registry.
556 gst_registry_remove_feature (GstRegistry * registry, GstPluginFeature * feature)
558 g_return_if_fail (GST_IS_REGISTRY (registry));
559 g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
561 GST_DEBUG_OBJECT (registry, "removing feature %p (%s)",
562 feature, gst_plugin_feature_get_name (feature));
564 GST_OBJECT_LOCK (registry);
565 registry->features = g_list_remove (registry->features, feature);
566 g_hash_table_remove (registry->feature_hash, feature->name);
567 registry->priv->cookie++;
568 GST_OBJECT_UNLOCK (registry);
569 gst_object_unref (feature);
573 * gst_registry_plugin_filter:
574 * @registry: registry to query
575 * @filter: the filter to use
576 * @first: only return first match
577 * @user_data: user data passed to the filter function
579 * Runs a filter against all plugins in the registry and returns a #GList with
580 * the results. If the first flag is set, only the first match is
581 * returned (as a list with a single object).
582 * Every plugin is reffed; use gst_plugin_list_free() after use, which
585 * Returns: a #GList of #GstPlugin. Use gst_plugin_list_free() after usage.
590 gst_registry_plugin_filter (GstRegistry * registry,
591 GstPluginFilter filter, gboolean first, gpointer user_data)
596 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
598 GST_OBJECT_LOCK (registry);
599 list = gst_filter_run (registry->plugins, (GstFilterFunc) filter, first,
601 for (g = list; g; g = g->next) {
602 gst_object_ref (GST_PLUGIN_CAST (g->data));
604 GST_OBJECT_UNLOCK (registry);
609 /* returns TRUE if the list was changed
611 * Must be called with the object lock taken */
613 gst_registry_get_feature_list_or_create (GstRegistry * registry,
614 GList ** previous, guint32 * cookie, GType type)
616 gboolean res = FALSE;
617 GstRegistryPrivate *priv = registry->priv;
619 if (G_UNLIKELY (!*previous || priv->cookie != *cookie)) {
620 GstTypeNameData data;
623 gst_plugin_feature_list_free (*previous);
628 gst_filter_run (registry->features,
629 (GstFilterFunc) gst_plugin_feature_type_name_filter, FALSE, &data);
630 g_list_foreach (*previous, (GFunc) gst_object_ref, NULL);
631 *cookie = priv->cookie;
639 type_find_factory_rank_cmp (const GstPluginFeature * fac1,
640 const GstPluginFeature * fac2)
642 if (G_LIKELY (fac1->rank != fac2->rank))
643 return fac2->rank - fac1->rank;
645 /* to make the order in which things happen more deterministic,
646 * sort by name when the ranks are the same. */
647 return strcmp (fac1->name, fac2->name);
651 gst_registry_get_element_factory_list (GstRegistry * registry)
655 GST_OBJECT_LOCK (registry);
657 gst_registry_get_feature_list_or_create (registry,
658 ®istry->priv->element_factory_list, ®istry->priv->efl_cookie,
659 GST_TYPE_ELEMENT_FACTORY);
661 /* Return reffed copy */
662 list = gst_plugin_feature_list_copy (registry->priv->element_factory_list);
664 GST_OBJECT_UNLOCK (registry);
670 gst_registry_get_typefind_factory_list (GstRegistry * registry)
674 GST_OBJECT_LOCK (registry);
676 if (G_UNLIKELY (gst_registry_get_feature_list_or_create (registry,
677 ®istry->priv->typefind_factory_list,
678 ®istry->priv->tfl_cookie, GST_TYPE_TYPE_FIND_FACTORY)))
679 registry->priv->typefind_factory_list =
680 g_list_sort (registry->priv->typefind_factory_list,
681 (GCompareFunc) type_find_factory_rank_cmp);
683 /* Return reffed copy */
684 list = gst_plugin_feature_list_copy (registry->priv->typefind_factory_list);
686 GST_OBJECT_UNLOCK (registry);
692 * gst_registry_feature_filter:
693 * @registry: registry to query
694 * @filter: the filter to use
695 * @first: only return first match
696 * @user_data: user data passed to the filter function
698 * Runs a filter against all features of the plugins in the registry
699 * and returns a GList with the results.
700 * If the first flag is set, only the first match is
701 * returned (as a list with a single object).
703 * Returns: a #GList of #GstPluginFeature. Use gst_plugin_feature_list_free()
709 gst_registry_feature_filter (GstRegistry * registry,
710 GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
715 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
717 GST_OBJECT_LOCK (registry);
718 list = gst_filter_run (registry->features, (GstFilterFunc) filter, first,
720 for (g = list; g; g = g->next) {
721 gst_object_ref (GST_PLUGIN_FEATURE_CAST (g->data));
723 GST_OBJECT_UNLOCK (registry);
729 * gst_registry_find_plugin:
730 * @registry: the registry to search
731 * @name: the plugin name to find
733 * Find the plugin with the given name in the registry.
734 * The plugin will be reffed; caller is responsible for unreffing.
736 * Returns: The plugin with the given name or NULL if the plugin was not found.
737 * gst_object_unref() after usage.
742 gst_registry_find_plugin (GstRegistry * registry, const gchar * name)
745 GstPlugin *result = NULL;
747 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
748 g_return_val_if_fail (name != NULL, NULL);
750 walk = gst_registry_plugin_filter (registry,
751 (GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name);
753 result = GST_PLUGIN_CAST (walk->data);
755 gst_object_ref (result);
756 gst_plugin_list_free (walk);
763 * gst_registry_find_feature:
764 * @registry: the registry to search
765 * @name: the pluginfeature name to find
766 * @type: the pluginfeature type to find
768 * Find the pluginfeature with the given name and type in the registry.
770 * Returns: The pluginfeature with the given name and type or NULL
771 * if the plugin was not found. gst_object_unref() after usage.
776 gst_registry_find_feature (GstRegistry * registry, const gchar * name,
779 GstPluginFeature *feature = NULL;
781 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
782 g_return_val_if_fail (name != NULL, NULL);
783 g_return_val_if_fail (g_type_is_a (type, GST_TYPE_PLUGIN_FEATURE), NULL);
785 feature = gst_registry_lookup_feature (registry, name);
786 if (feature && !g_type_is_a (G_TYPE_FROM_INSTANCE (feature), type)) {
787 gst_object_unref (feature);
795 * gst_registry_get_feature_list:
796 * @registry: a #GstRegistry
799 * Retrieves a #GList of #GstPluginFeature of @type.
801 * Returns: a #GList of #GstPluginFeature of @type. Use
802 * gst_plugin_feature_list_free() after usage.
807 gst_registry_get_feature_list (GstRegistry * registry, GType type)
809 GstTypeNameData data;
811 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
812 g_return_val_if_fail (g_type_is_a (type, GST_TYPE_PLUGIN_FEATURE), NULL);
815 if (type == GST_TYPE_ELEMENT_FACTORY)
816 return gst_registry_get_element_factory_list (registry);
817 else if (type == GST_TYPE_TYPE_FIND_FACTORY)
818 return gst_registry_get_typefind_factory_list (registry);
823 return gst_registry_feature_filter (registry,
824 (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
829 * gst_registry_get_plugin_list:
830 * @registry: the registry to search
832 * Get a copy of all plugins registered in the given registry. The refcount
833 * of each element in the list in incremented.
835 * Returns: a #GList of #GstPlugin. Use gst_plugin_list_free() after usage.
840 gst_registry_get_plugin_list (GstRegistry * registry)
845 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
847 GST_OBJECT_LOCK (registry);
848 list = g_list_copy (registry->plugins);
849 for (g = list; g; g = g->next) {
850 gst_object_ref (GST_PLUGIN_CAST (g->data));
852 GST_OBJECT_UNLOCK (registry);
857 static GstPluginFeature *
858 gst_registry_lookup_feature_locked (GstRegistry * registry, const char *name)
860 return g_hash_table_lookup (registry->feature_hash, name);
864 * gst_registry_lookup_feature:
865 * @registry: a #GstRegistry
866 * @name: a #GstPluginFeature name
868 * Find a #GstPluginFeature with @name in @registry.
870 * Returns: a #GstPluginFeature with its refcount incremented, use
871 * gst_object_unref() after usage.
876 gst_registry_lookup_feature (GstRegistry * registry, const char *name)
878 GstPluginFeature *feature;
880 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
881 g_return_val_if_fail (name != NULL, NULL);
883 GST_OBJECT_LOCK (registry);
884 feature = gst_registry_lookup_feature_locked (registry, name);
886 gst_object_ref (feature);
887 GST_OBJECT_UNLOCK (registry);
893 gst_registry_lookup_bn_locked (GstRegistry * registry, const char *basename)
895 return g_hash_table_lookup (registry->basename_hash, basename);
899 gst_registry_lookup_bn (GstRegistry * registry, const char *basename)
903 GST_OBJECT_LOCK (registry);
904 plugin = gst_registry_lookup_bn_locked (registry, basename);
906 gst_object_ref (plugin);
907 GST_OBJECT_UNLOCK (registry);
913 * gst_registry_lookup:
914 * @registry: the registry to look up in
915 * @filename: the name of the file to look up
917 * Look up a plugin in the given registry with the given filename.
918 * If found, plugin is reffed.
920 * Returns: the #GstPlugin if found, or NULL if not. gst_object_unref()
924 gst_registry_lookup (GstRegistry * registry, const char *filename)
929 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
930 g_return_val_if_fail (filename != NULL, NULL);
932 basename = g_path_get_basename (filename);
933 if (G_UNLIKELY (basename == NULL))
936 plugin = gst_registry_lookup_bn (registry, basename);
945 REGISTRY_SCAN_HELPER_NOT_STARTED = 0,
946 REGISTRY_SCAN_HELPER_DISABLED,
947 REGISTRY_SCAN_HELPER_RUNNING
948 } GstRegistryScanHelperState;
952 GstRegistry *registry;
953 GstRegistryScanHelperState helper_state;
954 GstPluginLoader *helper;
956 } GstRegistryScanContext;
959 init_scan_context (GstRegistryScanContext * context, GstRegistry * registry)
963 context->registry = registry;
965 /* see if forking is enabled and set up the scan helper state accordingly */
966 do_fork = _gst_enable_registry_fork;
968 const gchar *fork_env;
970 /* forking enabled, see if it is disabled with an env var */
971 if ((fork_env = g_getenv ("GST_REGISTRY_FORK"))) {
972 /* fork enabled for any value different from "no" */
973 do_fork = strcmp (fork_env, "no") != 0;
978 context->helper_state = REGISTRY_SCAN_HELPER_NOT_STARTED;
980 context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
982 context->helper = NULL;
983 context->changed = FALSE;
987 clear_scan_context (GstRegistryScanContext * context)
989 if (context->helper) {
990 context->changed |= _priv_gst_plugin_loader_funcs.destroy (context->helper);
991 context->helper = NULL;
996 gst_registry_scan_plugin_file (GstRegistryScanContext * context,
997 const gchar * filename, off_t file_size, time_t file_mtime)
999 gboolean changed = FALSE;
1000 GstPlugin *newplugin = NULL;
1003 /* Disable external plugin loader on Windows until it is ported properly. */
1004 context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
1008 /* Have a plugin to load - see if the scan-helper needs starting */
1009 if (context->helper_state == REGISTRY_SCAN_HELPER_NOT_STARTED) {
1010 GST_DEBUG ("Starting plugin scanner for file %s", filename);
1011 context->helper = _priv_gst_plugin_loader_funcs.create (context->registry);
1012 if (context->helper != NULL)
1013 context->helper_state = REGISTRY_SCAN_HELPER_RUNNING;
1015 GST_WARNING ("Failed starting plugin scanner. Scanning in-process");
1016 context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
1020 if (context->helper_state == REGISTRY_SCAN_HELPER_RUNNING) {
1021 GST_DEBUG ("Using scan-helper to load plugin %s", filename);
1022 if (!_priv_gst_plugin_loader_funcs.load (context->helper,
1023 filename, file_size, file_mtime)) {
1024 g_warning ("External plugin loader failed. This most likely means that "
1025 "the plugin loader helper binary was not found or could not be run. "
1026 "%s", (g_getenv ("GST_PLUGIN_PATH") != NULL) ?
1027 "If you are running an uninstalled GStreamer setup, you might need "
1028 "to update your gst-uninstalled script so that the "
1029 "GST_PLUGIN_SCANNER environment variable gets set." : "");
1030 context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
1034 /* Check if the helper is disabled (or just got disabled above) */
1035 if (context->helper_state == REGISTRY_SCAN_HELPER_DISABLED) {
1036 /* Load plugin the old fashioned way... */
1038 /* We don't use a GError here because a failure to load some shared
1039 * objects as plugins is normal (particularly in the uninstalled case)
1041 newplugin = gst_plugin_load_file (filename, NULL);
1045 GST_DEBUG_OBJECT (context->registry, "marking new plugin %p as registered",
1047 newplugin->registered = TRUE;
1048 gst_object_unref (newplugin);
1056 gst_registry_scan_path_level (GstRegistryScanContext * context,
1057 const gchar * path, int level)
1060 const gchar *dirent;
1063 gboolean changed = FALSE;
1065 dir = g_dir_open (path, 0, NULL);
1069 while ((dirent = g_dir_read_name (dir))) {
1070 struct stat file_status;
1072 filename = g_build_filename (path, dirent, NULL);
1073 if (g_stat (filename, &file_status) < 0) {
1074 /* Plugin will be removed from cache after the scan completes if it
1075 * is still marked 'cached' */
1080 if (file_status.st_mode & S_IFDIR) {
1081 /* skip the .debug directory, these contain elf files that are not
1082 * useful or worse, can crash dlopen (). do a quick check for the . first
1083 * and then call the compare functions. */
1084 if (G_UNLIKELY (dirent[0] == '.' && (g_str_equal (dirent, ".debug")
1085 || g_str_equal (dirent, ".git")))) {
1086 GST_LOG_OBJECT (context->registry, "ignoring .debug or .git directory");
1090 /* FIXME 0.11: Don't recurse into directories, this behaviour
1091 * is inconsistent with other PATH environment variables
1094 GST_LOG_OBJECT (context->registry, "recursing into directory %s",
1096 changed |= gst_registry_scan_path_level (context, filename, level - 1);
1098 GST_LOG_OBJECT (context->registry, "not recursing into directory %s, "
1099 "recursion level too deep", filename);
1104 if (!(file_status.st_mode & S_IFREG)) {
1105 GST_LOG_OBJECT (context->registry, "%s is not a regular file, ignoring",
1110 if (!g_str_has_suffix (dirent, G_MODULE_SUFFIX)
1111 #ifdef GST_EXTRA_MODULE_SUFFIX
1112 && !g_str_has_suffix (dirent, GST_EXTRA_MODULE_SUFFIX)
1115 GST_LOG_OBJECT (context->registry,
1116 "extension is not recognized as module file, ignoring file %s",
1122 GST_LOG_OBJECT (context->registry, "file %s looks like a possible module",
1125 /* plug-ins are considered unique by basename; if the given name
1126 * was already seen by the registry, we ignore it */
1127 plugin = gst_registry_lookup_bn (context->registry, dirent);
1129 gboolean env_vars_changed, deps_changed = FALSE;
1131 if (plugin->registered) {
1132 GST_DEBUG_OBJECT (context->registry,
1133 "plugin already registered from path \"%s\"",
1134 GST_STR_NULL (plugin->filename));
1136 gst_object_unref (plugin);
1140 env_vars_changed = _priv_plugin_deps_env_vars_changed (plugin);
1142 /* If a file with a certain basename is seen on a different path,
1143 * update the plugin to ensure the registry cache will reflect up
1144 * to date information */
1146 if (plugin->file_mtime == file_status.st_mtime &&
1147 plugin->file_size == file_status.st_size && !env_vars_changed &&
1148 !(deps_changed = _priv_plugin_deps_files_changed (plugin)) &&
1149 !strcmp (plugin->filename, filename)) {
1150 GST_LOG_OBJECT (context->registry, "file %s cached", filename);
1151 plugin->flags &= ~GST_PLUGIN_FLAG_CACHED;
1152 GST_LOG_OBJECT (context->registry,
1153 "marking plugin %p as registered as %s", plugin, filename);
1154 plugin->registered = TRUE;
1156 GST_INFO_OBJECT (context->registry, "cached info for %s is stale",
1158 GST_DEBUG_OBJECT (context->registry, "mtime %ld != %ld or size %"
1159 G_GINT64_FORMAT " != %" G_GINT64_FORMAT " or external dependency "
1160 "env_vars changed: %d or external dependencies changed: %d"
1161 " or old path %s != new path %s",
1162 plugin->file_mtime, file_status.st_mtime,
1163 (gint64) plugin->file_size, (gint64) file_status.st_size,
1164 env_vars_changed, deps_changed, plugin->filename, filename);
1165 gst_registry_remove_plugin (context->registry, plugin);
1166 changed |= gst_registry_scan_plugin_file (context, filename,
1167 file_status.st_size, file_status.st_mtime);
1169 gst_object_unref (plugin);
1172 GST_DEBUG_OBJECT (context->registry, "file %s not yet in registry",
1174 changed |= gst_registry_scan_plugin_file (context, filename,
1175 file_status.st_size, file_status.st_mtime);
1187 gst_registry_scan_path_internal (GstRegistryScanContext * context,
1192 GST_DEBUG_OBJECT (context->registry, "scanning path %s", path);
1193 changed = gst_registry_scan_path_level (context, path, 10);
1195 GST_DEBUG_OBJECT (context->registry, "registry changed in path %s: %d", path,
1201 * gst_registry_scan_path:
1202 * @registry: the registry to add found plugins to
1203 * @path: the path to scan
1205 * Scan the given path for plugins to add to the registry. The syntax of the
1206 * path is specific to the registry.
1208 * Returns: %TRUE if registry changed
1211 gst_registry_scan_path (GstRegistry * registry, const gchar * path)
1213 GstRegistryScanContext context;
1216 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
1217 g_return_val_if_fail (path != NULL, FALSE);
1219 init_scan_context (&context, registry);
1221 result = gst_registry_scan_path_internal (&context, path);
1223 clear_scan_context (&context);
1224 result |= context.changed;
1230 _gst_plugin_feature_filter_plugin_name (GstPluginFeature * feature,
1233 return (strcmp (feature->plugin_name, (gchar *) user_data) == 0);
1237 * gst_registry_get_feature_list_by_plugin:
1238 * @registry: a #GstRegistry.
1239 * @name: a plugin name.
1241 * Retrieves a #GList of features of the plugin with name @name.
1243 * Returns: a #GList of #GstPluginFeature. Use gst_plugin_feature_list_free()
1247 gst_registry_get_feature_list_by_plugin (GstRegistry * registry,
1250 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
1251 g_return_val_if_fail (name != NULL, NULL);
1253 return gst_registry_feature_filter (registry,
1254 _gst_plugin_feature_filter_plugin_name, FALSE, (gpointer) name);
1257 /* Unref and delete the default registry */
1259 _priv_gst_registry_cleanup ()
1261 GstRegistry *registry;
1263 g_static_mutex_lock (&_gst_registry_mutex);
1264 if ((registry = _gst_registry_default) != NULL) {
1265 _gst_registry_default = NULL;
1267 g_static_mutex_unlock (&_gst_registry_mutex);
1269 /* unref outside of the lock because we can. */
1271 gst_object_unref (registry);
1275 * gst_default_registry_check_feature_version:
1276 * @feature_name: the name of the feature (e.g. "oggdemux")
1277 * @min_major: the minimum major version number
1278 * @min_minor: the minimum minor version number
1279 * @min_micro: the minimum micro version number
1281 * Checks whether a plugin feature by the given name exists in the
1282 * default registry and whether its version is at least the
1285 * Returns: #TRUE if the feature could be found and the version is
1286 * the same as the required version or newer, and #FALSE otherwise.
1289 gst_default_registry_check_feature_version (const gchar * feature_name,
1290 guint min_major, guint min_minor, guint min_micro)
1292 GstPluginFeature *feature;
1293 GstRegistry *registry;
1294 gboolean ret = FALSE;
1296 g_return_val_if_fail (feature_name != NULL, FALSE);
1298 GST_DEBUG ("Looking up plugin feature '%s'", feature_name);
1300 registry = gst_registry_get_default ();
1301 feature = gst_registry_lookup_feature (registry, feature_name);
1303 ret = gst_plugin_feature_check_version (feature, min_major, min_minor,
1305 gst_object_unref (feature);
1307 GST_DEBUG ("Could not find plugin feature '%s'", feature_name);
1314 load_plugin_func (gpointer data, gpointer user_data)
1317 const gchar *filename;
1320 filename = (const gchar *) data;
1321 GST_DEBUG ("Pre-loading plugin %s", filename);
1323 plugin = gst_plugin_load_file (filename, &err);
1326 GST_INFO ("Loaded plugin: \"%s\"", filename);
1328 gst_default_registry_add_plugin (plugin);
1331 /* Report error to user, and free error */
1332 GST_ERROR ("Failed to load plugin: %s", err->message);
1335 GST_WARNING ("Failed to load plugin: \"%s\"", filename);
1340 #ifndef GST_DISABLE_REGISTRY
1341 /* Unref all plugins marked 'cached', to clear old plugins that no
1342 * longer exist. Returns TRUE if any plugins were removed */
1344 gst_registry_remove_cache_plugins (GstRegistry * registry)
1349 gboolean changed = FALSE;
1351 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
1353 GST_OBJECT_LOCK (registry);
1355 GST_DEBUG_OBJECT (registry, "removing cached plugins");
1356 g = registry->plugins;
1360 if (plugin->flags & GST_PLUGIN_FLAG_CACHED) {
1361 GST_DEBUG_OBJECT (registry, "removing cached plugin \"%s\"",
1362 GST_STR_NULL (plugin->filename));
1363 registry->plugins = g_list_delete_link (registry->plugins, g);
1364 if (G_LIKELY (plugin->basename))
1365 g_hash_table_remove (registry->basename_hash, plugin->basename);
1366 gst_registry_remove_features_for_plugin_unlocked (registry, plugin);
1367 gst_object_unref (plugin);
1373 GST_OBJECT_UNLOCK (registry);
1380 REGISTRY_SCAN_AND_UPDATE_FAILURE = 0,
1381 REGISTRY_SCAN_AND_UPDATE_SUCCESS_NOT_CHANGED,
1382 REGISTRY_SCAN_AND_UPDATE_SUCCESS_UPDATED
1383 } GstRegistryScanAndUpdateResult;
1386 * scan_and_update_registry:
1387 * @default_registry: the #GstRegistry
1388 * @registry_file: registry filename
1389 * @write_changes: write registry if it has changed?
1391 * Scans for registry changes and eventually updates the registry cache.
1393 * Return: %REGISTRY_SCAN_AND_UPDATE_FAILURE if the registry could not scanned
1394 * or updated, %REGISTRY_SCAN_AND_UPDATE_SUCCESS_NOT_CHANGED if the
1395 * registry is clean and %REGISTRY_SCAN_AND_UPDATE_SUCCESS_UPDATED if
1396 * it has been updated and the cache needs to be re-read.
1398 static GstRegistryScanAndUpdateResult
1399 scan_and_update_registry (GstRegistry * default_registry,
1400 const gchar * registry_file, gboolean write_changes, GError ** error)
1402 const gchar *plugin_path;
1403 gboolean changed = FALSE;
1405 GstRegistryScanContext context;
1407 GST_INFO ("Validating plugins from registry cache: %s", registry_file);
1409 init_scan_context (&context, default_registry);
1411 /* It sounds tempting to just compare the mtime of directories with the mtime
1412 * of the registry cache, but it does not work. It would not catch updated
1413 * plugins, which might bring more or less features.
1416 /* scan paths specified via --gst-plugin-path */
1417 GST_DEBUG ("scanning paths added via --gst-plugin-path");
1418 for (l = _priv_gst_plugin_paths; l != NULL; l = l->next) {
1419 GST_INFO ("Scanning plugin path: \"%s\"", (gchar *) l->data);
1420 changed |= gst_registry_scan_path_internal (&context, (gchar *) l->data);
1422 /* keep plugin_paths around in case a re-scan is forced later on */
1424 /* GST_PLUGIN_PATH specifies a list of directories to scan for
1425 * additional plugins. These take precedence over the system plugins */
1426 plugin_path = g_getenv ("GST_PLUGIN_PATH");
1431 GST_DEBUG ("GST_PLUGIN_PATH set to %s", plugin_path);
1432 list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0);
1433 for (i = 0; list[i]; i++) {
1434 changed |= gst_registry_scan_path_internal (&context, list[i]);
1438 GST_DEBUG ("GST_PLUGIN_PATH not set");
1441 /* GST_PLUGIN_SYSTEM_PATH specifies a list of plugins that are always
1442 * loaded by default. If not set, this defaults to the system-installed
1443 * path, and the plugins installed in the user's home directory */
1444 plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
1445 if (plugin_path == NULL) {
1448 GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH not set");
1450 /* plugins in the user's home directory take precedence over
1451 * system-installed ones */
1452 home_plugins = g_build_filename (g_get_home_dir (),
1453 ".gstreamer-" GST_MAJORMINOR, "plugins", NULL);
1454 GST_DEBUG ("scanning home plugins %s", home_plugins);
1455 changed |= gst_registry_scan_path_internal (&context, home_plugins);
1456 g_free (home_plugins);
1458 /* add the main (installed) library path */
1459 GST_DEBUG ("scanning main plugins %s", PLUGINDIR);
1460 changed |= gst_registry_scan_path_internal (&context, PLUGINDIR);
1468 g_win32_get_package_installation_directory_of_module
1469 (_priv_gst_dll_handle);
1471 dir = g_build_filename (base_dir, "lib", "gstreamer-0.10", NULL);
1472 GST_DEBUG ("scanning DLL dir %s", dir);
1474 changed |= gst_registry_scan_path_internal (&context, dir);
1484 GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH set to %s", plugin_path);
1485 list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0);
1486 for (i = 0; list[i]; i++) {
1487 changed |= gst_registry_scan_path_internal (&context, list[i]);
1492 clear_scan_context (&context);
1493 changed |= context.changed;
1495 /* Remove cached plugins so stale info is cleared. */
1496 changed |= gst_registry_remove_cache_plugins (default_registry);
1499 GST_INFO ("Registry cache has not changed");
1500 return REGISTRY_SCAN_AND_UPDATE_SUCCESS_NOT_CHANGED;
1503 if (!write_changes) {
1504 GST_INFO ("Registry cache changed, but writing is disabled. Not writing.");
1505 return REGISTRY_SCAN_AND_UPDATE_FAILURE;
1508 GST_INFO ("Registry cache changed. Writing new registry cache");
1509 if (!gst_registry_binary_write_cache (default_registry, registry_file)) {
1510 g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
1511 _("Error writing registry cache to %s: %s"),
1512 registry_file, g_strerror (errno));
1513 return REGISTRY_SCAN_AND_UPDATE_FAILURE;
1516 GST_INFO ("Registry cache written successfully");
1517 return REGISTRY_SCAN_AND_UPDATE_SUCCESS_UPDATED;
1521 ensure_current_registry (GError ** error)
1523 gchar *registry_file;
1524 GstRegistry *default_registry;
1525 gboolean ret = TRUE;
1526 gboolean do_update = TRUE;
1527 gboolean have_cache = TRUE;
1529 default_registry = gst_registry_get_default ();
1530 registry_file = g_strdup (g_getenv ("GST_REGISTRY"));
1531 if (registry_file == NULL) {
1532 registry_file = g_build_filename (g_get_home_dir (),
1533 ".gstreamer-" GST_MAJORMINOR, "registry." HOST_CPU ".bin", NULL);
1536 if (!_gst_disable_registry_cache) {
1537 GST_INFO ("reading registry cache: %s", registry_file);
1538 have_cache = gst_registry_binary_read_cache (default_registry,
1540 /* Only ever read the registry cache once, then disable it for
1541 * subsequent updates during the program lifetime */
1542 _gst_disable_registry_cache = TRUE;
1546 do_update = !_priv_gst_disable_registry_update;
1548 const gchar *update_env;
1550 if ((update_env = g_getenv ("GST_REGISTRY_UPDATE"))) {
1551 /* do update for any value different from "no" */
1552 do_update = (strcmp (update_env, "no") != 0);
1558 /* now check registry */
1559 GST_DEBUG ("Updating registry cache");
1560 scan_and_update_registry (default_registry, registry_file, TRUE, error);
1562 GST_DEBUG ("Not updating registry cache (disabled)");
1565 g_free (registry_file);
1566 GST_INFO ("registry reading and updating done, result = %d", ret);
1570 #endif /* GST_DISABLE_REGISTRY */
1573 * gst_registry_fork_is_enabled:
1575 * By default GStreamer will perform scanning and rebuilding of the
1576 * registry file using a helper child process.
1578 * Applications might want to disable this behaviour with the
1579 * gst_registry_fork_set_enabled() function, in which case new plugins
1580 * are scanned (and loaded) into the application process.
1582 * Returns: %TRUE if GStreamer will use the child helper process when
1583 * rebuilding the registry.
1588 gst_registry_fork_is_enabled (void)
1590 return _gst_enable_registry_fork;
1594 * gst_registry_fork_set_enabled:
1595 * @enabled: whether rebuilding the registry can use a temporary child helper process.
1597 * Applications might want to disable/enable spawning of a child helper process
1598 * when rebuilding the registry. See gst_registry_fork_is_enabled() for more
1604 gst_registry_fork_set_enabled (gboolean enabled)
1606 _gst_enable_registry_fork = enabled;
1610 * gst_update_registry:
1612 * Forces GStreamer to re-scan its plugin paths and update the default
1615 * Applications will almost never need to call this function, it is only
1616 * useful if the application knows new plugins have been installed (or old
1617 * ones removed) since the start of the application (or, to be precise, the
1618 * first call to gst_init()) and the application wants to make use of any
1619 * newly-installed plugins without restarting the application.
1621 * Applications should assume that the registry update is neither atomic nor
1622 * thread-safe and should therefore not have any dynamic pipelines running
1623 * (including the playbin and decodebin elements) and should also not create
1624 * any elements or access the GStreamer registry while the update is in
1627 * Note that this function may block for a significant amount of time.
1629 * Returns: %TRUE if the registry has been updated successfully (does not
1630 * imply that there were changes), otherwise %FALSE.
1635 gst_update_registry (void)
1639 #ifndef GST_DISABLE_REGISTRY
1642 res = ensure_current_registry (&err);
1644 GST_WARNING ("registry update failed: %s", err->message);
1647 GST_LOG ("registry update succeeded");
1651 GST_WARNING ("registry update failed: %s", "registry disabled");
1653 #endif /* GST_DISABLE_REGISTRY */
1655 if (_priv_gst_preload_plugins) {
1656 GST_DEBUG ("Preloading indicated plugins...");
1657 g_slist_foreach (_priv_gst_preload_plugins, load_plugin_func, NULL);
1664 * gst_registry_get_feature_list_cookie:
1665 * @registry: the registry
1667 * Returns the registrys feature list cookie. This changes
1668 * every time a feature is added or removed from the registry.
1670 * Returns: the feature list cookie.
1675 gst_registry_get_feature_list_cookie (GstRegistry * registry)
1677 g_return_val_if_fail (GST_IS_REGISTRY (registry), 0);
1679 return registry->priv->cookie;