1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
? .tm_project.cache
? nautilus.prj
? nautilus.pws
Index: configure.in
===================================================================
RCS file: /cvs/gnome/nautilus/configure.in,v
retrieving revision 1.540
diff -u -r1.540 configure.in
--- configure.in 22 Sep 2003 17:44:34 -0000 1.540
+++ configure.in 12 Oct 2003 13:50:52 -0000
@@ -20,6 +20,7 @@
RSVG_REQUIRED=2.0.1
XML_REQUIRED=2.4.7
STARTUP_NOTIFICATION_REQUIRED=0.5
+GSTREAMER_REQUIRED=0.6.0
AC_SUBST(ART_REQUIRED)
AC_SUBST(BONOBO_ACTIVATION_REQUIRED)
@@ -39,6 +40,7 @@
AC_SUBST(RSVG_REQUIRED)
AC_SUBST(XML_REQUIRED)
AC_SUBST(STARTUP_NOTIFICATION_REQUIRED)
+AC_SUBST(GSTREAMER_REQUIRED)
dnl ===========================================================================
@@ -245,6 +247,53 @@
dnl ==========================================================================
+dnl gstreamer checking
+
+AC_ARG_ENABLE(gstreamer,
+ AC_HELP_STRING([--enable-gstreamer],[use GStreamer for sound preview]),
+ [case "${enableval}" in
+ yes) ENABLE_GST=yes ;;
+ no) ENABLE_GST=no ;;
+ *) AC_MSG_ERROR(bad value ${enableval} for --enable-gstreamer) ;;
+ esac],
+ [ENABLE_GST=no]) dnl Default value
+
+AC_MSG_CHECKING(for backend libraries)
+
+if test x$ENABLE_GST = xyes; then
+
+dnl Now we're ready to ask for gstreamer libs and cflags
+dnl And we can also ask for the right version of gstreamer
+ HAVE_GSTREAMER=no
+
+dnl start with 0.7
+ GST_MAJORMINOR=0.7
+ PKG_CHECK_MODULES(GST, \
+ gstreamer-gconf-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED,
+ HAVE_GSTREAMER=yes,HAVE_GSTREAMER=no)
+
+dnl try 0.6
+ if test "x$HAVE_GSTREAMER" = "xno"; then
+ GST_MAJORMINOR=0.6
+ PKG_CHECK_MODULES(GST, \
+ gstreamer-gconf-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED,
+ HAVE_GSTREAMER=yes,HAVE_GSTREAMER=no)
+ fi
+
+dnl Give error and exit if we don't have gstreamer
+ if test "x$HAVE_GSTREAMER" = "xno"; then
+ AC_MSG_ERROR(you need gstreamer development packages installed !)
+ fi
+
+ MM="gstreamer-libs-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED gstreamer-gconf-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED"
+
+ AC_MSG_RESULT(GStreamer)
+ AC_DEFINE(USE_GST_AUDIO_PREVIEW,1,[Define if you want to use the GStreamer media framework])
+
+fi
+
+dnl ==========================================================================
+
dnl Turn on the additional warnings last, so -Werror doesn't affect other tests.
AC_ARG_ENABLE(more-warnings,
@@ -314,7 +363,7 @@
AC_SUBST(LIBNAUTILUS_IDL_INCLUDES)
dnl core nautilus (must list bonobo-activation and libbonobo because idldir does not respect "requires")
-CORE_MODULES="eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 libbonoboui-2.0 esound gnome-desktop-2.0 $EXTRA_CORE_MODULES"
+CORE_MODULES="eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 libbonoboui-2.0 esound gnome-desktop-2.0 $MM $EXTRA_CORE_MODULES"
CORE_CFLAGS="`$PKG_CONFIG --cflags $CORE_MODULES` $x_cflags"
AC_SUBST(CORE_CFLAGS)
CORE_LIBS="`$PKG_CONFIG --libs $CORE_MODULES` $CDDA_LIBS $LIBJPEG $x_libs"
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.287
diff -u -r1.287 fm-icon-view.c
--- src/file-manager/fm-icon-view.c 30 Sep 2003 20:38:00 -0000 1.287
+++ src/file-manager/fm-icon-view.c 12 Oct 2003 13:50:56 -0000
@@ -78,8 +78,13 @@
#include <sys/wait.h>
#include <unistd.h>
+#ifdef USE_GST_AUDIO_PREVIEW
+#include <gst/gst.h>
+#include <gst/gconf/gconf.h>
+#else
#define USE_OLD_AUDIO_PREVIEW 1
#define READ_CHUNK_SIZE 16384
+#endif /* USE_GST_AUDIO_PREVIEW */
/* Paths to use when creating & referring to Bonobo menu items */
#define MENU_PATH_STRETCH_ICON "/menu/Edit/Edit Items Placeholder/Stretch"
@@ -195,6 +200,10 @@
static int preview_sound_auto_value;
static gboolean gnome_esd_enabled_auto_value;
+#ifdef USE_GST_AUDIO_PREVIEW
+static GstElement *thread;
+#endif
+
static void fm_icon_view_set_directory_sort_by (FMIconView *icon_view,
NautilusFile *file,
const char *sort_by);
@@ -1741,6 +1750,22 @@
fm_directory_view_stop_batching_selection_changes (FM_DIRECTORY_VIEW (icon_view));
}
+#ifdef USE_GST_AUDIO_PREVIEW
+static void
+gst_end_of_stream_callback (GstElement *src, gpointer callback_data)
+{
+ FMIconView *icon_view;
+ icon_view = FM_ICON_VIEW (callback_data);
+
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
+
+ if (icon_view->details->audio_preview_timeout != 0) {
+ g_source_remove (icon_view->details->audio_preview_timeout);
+ icon_view->details->audio_preview_timeout = 0;
+ }
+}
+#endif
+
/* handle the preview signal by inspecting the mime type. For now, we only preview local sound files. */
/* here's the timer task that actually plays the file using mpg123, ogg123 or play. */
@@ -1748,6 +1773,34 @@
static gboolean
play_file (gpointer callback_data)
{
+#ifdef USE_GST_AUDIO_PREVIEW
+ gchar *file_uri;
+ GstElement *filesrc, *decoder, *audiosink;
+ FMIconView *icon_view;
+
+ icon_view = FM_ICON_VIEW (callback_data);
+ file_uri = nautilus_file_get_uri (icon_view->details->audio_preview_file);
+
+ if (file_uri != NULL && gst_init_check (NULL, NULL)) {
+ thread = gst_thread_new ("thread");
+ filesrc = gst_element_factory_make ("gnomevfssrc", "disk_source");
+ decoder = gst_element_factory_make ("spider", "spider");
+ audiosink = gst_gconf_get_default_audio_sink ();
+
+ g_object_set (G_OBJECT (filesrc), "location", file_uri, NULL);
+ g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (gst_end_of_stream_callback), icon_view);
+
+ gst_bin_add_many (GST_BIN (thread), filesrc, decoder, audiosink, NULL);
+ gst_element_link_many (filesrc, decoder, audiosink, NULL);
+
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING);
+ }
+
+ g_free (file_uri);
+
+ icon_view->details->audio_preview_file = NULL;
+ icon_view->details->audio_preview_timeout = 0;
+#else
#if USE_OLD_AUDIO_PREVIEW
NautilusFile *file;
FMIconView *icon_view;
@@ -1865,6 +1918,7 @@
icon_view->details->audio_preview_timeout = 0;
icon_view->details->audio_preview_file = NULL;
#endif
+#endif /* USE_GST_AUDIO_PREVIEW */
return FALSE;
}
@@ -1878,7 +1932,22 @@
static void
preview_audio (FMIconView *icon_view, NautilusFile *file, gboolean start_flag)
-{
+{
+#ifdef USE_GST_AUDIO_PREVIEW
+ if (thread != NULL) {
+ gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL);
+ }
+
+ if (icon_view->details->audio_preview_timeout != 0) {
+ g_source_remove (icon_view->details->audio_preview_timeout);
+ icon_view->details->audio_preview_timeout = 0;
+ }
+
+ if (start_flag) {
+ icon_view->details->audio_preview_file = file;
+ icon_view->details->audio_preview_timeout = g_timeout_add (1000, play_file, icon_view);
+ }
+#else
/* Stop current audio playback */
#if USE_OLD_AUDIO_PREVIEW
nautilus_sound_kill_sound ();
@@ -1903,15 +1972,18 @@
icon_view->details->audio_preview_timeout = g_timeout_add (1000, play_file, icon_view);
#endif
}
+#endif /* USE_GST_AUDIO_PREVIEW */
}
static gboolean
should_preview_sound (NautilusFile *file)
{
+#ifndef USE_GST_AUDIO_PREVIEW
/* Check gnome config sound preference */
if (!gnome_esd_enabled_auto_value) {
return FALSE;
}
+#endif /* USE_GST_AUDIO_PREVIEW */
/* Check user performance preference */
if (preview_sound_auto_value == NAUTILUS_SPEED_TRADEOFF_NEVER) {
@@ -1942,10 +2014,18 @@
mime_type = nautilus_file_get_mime_type (file);
if ((eel_istr_has_prefix (mime_type, "audio/")
- || eel_istr_has_prefix (mime_type, "application/x-ogg"))
+#ifdef USE_GST_AUDIO_PREVIEW
+ || eel_istr_has_prefix (mime_type, "application/ogg")
+ || eel_istr_has_prefix (mime_type, "application/x-flac"))
&& eel_strcasecmp (mime_type, "audio/x-pn-realaudio") != 0
&& eel_strcasecmp (mime_type, "audio/x-mpegurl") != 0
- && nautilus_sound_can_play_sound ()) {
+ ) {
+#else
+ || eel_istr_has_prefix (mime_type, "application/ogg"))
+ && eel_strcasecmp (mime_type, "audio/x-pn-realaudio") != 0
+ && eel_strcasecmp (mime_type, "audio/x-mpegurl") != 0
+ && nautilus_sound_can_play_sound ()) {
+#endif
result = 1;
preview_audio (icon_view, file, start_flag);
}
|