10 static guint64 iterations = 0;
11 static guint64 sum = 0;
12 static guint64 min = G_MAXINT64;
13 static guint64 max = 0;
14 static GstClock *s_clock;
17 idle_func (gpointer data)
20 GTimeVal tfthen, tfnow;
21 GstClockTimeDiff diff;
24 //g_print ("%lld\n", gst_clock_get_time (s_clock));
27 g_get_current_time (&tfthen);
28 busy = gst_bin_iterate (GST_BIN (data));
30 g_get_current_time (&tfnow);
32 diff = GST_TIMEVAL_TO_TIME (tfnow) -
33 GST_TIMEVAL_TO_TIME (tfthen);
36 min = MIN (min, diff);
37 max = MAX (max, diff);
42 g_print ("execution ended after %llu iterations (sum %llu ns, average %llu ns, min %llu ns, max %llu ns)\n",
43 iterations, sum, sum/iterations, min, max);
51 main (int argc, char *argv[])
54 gboolean verbose = FALSE;
55 gchar *exclude_args = NULL;
56 struct poptOption options[] = {
57 {"verbose", 'v', POPT_ARG_NONE|POPT_ARGFLAG_STRIP, &verbose, 0,
58 "do not output status information", NULL},
66 gchar *md5string = g_malloc0 (33);
68 free (malloc (8)); /* -lefence */
70 setlocale (LC_ALL, "");
72 gst_init_with_popt_table (&argc, &argv, options);
74 /* make a null-terminated version of argv with ! md5sink appended
75 * ! is stored in argvn[argc - 1], md5sink in argvn[argc],
76 * NULL pointer in argvn[argc + 1] */
77 argvn = g_new0 (char *, argc + 2);
78 memcpy (argvn, argv + 1, sizeof (char *) * (argc - 1));
79 argvn[argc - 1] = g_strdup_printf ("!");
80 argvn[argc] = g_strdup_printf ("md5sink");
82 pipeline = (GstElement*) gst_parse_launchv ((const gchar**) argvn, &error);
87 g_warning ("pipeline could not be constructed: %s\n", error->message);
91 g_warning ("pipeline could not be constructed\n");
97 gchar **exclude_list = exclude_args ? g_strsplit (exclude_args, ",", 0)
99 g_signal_connect (pipeline, "deep_notify",
100 G_CALLBACK (gst_element_default_deep_notify),
103 g_signal_connect (pipeline, "error",
104 G_CALLBACK (gst_element_default_error), NULL);
106 if (gst_element_set_state (pipeline, GST_STATE_PLAYING) != GST_STATE_SUCCESS)
108 g_warning ("pipeline doesn't want to play\n");
112 if (!GST_FLAG_IS_SET (GST_OBJECT (pipeline), GST_BIN_SELF_SCHEDULABLE)) {
113 g_idle_add (idle_func, pipeline);
116 gst_element_wait_state_change (pipeline);
119 gst_element_set_state (pipeline, GST_STATE_NULL);
121 /* print out md5sink here */
122 md5sink = gst_bin_get_by_name (GST_BIN (pipeline), "md5sink0");
124 g_object_get (G_OBJECT (md5sink), "md5", &md5string, NULL);
125 printf ("%s\n", md5string);
127 gst_object_unref (GST_OBJECT (pipeline));