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 static GTimeVal start_time;
22 gboolean done = FALSE;
23 GstClockTime total = 0;
27 handoff (GstElement * fakesink, GstBuffer * data)
32 if (!GST_IS_BUFFER (data))
34 g_get_current_time (&end_time);
35 diff = ((GstClockTime) end_time.tv_sec - start_time.tv_sec) * GST_SECOND +
36 ((GstClockTime) end_time.tv_usec -
37 start_time.tv_usec) * (GST_SECOND / G_USEC_PER_SEC);
38 g_print ("time to launch spider pipeline: %" GST_TIME_FORMAT "\n",
39 GST_TIME_ARGS (diff));
41 /* don't count first try, it loads the plugins */
47 main (gint argc, gchar * argv[])
51 gchar *file, *pipeline_str;
54 gst_init (&argc, &argv);
57 g_print ("usage : %s <file>\n", argv[0]);
60 bla = g_strsplit (argv[1], " ", -1);
61 file = g_strjoinv ("\\ ", bla);
64 ("filesrc location=\"%s\" ! spider ! audio/x-raw-int ! fakesink name = sink",
67 for (i = 0; i <= count; i++) {
70 g_get_current_time (&start_time);
71 pipeline = gst_parse_launch (pipeline_str, NULL);
72 sink = gst_bin_get_by_name (GST_BIN (pipeline), "sink");
73 g_object_set (sink, "signal-handoffs", TRUE, NULL);
74 g_signal_connect (sink, "handoff", (GCallback) handoff, NULL);
75 gst_element_set_state (pipeline, GST_STATE_PLAYING);
77 while (!done && gst_bin_iterate (GST_BIN (pipeline)));
78 g_object_unref (pipeline);
81 g_print ("\ntime to launch spider pipeline (average): %" GST_TIME_FORMAT "\n",
82 GST_TIME_ARGS (total / count));