check/Makefile.am: Fix environment variables.

Original commit message from CVS:
* check/Makefile.am: Fix environment variables.
* check/gst/gstplugin.c: Fix for API changes.
* tools/gst-inspect.c: Fix for API changes.
* tools/gst-xmlinspect.c: Fix for API changes.
* gst/gstelementfactory.c:
* gst/gstplugin.c:
* gst/gstplugin.h:
* gst/gstpluginfeature.c:
* gst/gstpluginfeature.h:
* gst/gstregistry.c:
* gst/gstregistry.h:
* gst/gstregistryxml.c:
* gst/gsttypefind.c:
* gst/gsttypefindfactory.c:
* gst/indexers/gstfileindex.c:
* gst/indexers/gstmemindex.c:
* gst/schedulers/Makefile.am:
Change registry to keep track of both plugins and features,
removing the feature tracking from plugins themselves.
This commit is contained in:
David Schleef 2005-09-18 06:59:25 +00:00
parent 6874412779
commit cb798ac570
23 changed files with 426 additions and 242 deletions

View file

@ -1,3 +1,25 @@
2005-09-17 David Schleef <ds@schleef.org>
* check/Makefile.am: Fix environment variables.
* check/gst/gstplugin.c: Fix for API changes.
* tools/gst-inspect.c: Fix for API changes.
* tools/gst-xmlinspect.c: Fix for API changes.
* gst/gstelementfactory.c:
* gst/gstplugin.c:
* gst/gstplugin.h:
* gst/gstpluginfeature.c:
* gst/gstpluginfeature.h:
* gst/gstregistry.c:
* gst/gstregistry.h:
* gst/gstregistryxml.c:
* gst/gsttypefind.c:
* gst/gsttypefindfactory.c:
* gst/indexers/gstfileindex.c:
* gst/indexers/gstmemindex.c:
* gst/schedulers/Makefile.am:
Change registry to keep track of both plugins and features,
removing the feature tracking from plugins themselves.
2005-09-16 Thomas Vander Stichele <thomas at apestaart dot org> 2005-09-16 Thomas Vander Stichele <thomas at apestaart dot org>
* check/Makefile.am: * check/Makefile.am:

View file

@ -10,7 +10,7 @@ REGISTRY_ENVIRONMENT = \
TESTS_ENVIRONMENT = \ TESTS_ENVIRONMENT = \
$(REGISTRY_ENVIRONMENT) \ $(REGISTRY_ENVIRONMENT) \
GST_PLUGIN_SYSTEM_PATH= \ GST_PLUGIN_SYSTEM_PATH= \
GST_PLUGIN_PATH=$(top_builddir)/gst/elements/.libs:$(top_builddir)/gst/indexers/.libs GST_PLUGIN_PATH=$(top_builddir)/gst/elements:$(top_builddir)/gst/indexers
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@ plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@

View file

@ -59,6 +59,32 @@ GST_START_TEST (test_register_static)
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_registry)
{
GList *g;
GstRegistry *registry;
registry = gst_registry_get_default ();
for (g = registry->plugins; g; g = g->next) {
GstPlugin *plugin = GST_PLUGIN (g->data);
fail_if (GST_OBJECT (plugin)->refcount != 1,
"Plugin in registry should have refcount of 1");
GST_DEBUG ("refcount %d %s", GST_OBJECT (plugin)->refcount,
plugin->desc.name);
}
for (g = registry->features; g; g = g->next) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
fail_if (GST_OBJECT (feature)->refcount != 1,
"Feature in registry should have refcount of 1");
GST_DEBUG ("refcount %d %s", GST_OBJECT (feature)->refcount, feature->name);
}
}
GST_END_TEST;
GST_START_TEST (test_load_gstelements) GST_START_TEST (test_load_gstelements)
{ {
GstPlugin *unloaded_plugin; GstPlugin *unloaded_plugin;
@ -66,17 +92,22 @@ GST_START_TEST (test_load_gstelements)
unloaded_plugin = gst_default_registry_find_plugin ("gstelements"); unloaded_plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (unloaded_plugin == NULL, "Failed to find gstelements plugin"); fail_if (unloaded_plugin == NULL, "Failed to find gstelements plugin");
fail_if (unloaded_plugin->object.refcount != 2, fail_if (GST_OBJECT (unloaded_plugin)->refcount != 2,
"Refcount of unloaded plugin in registry initially should be 2"); "Refcount of unloaded plugin in registry initially should be 2");
GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount);
gst_object_ref (unloaded_plugin); gst_object_ref (unloaded_plugin);
loaded_plugin = gst_plugin_load (unloaded_plugin); loaded_plugin = gst_plugin_load (unloaded_plugin);
fail_if (loaded_plugin == NULL, "Failed to load plugin"); fail_if (loaded_plugin == NULL, "Failed to load plugin");
fail_if (loaded_plugin->object.refcount != 2, if (loaded_plugin != unloaded_plugin) {
fail_if (GST_OBJECT (loaded_plugin)->refcount != 2,
"Refcount of loaded plugin in registry should be 2"); "Refcount of loaded plugin in registry should be 2");
fail_if (unloaded_plugin->object.refcount != 1, GST_DEBUG ("refcount %d", GST_OBJECT (loaded_plugin)->refcount);
"Refcount of replaced plugin in registry should be 1"); fail_if (GST_OBJECT (unloaded_plugin)->refcount != 1,
"Refcount of replaced plugin should be 1");
GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount);
}
gst_object_unref (unloaded_plugin); gst_object_unref (unloaded_plugin);
gst_object_unref (loaded_plugin); gst_object_unref (loaded_plugin);
@ -90,7 +121,7 @@ GST_START_TEST (test_registry_get_plugin_list)
GstPlugin *plugin; GstPlugin *plugin;
plugin = gst_default_registry_find_plugin ("gstelements"); plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (plugin->object.refcount != 2, fail_if (GST_OBJECT (plugin)->refcount != 2,
"Refcount of plugin in registry should be 2"); "Refcount of plugin in registry should be 2");
list = gst_registry_get_plugin_list (gst_registry_get_default ()); list = gst_registry_get_plugin_list (gst_registry_get_default ());
@ -100,7 +131,7 @@ GST_START_TEST (test_registry_get_plugin_list)
gst_plugin_list_free (list); gst_plugin_list_free (list);
fail_if (plugin->object.refcount != 2, fail_if (GST_OBJECT (plugin)->refcount != 2,
"Refcount of plugin in after list free should be 2"); "Refcount of plugin in after list free should be 2");
gst_object_unref (plugin); gst_object_unref (plugin);
@ -110,55 +141,34 @@ GST_END_TEST;
GST_START_TEST (test_find_feature) GST_START_TEST (test_find_feature)
{ {
GstPlugin *plugin;
GstPluginFeature *feature; GstPluginFeature *feature;
plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (plugin->object.refcount != 2,
"Refcount of plugin in registry should be 2");
feature = gst_registry_find_feature (gst_registry_get_default (), feature = gst_registry_find_feature (gst_registry_get_default (),
"identity", GST_TYPE_ELEMENT_FACTORY); "identity", GST_TYPE_ELEMENT_FACTORY);
fail_if (feature == NULL, "Failed to find identity element factory"); fail_if (feature == NULL, "Failed to find identity element factory");
fail_if (feature->plugin != plugin, fail_if (strcmp (feature->plugin_name, "gstelements"),
"Expected identity to be from gstelements plugin"); "Expected identity to be from gstelements plugin");
fail_if (plugin->object.refcount != 3, fail_if (GST_OBJECT (feature)->refcount != 2,
"Refcount of plugin in registry+feature should be 3"); "Refcount of feature should be 2");
GST_DEBUG ("refcount %d", GST_OBJECT (feature)->refcount);
gst_object_unref (feature->plugin); gst_object_unref (feature);
fail_if (plugin->object.refcount != 2,
"Refcount of plugin in after list free should be 2");
gst_object_unref (plugin);
} }
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_find_element) GST_START_TEST (test_find_element)
{ {
GstPlugin *plugin;
GstElementFactory *element_factory; GstElementFactory *element_factory;
plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (plugin->object.refcount != 2,
"Refcount of plugin in registry should be 2");
element_factory = gst_element_factory_find ("identity"); element_factory = gst_element_factory_find ("identity");
fail_if (element_factory == NULL, "Failed to find identity element factory"); fail_if (element_factory == NULL, "Failed to find identity element factory");
fail_if (GST_PLUGIN_FEATURE (element_factory)->plugin != plugin,
"Expected identity to be from gstelements plugin");
fail_if (plugin->object.refcount != 3, fail_if (GST_OBJECT (element_factory)->refcount != 2,
"Refcount of plugin in registry+feature should be 3"); "Refcount of plugin in registry+feature should be 2");
gst_object_unref (GST_PLUGIN_FEATURE (element_factory)->plugin); gst_object_unref (element_factory);
fail_if (plugin->object.refcount != 2,
"Refcount of plugin in after list free should be 2");
gst_object_unref (plugin);
} }
GST_END_TEST; GST_END_TEST;
@ -228,6 +238,7 @@ gst_plugin_suite (void)
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_register_static); tcase_add_test (tc_chain, test_register_static);
tcase_add_test (tc_chain, test_registry);
tcase_add_test (tc_chain, test_load_gstelements); tcase_add_test (tc_chain, test_load_gstelements);
tcase_add_test (tc_chain, test_registry_get_plugin_list); tcase_add_test (tc_chain, test_registry_get_plugin_list);
tcase_add_test (tc_chain, test_find_feature); tcase_add_test (tc_chain, test_find_feature);

2
common

@ -1 +1 @@
Subproject commit 39250a956e1dfc010fe9f9d93ca1e2c3a343cdca Subproject commit 3f8b422d851dc64797cdd97dd7a2014acd751386

View file

@ -263,7 +263,6 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name); gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name);
GST_LOG_OBJECT (factory, "Created new elementfactory for type %s", GST_LOG_OBJECT (factory, "Created new elementfactory for type %s",
g_type_name (type)); g_type_name (type));
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); klass = GST_ELEMENT_CLASS (g_type_class_ref (type));
factory->type = type; factory->type = type;
@ -304,7 +303,12 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
} }
g_free (interfaces); g_free (interfaces);
GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
gst_registry_add_feature (gst_registry_get_default (),
GST_PLUGIN_FEATURE (factory));
return TRUE; return TRUE;
@ -332,6 +336,7 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name)
g_return_val_if_fail (factory != NULL, NULL); g_return_val_if_fail (factory != NULL, NULL);
gst_object_ref (factory);
factory = factory =
GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
(factory))); (factory)));
@ -367,6 +372,8 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name)
gst_object_set_name (GST_OBJECT (element), name); gst_object_set_name (GST_OBJECT (element), name);
GST_DEBUG ("created \"%s\"", GST_PLUGIN_FEATURE_NAME (factory)); GST_DEBUG ("created \"%s\"", GST_PLUGIN_FEATURE_NAME (factory));
gst_object_unref (factory);
return element; return element;
} }

View file

@ -94,7 +94,7 @@ gst_plugin_finalize (GstPlugin * plugin)
GstRegistry *registry = gst_registry_get_default (); GstRegistry *registry = gst_registry_get_default ();
GList *g; GList *g;
GST_ERROR ("finalizing plugin %p", plugin); GST_DEBUG ("finalizing plugin %p", plugin);
for (g = registry->plugins; g; g = g->next) { for (g = registry->plugins; g; g = g->next) {
if (g->data == (gpointer) plugin) { if (g->data == (gpointer) plugin) {
g_warning ("removing plugin that is still in registry"); g_warning ("removing plugin that is still in registry");
@ -335,11 +335,14 @@ gst_plugin_load_file (const gchar * filename, GError ** error)
g_static_mutex_lock (&gst_plugin_loading_mutex); g_static_mutex_lock (&gst_plugin_loading_mutex);
plugin = gst_registry_lookup (registry, filename); plugin = gst_registry_lookup (registry, filename);
if (plugin && plugin->module) { if (plugin) {
if (plugin->module) {
g_static_mutex_unlock (&gst_plugin_loading_mutex); g_static_mutex_unlock (&gst_plugin_loading_mutex);
return plugin; return plugin;
} else {
gst_object_unref (plugin);
}
} }
GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"", GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"",
filename); filename);
@ -617,9 +620,10 @@ gst_plugin_is_loaded (GstPlugin * plugin)
{ {
g_return_val_if_fail (plugin != NULL, FALSE); g_return_val_if_fail (plugin != NULL, FALSE);
return (plugin->module != NULL); return (plugin->module != NULL || plugin->filename == NULL);
} }
#if 0
/** /**
* gst_plugin_feature_list: * gst_plugin_feature_list:
* @plugin: plugin to query * @plugin: plugin to query
@ -704,6 +708,7 @@ gst_plugin_list_feature_filter (GList * list,
return data.result; return data.result;
} }
#endif
/** /**
* gst_plugin_name_filter: * gst_plugin_name_filter:
@ -721,6 +726,7 @@ gst_plugin_name_filter (GstPlugin * plugin, const gchar * name)
return (plugin->desc.name && !strcmp (plugin->desc.name, name)); return (plugin->desc.name && !strcmp (plugin->desc.name, name));
} }
#if 0
/** /**
* gst_plugin_find_feature: * gst_plugin_find_feature:
* @plugin: plugin to get the feature from * @plugin: plugin to get the feature from
@ -749,19 +755,23 @@ gst_plugin_find_feature (GstPlugin * plugin, const gchar * name, GType type)
if (walk) { if (walk) {
result = GST_PLUGIN_FEATURE (walk->data); result = GST_PLUGIN_FEATURE (walk->data);
gst_object_ref (result->plugin); gst_object_ref (result);
gst_plugin_feature_list_free (walk); gst_plugin_feature_list_free (walk);
} }
return result; return result;
} }
#endif
#if 0
static gboolean static gboolean
gst_plugin_feature_name_filter (GstPluginFeature * feature, const gchar * name) gst_plugin_feature_name_filter (GstPluginFeature * feature, const gchar * name)
{ {
return !strcmp (name, GST_PLUGIN_FEATURE_NAME (feature)); return !strcmp (name, GST_PLUGIN_FEATURE_NAME (feature));
} }
#endif
#if 0
/** /**
* gst_plugin_find_feature_by_name: * gst_plugin_find_feature_by_name:
* @plugin: plugin to get the feature from * @plugin: plugin to get the feature from
@ -785,74 +795,24 @@ gst_plugin_find_feature_by_name (GstPlugin * plugin, const gchar * name)
if (walk) { if (walk) {
result = GST_PLUGIN_FEATURE (walk->data); result = GST_PLUGIN_FEATURE (walk->data);
gst_object_ref (result->plugin); gst_object_ref (result);
gst_plugin_feature_list_free (walk); gst_plugin_feature_list_free (walk);
} }
return result; return result;
} }
#endif
/** /**
* gst_plugin_add_feature: * gst_plugin_load_by_name:
* @plugin: plugin to add feature to
* @feature: feature to add
*
* Add feature to the list of those provided by the plugin.
* There is a separate namespace for each plugin feature type.
* See #gst_plugin_get_feature_list
*/
void
gst_plugin_add_feature (GstPlugin * plugin, GstPluginFeature * feature)
{
/* FIXME 0.9: get reference counting somewhat right in here,
* GstPluginFeatures should probably be GstObjects that are sinked when
* adding them to a plugin */
g_return_if_fail (plugin != NULL);
g_return_if_fail (GST_IS_PLUGIN_FEATURE (feature));
g_return_if_fail (feature != NULL);
g_return_if_fail (feature->plugin == NULL);
/* gst_object_sink (feature); */
feature->plugin = plugin;
plugin->features = g_list_prepend (plugin->features, feature);
plugin->numfeatures++;
}
/**
* gst_plugin_get_feature_list:
* @plugin: the plugin to get the features from
*
* get a list of all the features that this plugin provides
*
* Returns: a GList of features, use g_list_free to free the list.
*/
GList *
gst_plugin_get_feature_list (GstPlugin * plugin)
{
GList *list;
GList *g;
g_return_val_if_fail (plugin != NULL, NULL);
list = g_list_copy (plugin->features);
for (g = list; g; g = g->next) {
gst_object_ref (plugin);
}
return list;
}
/* FIXME is this function necessary? */
/**
* gst_plugin_load_1:
* @name: name of plugin to load * @name: name of plugin to load
* *
* Load the named plugin. * Load the named plugin.
* *
* Returns: whether the plugin was loaded or not * Returns: whether the plugin was loaded or not
*/ */
gboolean GstPlugin *
gst_plugin_load_1 (const gchar * name) gst_plugin_load_by_name (const gchar * name)
{ {
GstPlugin *plugin; GstPlugin *plugin;
GError *error = NULL; GError *error = NULL;
@ -863,13 +823,13 @@ gst_plugin_load_1 (const gchar * name)
if (!plugin) { if (!plugin) {
GST_WARNING ("load_plugin error: %s\n", error->message); GST_WARNING ("load_plugin error: %s\n", error->message);
g_error_free (error); g_error_free (error);
return FALSE; return NULL;
} }
return TRUE;; return plugin;
} }
GST_DEBUG ("Could not find %s in registry pool", name); GST_DEBUG ("Could not find plugin %s in registry", name);
return FALSE; return NULL;
} }
GstPlugin * GstPlugin *
@ -882,20 +842,15 @@ gst_plugin_load (GstPlugin * plugin)
return plugin; return plugin;
} }
if (!plugin->filename) {
return plugin;
}
newplugin = gst_plugin_load_file (plugin->filename, &error); newplugin = gst_plugin_load_file (plugin->filename, &error);
if (newplugin == NULL) { if (newplugin == NULL) {
GST_WARNING ("load_plugin error: %s\n", error->message); GST_WARNING ("load_plugin error: %s\n", error->message);
g_error_free (error); g_error_free (error);
//gst_object_unref (plugin); gst_object_unref (plugin);
return NULL; return NULL;
} }
/* FIXME hack to keep plugins from disappearing */ gst_object_unref (plugin);
//gst_object_unref (plugin);
return newplugin; return newplugin;
} }
@ -906,7 +861,7 @@ gst_plugin_list_free (GList * list)
GList *g; GList *g;
for (g = list; g; g = g->next) { for (g = list; g; g = g->next) {
//gst_object_unref (GST_PLUGIN(g->data)); gst_object_unref (GST_PLUGIN (g->data));
} }
g_list_free (list); g_list_free (list);
} }

View file

@ -90,8 +90,6 @@ struct _GstPlugin {
unsigned int flags; unsigned int flags;
gchar * filename; gchar * filename;
GList * features; /* list of features provided */
gint numfeatures;
GModule * module; /* contains the module if plugin is loaded */ GModule * module; /* contains the module if plugin is loaded */
@ -165,30 +163,15 @@ G_CONST_RETURN gchar* gst_plugin_get_origin (GstPlugin *plugin);
GModule * gst_plugin_get_module (GstPlugin *plugin); GModule * gst_plugin_get_module (GstPlugin *plugin);
gboolean gst_plugin_is_loaded (GstPlugin *plugin); gboolean gst_plugin_is_loaded (GstPlugin *plugin);
GList* gst_plugin_feature_filter (GstPlugin *plugin,
GstPluginFeatureFilter filter,
gboolean first,
gpointer user_data);
GList* gst_plugin_list_feature_filter (GList *list,
GstPluginFeatureFilter filter,
gboolean first,
gpointer user_data);
void gst_plugin_list_free (GList *list);
gboolean gst_plugin_name_filter (GstPlugin *plugin, const gchar *name); gboolean gst_plugin_name_filter (GstPlugin *plugin, const gchar *name);
GList* gst_plugin_get_feature_list (GstPlugin *plugin);
GstPluginFeature* gst_plugin_find_feature (GstPlugin *plugin, const gchar *name, GType type);
GstPluginFeature* gst_plugin_find_feature_by_name (GstPlugin *plugin, const gchar *name);
gboolean gst_plugin_check_file (const gchar *filename, GError** error); gboolean gst_plugin_check_file (const gchar *filename, GError** error);
GstPlugin * gst_plugin_load_file (const gchar *filename, GError** error); GstPlugin * gst_plugin_load_file (const gchar *filename, GError** error);
void gst_plugin_add_feature (GstPlugin *plugin, GstPluginFeature *feature);
GstPlugin * gst_plugin_load (GstPlugin *plugin); GstPlugin * gst_plugin_load (GstPlugin *plugin);
GstPlugin * gst_plugin_load_by_name (const gchar *name);
/* shortcuts to load from the registry pool */ void gst_plugin_list_free (GList *list);
gboolean gst_plugin_load_1 (const gchar *name);
G_END_DECLS G_END_DECLS

View file

@ -31,15 +31,18 @@
static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass); static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass);
static void gst_plugin_feature_init (GstPluginFeature * feature); static void gst_plugin_feature_init (GstPluginFeature * feature);
static void gst_plugin_feature_finalize (GstPluginFeature * feature);
/* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */ /* static guint gst_plugin_feature_signals[LAST_SIGNAL] = { 0 }; */
G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, G_TYPE_OBJECT); G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, GST_TYPE_OBJECT);
static void static void
gst_plugin_feature_class_init (GstPluginFeatureClass * klass) gst_plugin_feature_class_init (GstPluginFeatureClass * klass)
{ {
G_OBJECT_CLASS (klass)->finalize =
(GObjectFinalizeFunc) gst_plugin_feature_finalize;
} }
static void static void
@ -48,6 +51,12 @@ gst_plugin_feature_init (GstPluginFeature * feature)
} }
static void
gst_plugin_feature_finalize (GstPluginFeature * feature)
{
GST_DEBUG ("finalizing feature %p", feature);
}
/** /**
* gst_plugin_feature_load: * gst_plugin_feature_load:
* @feature: the plugin feature to check * @feature: the plugin feature to check
@ -66,24 +75,27 @@ gst_plugin_feature_load (GstPluginFeature * feature)
g_return_val_if_fail (feature != NULL, FALSE); g_return_val_if_fail (feature != NULL, FALSE);
g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE); g_return_val_if_fail (GST_IS_PLUGIN_FEATURE (feature), FALSE);
plugin = gst_plugin_load (feature->plugin); if (feature->loaded)
return feature;
plugin = gst_plugin_load_by_name (feature->plugin_name);
if (!plugin) { if (!plugin) {
g_critical ("Failed to load plugin containing feature '%s'.", g_critical ("Failed to load plugin containing feature '%s'.",
GST_PLUGIN_FEATURE_NAME (feature)); GST_PLUGIN_FEATURE_NAME (feature));
return NULL; return NULL;
} }
if (plugin == feature->plugin) { gst_object_unref (plugin);
return feature;
}
real_feature = gst_plugin_find_feature_by_name (plugin, feature->name); real_feature =
gst_registry_lookup_feature (gst_registry_get_default (), feature->name);
if (real_feature == NULL) { if (real_feature == NULL) {
g_critical g_critical
("Loaded plugin containing feature '%s', but feature disappeared.", ("Loaded plugin containing feature '%s', but feature disappeared.",
feature->name); feature->name);
} }
//gst_object_unref (feature->plugin); gst_object_unref (feature);
return real_feature; return real_feature;
} }
@ -117,6 +129,7 @@ gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name)
} else { } else {
feature->name = g_strdup (name); feature->name = g_strdup (name);
} }
gst_object_set_name (GST_OBJECT (feature), feature->name);
} }
/** /**
@ -171,14 +184,12 @@ gst_plugin_feature_get_rank (GstPluginFeature * feature)
void void
gst_plugin_feature_list_free (GList * list) gst_plugin_feature_list_free (GList * list)
{ {
#if 0
GList *g; GList *g;
for (g = list; g; g = g->next) { for (g = list; g; g = g->next) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data); GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
//gst_object_unref (feature->plugin); gst_object_unref (feature);
} }
#endif
g_list_free (list); g_list_free (list);
} }

View file

@ -25,6 +25,7 @@
#define __GST_PLUGIN_FEATURE_H__ #define __GST_PLUGIN_FEATURE_H__
#include <glib-object.h> #include <glib-object.h>
#include <gst/gstobject.h>
G_BEGIN_DECLS G_BEGIN_DECLS
@ -49,20 +50,22 @@ typedef enum {
} GstRank; } GstRank;
struct _GstPluginFeature { struct _GstPluginFeature {
GObject object; GstObject object;
/*< private >*/ /*< private >*/
gboolean loaded;
gchar *name; gchar *name;
guint rank; guint rank;
struct _GstPlugin *plugin; //struct _GstPlugin *plugin;
gchar *plugin_name;
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];
}; };
struct _GstPluginFeatureClass { struct _GstPluginFeatureClass {
GObjectClass parent_class; GstObjectClass parent_class;
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];

View file

@ -111,6 +111,7 @@
enum enum
{ {
PLUGIN_ADDED, PLUGIN_ADDED,
FEATURE_ADDED,
LAST_SIGNAL LAST_SIGNAL
}; };
@ -119,6 +120,8 @@ static void gst_registry_init (GstRegistry * registry);
static guint gst_registry_signals[LAST_SIGNAL] = { 0 }; static guint gst_registry_signals[LAST_SIGNAL] = { 0 };
static GstPluginFeature *gst_registry_lookup_feature_locked (GstRegistry *
registry, const char *name);
static GstPlugin *gst_registry_lookup_locked (GstRegistry * registry, static GstPlugin *gst_registry_lookup_locked (GstRegistry * registry,
const char *filename); const char *filename);
@ -135,6 +138,10 @@ gst_registry_class_init (GstRegistryClass * klass)
g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass), g_signal_new ("plugin-added", G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL, G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL,
NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER); NULL, gst_marshal_VOID__POINTER, G_TYPE_NONE, 1, G_TYPE_POINTER);
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);
gobject_class->dispose = NULL; gobject_class->dispose = NULL;
} }
@ -235,7 +242,7 @@ gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin)
GST_DEBUG ("Replacing existing plugin %p for filename \"%s\"", GST_DEBUG ("Replacing existing plugin %p for filename \"%s\"",
existing_plugin, plugin->filename); existing_plugin, plugin->filename);
registry->plugins = g_list_remove (registry->plugins, existing_plugin); registry->plugins = g_list_remove (registry->plugins, existing_plugin);
//gst_object_unref (existing_plugin); gst_object_unref (existing_plugin);
} }
GST_DEBUG ("Adding plugin %p for filename \"%s\"", plugin, plugin->filename); GST_DEBUG ("Adding plugin %p for filename \"%s\"", plugin, plugin->filename);
@ -268,7 +275,69 @@ gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin)
GST_LOCK (registry); GST_LOCK (registry);
registry->plugins = g_list_remove (registry->plugins, plugin); registry->plugins = g_list_remove (registry->plugins, plugin);
GST_UNLOCK (registry); GST_UNLOCK (registry);
//gst_object_unref (plugin); 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.
*
* Returns: TRUE on success.
*/
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);
GST_LOCK (registry);
existing_feature = gst_registry_lookup_feature_locked (registry,
feature->name);
if (existing_feature) {
GST_DEBUG ("Replacing existing feature %p (%s)",
existing_feature, feature->name);
registry->features = g_list_remove (registry->features, existing_feature);
gst_object_unref (existing_feature);
}
GST_DEBUG ("Adding feature %p (%s)", feature, feature->name);
registry->features = g_list_prepend (registry->features, feature);
gst_object_ref (feature);
gst_object_sink (feature);
GST_UNLOCK (registry);
GST_DEBUG ("emitting feature-added for %s", feature->name);
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.
*/
void
gst_registry_remove_feature (GstRegistry * registry, GstPluginFeature * feature)
{
g_return_if_fail (GST_IS_REGISTRY (registry));
GST_LOCK (registry);
registry->features = g_list_remove (registry->features, feature);
GST_UNLOCK (registry);
gst_object_unref (feature);
} }
/** /**
@ -323,12 +392,16 @@ gst_registry_feature_filter (GstRegistry * registry,
GstPluginFeatureFilter filter, gboolean first, gpointer user_data) GstPluginFeatureFilter filter, gboolean first, gpointer user_data)
{ {
GList *list; GList *list;
GList *g;
g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL); g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL);
GST_LOCK (registry); GST_LOCK (registry);
list = gst_plugin_list_feature_filter (registry->plugins, filter, first, list = gst_filter_run (registry->features, (GstFilterFunc) filter, first,
user_data); user_data);
for (g = list; g; g = g->next) {
gst_object_ref (GST_PLUGIN_FEATURE (g->data));
}
GST_UNLOCK (registry); GST_UNLOCK (registry);
return list; return list;
@ -396,7 +469,7 @@ gst_registry_find_feature (GstRegistry * registry, const gchar * name,
if (walk) { if (walk) {
feature = GST_PLUGIN_FEATURE (walk->data); feature = GST_PLUGIN_FEATURE (walk->data);
gst_object_ref (feature->plugin); gst_object_ref (feature);
gst_plugin_feature_list_free (walk); gst_plugin_feature_list_free (walk);
} }
@ -432,6 +505,39 @@ gst_registry_get_plugin_list (GstRegistry * registry)
return list; return list;
} }
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;
}
GstPluginFeature *
gst_registry_lookup_feature (GstRegistry * registry, const char *name)
{
GstPluginFeature *feature;
GST_LOCK (registry);
feature = gst_registry_lookup_feature_locked (registry, name);
if (feature)
gst_object_ref (feature);
GST_UNLOCK (registry);
return feature;
}
static GstPlugin * static GstPlugin *
gst_registry_lookup_locked (GstRegistry * registry, const char *filename) gst_registry_lookup_locked (GstRegistry * registry, const char *filename)
{ {
@ -458,6 +564,8 @@ gst_registry_lookup (GstRegistry * registry, const char *filename)
GST_LOCK (registry); GST_LOCK (registry);
plugin = gst_registry_lookup_locked (registry, filename); plugin = gst_registry_lookup_locked (registry, filename);
if (plugin)
gst_object_ref (plugin);
GST_UNLOCK (registry); GST_UNLOCK (registry);
return plugin; return plugin;
@ -471,6 +579,7 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path,
const gchar *dirent; const gchar *dirent;
gchar *filename; gchar *filename;
GstPlugin *plugin; GstPlugin *plugin;
GstPlugin *newplugin;
dir = g_dir_open (path, 0, NULL); dir = g_dir_open (path, 0, NULL);
if (!dir) if (!dir)
@ -524,11 +633,14 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path,
G_GSIZE_FORMAT, plugin->file_mtime, file_status.st_mtime, G_GSIZE_FORMAT, plugin->file_mtime, file_status.st_mtime,
plugin->file_size, file_status.st_size); plugin->file_size, file_status.st_size);
gst_registry_remove_plugin (gst_registry_get_default (), plugin); gst_registry_remove_plugin (gst_registry_get_default (), plugin);
gst_plugin_load_file (filename, NULL); newplugin = gst_plugin_load_file (filename, NULL);
gst_object_unref (newplugin);
} }
gst_object_unref (plugin);
} else { } else {
gst_plugin_load_file (filename, NULL); newplugin = gst_plugin_load_file (filename, NULL);
gst_object_unref (newplugin);
} }
g_free (filename); g_free (filename);
@ -570,3 +682,19 @@ _gst_registry_remove_cache_plugins (GstRegistry * registry)
g = g_next; g = g_next;
} }
} }
static gboolean
_gst_plugin_feature_filter_plugin_name (GstPluginFeature * feature,
gpointer user_data)
{
return (strcmp (feature->plugin_name, (gchar *) user_data) == 0);
}
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);
}

View file

@ -42,6 +42,7 @@ struct _GstRegistry {
GstObject object; GstObject object;
GList *plugins; GList *plugins;
GList *features;
GList *paths; GList *paths;
@ -56,6 +57,7 @@ struct _GstRegistryClass {
/* signals */ /* signals */
void (*plugin_added) (GstRegistry *registry, GstPlugin *plugin); void (*plugin_added) (GstRegistry *registry, GstPlugin *plugin);
void (*feature_added) (GstRegistry *registry, GstPluginFeature *feature);
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];
}; };
@ -71,6 +73,8 @@ GList* gst_registry_get_path_list (GstRegistry *registry);
gboolean gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin); gboolean gst_registry_add_plugin (GstRegistry *registry, GstPlugin *plugin);
void gst_registry_remove_plugin (GstRegistry *registry, GstPlugin *plugin); void gst_registry_remove_plugin (GstRegistry *registry, GstPlugin *plugin);
gboolean gst_registry_add_feature (GstRegistry * registry, GstPluginFeature * feature);
void gst_registry_remove_feature (GstRegistry * registry, GstPluginFeature * feature);
GList* gst_registry_get_plugin_list (GstRegistry *registry); GList* gst_registry_get_plugin_list (GstRegistry *registry);
GList* gst_registry_plugin_filter (GstRegistry *registry, GList* gst_registry_plugin_filter (GstRegistry *registry,
@ -83,10 +87,12 @@ GList* gst_registry_feature_filter (GstRegistry *registry,
gpointer user_data); gpointer user_data);
GList * gst_registry_get_feature_list (GstRegistry *registry, GList * gst_registry_get_feature_list (GstRegistry *registry,
GType type); GType type);
GList * gst_registry_get_feature_list_by_plugin (GstRegistry *registry, const gchar *name);
GstPlugin* gst_registry_find_plugin (GstRegistry *registry, const gchar *name); GstPlugin* gst_registry_find_plugin (GstRegistry *registry, const gchar *name);
GstPluginFeature* gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type); GstPluginFeature* gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type);
GstPlugin * gst_registry_lookup (GstRegistry *registry, const char *filename); GstPlugin * gst_registry_lookup (GstRegistry *registry, const char *filename);
GstPluginFeature * gst_registry_lookup_feature (GstRegistry *registry, const char *name);
gboolean gst_registry_xml_read_cache (GstRegistry * registry, const char *location); gboolean gst_registry_xml_read_cache (GstRegistry * registry, const char *location);
gboolean gst_registry_xml_write_cache (GstRegistry * registry, const char *location); gboolean gst_registry_xml_write_cache (GstRegistry * registry, const char *location);

View file

@ -604,11 +604,13 @@ load_feature (xmlTextReaderPtr reader)
} }
static GstPlugin * static GstPlugin *
load_plugin (xmlTextReaderPtr reader) load_plugin (xmlTextReaderPtr reader, GList ** feature_list)
{ {
int ret; int ret;
GstPlugin *plugin = g_object_new (GST_TYPE_PLUGIN, NULL); GstPlugin *plugin = g_object_new (GST_TYPE_PLUGIN, NULL);
*feature_list = NULL;
GST_DEBUG ("parsing plugin"); GST_DEBUG ("parsing plugin");
plugin->flags |= GST_PLUGIN_FLAG_CACHED; plugin->flags |= GST_PLUGIN_FLAG_CACHED;
@ -673,8 +675,11 @@ load_plugin (xmlTextReaderPtr reader)
} else if (g_str_equal (tag, "feature")) { } else if (g_str_equal (tag, "feature")) {
GstPluginFeature *feature = load_feature (reader); GstPluginFeature *feature = load_feature (reader);
if (feature) feature->plugin_name = g_strdup (plugin->desc.name);
gst_plugin_add_feature (plugin, feature);
if (feature) {
*feature_list = g_list_prepend (*feature_list, feature);
}
} else { } else {
GST_DEBUG ("unknown tag %s", tag); GST_DEBUG ("unknown tag %s", tag);
} }
@ -727,12 +732,18 @@ gst_registry_xml_read_cache (GstRegistry * registry, const char *location)
const gchar *tag = (const gchar *) xmlTextReaderConstName (reader); const gchar *tag = (const gchar *) xmlTextReaderConstName (reader);
if (g_str_equal (tag, "plugin")) { if (g_str_equal (tag, "plugin")) {
GstPlugin *plugin = load_plugin (reader); GList *feature_list;
GstPlugin *plugin = load_plugin (reader, &feature_list);
if (plugin) { if (plugin) {
GST_DEBUG ("adding plugin %s with %d features", plugin->desc.name, GList *g;
plugin->numfeatures);
GST_DEBUG ("adding plugin %s", plugin->desc.name);
gst_registry_add_plugin (registry, plugin); gst_registry_add_plugin (registry, plugin);
for (g = feature_list; g; g = g_list_next (g)) {
gst_registry_add_feature (registry, GST_PLUGIN_FEATURE (g->data));
}
g_list_free (feature_list);
} }
} }
} }
@ -918,6 +929,7 @@ gst_registry_xml_save_feature (GstRegistry * registry,
static gboolean static gboolean
gst_registry_xml_save_plugin (GstRegistry * registry, GstPlugin * plugin) gst_registry_xml_save_plugin (GstRegistry * registry, GstPlugin * plugin)
{ {
GList *list;
GList *walk; GList *walk;
char s[100]; char s[100];
@ -933,18 +945,19 @@ gst_registry_xml_save_plugin (GstRegistry * registry, GstPlugin * plugin)
PUT_ESCAPED (" ", "package", plugin->desc.package); PUT_ESCAPED (" ", "package", plugin->desc.package);
PUT_ESCAPED (" ", "origin", plugin->desc.origin); PUT_ESCAPED (" ", "origin", plugin->desc.origin);
walk = plugin->features; list = gst_registry_get_feature_list_by_plugin (registry, plugin->desc.name);
while (walk) { for (walk = list; walk; walk = g_list_next (walk)) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data); GstPluginFeature *feature = GST_PLUGIN_FEATURE (walk->data);
gst_registry_xml_save (registry, " <feature typename=\"%s\">\n", gst_registry_xml_save (registry, " <feature typename=\"%s\">\n",
g_type_name (G_OBJECT_TYPE (feature))); g_type_name (G_OBJECT_TYPE (feature)));
gst_registry_xml_save_feature (registry, feature); gst_registry_xml_save_feature (registry, feature);
gst_registry_xml_save (registry, " </feature>\n"); gst_registry_xml_save (registry, " </feature>\n");
walk = g_list_next (walk);
} }
gst_plugin_feature_list_free (list);
return TRUE; return TRUE;
} }

View file

@ -67,7 +67,6 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name); GST_DEBUG_OBJECT (factory, "using new typefind factory for %s", name);
g_assert (GST_IS_TYPE_FIND_FACTORY (factory)); g_assert (GST_IS_TYPE_FIND_FACTORY (factory));
gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name); gst_plugin_feature_set_name (GST_PLUGIN_FEATURE (factory), name);
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank); gst_plugin_feature_set_rank (GST_PLUGIN_FEATURE (factory), rank);
if (factory->extensions) if (factory->extensions)
@ -77,6 +76,11 @@ gst_type_find_register (GstPlugin * plugin, const gchar * name, guint rank,
gst_caps_replace (&factory->caps, (GstCaps *) possible_caps); gst_caps_replace (&factory->caps, (GstCaps *) possible_caps);
factory->function = func; factory->function = func;
factory->user_data = data; factory->user_data = data;
GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
gst_registry_add_feature (gst_registry_get_default (),
GST_PLUGIN_FEATURE (factory));
return TRUE; return TRUE;
} }

View file

@ -225,7 +225,7 @@ gst_type_find_factory_call_function (GstTypeFindFactory * factory,
g_return_if_fail (find->suggest != NULL); g_return_if_fail (find->suggest != NULL);
/* gst_plugin_feature_load will steal our ref */ /* gst_plugin_feature_load will steal our ref */
gst_object_ref (factory->feature.plugin); gst_object_ref (factory);
new_factory = new_factory =
GST_TYPE_FIND_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE GST_TYPE_FIND_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE
(factory))); (factory)));
@ -233,8 +233,6 @@ gst_type_find_factory_call_function (GstTypeFindFactory * factory,
g_assert (new_factory->function != NULL); g_assert (new_factory->function != NULL);
new_factory->function (find, new_factory->user_data); new_factory->function (find, new_factory->user_data);
/* FIXME hack. somehow, this refcount gets destroyed */ gst_object_unref (new_factory);
gst_object_ref (new_factory->feature.plugin);
//gst_object_unref (new_factory->feature.plugin);
} }
} }

View file

@ -992,11 +992,16 @@ gst_file_index_plugin_init (GstPlugin * plugin)
factory = gst_index_factory_new ("fileindex", factory = gst_index_factory_new ("fileindex",
"A index that stores entries in file", gst_file_index_get_type ()); "A index that stores entries in file", gst_file_index_get_type ());
if (factory != NULL) { if (factory == NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
} else {
return FALSE; return FALSE;
} }
GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
gst_registry_add_feature (gst_registry_get_default (),
GST_PLUGIN_FEATURE (factory));
GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL); GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL);
return TRUE; return TRUE;

View file

@ -411,10 +411,16 @@ gst_mem_index_plugin_init (GstPlugin * plugin)
factory = gst_index_factory_new ("memindex", factory = gst_index_factory_new ("memindex",
"A index that stores entries in memory", gst_mem_index_get_type ()); "A index that stores entries in memory", gst_mem_index_get_type ());
if (factory != NULL) { if (factory == NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); g_warning ("failed to create memindex factory");
} else { return FALSE;
g_warning ("could not register memindex");
} }
GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
gst_registry_add_feature (gst_registry_get_default (),
GST_PLUGIN_FEATURE (factory));
return TRUE; return TRUE;
} }

View file

@ -1,11 +0,0 @@
plugin_LTLIBRARIES = \
libgstthreadscheduler.la
libgstthreadscheduler_la_SOURCES = threadscheduler.c
libgstthreadscheduler_la_CFLAGS = $(GST_OBJ_CFLAGS)
libgstthreadscheduler_la_LIBADD = $(GST_OBJ_LIBS)
libgstthreadscheduler_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
noinst_HEADERS =

View file

@ -992,11 +992,16 @@ gst_file_index_plugin_init (GstPlugin * plugin)
factory = gst_index_factory_new ("fileindex", factory = gst_index_factory_new ("fileindex",
"A index that stores entries in file", gst_file_index_get_type ()); "A index that stores entries in file", gst_file_index_get_type ());
if (factory != NULL) { if (factory == NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory));
} else {
return FALSE; return FALSE;
} }
GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
gst_registry_add_feature (gst_registry_get_default (),
GST_PLUGIN_FEATURE (factory));
GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL); GST_DEBUG_CATEGORY_INIT (DC, "GST_FILEINDEX", 0, NULL);
return TRUE; return TRUE;

View file

@ -411,10 +411,16 @@ gst_mem_index_plugin_init (GstPlugin * plugin)
factory = gst_index_factory_new ("memindex", factory = gst_index_factory_new ("memindex",
"A index that stores entries in memory", gst_mem_index_get_type ()); "A index that stores entries in memory", gst_mem_index_get_type ());
if (factory != NULL) { if (factory == NULL) {
gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); g_warning ("failed to create memindex factory");
} else { return FALSE;
g_warning ("could not register memindex");
} }
GST_PLUGIN_FEATURE (factory)->plugin_name = g_strdup (plugin->desc.name);
GST_PLUGIN_FEATURE (factory)->loaded = TRUE;
gst_registry_add_feature (gst_registry_get_default (),
GST_PLUGIN_FEATURE (factory));
return TRUE; return TRUE;
} }

View file

@ -10,7 +10,7 @@ REGISTRY_ENVIRONMENT = \
TESTS_ENVIRONMENT = \ TESTS_ENVIRONMENT = \
$(REGISTRY_ENVIRONMENT) \ $(REGISTRY_ENVIRONMENT) \
GST_PLUGIN_SYSTEM_PATH= \ GST_PLUGIN_SYSTEM_PATH= \
GST_PLUGIN_PATH=$(top_builddir)/gst/elements/.libs:$(top_builddir)/gst/indexers/.libs GST_PLUGIN_PATH=$(top_builddir)/gst/elements:$(top_builddir)/gst/indexers
plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@ plugindir = $(libdir)/gstreamer-@GST_MAJORMINOR@

View file

@ -59,6 +59,32 @@ GST_START_TEST (test_register_static)
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_registry)
{
GList *g;
GstRegistry *registry;
registry = gst_registry_get_default ();
for (g = registry->plugins; g; g = g->next) {
GstPlugin *plugin = GST_PLUGIN (g->data);
fail_if (GST_OBJECT (plugin)->refcount != 1,
"Plugin in registry should have refcount of 1");
GST_DEBUG ("refcount %d %s", GST_OBJECT (plugin)->refcount,
plugin->desc.name);
}
for (g = registry->features; g; g = g->next) {
GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data);
fail_if (GST_OBJECT (feature)->refcount != 1,
"Feature in registry should have refcount of 1");
GST_DEBUG ("refcount %d %s", GST_OBJECT (feature)->refcount, feature->name);
}
}
GST_END_TEST;
GST_START_TEST (test_load_gstelements) GST_START_TEST (test_load_gstelements)
{ {
GstPlugin *unloaded_plugin; GstPlugin *unloaded_plugin;
@ -66,17 +92,22 @@ GST_START_TEST (test_load_gstelements)
unloaded_plugin = gst_default_registry_find_plugin ("gstelements"); unloaded_plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (unloaded_plugin == NULL, "Failed to find gstelements plugin"); fail_if (unloaded_plugin == NULL, "Failed to find gstelements plugin");
fail_if (unloaded_plugin->object.refcount != 2, fail_if (GST_OBJECT (unloaded_plugin)->refcount != 2,
"Refcount of unloaded plugin in registry initially should be 2"); "Refcount of unloaded plugin in registry initially should be 2");
GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount);
gst_object_ref (unloaded_plugin); gst_object_ref (unloaded_plugin);
loaded_plugin = gst_plugin_load (unloaded_plugin); loaded_plugin = gst_plugin_load (unloaded_plugin);
fail_if (loaded_plugin == NULL, "Failed to load plugin"); fail_if (loaded_plugin == NULL, "Failed to load plugin");
fail_if (loaded_plugin->object.refcount != 2, if (loaded_plugin != unloaded_plugin) {
fail_if (GST_OBJECT (loaded_plugin)->refcount != 2,
"Refcount of loaded plugin in registry should be 2"); "Refcount of loaded plugin in registry should be 2");
fail_if (unloaded_plugin->object.refcount != 1, GST_DEBUG ("refcount %d", GST_OBJECT (loaded_plugin)->refcount);
"Refcount of replaced plugin in registry should be 1"); fail_if (GST_OBJECT (unloaded_plugin)->refcount != 1,
"Refcount of replaced plugin should be 1");
GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount);
}
gst_object_unref (unloaded_plugin); gst_object_unref (unloaded_plugin);
gst_object_unref (loaded_plugin); gst_object_unref (loaded_plugin);
@ -90,7 +121,7 @@ GST_START_TEST (test_registry_get_plugin_list)
GstPlugin *plugin; GstPlugin *plugin;
plugin = gst_default_registry_find_plugin ("gstelements"); plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (plugin->object.refcount != 2, fail_if (GST_OBJECT (plugin)->refcount != 2,
"Refcount of plugin in registry should be 2"); "Refcount of plugin in registry should be 2");
list = gst_registry_get_plugin_list (gst_registry_get_default ()); list = gst_registry_get_plugin_list (gst_registry_get_default ());
@ -100,7 +131,7 @@ GST_START_TEST (test_registry_get_plugin_list)
gst_plugin_list_free (list); gst_plugin_list_free (list);
fail_if (plugin->object.refcount != 2, fail_if (GST_OBJECT (plugin)->refcount != 2,
"Refcount of plugin in after list free should be 2"); "Refcount of plugin in after list free should be 2");
gst_object_unref (plugin); gst_object_unref (plugin);
@ -110,55 +141,34 @@ GST_END_TEST;
GST_START_TEST (test_find_feature) GST_START_TEST (test_find_feature)
{ {
GstPlugin *plugin;
GstPluginFeature *feature; GstPluginFeature *feature;
plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (plugin->object.refcount != 2,
"Refcount of plugin in registry should be 2");
feature = gst_registry_find_feature (gst_registry_get_default (), feature = gst_registry_find_feature (gst_registry_get_default (),
"identity", GST_TYPE_ELEMENT_FACTORY); "identity", GST_TYPE_ELEMENT_FACTORY);
fail_if (feature == NULL, "Failed to find identity element factory"); fail_if (feature == NULL, "Failed to find identity element factory");
fail_if (feature->plugin != plugin, fail_if (strcmp (feature->plugin_name, "gstelements"),
"Expected identity to be from gstelements plugin"); "Expected identity to be from gstelements plugin");
fail_if (plugin->object.refcount != 3, fail_if (GST_OBJECT (feature)->refcount != 2,
"Refcount of plugin in registry+feature should be 3"); "Refcount of feature should be 2");
GST_DEBUG ("refcount %d", GST_OBJECT (feature)->refcount);
gst_object_unref (feature->plugin); gst_object_unref (feature);
fail_if (plugin->object.refcount != 2,
"Refcount of plugin in after list free should be 2");
gst_object_unref (plugin);
} }
GST_END_TEST; GST_END_TEST;
GST_START_TEST (test_find_element) GST_START_TEST (test_find_element)
{ {
GstPlugin *plugin;
GstElementFactory *element_factory; GstElementFactory *element_factory;
plugin = gst_default_registry_find_plugin ("gstelements");
fail_if (plugin->object.refcount != 2,
"Refcount of plugin in registry should be 2");
element_factory = gst_element_factory_find ("identity"); element_factory = gst_element_factory_find ("identity");
fail_if (element_factory == NULL, "Failed to find identity element factory"); fail_if (element_factory == NULL, "Failed to find identity element factory");
fail_if (GST_PLUGIN_FEATURE (element_factory)->plugin != plugin,
"Expected identity to be from gstelements plugin");
fail_if (plugin->object.refcount != 3, fail_if (GST_OBJECT (element_factory)->refcount != 2,
"Refcount of plugin in registry+feature should be 3"); "Refcount of plugin in registry+feature should be 2");
gst_object_unref (GST_PLUGIN_FEATURE (element_factory)->plugin); gst_object_unref (element_factory);
fail_if (plugin->object.refcount != 2,
"Refcount of plugin in after list free should be 2");
gst_object_unref (plugin);
} }
GST_END_TEST; GST_END_TEST;
@ -228,6 +238,7 @@ gst_plugin_suite (void)
suite_add_tcase (s, tc_chain); suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_register_static); tcase_add_test (tc_chain, test_register_static);
tcase_add_test (tc_chain, test_registry);
tcase_add_test (tc_chain, test_load_gstelements); tcase_add_test (tc_chain, test_load_gstelements);
tcase_add_test (tc_chain, test_registry_get_plugin_list); tcase_add_test (tc_chain, test_registry_get_plugin_list);
tcase_add_test (tc_chain, test_find_feature); tcase_add_test (tc_chain, test_find_feature);

View file

@ -835,7 +835,9 @@ print_element_list (gboolean print_all)
plugin = (GstPlugin *) (plugins->data); plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins); plugins = g_list_next (plugins);
features = gst_plugin_get_feature_list (plugin); features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
plugin->desc.name);
while (features) { while (features) {
GstPluginFeature *feature; GstPluginFeature *feature;
@ -920,7 +922,9 @@ print_plugin_features (GstPlugin * plugin)
gint num_indexes = 0; gint num_indexes = 0;
gint num_other = 0; gint num_other = 0;
features = gst_plugin_get_feature_list (plugin); features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
plugin->desc.name);
while (features) { while (features) {
GstPluginFeature *feature; GstPluginFeature *feature;
@ -1037,11 +1041,15 @@ print_element_info (GstElementFactory * factory, gboolean print_names)
_name = ""; _name = "";
print_factory_details_info (factory); print_factory_details_info (factory);
if (GST_PLUGIN_FEATURE (factory)->plugin) { if (GST_PLUGIN_FEATURE (factory)->plugin_name) {
GstPlugin *plugin = (GstPlugin *) GST_PLUGIN_FEATURE (factory)->plugin; GstPlugin *plugin;
plugin = gst_registry_find_plugin (gst_registry_get_default (),
GST_PLUGIN_FEATURE (factory)->plugin_name);
if (plugin) {
print_plugin_info (plugin); print_plugin_info (plugin);
} }
}
print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel); print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel);
print_interfaces (G_OBJECT_TYPE (element)); print_interfaces (G_OBJECT_TYPE (element));
@ -1062,15 +1070,19 @@ print_element_info (GstElementFactory * factory, gboolean print_names)
return 0; return 0;
} }
gboolean print_all = FALSE;
GOptionEntry options[] = {
{"print-all", 'a', 0, G_OPTION_ARG_NONE, &print_all,
N_("Print all elements"), NULL}
,
{NULL}
};
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
gboolean print_all = FALSE; GOptionContext *context;
struct poptOption options[] = { GError *error = NULL;
{"print-all", 'a', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &print_all, 0,
N_("Print all elements"), NULL},
POPT_TABLEEND
};
#ifdef GETTEXT_PACKAGE #ifdef GETTEXT_PACKAGE
bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
@ -1078,7 +1090,12 @@ main (int argc, char *argv[])
textdomain (GETTEXT_PACKAGE); textdomain (GETTEXT_PACKAGE);
#endif #endif
gst_init_with_popt_table (&argc, &argv, options); context = g_option_context_new ("- inspect plugins");
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
// g_option_context_add_group (context, gst_get_option_group ());
g_option_context_parse (context, &argc, &argv, &error);
gst_init (NULL, NULL);
if (print_all && argc > 2) { if (print_all && argc > 2) {
g_print ("-a requires no extra arguments\n"); g_print ("-a requires no extra arguments\n");

View file

@ -620,7 +620,9 @@ print_element_list (void)
plugin = (GstPlugin *) (plugins->data); plugin = (GstPlugin *) (plugins->data);
plugins = g_list_next (plugins); plugins = g_list_next (plugins);
features = gst_plugin_get_feature_list (plugin); features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
plugin->desc.name);
while (features) { while (features) {
GstPluginFeature *feature; GstPluginFeature *feature;
@ -688,7 +690,9 @@ print_plugin_info (GstPlugin * plugin)
g_print (" Origin URL:\t%s\n", plugin->desc.origin); g_print (" Origin URL:\t%s\n", plugin->desc.origin);
g_print ("\n"); g_print ("\n");
features = gst_plugin_get_feature_list (plugin); features =
gst_registry_get_feature_list_by_plugin (gst_registry_get_default (),
plugin->desc.name);
while (features) { while (features) {
GstPluginFeature *feature; GstPluginFeature *feature;