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.
This commit is contained in:
Ronald S. Bultje 2003-11-02 16:46:12 +00:00
parent 4180066759
commit 9abb3e0669
3 changed files with 41 additions and 38 deletions

View file

@ -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)); */

View file

@ -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);

View file

@ -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);