2 * Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
14 * You should have received a copy of the GNU General Public
15 * License along with this library; if not, write to the Free
16 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #define BUFFER_COUNT (1000)
22 #define SRC_ELEMENT "fakesrc"
23 #define SINK_ELEMENT "fakesink"
27 gst_get_current_time (void)
31 g_get_current_time (&tv);
32 return GST_TIMEVAL_TO_TIME (tv);
36 main (gint argc, gchar * argv[])
38 GstElement *pipeline, *src, *e;
39 GSList *saved_src_list, *src_list, *new_src_list;
40 guint complexity_order, n_elements, i, j, max_this_level;
41 GstClockTime start, end;
42 gboolean all_srcs_linked;
44 gst_init (&argc, &argv);
47 g_print ("usage: %s COMPLEXITY_ORDER N_ELEMENTS\n", argv[0]);
51 complexity_order = atoi (argv[1]);
52 n_elements = atoi (argv[2]);
54 start = gst_get_current_time ();
56 pipeline = gst_element_factory_make ("pipeline", NULL);
59 e = gst_element_factory_make ("fakesrc", NULL);
60 g_object_set (e, "num-buffers", BUFFER_COUNT, NULL);
61 g_object_set (e, "silent", TRUE, NULL);
62 gst_bin_add (GST_BIN (pipeline), e);
63 src_list = saved_src_list = g_slist_append (NULL, e);
70 all_srcs_linked = FALSE;
71 for (i = 0, j = 0; i < n_elements; i++, j++) {
72 if (j >= max_this_level) {
73 g_slist_free (saved_src_list);
74 saved_src_list = g_slist_reverse (new_src_list);
77 all_srcs_linked = FALSE;
78 max_this_level *= complexity_order;
83 all_srcs_linked = TRUE;
84 src_list = saved_src_list;
87 src = (GstElement *) src_list->data;
88 src_list = src_list->next;
90 if (i + max_this_level < n_elements) {
91 e = gst_element_factory_make ("tee", NULL);
93 e = gst_element_factory_make ("fakesink", NULL);
94 g_object_set (e, "preroll-queue-len", 1, NULL);
96 g_object_set (e, "silent", TRUE, NULL);
97 new_src_list = g_slist_prepend (new_src_list, e);
99 gst_bin_add (GST_BIN (pipeline), e);
100 if (!gst_element_link (src, e))
101 g_assert_not_reached ();
104 g_slist_free (saved_src_list);
105 g_slist_free (new_src_list);
107 end = gst_get_current_time ();
108 g_print ("%" GST_TIME_FORMAT " - creating and linking %d elements\n",
109 GST_TIME_ARGS (end - start), i);
111 start = gst_get_current_time ();
112 if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
113 g_assert_not_reached ();
114 end = gst_get_current_time ();
115 g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
116 GST_TIME_ARGS (end - start));
118 start = gst_get_current_time ();
119 gst_bus_poll (gst_element_get_bus (pipeline),
120 GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
121 end = gst_get_current_time ();
122 g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
123 GST_TIME_ARGS (end - start), BUFFER_COUNT);
125 start = gst_get_current_time ();
126 g_object_unref (pipeline);
127 end = gst_get_current_time ();
128 g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
129 GST_TIME_ARGS (end - start));