From 9abb3e0669878ab2b7b1df8b318b85bb5c75856e Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 2 Nov 2003 16:46:12 +0000 Subject: [PATCH] XML, gst-editor, gst-rec and anything that's not based on spider is now broken. This re-fixes it. Original commit message from CVS: XML, gst-editor, gst-rec and anything that's not based on spider is now broken. This re-fixes it. --- gst/gstelement.c | 25 +++++++++++++++++++++++++ gst/gstelement.h | 7 ++++++- gst/gstelementfactory.c | 47 ++++++++++------------------------------------- 3 files changed, 41 insertions(+), 38 deletions(-) diff --git a/gst/gstelement.c b/gst/gstelement.c index d76f4cb..2b0aaab 100644 --- a/gst/gstelement.c +++ b/gst/gstelement.c @@ -147,6 +147,8 @@ gst_element_class_init (GstElementClass *klass) klass->error = GST_DEBUG_FUNCPTR (gst_element_error_func); klass->padtemplates = NULL; klass->numpadtemplates = 0; + + klass->elementfactory = NULL; } static void @@ -2549,6 +2551,22 @@ failure: return GST_STATE_FAILURE; } +/** + * gst_element_get_factory: + * @element: a #GstElement to request the element factory of. + * + * Retrieves the factory that was used to create this element. + * + * Returns: the #GstElementFactory used for creating this element. + */ +GstElementFactory* +gst_element_get_factory (GstElement *element) +{ + g_return_val_if_fail (GST_IS_ELEMENT (element), NULL); + + return GST_ELEMENT_GET_CLASS (element)->elementfactory; +} + static void gst_element_dispose (GObject *object) { @@ -2628,6 +2646,13 @@ gst_element_save_thyself (GstObject *object, xmlNewChild(parent, NULL, "name", GST_ELEMENT_NAME(element)); + if (oclass->elementfactory != NULL) { + GstElementFactory *factory = (GstElementFactory *)oclass->elementfactory; + + xmlNewChild (parent, NULL, "type", + GST_PLUGIN_FEATURE (factory)->name); + } + /* FIXME: what is this? */ /* if (element->manager) */ /* xmlNewChild(parent, NULL, "manager", GST_ELEMENT_NAME(element->manager)); */ diff --git a/gst/gstelement.h b/gst/gstelement.h index efd2e57..7efb5e9 100644 --- a/gst/gstelement.h +++ b/gst/gstelement.h @@ -192,6 +192,10 @@ struct _GstElementClass { /* the element details */ GstElementDetails details; + + /* factory that the element was created from */ + GstElementFactory *elementfactory; + /* templates for our pads */ GList *padtemplates; gint numpadtemplates; @@ -359,6 +363,8 @@ void gst_element_wait_state_change (GstElement *element); const gchar* gst_element_state_get_name (GstElementState state); +GstElementFactory* gst_element_get_factory (GstElement *element); + GstBin* gst_element_get_managing_bin (GstElement *element); @@ -403,7 +409,6 @@ gboolean gst_element_register (GstPlugin *plugin, GType type); GstElementFactory * gst_element_factory_find (const gchar *name); -GstElementFactory * gst_element_factory_find_from_element (GstElement *element); GType gst_element_factory_get_element_type (GstElementFactory *factory); G_CONST_RETURN gchar * gst_element_factory_get_longname (GstElementFactory *factory); G_CONST_RETURN gchar * gst_element_factory_get_klass (GstElementFactory *factory); diff --git a/gst/gstelementfactory.c b/gst/gstelementfactory.c index 8d65c05..577dabc 100644 --- a/gst/gstelementfactory.c +++ b/gst/gstelementfactory.c @@ -108,43 +108,7 @@ gst_element_factory_find (const gchar *name) GST_DEBUG ("no such elementfactory \"%s\"", name); return NULL; } -typedef struct { - GType type; -} MyGTypeData; -static gboolean -find_type_filter (GstPluginFeature *feature, gpointer data) -{ - GstElementFactory *factory; - - if (!GST_IS_ELEMENT_FACTORY (feature)) - return FALSE; - - factory = GST_ELEMENT_FACTORY (feature); - return factory->type == ((MyGTypeData *) data)->type; -} -GstElementFactory * -gst_element_factory_find_from_element (GstElement *element) -{ - GstElementFactory *factory; - GList *list; - MyGTypeData data; - - g_return_val_if_fail(GST_IS_ELEMENT (element), NULL); - - data.type = G_OBJECT_TYPE (element); - - list = gst_registry_pool_feature_filter (find_type_filter, TRUE, &data); - - if (!list) - return NULL; - - g_assert (g_list_next (list) == NULL); - factory = GST_ELEMENT_FACTORY (list->data); - g_list_free (list); - - return factory; -} void __gst_element_details_clear (GstElementDetails *dp) { @@ -248,6 +212,7 @@ gst_element_factory_create (GstElementFactory *factory, const gchar *name) { GstElement *element; + GstElementClass *oclass; g_return_val_if_fail (factory != NULL, NULL); @@ -265,10 +230,18 @@ gst_element_factory_create (GstElementFactory *factory, return NULL; } + oclass = GST_ELEMENT_CLASS (g_type_class_ref (factory->type)); + if (oclass->elementfactory == NULL) { + GST_DEBUG ("class %s", GST_PLUGIN_FEATURE_NAME (factory)); + oclass->elementfactory = factory; + } + /* create an instance of the element */ element = GST_ELEMENT (g_object_new (factory->type, NULL)); g_assert (element != NULL); + g_type_class_unref (oclass); + gst_object_set_name (GST_OBJECT (element), name); return element; @@ -363,7 +336,7 @@ gst_element_factory_get_longname (GstElementFactory *factory) * Returns: the class */ G_CONST_RETURN gchar * -gst_element_factory_get_class (GstElementFactory *factory) +gst_element_factory_get_klass (GstElementFactory *factory) { g_return_val_if_fail (GST_IS_ELEMENT_FACTORY (factory), NULL); -- 2.7.4