[totem] backend: Use helper functions for GStreamer



commit 1cd2c5bba6c793069dffb43a9a39c027f8a84513
Author: Bastien Nocera <hadess hadess net>
Date:   Sun Apr 3 17:23:13 2011 +0100

    backend: Use helper functions for GStreamer

 configure.in                              |    1 +
 src/Makefile.am                           |    8 ++-
 src/backend/Makefile.am                   |   14 +++--
 src/backend/bacon-video-widget-gst-0.10.c |   47 +----------------
 src/gst/Makefile.am                       |   29 +++++++++++
 src/gst/totem-gst-helpers.c               |   77 +++++++++++++++++++++++++++++
 src/gst/totem-gst-helpers.h               |   55 ++++++++++++++++++++
 src/totem-audio-preview.c                 |   31 +-----------
 8 files changed, 180 insertions(+), 82 deletions(-)
---
diff --git a/configure.in b/configure.in
index a5b9363..07755d0 100644
--- a/configure.in
+++ b/configure.in
@@ -764,6 +764,7 @@ Makefile
 totem.spec
 lib/Makefile
 src/Makefile
+src/gst/Makefile
 src/properties/Makefile
 src/plugins/Makefile
 src/plugins/bemused/Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
index 0672900..5eb7099 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = backend properties . plugins
+SUBDIRS = gst backend properties . plugins
 
 bin_PROGRAMS = totem totem-video-thumbnailer totem-audio-preview
 lib_LTLIBRARIES = libtotem.la
@@ -267,6 +267,7 @@ totem_audio_preview_SOURCES = \
 
 totem_audio_preview_CPPFLAGS = \
 	-I$(top_builddir)/data			\
+	-I$(top_srcdir)/src/gst			\
 	-DG_LOG_DOMAIN=\""TotemAudioPreview"\"	\
 	$(AM_CPPFLAGS)
 
@@ -274,8 +275,9 @@ totem_audio_preview_CFLAGS = \
 	$(DEPENDENCY_CFLAGS)	\
 	$(AM_CFLAGS)
 
-totem_audio_preview_LDADD = \
-	backend/libbaconvideowidget.la	\
+totem_audio_preview_LDADD =			\
+	gst/libtotemgsthelpers.la		\
+	backend/libbaconvideowidget.la		\
 	$(DEPENDENCY_LIBS)
 
 # Introspection
diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am
index 8fa5d1c..f2c089f 100644
--- a/src/backend/Makefile.am
+++ b/src/backend/Makefile.am
@@ -58,6 +58,7 @@ libbaconvideowidget_la_SOURCES = \
 
 libbaconvideowidget_la_CPPFLAGS = \
 	-D_REENTRANT				\
+	-I$(top_srcdir)/src/gst/		\
 	$(DISABLE_DEPRECATED)			\
 	$(AM_CPPFLAGS)
 
@@ -67,12 +68,13 @@ libbaconvideowidget_la_CFLAGS = \
 	$(MISSING_PLUGINS_CFLAGS)	\
 	$(AM_CFLAGS)
 
-libbaconvideowidget_la_LIBADD = \
-	$(MM_LIBS)		\
-	$(GST_LIBS)		\
-	$(EXTRA_BACKEND_LIBS)	\
-	$(X_LIBS)		\
-	$(MISSING_PLUGINS_LIBS)	\
+libbaconvideowidget_la_LIBADD =				\
+	$(top_builddir)/src/gst/libtotemgsthelpers.la	\
+	$(MM_LIBS)					\
+	$(GST_LIBS)					\
+	$(EXTRA_BACKEND_LIBS)				\
+	$(X_LIBS)					\
+	$(MISSING_PLUGINS_LIBS)				\
 	-lm
 
 libbaconvideowidget_la_LDFLAGS= \
diff --git a/src/backend/bacon-video-widget-gst-0.10.c b/src/backend/bacon-video-widget-gst-0.10.c
index d9755fb..6e055a0 100644
--- a/src/backend/bacon-video-widget-gst-0.10.c
+++ b/src/backend/bacon-video-widget-gst-0.10.c
@@ -79,6 +79,7 @@
 #include <glib/gi18n.h>
 #include <gio/gio.h>
 
+#include "totem-gst-helpers.h"
 #include "bacon-video-widget.h"
 #include "bacon-video-widget-gst-missing-plugins.h"
 #include "baconvideowidget-marshal.h"
@@ -151,20 +152,6 @@ static const gchar *video_props_str[4] = {
   "hue"
 };
 
-/* GstPlayFlags flags from playbin2 */
-typedef enum {
-  GST_PLAY_FLAG_VIDEO         = (1 << 0),
-  GST_PLAY_FLAG_AUDIO         = (1 << 1),
-  GST_PLAY_FLAG_TEXT          = (1 << 2),
-  GST_PLAY_FLAG_VIS           = (1 << 3),
-  GST_PLAY_FLAG_SOFT_VOLUME   = (1 << 4),
-  GST_PLAY_FLAG_NATIVE_AUDIO  = (1 << 5),
-  GST_PLAY_FLAG_NATIVE_VIDEO  = (1 << 6),
-  GST_PLAY_FLAG_DOWNLOAD      = (1 << 7),
-  GST_PLAY_FLAG_BUFFERING     = (1 << 8),
-  GST_PLAY_FLAG_DEINTERLACE   = (1 << 9)
-} GstPlayFlags;
-
 struct BaconVideoWidgetPrivate
 {
   char                        *user_agent;
@@ -398,34 +385,6 @@ bvw_check_if_video_decoder_is_missing (BaconVideoWidget * bvw)
 }
 
 static void
-bvw_error_msg (BaconVideoWidget * bvw, GstMessage * msg)
-{
-  GError *err = NULL;
-  gchar *dbg = NULL;
-
-  GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN_CAST (bvw->priv->play),
-      GST_DEBUG_GRAPH_SHOW_ALL ^ GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS,
-      "totem-error");
-
-  gst_message_parse_error (msg, &err, &dbg);
-  if (err) {
-    GST_ERROR ("message = %s", GST_STR_NULL (err->message));
-    GST_ERROR ("domain  = %d (%s)", err->domain,
-        GST_STR_NULL (g_quark_to_string (err->domain)));
-    GST_ERROR ("code    = %d", err->code);
-    GST_ERROR ("debug   = %s", GST_STR_NULL (dbg));
-    GST_ERROR ("source  = %" GST_PTR_FORMAT, msg->src);
-    GST_ERROR ("uri     = %s", GST_STR_NULL (bvw->priv->mrl));
-
-    g_message ("Error: %s\n%s\n", GST_STR_NULL (err->message),
-        GST_STR_NULL (dbg));
-
-    g_error_free (err);
-  }
-  g_free (dbg);
-}
-
-static void
 set_display_pixel_aspect_ratio (GdkScreen *screen,
 				GValue    *value)
 {
@@ -1925,7 +1884,7 @@ bvw_bus_message_cb (GstBus * bus, GstMessage * message, gpointer data)
 
   switch (msg_type) {
     case GST_MESSAGE_ERROR: {
-      bvw_error_msg (bvw, message);
+      totem_gst_message_print (message, bvw->priv->play, "totem-error");
 
       if (!bvw_check_missing_plugins_error (bvw, message) &&
 	  !bvw_check_missing_auth (bvw, message)) {
@@ -3436,7 +3395,7 @@ poll_for_state_change_full (BaconVideoWidget *bvw, GstElement *element,
       break;
     }
     case GST_MESSAGE_ERROR: {
-      bvw_error_msg (bvw, message);
+      totem_gst_message_print (message, bvw->priv->play, "totem-error");
       *err_msg = message;
       message = NULL;
       goto error;
diff --git a/src/gst/Makefile.am b/src/gst/Makefile.am
new file mode 100644
index 0000000..2e2d2f3
--- /dev/null
+++ b/src/gst/Makefile.am
@@ -0,0 +1,29 @@
+noinst_LTLIBRARIES = libtotemgsthelpers.la
+
+libtotemgsthelpers_la_SOURCES =				\
+	totem-gst-helpers.c				\
+	totem-gst-helpers.h
+
+libtotemgsthelpers_la_CPPFLAGS = \
+	-D_REENTRANT				\
+	$(DISABLE_DEPRECATED)			\
+	$(AM_CPPFLAGS)
+
+libtotemgsthelpers_la_CFLAGS = \
+	$(DEPENDENCY_CFLAGS)		\
+	$(MM_CFLAGS)			\
+	$(MISSING_PLUGINS_CFLAGS)	\
+	$(AM_CFLAGS)
+
+libtotemgsthelpers_la_LIBADD = \
+	$(MM_LIBS)		\
+	$(GST_LIBS)		\
+	$(EXTRA_BACKEND_LIBS)	\
+	$(X_LIBS)		\
+	$(MISSING_PLUGINS_LIBS)	\
+	-lm
+
+libtotemgsthelpers_la_LDFLAGS= \
+	-no-undefined
+
+-include $(top_srcdir)/git.mk
diff --git a/src/gst/totem-gst-helpers.c b/src/gst/totem-gst-helpers.c
new file mode 100644
index 0000000..0d81645
--- /dev/null
+++ b/src/gst/totem-gst-helpers.c
@@ -0,0 +1,77 @@
+/* 
+ * Copyright (C) 2003-2007 the GStreamer project
+ *      Julien Moutte <julien moutte net>
+ *      Ronald Bultje <rbultje ronald bitfreak net>
+ * Copyright (C) 2005-2008 Tim-Philipp Müller <tim centricular net>
+ * Copyright (C) 2009 Sebastian Dröge <sebastian droege collabora co uk>
+ * Copyright © 2009 Christian Persch
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ * The Totem project hereby grant permission for non-gpl compatible GStreamer
+ * plugins to be used and distributed together with GStreamer and Totem. This
+ * permission is above and beyond the permissions granted by the GPL license
+ * Totem is covered by.
+ *
+ * Monday 7th February 2005: Christian Schaller: Add exception clause.
+ * See license_change file for details.
+ *
+ */
+
+#include "totem-gst-helpers.h"
+
+void
+totem_gst_message_print (GstMessage *msg,
+			 GstElement *play,
+			 const char *filename)
+{
+  GError *err = NULL;
+  char *dbg = NULL;
+
+  g_return_if_fail (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR);
+
+  if (play != NULL) {
+    g_return_if_fail (filename != NULL);
+
+    GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN_CAST (play),
+			       GST_DEBUG_GRAPH_SHOW_ALL ^ GST_DEBUG_GRAPH_SHOW_NON_DEFAULT_PARAMS,
+			       filename);
+  }
+
+  gst_message_parse_error (msg, &err, &dbg);
+  if (err) {
+    char *uri;
+
+    g_object_get (play, "uri", &uri, NULL);
+    GST_ERROR ("message = %s", GST_STR_NULL (err->message));
+    GST_ERROR ("domain  = %d (%s)", err->domain,
+        GST_STR_NULL (g_quark_to_string (err->domain)));
+    GST_ERROR ("code    = %d", err->code);
+    GST_ERROR ("debug   = %s", GST_STR_NULL (dbg));
+    GST_ERROR ("source  = %" GST_PTR_FORMAT, msg->src);
+    GST_ERROR ("uri     = %s", GST_STR_NULL (uri));
+    g_free (uri);
+
+    g_message ("Error: %s\n%s\n", GST_STR_NULL (err->message),
+        GST_STR_NULL (dbg));
+
+    g_error_free (err);
+  }
+  g_free (dbg);
+}
+
+/*
+ * vim: sw=2 ts=8 cindent noai bs=2
+ */
diff --git a/src/gst/totem-gst-helpers.h b/src/gst/totem-gst-helpers.h
new file mode 100644
index 0000000..85fde47
--- /dev/null
+++ b/src/gst/totem-gst-helpers.h
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2001,2002,2003,2004,2005 Bastien Nocera <hadess hadess net>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA.
+ *
+ * The Totem project hereby grant permission for non-gpl compatible GStreamer
+ * plugins to be used and distributed together with GStreamer and Totem. This
+ * permission are above and beyond the permissions granted by the GPL license
+ * Totem is covered by.
+ *
+ * Monday 7th February 2005: Christian Schaller: Add exception clause.
+ * See license_change file for details.
+ *
+ */
+
+#ifndef HAVE_TOTEM_GST_HELPERS_H
+#define HAVE_TOTEM_GST_HELPERS_H
+
+#include <gst/gst.h>
+
+G_BEGIN_DECLS
+
+/* GstPlayFlags flags from playbin2 */
+typedef enum {
+  GST_PLAY_FLAG_VIDEO         = (1 << 0),
+  GST_PLAY_FLAG_AUDIO         = (1 << 1),
+  GST_PLAY_FLAG_TEXT          = (1 << 2),
+  GST_PLAY_FLAG_VIS           = (1 << 3),
+  GST_PLAY_FLAG_SOFT_VOLUME   = (1 << 4),
+  GST_PLAY_FLAG_NATIVE_AUDIO  = (1 << 5),
+  GST_PLAY_FLAG_NATIVE_VIDEO  = (1 << 6),
+  GST_PLAY_FLAG_DOWNLOAD      = (1 << 7),
+  GST_PLAY_FLAG_BUFFERING     = (1 << 8),
+  GST_PLAY_FLAG_DEINTERLACE   = (1 << 9)
+} GstPlayFlags;
+
+void totem_gst_message_print (GstMessage *msg,
+			      GstElement *play,
+			      const char *filename);
+
+G_END_DECLS
+
+#endif				/* HAVE_TOTEM_GST_HELPERS_H */
diff --git a/src/totem-audio-preview.c b/src/totem-audio-preview.c
index 146bfd3..7709f1e 100644
--- a/src/totem-audio-preview.c
+++ b/src/totem-audio-preview.c
@@ -32,13 +32,13 @@
 
 #include <gtk/gtk.h>
 
-#include <gst/gst.h>
 #include <glib.h>
 #include <string.h>
 #include <unistd.h>
 #include <stdlib.h>
 #include <glib/gi18n.h>
 
+#include "totem-gst-helpers.h"
 #include "totem-resources.h"
 #include "totem-mime-types.h"
 
@@ -46,10 +46,6 @@ static gboolean show_mimetype = FALSE;
 static gboolean g_fatal_warnings = FALSE;
 static char **filenames = NULL;
 
-/* GstPlayFlags flags from playbin2 */
-#define GST_PLAY_FLAG_AUDIO         (1 << 1)
-#define GST_PLAY_FLAG_SOFT_VOLUME   (1 << 4)
-
 static void
 print_mimetypes (void)
 {
@@ -68,29 +64,6 @@ static const GOptionEntry entries[] = {
 };
 
 static void
-error_msg (GstMessage * msg)
-{
-	GError *err = NULL;
-	gchar *dbg = NULL;
-
-	gst_message_parse_error (msg, &err, &dbg);
-	if (err) {
-		GST_ERROR ("message = %s", GST_STR_NULL (err->message));
-		GST_ERROR ("domain  = %d (%s)", err->domain,
-			   GST_STR_NULL (g_quark_to_string (err->domain)));
-		GST_ERROR ("code    = %d", err->code);
-		GST_ERROR ("debug   = %s", GST_STR_NULL (dbg));
-		GST_ERROR ("source  = %" GST_PTR_FORMAT, msg->src);
-
-		g_message ("Error: %s\n%s\n", GST_STR_NULL (err->message),
-			   GST_STR_NULL (dbg));
-
-		g_error_free (err);
-	}
-	g_free (dbg);
-}
-
-static void
 setup_audio_sink (GstElement *play)
 {
 	GstElement *audio_sink;
@@ -108,7 +81,7 @@ error_handler (GstBus *bus,
 	msg_type = GST_MESSAGE_TYPE (message);
 	switch (msg_type) {
 	case GST_MESSAGE_ERROR:
-		error_msg (message);
+		totem_gst_message_print (message, play, "totem-audio-preview-error");
 		exit (1);
 	case GST_MESSAGE_EOS:
 		exit (0);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]