2003-02-10 20:32:32 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstregistry.c: handle registry
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gst_private.h"
|
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
#include "gstinfo.h"
|
|
|
|
#include "gstregistrypool.h"
|
2003-04-14 18:53:03 +00:00
|
|
|
#include "gstfilter.h"
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2003-05-06 22:10:29 +00:00
|
|
|
/* list of registries in the pool */
|
2003-02-10 20:32:32 +00:00
|
|
|
static GList *_gst_registry_pool = NULL;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-05-06 22:10:29 +00:00
|
|
|
/* list of plugins without a registry, like statically linked
|
|
|
|
* plugins */
|
2003-02-10 20:32:32 +00:00
|
|
|
static GList *_gst_registry_pool_plugins = NULL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_list:
|
|
|
|
*
|
|
|
|
* Get a list of all registries in the pool
|
|
|
|
*
|
|
|
|
* Returns: a Glist of GstRegistries, g_list_free after use.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
2003-02-10 20:32:32 +00:00
|
|
|
gst_registry_pool_list (void)
|
|
|
|
{
|
|
|
|
return g_list_copy (_gst_registry_pool);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
static gint
|
|
|
|
gst_registry_compare_func (gconstpointer a, gconstpointer b)
|
|
|
|
{
|
|
|
|
return GST_REGISTRY (a)->priority - GST_REGISTRY (b)->priority;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_add:
|
|
|
|
* @registry: the registry to add
|
|
|
|
* @priority: the priority of the registry
|
|
|
|
*
|
|
|
|
* Add the registry to the pool with the given priority.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_registry_pool_add (GstRegistry * registry, guint priority)
|
2003-02-10 20:32:32 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_REGISTRY (registry));
|
|
|
|
|
|
|
|
registry->priority = priority;
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
_gst_registry_pool =
|
|
|
|
g_list_insert_sorted (_gst_registry_pool, registry,
|
|
|
|
gst_registry_compare_func);
|
2003-02-10 20:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_remove:
|
|
|
|
* @registry: the registry to remove
|
|
|
|
*
|
|
|
|
* Remove the registry from the pool.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_registry_pool_remove (GstRegistry * registry)
|
2003-02-10 20:32:32 +00:00
|
|
|
{
|
|
|
|
g_return_if_fail (GST_IS_REGISTRY (registry));
|
|
|
|
|
|
|
|
_gst_registry_pool = g_list_remove (_gst_registry_pool, registry);
|
|
|
|
}
|
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_add_plugin:
|
|
|
|
* @plugin: the plugin to add
|
|
|
|
*
|
|
|
|
* Add the plugin to the global pool of plugins.
|
|
|
|
*/
|
|
|
|
void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_registry_pool_add_plugin (GstPlugin * plugin)
|
2003-02-10 20:32:32 +00:00
|
|
|
{
|
2004-03-13 15:27:01 +00:00
|
|
|
_gst_registry_pool_plugins =
|
|
|
|
g_list_prepend (_gst_registry_pool_plugins, plugin);
|
2003-02-10 20:32:32 +00:00
|
|
|
}
|
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
_registry_load_func (GstRegistry * registry, gpointer user_data)
|
2003-04-14 18:53:03 +00:00
|
|
|
{
|
2003-08-02 01:53:08 +00:00
|
|
|
if (!(registry->flags & GST_REGISTRY_DELAYED_LOADING)) {
|
2003-04-14 18:53:03 +00:00
|
|
|
gst_registry_load (registry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
2003-02-10 20:32:32 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_load_all:
|
|
|
|
*
|
|
|
|
* Load all the registries in the pool. Registries with the
|
|
|
|
* GST_REGISTRY_DELAYED_LOADING will not be loaded.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
gst_registry_pool_load_all (void)
|
|
|
|
{
|
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2003-04-14 18:53:03 +00:00
|
|
|
g_list_foreach (_gst_registry_pool, (GFunc) _registry_load_func, NULL);
|
2003-02-10 20:32:32 +00:00
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_plugin_list:
|
|
|
|
*
|
|
|
|
* Get a list of all plugins in the pool.
|
|
|
|
*
|
|
|
|
* Returns: a GList of plugins, g_list_free after use.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
2003-02-10 20:32:32 +00:00
|
|
|
gst_registry_pool_plugin_list (void)
|
2003-04-14 18:53:03 +00:00
|
|
|
{
|
|
|
|
return gst_registry_pool_plugin_filter (NULL, FALSE, NULL);
|
|
|
|
}
|
|
|
|
|
2003-05-06 22:10:29 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_pool_plugin_filter:
|
|
|
|
* @filter: the filter to use
|
|
|
|
* @first: only return first match
|
|
|
|
* @user_data: user data passed to the filter function
|
|
|
|
*
|
|
|
|
* Runs a filter against all plugins in all registries and returns a GList with
|
|
|
|
* the results. If the first flag is set, only the first match is
|
|
|
|
* returned (as a list with a single object).
|
|
|
|
*
|
|
|
|
* Returns: a GList of plugins, g_list_free after use.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
|
|
|
gst_registry_pool_plugin_filter (GstPluginFilter filter, gboolean first,
|
|
|
|
gpointer user_data)
|
2003-02-10 20:32:32 +00:00
|
|
|
{
|
|
|
|
GList *result = NULL;
|
2004-02-12 16:49:16 +00:00
|
|
|
GList *temp;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2004-02-12 16:49:16 +00:00
|
|
|
GList *walk;
|
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
walk = _gst_registry_pool;
|
2003-02-10 20:32:32 +00:00
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstRegistry *registry = GST_REGISTRY (walk->data);
|
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
temp = gst_registry_plugin_filter (registry, filter, first, user_data);
|
|
|
|
if (temp && first)
|
|
|
|
return temp;
|
|
|
|
|
|
|
|
result = g_list_concat (result, temp);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
temp =
|
|
|
|
gst_filter_run (_gst_registry_pool_plugins, (GstFilterFunc) filter, first,
|
|
|
|
user_data);
|
2003-04-12 15:14:55 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
result = g_list_concat (result, temp);
|
|
|
|
|
|
|
|
return result;
|
2003-04-12 15:14:55 +00:00
|
|
|
}
|
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
/**
|
|
|
|
* gst_registry_pool_feature_list:
|
|
|
|
* @type: the type of the features to list.
|
|
|
|
*
|
|
|
|
* Get a list of all pluginfeatures of the given type in the pool.
|
|
|
|
*
|
|
|
|
* Returns: a GList of pluginfeatures, g_list_free after use.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
2003-02-10 20:32:32 +00:00
|
|
|
gst_registry_pool_feature_list (GType type)
|
2003-04-12 15:14:55 +00:00
|
|
|
{
|
2003-04-14 18:53:03 +00:00
|
|
|
GstTypeNameData data;
|
|
|
|
|
|
|
|
data.name = NULL;
|
|
|
|
data.type = type;
|
|
|
|
|
2003-04-12 15:14:55 +00:00
|
|
|
return gst_registry_pool_feature_filter (
|
2004-03-13 15:27:01 +00:00
|
|
|
(GstPluginFeatureFilter) gst_plugin_feature_type_name_filter,
|
|
|
|
FALSE, &data);
|
2003-04-12 15:14:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_feature_filter:
|
|
|
|
* @filter: the filter to apply to the feature list
|
2003-04-14 18:53:03 +00:00
|
|
|
* @first: return the first matching feature
|
2003-04-12 15:14:55 +00:00
|
|
|
* @user_data: data passed to the filter function
|
|
|
|
*
|
|
|
|
* Apply the filter function to all features and return a list
|
2003-04-14 18:53:03 +00:00
|
|
|
* of those features that satisfy the filter. If the first flag
|
|
|
|
* is TRUE, only the first match is returned in a GList with
|
|
|
|
* one element.
|
2003-04-12 15:14:55 +00:00
|
|
|
*
|
|
|
|
* Returns: a GList of pluginfeatures, g_list_free after use.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GList *
|
|
|
|
gst_registry_pool_feature_filter (GstPluginFeatureFilter filter, gboolean first,
|
|
|
|
gpointer user_data)
|
2003-02-10 20:32:32 +00:00
|
|
|
{
|
|
|
|
GList *result = NULL;
|
2004-02-12 16:49:16 +00:00
|
|
|
GList *temp;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
2004-02-12 16:49:16 +00:00
|
|
|
GList *walk;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
walk = _gst_registry_pool;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstRegistry *registry = GST_REGISTRY (walk->data);
|
|
|
|
|
|
|
|
temp = gst_registry_feature_filter (registry, filter, first, user_data);
|
|
|
|
if (temp && first)
|
|
|
|
return temp;
|
|
|
|
|
|
|
|
result = g_list_concat (result, temp);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
walk = g_list_next (walk);
|
2003-02-10 20:32:32 +00:00
|
|
|
}
|
2003-04-14 18:53:03 +00:00
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
temp =
|
|
|
|
gst_plugin_list_feature_filter (_gst_registry_pool_plugins, filter, first,
|
|
|
|
user_data);
|
2003-04-14 18:53:03 +00:00
|
|
|
|
|
|
|
result = g_list_concat (result, temp);
|
2003-04-12 15:14:55 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_find_plugin:
|
|
|
|
* @name: the name of the plugin to find
|
|
|
|
*
|
|
|
|
* Get the named plugin from the registry pool
|
|
|
|
*
|
|
|
|
* Returns: The plugin with the given name or NULL if the plugin
|
|
|
|
* was not found.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstPlugin *
|
|
|
|
gst_registry_pool_find_plugin (const gchar * name)
|
2003-02-10 20:32:32 +00:00
|
|
|
{
|
|
|
|
GstPlugin *result = NULL;
|
|
|
|
GList *walk;
|
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
walk =
|
|
|
|
gst_registry_pool_plugin_filter ((GstPluginFilter) gst_plugin_name_filter,
|
|
|
|
TRUE, (gpointer) name);
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
if (walk)
|
|
|
|
result = GST_PLUGIN (walk->data);
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
g_list_free (walk);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
return result;
|
2003-02-10 20:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_find_feature:
|
|
|
|
* @name: the name of the pluginfeature to find
|
|
|
|
* @type: the type of the pluginfeature to find
|
|
|
|
*
|
|
|
|
* Get the pluginfeature with the given name and type from the pool of
|
|
|
|
* registries.
|
|
|
|
*
|
|
|
|
* Returns: A pluginfeature with the given name and type or NULL if the feature
|
|
|
|
* was not found.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstPluginFeature *
|
|
|
|
gst_registry_pool_find_feature (const gchar * name, GType type)
|
2003-02-10 20:32:32 +00:00
|
|
|
{
|
|
|
|
GstPluginFeature *result = NULL;
|
|
|
|
GList *walk;
|
2003-04-14 18:53:03 +00:00
|
|
|
GstTypeNameData data;
|
2003-02-10 20:32:32 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
2003-04-12 15:14:55 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
data.type = type;
|
|
|
|
data.name = name;
|
2003-04-12 15:14:55 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
walk = gst_registry_pool_feature_filter ((GstPluginFeatureFilter)
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_plugin_feature_type_name_filter, TRUE, &data);
|
|
|
|
|
|
|
|
if (walk)
|
2003-04-14 18:53:03 +00:00
|
|
|
result = GST_PLUGIN_FEATURE (walk->data);
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
g_list_free (walk);
|
2003-02-10 20:32:32 +00:00
|
|
|
|
2003-04-14 18:53:03 +00:00
|
|
|
return result;
|
2003-02-10 20:32:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_registry_pool_get_prefered:
|
|
|
|
* @flags: The flags for the prefered registry
|
|
|
|
*
|
|
|
|
* Get the prefered registry with the given flags
|
|
|
|
*
|
|
|
|
* Returns: The registry with the flags.
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
GstRegistry *
|
2003-02-10 20:32:32 +00:00
|
|
|
gst_registry_pool_get_prefered (GstRegistryFlags flags)
|
|
|
|
{
|
|
|
|
#ifndef GST_DISABLE_REGISTRY
|
|
|
|
GList *walk = _gst_registry_pool;
|
|
|
|
|
|
|
|
while (walk) {
|
|
|
|
GstRegistry *registry = GST_REGISTRY (walk->data);
|
|
|
|
|
|
|
|
if (registry->flags & flags)
|
|
|
|
return registry;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-02-10 20:32:32 +00:00
|
|
|
walk = g_list_next (walk);
|
|
|
|
}
|
|
|
|
#endif /* GST_DISABLE_REGISTRY */
|
|
|
|
return NULL;
|
|
|
|
}
|