* Boston, MA 02111-1307, USA.
*/
-/* this benchmark recursively builds a pipeline and meassures the time to go
+/* this benchmark recursively builds a pipeline and measures the time to go
* from ready to paused.
* The graph size and type can be controlled with a few commandline args:
* -d depth: is the depth of the tree
{"videotestsrc", "videomixer", "videoscale", "ffmpegcolorspace"}
};
+static const gchar *sink_pads[NUM_FLAVOURS][NUM_ELEM] = {
+ {NULL, "sink%d", NULL, NULL},
+ {NULL, "sink_%d", NULL, NULL}
+};
+
static gboolean
-create_node (GstBin * bin, GstElement * sink, GstElement ** new_sink,
- gint children, gint flavour)
+create_node (GstBin * bin, GstElement * sink, const gchar * sinkpadname,
+ GstElement ** new_sink, gint children, gint flavour)
{
GstElement *mix, *proc, *conv;
return FALSE;
}
gst_bin_add_many (bin, mix, proc, conv, NULL);
- if (!gst_element_link_many (mix, proc, conv, sink, NULL)) {
+ if (!gst_element_link_pads_full (mix, "src", proc, "sink",
+ GST_PAD_LINK_CHECK_NOTHING)
+ || !gst_element_link_pads_full (proc, "src", conv, "sink",
+ GST_PAD_LINK_CHECK_NOTHING)
+ || !gst_element_link_pads_full (conv, "src", sink, sinkpadname,
+ GST_PAD_LINK_CHECK_NOTHING)) {
GST_WARNING ("can't link elements");
return FALSE;
}
for (i = 0; i < children; i++) {
if (depth > 0) {
- if (!create_node (bin, sink, &new_sink, children, flavour)) {
+ if (!create_node (bin, sink, sink_pads[flavour][ELEM_MIX], &new_sink,
+ children, flavour)) {
return FALSE;
}
if (!create_nodes (bin, new_sink, depth - 1, children, flavour)) {
return FALSE;
}
gst_bin_add (bin, src);
- if (!gst_element_link (src, sink)) {
+ if (!gst_element_link_pads_full (src, "src", sink,
+ sink_pads[flavour][ELEM_MIX], GST_PAD_LINK_CHECK_NOTHING)) {
GST_WARNING ("can't link elements");
return FALSE;
}
}
static void
-event_loop (GstElement * bin)
+event_loop (GstElement * bin, GstClockTime start)
{
GstBus *bus;
GstMessage *msg = NULL;
bus = gst_element_get_bus (bin);
while (running) {
- msg = gst_bus_poll (bus, GST_MESSAGE_STATE_CHANGED, -1);
+ msg = gst_bus_poll (bus,
+ GST_MESSAGE_STATE_CHANGED | 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 (GST_MESSAGE_SRC (msg) == (GstObject *) bin) {
- GstState old_state, new_state;
+ if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED) {
+ running = FALSE;
+ }
+ }
+ break;
+ case GST_MESSAGE_WARNING:{
+ GError *err = NULL;
+ gchar *dbg = NULL;
+
+ gst_message_parse_warning (msg, &err, &dbg);
+ GST_WARNING_OBJECT (GST_MESSAGE_SRC (msg), "%s (%s)", err->message,
+ (dbg ? dbg : "no details"));
+ g_error_free (err);
+ g_free (dbg);
+ break;
+ }
+ case GST_MESSAGE_ERROR:{
+ GError *err = NULL;
+ gchar *dbg = NULL;
- gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
- if (old_state == GST_STATE_READY && new_state == GST_STATE_PAUSED) {
+ gst_message_parse_error (msg, &err, &dbg);
+ GST_ERROR_OBJECT (GST_MESSAGE_SRC (msg), "%s (%s)", err->message,
+ (dbg ? dbg : "no details"));
+ g_error_free (err);
+ g_free (dbg);
running = FALSE;
+ break;
}
+ default:
+ break;
}
gst_message_unref (msg);
}
+ gst_object_unref (bus);
}
bin = GST_BIN (gst_pipeline_new ("pipeline"));
sink = gst_element_factory_make ("fakesink", NULL);
gst_bin_add (bin, sink);
- if (!create_node (bin, sink, &new_sink, children, flavour)) {
+ if (!create_node (bin, sink, "sink", &new_sink, children, flavour)) {
goto Error;
}
if (!create_nodes (bin, new_sink, depth, children, flavour)) {
goto Error;
}
end = gst_util_get_timestamp ();
+ /* num-threads = num-sources = pow (children, depth) */
g_print ("%" GST_TIME_FORMAT " built pipeline with %d elements\n",
GST_TIME_ARGS (end - start), GST_BIN_NUMCHILDREN (bin));
- /* meassure */
+ /* measure */
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));
+ event_loop (GST_ELEMENT (bin), start);
end = gst_util_get_timestamp ();
g_print ("%" GST_TIME_FORMAT " reached paused\n",
GST_TIME_ARGS (end - start));