--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gstreamer_core/tsrc/examples/manual/manual_playbin/src/manual_playbin.c Thu Dec 17 08:53:32 2009 +0200
@@ -0,0 +1,116 @@
+/*
+* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+/*** block a from ../../../docs/manual/highlevel-components.xml ***/
+
+#define LOG_FILE "c:\\logs\\playbin_logs.txt"
+
+#include <gst/gst_global.h>
+#include "std_log_result.h"
+#define LOG_FILENAME_LINE __FILE__, __LINE__
+
+void create_xml(int result)
+{
+ if(result)
+ assert_failed = 1;
+
+ testResultXml(xmlfile);
+ close_log_file();
+}
+
+#include <gst/gst.h>
+
+/*** block b from ../../../docs/manual/highlevel-components.xml ***/
+static gboolean
+my_bus_callback (GstBus *bus,
+ GstMessage *message,
+ gpointer data)
+{
+ GMainLoop *loop = data;
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_ERROR: {
+ GError *err;
+ gchar *debug;
+
+ gst_message_parse_error (message, &err, &debug);
+ g_print ("Error: %s\n", err->message);
+ g_error_free (err);
+ g_free (debug);
+
+ g_main_loop_quit (loop);
+ break;
+ }
+ case GST_MESSAGE_EOS:
+ /* end-of-stream */
+ g_main_loop_quit (loop);
+ break;
+ default:
+ /* unhandled message */
+ break;
+ }
+
+ /* remove message from the queue */
+ return TRUE;
+}
+
+/*** block c from ../../../docs/manual/highlevel-components.xml ***/
+gint
+main (gint argc,
+ gchar *argv[])
+{
+ GMainLoop *loop;
+ GstElement *play;
+ GstBus *bus;
+
+ xmlfile = "playbin";
+ std_log(LOG_FILENAME_LINE, "Test Started playbin");
+
+ /* 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]);
+ std_log(LOG_FILENAME_LINE, "Test Failed");
+ create_xml(1);
+ 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));
+
+ std_log(LOG_FILENAME_LINE, "Test Successful");
+ create_xml(0);
+
+ return 0;
+}