summaryrefslogtreecommitdiffstats
path: root/src/test-native/gst/helloworld-playbin.c
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2012-04-16 20:50:06 +0200
committerSven Gothel <[email protected]>2012-04-16 20:50:06 +0200
commit10935e1ec0d8ed677bc3fddfaa8cd73898a3bcbf (patch)
tree6d453f72b3024670a6ed5c03454ef54ad4a04ba0 /src/test-native/gst/helloworld-playbin.c
parent62e5686fb583ad991d5811baf242d40d21952e27 (diff)
Add native tests for libav/ffmpeg and gst
Diffstat (limited to 'src/test-native/gst/helloworld-playbin.c')
-rw-r--r--src/test-native/gst/helloworld-playbin.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/src/test-native/gst/helloworld-playbin.c b/src/test-native/gst/helloworld-playbin.c
new file mode 100644
index 000000000..c5a42fe6c
--- /dev/null
+++ b/src/test-native/gst/helloworld-playbin.c
@@ -0,0 +1,75 @@
+#include <gst/gst.h>
+#include <glib.h>
+
+
+static gboolean
+my_bus_callback (GstBus *bus,
+ GstMessage *msg,
+ gpointer data)
+{
+ GMainLoop *loop = (GMainLoop *) data;
+
+ switch (GST_MESSAGE_TYPE (msg)) {
+
+ case GST_MESSAGE_EOS:
+ g_print ("End of stream\n");
+ g_main_loop_quit (loop);
+ break;
+
+ case GST_MESSAGE_ERROR: {
+ gchar *debug;
+ GError *error;
+
+ gst_message_parse_error (msg, &error, &debug);
+ g_free (debug);
+
+ g_printerr ("Error: %s\n", error->message);
+ g_error_free (error);
+
+ g_main_loop_quit (loop);
+ break;
+ }
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ GMainLoop *loop;
+ GstElement *play;
+ GstBus *bus;
+
+ /* init GStreamer */
+ gst_init (&argc, &argv);
+ loop = g_main_loop_new (NULL, FALSE);
+
+ /* make sure we have a URI */
+ if (argc != 2) {
+ g_print ("Usage: %s <URI>\n", argv[0]);
+ return -1;
+ }
+
+ /* set up */
+ play = gst_element_factory_make ("playbin", "play");
+ g_object_set (G_OBJECT (play), "uri", argv[1], NULL);
+
+ bus = gst_pipeline_get_bus (GST_PIPELINE (play));
+ gst_bus_add_watch (bus, my_bus_callback, loop);
+ gst_object_unref (bus);
+
+ gst_element_set_state (play, GST_STATE_PLAYING);
+
+ /* now run */
+ g_main_loop_run (loop);
+
+ /* also clean up */
+ gst_element_set_state (play, GST_STATE_NULL);
+ gst_object_unref (GST_OBJECT (play));
+
+ return 0;
+}