I'm going to commit this long patch :) This enable basic support to the Sound API with GStreamer.
Currently only SourceDataLines are supported (no CLip, no Target yet). The code is able to parse audio data and display basic information about the stream. More complex info about the audio data are not mandated by the spec but are a nice plus, I'm starting to implement this functionality. The example directory contains a new class that shows how to do that. The Java Sound API allows some small deviation from the workflow proposed, but this is the only that actually works (some methods are still stubbed, most of these are a one line implementation and I'll add these in the coming days). The backend is not complex as a whole, but has some tricky areas. It uses named pipe on the file system to allow communication between GStreamer and Java, and there are still situation where a deadlock can occur, but actually it seems to work fine. The pipes are removed when lines are closed, but if you kill java they will lie around the filesystem (look in your tmp directory for a pipe that starts with "cpgst", with perm 0600, this is your friend). The code is left out of compilation by default, can be enable with a configure switch. Once compiled is able to play/parse every kind of file you have a gstreamer plugin for. You don't need that at compile time, the only requirements are the core GStreamer itself and the default plugins. Hey, with a little of tweaking it can also play videos, I've tried it's fun :) The default output sink is alsa. It is hardcoded for now. Sound is always resampled to match the sound card sampling rate. This is needed to allow cheap sound cards to not sound like a Chipmunks [1]. For the next version I plan to let users to override this default and to let GStreamer choose the default if the GConf preference plugin is enabled, this way, at least under the Gnome Desktop, the process of configuring the output devices will be completely centralized using the system tools. I'm writing a README.gstreamer (not included in this patch) to explain more about this backed. Feedback is welcomed as always. I hope you'll enjoy your favourite class library first wailing :) Happy hacking, Mario [1] http://en.wikipedia.org/wiki/Alvin_and_the_Chipmunks --- Changelog (not very informative, sorry, but the level of changes is so deep that does not make sense to list every single line) 2007-08-18 Mario Torre <[EMAIL PROTECTED]> * examples/gnu/classpath/examples/sound/AudioPlayerSample.java: new file. * gnu/javax/sound/sampled/gstreamer/GStreamerMixer.java: removed unused import. * gnu/javax/sound/sampled/gstreamer/io/GstAudioFileWriter.java: likewise. * gnu/javax/sound/sampled/gstreamer/io/GstAudioFileReaderNativePeer.java: (gstreamer_get_audio_format_stream): changed signature tu accept a Pointer object instead of a BufferedInputStream. (GstHeader): (getAudioFormat(InputStream, GstHeader)): new private method. (getAudioFormat(public)): refactored to use the private getAudioFormat with shared functionality. (getAudioFormat(GstHeader header)): removed a redundant check. (init_id_cache): new native method. * gnu/javax/sound/sampled/gstreamer/io/GstInputStream.java: new file. * gnu/javax/sound/sampled/gstreamer/lines/GstDataLine.java: (GstDataLine.State): removed enum. (state): removed local variable. (isRunning): removed method. (open): likewise. (setFormat): new methods. (setOpen): likewise. (setBufferSize): likewise. * gnu/javax/sound/sampled/gstreamer/lines/GstNativeDataLine.java: (createSourcePipeline): new method. (setup_sink_pipeline): likewise. (init_id_cache): likewise. Added to the static initializer. * gnu/javax/sound/sampled/gstreamer/lines/GstPipeline.java: (GstPipeline.State): new enum. (state): new local variable. (name): likewise. (output): likewise. (source): likewise. (ready): likewise. (getState): new method. (closePipe): likewise. (create_named_pipe): likewise. (set_state): likewise. (available): likewise. (drain): likewise. (GstPipeline): likewise. (close): likewise. (prepareWrite): likewise. (flush): likewise. (write): likewise. (init_instance): likewise. (read): likewise. (createForWrite): likewise. (setState): likewise. (getNativeClass): likewise. (init_id_cache): likewise. * gnu/javax/sound/sampled/gstreamer/lines/GstSourceDataLine.java: (pipeline): new local variable. (opne): likewise. (isActive): method implemented. (stop): likewise. (open): likewise. (flush): likewise. (isRunning): likewise. (start): likewise. (write): likewise. (available): likewise. (drain): likewise. (close): likewise. * include/Makefile.am: added entry to generate new header file. * include/gnu_javax_sound_sampled_gstreamer_io_GstAudioFileReaderNativePeer.h: regenerated. * include/gnu_javax_sound_sampled_gstreamer_io_GstInputStream.h: likewise. * include/gnu_javax_sound_sampled_gstreamer_lines_GstNativeDataLine.h: likewise. * include/gnu_javax_sound_sampled_gstreamer_lines_GstPipeline.h: likewise. * native/jni/gstreamer-peer/gstclasspathsrc.c: removed. * native/jni/gstreamer-peer/gstinputstream.c: likewise. * native/jni/gstreamer-peer/GStreamerIOPeer.c: likewise. * native/jni/gstreamer-peer/gstinputstream.h: likewise. * native/jni/gstreamer-peer/gstclasspathsrc.h: likewise. * native/jni/gstreamer-peer/Makefile.am: new file added for compilation. code reformat to keep the 80 columns constraint. * native/jni/gstreamer-peer/gst_native_pipeline.h: new file. * native/jni/gstreamer-peer/gst_input_stream.c: likewise. * native/jni/gstreamer-peer/gst_input_stream.h: likewise. * native/jni/gstreamer-peer/gst_classpath_src.c: likewise. * native/jni/gstreamer-peer/gst_native_pipeline.c: likewise. * native/jni/gstreamer-peer/gst_native_data_line.c: likewise. * native/jni/gstreamer-peer/gst_classpath_src.h: likewise. * native/jni/gstreamer-peer/gstreamer_io_peer.c: likewise. * native/jni/gstreamer-peer/gst_peer.c: likewise. * native/jni/gstreamer-peer/gst_peer.h: likewise. -- Lima Software - http://www.limasoftware.net/ GNU Classpath Developer - http://www.classpath.org/ Fedora Ambassador - http://fedoraproject.org/wiki/MarioTorre Jabber: [EMAIL PROTECTED] pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF Please, support open standards: http://opendocumentfellowship.org/petition/ http://www.nosoftwarepatents.com/
2007-08-18c.patch.tar.gz
Description: application/compressed-tar
