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

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, ...@@ -134,7 +134,7 @@ create_nodes (GstBin * bin, GstElement * sink, gint depth, gint children,
} }
static void static void
event_loop (GstElement * bin, GstClockTime start) event_loop (GstElement * bin)
{ {
GstBus *bus; GstBus *bus;
GstMessage *msg = NULL; GstMessage *msg = NULL;
...@@ -144,27 +144,11 @@ event_loop (GstElement * bin, GstClockTime start) ...@@ -144,27 +144,11 @@ event_loop (GstElement * bin, GstClockTime start)
while (running) { while (running) {
msg = gst_bus_poll (bus, msg = gst_bus_poll (bus,
GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_WARNING, GST_MESSAGE_ASYNC_DONE | GST_MESSAGE_ERROR | GST_MESSAGE_WARNING, -1);
-1);
switch (GST_MESSAGE_TYPE (msg)) { switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_STATE_CHANGED: case GST_MESSAGE_ASYNC_DONE:
if (GST_MESSAGE_SRC (msg) == (GstObject *) bin) { running = FALSE;
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;
}
}
break; break;
case GST_MESSAGE_WARNING:{ case GST_MESSAGE_WARNING:{
GError *err = NULL; GError *err = NULL;
...@@ -205,6 +189,7 @@ main (gint argc, gchar * argv[]) ...@@ -205,6 +189,7 @@ main (gint argc, gchar * argv[])
gint flavour = FLAVOUR_AUDIO; gint flavour = FLAVOUR_AUDIO;
gint children = 3; gint children = 3;
gint depth = 4; gint depth = 4;
gint loops = 50;
GOptionContext *ctx; GOptionContext *ctx;
GOptionEntry options[] = { GOptionEntry options[] = {
...@@ -212,15 +197,18 @@ main (gint argc, gchar * argv[]) ...@@ -212,15 +197,18 @@ main (gint argc, gchar * argv[])
"Number of children (branches on each level) (default: 3)", NULL}, "Number of children (branches on each level) (default: 3)", NULL},
{"depth", 'd', 0, G_OPTION_ARG_INT, &depth, {"depth", 'd', 0, G_OPTION_ARG_INT, &depth,
"Depth of pipeline hierarchy tree (default: 4)", NULL}, "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 " "Flavour (video|audio) controlling the kind of elements used "
"(default: audio)", NULL}, "(default: audio)", NULL},
{"loops", 'l', 0, G_OPTION_ARG_INT, &loops,
"How many loops to run (default: 50)", NULL},
{NULL} {NULL}
}; };
GError *err = NULL; GError *err = NULL;
GstBin *bin; GstBin *bin;
GstClockTime start, end; GstClockTime start, end;
GstElement *sink, *new_sink; GstElement *sink, *new_sink;
gint i;
g_set_prgname ("capsnego"); g_set_prgname ("capsnego");
...@@ -259,13 +247,16 @@ main (gint argc, gchar * argv[]) ...@@ -259,13 +247,16 @@ main (gint argc, gchar * argv[])
g_print ("starting pipeline\n"); g_print ("starting pipeline\n");
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY); gst_element_set_state (GST_ELEMENT (bin), GST_STATE_READY);
GST_DEBUG_BIN_TO_DOT_FILE (bin, GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE, "capsnego"); GST_DEBUG_BIN_TO_DOT_FILE (bin, GST_DEBUG_GRAPH_SHOW_MEDIA_TYPE, "capsnego");
start = gst_util_get_timestamp (); start = gst_util_get_timestamp ();
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_PAUSED); for (i = 0; i < loops; ++i) {
event_loop (GST_ELEMENT (bin), start); 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 (); end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " reached paused\n", g_print ("%" GST_TIME_FORMAT " reached PAUSED state (%d loop iterations)\n",
GST_TIME_ARGS (end - start)); GST_TIME_ARGS (end - start), loops);
/* clean up */ /* clean up */
Error: Error:
gst_element_set_state (GST_ELEMENT (bin), GST_STATE_NULL); 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