gst-indent run on core
[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 G_GNUC_UNUSED 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
20           g_print ("object %s loaded with comment '%s'\n",
21               gst_object_get_name (object), name);
22         }
23         nodes = nodes->next;
24       }
25     }
26     children = children->next;
27   }
28 }
29
30 int
31 main (int argc, char *argv[])
32 {
33   GstXML *xml;
34   GstElement *pipeline;
35   gboolean ret;
36
37   gst_init (&argc, &argv);
38
39   xml = gst_xml_new ();
40
41 /*  g_signal_connect (G_OBJECT (xml), "object_loaded", */
42 /*                  G_CALLBACK (xml_loaded), xml); */
43
44   if (argc == 2)
45     ret = gst_xml_parse_file (xml, argv[1], NULL);
46   else
47     ret = gst_xml_parse_file (xml, "xmlTest.gst", NULL);
48
49   g_assert (ret == TRUE);
50
51   pipeline = gst_xml_get_element (xml, "pipeline");
52   g_assert (pipeline != NULL);
53
54   gst_element_set_state (pipeline, GST_STATE_PLAYING);
55
56   while (gst_bin_iterate (GST_BIN (pipeline)));
57
58   gst_element_set_state (pipeline, GST_STATE_NULL);
59
60   exit (0);
61 }