2004-07-02 03:26:44 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2004 Benjamin Otte <otte@gnome.org>
|
|
|
|
*
|
|
|
|
* 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
|
2004-07-02 03:26:44 +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.
|
2004-07-02 03:26:44 +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
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
2004-07-02 03:26:44 +00:00
|
|
|
*/
|
|
|
|
|
2005-11-30 19:01:53 +00:00
|
|
|
#include <stdlib.h>
|
2004-07-02 03:26:44 +00:00
|
|
|
#include <gst/gst.h>
|
|
|
|
|
|
|
|
#define IDENTITY_COUNT (1000)
|
|
|
|
#define BUFFER_COUNT (1000)
|
2004-08-04 12:54:22 +00:00
|
|
|
#define SRC_ELEMENT "fakesrc"
|
|
|
|
#define SINK_ELEMENT "fakesink"
|
2004-07-02 03:26:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
static GstClockTime
|
|
|
|
gst_get_current_time (void)
|
|
|
|
{
|
|
|
|
GTimeVal tv;
|
|
|
|
|
|
|
|
g_get_current_time (&tv);
|
|
|
|
return GST_TIMEVAL_TO_TIME (tv);
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
|
|
|
main (gint argc, gchar * argv[])
|
|
|
|
{
|
2007-05-09 10:01:35 +00:00
|
|
|
GstMessage *msg;
|
2004-07-02 03:26:44 +00:00
|
|
|
GstElement *pipeline, *src, *sink, *current, *last;
|
|
|
|
guint i, buffers = BUFFER_COUNT, identities = IDENTITY_COUNT;
|
|
|
|
GstClockTime start, end;
|
2010-03-03 10:45:38 +00:00
|
|
|
const gchar *src_name = SRC_ELEMENT, *sink_name = SINK_ELEMENT;
|
2004-07-02 03:26:44 +00:00
|
|
|
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
|
|
|
|
if (argc > 1)
|
|
|
|
identities = atoi (argv[1]);
|
|
|
|
if (argc > 2)
|
|
|
|
buffers = atoi (argv[2]);
|
2004-08-04 12:54:22 +00:00
|
|
|
if (argc > 3)
|
|
|
|
src_name = argv[3];
|
|
|
|
if (argc > 4)
|
|
|
|
sink_name = argv[4];
|
2004-07-02 03:26:44 +00:00
|
|
|
|
|
|
|
g_print
|
2004-08-04 12:54:22 +00:00
|
|
|
("*** benchmarking this pipeline: %s num-buffers=%u ! %u * identity ! %s\n",
|
|
|
|
src_name, buffers, identities, sink_name);
|
2004-07-02 03:26:44 +00:00
|
|
|
start = gst_get_current_time ();
|
|
|
|
pipeline = gst_element_factory_make ("pipeline", NULL);
|
|
|
|
g_assert (pipeline);
|
2004-08-04 12:54:22 +00:00
|
|
|
src = gst_element_factory_make (src_name, NULL);
|
|
|
|
if (!src) {
|
|
|
|
g_print ("no element named \"%s\" found, aborting...\n", src_name);
|
|
|
|
return 1;
|
|
|
|
}
|
2004-07-02 03:26:44 +00:00
|
|
|
g_object_set (src, "num-buffers", buffers, NULL);
|
2004-08-04 12:54:22 +00:00
|
|
|
sink = gst_element_factory_make (sink_name, NULL);
|
|
|
|
if (!sink) {
|
|
|
|
g_print ("no element named \"%s\" found, aborting...\n", sink_name);
|
|
|
|
return 1;
|
|
|
|
}
|
2004-07-02 03:26:44 +00:00
|
|
|
last = src;
|
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, sink, NULL);
|
|
|
|
for (i = 0; i < identities; i++) {
|
|
|
|
current = gst_element_factory_make ("identity", NULL);
|
|
|
|
g_assert (current);
|
2004-08-04 12:54:22 +00:00
|
|
|
/* shut this element up (no g_strdup_printf please) */
|
|
|
|
g_object_set (current, "silent", TRUE, NULL);
|
2004-07-02 03:26:44 +00:00
|
|
|
gst_bin_add (GST_BIN (pipeline), current);
|
|
|
|
if (!gst_element_link (last, current))
|
|
|
|
g_assert_not_reached ();
|
|
|
|
last = current;
|
|
|
|
}
|
|
|
|
if (!gst_element_link (last, sink))
|
|
|
|
g_assert_not_reached ();
|
|
|
|
end = gst_get_current_time ();
|
|
|
|
g_print ("%" GST_TIME_FORMAT " - creating %u identity elements\n",
|
|
|
|
GST_TIME_ARGS (end - start), identities);
|
|
|
|
|
|
|
|
start = gst_get_current_time ();
|
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)
|
2004-07-02 03:26:44 +00:00
|
|
|
g_assert_not_reached ();
|
|
|
|
end = gst_get_current_time ();
|
|
|
|
g_print ("%" GST_TIME_FORMAT " - setting pipeline to playing\n",
|
|
|
|
GST_TIME_ARGS (end - start));
|
|
|
|
|
|
|
|
start = gst_get_current_time ();
|
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);
|
2004-07-02 03:26:44 +00:00
|
|
|
end = gst_get_current_time ();
|
2007-05-09 10:01:35 +00:00
|
|
|
gst_message_unref (msg);
|
2004-07-02 03:26:44 +00:00
|
|
|
g_print ("%" GST_TIME_FORMAT " - putting %u buffers through\n",
|
|
|
|
GST_TIME_ARGS (end - start), buffers);
|
|
|
|
|
2009-10-08 01:42:16 +00:00
|
|
|
start = gst_get_current_time ();
|
|
|
|
if (gst_element_set_state (pipeline,
|
|
|
|
GST_STATE_NULL) != GST_STATE_CHANGE_SUCCESS)
|
|
|
|
g_assert_not_reached ();
|
|
|
|
end = gst_get_current_time ();
|
|
|
|
g_print ("%" GST_TIME_FORMAT " - setting pipeline to NULL\n",
|
|
|
|
GST_TIME_ARGS (end - start));
|
|
|
|
|
2004-07-02 03:26:44 +00:00
|
|
|
start = gst_get_current_time ();
|
|
|
|
g_object_unref (pipeline);
|
|
|
|
end = gst_get_current_time ();
|
|
|
|
g_print ("%" GST_TIME_FORMAT " - unreffing pipeline\n",
|
|
|
|
GST_TIME_ARGS (end - start));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|