From: <tp...@fr...> - 2005-10-27 18:30:22
|
CVS Root: /cvs/gstreamer Module: gst-plugins-base Changes by: tpm Date: Thu Oct 27 2005 11:30:17 PDT Log message: * gst/playback/.cvsignore: * gst/playback/decodetest.c: * gst/playback/test3.c: Port these two tests as well. Modified files: . : ChangeLog gst/playback : .cvsignore decodetest.c test3.c Links: http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/ChangeLog.diff?r1=1.2030&r2=1.2031 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/.cvsignore.diff?r1=1.2&r2=1.3 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/decodetest.c.diff?r1=1.3&r2=1.4 http://freedesktop.org/cgi-bin/viewcvs.cgi/gstreamer/gst-plugins-base/gst/playback/test3.c.diff?r1=1.8&r2=1.9 ====Begin Diffs==== Index: ChangeLog =================================================================== RCS file: /cvs/gstreamer/gst-plugins-base/ChangeLog,v retrieving revision 1.2030 retrieving revision 1.2031 diff -u -d -r1.2030 -r1.2031 --- ChangeLog 27 Oct 2005 11:33:09 -0000 1.2030 +++ ChangeLog 27 Oct 2005 18:30:04 -0000 1.2031 @@ -1,3 +1,10 @@ +2005-10-27 Tim-Philipp Müller <tim at centricular dot net> + + * gst/playback/.cvsignore: + * gst/playback/decodetest.c: + * gst/playback/test3.c: + Port these two tests as well. 2005-10-27 Wim Taymans <wi...@fl...> * ext/theora/theoradec.c: (theora_dec_src_query), Index: .cvsignore RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/.cvsignore,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- .cvsignore 17 Jan 2005 12:45:48 -0000 1.2 +++ .cvsignore 27 Oct 2005 18:30:04 -0000 1.3 @@ -3,5 +3,7 @@ test2 test3 test4 +test5 gstplay-marshal.c gstplay-marshal.h +test6 Index: decodetest.c RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/decodetest.c,v retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- decodetest.c 2 Sep 2005 15:43:16 -0000 1.3 +++ decodetest.c 27 Oct 2005 18:30:04 -0000 1.4 @@ -17,6 +17,86 @@ * Boston, MA 02111-1307, USA. */ #include <gst/gst.h> +#include <string.h> +static void +warning_cb (GstBus * bus, GstMessage * msg, gpointer foo) +{ + GError *err = NULL; + gchar *dbg = NULL; + gst_message_parse_warning (msg, &err, &dbg); + g_printerr ("WARNING: %s (%s)\n", err->message, (dbg) ? dbg : "no details"); + g_error_free (err); + g_free (dbg); +} +error_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop) + gst_message_parse_error (msg, &err, &dbg); + g_printerr ("ERROR: %s (%s)\n", err->message, (dbg) ? dbg : "no details"); + g_main_loop_quit (main_loop); +eos_cb (GstBus * bus, GstMessage * msg, GMainLoop * main_loop) + g_print ("EOS\n"); +state_cb (GstBus * bus, GstMessage * msg, GstElement * pipeline) + if (msg->src == GST_OBJECT (pipeline)) { + GstState old_state, new_state, pending_state; + gst_message_parse_state_changed (msg, &old_state, &new_state, + &pending_state); + if (new_state == GST_STATE_PLAYING) { + g_print ("Decoding ...\n"); + } + } +new_decoded_pad_cb (GstElement * decodebin, GstPad * pad, gboolean last, + GstElement * pipeline) + GstPadLinkReturn ret; + GstElement *fakesink; + GstPad *fakesink_pad; + fakesink = gst_element_factory_make ("fakesink", NULL); + fakesink_pad = gst_element_get_pad (fakesink, "sink"); + gst_bin_add (GST_BIN (pipeline), fakesink); + /* this doesn't really seem right, but it makes things work for me */ + gst_element_set_state (fakesink, GST_STATE_PLAYING); + ret = gst_pad_link (pad, fakesink_pad); + if (!GST_PAD_LINK_SUCCESSFUL (ret)) { + g_printerr ("Failed to link %s:%s to %s:%s (ret = %d)\n", + GST_DEBUG_PAD_NAME (pad), GST_DEBUG_PAD_NAME (fakesink_pad), ret); + } else { + g_printerr ("Linked %s:%s to %s:%s\n", GST_DEBUG_PAD_NAME (pad), + GST_DEBUG_PAD_NAME (fakesink_pad)); + gst_object_unref (fakesink_pad); gint main (gint argc, gchar * argv[]) @@ -25,14 +105,41 @@ GstElement *source; GstElement *pipeline; GstStateChangeReturn res; + GMainLoop *loop; + GstBus *bus; gst_init (&argc, &argv); + if (argc != 2) { + g_printerr ("Decode file from start to end.\n"); + g_printerr ("Usage: %s URI\n\n", argv[0]); + return 1; + loop = g_main_loop_new (NULL, TRUE); pipeline = gst_pipeline_new ("pipeline"); + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_add_signal_watch (bus); + g_signal_connect (bus, "message::eos", G_CALLBACK (eos_cb), loop); + g_signal_connect (bus, "message::error", G_CALLBACK (error_cb), loop); + g_signal_connect (bus, "message::warning", G_CALLBACK (warning_cb), NULL); + g_signal_connect (bus, "message::state-changed", G_CALLBACK (state_cb), + pipeline); source = gst_element_factory_make ("gnomevfssrc", "source"); g_assert (source); - g_object_set (G_OBJECT (source), "location", argv[1], NULL); + if (argv[1] && strstr (argv[1], "://") != NULL) { + g_object_set (G_OBJECT (source), "location", argv[1], NULL); + } else if (argv[1]) { + gchar *uri = g_strdup_printf ("file://%s", argv[1]); + g_object_set (G_OBJECT (source), "location", uri, NULL); + g_free (uri); decoder = gst_element_factory_make ("decodebin", "decoder"); g_assert (decoder); @@ -42,13 +149,21 @@ gst_element_link_pads (source, "src", decoder, "sink"); + g_signal_connect (decoder, "new-decoded-pad", + G_CALLBACK (new_decoded_pad_cb), pipeline); res = gst_element_set_state (pipeline, GST_STATE_PLAYING); - if (res != GST_STATE_CHANGE_SUCCESS) { + if (res == GST_STATE_CHANGE_FAILURE) { g_print ("could not play\n"); return -1; } - g_main_loop_run (g_main_loop_new (NULL, FALSE)); + g_main_loop_run (loop); + /* tidy up */ + gst_element_set_state (pipeline, GST_STATE_NULL); + gst_object_unref (pipeline); + gst_object_unref (bus); return 0; } Index: test3.c RCS file: /cvs/gstreamer/gst-plugins-base/gst/playback/test3.c,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- test3.c 20 Oct 2005 19:06:43 -0000 1.8 +++ test3.c 27 Oct 2005 18:30:04 -0000 1.9 @@ -47,17 +47,66 @@ return TRUE; { - GstElement *player; + GstElement *player; player = gst_element_factory_make ("playbin", "player"); g_assert (player); + bus = gst_pipeline_get_bus (GST_PIPELINE (player)); g_object_set (G_OBJECT (player), "uri", argv[1], NULL); res = gst_element_set_state (player, GST_STATE_PLAYING); @@ -68,7 +117,12 @@ g_timeout_add (UPDATE_INTERVAL, (GSourceFunc) update_scale, player); - g_main_loop_run (g_main_loop_new (NULL, TRUE)); + gst_element_set_state (player, GST_STATE_NULL); + gst_object_unref (player); |