[0.11] gst-plugins-good: cairooverlay: Add a bus handler to the example to handle EOS/ERROR/WARNING
Wim Taymans
wtay at kemper.freedesktop.org
Tue Mar 8 09:24:28 PST 2011
Module: gst-plugins-good
Branch: 0.11
Commit: 1a8aa16612ed36b489c7112a908fd207bd0b3e3d
URL: http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=1a8aa16612ed36b489c7112a908fd207bd0b3e3d
Author: Sebastian Dröge <sebastian.droege at collabora.co.uk>
Date: Mon Mar 7 10:54:22 2011 +0100
cairooverlay: Add a bus handler to the example to handle EOS/ERROR/WARNING
Also clean up the pipeline properly.
---
tests/examples/cairo/cairo_overlay.c | 48 +++++++++++++++++++++++++++++++---
1 files changed, 44 insertions(+), 4 deletions(-)
diff --git a/tests/examples/cairo/cairo_overlay.c b/tests/examples/cairo/cairo_overlay.c
index ea921e6..c941b53 100644
--- a/tests/examples/cairo/cairo_overlay.c
+++ b/tests/examples/cairo/cairo_overlay.c
@@ -29,6 +29,41 @@
#include <glib.h>
+
+static gboolean
+on_message (GstBus * bus, GstMessage * message, gpointer user_data)
+{
+ GMainLoop *loop = (GMainLoop *) user_data;
+
+ switch (GST_MESSAGE_TYPE (message)) {
+ case GST_MESSAGE_ERROR:{
+ GError *err = NULL;
+ gchar *debug;
+
+ gst_message_parse_error (message, &err, &debug);
+ g_critical ("Got ERROR: %s (%s)", err->message, GST_STR_NULL (debug));
+ g_main_loop_quit (loop);
+ break;
+ }
+ case GST_MESSAGE_WARNING:{
+ GError *err = NULL;
+ gchar *debug;
+
+ gst_message_parse_warning (message, &err, &debug);
+ g_warning ("Got WARNING: %s (%s)", err->message, GST_STR_NULL (debug));
+ g_main_loop_quit (loop);
+ break;
+ }
+ case GST_MESSAGE_EOS:
+ g_main_loop_quit (loop);
+ break;
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
/* Datastructure to share the state we are interested in between
* prepare and render function. */
typedef struct
@@ -114,17 +149,22 @@ main (int argc, char **argv)
{
GMainLoop *loop;
GstElement *pipeline;
- CairoOverlayState *overlay_state;
+ GstBus *bus;
+ CairoOverlayState overlay_state = { FALSE, 0, 0 };
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
- overlay_state = g_new0 (CairoOverlayState, 1);
- pipeline = setup_gst_pipeline (overlay_state);
+ pipeline = setup_gst_pipeline (&overlay_state);
+
+ bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
+ gst_bus_add_signal_watch (bus);
+ g_signal_connect (G_OBJECT (bus), "message", G_CALLBACK (on_message), loop);
+ gst_object_unref (GST_OBJECT (bus));
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_main_loop_run (loop);
+ gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
- g_free (overlay_state);
}
More information about the gstreamer-commits
mailing list