2005-02-24 15:36:22 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
2005-03-31 15:00:11 +00:00
|
|
|
* Copyright (C) 2005 Andy Wingo <wingo@pobox.com>
|
2005-02-24 15:36:22 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
2007-04-19 08:40:33 +00:00
|
|
|
* modify it under the terms of the GNU Library General Public
|
2005-02-24 15:36:22 +00:00
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
2007-04-19 08:40:33 +00:00
|
|
|
* Library General Public License for more details.
|
2005-02-24 15:36:22 +00:00
|
|
|
*
|
2007-04-19 08:40:33 +00:00
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2012-11-03 20:44:48 +00:00
|
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
2005-02-24 15:36:22 +00:00
|
|
|
*/
|
|
|
|
|
2005-11-30 19:01:53 +00:00
|
|
|
#include <stdlib.h>
|
2005-02-24 15:36:22 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#define BUFFER_COUNT (1000)
|
|
|
|
|
|
|
|
gint
|
|
|
|
main (gint argc, gchar * argv[])
|
|
|
|
{
|
2007-05-09 10:01:35 +00:00
|
|
|
GstMessage *msg;
|
2005-02-24 15:36:22 +00:00
|
|
|
GstElement *pipeline, *src, *e;
|
|
|
|
GSList *saved_src_list, *src_list, *new_src_list;
|
|
|
|
guint complexity_order, n_elements, i, j, max_this_level;
|
|
|
|
GstClockTime start, end;
|
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
if (argc != 3) {
|
2017-07-10 14:52:38 +00:00
|
|
|
g_print ("Usage: %s COMPLEXITY_ORDER N_ELEMENTS\n", argv[0]);
|
2005-02-24 15:36:22 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
complexity_order = atoi (argv[1]);
|
|
|
|
n_elements = atoi (argv[2]);
|
|
|
|
|
2010-05-18 14:51:01 +00:00
|
|
|
start = gst_util_get_timestamp ();
|
2005-02-24 15:36:22 +00:00
|
|
|
|
|
|
|
pipeline = gst_element_factory_make ("pipeline", NULL);
|
|
|
|
g_assert (pipeline);
|
|
|
|
|
|
|
|
e = gst_element_factory_make ("fakesrc", NULL);
|
|
|
|
g_object_set (e, "num-buffers", BUFFER_COUNT, NULL);
|
2005-02-24 17:12:19 +00:00
|
|
|
g_object_set (e, "silent", TRUE, NULL);
|
2005-02-24 15:36:22 +00:00
|
|
|
gst_bin_add (GST_BIN (pipeline), e);
|
|
|
|
src_list = saved_src_list = g_slist_append (NULL, e);
|
|
|
|
|
|
|
|
new_src_list = NULL;
|
|
|
|
|
|
|
|
max_this_level = 1;
|
|
|
|
for (i = 0, j = 0; i < n_elements; i++, j++) {
|
|
|
|
if (j >= max_this_level) {
|
|
|
|
g_slist_free (saved_src_list);
|
2005-02-24 17:12:19 +00:00
|
|
|
saved_src_list = g_slist_reverse (new_src_list);
|
2005-02-24 15:36:22 +00:00
|
|
|
new_src_list = NULL;
|
|
|
|
j = 0;
|
|
|
|
max_this_level *= complexity_order;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!src_list) {
|
|
|
|
src_list = saved_src_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
src = (GstElement *) src_list->data;
|
|
|
|
src_list = src_list->next;
|
|
|
|
|
2005-03-29 13:10:25 +00:00
|
|
|
if (i + max_this_level < n_elements) {
|
2005-02-24 17:12:19 +00:00
|
|
|
e = gst_element_factory_make ("tee", NULL);
|
2005-03-29 13:10:25 +00:00
|
|
|
} else {
|
2005-02-24 17:12:19 +00:00
|
|
|
e = gst_element_factory_make ("fakesink", NULL);
|
2017-07-10 14:52:38 +00:00
|
|
|
g_object_set (e, "async", FALSE, NULL);
|
2005-03-29 13:10:25 +00:00
|
|
|
}
|
2005-02-24 17:12:19 +00:00
|
|
|
g_object_set (e, "silent", TRUE, NULL);
|
2005-02-24 15:36:22 +00:00
|
|
|
new_src_list = g_slist_prepend (new_src_list, e);
|
|
|
|
|
|
|
|
gst_bin_add (GST_BIN (pipeline), e);
|
2005-03-29 14:12:48 +00:00
|
|
|
if (!gst_element_link (src, e))
|
2005-02-24 15:36:22 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
}
|
|
|
|
|
|
|
|
g_slist_free (saved_src_list);
|
2005-02-24 17:12:19 +00:00
|
|
|
g_slist_free (new_src_list);
|
2005-02-24 15:36:22 +00:00
|
|
|
|
2010-05-18 14:51:01 +00:00
|
|
|
end = gst_util_get_timestamp ();
|
2012-09-25 00:02:03 +00:00
|
|
|
g_print ("%" GST_TIME_FORMAT " - creating and linking %u elements\n",
|
2005-02-24 15:36:22 +00:00
|
|
|
GST_TIME_ARGS (end - start), i);
|
|
|
|
|
2010-05-18 14:51:01 +00:00
|
|
|
start = gst_util_get_timestamp ();
|
2005-09-02 15:42:00 +00:00
|
|
|
if (gst_element_set_state (pipeline,
|
2009-10-08 01:42:16 +00:00
|
|
|
GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE)
|
|
|
|
g_assert_not_reached ();
|
|
|
|
if (gst_element_get_state (pipeline, NULL, NULL,
|
|
|
|
GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_FAILURE)
|
2005-02-24 15:36:22 +00:00
|
|
|
g_assert_not_reached ();
|
2010-05-18 14:51:01 +00:00
|
|
|
end = gst_util_get_timestamp ();
|
2005-02-24 15:36:22 +00:00
|
|
|
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
|
|
|
|
GST_TIME_ARGS (end - start));
|
|
|
|
|
2010-05-18 14:51:01 +00:00
|
|
|
start = gst_util_get_timestamp ();
|
2007-05-09 10:01:35 +00:00
|
|
|
msg = gst_bus_poll (gst_element_get_bus (pipeline),
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_MESSAGE_EOS | GST_MESSAGE_ERROR, -1);
|
2010-05-18 14:51:01 +00:00
|
|
|
end = gst_util_get_timestamp ();
|
2007-05-09 10:01:35 +00:00
|
|
|
gst_message_unref (msg);
|
2012-09-25 00:02:03 +00:00
|
|
|
g_print ("%" GST_TIME_FORMAT " - putting %d buffers through\n",
|
2005-02-24 15:36:22 +00:00
|
|
|
GST_TIME_ARGS (end - start), BUFFER_COUNT);
|
|
|
|
|
2010-05-18 14:51:01 +00:00
|
|
|
start = gst_util_get_timestamp ();
|
2009-10-08 01:42:16 +00:00
|
|
|
if (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS)
|
|
|
|
g_assert_not_reached ();
|
2010-05-18 14:51:01 +00:00
|
|
|
end = gst_util_get_timestamp ();
|
2009-10-08 01:42:16 +00:00
|
|
|
g_print ("%" GST_TIME_FORMAT " - setting pipeline to NULL\n",
|
|
|
|
GST_TIME_ARGS (end - start));
|
|
|
|
|
2010-05-18 14:51:01 +00:00
|
|
|
start = gst_util_get_timestamp ();
|
2005-02-24 15:36:22 +00:00
|
|
|
g_object_unref (pipeline);
|
2010-05-18 14:51:01 +00:00
|
|
|
end = gst_util_get_timestamp ();
|
2005-02-24 15:36:22 +00:00
|
|
|
g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
|
|
|
|
GST_TIME_ARGS (end - start));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|