2000-12-28 22:12:02 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
|
|
|
* gstxml.c: XML save/restore of pipelines
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
2000-12-28 22:12:02 +00:00
|
|
|
#include "gst_private.h"
|
|
|
|
|
2000-12-15 01:57:34 +00:00
|
|
|
#include "gstxml.h"
|
2002-07-08 19:07:30 +00:00
|
|
|
#include "gstlog.h"
|
2001-01-08 22:08:40 +00:00
|
|
|
#include "gstbin.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
enum {
|
|
|
|
OBJECT_LOADED,
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2001-01-21 23:20:46 +00:00
|
|
|
static void gst_xml_class_init (GstXMLClass *klass);
|
2000-12-16 17:12:28 +00:00
|
|
|
static void gst_xml_init (GstXML *xml);
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2001-01-30 23:53:04 +00:00
|
|
|
static void gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, gpointer data);
|
|
|
|
|
2000-09-24 22:45:48 +00:00
|
|
|
static GstObjectClass *parent_class = NULL;
|
2001-01-29 00:06:02 +00:00
|
|
|
static guint gst_xml_signals[LAST_SIGNAL] = { 0 };
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
GType
|
2001-01-21 23:20:46 +00:00
|
|
|
gst_xml_get_type(void)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
static GType xml_type = 0;
|
2000-09-24 22:45:48 +00:00
|
|
|
|
|
|
|
if (!xml_type) {
|
2001-06-25 01:20:11 +00:00
|
|
|
static const GTypeInfo xml_info = {
|
2001-01-29 00:06:02 +00:00
|
|
|
sizeof(GstXMLClass),
|
2001-06-25 01:20:11 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
(GClassInitFunc)gst_xml_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstXML),
|
|
|
|
0,
|
|
|
|
(GInstanceInitFunc)gst_xml_init,
|
2001-09-14 22:16:47 +00:00
|
|
|
NULL
|
2000-09-24 22:45:48 +00:00
|
|
|
};
|
2002-03-31 14:04:50 +00:00
|
|
|
xml_type = g_type_register_static (GST_TYPE_OBJECT, "GstXML", &xml_info, 0);
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
return xml_type;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2001-01-21 23:20:46 +00:00
|
|
|
gst_xml_class_init (GstXMLClass *klass)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
GObjectClass *gobject_class;
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
gobject_class = (GObjectClass *)klass;
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
parent_class = g_type_class_ref (GST_TYPE_OBJECT);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
|
|
|
gst_xml_signals[OBJECT_LOADED] =
|
2001-08-13 19:00:13 +00:00
|
|
|
g_signal_new ("object_loaded", G_TYPE_FROM_CLASS(klass), G_SIGNAL_RUN_LAST,
|
2001-06-25 01:20:11 +00:00
|
|
|
G_STRUCT_OFFSET (GstXMLClass, object_loaded), NULL, NULL,
|
|
|
|
gst_marshal_VOID__OBJECT_POINTER, G_TYPE_NONE, 2,
|
|
|
|
GST_TYPE_OBJECT, G_TYPE_POINTER);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
|
2001-01-21 23:20:46 +00:00
|
|
|
static void
|
|
|
|
gst_xml_init(GstXML *xml)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
xml->topelements = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_xml_new:
|
|
|
|
*
|
|
|
|
* Create a new GstXML parser object.
|
|
|
|
*
|
|
|
|
* Returns: a pointer to a new GstXML object.
|
|
|
|
*/
|
|
|
|
GstXML*
|
|
|
|
gst_xml_new (void)
|
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
return GST_XML (g_object_new(GST_TYPE_XML,NULL));
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
|
2000-03-27 19:53:43 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_write:
|
|
|
|
* @element: The element to write out
|
|
|
|
*
|
2001-01-10 09:15:00 +00:00
|
|
|
* Converts the given element into an XML presentation.
|
2000-03-27 19:53:43 +00:00
|
|
|
*
|
|
|
|
* Returns: a pointer to an XML document
|
|
|
|
*/
|
2001-01-21 23:20:46 +00:00
|
|
|
xmlDocPtr
|
2003-06-09 13:14:35 +00:00
|
|
|
gst_xml_write (GstElement *element)
|
2000-12-25 01:33:06 +00:00
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
xmlDocPtr doc;
|
2001-01-29 00:06:02 +00:00
|
|
|
xmlNodePtr elementnode;
|
2003-06-09 12:28:06 +00:00
|
|
|
xmlNsPtr gst_ns;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-25 01:33:06 +00:00
|
|
|
doc = xmlNewDoc ("1.0");
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-01-11 15:49:47 +00:00
|
|
|
doc->xmlRootNode = xmlNewDocNode (doc, NULL, "gstreamer", NULL);
|
|
|
|
|
2003-06-09 12:28:06 +00:00
|
|
|
gst_ns = xmlNewNs (doc->xmlRootNode, "http://gstreamer.net/gst-core/1.0/", "gst");
|
2002-01-11 15:49:47 +00:00
|
|
|
|
2003-06-09 12:28:06 +00:00
|
|
|
elementnode = xmlNewChild (doc->xmlRootNode, gst_ns, "element", NULL);
|
2001-01-29 00:06:02 +00:00
|
|
|
|
|
|
|
gst_object_save_thyself (GST_OBJECT (element), elementnode);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
return doc;
|
|
|
|
}
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2002-01-11 01:48:17 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_write_file:
|
|
|
|
* @element: The element to write out
|
|
|
|
* @out: an open file, like stdout
|
|
|
|
*
|
|
|
|
* Converts the given element into XML and writes the formatted XML to an open
|
|
|
|
* file.
|
|
|
|
*
|
|
|
|
* Returns: number of bytes written on success, -1 otherwise.
|
|
|
|
*/
|
|
|
|
gint
|
2003-06-09 13:14:35 +00:00
|
|
|
gst_xml_write_file (GstElement *element, FILE *out)
|
2002-01-11 01:48:17 +00:00
|
|
|
{
|
|
|
|
xmlDocPtr cur;
|
2002-01-11 07:21:26 +00:00
|
|
|
#ifdef HAVE_LIBXML2
|
2002-01-11 01:48:17 +00:00
|
|
|
xmlOutputBufferPtr buf;
|
2002-01-11 07:21:26 +00:00
|
|
|
#endif
|
2002-01-11 01:48:17 +00:00
|
|
|
const char * encoding;
|
|
|
|
xmlCharEncodingHandlerPtr handler = NULL;
|
|
|
|
int indent;
|
|
|
|
gboolean ret;
|
|
|
|
|
|
|
|
cur = gst_xml_write (element);
|
|
|
|
if (!cur) return -1;
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBXML2
|
|
|
|
encoding = (const char *) cur->encoding;
|
|
|
|
|
|
|
|
if (encoding != NULL) {
|
|
|
|
xmlCharEncoding enc;
|
|
|
|
|
|
|
|
enc = xmlParseCharEncoding (encoding);
|
|
|
|
|
|
|
|
if (cur->charset != XML_CHAR_ENCODING_UTF8) {
|
|
|
|
xmlGenericError (xmlGenericErrorContext,
|
|
|
|
"xmlDocDump: document not in UTF8\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (enc != XML_CHAR_ENCODING_UTF8) {
|
|
|
|
handler = xmlFindCharEncodingHandler (encoding);
|
|
|
|
if (handler == NULL) {
|
|
|
|
xmlFree ((char *) cur->encoding);
|
|
|
|
cur->encoding = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
buf = xmlOutputBufferCreateFile (out, handler);
|
|
|
|
|
|
|
|
indent = xmlIndentTreeOutput;
|
|
|
|
xmlIndentTreeOutput = 1;
|
|
|
|
ret = xmlSaveFormatFileTo(buf, cur, NULL, 1);
|
|
|
|
xmlIndentTreeOutput = indent;
|
|
|
|
#else
|
2002-01-11 16:05:06 +00:00
|
|
|
/* apparently this doesn't return anything in libxml1 */
|
|
|
|
xmlDocDump (out, cur);
|
|
|
|
ret = 1;
|
2002-01-11 01:48:17 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2001-01-31 20:27:00 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_parse_doc:
|
|
|
|
* @xml: a pointer to a GstXML object
|
|
|
|
* @doc: a pointer to an xml document to parse
|
|
|
|
* @root: The name of the root object to build
|
|
|
|
*
|
|
|
|
* Fills the GstXML object with the elements from the
|
|
|
|
* xmlDocPtr.
|
|
|
|
*
|
|
|
|
* Returns: TRUE on success, FALSE otherwise
|
|
|
|
*/
|
2001-01-30 23:53:04 +00:00
|
|
|
gboolean
|
|
|
|
gst_xml_parse_doc (GstXML *xml, xmlDocPtr doc, const guchar *root)
|
2000-12-16 17:12:28 +00:00
|
|
|
{
|
2001-01-29 00:06:02 +00:00
|
|
|
xmlNodePtr field, cur;
|
|
|
|
xmlNsPtr ns;
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
cur = xmlDocGetRootElement(doc);
|
|
|
|
if (cur == NULL) {
|
|
|
|
g_warning("gstxml: empty document\n");
|
|
|
|
return FALSE ;
|
|
|
|
}
|
|
|
|
ns = xmlSearchNsByHref(doc, cur, "http://gstreamer.net/gst-core/1.0/");
|
|
|
|
if (ns == NULL) {
|
|
|
|
g_warning("gstxml: document of wrong type, core namespace not found\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
2001-01-29 23:50:29 +00:00
|
|
|
if (strcmp(cur->name, "gstreamer")) {
|
2001-01-21 23:20:46 +00:00
|
|
|
g_warning("gstxml: XML file is in wrong format\n");
|
2001-01-29 00:06:02 +00:00
|
|
|
return FALSE;
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
gst_class_signal_connect (GST_OBJECT_CLASS (G_OBJECT_GET_CLASS(xml)),
|
2001-01-30 23:53:04 +00:00
|
|
|
"object_loaded", gst_xml_object_loaded, xml);
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
xml->ns = ns;
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
field = cur->xmlChildrenNode;
|
2001-01-21 23:20:46 +00:00
|
|
|
|
2000-09-27 19:33:10 +00:00
|
|
|
while (field) {
|
2001-01-29 00:06:02 +00:00
|
|
|
if (!strcmp(field->name, "element") && (field->ns == xml->ns)) {
|
2000-12-16 17:12:28 +00:00
|
|
|
GstElement *element;
|
2001-01-21 23:20:46 +00:00
|
|
|
|
2002-01-11 15:49:47 +00:00
|
|
|
element = gst_xml_make_element (field, NULL);
|
2000-12-16 17:12:28 +00:00
|
|
|
|
|
|
|
xml->topelements = g_list_prepend (xml->topelements, element);
|
2000-09-27 19:33:10 +00:00
|
|
|
}
|
|
|
|
field = field->next;
|
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
xml->topelements = g_list_reverse (xml->topelements);
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
return TRUE;
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
|
|
|
|
2001-01-21 23:20:46 +00:00
|
|
|
/**
|
2001-01-29 00:06:02 +00:00
|
|
|
* gst_xml_parse_file:
|
2001-01-31 20:27:00 +00:00
|
|
|
* @xml: a pointer to a GstXML object
|
2001-01-21 23:20:46 +00:00
|
|
|
* @fname: The filename with the xml description
|
|
|
|
* @root: The name of the root object to build
|
|
|
|
*
|
2001-01-31 20:27:00 +00:00
|
|
|
* Fills the GstXML object with the corresponding elements from
|
2001-01-21 23:20:46 +00:00
|
|
|
* the XML file fname. Optionally it will only build the element from
|
|
|
|
* the element node root (if it is not NULL). This feature is useful
|
|
|
|
* if you only want to build a specific element from an XML file
|
2001-01-31 20:27:00 +00:00
|
|
|
* but not the pipeline it is embedded in.
|
2001-01-21 23:20:46 +00:00
|
|
|
*
|
2002-01-18 22:44:19 +00:00
|
|
|
* Pass "-" as fname to read from stdin. You can also pass a URI
|
|
|
|
* of any format that libxml supports, including http.
|
|
|
|
*
|
2001-01-29 00:06:02 +00:00
|
|
|
* Returns: TRUE on success, FALSE otherwise
|
2001-01-21 23:20:46 +00:00
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gboolean
|
|
|
|
gst_xml_parse_file (GstXML *xml, const guchar *fname, const guchar *root)
|
2001-01-21 23:20:46 +00:00
|
|
|
{
|
|
|
|
xmlDocPtr doc;
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
g_return_val_if_fail(fname != NULL, FALSE);
|
2001-01-21 23:20:46 +00:00
|
|
|
|
|
|
|
doc = xmlParseFile(fname);
|
|
|
|
|
|
|
|
if (!doc) {
|
|
|
|
g_warning("gstxml: XML file \"%s\" could not be read\n", fname);
|
2001-01-29 00:06:02 +00:00
|
|
|
return FALSE;
|
2001-01-21 23:20:46 +00:00
|
|
|
}
|
|
|
|
|
2001-01-30 23:53:04 +00:00
|
|
|
return gst_xml_parse_doc (xml, doc, root);
|
2001-01-21 23:20:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2001-01-29 00:06:02 +00:00
|
|
|
* gst_xml_parse_memory:
|
2001-01-31 20:27:00 +00:00
|
|
|
* @xml: a pointer to a GstXML object
|
2001-01-21 23:20:46 +00:00
|
|
|
* @buffer: a pointer to the in memory XML buffer
|
|
|
|
* @size: the size of the buffer
|
|
|
|
* @root: the name of the root objects to build
|
|
|
|
*
|
2001-01-31 20:27:00 +00:00
|
|
|
* Fills the GstXML object with the corresponding elements from
|
2001-01-21 23:20:46 +00:00
|
|
|
* an in memory XML buffer.
|
|
|
|
*
|
2001-01-31 20:27:00 +00:00
|
|
|
* Returns: TRUE on success
|
2001-01-21 23:20:46 +00:00
|
|
|
*/
|
2001-01-29 00:06:02 +00:00
|
|
|
gboolean
|
|
|
|
gst_xml_parse_memory (GstXML *xml, guchar *buffer, guint size, const gchar *root)
|
2001-01-21 23:20:46 +00:00
|
|
|
{
|
|
|
|
xmlDocPtr doc;
|
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
g_return_val_if_fail(buffer != NULL, FALSE);
|
2001-01-21 23:20:46 +00:00
|
|
|
|
|
|
|
doc = xmlParseMemory (buffer, size);
|
|
|
|
|
2001-01-30 23:53:04 +00:00
|
|
|
return gst_xml_parse_doc (xml, doc, root);
|
2001-01-29 00:06:02 +00:00
|
|
|
}
|
|
|
|
|
2001-01-30 23:53:04 +00:00
|
|
|
static void
|
|
|
|
gst_xml_object_loaded (GstObject *private, GstObject *object, xmlNodePtr self, gpointer data)
|
2001-01-29 00:06:02 +00:00
|
|
|
{
|
2001-01-30 23:53:04 +00:00
|
|
|
GstXML *xml = GST_XML (data);
|
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* FIXME check that this element was created from the same xmlDocPtr...*/
|
2001-06-25 01:20:11 +00:00
|
|
|
g_signal_emit (G_OBJECT (xml), gst_xml_signals[OBJECT_LOADED], 0, object, self);
|
2001-01-21 23:20:46 +00:00
|
|
|
}
|
|
|
|
|
2000-12-16 17:12:28 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_get_topelements:
|
|
|
|
* @xml: The GstXML to get the elements from
|
|
|
|
*
|
2001-01-10 09:15:00 +00:00
|
|
|
* Retrive a list of toplevel elements.
|
2000-12-16 17:12:28 +00:00
|
|
|
*
|
|
|
|
* Returns: a GList of elements
|
|
|
|
*/
|
|
|
|
GList*
|
2001-01-21 23:20:46 +00:00
|
|
|
gst_xml_get_topelements (GstXML *xml)
|
2000-12-16 17:12:28 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (xml != NULL, NULL);
|
|
|
|
|
|
|
|
return xml->topelements;
|
|
|
|
}
|
|
|
|
|
2000-09-24 22:45:48 +00:00
|
|
|
/**
|
|
|
|
* gst_xml_get_element:
|
|
|
|
* @xml: The GstXML to get the element from
|
|
|
|
* @name: The name of element to retreive
|
|
|
|
*
|
2001-01-21 23:20:46 +00:00
|
|
|
* This function is used to get a pointer to the GstElement corresponding
|
|
|
|
* to name in the pipeline description. You would use this if you have
|
2000-09-24 22:45:48 +00:00
|
|
|
* to do anything to the element after loading.
|
|
|
|
*
|
|
|
|
* Returns: a pointer to a new GstElement
|
|
|
|
*/
|
2000-12-16 17:12:28 +00:00
|
|
|
GstElement*
|
2001-01-21 23:20:46 +00:00
|
|
|
gst_xml_get_element (GstXML *xml, const guchar *name)
|
2000-12-16 17:12:28 +00:00
|
|
|
{
|
2000-09-27 19:33:10 +00:00
|
|
|
GstElement *element;
|
2001-01-08 22:08:40 +00:00
|
|
|
GList *topelements;
|
2000-09-24 22:45:48 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail(xml != NULL, NULL);
|
|
|
|
g_return_val_if_fail(name != NULL, NULL);
|
|
|
|
|
2002-03-24 22:07:09 +00:00
|
|
|
GST_DEBUG (0,"gstxml: getting element \"%s\"", name);
|
2000-09-27 19:33:10 +00:00
|
|
|
|
2001-01-08 22:08:40 +00:00
|
|
|
topelements = gst_xml_get_topelements (xml);
|
2000-09-24 22:45:48 +00:00
|
|
|
|
2001-01-08 22:08:40 +00:00
|
|
|
while (topelements) {
|
|
|
|
GstElement *top = GST_ELEMENT (topelements->data);
|
|
|
|
|
2002-03-24 22:07:09 +00:00
|
|
|
GST_DEBUG (0,"gstxml: getting element \"%s\"", name);
|
2001-01-29 00:06:02 +00:00
|
|
|
if (!strcmp (GST_ELEMENT_NAME (top), name)) {
|
2001-01-08 22:08:40 +00:00
|
|
|
return top;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (GST_IS_BIN (top)) {
|
|
|
|
element = gst_bin_get_by_name (GST_BIN (top), name);
|
|
|
|
|
2001-01-21 23:20:46 +00:00
|
|
|
if (element)
|
2001-01-08 22:08:40 +00:00
|
|
|
return element;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
topelements = g_list_next (topelements);
|
|
|
|
}
|
|
|
|
return NULL;
|
2000-09-24 22:45:48 +00:00
|
|
|
}
|
2002-01-11 15:49:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* gst_xml_make_element:
|
|
|
|
* @cur: the xml node
|
|
|
|
* @parent: the parent of this object when it's loaded
|
|
|
|
*
|
|
|
|
* Load the element from the XML description
|
|
|
|
*
|
|
|
|
* Returns: the new element
|
|
|
|
*/
|
|
|
|
GstElement*
|
|
|
|
gst_xml_make_element (xmlNodePtr cur, GstObject *parent)
|
|
|
|
{
|
|
|
|
xmlNodePtr children = cur->xmlChildrenNode;
|
|
|
|
GstElement *element;
|
|
|
|
guchar *name = NULL;
|
|
|
|
guchar *type = NULL;
|
|
|
|
|
|
|
|
/* first get the needed tags to construct the element */
|
|
|
|
while (children) {
|
|
|
|
if (!strcmp (children->name, "name")) {
|
|
|
|
name = xmlNodeGetContent (children);
|
|
|
|
} else if (!strcmp (children->name, "type")) {
|
|
|
|
type = xmlNodeGetContent (children);
|
|
|
|
}
|
|
|
|
children = children->next;
|
|
|
|
}
|
|
|
|
g_return_val_if_fail (name != NULL, NULL);
|
|
|
|
g_return_val_if_fail (type != NULL, NULL);
|
|
|
|
|
|
|
|
GST_INFO (GST_CAT_XML,"loading \"%s\" of type \"%s\"", name, type);
|
|
|
|
|
2002-04-11 20:35:18 +00:00
|
|
|
element = gst_element_factory_make (type, name);
|
2002-01-11 15:49:47 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (element != NULL, NULL);
|
|
|
|
|
|
|
|
/* ne need to set the parent on this object bacause the pads */
|
2003-01-08 22:45:46 +00:00
|
|
|
/* will go through the hierarchy to link to their peers */
|
2002-01-11 15:49:47 +00:00
|
|
|
if (parent)
|
|
|
|
gst_object_set_parent (GST_OBJECT (element), parent);
|
|
|
|
|
|
|
|
gst_object_restore_thyself (GST_OBJECT (element), cur);
|
|
|
|
|
|
|
|
return element;
|
|
|
|
}
|