Build the timings tree. Remove next from segments and make sub_segments GSList values
[laugh.git] / src / main.c
blob2c555595455e10e85f4e2190b6d2a66e9d07f072
1 /*
2 * Laugh.
4 * An glib SMIL library.
6 * Authored By Koos Vriezen <koos.vriezen@gmail.com>
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the
20 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21 * Boston, MA 02111-1307, USA.
24 #ifdef HAVE_CONFIG_H
25 #include "config.h"
26 #endif
28 #include "laugh-dom.h"
30 #include <glib/gprintf.h>
31 #include <clutter/clutter-main.h>
32 #include <clutter/clutter-stage.h>
34 void dump_timings (LaughTimingSegment *segment)
36 GSList *s = segment->sub_segments;
37 gboolean first = TRUE;
39 g_printf ("%s[", laugh_tag_from_id (segment->node->id));
41 for ( ; s; s = s->next) {
42 GSList *s1 = (GSList *) s->data;
43 gboolean sub_first = TRUE;
44 if (!first)
45 g_printf (", ");
46 else
47 first = FALSE;
48 for ( ; s1; s1 = s1->next) {
49 if (!sub_first)
50 g_printf ("->");
51 else
52 sub_first = FALSE;
53 dump_timings ((LaughTimingSegment *) s1->data);
56 g_printf ("]");
59 void initialized_callback (LaughNode *node, gpointer d)
61 gchar *xml = laugh_node_get_inner_xml (node);
62 g_printf ("cb initialized\n%s\n", xml);
63 dump_timings (((LaughDocument *)node)->timing);
64 g_printf ("\n");
66 g_free (xml);
69 int main (int argc, char **argv)
71 LaughDocument *doc;
72 LaughInitializer *initializer;
73 ClutterActor *stage;
74 guint width, height;
76 if (argc < 2) {
77 g_printerr ("usage %s uri\n", argv[0]);
78 return 1;
81 g_thread_init (NULL);
82 clutter_init (&argc, &argv);
83 /*gst_init (&argc, &argv);*/
85 stage = clutter_stage_get_default ();
86 clutter_actor_get_size (stage, &width, &height);
87 initializer = laugh_dom_initializer_new (CLUTTER_CONTAINER (stage),
88 width, height);
90 doc = laugh_document_new (argv[1]);
92 g_signal_connect (G_OBJECT (doc), "initialized",
93 (GCallback) initialized_callback, (gpointer) 0);
95 laugh_node_init (LAUGH_NODE (doc), initializer);
97 clutter_actor_show_all (stage);
99 clutter_main ();
101 g_object_unref (G_OBJECT (doc));
102 g_free (initializer);
104 return 0;