run a file, this is a quick hack
[platform/upstream/gstreamer.git] / examples / xml / runxml.c
1 #include <string.h>
2 #include <stdlib.h>
3 #include <gst/gst.h>
4
5 gboolean playing;
6
7 static void
8 xml_loaded (GstXML *xml, GstObject *object, xmlNodePtr self, gpointer data)
9 {
10   xmlNodePtr children = self->xmlChildrenNode;
11
12   while (children) {
13     if (!strcmp (children->name, "comment")) {
14       xmlNodePtr nodes = children->xmlChildrenNode;
15
16       while (nodes) {
17         if (!strcmp (nodes->name, "text")) {
18           gchar *name = g_strdup (xmlNodeGetContent (nodes));
19           g_print ("object %s loaded with comment '%s'\n",
20                       gst_object_get_name (object), name);
21         }
22         nodes = nodes->next;
23       }
24     }
25     children = children->next;
26   }
27 }
28
29 int main(int argc,char *argv[])
30 {
31   GstXML *xml;
32   GstElement *pipeline;
33   gboolean ret;
34
35   gst_init(&argc,&argv);
36
37   xml = gst_xml_new ();
38
39 //  g_signal_connect (G_OBJECT (xml), "object_loaded",
40 //                  G_CALLBACK (xml_loaded), xml);
41
42   if (argc == 2)
43     ret = gst_xml_parse_file(xml, argv[1], NULL);
44   else
45     ret = gst_xml_parse_file(xml, "xmlTest.gst", NULL);
46   
47   g_assert (ret == TRUE);
48
49   pipeline = gst_xml_get_element(xml, "pipeline");
50   g_assert (pipeline != NULL);
51
52   gst_element_set_state(pipeline, GST_STATE_PLAYING);
53
54   while (gst_bin_iterate(GST_BIN(pipeline)));
55
56   gst_element_set_state(pipeline, GST_STATE_NULL);
57
58   exit(0);
59 }
60