Index: cd-recorder.c
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/cd-recorder.c,v
retrieving revision 1.20
diff -u -r1.20 cd-recorder.c
--- cd-recorder.c	28 May 2003 10:10:37 -0000	1.20
+++ cd-recorder.c	21 Jun 2003 12:15:08 -0000
@@ -66,6 +66,8 @@
 	LAST_SIGNAL
 };
 
+#define MAX_ARGS 200
+
 static int cd_recorder_table_signals[LAST_SIGNAL] = { 0 };
 
 static GObjectClass *parent_class = NULL;
@@ -279,13 +281,14 @@
 				 gboolean music,
 		       gboolean dummy_write)
 {
-	const char *argv[200]; /* Shouldn't need more than 200 arguments */
+	const char *argv[MAX_ARGS]; /* Shouldn't need more than MAX_ARGS arguments */
 	char *speed_str, *dev_str;
 	int stdout_pipe, stderr_pipe;
 	guint stdout_tag, stderr_tag;
 	GIOChannel *channel;
 	GError *error;
 	int i, saved_i;
+    char *wavdir = NULL;
 
 	i = 0;
 	saved_i = 0;
@@ -310,7 +313,7 @@
 		argv[i++] = "-pad";
 		argv[i++] = "-audio";
 		saved_i = i;
-		cdrecorder->priv->music_count = build_list_of_music_arguments ("burn:///", &i, argv, 200-i-5);
+		cdrecorder->priv->music_count = build_list_of_music_arguments ("burn:///", &i, argv, MAX_ARGS-i-5, &wavdir);
 	} else {
 		cdrecorder->priv->music_count = 0;
 		argv[i++] = "-data";
@@ -399,9 +402,24 @@
 
 	if (music) {
 		int j;
+        
 		for (j=0;j<cdrecorder->priv->music_count;j++) {
 			g_free ((char *)argv[saved_i+j]);
 		}
+        if (wavdir) {
+            GDir *dir;
+            const char *file;
+
+            dir = g_dir_open(wavdir, 0, NULL);
+            while ((file = g_dir_read_name(dir))) {
+                char *fullname = g_strdup_printf("%s/%s", wavdir, file);
+                remove(fullname);
+                g_free(fullname);
+            }
+            g_dir_close(dir);
+            remove(wavdir);
+            free(wavdir);
+        }
 	}
 
 	g_signal_emit (G_OBJECT (cdrecorder),
Index: configure.in
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/configure.in,v
retrieving revision 1.43
diff -u -r1.43 configure.in
--- configure.in	27 May 2003 09:52:14 -0000	1.43
+++ configure.in	21 Jun 2003 12:15:09 -0000
@@ -14,6 +14,7 @@
 LIBGLADE_REQUIRED=2.0.0
 LIBGNOME_REQUIRED=2.0.0
 EEL_REQUIRED=2.0.0
+GST_REQUIRED=0.6
 
 AC_CHECK_LIB(cam, cam_open_spec_device)
 	
@@ -25,7 +26,7 @@
 AC_SUBST(DAEMON_CFLAGS)
 AC_SUBST(DAEMON_LIBS)
 	
-PKG_CHECK_MODULES(GUI, glib-2.0 >= $GLIB_REQUIRED libgnome-2.0 >= $LIBGNOME_REQUIRED gtk+-2.0 gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED eel-2.0 >= $EEL_REQUIRED)
+PKG_CHECK_MODULES(GUI, glib-2.0 >= $GLIB_REQUIRED libgnome-2.0 >= $LIBGNOME_REQUIRED gtk+-2.0 gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libglade-2.0 >= $LIBGLADE_REQUIRED eel-2.0 >= $EEL_REQUIRED gstreamer-0.6 >= $GST_REQUIRED)
 AC_SUBST(GUI_CFLAGS)
 AC_SUBST(GUI_LIBS)
 	
Index: make-iso.c
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/make-iso.c,v
retrieving revision 1.20
diff -u -r1.20 make-iso.c
--- make-iso.c	27 May 2003 08:07:06 -0000	1.20
+++ make-iso.c	21 Jun 2003 12:15:09 -0000
@@ -38,9 +38,14 @@
 #include <signal.h>
 #include <libgnomevfs/gnome-vfs.h>
 #include <gtk/gtkmessagedialog.h>
+#include <gst/gst.h>
 
 #include "nautilus-cd-burner.h"
 
+#define TYPE_WAV 0
+#define TYPE_MP3 1
+#define TYPE_OGG 2
+
 static void
 write_all (int fd, char *buf, int len)
 {
@@ -647,8 +652,75 @@
 	return mkisofs_output.result;
 }
 
+static int
+get_audio_type(char *mime)
+{
+    if (strcmp(mime, "audio/x-wav") == 0 || strcmp(mime, "audio/x-ulaw") == 0) {
+        return TYPE_WAV;
+    } else if (strcmp(mime, "audio/mpeg") == 0 || strcmp(mime, "audio/x-mp3") ==0) {
+        return TYPE_MP3;
+    } else if (strcmp(mime, "application/x-ogg") == 0) {
+        return TYPE_OGG;
+    } else {
+        return -1;
+    }
+}
+
+static char*
+make_wav (char *srcfile, char *wavdir, int type)
+{
+    GstElement *pipeline, *filesrc, *decoder, *encoder, *filesink;
+    char *dstfile, *base;
+
+    pipeline = gst_pipeline_new ("pipeline");
+    g_assert(pipeline != NULL);
+
+    /* Read from disk */
+    filesrc = gst_element_factory_make ("filesrc", "disk_source");
+    g_assert(filesrc != NULL);
+    g_object_set (G_OBJECT (filesrc), "location", srcfile, NULL);
+    /* Decoder */
+    decoder = NULL;
+    switch (type) {
+        case TYPE_MP3:
+            decoder = gst_element_factory_make("mad", "decoder");
+            break;
+        case TYPE_OGG:
+            decoder = gst_element_factory_make("vorbisfile", "sink");
+            break;
+    }
+    g_assert(decoder != NULL);
+    /* Encode */
+    encoder = gst_element_factory_make ("wavenc", "encoder");
+    g_assert(encoder != NULL);
+    /* Write to disk */
+    filesink = gst_element_factory_make ("filesink", "filesink");
+    g_assert(filesink != NULL);
+    base = g_path_get_basename(srcfile);
+    dstfile = g_strdup_printf("%s/%s.wav", wavdir, base);
+    g_object_set (G_OBJECT (filesink), "location", dstfile, NULL);
+
+    /* Add the elements to the pipeline */
+    gst_bin_add (GST_BIN (pipeline), filesrc);
+    gst_bin_add (GST_BIN (pipeline), decoder);
+    gst_bin_add (GST_BIN (pipeline), encoder);
+    gst_bin_add (GST_BIN (pipeline), filesink);
+
+    /* Link it all together */
+    gst_element_link_many (filesrc, decoder, encoder, filesink, NULL);
+    
+    gst_element_set_state (pipeline, GST_STATE_PAUSED);
+
+    gst_element_set_state (pipeline, GST_STATE_PLAYING);
+    while (gst_bin_iterate (GST_BIN (pipeline)));
+    gst_element_set_state (pipeline, GST_STATE_NULL);
+    gst_object_unref (GST_OBJECT (pipeline));
+
+    return dstfile;
+}
+
 gint 
-build_list_of_music_arguments (char *uri, int *argc, const char **argv, int max_num_args)
+build_list_of_music_arguments (char *uri, int *argc, const char **argv, int max_num_args, char **wavdir)
 {
 	GnomeVFSFileInfo *info;
 	GnomeVFSDirectoryHandle *handle;
@@ -672,8 +744,27 @@
 
 		if (is_audio (info->mime_type)) {
 			backing = get_backing_file (info->name);
-			argv[(*argc)++] = backing;
-			count++;
+            int type = get_audio_type(info->mime_type);
+            if (type != TYPE_WAV) {
+                char *wav = NULL;
+                
+                if (!*wavdir) {
+                    const char *tmpdir = g_get_tmp_dir();
+                    *wavdir = g_strdup_printf("%s/cd-burner-XXXXXX", tmpdir);
+                    mktemp(*wavdir);
+                    mkdir(*wavdir, 0700);
+                    //FIXME: should this be freed?
+                    //g_free(tmpdir);
+                }
+                wav = make_wav(backing, *wavdir, type);
+                if (wav) {
+                    argv[(*argc)++] = wav;
+                    count++;  
+                }
+            } else {
+                argv[(*argc)++] = backing;
+                count++;
+            }
 		}
 		
 		if (count == max_num_args) {
Index: make-iso.h
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/make-iso.h,v
retrieving revision 1.5
diff -u -r1.5 make-iso.h
--- make-iso.h	27 May 2003 08:07:06 -0000	1.5
+++ make-iso.h	21 Jun 2003 12:15:09 -0000
@@ -22,5 +22,5 @@
    Authors: Alexander Larsson <alexl@redhat.com>
 */
 int make_iso (const char *filename, const char *label);
-gint build_list_of_music_arguments (char *uri, int *argc, const char **argv, int max_num_args);
+gint build_list_of_music_arguments (char *uri, int *argc, const char **argv, int max_num_args, char **wavdir);
 extern gboolean is_audio (char *mime_type);
Index: nautilus-cd-burner.c
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/nautilus-cd-burner.c,v
retrieving revision 1.31
diff -u -r1.31 nautilus-cd-burner.c
--- nautilus-cd-burner.c	27 May 2003 08:07:06 -0000	1.31
+++ nautilus-cd-burner.c	21 Jun 2003 12:15:09 -0000
@@ -31,6 +31,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <string.h>
+#include <gst/gst.h>
 
 #include "nautilus-cd-burner.h"
 #include "make-iso.h"
@@ -394,7 +395,9 @@
 gboolean
 is_audio (char *mime_type) 
 {
-	if (strcmp (mime_type, "audio/x-wav") == 0 || strcmp (mime_type, "audio/x-ulaw") == 0) {
+	if (strcmp (mime_type, "audio/x-wav") == 0 || strcmp (mime_type, "audio/x-ulaw") == 0
+        || strcmp(mime_type, "audio/x-mp3") == 0 || strcmp(mime_type, "audio/mpeg") == 0
+        || strcmp(mime_type, "application/x-ogg") == 0) {
 		return TRUE;
 	}
 	return FALSE;
@@ -850,7 +853,7 @@
 	CDDrive *rec;
 	GtkWidget *dialog, *entry, *eject_check, *blank_check, *music_check, *reuse_check, *progress_window;
 	GtkWidget *cancel_button, *dummy_check, *option_menu, *item;
-	const char *label;
+	const char *label = NULL;
 	int res, speed;
 	gboolean eject, blank, music, reuse, dummy;
 	GnomeVFSURI *uri;
@@ -866,6 +869,7 @@
 	
 	gtk_init (&argc, &argv);
 	gnome_vfs_init ();
+    gst_init(&argc, &argv);
 
 	if (argc > 2) {
 		dialog = gtk_message_dialog_new (NULL,
@@ -952,9 +956,6 @@
 	if (res == 0) {
 		rec = lookup_current_recorder (xml);
 		
-		entry = glade_xml_get_widget (xml, "cdname_entry");
-		label = gtk_entry_get_text (GTK_ENTRY (entry));
-
 		eject_check = glade_xml_get_widget (xml, "eject_check");
 		eject = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (eject_check));
 
@@ -965,6 +966,11 @@
 		music = (rec->type != CDDRIVE_TYPE_FILE) &&
 			gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (music_check));
 	
+		entry = glade_xml_get_widget (xml, "cdname_entry");
+        if (!music) {
+    		label = gtk_entry_get_text (GTK_ENTRY (entry));
+        }
+
 		dummy = FALSE;
 
 #ifdef ENABLE_DUMMY_WRITE
Index: nautilus-cd-burner.h
===================================================================
RCS file: /cvs/gnome/nautilus-cd-burner/nautilus-cd-burner.h,v
retrieving revision 1.13
diff -u -r1.13 nautilus-cd-burner.h
--- nautilus-cd-burner.h	27 May 2003 08:07:06 -0000	1.13
+++ nautilus-cd-burner.h	21 Jun 2003 12:15:09 -0000
@@ -31,7 +31,7 @@
 
 extern int make_iso (const char *filename,
 		     const char *label);
-extern gint build_list_of_music_arguments (char *uri, int *argc, const char **argv, int max_num_args);
+extern gint build_list_of_music_arguments (char *uri, int *argc, const char **argv, int max_num_args, char **wavdir);
 gboolean is_audio (char *mime_type);
 
 /* UI callbacks: */
