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 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 file. The format
49 * and location of the cache file is internal to gstreamer.
51 * On startup, plugins are searched for in the plugin search path. The following
52 * locations are checked in this order:
55 * <para>location from --gst-plugin-path commandline option.</para>
58 * <para>the GST_PLUGIN_PATH environment variable.</para>
61 * <para>the GST_PLUGIN_SYSTEM_PATH environment variable.</para>
64 * <para>default locations (if GST_PLUGIN_SYSTEM_PATH is not set). Those
65 * default locations are:
66 * <filename>~/.gstreamer-$GST_MAJORMINOR/plugins/</filename>
67 * and <filename>$prefix/libs/gstreamer-$GST_MAJORMINOR/</filename>.
71 * The registry cache file is loaded from
72 * <filename>~/.gstreamer-$GST_MAJORMINOR/registry-$ARCH.bin</filename> or the
73 * file listed in the GST_REGISTRY env var. One reason to change the registry
74 * location is for testing.
76 * For each plugin that is found in the plugin search path, there could be 3
77 * possibilities for cached information:
80 * <para>the cache may not contain information about a given file.</para>
83 * <para>the cache may have stale information.</para>
86 * <para>the cache may have current information.</para>
90 * In the first two cases, the plugin is loaded and the cache updated. In
91 * addition to these cases, the cache may have entries for plugins that are not
92 * relevant to the current process. These are marked as not available to the
93 * current process. If the cache is updated for whatever reason, it is marked
96 * A dirty cache is written out at the end of initialization. Each entry is
97 * checked to make sure the information is minimally valid. If not, the entry is
100 * <emphasis role="bold">Implementation notes:</emphasis>
102 * The "cache" and "default registry" are different concepts and can represent
103 * different sets of plugins. For various reasons, at init time, the cache is
104 * stored in the default registry, and plugins not relevant to the current
105 * process are marked with the %GST_PLUGIN_FLAG_CACHED bit. These plugins are
106 * removed at the end of intitialization.
112 #include "gstconfig.h"
113 #include "gst_private.h"
115 #include <sys/types.h>
116 #include <sys/stat.h>
125 #include <glib/gstdio.h>
128 #include "gsterror.h"
129 #include "gstregistry.h"
130 #include "gstmarshal.h"
131 #include "gstfilter.h"
133 #include "gstpluginloader.h"
135 #include "gst-i18n-lib.h"
138 #include "glib-compat-private.h"
142 extern HMODULE _priv_gst_dll_handle;
145 #define GST_CAT_DEFAULT GST_CAT_REGISTRY
147 struct _GstRegistryPrivate
149 /* updated whenever the feature list changes */
151 /* speedup for searching features */
152 GList *element_factory_list;
154 GList *typefind_factory_list;
158 /* the one instance of the default registry and the mutex protecting the
160 static GStaticMutex _gst_registry_mutex = G_STATIC_MUTEX_INIT;
161 static GstRegistry *_gst_registry_default = NULL;
164 #define DEFAULT_FORK TRUE
166 /* control the behaviour of registry rebuild */
167 static gboolean _gst_enable_registry_fork = DEFAULT_FORK;
168 /* List of plugins that need preloading/reloading after scanning registry */
169 extern GSList *_priv_gst_preload_plugins;
171 #ifndef GST_DISABLE_REGISTRY
172 /*set to TRUE when registry needn't to be updated */
173 gboolean _priv_gst_disable_registry_update = FALSE;
174 extern GList *_priv_gst_plugin_paths;
176 /* Set to TRUE when the registry cache should be disabled */
177 gboolean _gst_disable_registry_cache = FALSE;
180 /* Element signals and args */
188 static void gst_registry_finalize (GObject * object);
190 static guint gst_registry_signals[LAST_SIGNAL] = { 0 };
192 static GstPluginFeature *gst_registry_lookup_feature_locked (GstRegistry *
193 registry, const char *name);
194 static GstPlugin *gst_registry_lookup_bn_locked (GstRegistry * registry,
195 const char *basename);
197 G_DEFINE_TYPE (GstRegistry, gst_registry, GST_TYPE_OBJECT);
198 static GstObjectClass *parent_class = NULL;
201 gst_registry_class_init (GstRegistryClass * klass)
203 GObjectClass *gobject_class;
205 gobject_class = (GObjectClass *) klass;
207 parent_class = g_type_class_peek_parent (klass);
208 g_type_class_add_private (klass, sizeof (GstRegistryPrivate));
211 * GstRegistry::plugin-added:
212 * @registry: the registry that emitted the signal
213 * @plugin: the plugin that has been added
215 * Signals that a plugin has been added to the registry (possibly
216 * replacing a previously-added one by the same name)
218 gst_registry_signals[PLUGIN_ADDED] =
219 g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass),
220 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL,
221 NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
224 * GstRegistry::feature-added:
225 * @registry: the registry that emitted the signal
226 * @feature: the feature that has been added
228 * Signals that a feature has been added to the registry (possibly
229 * replacing a previously-added one by the same name)
231 gst_registry_signals[FEATURE_ADDED] =
232 g_signal_new ("feature-added", G_TYPE_FROM_CLASS (klass),
233 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, feature_added),
234 NULL, NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
236 gobject_class->finalize = gst_registry_finalize;
240 gst_registry_init (GstRegistry * registry)
242 registry->feature_hash = g_hash_table_new (g_str_hash, g_str_equal);
243 registry->basename_hash = g_hash_table_new (g_str_hash, g_str_equal);
245 G_TYPE_INSTANCE_GET_PRIVATE (registry, GST_TYPE_REGISTRY,
250 gst_registry_finalize (GObject * object)
252 GstRegistry *registry = GST_REGISTRY (object);
256 plugins = registry->plugins;
257 registry->plugins = NULL;
259 GST_DEBUG_OBJECT (registry, "registry finalize");
262 GstPlugin *plugin = p->data;
265 GST_LOG_OBJECT (registry, "removing plugin %s",
266 gst_plugin_get_name (plugin));
267 gst_object_unref (plugin);
271 g_list_free (plugins);
273 features = registry->features;
274 registry->features = NULL;
278 GstPluginFeature *feature = f->data;
281 GST_LOG_OBJECT (registry, "removing feature %p (%s)",
282 feature, gst_plugin_feature_get_name (feature));
283 gst_object_unref (feature);
287 g_list_free (features);
289 g_hash_table_destroy (registry->feature_hash);
290 registry->feature_hash = NULL;
291 g_hash_table_destroy (registry->basename_hash);
292 registry->basename_hash = NULL;
294 if (registry->priv->element_factory_list) {
295 GST_DEBUG_OBJECT (registry, "Cleaning up cached element factory list");
296 gst_plugin_feature_list_free (registry->priv->element_factory_list);
299 if (registry->priv->typefind_factory_list) {
300 GST_DEBUG_OBJECT (registry, "Cleaning up cached typefind factory list");
301 gst_plugin_feature_list_free (registry->priv->typefind_factory_list);
304 G_OBJECT_CLASS (parent_class)->finalize (object);
308 * gst_registry_get_default:
310 * Retrieves the default registry. The caller does not own a reference on the
311 * registry, as it is alive as long as GStreamer is initialized.
313 * Returns: (transfer none): The default #GstRegistry.
316 gst_registry_get_default (void)
318 GstRegistry *registry;
320 g_static_mutex_lock (&_gst_registry_mutex);
321 if (G_UNLIKELY (!_gst_registry_default)) {
322 _gst_registry_default = g_object_newv (GST_TYPE_REGISTRY, 0, NULL);
323 gst_object_ref_sink (GST_OBJECT_CAST (_gst_registry_default));
325 registry = _gst_registry_default;
326 g_static_mutex_unlock (&_gst_registry_mutex);
332 * gst_registry_add_path:
333 * @registry: the registry to add the path to
334 * @path: the path to add to the registry
336 * Add the given path to the registry. The syntax of the
337 * path is specific to the registry. If the path has already been
341 gst_registry_add_path (GstRegistry * registry, const gchar * path)
343 g_return_if_fail (GST_IS_REGISTRY (registry));
344 g_return_if_fail (path != NULL);
346 if (strlen (path) == 0)
349 GST_OBJECT_LOCK (registry);
350 if (g_list_find_custom (registry->paths, path, (GCompareFunc) strcmp))
353 GST_INFO ("Adding plugin path: \"%s\"", path);
354 registry->paths = g_list_append (registry->paths, g_strdup (path));
355 GST_OBJECT_UNLOCK (registry);
361 GST_INFO ("Ignoring empty plugin path");
366 g_warning ("path %s already added to registry", path);
367 GST_OBJECT_UNLOCK (registry);
373 * gst_registry_get_path_list:
374 * @registry: the registry to get the pathlist of
376 * Get the list of paths for the given registry.
378 * Returns: (transfer container) (element-type char*): A #GList of paths as
379 * strings. g_list_free after use.
384 gst_registry_get_path_list (GstRegistry * registry)
388 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
390 GST_OBJECT_LOCK (registry);
391 /* We don't need to copy the strings, because they won't be deleted
392 * as long as the GstRegistry is around */
393 list = g_list_copy (registry->paths);
394 GST_OBJECT_UNLOCK (registry);
401 * gst_registry_add_plugin:
402 * @registry: the registry to add the plugin to
403 * @plugin: (transfer full): the plugin to add
405 * Add the plugin to the registry. The plugin-added signal will be emitted.
406 * This function will sink @plugin.
408 * Returns: TRUE on success.
413 gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
415 GstPlugin *existing_plugin;
417 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
418 g_return_val_if_fail (GST_IS_PLUGIN (plugin), FALSE);
420 GST_OBJECT_LOCK (registry);
421 if (G_LIKELY (plugin->basename)) {
422 /* we have a basename, see if we find the plugin */
424 gst_registry_lookup_bn_locked (registry, plugin->basename);
425 if (existing_plugin) {
426 GST_DEBUG_OBJECT (registry,
427 "Replacing existing plugin \"%s\" %p with new plugin %p for filename \"%s\"",
428 GST_STR_NULL (existing_plugin->filename), existing_plugin, plugin,
429 GST_STR_NULL (plugin->filename));
430 /* If the new plugin is blacklisted and the existing one isn't cached, do not
431 * accept if it's from a different location than the existing one */
432 if ((plugin->flags & GST_PLUGIN_FLAG_BLACKLISTED) &&
433 strcmp (plugin->filename, existing_plugin->filename)) {
434 GST_WARNING_OBJECT (registry,
435 "Not replacing plugin because new one (%s) is blacklisted but for a different location than existing one (%s)",
436 plugin->filename, existing_plugin->filename);
437 gst_object_unref (plugin);
438 GST_OBJECT_UNLOCK (registry);
441 registry->plugins = g_list_remove (registry->plugins, existing_plugin);
442 if (G_LIKELY (existing_plugin->basename))
443 g_hash_table_remove (registry->basename_hash,
444 existing_plugin->basename);
445 gst_object_unref (existing_plugin);
449 GST_DEBUG_OBJECT (registry, "adding plugin %p for filename \"%s\"",
450 plugin, GST_STR_NULL (plugin->filename));
452 registry->plugins = g_list_prepend (registry->plugins, plugin);
453 if (G_LIKELY (plugin->basename))
454 g_hash_table_replace (registry->basename_hash, plugin->basename, plugin);
456 gst_object_ref_sink (plugin);
457 GST_OBJECT_UNLOCK (registry);
459 GST_LOG_OBJECT (registry, "emitting plugin-added for filename \"%s\"",
460 GST_STR_NULL (plugin->filename));
461 g_signal_emit (registry, gst_registry_signals[PLUGIN_ADDED], 0, plugin);
467 gst_registry_remove_features_for_plugin_unlocked (GstRegistry * registry,
473 g_return_if_fail (GST_IS_REGISTRY (registry));
474 g_return_if_fail (GST_IS_PLUGIN (plugin));
476 name = gst_plugin_get_name (plugin);
478 /* Remove all features for this plugin */
479 f = registry->features;
481 GList *next = g_list_next (f);
482 GstPluginFeature *feature = f->data;
484 if (G_UNLIKELY (feature && !strcmp (feature->plugin_name, name))) {
485 GST_DEBUG_OBJECT (registry, "removing feature %p (%s) for plugin %s",
486 feature, gst_plugin_feature_get_name (feature), name);
488 registry->features = g_list_delete_link (registry->features, f);
489 g_hash_table_remove (registry->feature_hash, feature->name);
490 gst_object_unref (feature);
494 registry->priv->cookie++;
498 * gst_registry_remove_plugin:
499 * @registry: the registry to remove the plugin from
500 * @plugin: (transfer none): the plugin to remove
502 * Remove the plugin from the registry.
507 gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin)
509 g_return_if_fail (GST_IS_REGISTRY (registry));
510 g_return_if_fail (GST_IS_PLUGIN (plugin));
512 GST_DEBUG_OBJECT (registry, "removing plugin %p (%s)",
513 plugin, gst_plugin_get_name (plugin));
515 GST_OBJECT_LOCK (registry);
516 registry->plugins = g_list_remove (registry->plugins, plugin);
517 if (G_LIKELY (plugin->basename))
518 g_hash_table_remove (registry->basename_hash, plugin->basename);
519 gst_registry_remove_features_for_plugin_unlocked (registry, plugin);
520 GST_OBJECT_UNLOCK (registry);
521 gst_object_unref (plugin);
525 * gst_registry_add_feature:
526 * @registry: the registry to add the plugin to
527 * @feature: (transfer full): the feature to add
529 * Add the feature to the registry. The feature-added signal will be emitted.
530 * This function sinks @feature.
532 * Returns: TRUE on success.
537 gst_registry_add_feature (GstRegistry * registry, GstPluginFeature * feature)
539 GstPluginFeature *existing_feature;
541 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
542 g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
543 g_return_val_if_fail (feature->name != NULL, FALSE);
544 g_return_val_if_fail (feature->plugin_name != NULL, FALSE);
546 GST_OBJECT_LOCK (registry);
547 existing_feature = gst_registry_lookup_feature_locked (registry,
549 if (G_UNLIKELY (existing_feature)) {
550 GST_DEBUG_OBJECT (registry, "replacing existing feature %p (%s)",
551 existing_feature, feature->name);
552 /* Remove the existing feature from the list now, before we insert the new
553 * one, but don't unref yet because the hash is still storing a reference to
555 registry->features = g_list_remove (registry->features, existing_feature);
558 GST_DEBUG_OBJECT (registry, "adding feature %p (%s)", feature, feature->name);
560 registry->features = g_list_prepend (registry->features, feature);
561 g_hash_table_replace (registry->feature_hash, feature->name, feature);
563 if (G_UNLIKELY (existing_feature)) {
564 /* We unref now. No need to remove the feature name from the hash table, it
565 * got replaced by the new feature */
566 gst_object_unref (existing_feature);
569 gst_object_ref_sink (feature);
571 registry->priv->cookie++;
572 GST_OBJECT_UNLOCK (registry);
574 GST_LOG_OBJECT (registry, "emitting feature-added for %s", feature->name);
575 g_signal_emit (registry, gst_registry_signals[FEATURE_ADDED], 0, feature);
581 * gst_registry_remove_feature:
582 * @registry: the registry to remove the feature from
583 * @feature: (transfer none): the feature to remove
585 * Remove the feature from the registry.
590 gst_registry_remove_feature (GstRegistry * registry, GstPluginFeature * feature)
592 g_return_if_fail (GST_IS_REGISTRY (registry));
593 g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
595 GST_DEBUG_OBJECT (registry, "removing feature %p (%s)",
596 feature, gst_plugin_feature_get_name (feature));
598 GST_OBJECT_LOCK (registry);
599 registry->features = g_list_remove (registry->features, feature);
600 g_hash_table_remove (registry->feature_hash, feature->name);
601 registry->priv->cookie++;
602 GST_OBJECT_UNLOCK (registry);
603 gst_object_unref (feature);
607 * gst_registry_plugin_filter:
608 * @registry: registry to query
609 * @filter: the filter to use
610 * @first: only return first match
611 * @user_data: (closure): user data passed to the filter function
613 * Runs a filter against all plugins in the registry and returns a #GList with
614 * the results. If the first flag is set, only the first match is
615 * returned (as a list with a single object).
616 * Every plugin is reffed; use gst_plugin_list_free() after use, which
619 * Returns: (transfer full) (element-type Gst.Plugin): a #GList of #GstPlugin.
620 * Use gst_plugin_list_free() after usage.
625 gst_registry_plugin_filter (GstRegistry * registry,
626 GstPluginFilter filter, gboolean first, gpointer user_data)
631 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
633 GST_OBJECT_LOCK (registry);
634 list = gst_filter_run (registry->plugins, (GstFilterFunc) filter, first,
636 for (g = list; g; g = g->next) {
637 gst_object_ref (GST_PLUGIN_CAST (g->data));
639 GST_OBJECT_UNLOCK (registry);
644 /* returns TRUE if the list was changed
646 * Must be called with the object lock taken */
648 gst_registry_get_feature_list_or_create (GstRegistry * registry,
649 GList ** previous, guint32 * cookie, GType type)
651 gboolean res = FALSE;
652 GstRegistryPrivate *priv = registry->priv;
654 if (G_UNLIKELY (!*previous || priv->cookie != *cookie)) {
655 GstTypeNameData data;
658 gst_plugin_feature_list_free (*previous);
663 gst_filter_run (registry->features,
664 (GstFilterFunc) gst_plugin_feature_type_name_filter, FALSE, &data);
665 g_list_foreach (*previous, (GFunc) gst_object_ref, NULL);
666 *cookie = priv->cookie;
674 type_find_factory_rank_cmp (const GstPluginFeature * fac1,
675 const GstPluginFeature * fac2)
677 if (G_LIKELY (fac1->rank != fac2->rank))
678 return fac2->rank - fac1->rank;
680 /* to make the order in which things happen more deterministic,
681 * sort by name when the ranks are the same. */
682 return strcmp (fac1->name, fac2->name);
686 gst_registry_get_element_factory_list (GstRegistry * registry)
690 GST_OBJECT_LOCK (registry);
692 gst_registry_get_feature_list_or_create (registry,
693 ®istry->priv->element_factory_list, ®istry->priv->efl_cookie,
694 GST_TYPE_ELEMENT_FACTORY);
696 /* Return reffed copy */
697 list = gst_plugin_feature_list_copy (registry->priv->element_factory_list);
699 GST_OBJECT_UNLOCK (registry);
705 gst_registry_get_typefind_factory_list (GstRegistry * registry)
709 GST_OBJECT_LOCK (registry);
711 if (G_UNLIKELY (gst_registry_get_feature_list_or_create (registry,
712 ®istry->priv->typefind_factory_list,
713 ®istry->priv->tfl_cookie, GST_TYPE_TYPE_FIND_FACTORY)))
714 registry->priv->typefind_factory_list =
715 g_list_sort (registry->priv->typefind_factory_list,
716 (GCompareFunc) type_find_factory_rank_cmp);
718 /* Return reffed copy */
719 list = gst_plugin_feature_list_copy (registry->priv->typefind_factory_list);
721 GST_OBJECT_UNLOCK (registry);
727 * gst_registry_feature_filter:
728 * @registry: registry to query
729 * @filter: the filter to use
730 * @first: only return first match
731 * @user_data: (closure): user data passed to the filter function
733 * Runs a filter against all features of the plugins in the registry
734 * and returns a GList with the results.
735 * If the first flag is set, only the first match is
736 * returned (as a list with a single object).
738 * Returns: (transfer full) (element-type Gst.PluginFeature): a #GList of
739 * #GstPluginFeature. Use gst_plugin_feature_list_free() after usage.
744 gst_registry_feature_filter (GstRegistry * registry,
745 GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
750 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
752 GST_OBJECT_LOCK (registry);
753 list = gst_filter_run (registry->features, (GstFilterFunc) filter, first,
755 for (g = list; g; g = g->next) {
756 gst_object_ref (GST_PLUGIN_FEATURE_CAST (g->data));
758 GST_OBJECT_UNLOCK (registry);
764 * gst_registry_find_plugin:
765 * @registry: the registry to search
766 * @name: the plugin name to find
768 * Find the plugin with the given name in the registry.
769 * The plugin will be reffed; caller is responsible for unreffing.
771 * Returns: (transfer full): the plugin with the given name or NULL if the
772 * plugin was not found. gst_object_unref() after usage.
777 gst_registry_find_plugin (GstRegistry * registry, const gchar * name)
780 GstPlugin *result = NULL;
782 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
783 g_return_val_if_fail (name != NULL, NULL);
785 walk = gst_registry_plugin_filter (registry,
786 (GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name);
788 result = GST_PLUGIN_CAST (walk->data);
790 gst_object_ref (result);
791 gst_plugin_list_free (walk);
798 * gst_registry_find_feature:
799 * @registry: the registry to search
800 * @name: the pluginfeature name to find
801 * @type: the pluginfeature type to find
803 * Find the pluginfeature with the given name and type in the registry.
805 * Returns: (transfer full): the pluginfeature with the given name and type
806 * or NULL if the plugin was not found. gst_object_unref() after usage.
811 gst_registry_find_feature (GstRegistry * registry, const gchar * name,
814 GstPluginFeature *feature = NULL;
816 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
817 g_return_val_if_fail (name != NULL, NULL);
818 g_return_val_if_fail (g_type_is_a (type, GST_TYPE_PLUGIN_FEATURE), NULL);
820 feature = gst_registry_lookup_feature (registry, name);
821 if (feature && !g_type_is_a (G_TYPE_FROM_INSTANCE (feature), type)) {
822 gst_object_unref (feature);
830 * gst_registry_get_feature_list:
831 * @registry: a #GstRegistry
834 * Retrieves a #GList of #GstPluginFeature of @type.
836 * Returns: (transfer full) (element-type Gst.PluginFeature): a #GList of
837 * #GstPluginFeature of @type. Use gst_plugin_feature_list_free() after use
842 gst_registry_get_feature_list (GstRegistry * registry, GType type)
844 GstTypeNameData data;
846 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
847 g_return_val_if_fail (g_type_is_a (type, GST_TYPE_PLUGIN_FEATURE), NULL);
850 if (type == GST_TYPE_ELEMENT_FACTORY)
851 return gst_registry_get_element_factory_list (registry);
852 else if (type == GST_TYPE_TYPE_FIND_FACTORY)
853 return gst_registry_get_typefind_factory_list (registry);
858 return gst_registry_feature_filter (registry,
859 (GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
864 * gst_registry_get_plugin_list:
865 * @registry: the registry to search
867 * Get a copy of all plugins registered in the given registry. The refcount
868 * of each element in the list in incremented.
870 * Returns: (transfer full) (element-type Gst.Plugin): a #GList of #GstPlugin.
871 * Use gst_plugin_list_free() after usage.
876 gst_registry_get_plugin_list (GstRegistry * registry)
881 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
883 GST_OBJECT_LOCK (registry);
884 list = g_list_copy (registry->plugins);
885 for (g = list; g; g = g->next) {
886 gst_object_ref (GST_PLUGIN_CAST (g->data));
888 GST_OBJECT_UNLOCK (registry);
893 static GstPluginFeature *
894 gst_registry_lookup_feature_locked (GstRegistry * registry, const char *name)
896 return g_hash_table_lookup (registry->feature_hash, name);
900 * gst_registry_lookup_feature:
901 * @registry: a #GstRegistry
902 * @name: a #GstPluginFeature name
904 * Find a #GstPluginFeature with @name in @registry.
906 * Returns: (transfer full): a #GstPluginFeature with its refcount incremented,
907 * use gst_object_unref() after usage.
912 gst_registry_lookup_feature (GstRegistry * registry, const char *name)
914 GstPluginFeature *feature;
916 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
917 g_return_val_if_fail (name != NULL, NULL);
919 GST_OBJECT_LOCK (registry);
920 feature = gst_registry_lookup_feature_locked (registry, name);
922 gst_object_ref (feature);
923 GST_OBJECT_UNLOCK (registry);
929 gst_registry_lookup_bn_locked (GstRegistry * registry, const char *basename)
931 return g_hash_table_lookup (registry->basename_hash, basename);
935 gst_registry_lookup_bn (GstRegistry * registry, const char *basename)
939 GST_OBJECT_LOCK (registry);
940 plugin = gst_registry_lookup_bn_locked (registry, basename);
942 gst_object_ref (plugin);
943 GST_OBJECT_UNLOCK (registry);
949 * gst_registry_lookup:
950 * @registry: the registry to look up in
951 * @filename: the name of the file to look up
953 * Look up a plugin in the given registry with the given filename.
954 * If found, plugin is reffed.
956 * Returns: (transfer full): the #GstPlugin if found, or NULL if not.
957 * gst_object_unref() after usage.
960 gst_registry_lookup (GstRegistry * registry, const char *filename)
965 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
966 g_return_val_if_fail (filename != NULL, NULL);
968 basename = g_path_get_basename (filename);
969 if (G_UNLIKELY (basename == NULL))
972 plugin = gst_registry_lookup_bn (registry, basename);
981 REGISTRY_SCAN_HELPER_NOT_STARTED = 0,
982 REGISTRY_SCAN_HELPER_DISABLED,
983 REGISTRY_SCAN_HELPER_RUNNING
984 } GstRegistryScanHelperState;
988 GstRegistry *registry;
989 GstRegistryScanHelperState helper_state;
990 GstPluginLoader *helper;
992 } GstRegistryScanContext;
995 init_scan_context (GstRegistryScanContext * context, GstRegistry * registry)
999 context->registry = registry;
1001 /* see if forking is enabled and set up the scan helper state accordingly */
1002 do_fork = _gst_enable_registry_fork;
1004 const gchar *fork_env;
1006 /* forking enabled, see if it is disabled with an env var */
1007 if ((fork_env = g_getenv ("GST_REGISTRY_FORK"))) {
1008 /* fork enabled for any value different from "no" */
1009 do_fork = strcmp (fork_env, "no") != 0;
1014 context->helper_state = REGISTRY_SCAN_HELPER_NOT_STARTED;
1016 context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
1018 context->helper = NULL;
1019 context->changed = FALSE;
1023 clear_scan_context (GstRegistryScanContext * context)
1025 if (context->helper) {
1026 context->changed |= _priv_gst_plugin_loader_funcs.destroy (context->helper);
1027 context->helper = NULL;
1032 gst_registry_scan_plugin_file (GstRegistryScanContext * context,
1033 const gchar * filename, off_t file_size, time_t file_mtime)
1035 gboolean changed = FALSE;
1036 GstPlugin *newplugin = NULL;
1039 /* Disable external plugin loader on Windows until it is ported properly. */
1040 context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
1044 /* Have a plugin to load - see if the scan-helper needs starting */
1045 if (context->helper_state == REGISTRY_SCAN_HELPER_NOT_STARTED) {
1046 GST_DEBUG ("Starting plugin scanner for file %s", filename);
1047 context->helper = _priv_gst_plugin_loader_funcs.create (context->registry);
1048 if (context->helper != NULL)
1049 context->helper_state = REGISTRY_SCAN_HELPER_RUNNING;
1051 GST_WARNING ("Failed starting plugin scanner. Scanning in-process");
1052 context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
1056 if (context->helper_state == REGISTRY_SCAN_HELPER_RUNNING) {
1057 GST_DEBUG ("Using scan-helper to load plugin %s", filename);
1058 if (!_priv_gst_plugin_loader_funcs.load (context->helper,
1059 filename, file_size, file_mtime)) {
1060 g_warning ("External plugin loader failed. This most likely means that "
1061 "the plugin loader helper binary was not found or could not be run. "
1062 "%s", (g_getenv ("GST_PLUGIN_PATH") != NULL) ?
1063 "If you are running an uninstalled GStreamer setup, you might need "
1064 "to update your gst-uninstalled script so that the "
1065 "GST_PLUGIN_SCANNER environment variable gets set." : "");
1066 context->helper_state = REGISTRY_SCAN_HELPER_DISABLED;
1070 /* Check if the helper is disabled (or just got disabled above) */
1071 if (context->helper_state == REGISTRY_SCAN_HELPER_DISABLED) {
1072 /* Load plugin the old fashioned way... */
1074 /* We don't use a GError here because a failure to load some shared
1075 * objects as plugins is normal (particularly in the uninstalled case)
1077 newplugin = gst_plugin_load_file (filename, NULL);
1081 GST_DEBUG_OBJECT (context->registry, "marking new plugin %p as registered",
1083 newplugin->registered = TRUE;
1084 gst_object_unref (newplugin);
1092 is_blacklisted_hidden_directory (const gchar * dirent)
1094 if (G_LIKELY (dirent[0] != '.'))
1097 /* skip the .debug directory, these contain elf files that are not
1098 * useful or worse, can crash dlopen () */
1099 if (strcmp (dirent, ".debug") == 0)
1102 /* can also skip .git and .deps dirs, those won't contain useful files.
1103 * This speeds up scanning a bit in uninstalled setups. */
1104 if (strcmp (dirent, ".git") == 0 || strcmp (dirent, ".deps") == 0)
1111 gst_registry_scan_path_level (GstRegistryScanContext * context,
1112 const gchar * path, int level)
1115 const gchar *dirent;
1118 gboolean changed = FALSE;
1120 dir = g_dir_open (path, 0, NULL);
1124 while ((dirent = g_dir_read_name (dir))) {
1125 GStatBuf file_status;
1127 filename = g_build_filename (path, dirent, NULL);
1128 if (g_stat (filename, &file_status) < 0) {
1129 /* Plugin will be removed from cache after the scan completes if it
1130 * is still marked 'cached' */
1135 if (file_status.st_mode & S_IFDIR) {
1136 if (G_UNLIKELY (is_blacklisted_hidden_directory (dirent))) {
1137 GST_LOG_OBJECT (context->registry, "ignoring %s directory", dirent);
1141 /* FIXME 0.11: Don't recurse into directories, this behaviour
1142 * is inconsistent with other PATH environment variables
1145 GST_LOG_OBJECT (context->registry, "recursing into directory %s",
1147 changed |= gst_registry_scan_path_level (context, filename, level - 1);
1149 GST_LOG_OBJECT (context->registry, "not recursing into directory %s, "
1150 "recursion level too deep", filename);
1155 if (!(file_status.st_mode & S_IFREG)) {
1156 GST_LOG_OBJECT (context->registry, "%s is not a regular file, ignoring",
1161 if (!g_str_has_suffix (dirent, G_MODULE_SUFFIX)
1162 #ifdef GST_EXTRA_MODULE_SUFFIX
1163 && !g_str_has_suffix (dirent, GST_EXTRA_MODULE_SUFFIX)
1166 GST_LOG_OBJECT (context->registry,
1167 "extension is not recognized as module file, ignoring file %s",
1173 GST_LOG_OBJECT (context->registry, "file %s looks like a possible module",
1176 /* try to avoid unnecessary plugin-move pain */
1177 if (g_str_has_prefix (dirent, "libgstvalve") ||
1178 g_str_has_prefix (dirent, "libgstselector")) {
1179 GST_WARNING_OBJECT (context->registry, "ignoring old plugin %s which "
1180 "has been merged into the corelements plugin", filename);
1181 /* Plugin will be removed from cache after the scan completes if it
1182 * is still marked 'cached' */
1187 /* plug-ins are considered unique by basename; if the given name
1188 * was already seen by the registry, we ignore it */
1189 plugin = gst_registry_lookup_bn (context->registry, dirent);
1191 gboolean env_vars_changed, deps_changed = FALSE;
1193 if (plugin->registered) {
1194 GST_DEBUG_OBJECT (context->registry,
1195 "plugin already registered from path \"%s\"",
1196 GST_STR_NULL (plugin->filename));
1198 gst_object_unref (plugin);
1202 env_vars_changed = _priv_plugin_deps_env_vars_changed (plugin);
1204 /* If a file with a certain basename is seen on a different path,
1205 * update the plugin to ensure the registry cache will reflect up
1206 * to date information */
1208 if (plugin->file_mtime == file_status.st_mtime &&
1209 plugin->file_size == file_status.st_size && !env_vars_changed &&
1210 !(deps_changed = _priv_plugin_deps_files_changed (plugin)) &&
1211 !strcmp (plugin->filename, filename)) {
1212 GST_LOG_OBJECT (context->registry, "file %s cached", filename);
1213 plugin->flags &= ~GST_PLUGIN_FLAG_CACHED;
1214 GST_LOG_OBJECT (context->registry,
1215 "marking plugin %p as registered as %s", plugin, filename);
1216 plugin->registered = TRUE;
1218 GST_INFO_OBJECT (context->registry, "cached info for %s is stale",
1220 GST_DEBUG_OBJECT (context->registry, "mtime %ld != %ld or size %"
1221 G_GINT64_FORMAT " != %" G_GINT64_FORMAT " or external dependency "
1222 "env_vars changed: %d or external dependencies changed: %d"
1223 " or old path %s != new path %s",
1224 plugin->file_mtime, file_status.st_mtime,
1225 (gint64) plugin->file_size, (gint64) file_status.st_size,
1226 env_vars_changed, deps_changed, plugin->filename, filename);
1227 gst_registry_remove_plugin (context->registry, plugin);
1228 changed |= gst_registry_scan_plugin_file (context, filename,
1229 file_status.st_size, file_status.st_mtime);
1231 gst_object_unref (plugin);
1234 GST_DEBUG_OBJECT (context->registry, "file %s not yet in registry",
1236 changed |= gst_registry_scan_plugin_file (context, filename,
1237 file_status.st_size, file_status.st_mtime);
1249 gst_registry_scan_path_internal (GstRegistryScanContext * context,
1254 GST_DEBUG_OBJECT (context->registry, "scanning path %s", path);
1255 changed = gst_registry_scan_path_level (context, path, 10);
1257 GST_DEBUG_OBJECT (context->registry, "registry changed in path %s: %d", path,
1263 * gst_registry_scan_path:
1264 * @registry: the registry to add found plugins to
1265 * @path: the path to scan
1267 * Scan the given path for plugins to add to the registry. The syntax of the
1268 * path is specific to the registry.
1270 * Returns: %TRUE if registry changed
1273 gst_registry_scan_path (GstRegistry * registry, const gchar * path)
1275 GstRegistryScanContext context;
1278 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
1279 g_return_val_if_fail (path != NULL, FALSE);
1281 init_scan_context (&context, registry);
1283 result = gst_registry_scan_path_internal (&context, path);
1285 clear_scan_context (&context);
1286 result |= context.changed;
1292 _gst_plugin_feature_filter_plugin_name (GstPluginFeature * feature,
1295 return (strcmp (feature->plugin_name, (gchar *) user_data) == 0);
1299 * gst_registry_get_feature_list_by_plugin:
1300 * @registry: a #GstRegistry.
1301 * @name: a plugin name.
1303 * Retrieves a #GList of features of the plugin with name @name.
1305 * Returns: (transfer full) (element-type Gst.PluginFeature): a #GList of
1306 * #GstPluginFeature. Use gst_plugin_feature_list_free() after usage.
1309 gst_registry_get_feature_list_by_plugin (GstRegistry * registry,
1312 g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
1313 g_return_val_if_fail (name != NULL, NULL);
1315 return gst_registry_feature_filter (registry,
1316 _gst_plugin_feature_filter_plugin_name, FALSE, (gpointer) name);
1319 /* Unref and delete the default registry */
1321 _priv_gst_registry_cleanup (void)
1323 GstRegistry *registry;
1325 g_static_mutex_lock (&_gst_registry_mutex);
1326 if ((registry = _gst_registry_default) != NULL) {
1327 _gst_registry_default = NULL;
1329 g_static_mutex_unlock (&_gst_registry_mutex);
1331 /* unref outside of the lock because we can. */
1333 gst_object_unref (registry);
1337 * gst_default_registry_check_feature_version:
1338 * @feature_name: the name of the feature (e.g. "oggdemux")
1339 * @min_major: the minimum major version number
1340 * @min_minor: the minimum minor version number
1341 * @min_micro: the minimum micro version number
1343 * Checks whether a plugin feature by the given name exists in the
1344 * default registry and whether its version is at least the
1347 * Returns: #TRUE if the feature could be found and the version is
1348 * the same as the required version or newer, and #FALSE otherwise.
1351 gst_default_registry_check_feature_version (const gchar * feature_name,
1352 guint min_major, guint min_minor, guint min_micro)
1354 GstPluginFeature *feature;
1355 GstRegistry *registry;
1356 gboolean ret = FALSE;
1358 g_return_val_if_fail (feature_name != NULL, FALSE);
1360 GST_DEBUG ("Looking up plugin feature '%s'", feature_name);
1362 registry = gst_registry_get_default ();
1363 feature = gst_registry_lookup_feature (registry, feature_name);
1365 ret = gst_plugin_feature_check_version (feature, min_major, min_minor,
1367 gst_object_unref (feature);
1369 GST_DEBUG ("Could not find plugin feature '%s'", feature_name);
1376 load_plugin_func (gpointer data, gpointer user_data)
1379 const gchar *filename;
1382 filename = (const gchar *) data;
1383 GST_DEBUG ("Pre-loading plugin %s", filename);
1385 plugin = gst_plugin_load_file (filename, &err);
1388 GST_INFO ("Loaded plugin: \"%s\"", filename);
1390 gst_default_registry_add_plugin (plugin);
1393 /* Report error to user, and free error */
1394 GST_ERROR ("Failed to load plugin: %s", err->message);
1397 GST_WARNING ("Failed to load plugin: \"%s\"", filename);
1402 #ifndef GST_DISABLE_REGISTRY
1403 /* Unref all plugins marked 'cached', to clear old plugins that no
1404 * longer exist. Returns TRUE if any plugins were removed */
1406 gst_registry_remove_cache_plugins (GstRegistry * registry)
1411 gboolean changed = FALSE;
1413 g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
1415 GST_OBJECT_LOCK (registry);
1417 GST_DEBUG_OBJECT (registry, "removing cached plugins");
1418 g = registry->plugins;
1422 if (plugin->flags & GST_PLUGIN_FLAG_CACHED) {
1423 GST_DEBUG_OBJECT (registry, "removing cached plugin \"%s\"",
1424 GST_STR_NULL (plugin->filename));
1425 registry->plugins = g_list_delete_link (registry->plugins, g);
1426 if (G_LIKELY (plugin->basename))
1427 g_hash_table_remove (registry->basename_hash, plugin->basename);
1428 gst_registry_remove_features_for_plugin_unlocked (registry, plugin);
1429 gst_object_unref (plugin);
1435 GST_OBJECT_UNLOCK (registry);
1442 REGISTRY_SCAN_AND_UPDATE_FAILURE = 0,
1443 REGISTRY_SCAN_AND_UPDATE_SUCCESS_NOT_CHANGED,
1444 REGISTRY_SCAN_AND_UPDATE_SUCCESS_UPDATED
1445 } GstRegistryScanAndUpdateResult;
1448 * scan_and_update_registry:
1449 * @default_registry: the #GstRegistry
1450 * @registry_file: registry filename
1451 * @write_changes: write registry if it has changed?
1453 * Scans for registry changes and eventually updates the registry cache.
1455 * Return: %REGISTRY_SCAN_AND_UPDATE_FAILURE if the registry could not scanned
1456 * or updated, %REGISTRY_SCAN_AND_UPDATE_SUCCESS_NOT_CHANGED if the
1457 * registry is clean and %REGISTRY_SCAN_AND_UPDATE_SUCCESS_UPDATED if
1458 * it has been updated and the cache needs to be re-read.
1460 static GstRegistryScanAndUpdateResult
1461 scan_and_update_registry (GstRegistry * default_registry,
1462 const gchar * registry_file, gboolean write_changes, GError ** error)
1464 const gchar *plugin_path;
1465 gboolean changed = FALSE;
1467 GstRegistryScanContext context;
1469 GST_INFO ("Validating plugins from registry cache: %s", registry_file);
1471 init_scan_context (&context, default_registry);
1473 /* It sounds tempting to just compare the mtime of directories with the mtime
1474 * of the registry cache, but it does not work. It would not catch updated
1475 * plugins, which might bring more or less features.
1478 /* scan paths specified via --gst-plugin-path */
1479 GST_DEBUG ("scanning paths added via --gst-plugin-path");
1480 for (l = _priv_gst_plugin_paths; l != NULL; l = l->next) {
1481 GST_INFO ("Scanning plugin path: \"%s\"", (gchar *) l->data);
1482 changed |= gst_registry_scan_path_internal (&context, (gchar *) l->data);
1484 /* keep plugin_paths around in case a re-scan is forced later on */
1486 /* GST_PLUGIN_PATH specifies a list of directories to scan for
1487 * additional plugins. These take precedence over the system plugins */
1488 plugin_path = g_getenv ("GST_PLUGIN_PATH");
1493 GST_DEBUG ("GST_PLUGIN_PATH set to %s", plugin_path);
1494 list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0);
1495 for (i = 0; list[i]; i++) {
1496 changed |= gst_registry_scan_path_internal (&context, list[i]);
1500 GST_DEBUG ("GST_PLUGIN_PATH not set");
1503 /* GST_PLUGIN_SYSTEM_PATH specifies a list of plugins that are always
1504 * loaded by default. If not set, this defaults to the system-installed
1505 * path, and the plugins installed in the user's home directory */
1506 plugin_path = g_getenv ("GST_PLUGIN_SYSTEM_PATH");
1507 if (plugin_path == NULL) {
1510 GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH not set");
1512 /* plugins in the user's home directory take precedence over
1513 * system-installed ones */
1514 home_plugins = g_build_filename (g_get_home_dir (),
1515 ".gstreamer-" GST_MAJORMINOR, "plugins", NULL);
1516 GST_DEBUG ("scanning home plugins %s", home_plugins);
1517 changed |= gst_registry_scan_path_internal (&context, home_plugins);
1518 g_free (home_plugins);
1520 /* add the main (installed) library path */
1521 GST_DEBUG ("scanning main plugins %s", PLUGINDIR);
1522 changed |= gst_registry_scan_path_internal (&context, PLUGINDIR);
1530 g_win32_get_package_installation_directory_of_module
1531 (_priv_gst_dll_handle);
1533 dir = g_build_filename (base_dir, "lib", "gstreamer-0.10", NULL);
1534 GST_DEBUG ("scanning DLL dir %s", dir);
1536 changed |= gst_registry_scan_path_internal (&context, dir);
1546 GST_DEBUG ("GST_PLUGIN_SYSTEM_PATH set to %s", plugin_path);
1547 list = g_strsplit (plugin_path, G_SEARCHPATH_SEPARATOR_S, 0);
1548 for (i = 0; list[i]; i++) {
1549 changed |= gst_registry_scan_path_internal (&context, list[i]);
1554 clear_scan_context (&context);
1555 changed |= context.changed;
1557 /* Remove cached plugins so stale info is cleared. */
1558 changed |= gst_registry_remove_cache_plugins (default_registry);
1561 GST_INFO ("Registry cache has not changed");
1562 return REGISTRY_SCAN_AND_UPDATE_SUCCESS_NOT_CHANGED;
1565 if (!write_changes) {
1566 GST_INFO ("Registry cache changed, but writing is disabled. Not writing.");
1567 return REGISTRY_SCAN_AND_UPDATE_FAILURE;
1570 GST_INFO ("Registry cache changed. Writing new registry cache");
1571 if (!gst_registry_binary_write_cache (default_registry, registry_file)) {
1572 g_set_error (error, GST_CORE_ERROR, GST_CORE_ERROR_FAILED,
1573 _("Error writing registry cache to %s: %s"),
1574 registry_file, g_strerror (errno));
1575 return REGISTRY_SCAN_AND_UPDATE_FAILURE;
1578 GST_INFO ("Registry cache written successfully");
1579 return REGISTRY_SCAN_AND_UPDATE_SUCCESS_UPDATED;
1583 ensure_current_registry (GError ** error)
1585 gchar *registry_file;
1586 GstRegistry *default_registry;
1587 gboolean ret = TRUE;
1588 gboolean do_update = TRUE;
1589 gboolean have_cache = TRUE;
1591 default_registry = gst_registry_get_default ();
1592 registry_file = g_strdup (g_getenv ("GST_REGISTRY"));
1593 if (registry_file == NULL) {
1594 registry_file = g_build_filename (g_get_home_dir (),
1595 ".gstreamer-" GST_MAJORMINOR, "registry." HOST_CPU ".bin", NULL);
1598 if (!_gst_disable_registry_cache) {
1599 GST_INFO ("reading registry cache: %s", registry_file);
1600 have_cache = gst_registry_binary_read_cache (default_registry,
1602 /* Only ever read the registry cache once, then disable it for
1603 * subsequent updates during the program lifetime */
1604 _gst_disable_registry_cache = TRUE;
1608 do_update = !_priv_gst_disable_registry_update;
1610 const gchar *update_env;
1612 if ((update_env = g_getenv ("GST_REGISTRY_UPDATE"))) {
1613 /* do update for any value different from "no" */
1614 do_update = (strcmp (update_env, "no") != 0);
1620 /* now check registry */
1621 GST_DEBUG ("Updating registry cache");
1622 scan_and_update_registry (default_registry, registry_file, TRUE, error);
1624 GST_DEBUG ("Not updating registry cache (disabled)");
1627 g_free (registry_file);
1628 GST_INFO ("registry reading and updating done, result = %d", ret);
1632 #endif /* GST_DISABLE_REGISTRY */
1635 * gst_registry_fork_is_enabled:
1637 * By default GStreamer will perform scanning and rebuilding of the
1638 * registry file using a helper child process.
1640 * Applications might want to disable this behaviour with the
1641 * gst_registry_fork_set_enabled() function, in which case new plugins
1642 * are scanned (and loaded) into the application process.
1644 * Returns: %TRUE if GStreamer will use the child helper process when
1645 * rebuilding the registry.
1650 gst_registry_fork_is_enabled (void)
1652 return _gst_enable_registry_fork;
1656 * gst_registry_fork_set_enabled:
1657 * @enabled: whether rebuilding the registry can use a temporary child helper process.
1659 * Applications might want to disable/enable spawning of a child helper process
1660 * when rebuilding the registry. See gst_registry_fork_is_enabled() for more
1666 gst_registry_fork_set_enabled (gboolean enabled)
1668 _gst_enable_registry_fork = enabled;
1672 * gst_update_registry:
1674 * Forces GStreamer to re-scan its plugin paths and update the default
1677 * Applications will almost never need to call this function, it is only
1678 * useful if the application knows new plugins have been installed (or old
1679 * ones removed) since the start of the application (or, to be precise, the
1680 * first call to gst_init()) and the application wants to make use of any
1681 * newly-installed plugins without restarting the application.
1683 * Applications should assume that the registry update is neither atomic nor
1684 * thread-safe and should therefore not have any dynamic pipelines running
1685 * (including the playbin and decodebin elements) and should also not create
1686 * any elements or access the GStreamer registry while the update is in
1689 * Note that this function may block for a significant amount of time.
1691 * Returns: %TRUE if the registry has been updated successfully (does not
1692 * imply that there were changes), otherwise %FALSE.
1697 gst_update_registry (void)
1701 #ifndef GST_DISABLE_REGISTRY
1704 res = ensure_current_registry (&err);
1706 GST_WARNING ("registry update failed: %s", err->message);
1709 GST_LOG ("registry update succeeded");
1713 GST_WARNING ("registry update failed: %s", "registry disabled");
1715 #endif /* GST_DISABLE_REGISTRY */
1717 if (_priv_gst_preload_plugins) {
1718 GST_DEBUG ("Preloading indicated plugins...");
1719 g_slist_foreach (_priv_gst_preload_plugins, load_plugin_func, NULL);
1726 * gst_registry_get_feature_list_cookie:
1727 * @registry: the registry
1729 * Returns the registrys feature list cookie. This changes
1730 * every time a feature is added or removed from the registry.
1732 * Returns: the feature list cookie.
1737 gst_registry_get_feature_list_cookie (GstRegistry * registry)
1739 g_return_val_if_fail (GST_IS_REGISTRY (registry), 0);
1741 return registry->priv->cookie;