From: David Schleef Date: Sun, 18 Sep 2005 06:59:25 +0000 (+0000) Subject: check/Makefile.am: Fix environment variables. X-Git-Tag: RELEASE-0_9_3~130 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cb798ac570e4a4f86001d5d26af550eb09f4c329;p=platform%2Fupstream%2Fgstreamer.git 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. --- diff --git a/ChangeLog b/ChangeLog index 1d38ce5..1d1ee32 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2005-09-17 David Schleef + + * 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 * check/Makefile.am: diff --git a/check/Makefile.am b/check/Makefile.am index 92cff19..3d8dfca 100644 --- a/check/Makefile.am +++ b/check/Makefile.am @@ -10,7 +10,7 @@ REGISTRY_ENVIRONMENT = \ TESTS_ENVIRONMENT = \ $(REGISTRY_ENVIRONMENT) \ 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@ diff --git a/check/gst/gstplugin.c b/check/gst/gstplugin.c index 446d77f..325cd2e 100644 --- a/check/gst/gstplugin.c +++ b/check/gst/gstplugin.c @@ -59,6 +59,32 @@ GST_START_TEST (test_register_static) 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) { GstPlugin *unloaded_plugin; @@ -66,17 +92,22 @@ GST_START_TEST (test_load_gstelements) unloaded_plugin = gst_default_registry_find_plugin ("gstelements"); 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"); + GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount); gst_object_ref (unloaded_plugin); loaded_plugin = gst_plugin_load (unloaded_plugin); fail_if (loaded_plugin == NULL, "Failed to load plugin"); - fail_if (loaded_plugin->object.refcount != 2, - "Refcount of loaded plugin in registry should be 2"); - fail_if (unloaded_plugin->object.refcount != 1, - "Refcount of replaced plugin in registry should be 1"); + if (loaded_plugin != unloaded_plugin) { + fail_if (GST_OBJECT (loaded_plugin)->refcount != 2, + "Refcount of loaded plugin in registry should be 2"); + GST_DEBUG ("refcount %d", GST_OBJECT (loaded_plugin)->refcount); + 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 (loaded_plugin); @@ -90,7 +121,7 @@ GST_START_TEST (test_registry_get_plugin_list) GstPlugin *plugin; 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"); 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); - fail_if (plugin->object.refcount != 2, + fail_if (GST_OBJECT (plugin)->refcount != 2, "Refcount of plugin in after list free should be 2"); gst_object_unref (plugin); @@ -110,55 +141,34 @@ GST_END_TEST; GST_START_TEST (test_find_feature) { - GstPlugin *plugin; 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 (), "identity", GST_TYPE_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"); - fail_if (plugin->object.refcount != 3, - "Refcount of plugin in registry+feature should be 3"); - - gst_object_unref (feature->plugin); - - fail_if (plugin->object.refcount != 2, - "Refcount of plugin in after list free should be 2"); + fail_if (GST_OBJECT (feature)->refcount != 2, + "Refcount of feature should be 2"); + GST_DEBUG ("refcount %d", GST_OBJECT (feature)->refcount); - gst_object_unref (plugin); + gst_object_unref (feature); } GST_END_TEST; GST_START_TEST (test_find_element) { - GstPlugin *plugin; 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"); 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, - "Refcount of plugin in registry+feature should be 3"); - gst_object_unref (GST_PLUGIN_FEATURE (element_factory)->plugin); + fail_if (GST_OBJECT (element_factory)->refcount != 2, + "Refcount of plugin in registry+feature should be 2"); - fail_if (plugin->object.refcount != 2, - "Refcount of plugin in after list free should be 2"); - - gst_object_unref (plugin); + gst_object_unref (element_factory); } GST_END_TEST; @@ -228,6 +238,7 @@ gst_plugin_suite (void) suite_add_tcase (s, tc_chain); 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_registry_get_plugin_list); tcase_add_test (tc_chain, test_find_feature); diff --git a/common b/common index 39250a9..3f8b422 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 39250a956e1dfc010fe9f9d93ca1e2c3a343cdca +Subproject commit 3f8b422d851dc64797cdd97dd7a2014acd751386 diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 932466f..180d301 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -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_LOG_OBJECT (factory, "Created new elementfactory for type %s", g_type_name (type)); - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); klass = GST_ELEMENT_CLASS (g_type_class_ref (type)); factory->type = type; @@ -304,7 +303,12 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank, } 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 (factory)->loaded = TRUE; + + gst_registry_add_feature (gst_registry_get_default (), + GST_PLUGIN_FEATURE (factory)); return TRUE; @@ -332,6 +336,7 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name) g_return_val_if_fail (factory != NULL, NULL); + gst_object_ref (factory); factory = GST_ELEMENT_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE (factory))); @@ -367,6 +372,8 @@ gst_element_factory_create (GstElementFactory * factory, const gchar * name) gst_object_set_name (GST_OBJECT (element), name); GST_DEBUG ("created \"%s\"", GST_PLUGIN_FEATURE_NAME (factory)); + gst_object_unref (factory); + return element; } diff --git a/gst/gstplugin.c b/gst/gstplugin.c index 5787cc0..3cc6bcd 100644 --- a/gst/gstplugin.c +++ b/gst/gstplugin.c @@ -94,7 +94,7 @@ gst_plugin_finalize (GstPlugin * plugin) GstRegistry *registry = gst_registry_get_default (); GList *g; - GST_ERROR ("finalizing plugin %p", plugin); + GST_DEBUG ("finalizing plugin %p", plugin); for (g = registry->plugins; g; g = g->next) { if (g->data == (gpointer) plugin) { g_warning ("removing plugin that is still in registry"); @@ -335,12 +335,15 @@ gst_plugin_load_file (const gchar * filename, GError ** error) g_static_mutex_lock (&gst_plugin_loading_mutex); plugin = gst_registry_lookup (registry, filename); - if (plugin && plugin->module) { - g_static_mutex_unlock (&gst_plugin_loading_mutex); - return plugin; + if (plugin) { + if (plugin->module) { + g_static_mutex_unlock (&gst_plugin_loading_mutex); + return plugin; + } else { + gst_object_unref (plugin); + } } - GST_CAT_DEBUG (GST_CAT_PLUGIN_LOADING, "attempt to load plugin \"%s\"", filename); @@ -617,9 +620,10 @@ gst_plugin_is_loaded (GstPlugin * plugin) { 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: * @plugin: plugin to query @@ -704,6 +708,7 @@ gst_plugin_list_feature_filter (GList * list, return data.result; } +#endif /** * 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)); } +#if 0 /** * gst_plugin_find_feature: * @plugin: plugin to get the feature from @@ -749,19 +755,23 @@ gst_plugin_find_feature (GstPlugin * plugin, const gchar * name, GType type) if (walk) { result = GST_PLUGIN_FEATURE (walk->data); - gst_object_ref (result->plugin); + gst_object_ref (result); gst_plugin_feature_list_free (walk); } return result; } +#endif +#if 0 static gboolean gst_plugin_feature_name_filter (GstPluginFeature * feature, const gchar * name) { return !strcmp (name, GST_PLUGIN_FEATURE_NAME (feature)); } +#endif +#if 0 /** * gst_plugin_find_feature_by_name: * @plugin: plugin to get the feature from @@ -785,74 +795,24 @@ gst_plugin_find_feature_by_name (GstPlugin * plugin, const gchar * name) if (walk) { result = GST_PLUGIN_FEATURE (walk->data); - gst_object_ref (result->plugin); + gst_object_ref (result); gst_plugin_feature_list_free (walk); } return result; } +#endif /** - * gst_plugin_add_feature: - * @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: + * gst_plugin_load_by_name: * @name: name of plugin to load * * Load the named plugin. * * Returns: whether the plugin was loaded or not */ -gboolean -gst_plugin_load_1 (const gchar * name) +GstPlugin * +gst_plugin_load_by_name (const gchar * name) { GstPlugin *plugin; GError *error = NULL; @@ -863,13 +823,13 @@ gst_plugin_load_1 (const gchar * name) if (!plugin) { GST_WARNING ("load_plugin error: %s\n", error->message); g_error_free (error); - return FALSE; + return NULL; } - return TRUE;; + return plugin; } - GST_DEBUG ("Could not find %s in registry pool", name); - return FALSE; + GST_DEBUG ("Could not find plugin %s in registry", name); + return NULL; } GstPlugin * @@ -882,20 +842,15 @@ gst_plugin_load (GstPlugin * plugin) return plugin; } - if (!plugin->filename) { - return plugin; - } - newplugin = gst_plugin_load_file (plugin->filename, &error); if (newplugin == NULL) { GST_WARNING ("load_plugin error: %s\n", error->message); g_error_free (error); - //gst_object_unref (plugin); + gst_object_unref (plugin); return NULL; } - /* FIXME hack to keep plugins from disappearing */ - //gst_object_unref (plugin); + gst_object_unref (plugin); return newplugin; } @@ -906,7 +861,7 @@ gst_plugin_list_free (GList * list) GList *g; 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); } diff --git a/gst/gstplugin.h b/gst/gstplugin.h index a87a2cd..ec6e1d1 100644 --- a/gst/gstplugin.h +++ b/gst/gstplugin.h @@ -90,8 +90,6 @@ struct _GstPlugin { unsigned int flags; gchar * filename; - GList * features; /* list of features provided */ - gint numfeatures; 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); 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); -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); 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_by_name (const gchar *name); -/* shortcuts to load from the registry pool */ -gboolean gst_plugin_load_1 (const gchar *name); +void gst_plugin_list_free (GList *list); G_END_DECLS diff --git a/gst/gstpluginfeature.c b/gst/gstpluginfeature.c index a51f567..795a5ad 100644 --- a/gst/gstpluginfeature.c +++ b/gst/gstpluginfeature.c @@ -31,15 +31,18 @@ static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass); 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 }; */ -G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, G_TYPE_OBJECT); +G_DEFINE_ABSTRACT_TYPE (GstPluginFeature, gst_plugin_feature, GST_TYPE_OBJECT); static void gst_plugin_feature_class_init (GstPluginFeatureClass * klass) { + G_OBJECT_CLASS (klass)->finalize = + (GObjectFinalizeFunc) gst_plugin_feature_finalize; } 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: * @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 (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) { g_critical ("Failed to load plugin containing feature '%s'.", GST_PLUGIN_FEATURE_NAME (feature)); return NULL; } - if (plugin == feature->plugin) { - return feature; - } + gst_object_unref (plugin); - 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) { g_critical ("Loaded plugin containing feature '%s', but feature disappeared.", feature->name); } - //gst_object_unref (feature->plugin); + gst_object_unref (feature); + return real_feature; } @@ -117,6 +129,7 @@ gst_plugin_feature_set_name (GstPluginFeature * feature, const gchar * name) } else { 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 gst_plugin_feature_list_free (GList * list) { -#if 0 GList *g; for (g = list; g; g = g->next) { GstPluginFeature *feature = GST_PLUGIN_FEATURE (g->data); - //gst_object_unref (feature->plugin); + gst_object_unref (feature); } -#endif g_list_free (list); } diff --git a/gst/gstpluginfeature.h b/gst/gstpluginfeature.h index 1ae5545..0fa88f7 100644 --- a/gst/gstpluginfeature.h +++ b/gst/gstpluginfeature.h @@ -25,6 +25,7 @@ #define __GST_PLUGIN_FEATURE_H__ #include +#include G_BEGIN_DECLS @@ -49,20 +50,22 @@ typedef enum { } GstRank; struct _GstPluginFeature { - GObject object; + GstObject object; /*< private >*/ + gboolean loaded; gchar *name; guint rank; - struct _GstPlugin *plugin; + //struct _GstPlugin *plugin; + gchar *plugin_name; /*< private >*/ gpointer _gst_reserved[GST_PADDING]; }; struct _GstPluginFeatureClass { - GObjectClass parent_class; + GstObjectClass parent_class; /*< private >*/ gpointer _gst_reserved[GST_PADDING]; diff --git a/gst/gstregistry.c b/gst/gstregistry.c index 349b913..035e02b 100644 --- a/gst/gstregistry.c +++ b/gst/gstregistry.c @@ -111,6 +111,7 @@ enum { PLUGIN_ADDED, + FEATURE_ADDED, LAST_SIGNAL }; @@ -119,6 +120,8 @@ static void gst_registry_init (GstRegistry * registry); 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, 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_RUN_LAST, G_STRUCT_OFFSET (GstRegistryClass, plugin_added), NULL, 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; } @@ -235,7 +242,7 @@ gst_registry_add_plugin (GstRegistry * registry, GstPlugin * plugin) GST_DEBUG ("Replacing existing plugin %p for filename \"%s\"", existing_plugin, plugin->filename); 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); @@ -268,7 +275,69 @@ gst_registry_remove_plugin (GstRegistry * registry, GstPlugin * plugin) GST_LOCK (registry); registry->plugins = g_list_remove (registry->plugins, plugin); 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) { GList *list; + GList *g; g_return_val_if_fail (GST_IS_REGISTRY (registry), NULL); GST_LOCK (registry); - list = gst_plugin_list_feature_filter (registry->plugins, filter, first, + list = gst_filter_run (registry->features, (GstFilterFunc) filter, first, user_data); + for (g = list; g; g = g->next) { + gst_object_ref (GST_PLUGIN_FEATURE (g->data)); + } GST_UNLOCK (registry); return list; @@ -396,7 +469,7 @@ gst_registry_find_feature (GstRegistry * registry, const gchar * name, if (walk) { feature = GST_PLUGIN_FEATURE (walk->data); - gst_object_ref (feature->plugin); + gst_object_ref (feature); gst_plugin_feature_list_free (walk); } @@ -432,6 +505,39 @@ gst_registry_get_plugin_list (GstRegistry * registry) 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 * gst_registry_lookup_locked (GstRegistry * registry, const char *filename) { @@ -458,6 +564,8 @@ gst_registry_lookup (GstRegistry * registry, const char *filename) GST_LOCK (registry); plugin = gst_registry_lookup_locked (registry, filename); + if (plugin) + gst_object_ref (plugin); GST_UNLOCK (registry); return plugin; @@ -471,6 +579,7 @@ gst_registry_scan_path_level (GstRegistry * registry, const gchar * path, const gchar *dirent; gchar *filename; GstPlugin *plugin; + GstPlugin *newplugin; dir = g_dir_open (path, 0, NULL); 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, plugin->file_size, file_status.st_size); 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 { - gst_plugin_load_file (filename, NULL); + newplugin = gst_plugin_load_file (filename, NULL); + gst_object_unref (newplugin); } g_free (filename); @@ -570,3 +682,19 @@ _gst_registry_remove_cache_plugins (GstRegistry * registry) 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); +} diff --git a/gst/gstregistry.h b/gst/gstregistry.h index 5db5e17..359d1cb 100644 --- a/gst/gstregistry.h +++ b/gst/gstregistry.h @@ -42,6 +42,7 @@ struct _GstRegistry { GstObject object; GList *plugins; + GList *features; GList *paths; @@ -56,6 +57,7 @@ struct _GstRegistryClass { /* signals */ void (*plugin_added) (GstRegistry *registry, GstPlugin *plugin); + void (*feature_added) (GstRegistry *registry, GstPluginFeature *feature); 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); 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_plugin_filter (GstRegistry *registry, @@ -83,10 +87,12 @@ GList* gst_registry_feature_filter (GstRegistry *registry, gpointer user_data); GList * gst_registry_get_feature_list (GstRegistry *registry, 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); GstPluginFeature* gst_registry_find_feature (GstRegistry *registry, const gchar *name, GType type); 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_write_cache (GstRegistry * registry, const char *location); diff --git a/gst/gstregistryxml.c b/gst/gstregistryxml.c index fe5405c..ea84ea0 100644 --- a/gst/gstregistryxml.c +++ b/gst/gstregistryxml.c @@ -604,11 +604,13 @@ load_feature (xmlTextReaderPtr reader) } static GstPlugin * -load_plugin (xmlTextReaderPtr reader) +load_plugin (xmlTextReaderPtr reader, GList ** feature_list) { int ret; GstPlugin *plugin = g_object_new (GST_TYPE_PLUGIN, NULL); + *feature_list = NULL; + GST_DEBUG ("parsing plugin"); plugin->flags |= GST_PLUGIN_FLAG_CACHED; @@ -673,8 +675,11 @@ load_plugin (xmlTextReaderPtr reader) } else if (g_str_equal (tag, "feature")) { GstPluginFeature *feature = load_feature (reader); - if (feature) - gst_plugin_add_feature (plugin, feature); + feature->plugin_name = g_strdup (plugin->desc.name); + + if (feature) { + *feature_list = g_list_prepend (*feature_list, feature); + } } else { 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); if (g_str_equal (tag, "plugin")) { - GstPlugin *plugin = load_plugin (reader); + GList *feature_list; + GstPlugin *plugin = load_plugin (reader, &feature_list); if (plugin) { - GST_DEBUG ("adding plugin %s with %d features", plugin->desc.name, - plugin->numfeatures); + GList *g; + + GST_DEBUG ("adding plugin %s", plugin->desc.name); 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 gst_registry_xml_save_plugin (GstRegistry * registry, GstPlugin * plugin) { + GList *list; GList *walk; char s[100]; @@ -933,18 +945,19 @@ gst_registry_xml_save_plugin (GstRegistry * registry, GstPlugin * plugin) PUT_ESCAPED (" ", "package", plugin->desc.package); 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); gst_registry_xml_save (registry, " \n", g_type_name (G_OBJECT_TYPE (feature))); gst_registry_xml_save_feature (registry, feature); gst_registry_xml_save (registry, " \n"); - - walk = g_list_next (walk); } + + gst_plugin_feature_list_free (list); + return TRUE; } diff --git a/gst/gsttypefind.c b/gst/gsttypefind.c index 87cd74d..b59591e 100644 --- a/gst/gsttypefind.c +++ b/gst/gsttypefind.c @@ -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); g_assert (GST_IS_TYPE_FIND_FACTORY (factory)); 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); 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); factory->function = func; 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; } diff --git a/gst/gsttypefindfactory.c b/gst/gsttypefindfactory.c index 0157093..bc6de2b 100644 --- a/gst/gsttypefindfactory.c +++ b/gst/gsttypefindfactory.c @@ -225,7 +225,7 @@ gst_type_find_factory_call_function (GstTypeFindFactory * factory, g_return_if_fail (find->suggest != NULL); /* gst_plugin_feature_load will steal our ref */ - gst_object_ref (factory->feature.plugin); + gst_object_ref (factory); new_factory = GST_TYPE_FIND_FACTORY (gst_plugin_feature_load (GST_PLUGIN_FEATURE (factory))); @@ -233,8 +233,6 @@ gst_type_find_factory_call_function (GstTypeFindFactory * factory, g_assert (new_factory->function != NULL); new_factory->function (find, new_factory->user_data); - /* FIXME hack. somehow, this refcount gets destroyed */ - gst_object_ref (new_factory->feature.plugin); - //gst_object_unref (new_factory->feature.plugin); + gst_object_unref (new_factory); } } diff --git a/gst/indexers/gstfileindex.c b/gst/indexers/gstfileindex.c index d0ef6eb..4789eab 100644 --- a/gst/indexers/gstfileindex.c +++ b/gst/indexers/gstfileindex.c @@ -992,11 +992,16 @@ gst_file_index_plugin_init (GstPlugin * plugin) factory = gst_index_factory_new ("fileindex", "A index that stores entries in file", gst_file_index_get_type ()); - if (factory != NULL) { - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } else { + if (factory == NULL) { 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); return TRUE; diff --git a/gst/indexers/gstmemindex.c b/gst/indexers/gstmemindex.c index c3ef4c2..8c75264 100644 --- a/gst/indexers/gstmemindex.c +++ b/gst/indexers/gstmemindex.c @@ -411,10 +411,16 @@ gst_mem_index_plugin_init (GstPlugin * plugin) factory = gst_index_factory_new ("memindex", "A index that stores entries in memory", gst_mem_index_get_type ()); - if (factory != NULL) { - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } else { - g_warning ("could not register memindex"); + if (factory == NULL) { + g_warning ("failed to create memindex factory"); + 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)); + return TRUE; } diff --git a/gst/schedulers/Makefile.am b/gst/schedulers/Makefile.am deleted file mode 100644 index 022a0a3..0000000 --- a/gst/schedulers/Makefile.am +++ /dev/null @@ -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 = - diff --git a/plugins/indexers/gstfileindex.c b/plugins/indexers/gstfileindex.c index d0ef6eb..4789eab 100644 --- a/plugins/indexers/gstfileindex.c +++ b/plugins/indexers/gstfileindex.c @@ -992,11 +992,16 @@ gst_file_index_plugin_init (GstPlugin * plugin) factory = gst_index_factory_new ("fileindex", "A index that stores entries in file", gst_file_index_get_type ()); - if (factory != NULL) { - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } else { + if (factory == NULL) { 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); return TRUE; diff --git a/plugins/indexers/gstmemindex.c b/plugins/indexers/gstmemindex.c index c3ef4c2..8c75264 100644 --- a/plugins/indexers/gstmemindex.c +++ b/plugins/indexers/gstmemindex.c @@ -411,10 +411,16 @@ gst_mem_index_plugin_init (GstPlugin * plugin) factory = gst_index_factory_new ("memindex", "A index that stores entries in memory", gst_mem_index_get_type ()); - if (factory != NULL) { - gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); - } else { - g_warning ("could not register memindex"); + if (factory == NULL) { + g_warning ("failed to create memindex factory"); + 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)); + return TRUE; } diff --git a/tests/check/Makefile.am b/tests/check/Makefile.am index 92cff19..3d8dfca 100644 --- a/tests/check/Makefile.am +++ b/tests/check/Makefile.am @@ -10,7 +10,7 @@ REGISTRY_ENVIRONMENT = \ TESTS_ENVIRONMENT = \ $(REGISTRY_ENVIRONMENT) \ 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@ diff --git a/tests/check/gst/gstplugin.c b/tests/check/gst/gstplugin.c index 446d77f..325cd2e 100644 --- a/tests/check/gst/gstplugin.c +++ b/tests/check/gst/gstplugin.c @@ -59,6 +59,32 @@ GST_START_TEST (test_register_static) 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) { GstPlugin *unloaded_plugin; @@ -66,17 +92,22 @@ GST_START_TEST (test_load_gstelements) unloaded_plugin = gst_default_registry_find_plugin ("gstelements"); 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"); + GST_DEBUG ("refcount %d", GST_OBJECT (unloaded_plugin)->refcount); gst_object_ref (unloaded_plugin); loaded_plugin = gst_plugin_load (unloaded_plugin); fail_if (loaded_plugin == NULL, "Failed to load plugin"); - fail_if (loaded_plugin->object.refcount != 2, - "Refcount of loaded plugin in registry should be 2"); - fail_if (unloaded_plugin->object.refcount != 1, - "Refcount of replaced plugin in registry should be 1"); + if (loaded_plugin != unloaded_plugin) { + fail_if (GST_OBJECT (loaded_plugin)->refcount != 2, + "Refcount of loaded plugin in registry should be 2"); + GST_DEBUG ("refcount %d", GST_OBJECT (loaded_plugin)->refcount); + 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 (loaded_plugin); @@ -90,7 +121,7 @@ GST_START_TEST (test_registry_get_plugin_list) GstPlugin *plugin; 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"); 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); - fail_if (plugin->object.refcount != 2, + fail_if (GST_OBJECT (plugin)->refcount != 2, "Refcount of plugin in after list free should be 2"); gst_object_unref (plugin); @@ -110,55 +141,34 @@ GST_END_TEST; GST_START_TEST (test_find_feature) { - GstPlugin *plugin; 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 (), "identity", GST_TYPE_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"); - fail_if (plugin->object.refcount != 3, - "Refcount of plugin in registry+feature should be 3"); - - gst_object_unref (feature->plugin); - - fail_if (plugin->object.refcount != 2, - "Refcount of plugin in after list free should be 2"); + fail_if (GST_OBJECT (feature)->refcount != 2, + "Refcount of feature should be 2"); + GST_DEBUG ("refcount %d", GST_OBJECT (feature)->refcount); - gst_object_unref (plugin); + gst_object_unref (feature); } GST_END_TEST; GST_START_TEST (test_find_element) { - GstPlugin *plugin; 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"); 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, - "Refcount of plugin in registry+feature should be 3"); - gst_object_unref (GST_PLUGIN_FEATURE (element_factory)->plugin); + fail_if (GST_OBJECT (element_factory)->refcount != 2, + "Refcount of plugin in registry+feature should be 2"); - fail_if (plugin->object.refcount != 2, - "Refcount of plugin in after list free should be 2"); - - gst_object_unref (plugin); + gst_object_unref (element_factory); } GST_END_TEST; @@ -228,6 +238,7 @@ gst_plugin_suite (void) suite_add_tcase (s, tc_chain); 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_registry_get_plugin_list); tcase_add_test (tc_chain, test_find_feature); diff --git a/tools/gst-inspect.c b/tools/gst-inspect.c index 43c4ff1..4e16438 100644 --- a/tools/gst-inspect.c +++ b/tools/gst-inspect.c @@ -835,7 +835,9 @@ print_element_list (gboolean print_all) plugin = (GstPlugin *) (plugins->data); 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) { GstPluginFeature *feature; @@ -920,7 +922,9 @@ print_plugin_features (GstPlugin * plugin) gint num_indexes = 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) { GstPluginFeature *feature; @@ -1037,10 +1041,14 @@ print_element_info (GstElementFactory * factory, gboolean print_names) _name = ""; print_factory_details_info (factory); - if (GST_PLUGIN_FEATURE (factory)->plugin) { - GstPlugin *plugin = (GstPlugin *) GST_PLUGIN_FEATURE (factory)->plugin; + if (GST_PLUGIN_FEATURE (factory)->plugin_name) { + GstPlugin *plugin; - print_plugin_info (plugin); + plugin = gst_registry_find_plugin (gst_registry_get_default (), + GST_PLUGIN_FEATURE (factory)->plugin_name); + if (plugin) { + print_plugin_info (plugin); + } } print_hierarchy (G_OBJECT_TYPE (element), 0, &maxlevel); @@ -1062,15 +1070,19 @@ print_element_info (GstElementFactory * factory, gboolean print_names) 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 main (int argc, char *argv[]) { - gboolean print_all = FALSE; - struct poptOption options[] = { - {"print-all", 'a', POPT_ARG_NONE | POPT_ARGFLAG_STRIP, &print_all, 0, - N_("Print all elements"), NULL}, - POPT_TABLEEND - }; + GOptionContext *context; + GError *error = NULL; #ifdef GETTEXT_PACKAGE bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); @@ -1078,7 +1090,12 @@ main (int argc, char *argv[]) textdomain (GETTEXT_PACKAGE); #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) { g_print ("-a requires no extra arguments\n"); diff --git a/tools/gst-xmlinspect.c b/tools/gst-xmlinspect.c index 1acbbf3..e312b46 100644 --- a/tools/gst-xmlinspect.c +++ b/tools/gst-xmlinspect.c @@ -620,7 +620,9 @@ print_element_list (void) plugin = (GstPlugin *) (plugins->data); 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) { GstPluginFeature *feature; @@ -688,7 +690,9 @@ print_plugin_info (GstPlugin * plugin) g_print (" Origin URL:\t%s\n", plugin->desc.origin); 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) { GstPluginFeature *feature;