[gst-devel] gst-player

Thomas Vander Stichele thomas at urgent.rug.ac.be
Wed Sep 25 03:10:03 CEST 2002


Hi,

As I said, I've been working on somewhat better error handling for the 
player.

I attached an (uncleaned) patch that shows how I'm doing it based on the 
feedback I got.  You're welcome to try it out and let me know if you think 
it's the right way to do this.

A simple screenshot of an error is up at

http://thomas.apestaart.org/download/screenshots/gst-player-error.png

Nothing special, but this is how it would look.

Later on I could try implementing some of Bastien's suggestions, like not 
showing the volume slider if you don't have volume, but still be able to 
play.

Let me also know if you think this should go in before we release (from 
this point on, if you guys agree with the patch, it's fairly easy to do 
this everywhere) or not.  it involves some API changes, obviously, to the 
play library.

Thomas

 -- 

The Dave/Dina Project : future TV today ! - http://davedina.apestaart.org/
<-*-                      -*->
There's a world outside
And I know cause I've heard talk
In my sweetest dreams
I would go out for a walk
<-*- thomas at apestaart.org -*->
URGent, the best radio on the Internet - 24/7 ! - http://urgent.rug.ac.be/
-------------- next part --------------
? autoregen.sh
? compile
? config.guess
? config.sub
? depcomp
? gst-player-0.4.0.3.tar.gz
? gst-player.patch
? gstreamer-player-uninstalled.pc
? gstreamer-player.pc
? install-sh
? intltool-extract
? intltool-extract.in
? intltool-merge
? intltool-merge.in
? intltool-update
? intltool-update.in
? missing
? mkinstalldirs
? po/.intltool-merge-cache
? po/Makefile.in.in
? po/POTFILES
? po/gst-player.pot
? po/messages.mo
? po/nl.gmo
? tests/gstcmdplay
Index: configure.ac
===================================================================
RCS file: /cvsroot/gstreamer/gst-player/configure.ac,v
retrieving revision 1.39.2.1
diff -u -p -r1.39.2.1 configure.ac
--- configure.ac	22 Sep 2002 17:54:41 -0000	1.39.2.1
+++ configure.ac	25 Sep 2002 10:05:44 -0000
@@ -2,7 +2,7 @@ dnl autoconf configuration file for gst-
 AC_INIT
 
 dnl when going to/from release please set the nano (fourth number) right !
-AS_VERSION(gst-player, GST_PLAYER_VERSION, 0, 4, 0, 2)
+AS_VERSION(gst-player, GST_PLAYER_VERSION, 0, 4, 0, 3)
 PACKAGE=gst-player
 AM_INIT_AUTOMAKE($PACKAGE,$VERSION)
 AM_DISABLE_STATIC
Index: libs/gst/play/play.c
===================================================================
RCS file: /cvsroot/gstreamer/gst-player/libs/gst/play/play.c,v
retrieving revision 1.27
diff -u -p -r1.27 play.c
--- libs/gst/play/play.c	12 Sep 2002 21:10:29 -0000	1.27
+++ libs/gst/play/play.c	25 Sep 2002 10:05:45 -0000
@@ -1,3 +1,26 @@
+/* GStreamer
+ * Copyright (C) 1999,2000,2001,2002 Erik Walthinsen <omega at cse.ogi.edu>
+ *                    2000,2001,2002 Wim Taymans <wtay at chello.be>
+ *                              2002 Steve Baker <steve at stevebaker.org>
+ *
+ * play.c: GstPlay object code
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
 #include "play.h"
 
 enum {
@@ -74,6 +97,17 @@ static gboolean     gst_play_idle_callba
 static gboolean     gst_play_get_length_callback    (GstPlay *play);
 static gboolean     gst_play_tick_callback          (GstPlay *play);
 
+GQuark
+gst_play_error_quark (void)
+{
+	static GQuark quark = 0;
+	if (quark == 0) {
+		quark = g_quark_from_static_string ("gst-play-error-quark");
+	}
+
+	return quark;
+}
+
 /* split static pipeline functions to a seperate file */
 #include "playpipelines.c"
 
@@ -118,10 +152,12 @@ gst_play_class_init (GstPlayClass *klass
 	gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_play_get_property);
 
 	g_object_class_install_property (gobject_class, ARG_LOCATION,
-					 g_param_spec_string ("location", "location of file", "location of the file to play",
-							      NULL, G_PARAM_READWRITE));
+		g_param_spec_string ("location", "location of file", 
+			             "location of the file to play",
+				     NULL, G_PARAM_READWRITE));
 	g_object_class_install_property (gobject_class, ARG_VOLUME,
-					 g_param_spec_float ("volume", "Playing volume", "Playing volume", 
+		g_param_spec_float ("volume", "Playing volume", 
+			            "Playing volume", 
 							     0, 1.0, 0, G_PARAM_READWRITE));
 	g_object_class_install_property (gobject_class, ARG_MUTE,
 					 g_param_spec_boolean ("mute", "Volume muted", "Playing volume muted",
@@ -220,12 +256,13 @@ gst_play_init (GstPlay *play) 
 }
 
 GstPlay *
-gst_play_new (GstPlayPipeType pipe_type)
+gst_play_new (GstPlayPipeType pipe_type, GError **error)
 {
 	GstPlay *play;
 
 	play = g_object_new (GST_TYPE_PLAY, NULL);
 
+	/* FIXME: looks like only VIDEO ever gets used ! */
 	switch (pipe_type){
 		case GST_PLAY_PIPE_VIDEO:
 			play->setup_pipeline = gst_play_video_setup;
@@ -260,9 +297,12 @@ gst_play_new (GstPlayPipeType pipe_type)
 	}
 
 	/* init pipeline */
-	if (play->setup_pipeline){
-		if (! play->setup_pipeline(play)){
-			g_warning ("couldn't init pipelie\n");
+	if ((play->setup_pipeline) &&
+	    (! play->setup_pipeline (play, error)))
+	{
+		if (*error)
+		{
+			g_print ("GError: %s\n", (*error)->message);
 			return NULL;
 		}
 	}
@@ -803,3 +843,7 @@ gst_play_get_mute (GstPlay *play)
 
 	return mute;
 }
+
+/* modelines */
+/* vim:set ts=8:sw=8:noet */
+
Index: libs/gst/play/play.h
===================================================================
RCS file: /cvsroot/gstreamer/gst-player/libs/gst/play/play.h,v
retrieving revision 1.16
diff -u -p -r1.16 play.h
--- libs/gst/play/play.h	9 Aug 2002 19:32:42 -0000	1.16
+++ libs/gst/play/play.h	25 Sep 2002 10:05:45 -0000
@@ -1,3 +1,27 @@
+/* GStreamer
+ * Copyright (C) 1999,2000,2001,2002 Erik Walthinsen <omega at cse.ogi.edu>
+ *                    2000,2001,2002 Wim Taymans <wtay at chello.be>
+ *                              2002 Steve Baker <steve at stevebaker.org>
+ *
+ * play.h: GstPlay object code
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
 #ifndef __GSTPLAY_H__
 #define __GSTPLAY_H__
 
@@ -30,6 +54,14 @@ typedef enum {
 	GST_PLAY_PIPE_VIDEO,
 } GstPlayPipeType;
 
+typedef enum {
+	GST_PLAY_ERROR_GNOMEVFSSRC,
+	GST_PLAY_ERROR_VOLUME,
+	GST_PLAY_ERROR_LAST,
+} GstPlayError;
+
+#define GST_PLAY_ERROR 		gst_play_error_quark ()
+
 #define GST_TYPE_PLAY            (gst_play_get_type())
 #define GST_PLAY(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_PLAY, GstPlay))
 #define GST_PLAY_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_PLAY, GstPlayClass))
@@ -48,7 +80,7 @@ struct _GstPlay
 {
 	GObject parent;
 	
-	gboolean (*setup_pipeline)     (GstPlay *play);
+	gboolean (*setup_pipeline)     (GstPlay *play, GError **error);
 	void (*teardown_pipeline)  (GstPlay *play);
 	gboolean (*set_autoplugger)  (GstPlay *play, GstElement *autoplugger);
 	gboolean (*set_video_sink)     (GstPlay *play, GstElement *videosink);
@@ -109,7 +141,7 @@ struct _GstPlayIdleData
 
 GType	  gst_play_get_type	   (void);
 
-GstPlay*  gst_play_new		   (GstPlayPipeType pipe_type);
+GstPlay*  gst_play_new		   (GstPlayPipeType pipe_type, GError **error);
 
 void      gst_play_seek_to_time (GstPlay *play, gint64 time_nanos);
 
@@ -134,3 +166,7 @@ gboolean  gst_play_get_mute        (GstP
 void      gst_play_set_idle_timeout_funcs (GstPlay *play, GstPlayTimeoutAdd timeout_add_func, GstPlayIdleAdd idle_add_func);
 
 #endif /* __GSTPLAY_H__ */
+
+/* modelines */
+/* vim:set ts=8:sw=8:noet */
+
Index: libs/gst/play/playpipelines.c
===================================================================
RCS file: /cvsroot/gstreamer/gst-player/libs/gst/play/playpipelines.c,v
retrieving revision 1.11
diff -u -p -r1.11 playpipelines.c
--- libs/gst/play/playpipelines.c	10 Sep 2002 17:02:45 -0000	1.11
+++ libs/gst/play/playpipelines.c	25 Sep 2002 10:05:47 -0000
@@ -1,24 +1,86 @@
+/* GStreamer
+ * Copyright (C) 1999,2000,2001,2002 Erik Walthinsen <omega at cse.ogi.edu>
+ *                    2000,2001,2002 Wim Taymans <wtay at chello.be>
+ *                              2002 Steve Baker <steve at stevebaker.org>
+ *
+ * playpipelines.c: Set up pipelines for playback
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* GError creation when plugin is missing */
+static void
+gst_play_error_plugin (GstPlayError type, GError **error)
+{
+	gchar *name;
+	
+	g_print ("error_plugin: start\n");
+	if (error == NULL) return;
+
+	switch (type)
+	{
+		case GST_PLAY_ERROR_GNOMEVFSSRC:
+			name = g_strdup ("gnomevfssrc");
+			break;
+		default:
+			name = g_strdup ("unknown");
+			break;
+	}
+	g_print ("error_plugin: name %s\n", name);
+        *error = g_error_new (GST_PLAY_ERROR, type,
+		  	      "The %s plug-in could not be found. "
+			      "This plug-in is essential for gst-player. "
+			      "Please install it and verify that it works "
+			      "by running 'gst-inspect %s'", 
+			      name, name);
+	g_free (name);
+	return;
+}
 
 /*  
  *  GST_PLAY_PIPE_AUDIO_THREADED
  *  { gnomevfssrc ! spider ! volume ! osssink }
  */
 static gboolean 
-gst_play_audiot_setup (GstPlay *play)
+gst_play_audiot_setup (GstPlay *play, GError **error)
 {
 	play->pipeline = gst_thread_new ("main_pipeline");
 	g_return_val_if_fail (GST_IS_THREAD (play->pipeline), FALSE);
+
 /*
 	play->pipeline = gst_pipeline_new ("main_pipeline");
 	g_return_val_if_fail (GST_IS_PIPELINE (play->pipeline), FALSE);
 */
 	/* create source element */
-	play->source = gst_element_factory_make ("gnomevfssrc", "source");
-	g_return_val_if_fail (play->source != NULL, FALSE);
+	play->source = gst_element_factory_make ("nomevfssrc", "source");
+	if (play->source == NULL)
+	{
+		gst_play_error_plugin (GST_PLAY_ERROR_GNOMEVFSSRC, error);
+		return FALSE;
+	}
 	gst_bin_add (GST_BIN (play->pipeline), play->source);
 	
 	/* create audio elements */
 	play->volume = gst_element_factory_make ("volume", "volume");
+	if (play->source == NULL)
+	{
+		*error = g_error_new (GST_PLAY_ERROR, GST_PLAY_ERROR_VOLUME,
+		  "The volume plug-in could not be found.");
+		return FALSE;
+	}
 	if (play->volume == NULL)
 	  g_warning ("You need the volume element to use this program.\n");
 
@@ -80,7 +142,7 @@ gst_play_audiot_set_auto (GstPlay *play,
  *  { gnomevfssrc ! spider ! { queue ! volume ! osssink } }
  */
 static gboolean 
-gst_play_audioht_setup (GstPlay *play)
+gst_play_audioht_setup (GstPlay *play, GError **error)
 {
 	GstElement *audio_thread, *audio_queue;
 /*
@@ -182,7 +244,7 @@ gst_play_audioht_set_auto (GstPlay *play
  */
 
 static gboolean 
-gst_play_video_setup (GstPlay *play)
+gst_play_video_setup (GstPlay *play, GError **error)
 {
 	GstElement *audio_bin, *audio_queue, *video_queue, *video_bin, *work_thread, *colorspace;
 
@@ -196,8 +258,12 @@ gst_play_video_setup (GstPlay *play)
 	gst_bin_add (GST_BIN (play->pipeline), work_thread);
 
 	/* create source element */
-	play->source = gst_element_factory_make ("gnomevfssrc", "source");
-	g_return_val_if_fail (play->source != NULL, FALSE);
+	play->source = gst_element_factory_make ("nomevfssrc", "source");
+	if (play->source == NULL)
+	{
+		gst_play_error_plugin (GST_PLAY_ERROR_GNOMEVFSSRC, error);
+		return FALSE;
+	}
 	gst_bin_add (GST_BIN (work_thread), play->source);
 	
 	play->volume = gst_element_factory_make ("volume", "volume");
@@ -357,7 +423,7 @@ gst_play_video_set_audio (GstPlay *play,
  * (note that the xvideosink is not contained by a thread)
  */
 static gboolean 
-gst_play_videots_setup (GstPlay *play)
+gst_play_videots_setup (GstPlay *play, GError **error)
 {
 	GstElement *audio_bin, *audio_queue, *video_queue, *auto_identity, *work_thread;
 
@@ -507,6 +573,9 @@ gst_play_videots_set_audio (GstPlay *pla
 	gst_bin_add (GST_BIN (audio_bin), play->audio_sink);
 	gst_element_connect (play->volume, play->audio_sink);
 
+
 	return TRUE;
 }
 
+/* modelines */
+/* vim:set ts=8:sw=8:noet */
Index: libs/gst/player/gstmediaplay.c
===================================================================
RCS file: /cvsroot/gstreamer/gst-player/libs/gst/player/gstmediaplay.c,v
retrieving revision 1.62.2.1
diff -u -p -r1.62.2.1 gstmediaplay.c
--- libs/gst/player/gstmediaplay.c	23 Sep 2002 00:08:00 -0000	1.62.2.1
+++ libs/gst/player/gstmediaplay.c	25 Sep 2002 10:05:47 -0000
@@ -122,9 +122,26 @@ static void
 gst_media_play_init (GstMediaPlay *mplay)
 {
 	GstElement *audio_sink, *video_sink;
+	GError *error = NULL;
 	
 	/* play object */
-	mplay->play = gst_play_new (GST_PLAY_PIPE_VIDEO);
+	mplay->play = gst_play_new (GST_PLAY_PIPE_VIDEO, &error);
+	if (error != NULL)
+	{
+		GtkWidget *dialog;
+		/* throw up a dialog box; FIXME: we don't have a parent */
+		/* FIXME: maybe even fallback the GError and do error
+		 * handling higher up ? */
+		dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
+					         GTK_BUTTONS_CLOSE,
+						 error->message);
+		g_error_free (error);
+		gtk_widget_show (dialog);
+		g_signal_connect_swapped (GTK_OBJECT (dialog), "response",
+					  G_CALLBACK (gtk_widget_destroy),
+					  GTK_OBJECT (dialog));
+
+	}
 	g_return_if_fail(mplay->play != NULL);
 
 	/*audio_sink = gst_gconf_render_bin_from_key("osssink fragment=1572872");*/
Index: tests/gstcmdplay.c
===================================================================
RCS file: /cvsroot/gstreamer/gst-player/tests/gstcmdplay.c,v
retrieving revision 1.5
diff -u -p -r1.5 gstcmdplay.c
--- tests/gstcmdplay.c	11 Jul 2002 16:54:21 -0000	1.5
+++ tests/gstcmdplay.c	25 Sep 2002 10:05:47 -0000
@@ -142,7 +142,7 @@ int main(int argc,char *argv[]) 
 
 	cmdplay = g_new0(GstCmdPlay, 1);
 
-	cmdplay->play = gst_play_new(PLAY_PIPELINE);
+	cmdplay->play = gst_play_new(PLAY_PIPELINE, NULL);
 	g_assert (cmdplay->play != NULL);
 
 	


More information about the gstreamer-devel mailing list