2002-04-12 09:53:00 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
2005-09-15 00:13:26 +00:00
|
|
|
* 2005 David A. Schleef <ds@schleef.org>
|
2002-04-12 09:53:00 +00:00
|
|
|
*
|
|
|
|
* gstregistry.c: handle registry
|
2004-03-15 15:16:04 +00:00
|
|
|
*
|
2002-04-12 09:53:00 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
2005-10-15 16:01:57 +00:00
|
|
|
|
2005-09-02 16:17:23 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gstregistry
|
|
|
|
* @short_description: Abstract base class for management of #GstPlugin objects
|
|
|
|
* @see_also: #GstPlugin, #GstPluginFeature
|
|
|
|
*
|
|
|
|
* One registry holds the metadata of a set of plugins.
|
|
|
|
* All registries build the #GstRegistryPool.
|
|
|
|
*/
|
2002-04-12 09:53:00 +00:00
|
|
|
|
2004-04-28 23:26:06 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2004-05-07 02:36:28 +00:00
|
|
|
#include "gst_private.h"
|
2002-04-12 09:53:00 +00:00
|
|
|
#include <glib.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2004-04-28 23:26:06 +00:00
|
|
|
#ifdef HAVE_UNISTD_H
|
2002-04-12 09:53:00 +00:00
|
|
|
#include <unistd.h>
|
2004-04-28 23:26:06 +00:00
|
|
|
#endif
|
2002-04-12 09:53:00 +00:00
|
|
|
#include <errno.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
|
2002-04-12 09:53:00 +00:00
|
|
|
#include "gstinfo.h"
|
|
|
|
#include "gstregistry.h"
|
2002-07-08 19:07:30 +00:00
|
|
|
#include "gstmarshal.h"
|
2003-04-14 18:53:03 +00:00
|
|
|
#include "gstfilter.h"
|
2002-04-12 09:53:00 +00:00
|
|
|
|
2005-09-15 00:13:26 +00:00
|
|
|
#define GST_CAT_DEFAULT GST_CAT_REGISTRY
|
|
|
|
|
2005-09-18 21:24:55 +00:00
|
|
|
/* the one instance of the default registry */
|
|
|
|
static GstRegistry *_gst_registry_default = NULL;
|
|
|
|
|
2005-09-15 00:13:26 +00:00
|
|
|
/*
|
|
|
|
* Design:
|
|
|
|
*
|
|
|
|
* The GstRegistry object is a list of plugins and some functions
|
|
|
|
* for dealing with them. Plugins are matched 1-1 with a file on
|
|
|
|
* disk, and may or may not be loaded at a given time. There may
|
|
|
|
* be multiple GstRegistry objects, but the "default registry" is
|
|
|
|
* the only object that has any meaning to the core.
|
|
|
|
*
|
|
|
|
* The registry.xml file in 0.9 is actually a cache of plugin
|
|
|
|
* information. This is unlike previous versions, where the registry
|
|
|
|
* file was the primary source of plugin information, and was created
|
|
|
|
* by the gst-register command.
|
|
|
|
*
|
|
|
|
* In 0.9, the primary source, at all times, of plugin information
|
|
|
|
* is each plugin file itself. Thus, if an application wants
|
|
|
|
* information about a particular plugin, or wants to search for
|
|
|
|
* a feature that satisfies given criteria, the primary means of
|
|
|
|
* doing so is to load every plugin and look at the resulting
|
|
|
|
* information that is gathered in the default registry. Clearly,
|
|
|
|
* this is a time consuming process, so we cache information in
|
|
|
|
* the registry.xml file.
|
|
|
|
*
|
|
|
|
* On startup, plugins are searched for in the plugin search path.
|
|
|
|
* This path can be set directly using the GST_PLUGIN_PATH
|
|
|
|
* environment variable. The registry file is loaded from
|
|
|
|
* ~/.gstreamer-0.9/registry.xml or the file listed in the
|
|
|
|
* GST_REGISTRY env var. The only reason to change the registry
|
|
|
|
* location is for testing.
|
|
|
|
*
|
|
|
|
* For each plugin that is found in the plugin search path, there
|
|
|
|
* could be 3 possibilities for cached information:
|
|
|
|
* - the cache may not contain information about a given file.
|
|
|
|
* - the cache may have stale information.
|
|
|
|
* - the cache may have current information.
|
|
|
|
* In the first two cases, the plugin is loaded and the cache
|
|
|
|
* updated. In addition to these cases, the cache may have entries
|
|
|
|
* for plugins that are not relevant to the current process. These
|
|
|
|
* are marked as not available to the current process. If the
|
|
|
|
* cache is updated for whatever reason, it is marked dirty.
|
|
|
|
*
|
|
|
|
* A dirty cache is written out at the end of initialization. Each
|
|
|
|
* entry is checked to make sure the information is minimally valid.
|
|
|
|
* If not, the entry is simply dropped.
|
|
|
|
*
|
|
|
|
* Implementation notes:
|
|
|
|
*
|
|
|
|
* The "cache" and "default registry" are different concepts and
|
|
|
|
* can represent different sets of plugins. For various reasons,
|
|
|
|
* at init time, the cache is stored in the default registry, and
|
|
|
|
* plugins not relevant to the current process are marked with the
|
|
|
|
* GST_PLUGIN_FLAG_CACHED bit. These plugins are removed at the
|
|
|
|
* end of intitialization.
|
|
|
|
*
|
|
|
|
*/
|
2005-06-29 12:25:05 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
/* Element signals and args */
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2002-05-08 20:40:48 +00:00
|
|
|
PLUGIN_ADDED,
|
2005-09-18 06:59:25 +00:00
|
|
|
FEATURE_ADDED,
|
2002-05-08 20:40:48 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_registry_class_init (GstRegistryClass * klass);
|
|
|
|
static void gst_registry_init (GstRegistry * registry);
|
2005-09-18 21:24:55 +00:00
|
|
|
static void gst_registry_finalize (GObject * object);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static guint gst_registry_signals[LAST_SIGNAL] = { 0 };
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
static GstPluginFeature *gst_registry_lookup_feature_locked (GstRegistry *
|
|
|
|
registry, const char *name);
|
2005-09-15 23:51:24 +00:00
|
|
|
static GstPlugin *gst_registry_lookup_locked (GstRegistry * registry,
|
|
|
|
const char *filename);
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GstRegistry, gst_registry, GST_TYPE_OBJECT);
|
2005-09-18 21:24:55 +00:00
|
|
|
static GstObjectClass *parent_class = NULL;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_registry_class_init (GstRegistryClass * klass)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gobject_class = (GObjectClass *) klass;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-09-18 21:24:55 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
gst_registry_signals[PLUGIN_ADDED] =
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL,
|
|
|
|
NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_registry_signals[FEATURE_ADDED] =
|
|
|
|
g_signal_new ("feature-added", G_TYPE_FROM_CLASS (klass),
|
|
|
|
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, feature_added),
|
|
|
|
NULL, NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-09-18 21:24:55 +00:00
|
|
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_registry_finalize);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_registry_init (GstRegistry * registry)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2005-09-18 21:24:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_registry_finalize (GObject * object)
|
|
|
|
{
|
|
|
|
GstRegistry *registry = GST_REGISTRY (object);
|
|
|
|
GList *plugins, *p;
|
|
|
|
GList *features, *f;
|
|
|
|
|
|
|
|
plugins = registry->plugins;
|
|
|
|
registry->plugins = NULL;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (registry, "registry finalize");
|
|
|
|
p = plugins;
|
|
|
|
while (p) {
|
|
|
|
GstPlugin *plugin = p->data;
|
|
|
|
|
|
|
|
if (plugin) {
|
|
|
|
GST_DEBUG_OBJECT (registry, "removing plugin %s",
|
|
|
|
gst_plugin_get_name (plugin));
|
|
|
|
gst_registry_remove_plugin (registry, plugin);
|
|
|
|
}
|
|
|
|
p = g_list_next (p);
|
|
|
|
}
|
|
|
|
g_list_free (plugins);
|
|
|
|
|
|
|
|
features = registry->features;
|
|
|
|
registry->features = NULL;
|
2002-12-19 21:31:03 +00:00
|
|
|
|
2005-09-18 21:24:55 +00:00
|
|
|
f = features;
|
|
|
|
while (f) {
|
|
|
|
GstPluginFeature *feature = f->data;
|
|
|
|
|
|
|
|
if (feature) {
|
|
|
|
gst_registry_remove_feature (registry, feature);
|
|
|
|
}
|
|
|
|
f = g_list_next (f);
|
|
|
|
}
|
|
|
|
g_list_free (features);
|
|
|
|
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
2005-09-22 12:05:05 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_get_default:
|
|
|
|
*
|
|
|
|
* Retrieves the default registry. The caller does not own a reference on the
|
|
|
|
* registry, as it is alive as long as GStreamer is initialized.
|
2005-12-02 12:34:47 +00:00
|
|
|
*
|
|
|
|
* Returns: The default #GstRegistry.
|
2005-09-22 12:05:05 +00:00
|
|
|
*/
|
2005-09-15 00:13:26 +00:00
|
|
|
GstRegistry *
|
|
|
|
gst_registry_get_default (void)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2005-09-15 00:13:26 +00:00
|
|
|
if (!_gst_registry_default) {
|
|
|
|
_gst_registry_default = g_object_new (GST_TYPE_REGISTRY, NULL);
|
|
|
|
}
|
|
|
|
return _gst_registry_default;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_add_path:
|
|
|
|
* @registry: the registry to add the path to
|
2004-03-15 15:16:04 +00:00
|
|
|
* @path: the path to add to the registry
|
2002-05-08 20:40:48 +00:00
|
|
|
*
|
2002-05-11 20:30:05 +00:00
|
|
|
* Add the given path to the registry. The syntax of the
|
|
|
|
* path is specific to the registry. If the path has already been
|
|
|
|
* added, do nothing.
|
2002-05-08 20:40:48 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_registry_add_path (GstRegistry * registry, const gchar * path)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_REGISTRY (registry));
|
|
|
|
g_return_if_fail (path != NULL);
|
|
|
|
|
2005-12-02 12:34:47 +00:00
|
|
|
if (strlen (path) == 0)
|
|
|
|
goto empty_path;
|
|
|
|
|
|
|
|
GST_OBJECT_LOCK (registry);
|
|
|
|
if (g_list_find_custom (registry->paths, path, (GCompareFunc) strcmp))
|
|
|
|
goto was_added;
|
|
|
|
|
|
|
|
GST_INFO ("Adding plugin path: \"%s\"", path);
|
|
|
|
registry->paths = g_list_append (registry->paths, g_strdup (path));
|
|
|
|
GST_OBJECT_UNLOCK (registry);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
empty_path:
|
|
|
|
{
|
2005-06-29 12:25:05 +00:00
|
|
|
GST_INFO ("Ignoring empty plugin path");
|
|
|
|
return;
|
|
|
|
}
|
2005-12-02 12:34:47 +00:00
|
|
|
was_added:
|
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
g_warning ("path %s already added to registry", path);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2003-04-14 18:53:03 +00:00
|
|
|
return;
|
2002-05-11 20:30:05 +00:00
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_get_path_list:
|
|
|
|
* @registry: the registry to get the pathlist of
|
|
|
|
*
|
|
|
|
* Get the list of paths for the given registry.
|
|
|
|
*
|
|
|
|
* Returns: A Glist of paths as strings. g_list_free after use.
|
2005-12-02 12:34:47 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-05-08 20:40:48 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
|
|
|
gst_registry_get_path_list (GstRegistry * registry)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2005-09-15 23:51:24 +00:00
|
|
|
GList *list;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-09-15 23:51:24 +00:00
|
|
|
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
/* We don't need to copy the strings, because they won't be deleted
|
|
|
|
* as long as the GstRegistry is around */
|
|
|
|
list = g_list_copy (registry->paths);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-09-15 23:51:24 +00:00
|
|
|
return list;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
2005-09-15 23:51:24 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_add_plugin:
|
|
|
|
* @registry: the registry to add the plugin to
|
|
|
|
* @plugin: the plugin to add
|
|
|
|
*
|
2004-03-15 15:16:04 +00:00
|
|
|
* Add the plugin to the registry. The plugin-added signal will be emitted.
|
2005-12-02 12:34:47 +00:00
|
|
|
* This function will sink @plugin.
|
2002-05-08 20:40:48 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
2005-12-02 12:34:47 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-05-08 20:40:48 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
gboolean
|
|
|
|
gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2005-09-15 00:13:26 +00:00
|
|
|
GstPlugin *existing_plugin;
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
|
2005-09-15 00:13:26 +00:00
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
existing_plugin = gst_registry_lookup_locked (registry, plugin->filename);
|
2005-09-15 00:13:26 +00:00
|
|
|
if (existing_plugin) {
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_DEBUG_OBJECT (registry,
|
|
|
|
"Replacing existing plugin %p with new plugin %p for filename \"%s\"",
|
2005-10-11 16:05:16 +00:00
|
|
|
existing_plugin, plugin, GST_STR_NULL (plugin->filename));
|
2005-09-15 00:13:26 +00:00
|
|
|
registry->plugins = g_list_remove (registry->plugins, existing_plugin);
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_unref (existing_plugin);
|
2004-05-10 00:35:59 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "adding plugin %p for filename \"%s\"",
|
2005-10-11 16:05:16 +00:00
|
|
|
plugin, GST_STR_NULL (plugin->filename));
|
2005-09-15 23:51:24 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
registry->plugins = g_list_prepend (registry->plugins, plugin);
|
|
|
|
|
2005-09-15 20:56:30 +00:00
|
|
|
gst_object_ref (plugin);
|
|
|
|
gst_object_sink (plugin);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-15 20:56:30 +00:00
|
|
|
|
2005-10-11 16:05:16 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "emitting plugin-added for filename \"%s\"",
|
|
|
|
GST_STR_NULL (plugin->filename));
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_emit (G_OBJECT (registry), gst_registry_signals[PLUGIN_ADDED], 0,
|
|
|
|
plugin);
|
2002-05-08 20:40:48 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_remove_plugin:
|
|
|
|
* @registry: the registry to remove the plugin from
|
|
|
|
* @plugin: the plugin to remove
|
|
|
|
*
|
|
|
|
* Remove the plugin from the registry.
|
2005-12-02 12:34:47 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2002-05-08 20:40:48 +00:00
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_REGISTRY (registry));
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2002-05-08 20:40:48 +00:00
|
|
|
registry->plugins = g_list_remove (registry->plugins, plugin);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_unref (plugin);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_add_feature:
|
|
|
|
* @registry: the registry to add the plugin to
|
|
|
|
* @feature: the feature to add
|
|
|
|
*
|
|
|
|
* Add the feature to the registry. The feature-added signal will be emitted.
|
2005-12-02 12:34:47 +00:00
|
|
|
* This function sinks @feature.
|
2005-09-18 06:59:25 +00:00
|
|
|
*
|
|
|
|
* Returns: TRUE on success.
|
2005-12-02 12:34:47 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2005-09-18 06:59:25 +00:00
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_registry_add_feature (GstRegistry * registry, GstPluginFeature * feature)
|
|
|
|
{
|
|
|
|
GstPluginFeature *existing_feature;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GST_IS_REGISTRY (registry), FALSE);
|
|
|
|
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
|
|
|
|
g_return_val_if_fail (feature->name != NULL, FALSE);
|
|
|
|
g_return_val_if_fail (feature->plugin_name != NULL, FALSE);
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-18 06:59:25 +00:00
|
|
|
existing_feature = gst_registry_lookup_feature_locked (registry,
|
|
|
|
feature->name);
|
|
|
|
if (existing_feature) {
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "Replacing existing feature %p (%s)",
|
2005-09-18 06:59:25 +00:00
|
|
|
existing_feature, feature->name);
|
|
|
|
registry->features = g_list_remove (registry->features, existing_feature);
|
|
|
|
gst_object_unref (existing_feature);
|
|
|
|
}
|
|
|
|
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "adding feature %p (%s)", feature, feature->name);
|
2005-09-18 06:59:25 +00:00
|
|
|
|
|
|
|
registry->features = g_list_prepend (registry->features, feature);
|
|
|
|
|
|
|
|
gst_object_ref (feature);
|
|
|
|
gst_object_sink (feature);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-18 06:59:25 +00:00
|
|
|
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "emitting feature-added for %s", feature->name);
|
2005-09-18 06:59:25 +00:00
|
|
|
g_signal_emit (G_OBJECT (registry), gst_registry_signals[FEATURE_ADDED], 0,
|
|
|
|
feature);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_remove_feature:
|
|
|
|
* @registry: the registry to remove the feature from
|
|
|
|
* @feature: the feature to remove
|
|
|
|
*
|
|
|
|
* Remove the feature from the registry.
|
2005-12-02 12:34:47 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2005-09-18 06:59:25 +00:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_registry_remove_feature (GstRegistry * registry, GstPluginFeature * feature)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_REGISTRY (registry));
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "removing feature %p (%s)",
|
|
|
|
feature, gst_plugin_feature_get_name (feature));
|
2005-09-18 06:59:25 +00:00
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-18 06:59:25 +00:00
|
|
|
registry->features = g_list_remove (registry->features, feature);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_unref (feature);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 22:10:29 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_plugin_filter:
|
|
|
|
* @registry: registry to query
|
|
|
|
* @filter: the filter to use
|
|
|
|
* @first: only return first match
|
|
|
|
* @user_data: user data passed to the filter function
|
|
|
|
*
|
2005-12-02 12:34:47 +00:00
|
|
|
* Runs a filter against all plugins in the registry and returns a #GList with
|
2004-03-15 15:16:04 +00:00
|
|
|
* the results. If the first flag is set, only the first match is
|
2003-05-06 22:10:29 +00:00
|
|
|
* returned (as a list with a single object).
|
2005-09-19 14:09:54 +00:00
|
|
|
* Every plugin is reffed; use gst_plugin_list_free() after use, which
|
|
|
|
* will unref again.
|
2003-05-06 22:10:29 +00:00
|
|
|
*
|
2005-12-02 12:34:47 +00:00
|
|
|
* Returns: a #GList of #GstPlugin. Use gst_plugin_list_free() after usage.
|
|
|
|
*
|
|
|
|
* MT safe.
|
2003-05-06 22:10:29 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
|
|
|
gst_registry_plugin_filter (GstRegistry * registry,
|
|
|
|
GstPluginFilter filter, gboolean first, gpointer user_data)
|
2003-04-14 18:53:03 +00:00
|
|
|
{
|
2005-09-15 23:51:24 +00:00
|
|
|
GList *list;
|
|
|
|
GList *g;
|
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
list = gst_filter_run (registry->plugins, (GstFilterFunc) filter, first,
|
2004-03-13 15:27:01 +00:00
|
|
|
user_data);
|
2005-09-15 23:51:24 +00:00
|
|
|
for (g = list; g; g = g->next) {
|
|
|
|
gst_object_ref (GST_PLUGIN (g->data));
|
|
|
|
}
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
|
|
|
|
return list;
|
2003-04-14 18:53:03 +00:00
|
|
|
}
|
|
|
|
|
2003-05-06 22:10:29 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_feature_filter:
|
|
|
|
* @registry: registry to query
|
|
|
|
* @filter: the filter to use
|
|
|
|
* @first: only return first match
|
|
|
|
* @user_data: user data passed to the filter function
|
|
|
|
*
|
2004-03-15 15:16:04 +00:00
|
|
|
* Runs a filter against all features of the plugins in the registry
|
|
|
|
* and returns a GList with the results.
|
|
|
|
* If the first flag is set, only the first match is
|
2003-05-06 22:10:29 +00:00
|
|
|
* returned (as a list with a single object).
|
|
|
|
*
|
2005-09-15 23:51:24 +00:00
|
|
|
* Returns: a GList of plugin features, gst_plugin_feature_list_free after use.
|
2005-12-02 12:34:47 +00:00
|
|
|
*
|
|
|
|
* MT safe.
|
2003-05-06 22:10:29 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
|
|
|
gst_registry_feature_filter (GstRegistry * registry,
|
|
|
|
GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
|
2003-04-14 18:53:03 +00:00
|
|
|
{
|
2005-09-15 23:51:24 +00:00
|
|
|
GList *list;
|
2005-09-18 06:59:25 +00:00
|
|
|
GList *g;
|
2005-09-15 23:51:24 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-18 06:59:25 +00:00
|
|
|
list = gst_filter_run (registry->features, (GstFilterFunc) filter, first,
|
2004-03-13 15:27:01 +00:00
|
|
|
user_data);
|
2005-09-18 06:59:25 +00:00
|
|
|
for (g = list; g; g = g->next) {
|
|
|
|
gst_object_ref (GST_PLUGIN_FEATURE (g->data));
|
|
|
|
}
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
|
|
|
|
return list;
|
2003-04-14 18:53:03 +00:00
|
|
|
}
|
|
|
|
|
2002-05-10 19:23:18 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_find_plugin:
|
|
|
|
* @registry: the registry to search
|
|
|
|
* @name: the plugin name to find
|
|
|
|
*
|
|
|
|
* Find the plugin with the given name in the registry.
|
2005-09-19 14:09:54 +00:00
|
|
|
* The plugin will be reffed; caller is responsible for unreffing.
|
2002-05-10 19:23:18 +00:00
|
|
|
*
|
|
|
|
* Returns: The plugin with the given name or NULL if the plugin was not found.
|
2005-12-02 12:34:47 +00:00
|
|
|
* gst_object_unref() after usage.
|
|
|
|
*
|
|
|
|
* MT safe.
|
2002-05-10 19:23:18 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstPlugin *
|
|
|
|
gst_registry_find_plugin (GstRegistry * registry, const gchar * name)
|
2002-05-10 19:23:18 +00:00
|
|
|
{
|
2003-04-14 18:53:03 +00:00
|
|
|
GList *walk;
|
|
|
|
GstPlugin *result = NULL;
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2002-05-10 19:23:18 +00:00
|
|
|
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
walk = gst_registry_plugin_filter (registry,
|
|
|
|
(GstPluginFilter) gst_plugin_name_filter, TRUE, (gpointer) name);
|
2005-09-16 00:02:27 +00:00
|
|
|
if (walk) {
|
2003-04-14 18:53:03 +00:00
|
|
|
result = GST_PLUGIN (walk->data);
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2005-09-16 00:02:27 +00:00
|
|
|
gst_object_ref (result);
|
|
|
|
gst_plugin_list_free (walk);
|
|
|
|
}
|
2003-04-14 18:53:03 +00:00
|
|
|
|
|
|
|
return result;
|
2002-05-10 19:23:18 +00:00
|
|
|
}
|
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_find_feature:
|
|
|
|
* @registry: the registry to search
|
|
|
|
* @name: the pluginfeature name to find
|
|
|
|
* @type: the pluginfeature type to find
|
|
|
|
*
|
|
|
|
* Find the pluginfeature with the given name and type in the registry.
|
|
|
|
*
|
2004-03-15 15:16:04 +00:00
|
|
|
* Returns: The pluginfeature with the given name and type or NULL
|
2005-12-02 12:34:47 +00:00
|
|
|
* if the plugin was not found. gst_object_unref() after usage.
|
|
|
|
*
|
|
|
|
* MT safe.
|
2002-05-08 20:40:48 +00:00
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstPluginFeature *
|
|
|
|
gst_registry_find_feature (GstRegistry * registry, const gchar * name,
|
|
|
|
GType type)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2003-02-10 20:32:32 +00:00
|
|
|
GstPluginFeature *feature = NULL;
|
2003-04-14 18:53:03 +00:00
|
|
|
GList *walk;
|
|
|
|
GstTypeNameData data;
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2002-05-08 20:40:48 +00:00
|
|
|
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
data.name = name;
|
|
|
|
data.type = type;
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
walk = gst_registry_feature_filter (registry,
|
|
|
|
(GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
|
|
|
|
TRUE, &data);
|
2003-04-14 18:53:03 +00:00
|
|
|
|
2005-09-16 00:02:27 +00:00
|
|
|
if (walk) {
|
2003-04-14 18:53:03 +00:00
|
|
|
feature = GST_PLUGIN_FEATURE (walk->data);
|
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_ref (feature);
|
2005-09-16 00:02:27 +00:00
|
|
|
gst_plugin_feature_list_free (walk);
|
|
|
|
}
|
2003-02-10 20:32:32 +00:00
|
|
|
|
|
|
|
return feature;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
2005-12-02 12:34:47 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_get_feature_list:
|
|
|
|
* @registry: a #GstRegistry
|
|
|
|
* @type: a #GType.
|
|
|
|
*
|
|
|
|
* Retrieves a #GList of #GstPluginFeature of @type.
|
|
|
|
*
|
|
|
|
* Returns: a #GList of #GstPluginFeature of @type. gst_plugin_feature_list_free
|
|
|
|
* after usage.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
2005-09-15 00:13:26 +00:00
|
|
|
GList *
|
|
|
|
gst_registry_get_feature_list (GstRegistry * registry, GType type)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2005-09-15 14:21:08 +00:00
|
|
|
GstTypeNameData data;
|
2002-12-19 21:31:03 +00:00
|
|
|
|
2005-09-15 14:21:08 +00:00
|
|
|
data.type = type;
|
|
|
|
data.name = NULL;
|
|
|
|
|
|
|
|
return gst_registry_feature_filter (registry,
|
|
|
|
(GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
|
|
|
|
FALSE, &data);
|
2005-09-15 00:13:26 +00:00
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-11-04 15:02:48 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_get_plugin_list:
|
|
|
|
* @registry: the registry to search
|
|
|
|
*
|
2005-12-02 12:34:47 +00:00
|
|
|
* Get a copy of all plugins registered in the given registry. The refcount
|
|
|
|
* of each element in the list in incremented.
|
2005-11-04 15:02:48 +00:00
|
|
|
*
|
2005-12-02 12:34:47 +00:00
|
|
|
* Returns: a #GList of #GstPlugin. gst_plugin_list_free after use.
|
|
|
|
*
|
|
|
|
* MT safe.
|
2005-11-04 15:02:48 +00:00
|
|
|
*/
|
2005-09-15 00:13:26 +00:00
|
|
|
GList *
|
|
|
|
gst_registry_get_plugin_list (GstRegistry * registry)
|
|
|
|
{
|
2005-09-15 23:51:24 +00:00
|
|
|
GList *list;
|
|
|
|
GList *g;
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
list = g_list_copy (registry->plugins);
|
|
|
|
for (g = list; g; g = g->next) {
|
|
|
|
gst_object_ref (GST_PLUGIN (g->data));
|
|
|
|
}
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
|
|
|
|
return list;
|
2005-09-15 00:13:26 +00:00
|
|
|
}
|
2002-12-19 21:31:03 +00:00
|
|
|
|
2005-09-18 06:59:25 +00:00
|
|
|
static GstPluginFeature *
|
|
|
|
gst_registry_lookup_feature_locked (GstRegistry * registry, const char *name)
|
|
|
|
{
|
|
|
|
GList *g;
|
|
|
|
GstPluginFeature *feature;
|
|
|
|
|
|
|
|
if (name == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (g = registry->features; g; g = g_list_next (g)) {
|
|
|
|
feature = GST_PLUGIN_FEATURE (g->data);
|
|
|
|
if (feature->name && strcmp (name, feature->name) == 0) {
|
|
|
|
return feature;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-12-02 12:34:47 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_lookup_feature:
|
|
|
|
* @registry: a #GstRegistry
|
|
|
|
* @name: a #GstPluginFeature name
|
|
|
|
*
|
|
|
|
* Find a #GstPluginFeature with @name in @registry.
|
|
|
|
*
|
|
|
|
* Returns: a #GstPluginFeature with its refcount incremented, use
|
|
|
|
* gst_object_unref() after usage.
|
|
|
|
*
|
|
|
|
* MT safe.
|
|
|
|
*/
|
2005-09-18 06:59:25 +00:00
|
|
|
GstPluginFeature *
|
|
|
|
gst_registry_lookup_feature (GstRegistry * registry, const char *name)
|
|
|
|
{
|
|
|
|
GstPluginFeature *feature;
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-18 06:59:25 +00:00
|
|
|
feature = gst_registry_lookup_feature_locked (registry, name);
|
|
|
|
if (feature)
|
|
|
|
gst_object_ref (feature);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-18 06:59:25 +00:00
|
|
|
|
|
|
|
return feature;
|
|
|
|
}
|
|
|
|
|
2005-09-15 23:51:24 +00:00
|
|
|
static GstPlugin *
|
|
|
|
gst_registry_lookup_locked (GstRegistry * registry, const char *filename)
|
2005-09-15 00:13:26 +00:00
|
|
|
{
|
|
|
|
GList *g;
|
|
|
|
GstPlugin *plugin;
|
2005-10-08 13:57:17 +00:00
|
|
|
gchar *basename;
|
2005-09-15 00:13:26 +00:00
|
|
|
|
2005-09-15 23:51:24 +00:00
|
|
|
if (filename == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
2005-10-08 13:57:17 +00:00
|
|
|
basename = g_path_get_basename (filename);
|
2005-09-15 00:13:26 +00:00
|
|
|
for (g = registry->plugins; g; g = g_list_next (g)) {
|
|
|
|
plugin = GST_PLUGIN (g->data);
|
2005-10-08 13:57:17 +00:00
|
|
|
if (plugin->basename && strcmp (basename, plugin->basename) == 0) {
|
|
|
|
g_free (basename);
|
2005-09-15 00:13:26 +00:00
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-10-08 13:57:17 +00:00
|
|
|
g_free (basename);
|
2005-09-15 00:13:26 +00:00
|
|
|
return NULL;
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
2005-09-19 14:09:54 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_lookup:
|
|
|
|
* @registry: the registry to look up in
|
|
|
|
* @filename: the name of the file to look up
|
|
|
|
*
|
|
|
|
* Look up a plugin in the given registry with the given filename.
|
2005-12-02 12:34:47 +00:00
|
|
|
* If found, plugin is reffed.
|
2005-09-19 14:09:54 +00:00
|
|
|
*
|
2005-12-02 12:34:47 +00:00
|
|
|
* Returns: the #GstPlugin if found, or NULL if not. gst_object_unref()
|
|
|
|
* after usage.
|
2005-09-19 14:09:54 +00:00
|
|
|
*/
|
2005-09-15 23:51:24 +00:00
|
|
|
GstPlugin *
|
|
|
|
gst_registry_lookup (GstRegistry * registry, const char *filename)
|
|
|
|
{
|
|
|
|
GstPlugin *plugin;
|
|
|
|
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_LOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
plugin = gst_registry_lookup_locked (registry, filename);
|
2005-09-18 06:59:25 +00:00
|
|
|
if (plugin)
|
|
|
|
gst_object_ref (plugin);
|
2005-11-21 16:34:26 +00:00
|
|
|
GST_OBJECT_UNLOCK (registry);
|
2005-09-15 23:51:24 +00:00
|
|
|
|
|
|
|
return plugin;
|
|
|
|
}
|
|
|
|
|
2005-09-15 00:13:26 +00:00
|
|
|
static void
|
|
|
|
gst_registry_scan_path_level (GstRegistry * registry, const gchar * path,
|
|
|
|
int level)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2005-09-15 00:13:26 +00:00
|
|
|
GDir *dir;
|
|
|
|
const gchar *dirent;
|
|
|
|
gchar *filename;
|
|
|
|
GstPlugin *plugin;
|
2005-09-18 06:59:25 +00:00
|
|
|
GstPlugin *newplugin;
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-09-15 00:13:26 +00:00
|
|
|
dir = g_dir_open (path, 0, NULL);
|
|
|
|
if (!dir)
|
|
|
|
return;
|
2002-12-19 21:31:03 +00:00
|
|
|
|
2005-09-15 00:13:26 +00:00
|
|
|
while ((dirent = g_dir_read_name (dir))) {
|
|
|
|
filename = g_strjoin ("/", path, dirent, NULL);
|
|
|
|
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_LOG_OBJECT (registry, "examining file: %s", filename);
|
2005-09-15 00:13:26 +00:00
|
|
|
|
|
|
|
if (g_file_test (filename, G_FILE_TEST_IS_DIR)) {
|
|
|
|
if (level > 0) {
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_LOG_OBJECT (registry, "found directory, recursing");
|
2005-09-15 00:13:26 +00:00
|
|
|
gst_registry_scan_path_level (registry, filename, level - 1);
|
|
|
|
} else {
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_LOG_OBJECT (registry,
|
|
|
|
"found directory, but recursion level is too deep");
|
2005-09-15 00:13:26 +00:00
|
|
|
}
|
|
|
|
g_free (filename);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_LOG_OBJECT (registry, "not a regular file, ignoring");
|
2005-09-15 00:13:26 +00:00
|
|
|
g_free (filename);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!g_str_has_suffix (filename, ".so") &&
|
|
|
|
!g_str_has_suffix (filename, ".dll") &&
|
|
|
|
!g_str_has_suffix (filename, ".dynlib")) {
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_LOG_OBJECT (registry,
|
|
|
|
"extension is not recognized as module file, ignoring");
|
2005-09-15 00:13:26 +00:00
|
|
|
g_free (filename);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2005-10-08 13:57:17 +00:00
|
|
|
/* plug-ins are considered unique by basename; if the given name
|
|
|
|
* was already seen by the registry, we ignore it */
|
2005-09-15 00:13:26 +00:00
|
|
|
plugin = gst_registry_lookup (registry, filename);
|
|
|
|
if (plugin) {
|
|
|
|
struct stat file_status;
|
|
|
|
|
|
|
|
if (stat (filename, &file_status)) {
|
|
|
|
/* FIXME remove from cache */
|
|
|
|
g_free (filename);
|
|
|
|
continue;
|
|
|
|
}
|
2005-10-08 13:57:17 +00:00
|
|
|
if (plugin->registered) {
|
2005-10-11 16:05:16 +00:00
|
|
|
GST_DEBUG_OBJECT (registry,
|
|
|
|
"plugin already registered from path \"%s\"",
|
|
|
|
GST_STR_NULL (plugin->filename));
|
2005-10-08 14:41:56 +00:00
|
|
|
g_free (filename);
|
2005-10-18 07:13:25 +00:00
|
|
|
gst_object_unref (plugin);
|
2005-10-08 13:57:17 +00:00
|
|
|
continue;
|
|
|
|
}
|
2005-09-15 00:13:26 +00:00
|
|
|
if (plugin->file_mtime == file_status.st_mtime &&
|
|
|
|
plugin->file_size == file_status.st_size) {
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "file %s cached", filename);
|
2005-09-15 00:13:26 +00:00
|
|
|
plugin->flags &= ~GST_PLUGIN_FLAG_CACHED;
|
2005-11-02 15:34:23 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "marking plugin %p as registered", plugin);
|
|
|
|
plugin->registered = TRUE;
|
2005-09-15 00:13:26 +00:00
|
|
|
} else {
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_INFO_OBJECT (registry, "cached info for %s is stale", filename);
|
|
|
|
GST_DEBUG_OBJECT (registry, "mtime %ld != %ld or size %"
|
|
|
|
G_GSIZE_FORMAT " != %"
|
2005-09-15 00:13:26 +00:00
|
|
|
G_GSIZE_FORMAT, plugin->file_mtime, file_status.st_mtime,
|
|
|
|
plugin->file_size, file_status.st_size);
|
|
|
|
gst_registry_remove_plugin (gst_registry_get_default (), plugin);
|
2005-09-18 06:59:25 +00:00
|
|
|
newplugin = gst_plugin_load_file (filename, NULL);
|
2005-11-02 15:34:23 +00:00
|
|
|
if (newplugin) {
|
|
|
|
GST_DEBUG_OBJECT (registry, "marking new plugin %p as registered",
|
|
|
|
newplugin);
|
|
|
|
newplugin->registered = TRUE;
|
2005-09-18 09:15:10 +00:00
|
|
|
gst_object_unref (newplugin);
|
2005-11-02 15:34:23 +00:00
|
|
|
}
|
2005-09-15 00:13:26 +00:00
|
|
|
}
|
2005-09-18 06:59:25 +00:00
|
|
|
gst_object_unref (plugin);
|
2005-09-15 00:13:26 +00:00
|
|
|
|
|
|
|
} else {
|
2005-10-08 13:57:17 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "file %s not yet in registry", filename);
|
2005-09-18 06:59:25 +00:00
|
|
|
newplugin = gst_plugin_load_file (filename, NULL);
|
2005-10-08 13:57:17 +00:00
|
|
|
if (newplugin) {
|
|
|
|
newplugin->registered = TRUE;
|
2005-09-18 09:15:10 +00:00
|
|
|
gst_object_unref (newplugin);
|
2005-10-08 13:57:17 +00:00
|
|
|
}
|
2005-09-15 00:13:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
g_free (filename);
|
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-09-15 00:13:26 +00:00
|
|
|
g_dir_close (dir);
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2005-09-15 00:13:26 +00:00
|
|
|
* gst_registry_scan_path:
|
|
|
|
* @registry: the registry to add the path to
|
|
|
|
* @path: the path to add to the registry
|
2002-05-08 20:40:48 +00:00
|
|
|
*
|
2005-09-15 00:13:26 +00:00
|
|
|
* Add the given path to the registry. The syntax of the
|
|
|
|
* path is specific to the registry. If the path has already been
|
|
|
|
* added, do nothing.
|
2002-05-08 20:40:48 +00:00
|
|
|
*/
|
2005-09-15 00:13:26 +00:00
|
|
|
void
|
|
|
|
gst_registry_scan_path (GstRegistry * registry, const gchar * path)
|
2002-05-08 20:40:48 +00:00
|
|
|
{
|
2005-10-08 06:49:09 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "scanning path %s", path);
|
2005-09-15 00:13:26 +00:00
|
|
|
gst_registry_scan_path_level (registry, path, 10);
|
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
|
2005-09-15 00:13:26 +00:00
|
|
|
void
|
|
|
|
_gst_registry_remove_cache_plugins (GstRegistry * registry)
|
|
|
|
{
|
|
|
|
GList *g;
|
|
|
|
GList *g_next;
|
|
|
|
GstPlugin *plugin;
|
|
|
|
|
2005-09-19 14:09:54 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "removing cached plugins");
|
2005-09-15 00:13:26 +00:00
|
|
|
g = registry->plugins;
|
|
|
|
while (g) {
|
|
|
|
g_next = g->next;
|
|
|
|
plugin = g->data;
|
|
|
|
if (plugin->flags & GST_PLUGIN_FLAG_CACHED) {
|
2005-10-11 16:05:16 +00:00
|
|
|
GST_DEBUG_OBJECT (registry, "removing cached plugin \"%s\"",
|
|
|
|
GST_STR_NULL (plugin->filename));
|
2005-09-15 00:13:26 +00:00
|
|
|
registry->plugins = g_list_remove (registry->plugins, plugin);
|
2005-09-19 14:09:54 +00:00
|
|
|
gst_object_unref (plugin);
|
2005-09-15 00:13:26 +00:00
|
|
|
}
|
|
|
|
g = g_next;
|
|
|
|
}
|
2002-05-08 20:40:48 +00:00
|
|
|
}
|
2005-09-18 06:59:25 +00:00
|
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
_gst_plugin_feature_filter_plugin_name (GstPluginFeature * feature,
|
|
|
|
gpointer user_data)
|
|
|
|
{
|
|
|
|
return (strcmp (feature->plugin_name, (gchar *) user_data) == 0);
|
|
|
|
}
|
|
|
|
|
2005-12-02 12:34:47 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_get_feature_list_by_plugin:
|
|
|
|
* @registry: a #GstRegistry.
|
|
|
|
* @name: a plugin name.
|
|
|
|
*
|
|
|
|
* Retrieves a #GList of features of the plugin with name @name.
|
|
|
|
*
|
|
|
|
* Returns: a #GList of #GstPluginFeature. gst_plugin_feature_list_free() after usage.
|
|
|
|
*/
|
2005-09-18 06:59:25 +00:00
|
|
|
GList *
|
|
|
|
gst_registry_get_feature_list_by_plugin (GstRegistry * registry,
|
|
|
|
const gchar * name)
|
|
|
|
{
|
|
|
|
return gst_registry_feature_filter (registry,
|
|
|
|
_gst_plugin_feature_filter_plugin_name, FALSE, (gpointer) name);
|
|
|
|
}
|
2005-09-18 21:24:55 +00:00
|
|
|
|
|
|
|
void
|
2005-09-20 06:28:33 +00:00
|
|
|
_gst_registry_cleanup ()
|
2005-09-18 21:24:55 +00:00
|
|
|
{
|
|
|
|
if (!_gst_registry_default)
|
|
|
|
return;
|
|
|
|
|
|
|
|
gst_object_unref (_gst_registry_default);
|
|
|
|
_gst_registry_default = NULL;
|
|
|
|
}
|
2005-10-14 11:09:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_default_registry_check_feature_version:
|
|
|
|
* @feature_name: the name of the feature (e.g. "oggdemux")
|
|
|
|
* @min_major: the minimum major version number
|
|
|
|
* @min_minor: the minimum minor version number
|
|
|
|
* @min_micro: the minimum micro version number
|
|
|
|
*
|
|
|
|
* Checks whether a plugin feature by the given name exists in the
|
|
|
|
* default registry and whether its version is at least the
|
|
|
|
* version required.
|
|
|
|
*
|
|
|
|
* Returns: #TRUE if the feature could be found and the version is
|
|
|
|
* the same as the required version or newer, and #FALSE otherwise.
|
|
|
|
*/
|
|
|
|
gboolean
|
|
|
|
gst_default_registry_check_feature_version (const gchar * feature_name,
|
|
|
|
guint min_major, guint min_minor, guint min_micro)
|
|
|
|
{
|
|
|
|
GstPluginFeature *feature;
|
|
|
|
GstRegistry *registry;
|
|
|
|
gboolean ret = FALSE;
|
|
|
|
|
|
|
|
g_return_val_if_fail (feature_name != NULL, FALSE);
|
|
|
|
|
|
|
|
GST_DEBUG ("Looking up plugin feature '%s'", feature_name);
|
|
|
|
|
|
|
|
registry = gst_registry_get_default ();
|
|
|
|
feature = gst_registry_lookup_feature (registry, feature_name);
|
|
|
|
if (feature) {
|
|
|
|
ret = gst_plugin_feature_check_version (feature, min_major, min_minor,
|
|
|
|
min_micro);
|
|
|
|
gst_object_unref (feature);
|
|
|
|
} else {
|
|
|
|
GST_DEBUG ("Could not find plugin feature '%s'", feature_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|