summaryrefslogtreecommitdiff
path: root/gst/playback/test6.c
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.net>2006-02-01 14:51:29 +0000
committerTim-Philipp Müller <tim@centricular.net>2006-02-01 14:51:29 +0000
commitf85c7f526836120fb5d709235af83b55b6b7f6d0 (patch)
tree94ce63fcd796c16616a94a6dedcf27d135a29f1d /gst/playback/test6.c
parent51ce1f6179c692800cdf6f64b89ffc8650dd5b49 (diff)
gst/playback/test6.c: Make test work again by connecting fakesinks to each decoded pad, which makes the pipeline wait...
Original commit message from CVS: * gst/playback/test6.c: (new_decoded_pad_cb), (show_error), (main): Make test work again by connecting fakesinks to each decoded pad, which makes the pipeline wait until each fakesink has a buffer queued before going to PAUSED state. At that point we know the decodebin pads are negotiated.
Diffstat (limited to 'gst/playback/test6.c')
-rw-r--r--gst/playback/test6.c71
1 files changed, 67 insertions, 4 deletions
diff --git a/gst/playback/test6.c b/gst/playback/test6.c
index cdc999c9f..74ed8985d 100644
--- a/gst/playback/test6.c
+++ b/gst/playback/test6.c
@@ -19,12 +19,58 @@
#include <unistd.h>
#include <gst/gst.h>
+static void
+new_decoded_pad_cb (GstElement * decodebin, GstPad * new_pad, gboolean last,
+ GstElement * pipeline)
+{
+ GstElement *fakesink;
+ GstPad *sinkpad;
+
+ fakesink = gst_element_factory_make ("fakesink", NULL);
+ gst_bin_add (GST_BIN (pipeline), fakesink);
+
+ sinkpad = gst_element_get_pad (fakesink, "sink");
+ if (GST_PAD_LINK_FAILED (gst_pad_link (new_pad, sinkpad))) {
+ g_warning ("Failed to link %s:%s to %s:%s", GST_DEBUG_PAD_NAME (new_pad),
+ GST_DEBUG_PAD_NAME (sinkpad));
+ gst_bin_remove (GST_BIN (pipeline), fakesink);
+ } else {
+ gst_element_set_state (fakesink, GST_STATE_PAUSED);
+ }
+}
+
+static void
+show_error (const gchar * errmsg, GstBus * bus)
+{
+ GstMessage *msg;
+ GError *err = NULL;
+ gchar *dbg = NULL;
+
+ msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
+ if (msg) {
+ g_assert (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
+
+ gst_message_parse_error (msg, &err, &dbg);
+ }
+
+ g_print ("ERROR: %s\n", errmsg);
+ g_print (" %s\n", (err) ? err->message : "");
+ if (dbg) {
+ g_print ("\ndebug: %s\n\n", dbg);
+ g_free (dbg);
+ }
+
+ if (err)
+ g_error_free (err);
+}
+
gint
main (gint argc, gchar * argv[])
{
GstElement *pipeline, *filesrc, *decodebin;
GstStateChangeReturn res;
GstIterator *it;
+ GstBus *bus;
gpointer data;
gst_init (&argc, &argv);
@@ -41,21 +87,38 @@ main (gint argc, gchar * argv[])
gst_element_link (filesrc, decodebin);
if (argc < 2) {
- g_print ("usage: %s <uri>\n", argv[0]);
+ g_print ("usage: %s <filenames>\n", argv[0]);
exit (-1);
}
- g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+
+ if (!g_str_has_prefix (argv[1], "file://")) {
+ g_object_set (G_OBJECT (filesrc), "location", argv[1], NULL);
+ } else {
+ g_object_set (G_OBJECT (filesrc), "location", argv[1] + 7, NULL);
+ }
+
+ /* we've got to connect fakesinks to newly decoded pads to make sure
+ * buffers have actually been flowing over those pads and caps have
+ * been set on them. decodebin might insert internal queues and
+ * without fakesinks it's pot-luck what caps we get from the pad, because
+ * it depends on whether the queues have started pushing buffers yet or not.
+ * With fakesinks we make sure that the pipeline doesn't go to PAUSED state
+ * before each fakesink has a buffer queued. */
+ g_signal_connect (decodebin, "new-decoded-pad",
+ G_CALLBACK (new_decoded_pad_cb), pipeline);
+
+ bus = gst_element_get_bus (pipeline);
g_print ("pause..\n");
res = gst_element_set_state (pipeline, GST_STATE_PAUSED);
if (res == GST_STATE_CHANGE_FAILURE) {
- g_print ("could not pause\n");
+ show_error ("Could not go to PAUSED state", bus);
exit (-1);
}
g_print ("waiting..\n");
res = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
if (res != GST_STATE_CHANGE_SUCCESS) {
- g_print ("could not complete pause\n");
+ show_error ("Failed to complete state change to PAUSED", bus);
exit (-1);
}
g_print ("stats..\n");