Commit 4620048e authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

benchmarks: capsnego: add --loops command line option

And default to 50 loops.
parent 4e12c452
......@@ -134,7 +134,7 @@ create_nodes (GstBin * bin, GstElement * sink, gint depth, gint children,
}
static void
event_loop (GstElement * bin, GstClockTime start)
event_loop (GstElement * bin)
{
GstBus *bus;
GstMessage *msg = NULL;
......@@ -144,27 +144,11 @@ event_loop (GstElement * bin, GstClockTime start)
while (running) {
msg = gst_bus_poll (bus,
GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_WARNING,
-1);
GST_MESSAGE_ASYNC_DONE | GST_MESSAGE_ERROR | GST_MESSAGE_WARNING, -1);
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_STATE_CHANGED:
if (GST_MESSAGE_SRC (msg) == (GstObject *) bin) {
GstState old_state, new_state;
GstClockTime end;
gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " state change on the bin: %s -> %s\n",
GST_TIME_ARGS (end - start),
gst_element_state_get_name (old_state),
gst_element_state_get_name (new_state));
if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED) {
running = FALSE;
}
}
case GST_MESSAGE_ASYNC_DONE:
running = FALSE;
break;
case GST_MESSAGE_WARNING:{
GError *err = NULL;
......@@ -205,6 +189,7 @@ main (gint argc, gchar * argv[])
gint flavour = FLAVOUR_AUDIO;
gint children = 3;
gint depth = 4;
gint loops = 50;
GOptionContext *ctx;
GOptionEntry options[] = {
......@@ -212,15 +197,18 @@ main (gint argc, gchar * argv[])
"Number of children (branches on each level) (default: 3)", NULL},
{"depth", 'd', 0, G_OPTION_ARG_INT, &depth,
"Depth of pipeline hierarchy tree (default: 4)", NULL},
{"flavour", 0, 0, G_OPTION_ARG_STRING, &flavour_str,
{"flavour", 'f', 0, G_OPTION_ARG_STRING, &flavour_str,
"Flavour (video|audio) controlling the kind of elements used "
"(default: audio)", NULL},
{"loops", 'l', 0, G_OPTION_ARG_INT, &loops,
"How many loops to run (default: 50)", NULL},
{NULL}
};
GError *err = NULL;
GstBin *bin;
GstClockTime start, end;
GstElement *sink, *new_sink;
gint i;
g_set_prgname ("capsnego");
......@@ -259,13 +247,16 @@ main (gint argc, gchar * argv[])
g_print ("starting pipeline\n");
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
GST_DEBUG_BIN_TO_DOT_FILE (bin, GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE, "capsnego");
start = gst_util_get_timestamp ();
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
event_loop (GST_ELEMENT (bin), start);
for (i = 0; i < loops; ++i) {
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED);
event_loop (GST_ELEMENT (bin));
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
}
end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " reached paused\n",
GST_TIME_ARGS (end - start));
g_print ("%" GST_TIME_FORMAT " reached PAUSED state (%d loop iterations)\n",
GST_TIME_ARGS (end - start), loops);
/* clean up */
Error:
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment