| GStreamer Application Development Manual (0.8.7) | ||
|---|---|---|
| <<< Previous | XML in GStreamer | Next >>> |
Before an XML file can be loaded, you must create a GstXML object. A saved XML file can then be loaded with the gst_xml_parse_file (xml, filename, rootelement) method. The root element can optionally left NULL. The following code example loads the previously created XML file and runs it.
#include <stdlib.h>
#include <gst/gst.h>
int
main(int argc, char *argv[])
{
GstXML *xml;
GstElement *bin;
gboolean ret;
gst_init (&argc, &argv);
xml = gst_xml_new ();
ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL);
g_assert (ret == TRUE);
bin = gst_xml_get_element (xml, "bin");
g_assert (bin != NULL);
gst_element_set_state (bin, GST_STATE_PLAYING);
while (gst_bin_iterate(GST_BIN(bin)));
gst_element_set_state (bin, GST_STATE_NULL);
exit (0);
}
|
gst_xml_get_element (xml, "name") can be used to get a specific element from the XML file.
gst_xml_get_topelements (xml) can be used to get a list of all toplevel elements in the XML file.
In addition to loading a file, you can also load a from a xmlDocPtr and an in memory buffer using gst_xml_parse_doc and gst_xml_parse_memory respectively. Both of these methods return a gboolean indicating success or failure of the requested action.
| <<< Previous | Home | Next >>> |
| XML in GStreamer | Up | Adding custom XML tags into the core XML data |