loadsave: fix requestpad handling and serialisation order.

Support request pads when loading. Reverse pad serialisation order to
preserve it when recreating the pipeline.
This commit is contained in:
Hannes Bistry 2009-05-20 10:56:11 +03:00 committed by Stefan Kost
parent fca63abbe7
commit b47f425069
3 changed files with 11 additions and 6 deletions

View file

@ -3611,12 +3611,12 @@ gst_bin_save_thyself (GstObject * object, xmlNodePtr parent)
GST_CAT_INFO (GST_CAT_XML, "[%s]: saving %d children",
GST_ELEMENT_NAME (bin), bin->numchildren);
children = bin->children;
children = g_list_last (bin->children);
while (children) {
child = GST_ELEMENT (children->data);
elementnode = xmlNewChild (childlist, NULL, (xmlChar *) "element", NULL);
gst_object_save_thyself (GST_OBJECT (child), elementnode);
children = g_list_next (children);
children = g_list_previous (children);
}
return childlist;
}

View file

@ -2886,7 +2886,7 @@ gst_element_save_thyself (GstObject * object, xmlNodePtr parent)
g_free (specs);
pads = GST_ELEMENT_PADS (element);
pads = g_list_last (GST_ELEMENT_PADS (element));
while (pads) {
GstPad *pad = GST_PAD_CAST (pads->data);
@ -2897,7 +2897,7 @@ gst_element_save_thyself (GstObject * object, xmlNodePtr parent)
gst_object_save_thyself (GST_OBJECT_CAST (pad), padtag);
}
pads = g_list_next (pads);
pads = g_list_previous (pads);
}
return parent;

View file

@ -3645,6 +3645,7 @@ gst_pad_load_and_link (xmlNodePtr self, GstObject * parent)
{
xmlNodePtr field = self->xmlChildrenNode;
GstPad *pad = NULL, *targetpad;
GstPadTemplate *tmpl;
gchar *peer = NULL;
gchar **split;
GstElement *target;
@ -3655,7 +3656,8 @@ gst_pad_load_and_link (xmlNodePtr self, GstObject * parent)
if (!strcmp ((char *) field->name, "name")) {
name = (gchar *) xmlNodeGetContent (field);
pad = gst_element_get_static_pad (GST_ELEMENT (parent), name);
if (!pad)
if ((!pad) || ((tmpl = gst_pad_get_pad_template (pad))
&& (GST_PAD_REQUEST == GST_PAD_TEMPLATE_PRESENCE (tmpl))))
pad = gst_element_get_request_pad (GST_ELEMENT (parent), name);
g_free (name);
} else if (!strcmp ((char *) field->name, "peer")) {
@ -3699,7 +3701,10 @@ gst_pad_load_and_link (xmlNodePtr self, GstObject * parent)
if (targetpad == NULL)
goto cleanup;
gst_pad_link (pad, targetpad);
if (gst_pad_get_direction (pad) == GST_PAD_SRC)
gst_pad_link (pad, targetpad);
else
gst_pad_link (targetpad, pad);
cleanup:
g_strfreev (split);