Index: configure.ac
===================================================================
RCS file: /cvs/gnome/rhythmbox/configure.ac,v
retrieving revision 1.191
diff -u -r1.191 configure.ac
--- configure.ac	28 Nov 2005 11:58:16 -0000	1.191
+++ configure.ac	5 Dec 2005 11:48:58 -0000
@@ -140,28 +140,60 @@
 dnl And we can also ask for the right version of gstreamer
 HAVE_SOUNDSYSTEM=no
 
-GST_MAJORMINOR=0.8
-GST_REQUIRED_VERSION=0.8.2
-PKG_CHECK_MODULES(SOUNDSYSTEM, \
-	gstreamer-$GST_MAJORMINOR >= $GST_REQUIRED_VERSION gstreamer-libs-$GST_MAJORMINOR >= $GST_REQUIRED_VERSION
-	gstreamer-control-$GST_MAJORMINOR >= $GST_REQUIRED_VERSION gstreamer-gconf-$GST_MAJORMINOR >= $GST_REQUIRED_VERSION,
-	HAVE_SOUNDSYSTEM=yes,HAVE_SOUNDSYSTEM=no)
+GST_0_8_MAJORMINOR=0.8
+GST_0_8_REQUIRED_VERSION=0.8.9
+PKG_CHECK_MODULES(GSTREAMER_0_8, \
+	gstreamer-$GST_0_8_MAJORMINOR >= $GST_0_8_REQUIRED_VERSION gstreamer-libs-$GST_0_8_MAJORMINOR >= $GST_0_8_REQUIRED_VERSION
+	gstreamer-control-$GST_0_8_MAJORMINOR >= $GST_0_8_REQUIRED_VERSION
+	gstreamer-gconf-$GST_0_8_MAJORMINOR >= $GST_0_8_REQUIRED_VERSION,
+	have_gstreamer_0_8=yes,have_gstreamer_0_8=no)
+	
+GST_0_10_MAJORMINOR=0.10
+GST_0_10_REQUIRED_VERSION=0.9.7
+PKG_CHECK_MODULES(GSTREAMER_0_10, \
+	gstreamer-$GST_0_10_MAJORMINOR >= $GST_0_10_REQUIRED_VERSION
+	gstreamer-plugins-base-$GST_0_10_MAJORMINOR >= $GST_0_10_REQUIRED_VERSION,
+	have_gstreamer_0_10=yes,have_gstreamer_0_10=no)
+
+AC_ARG_WITH(player,
+   AC_HELP_STRING([--with-playback=auto|gstreamer-0-8|gstreamer-0-10],
+   [Select the playback backend to use (default auto)]),,
+   with_playback=auto)
+
+if test x$with_playback = xauto -o x$with_playback = x$gstreamer_0_10; then
+	if test x"$have_gstreamer_0_10" = xyes; then
+		with_playback=gstreamer_0_10
+		SOUNDSYSTEM_DEPS="gstreamer-$GST_0_10_MAJORMINOR"
+		AC_DEFINE(HAVE_GSTREAMER,1,[Define if you want to use the GStreamer media framework])
+		AC_DEFINE(HAVE_GSTREAMER_0_10,1,[Define if you want to use the GStreamer 0.10])
+		SOUNDSYSTEM_CFLAGS="$GSTREAMER_0_10_CFLAGS"
+		SOUNDSYSTEM_LIBS="$GSTREAMER_0_10_LIBS"
+	elif test x$with_playback = x$gstreamer_0_10; then
+		AC_MSG_ERROR([GStreamer 0.10 explicity requested, and not found or older than version $GST_REQUIRED_VERSION])
+	fi
+fi
+if test x$with_playback = xauto -o x$with_playback = x$gstreamer_0_8; then
+	if test x"$have_gstreamer_0_8" = xyes; then
+		with_playback=gstreamer_0_8
+		SOUNDSYSTEM_DEPS="gstreamer-$GST_0_8_MAJORMINOR"
+		AC_DEFINE(HAVE_GSTREAMER,1,[Define if you want to use the GStreamer media framework])
+		AC_DEFINE(HAVE_GSTREAMER_0_8,1,[Define if you want to use the GStreamer 0.8])
+		SOUNDSYSTEM_CFLAGS="$GSTREAMER_0_8_CFLAGS"
+		SOUNDSYSTEM_LIBS="$GSTREAMER_0_8_LIBS"
+	elif test x$with_playback = x$gstreamer_0_8; then
+		AC_MSG_ERROR([GStreamer 0.8 explicity requested, and not found or older than version $GST_REQUIRED_VERSION])
+	fi
+fi
 
 dnl Give error and exit if we don't have gstreamer
-if test "x$HAVE_SOUNDSYSTEM" = "xno"; then
-		AC_MSG_ERROR([GStreamer not found, or older than version $GST_REQUIRED_VERSION])
+if test x$with_playback = xauto; then
+		AC_MSG_ERROR([GStreamer not found, or older than version $GST_0_8_REQUIRED_VERSION/$GST_0_10_REQUIRED_VERSION])
 fi
 
-SOUNDSYSTEM_DEPS="gstreamer-$GST_MAJORMINOR"
 AC_SUBST(SOUNDSYSTEM_DEPS)
-
-AC_DEFINE(HAVE_GSTREAMER,1,[Define if you want to use the GStreamer media framework])
-
 RHYTHMBOX_CFLAGS="$RHYTHMBOX_CFLAGS $SOUNDSYSTEM_CFLAGS"
 RHYTHMBOX_LIBS="$RHYTHMBOX_LIBS $SOUNDSYSTEM_LIBS"
 
-dnl Check for gstreamer elements
-AM_GST_ELEMENT_CHECK(playbin,,missing_gst_elements="$missing_gst_elements spider")
 
 dnl Tag writing
 AC_ARG_ENABLE(tag-writing,
@@ -613,7 +645,6 @@
 	AC_MSG_NOTICE([** RhythmDB sanity checking enabled (may be slow!)])
 fi
 
-AC_MSG_NOTICE([** GStreamer metadata is enabled])
 
 if test x"$enable_tag_writing" = xyes; then
         AC_MSG_NOTICE([** Tag writing is enabled - USE AT YOUR OWN RISK])
@@ -631,7 +662,13 @@
 	AC_MSG_NOTICE([** MusicBrainz support is enabled])
 fi
 
-AC_MSG_NOTICE([** GStreamer $GST_MAJORMINOR player is enabled])
+if test x"$with_player" = xgstreamer_0_8; then
+	AC_MSG_NOTICE([** GStreamer 0.8 player is enabled])
+elif test x"$with_player" = xgstreamer_0_10; then
+	AC_MSG_NOTICE([** GStreamer 0.10 player is enabled])
+else
+	AC_MSG_NOTICE([** this shouldn't happen])
+fi
 
 if test x"$use_ipod" = xyes; then
 	AC_MSG_NOTICE([** iPod integration enabled])
@@ -659,11 +696,4 @@
 	AC_MSG_NOTICE([   Audioscrobbler support disabled])
 fi
 
-if test x"$missing_gst_output_element" != x; then
-	AC_MSG_WARN([Neither osssink nor alsasink could be found on your system])
-fi	
-if test x"$missing_gst_elements" != x; then
-	AC_MSG_WARN([The following GStreamer elements could not be found at compile time: $missing_gst_elements])
-	AC_MSG_WARN([Rhythmbox will fail at runtime if these elements cannot be found])
-fi
 AC_MSG_NOTICE([End options])
Index: metadata/rb-metadata-gst.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/metadata/rb-metadata-gst.c,v
retrieving revision 1.50
diff -u -r1.50 rb-metadata-gst.c
--- metadata/rb-metadata-gst.c	2 Dec 2005 11:59:28 -0000	1.50
+++ metadata/rb-metadata-gst.c	5 Dec 2005 11:49:00 -0000
@@ -26,9 +26,18 @@
 
 #include <glib/gi18n.h>
 #include <gst/gst.h>
-#include <gst/gsttag.h>
 #include <gst/gsturi.h>
 
+#ifdef HAVE_GSTREAMER_0_8
+#include <gst/gsttag.h>
+#define gst_caps_unref gst_caps_free
+#define gst_tag_setter_add_tag_values gst_tag_setter_add_values
+#define gst_tag_setter_set_tag_merge_mode gst_tag_setter_set_merge_mode
+#endif
+#ifdef HAVE_GSTREAMER_0_10
+#include <gst/gsttagsetter.h>
+#endif
+
 #include "rb-metadata.h"
 #include "rb-debug.h"
 #include "rb-file-helpers.h"
@@ -106,7 +115,12 @@
 static GstElement *
 rb_add_id3_tagger (GstBin *pipeline, GstElement *element)
 {
-        GstElement * tagger, * identity;
+        GstElement *tagger = NULL;
+	GstElement *spider = NULL;
+	GstElement *identity = NULL;
+#ifdef HAVE_GSTREAMER_0_10
+	GstElement *filter = NULL;
+#endif
 	GstCaps *filtercaps = NULL;
 
         if (!(tagger = gst_element_factory_make("id3tag", "tagger"))) 
@@ -116,21 +130,46 @@
                 gst_object_unref( GST_OBJECT(tagger) );
                 return NULL;
         }
-        
+	if (!(spider = gst_element_factory_make ("spider", "spider")) ||
+	    !(tagger = gst_element_factory_make ("id3mux", "id3mux")) ||
+	    !(filtercaps = gst_caps_new_simple ("application/x-id3", NULL))) {
+		gst_object_unref (GST_OBJECT (spider));
+		gst_object_unref (GST_OBJECT (tagger));
+		gst_caps_unref (filtercaps);
+		return NULL;
+	}
+
+#ifdef HAVE_GSTREAMER_0_10
+	if (! (filter = gst_element_factory_make ("capsfilter", NULL))) {
+		gst_object_unref (GST_OBJECT (spider));
+		gst_object_unref (GST_OBJECT (tagger));
+		gst_caps_unref (filtercaps);
+		return NULL;
+	}
+	g_object_set (GST_OBJECT (tagger), "v1-tag", TRUE, NULL);
+#else
 	gst_element_set (tagger, "v1-tag", TRUE, NULL);
-        gst_bin_add_many (GST_BIN (pipeline), tagger, identity, NULL);
+#endif
         
-	filtercaps = gst_caps_new_simple ("application/x-id3", NULL);
+        gst_bin_add_many (GST_BIN (pipeline), tagger, identity, NULL);
+
+#ifdef HAVE_GSTREAMER_0_8
 	if (!gst_element_link_filtered (tagger, identity, filtercaps)) {
+#endif
+#ifdef HAVE_GSTREAMER_0_10
+	g_object_set (G_OBJECT (filter), "filter-caps", filtercaps, NULL);
+	if (!gst_element_link_many (tagger, filter, identity, NULL)) {
+#endif
+
 		g_warning("Linking id3tag and identity failed");
-                gst_caps_free(filtercaps);
+                gst_caps_unref(filtercaps);
                 gst_object_unref(GST_OBJECT(tagger));
                 gst_object_unref(GST_OBJECT(identity));
                 return NULL;
         }
-	gst_caps_free (filtercaps);
+	gst_caps_unref (filtercaps);
 
-        gst_element_link_many(element, tagger, NULL);
+        gst_element_link_many (element, tagger, NULL);
         
 	return identity;
 }
@@ -458,6 +497,7 @@
 			     newval);
 }
 
+#ifdef HAVE_GSTREAMER_0_8
 static void
 rb_metadata_gst_found_tag (GObject *pipeline, GstElement *source, GstTagList *tags, RBMetaData *md)
 {
@@ -465,15 +505,6 @@
 }
 
 static void
-rb_metadata_gst_typefind_cb (GstElement *typefind, guint probability, GstCaps *caps, RBMetaData *md)
-{
-	if (gst_caps_get_size (caps) > 0) {
-		md->priv->type = g_strdup (gst_structure_get_name (gst_caps_get_structure (caps, 0)));
-		rb_debug ("found type %s", md->priv->type);
-	}
-}
-
-static void
 rb_metadata_gst_fakesink_handoff_cb (GstElement *fakesink, GstBuffer *buf, GstPad *pad, RBMetaData *md)
 {
 	if (md->priv->handoff) {
@@ -488,6 +519,17 @@
 	rb_debug ("in fakesink handoff");
 	md->priv->handoff = TRUE;
 }
+#endif
+
+static void
+rb_metadata_gst_typefind_cb (GstElement *typefind, guint probability, GstCaps *caps, RBMetaData *md)
+{
+	if (gst_caps_get_size (caps) > 0) {
+		md->priv->type = g_strdup (gst_structure_get_name (gst_caps_get_structure (caps, 0)));
+		rb_debug ("found type %s", md->priv->type);
+	}
+}
+
 
 static void
 rb_metadata_gst_new_decoded_pad_cb (GstElement *decodebin, GstPad *pad, gboolean last, RBMetaData *md)
@@ -525,7 +567,7 @@
 		}
 	}
 
-	gst_caps_free (caps);
+	gst_caps_unref (caps);
 }
 
 static void
@@ -552,6 +594,81 @@
 	return elem;
 }
 
+#ifdef HAVE_GSTREAMER_0_10
+static gboolean
+rb_metadata_bus_handler (GstBus *bus, GstMessage *message, RBMetaData *md)
+{
+	switch (GST_MESSAGE_TYPE (message)) {
+	case GST_MESSAGE_EOS:
+		rb_debug ("EOS reached");
+		md->priv->eos = TRUE;
+		break;
+	case GST_MESSAGE_ERROR:
+	{
+		GError *gerror;
+		gchar *debug;
+
+		gst_message_parse_error (message, &gerror, &debug);
+		rb_debug ("caught error: %s ", gerror->message);
+		md->priv->error = g_error_new_literal (RB_METADATA_ERROR,
+						       RB_METADATA_ERROR_GENERAL,
+						       gerror->message);
+
+		g_error_free (gerror);
+		g_free (debug);
+		break;
+	}
+	case GST_MESSAGE_TAG:
+	{
+		GstTagList *tags;
+
+		gst_message_parse_tag (message, &tags);
+		if (tags) {
+			gst_tag_list_foreach (tags, (GstTagForeachFunc) rb_metadata_gst_load_tag, md);
+			gst_tag_list_free (tags);
+		} else {
+			const gchar *errmsg = "Could not retrieve tag list";
+
+			rb_debug ("caught error: %s ", errmsg);
+			md->priv->error = g_error_new_literal (RB_METADATA_ERROR,
+							       RB_METADATA_ERROR_GENERAL,
+							       errmsg);
+		}
+		break;
+	}
+	default:
+		rb_debug ("message of type %d", GST_MESSAGE_TYPE (message));
+		break;
+	}
+
+	return FALSE;
+}
+
+static void 
+rb_metadata_event_loop (RBMetaData *md, GstElement *element)
+{
+	GstBus *bus;
+	gboolean done = FALSE;
+
+	bus = gst_element_get_bus (element);
+	g_return_if_fail (bus != NULL);
+
+	while (!done && !md->priv->eos) {
+		GstMessage *message;
+
+		message = gst_bus_pop (bus);
+		if (message == NULL) {
+			gst_object_unref (bus);
+			return;
+		}
+
+		done = rb_metadata_bus_handler (bus, message, md);
+		gst_message_unref (message);
+	}
+	gst_object_unref (bus);
+}
+#endif
+
 void
 rb_metadata_load (RBMetaData *md,
 		  const char *uri,
@@ -561,6 +678,9 @@
 	GstElement *urisrc = NULL;
 	GstElement *decodebin = NULL;
 	GstElement *typefind = NULL;
+#ifdef HAVE_GSTREAMER_0_10
+	GstStateChangeReturn state_ret;
+#endif
 
 	g_free (md->priv->uri);
 	md->priv->uri = NULL;
@@ -616,6 +736,7 @@
  		goto out;
  	}
 
+#ifdef HAVE_GSTREAMER_0_8
 	g_object_set (G_OBJECT (md->priv->sink), "signal-handoffs", TRUE, NULL);
  
  	g_signal_connect_object (pipeline, "error", G_CALLBACK (rb_metadata_gst_error_cb), md, 0);
@@ -623,7 +744,7 @@
 
 	g_signal_connect_object (md->priv->sink, "handoff", G_CALLBACK (rb_metadata_gst_fakesink_handoff_cb), md, 0);
 	g_signal_connect_object (md->priv->sink, "eos", G_CALLBACK (rb_metadata_gst_eos_cb), md, 0);
-
+#endif
  	g_signal_connect_object (decodebin, "new-decoded-pad", G_CALLBACK (rb_metadata_gst_new_decoded_pad_cb), md, 0);
  	g_signal_connect_object (decodebin, "unknown-type", G_CALLBACK (rb_metadata_gst_unknown_type_cb), md, 0);
   
@@ -639,6 +760,7 @@
  	gst_element_link (urisrc, decodebin);
 
 	md->priv->pipeline = pipeline;
+#ifdef HAVE_GSTREAMER_0_8
 	gst_element_set_state (pipeline, GST_STATE_PLAYING);
 	while (gst_bin_iterate (GST_BIN (pipeline))
 	       && md->priv->error == NULL
@@ -647,32 +769,74 @@
 		;
 
 	if (md->priv->handoff) {
-		/* We caught the first buffer, which means the decoder should have read all
+#endif
+#ifdef HAVE_GSTREAMER_0_10
+	rb_debug ("going to PAUSED for metadata, uri: %s", uri);
+	state_ret = gst_element_set_state (pipeline, GST_STATE_PAUSED);
+        if (state_ret == GST_STATE_CHANGE_ASYNC && !md->priv->eos) {
+	    GstState state;
+	    state_ret = gst_element_get_state (GST_ELEMENT (pipeline),
+			    &state, NULL, 5 * GST_SECOND);
+	}
+
+	if (state_ret != GST_STATE_CHANGE_FAILURE) {
+		/* Post application specific message so we'll know when to stop
+		 * the message loop */
+		GstBus *bus;
+		bus = gst_element_get_bus (GST_ELEMENT (pipeline));
+		if (bus) {
+			gst_bus_post (bus, 
+			gst_message_new_application (GST_OBJECT (pipeline), NULL));
+			gst_object_unref (bus);
+		}
+
+		/* Poll the bus for messages */
+		rb_metadata_event_loop (md, GST_ELEMENT (pipeline));
+#endif
+		/* We caught the first buffer(0.8) or went to PAUSED (0.10),
+		 * which means the decoder should have read all
 		 * of the metadata, and should know the length now.
 		 */
 		if (g_hash_table_lookup (md->priv->metadata, GINT_TO_POINTER (RB_METADATA_FIELD_DURATION)) == NULL) {
 			GstFormat format = GST_FORMAT_TIME;
 			gint64 length;
+			GValue *newval;
 			
-			if (gst_element_query (md->priv->sink, GST_QUERY_TOTAL,
-					       &format, &length)) {
-				GValue *newval = g_new0 (GValue, 1);
+#ifdef HAVE_GSTREAMER_0_8
+			if (gst_element_query (md->priv->sink, GST_QUERY_TOTAL, &format, &length)) {
+#endif
+#ifdef HAVE_GSTREAMER_0_10
+			if (gst_element_query_duration (md->priv->sink, &format, &length)) {
+				g_assert (format == GST_FORMAT_TIME);
+#endif
+				newval = g_new0 (GValue, 1);
 				
 				rb_debug ("duration query succeeded");
 				
 				g_value_init (newval, G_TYPE_ULONG);
 				/* FIXME - use guint64 for duration? */
-				g_value_set_ulong (newval, (long) (length / (1 * 1000 * 1000 * 1000)));
+				g_value_set_ulong (newval, (long) (length / GST_SECOND));
 				g_hash_table_insert (md->priv->metadata, GINT_TO_POINTER (RB_METADATA_FIELD_DURATION),
 						     newval);
 			} else {
 				rb_debug ("duration query failed!");
 			}
 		}
-	} else if (md->priv->eos)
-		rb_debug ("caught eos without handoff!");
-	
+	}
+#ifdef HAVE_GSTREAMER_0_8
+	else if (md->priv->eos) {
+		g_warning ("caught eos without handoff!");
+	}
+
 	gst_element_set_state (pipeline, GST_STATE_NULL);
+#endif
+#ifdef HAVE_GSTREAMER_0_10
+	state_ret = gst_element_set_state (pipeline, GST_STATE_NULL);
+	if (state_ret == GST_STATE_CHANGE_ASYNC) {
+	    g_warning ("Failed to return metadata reader to NULL state");
+	}
+	md->priv->handoff = (state_ret == GST_STATE_CHANGE_SUCCESS);
+#endif
 
 	/* report errors for various failure cases.
 	 * these don't include the URI as the load failure dialog
@@ -767,7 +931,7 @@
 				 * but there is no easy way of doing so
 				 */
 			} else {
-				gst_tag_setter_add_values (GST_TAG_SETTER (tagsetter),
+				gst_tag_setter_add_tag_values (GST_TAG_SETTER (tagsetter),
 							   GST_TAG_MERGE_REPLACE,
 							   tag, &newval, NULL);
 			}
@@ -868,7 +1032,7 @@
 		goto missing_plugin;
 	}
 
-	gst_tag_setter_set_merge_mode (GST_TAG_SETTER (tagger), GST_TAG_MERGE_REPLACE);
+	gst_tag_setter_set_tag_merge_mode (GST_TAG_SETTER (tagger), GST_TAG_MERGE_REPLACE);
 	g_hash_table_foreach (md->priv->metadata, 
 			      (GHFunc) rb_metadata_gst_add_tag_data,
 			      GST_TAG_SETTER (tagger));
@@ -878,10 +1042,15 @@
 
 	md->priv->pipeline = pipeline;
 	gst_element_set_state (pipeline, GST_STATE_PLAYING);
+#ifdef HAVE_GSTREAMER_0_8
 	while (gst_bin_iterate (GST_BIN (pipeline))
 	       && md->priv->error == NULL
 	       && !md->priv->eos)
 		;
+#endif
+#ifdef HAVE_GSTREAMER_0_10
+	rb_metadata_event_loop (md, GST_ELEMENT (pipeline));
+#endif
 	gst_element_set_state (pipeline, GST_STATE_NULL);
 	if (md->priv->error) {
 		g_propagate_error (error, md->priv->error);
Index: player/rb-player-gst.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/player/rb-player-gst.c,v
retrieving revision 1.52
diff -u -r1.52 rb-player-gst.c
--- player/rb-player-gst.c	3 Dec 2005 10:56:42 -0000	1.52
+++ player/rb-player-gst.c	5 Dec 2005 11:49:00 -0000
@@ -29,7 +29,9 @@
 #include <glib/gi18n.h>
 #include <gdk/gdk.h>
 #include <gst/gst.h>
+#ifdef HAVE_GSTREAMER_0_8
 #include <gst/gconf/gconf.h>
+#endif
 #include <libgnomevfs/gnome-vfs-ops.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
 
@@ -62,8 +64,10 @@
 	guint idle_buffering_id;
 	GHashTable *idle_info_ids;
 
+#ifdef HAVE_GSTREAMER_0_8
 	guint error_signal_id;
 	guint buffering_signal_id;
+#endif
 
 	float cur_volume;
 
@@ -191,10 +195,12 @@
 	g_hash_table_destroy (mp->priv->idle_info_ids);
 
 	if (mp->priv->playbin) {
+#ifdef HAVE_GSTREAMER_0_8
 		g_signal_handler_disconnect (G_OBJECT (mp->priv->playbin),
 					     mp->priv->error_signal_id);
 		g_signal_handler_disconnect (G_OBJECT (mp->priv->playbin),
 					     mp->priv->buffering_signal_id);
+#endif
 		
 		gst_element_set_state (mp->priv->playbin,
 				       GST_STATE_NULL);
@@ -275,6 +281,7 @@
 	return FALSE;
 }
 
+#ifdef HAVE_GSTREAMER_0_8
 static void
 eos_cb (GstElement *element,
 	RBPlayer *mp)
@@ -342,6 +349,7 @@
 						   signal,
 						   destroy_idle_signal);
 }
+#endif
 
 static void
 process_tag (const GstTagList *list, const gchar *tag, RBPlayer *player)
@@ -404,6 +412,7 @@
 	g_hash_table_insert (player->priv->idle_info_ids, GUINT_TO_POINTER (signal->id), NULL);
 }
 
+#ifdef HAVE_GSTREAMER_0_8
 static void
 found_tag_cb (GObject *pipeline, GstElement *source, GstTagList *tags, RBPlayer *player)
 {
@@ -428,6 +437,83 @@
 		g_source_remove (mp->priv->idle_buffering_id);
 	mp->priv->idle_buffering_id = g_idle_add ((GSourceFunc) emit_signal_idle, signal);
 }
+#elif HAVE_GSTREAMER_0_10
+static gboolean
+rb_player_bus_cb (GstBus * bus, GstMessage * message, RBPlayer *mp)
+{
+	g_return_val_if_fail (mp != NULL, FALSE);
+
+	switch (GST_MESSAGE_TYPE (message)) {
+	case GST_MESSAGE_ERROR: {
+		char *debug;
+		GError *error, *sig_error;
+		int code;
+
+		gst_message_parse_error (message, &error, &debug);
+
+		if ((error->domain == GST_CORE_ERROR)
+			|| (error->domain == GST_LIBRARY_ERROR)
+			|| (error->code == GST_RESOURCE_ERROR_BUSY)) {
+			code = RB_PLAYER_ERROR_NO_AUDIO;
+		} else {
+		code = RB_PLAYER_ERROR_GENERAL;
+		}
+
+		sig_error = g_error_new_literal (RB_PLAYER_ERROR,
+						 code,
+						 error->message);
+		g_signal_emit (G_OBJECT (mp),
+			       rb_player_signals[ERROR], 0,
+			       sig_error);
+
+		/* close if not already closing */
+		if (mp->priv->uri != NULL)
+			rb_player_close (mp, NULL);
+
+		g_error_free (error);
+		g_free (debug);
+		break;
+	}
+	case GST_MESSAGE_EOS:
+		g_signal_emit (G_OBJECT (mp), rb_player_signals[EOS], 0);
+		break;
+	case GST_MESSAGE_TAG: {
+		GstTagList *tags;
+		gst_message_parse_tag (message, &tags);
+
+		gst_tag_list_foreach (tags, (GstTagForeachFunc) process_tag, mp);
+		gst_tag_list_free (tags);
+		break;
+	}
+	case GST_MESSAGE_BUFFERING: {
+		RBPlayerSignal *signal;
+		const GstStructure *s;
+		gint progress;
+
+		s = gst_message_get_structure (message);
+		if (!gst_structure_get_int (s, "buffer-percent", &progress)) {
+			g_warning ("Could not get value from BUFFERING message");
+			break;
+		}
+		signal = g_new0 (RBPlayerSignal, 1);
+		signal->type = BUFFERING;
+
+		g_object_ref (G_OBJECT (mp));
+		signal->object = mp;
+		signal->info = g_new0 (GValue, 1);
+		g_value_init (signal->info, G_TYPE_UINT);
+		g_value_set_uint (signal->info, (guint)progress);
+		g_idle_add ((GSourceFunc) emit_signal_idle, signal);
+		break;
+	} 
+	default:
+		break;
+	}
+
+	return TRUE;
+}
+ 
+#endif
 
 static gboolean
 rb_player_construct (RBPlayer *mp, GError **error)
@@ -445,6 +531,7 @@
 	fakesink = gst_element_factory_make ("fakesink", "fakesink");
 	g_object_set (G_OBJECT (mp->priv->playbin), "video-sink", fakesink, NULL);
 
+#ifdef HAVE_GSTREAMER_0_8
 	g_signal_connect_object (G_OBJECT (mp->priv->playbin),
 				 "found_tag",
 				 G_CALLBACK (found_tag_cb),
@@ -464,6 +551,15 @@
 
 	/* Output sink */
 	sink = gst_gconf_get_default_audio_sink ();
+#endif
+#ifdef HAVE_GSTREAMER_0_10
+	gst_bus_add_watch (gst_element_get_bus (GST_ELEMENT (mp->priv->playbin)),
+			     (GstBusFunc) rb_player_bus_cb, mp);
+
+	/* Output sink */
+	sink = gst_element_factory_make ("gconfaudiosink", "audiosink");
+#endif
+	
 	if (sink == NULL) {
 		g_set_error (error,
 			     RB_PLAYER_ERROR,
@@ -474,8 +570,10 @@
 	}
 
 	g_object_set (G_OBJECT (mp->priv->playbin), "audio-sink", sink, NULL);
+#ifdef HAVE_GSTREAMER_0_8
 	g_signal_connect_object (G_OBJECT (mp->priv->playbin), "eos",
 				 G_CALLBACK (eos_cb), mp, 0);
+#endif
 
 	if (mp->priv->cur_volume > 1.0)
 		mp->priv->cur_volume = 1.0;
@@ -503,6 +601,8 @@
 rb_player_new (GError **error)
 {
 	RBPlayer *mp;
+
+#ifdef HAVE_GSTREAMER_0_8
 	GstElement *dummy;
 
 	dummy = gst_element_factory_make ("fakesink", "fakesink");
@@ -514,6 +614,7 @@
 			     _("Couldn't initialize scheduler.  Did you run gst-register?"));
 		return NULL;
 	}
+#endif
 
 	mp = RB_PLAYER (g_object_new (RB_TYPE_PLAYER, NULL, NULL));
 
@@ -536,17 +637,28 @@
 	rb_debug ("syncing pipeline");
 	if (mp->priv->playing) {
  		rb_debug ("PLAYING pipeline");
- 		if (gst_element_set_state (mp->priv->playbin,
- 					   GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+#ifdef HAVE_GSTREAMER_0_8
+ 		if (gst_element_set_state (mp->priv->playbin, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+#elif HAVE_GSTREAMER_0_10
+		if (gst_element_set_state (mp->priv->playbin, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
+#endif
  			return FALSE;
 		}
 	} else {
 		rb_debug ("PAUSING pipeline");
-		if (gst_element_set_state (mp->priv->playbin,
-					   GST_STATE_PAUSED) == GST_STATE_FAILURE) {
+#ifdef HAVE_GSTREAMER_0_8
+ 		if (gst_element_set_state (mp->priv->playbin, GST_STATE_PAUSED) == GST_STATE_FAILURE) {
+#elif HAVE_GSTREAMER_0_10
+		if (gst_element_set_state (mp->priv->playbin, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) {
+#endif
 			return FALSE;
 		}
 	}
+#ifdef HAVE_GSTREAMER_0_10
+	/* FIXME: Set up a timeout to watch if the pipeline doesn't 
+         * go to PAUSED/PLAYING within some time (5 secs maybe?)
+	 */
+#endif
 	return TRUE;
 }
 
@@ -583,7 +695,11 @@
 {
 	GstElement *source;
 
+#ifdef HAVE_GSTREAMER_0_10
+	g_object_get (object, "source", &source, NULL);
+#elif HAVE_GSTREAMER_0_8
 	gst_element_get (GST_ELEMENT (object), "source", &source, NULL);
+#endif
 	rb_debug ("got source %p", source);
 	if (source) {
 		g_signal_handlers_disconnect_by_func (object, cdda_got_source_cb, uri);
@@ -652,6 +768,7 @@
 		rb_player_close (mp, NULL);
 		return FALSE;
 	}
+
 	end_gstreamer_operation (mp, FALSE, error);
 	return TRUE;
 }
@@ -693,7 +810,11 @@
 		return TRUE;
 
 	begin_gstreamer_operation (mp);
+#ifdef HAVE_GSTREAMER_0_8
 	ret = gst_element_set_state (mp->priv->playbin, GST_STATE_READY) == GST_STATE_SUCCESS;
+#elif HAVE_GSTREAMER_0_10
+	ret = gst_element_set_state (mp->priv->playbin, GST_STATE_READY) == GST_STATE_CHANGE_SUCCESS;
+#endif
 	end_gstreamer_operation (mp, !ret, error);
 	return ret;
 }
@@ -825,12 +946,27 @@
 gboolean
 rb_player_seekable (RBPlayer *mp)
 {
+#ifdef HAVE_GSTREAMER_0_8
+	/* FIXME we're lying here,
+	 * (0.8) trying a seek might disrupt playback */
+	gboolean can_seek = TRUE;
+#elif HAVE_GSTREAMER_0_10
+	/* (0.10) Need to send a seekable query on playbin */
+	gboolean can_seek = TRUE;
+	GstQuery *query;
+#endif
+
 	g_return_val_if_fail (RB_IS_PLAYER (mp), FALSE);
 	g_return_val_if_fail (mp->priv->playbin != NULL, FALSE);
+#ifdef HAVE_GSTREAMER_0_10
+	query = gst_query_new_seeking (GST_FORMAT_TIME);
+	g_return_val_if_fail (gst_element_query (mp->priv->playbin, query),
+	    FALSE);
+	gst_query_parse_seeking (query, NULL, &can_seek, NULL, NULL);
+	gst_query_unref (query);
+#endif
 
-	/* FIXME we're lying here, no idea how to fix this though, without trying
-	 * a seek which might disrupt playback */
-	return TRUE;
+	return can_seek;
 }
 
 void
@@ -841,7 +977,16 @@
 
 	g_return_if_fail (mp->priv->playbin != NULL);
 
+#ifdef HAVE_GSTREAMER_0_8
 	gst_element_set_state (mp->priv->playbin, GST_STATE_PAUSED);
+#elif HAVE_GSTREAMER_0_10
+	if (gst_element_set_state (mp->priv->playbin, GST_STATE_PAUSED) == GST_STATE_CHANGE_ASYNC) {
+		/* FIXME: Use a timeout on get_state. Post a GError somewhere on failed? */
+		if (gst_element_get_state (mp->priv->playbin, NULL, NULL, 3 * GST_SECOND) != GST_STATE_CHANGE_SUCCESS) {
+			g_warning ("Failed to pause pipeline before seek");
+		}
+	}
+#endif
 
 #ifdef WITH_DAAP_SUPPORT
 	/* FIXME?
@@ -857,16 +1002,25 @@
 		rb_daap_src_set_time (time);
 	} else {
 #endif
+#ifdef HAVE_GSTREAMER_0_8
 	gst_element_seek (mp->priv->playbin, 
 			  GST_FORMAT_TIME 
 			  | GST_SEEK_METHOD_SET 
 			  | GST_SEEK_FLAG_FLUSH, 
 			  time * GST_SECOND);
+#elif HAVE_GSTREAMER_0_10
+	gst_element_seek (mp->priv->playbin, 1.0, 
+			  GST_FORMAT_TIME, GST_SEEK_FLAG_FLUSH, 
+			  GST_SEEK_TYPE_SET, time * GST_SECOND,
+			  GST_SEEK_TYPE_NONE, -1);
+#endif
+	
 #ifdef WITH_DAAP_SUPPORT
 	}
 #endif
-	if (mp->priv->playing)
+	if (mp->priv->playing) {
 		gst_element_set_state (mp->priv->playbin, GST_STATE_PLAYING);
+	}
 }
 
 long
@@ -875,20 +1029,24 @@
 	g_return_val_if_fail (RB_IS_PLAYER (mp), -1);
 
 	if (mp->priv->playbin != NULL) {
-		gint64 gst_position;
-		glong ret = 0;
-
+		gint64 position = -1;
 		GstFormat fmt = GST_FORMAT_TIME;
-		gst_element_query (mp->priv->playbin, GST_QUERY_POSITION, &fmt, &gst_position);
-		ret = (glong) (gst_position / (1000*1000*1000));
+		
+#ifdef HAVE_GSTREAMER_0_8
+		gst_element_query (mp->priv->playbin, GST_QUERY_POSITION, &fmt, &position);
+#elif HAVE_GSTREAMER_0_10
+		gst_element_query_position (mp->priv->playbin, &fmt, &position);
+#endif
+		if (position != -1)
+			position /= GST_SECOND;
 
 #ifdef WITH_DAAP_SUPPORT
 		if (mp->priv->uri && g_strncasecmp (mp->priv->uri, "daap://", 7) == 0) {
-			ret += rb_daap_src_get_time ();
+			position += rb_daap_src_get_time ();
 		}
 #endif
 
-		return ret;
+		return (long) position;
 	} else
 		return -1;
 }
Index: player/rb-recorder-gst.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/player/rb-recorder-gst.c,v
retrieving revision 1.10
diff -u -r1.10 rb-recorder-gst.c
--- player/rb-recorder-gst.c	29 Nov 2005 01:40:49 -0000	1.10
+++ player/rb-recorder-gst.c	5 Dec 2005 11:49:01 -0000
@@ -30,18 +30,24 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#include <gst/gst.h>
-#include <gst/gconf/gconf.h>
-#include <gst/play/play.h>
 #include <glib/gi18n.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
 #include <nautilus-burn-recorder.h>
+#include <gst/gst.h>
+#ifdef HAVE_GSTREAMER_0_8
+#include <gst/gconf/gconf.h>
+#include <gst/play/play.h>
+#endif
 
 #include "rb-recorder.h"
 #include "rb-recorder-marshal.h"
 
 #include "rb-debug.h"
 
+#ifdef HAVE_GSTREAMER_0_8
+#define gst_caps_unref gst_caps_free
+#endif
+
 static void rb_recorder_class_init (RBRecorderClass *klass);
 static void rb_recorder_init       (RBRecorder      *recorder);
 static void rb_recorder_finalize   (GObject         *object);
@@ -52,34 +58,38 @@
         char       *tmp_dir;
         
         GstElement *pipeline;
-        
-        GstElement *src;
-        GstPad     *src_pad;
         GstElement *decoder;
+        GstElement *src;
         GstElement *typefind;
         GstElement *audioconvert;
         GstElement *audioscale;
         GstElement *encoder;
         GstElement *sink;
 
+#ifdef HAVE_GSTREAMER_0_8
+        GstPad     *src_pad;
+        GError     *error;
+
         guint       idle_id;
         guint       error_signal_id;
         guint       eos_signal_id;
+#elif HAVE_GSTREAMER_0_10
+	GstElement *capsfilter;
+	gboolean    got_audio_pad;
+#endif
+
         guint       tick_timeout_id;
 
         GTimer     *start_timer;
         guint64     start_pos;
 
         double      progress;
-
         GList      *tracks;
 
         NautilusBurnDrive    *drive;
         NautilusBurnRecorder *recorder;
 
         gboolean    playing;
-
-        GError     *error;
 };
 
 typedef enum {
@@ -93,11 +103,13 @@
         LAST_SIGNAL
 } RBRecorderSignalType;
 
+#ifdef HAVE_GSTREAMER_0_8
 typedef struct {
         RBRecorder *object;
         GError     *error;
         GValue     *info;
 } RBRecorderSignal;
+#endif
 
 static guint rb_recorder_signals [LAST_SIGNAL] = { 0 };
 
@@ -263,6 +275,7 @@
                 }
         }
 
+#ifdef HAVE_GSTREAMER_0_8
         if (recorder->priv->idle_id > 0) {
                 g_source_remove (recorder->priv->idle_id);
                 recorder->priv->idle_id = 0;
@@ -283,6 +296,9 @@
                                                      recorder->priv->eos_signal_id);
                 recorder->priv->eos_signal_id = 0;
         }
+#elif HAVE_GSTREAMER_0_10
+	recorder->priv->got_audio_pad = FALSE;
+#endif
 
         gst_object_unref (GST_OBJECT (recorder->priv->pipeline));
         recorder->priv->pipeline = NULL;
@@ -311,6 +327,7 @@
         return TRUE;
 }
 
+#ifdef HAVE_GSTREAMER_0_8
 static void
 eos_cb (GstElement *element,
         RBRecorder *recorder)
@@ -369,6 +386,98 @@
 
         rb_recorder_gst_signal_error (recorder, error->message);
 }
+#elif HAVE_GSTREAMER_0_10
+static void
+rb_recorder_gst_signal_error (RBRecorder *recorder,
+			      const char *msg)
+{
+	GError *error;
+
+	g_object_ref (recorder);
+	error = g_error_new_literal (RB_RECORDER_ERROR,
+				     RB_RECORDER_ERROR_GENERAL,
+				     msg);
+	g_signal_emit (G_OBJECT (recorder),
+		       rb_recorder_signals [ERROR],
+		       0,
+		       error);
+
+	/* close if not already closing */
+	if (recorder->priv->src_uri != NULL)
+		rb_recorder_close (recorder, NULL);
+
+	g_object_unref (recorder);
+	g_error_free (error);
+}
+
+static gboolean
+pipe_message (GstBus *bus, GstMessage *message, RBRecorder *recorder)
+{
+	switch (message->type) {
+	case GST_MESSAGE_EOS: 
+		rb_debug ("EOS");
+
+		if (recorder->priv->pipeline)
+			gst_element_set_state (recorder->priv->pipeline, GST_STATE_NULL);
+
+		g_signal_emit (G_OBJECT (recorder), 
+			       rb_recorder_signals [EOS], 0);
+		break;
+	case GST_MESSAGE_ERROR:
+	{
+		GError *error;
+		gchar *debug;
+
+		rb_debug ("Error");
+		gst_message_parse_error (message, &error, &debug);
+		if (error) {
+			rb_recorder_gst_signal_error (recorder, error->message);
+			g_error_free (error);
+		} else {
+			rb_recorder_gst_signal_error (recorder, NULL);
+		}
+
+		g_free (debug);
+		break;
+	}
+	default:
+		break;
+	}
+
+	return TRUE;
+}
+#endif
+ 
+static void
+rb_recorder_new_pad_cb (GstElement *decodebin,
+			GstPad     *pad,
+			gboolean    last,
+			RBRecorder *recorder)
+{
+	GstCaps      *caps;
+	GstStructure *str;
+	GstPad       *audio_pad;
+
+	audio_pad = gst_element_get_pad (recorder->priv->audioconvert, "sink");
+
+	/* Only link once. */
+	if (GST_PAD_IS_LINKED (audio_pad))
+		return;
+
+	/* Only link audio. */
+	caps = gst_pad_get_caps (pad);
+	str = gst_caps_get_structure (caps, 0);
+	if (!g_strrstr (gst_structure_get_name (str), "audio")) {
+		gst_caps_unref (caps);
+		return;
+	}
+
+	gst_caps_unref (caps);
+#ifdef HAVE_GSTREAMER_0_10
+	if (gst_pad_link (pad, audio_pad))
+		recorder->priv->got_audio_pad = TRUE;
+#endif
+}
 
 static void
 rb_recorder_construct (RBRecorder *recorder,
@@ -377,6 +486,9 @@
 {
         char    *element_name = NULL;
         GstCaps *filtercaps;
+#ifdef HAVE_GSTREAMER_0_10
+	GstBus  *bus;
+#endif
 
 #define MAKE_ELEMENT_OR_LOSE(NAME, NICE) G_STMT_START {                 \
                 element_name = #NAME ;                                  \
@@ -389,7 +501,7 @@
         rb_recorder_gst_free_pipeline (recorder);
 
         /* The recording pipeline looks like:
-         *  { src ! spider ! audioconvert ! audioscale
+         *  { src ! decodebin ! audioconvert ! audioscale
          *    ! audio/x-raw-int,rate=44100,width=16,depth=16 ! wavenc ! sink }
          */
 
@@ -403,11 +515,17 @@
                 return;
         }
 
+#ifdef HAVE_GSTREAMER_0_8
         recorder->priv->error_signal_id =
                 g_signal_connect_object (G_OBJECT (recorder->priv->pipeline),
                                          "error",
                                          G_CALLBACK (error_cb),
                                          recorder, 0);
+#elif HAVE_GSTREAMER_0_10
+	bus = gst_element_get_bus (recorder->priv->pipeline);
+	gst_bus_add_watch (bus, (GstBusFunc) pipe_message, recorder);
+	gst_object_unref (bus);
+#endif
 
         /* Construct elements */
 
@@ -416,16 +534,22 @@
         MAKE_ELEMENT_OR_LOSE(gnomevfssrc, src);
         gst_bin_add (GST_BIN (recorder->priv->pipeline), recorder->priv->src);
 
+#ifdef HAVE_GSTREAMER_0_8
         recorder->priv->src_pad = gst_element_get_pad (recorder->priv->src, "src");
         g_assert (recorder->priv->src_pad); /* TODO: GError */
+#endif
 
         /* The queue */
 
         MAKE_ELEMENT_OR_LOSE(typefind, typefind);
         gst_bin_add (GST_BIN (recorder->priv->pipeline), recorder->priv->typefind);
 
-        MAKE_ELEMENT_OR_LOSE(spider, decoder);
+        MAKE_ELEMENT_OR_LOSE(decodebin, decoder);
         gst_bin_add (GST_BIN (recorder->priv->pipeline), recorder->priv->decoder);
+	
+	g_signal_connect_object (G_OBJECT (recorder->priv->decoder), 
+				 "new_decoded_pad", G_CALLBACK (rb_recorder_new_pad_cb), 
+				 recorder, 0);
 
         MAKE_ELEMENT_OR_LOSE(audioconvert, audioconvert);
         gst_bin_add (GST_BIN (recorder->priv->pipeline), recorder->priv->audioconvert);
@@ -433,6 +557,11 @@
         MAKE_ELEMENT_OR_LOSE(audioscale, audioscale);
         gst_bin_add (GST_BIN (recorder->priv->pipeline), recorder->priv->audioscale);
 
+#ifdef HAVE_GSTREAMER_0_10
+	MAKE_ELEMENT_OR_LOSE(capsfilter, capsfilter);
+	gst_bin_add (GST_BIN (recorder->priv->pipeline), recorder->priv->capsfilter);
+#endif
+	
         MAKE_ELEMENT_OR_LOSE(wavenc, encoder);
         gst_bin_add (GST_BIN (recorder->priv->pipeline), recorder->priv->encoder);
 
@@ -450,6 +579,13 @@
         }
         gst_bin_add (GST_BIN (recorder->priv->pipeline), recorder->priv->sink);
 
+        filtercaps = gst_caps_new_simple ("audio/x-raw-int",
+                                          "channels", G_TYPE_INT, 2,
+                                          "rate",     G_TYPE_INT, 44100,
+                                          "width",    G_TYPE_INT, 16,
+                                          "depth",    G_TYPE_INT, 16,
+                                          NULL);
+#ifdef HAVE_GSTREAMER_0_8
         gst_element_link_many (recorder->priv->src,
                                recorder->priv->typefind,
                                recorder->priv->decoder,
@@ -457,12 +593,6 @@
                                recorder->priv->audioscale,
                                NULL);
 
-        filtercaps = gst_caps_new_simple ("audio/x-raw-int",
-                                          "channels", G_TYPE_INT, 2,
-                                          "rate",     G_TYPE_INT, 44100,
-                                          "width",    G_TYPE_INT, 16,
-                                          "depth",    G_TYPE_INT, 16,
-                                          NULL);
         gst_element_link_filtered (recorder->priv->audioscale,
                                    recorder->priv->encoder,
                                    filtercaps);
@@ -474,6 +604,21 @@
         recorder->priv->eos_signal_id =
                 g_signal_connect_object (G_OBJECT (recorder->priv->pipeline), "eos",
                                          G_CALLBACK (eos_cb), recorder, 0);
+#elif HAVE_GSTREAMER_0_10
+	g_object_set (recorder->priv->capsfilter, "filter-caps",  filtercaps, NULL);
+
+	gst_element_link_many (recorder->priv->src,
+			       recorder->priv->typefind,
+			       recorder->priv->decoder,
+			       NULL);
+
+	gst_element_link_many (recorder->priv->audioconvert,
+			       recorder->priv->audioscale,
+			       recorder->priv->capsfilter,
+			       recorder->priv->encoder,
+			       recorder->priv->sink,
+			       NULL);
+#endif
 
         rb_debug ("Pipeline construction complete");
         return;
@@ -536,9 +681,9 @@
 rb_recorder_new (GError **error)
 {
         RBRecorder *recorder;
-        GstElement *dummy;
 
-        rb_debug ("New rb_recorder");
+#ifdef HAVE_GSTREAMER_0_8
+        GstElement *dummy;
 
         dummy = gst_element_factory_make ("fakesink", "fakesink");
         if (!dummy
@@ -548,6 +693,7 @@
                              _("Couldn't initialize scheduler.  Did you run gst-register?"));
                 return NULL;
         }
+#endif
 
         recorder = g_object_new (RB_TYPE_RECORDER, NULL, NULL);
 
@@ -557,19 +703,30 @@
 static gboolean
 tick_timeout_cb (RBRecorder *recorder)
 {
-        gint64           position, total;
-        double           fraction;
-        double           rate;
-        double           elapsed;
-        double           secs;
-        static GstFormat format = GST_FORMAT_BYTES;
+        gint64 position, total;
+        double fraction;
+        double rate;
+        double elapsed;
+        double secs;
+        GstFormat format = GST_FORMAT_BYTES;
+#ifdef HAVE_GSTREAMER_0_10
+	GstState  state;
+#endif
 
         g_return_val_if_fail (recorder != NULL, FALSE);
         g_return_val_if_fail (RB_IS_RECORDER (recorder), FALSE);
         g_return_val_if_fail (recorder->priv != NULL, FALSE);
         g_return_val_if_fail (recorder->priv->pipeline != NULL, FALSE);
 
+#ifdef HAVE_GSTREAMER_0_8
         if (gst_element_get_state (recorder->priv->pipeline) != GST_STATE_PLAYING) {
+#elif HAVE_GSTREAMER_0_10
+	if (!gst_element_get_state (recorder->priv->pipeline, &state,  NULL, 3 * GST_SECOND)) {
+		g_warning (_("Could not retrieve state from processing pipeline"));
+		return TRUE;
+	}
+	if (state != GST_STATE_PLAYING) {		
+#endif
                 recorder->priv->tick_timeout_id = 0;
                 if (recorder->priv->start_timer) {
                         g_timer_destroy (recorder->priv->start_timer);
@@ -578,12 +735,16 @@
                 return FALSE;
         }
 
+#ifdef  HAVE_GSTREAMER_0_8
         if (!gst_pad_query (recorder->priv->src_pad, GST_QUERY_POSITION, &format, &position)) {
                 g_warning (_("Could not get current track position"));
                 return TRUE;
         }
 
         if (!gst_pad_query (recorder->priv->src_pad, GST_QUERY_TOTAL, &format, &total)) {
+#elif HAVE_GSTREAMER_0_10
+		if (!gst_element_query_position (recorder->priv->src, &format, &position) || !gst_element_query_duration (recorder->priv->src, &format, &total)) {
+#endif
                 g_warning (_("Could not get current track position"));
                 return TRUE;
         }
@@ -612,8 +773,10 @@
                                fraction, (long)secs);
         }
 
+#ifdef HAVE_GSTREAMER_0_8
         /* Extra kick in the pants to keep things moving on a busy system */
         gst_bin_iterate (GST_BIN (recorder->priv->pipeline));
+#endif
 
         return TRUE;
 }
@@ -630,33 +793,46 @@
         rb_debug ("Syncing pipeline");
         if (recorder->priv->playing) {
                 rb_debug ("Playing pipeline");
-                if (gst_element_set_state (recorder->priv->pipeline,
-                                           GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+#ifdef HAVE_GSTREAMER_0_8
+                if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PLAYING) == GST_STATE_FAILURE) {
+#elif HAVE_GSTREAMER_0_10
+                if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
+#endif
                         g_set_error (error,
                                      RB_RECORDER_ERROR,
                                      RB_RECORDER_ERROR_GENERAL,
                                      _("Could not start pipeline playing"));
                         return FALSE;
-                }                               
+                }
+#ifdef HAVE_GSTREAMER_0_8
                 recorder->priv->idle_id = g_idle_add ((GSourceFunc)gst_bin_iterate,
                                                       GST_BIN (recorder->priv->pipeline));
                 recorder->priv->tick_timeout_id = g_timeout_add (200,
                                                                  (GSourceFunc)tick_timeout_cb,
                                                                  recorder);
+#elif HAVE_GSTREAMER_0_10
+		recorder->priv->tick_timeout_id = 
+			g_timeout_add (200, (GSourceFunc)tick_timeout_cb, recorder);
+#endif
         } else {
                 rb_debug ("Pausing pipeline");
-                if (gst_element_set_state (recorder->priv->pipeline,
-                                           GST_STATE_PAUSED) == GST_STATE_FAILURE) {
+#ifdef HAVE_GSTREAMER_0_8
+                if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PAUSED) == GST_STATE_FAILURE) {
+#elif HAVE_GSTREAMER_0_10
+                if (gst_element_set_state (recorder->priv->pipeline, GST_STATE_PAUSED) == GST_STATE_CHANGE_FAILURE) {
+#endif
                         g_set_error (error,
                                      RB_RECORDER_ERROR,
                                      RB_RECORDER_ERROR_GENERAL,
                                      _("Could not pause playback"));
                         return FALSE;
                 }
+#ifdef HAVE_GSTREAMER_0_8
                 if (recorder->priv->idle_id > 0) {
                         g_source_remove (recorder->priv->idle_id);
                         recorder->priv->idle_id = 0;
                 }
+#endif
                 if (recorder->priv->tick_timeout_id > 0) {
                         g_source_remove (recorder->priv->tick_timeout_id);
                         recorder->priv->tick_timeout_id = 0;
@@ -678,8 +854,10 @@
 
         rb_debug ("Closing rb_recorder");
 
+#ifdef HAVE_GSTREAMER_0_10
+	recorder->priv->got_audio_pad = FALSE;
+#endif
         recorder->priv->playing = FALSE;
-
         g_free (recorder->priv->src_uri);
         recorder->priv->src_uri = NULL;
 
@@ -753,10 +931,14 @@
         if (error && *error)
                 return;
                 
+#ifdef HAVE_GSTREAMER_0_8
         if (recorder->priv->idle_id > 0) {
                 g_source_remove (recorder->priv->idle_id);
                 recorder->priv->idle_id = 0;
         }
+#elif HAVE_GSTREAMER_0_10
+	recorder->priv->got_audio_pad = FALSE;
+#endif
 
         g_object_set (G_OBJECT (recorder->priv->src), "iradio-mode", FALSE, NULL);
         gst_element_set_state (recorder->priv->src, GST_STATE_NULL);
Index: shell/main.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/shell/main.c,v
retrieving revision 1.78
diff -u -r1.78 main.c
--- shell/main.c	2 Dec 2005 12:42:33 -0000	1.78
+++ shell/main.c	5 Dec 2005 11:49:01 -0000
@@ -40,11 +40,10 @@
 
 #ifdef HAVE_GSTREAMER
 #include <gst/gst.h>
+#ifdef HAVE_GSTREAMER_0_8
 #include <gst/gconf/gconf.h>
 #include <gst/control/control.h>
 #endif
-#ifdef WITH_MONKEYMEDIA
-#include "monkey-media.h"
 #endif
 #ifdef WITH_RHYTHMDB_GDA
 #include <libgda/libgda.h>
@@ -172,7 +171,7 @@
 		{ "dry-run",			0,  POPT_ARG_NONE,	&dry_run,			0, N_("Don't save any data permanently (implies --no-registration)"), NULL },
 		{ "rhythmdb-file",		0,  POPT_ARG_STRING,	&rhythmdb_file,			0, N_("Path for database file to use"), NULL },
 		{ "quit",			'q',POPT_ARG_NONE,	&quit,				0, N_("Quit Rhythmbox"), NULL },
-#ifdef HAVE_GSTREAMER
+#ifdef HAVE_GSTREAMER_0_8
 		{NULL, '\0', POPT_ARG_INCLUDE_TABLE, NULL, 0, "GStreamer", NULL},
 #endif
 		POPT_TABLEEND
@@ -185,9 +184,14 @@
 	new_argv[argc] = g_strdup ("--disable-sound");
 	new_argv[argc+1] = NULL;
 
-#ifdef HAVE_GSTREAMER	
+#ifdef HAVE_GSTREAMER_0_8
 	popt_options[(sizeof(popt_options)/sizeof(popt_options[0]))-2].arg
 		= (void *) gst_init_get_popt_table ();
+#elif HAVE_GSTREAMER_0_10
+        /* To pass options to GStreamer in 0.10, RB needs to use GOption, for
+         * now, GStreamer can live without them (people can still use env
+         * vars, after all) */
+        gst_init (NULL, NULL);
 #endif
 #ifdef WITH_BONOBO
 	rb_remote_bonobo_preinit ();
@@ -216,11 +220,8 @@
 	textdomain (GETTEXT_PACKAGE);
 #endif
 
-#ifdef HAVE_GSTREAMER	
+#ifdef HAVE_GSTREAMER_0_8
 	gst_control_init (&argc, &argv);
-#endif
-#ifdef WITH_MONKEYMEDIA
-	monkey_media_init (&argc, &argv);
 #endif
 
 	rb_debug_init (debug);
Index: sources/rb-audiocd-source.c
===================================================================
RCS file: /cvs/gnome/rhythmbox/sources/rb-audiocd-source.c,v
retrieving revision 1.13
diff -u -r1.13 rb-audiocd-source.c
--- sources/rb-audiocd-source.c	2 Dec 2005 04:00:48 -0000	1.13
+++ sources/rb-audiocd-source.c	5 Dec 2005 11:49:02 -0000
@@ -228,9 +228,10 @@
 	{
 		GstFormat time_format = GST_FORMAT_TIME;
 		GstFormat track_format = gst_format_get_by_nick ("track");
-		GstEvent *event;
 		gint64 duration;
 		gboolean result;
+#ifdef HAVE_GSTREAMER_0_8
+		GstEvent *event;
 
 		event = gst_event_new_seek (track_format | GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH, 
 					    (guint64) track_number - 1);
@@ -238,6 +239,12 @@
 
 		if (result)
 			result = gst_element_query (priv->fakesink, GST_QUERY_TOTAL, &time_format, &duration);
+#elif HAVE_GSTREAMER_0_10
+                result = gst_element_seek (priv->fakesink, 1.0, track_format, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, (guint64) track_number - 1, GST_SEEK_TYPE_NONE, -1);
+		if (result) {
+			result = gst_element_query_duration (priv->fakesink, &time_format, &duration) && time_format == GST_FORMAT_TIME;
+		}
+#endif
 
 		if (result) {
 			g_value_init (&value, G_TYPE_ULONG);
@@ -266,11 +273,17 @@
 {
 	RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source);
 	GstFormat fmt = gst_format_get_by_nick ("track");
-
+#ifdef HAVE_GSTREAMER_0_8
 	if (!gst_element_query (priv->cdda, GST_QUERY_TOTAL, &fmt, num_tracks)) {
 		rb_debug ("failed to read cd track count");
 		return FALSE;
 	}
+#elif HAVE_GSTREAMER_0_10
+	GstFormat out_fmt = fmt;
+	if (!gst_element_query_duration (priv->cdda, &out_fmt, num_tracks) || out_fmt != fmt) {
+	    return FALSE;
+	}
+#endif
 
 	return TRUE;
 }
@@ -280,12 +293,27 @@
 {
 	gint64 i, num_tracks;
 	RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source);
+#ifdef HAVE_GSTREAMER_0_10
+        GstStateChangeReturn ret;
+#endif
 
+#ifdef HAVE_GSTREAMER_0_8
 	if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS) {
 		rb_error_dialog (NULL, _("Couldn't load Audio CD"),
 					_("Rhythmbox couldn't access the cd."));
 		return;
 	}
+#elif HAVE_GSTREAMER_0_10
+	ret = gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
+	if (ret == GST_STATE_CHANGE_ASYNC) {
+		ret = gst_element_get_state (priv->pipeline, NULL, NULL, 3 * GST_SECOND);
+	}
+        if (ret == GST_STATE_CHANGE_FAILURE) {
+		rb_error_dialog (NULL, _("Couldn't load Audio CD"),
+					_("Rhythmbox couldn't access the cd."));
+		return;
+	}
+#endif
 
 	if (!rb_audiocd_get_cd_info (source, &num_tracks))
 	{
@@ -305,7 +333,11 @@
 	}
 	priv->tracks = g_list_reverse (priv->tracks);
 
+#ifdef HAVE_GSTREAMER_0_8
 	if (gst_element_set_state (priv->pipeline, GST_STATE_NULL) != GST_STATE_SUCCESS) {
+#elif HAVE_GSTREAMER_0_10
+	if (gst_element_set_state (priv->pipeline, GST_STATE_NULL) == GST_STATE_CHANGE_FAILURE) {
+#endif
 		rb_debug ("failed to set cd state");
 	}
 }
@@ -443,7 +475,11 @@
 	}
 
 	rb_debug ("cdda longname: %s", gst_element_factory_get_longname (gst_element_get_factory (priv->cdda)));
+#ifdef HAVE_GSTREAMER_0_8
 	gst_element_set (priv->cdda, "device", priv->device_path, NULL);
+#elif HAVE_GSTREAMER_0_10
+	g_object_set (G_OBJECT (priv->cdda), "device", priv->device_path, NULL);
+#endif
 	
 	priv->pipeline = gst_pipeline_new ("pipeline");
 	priv->fakesink = gst_element_factory_make ("fakesink", "fakesink");
