Changeset 70

Show
Ignore:
Timestamp:
12/10/05 11:20:52 (3 years ago)
Author:
alban
Message:

* created OggDecoder? and AudioSystem? to encapsulate and control
FileReader? and ConversionProvider? choices
* created URIParser to encode "special" characters (like spaces) and
parse file paths like c:\...
* integrated last mp3spi and vorbisspi releases (rebuilt with
tritonus 0.3.6)
* add PlaylistEncoderReceiver? to the node configuration and test it
on various playlists and files

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/.classpath

    r63 r70  
    2121        <classpathentry kind="lib" path="track/jetty/releases/5.1.4rc0/lib/org.mortbay.jetty.jar"/> 
    2222        <classpathentry kind="lib" path="track/commons-httpclient/releases/3.0-rc3/commons-httpclient-3.0-rc3.jar"/> 
    23         <classpathentry kind="lib" path="track/vorbisspi/releases/1.0.1/lib/jogg-0.0.7.jar"/> 
    24         <classpathentry kind="lib" path="track/vorbisspi/releases/1.0.1/lib/jorbis-0.0.13.jar"/> 
    25         <classpathentry kind="lib" path="track/vorbisspi/releases/1.0.1/lib/tritonus_share.jar"/> 
    26         <classpathentry kind="lib" path="track/vorbisspi/releases/1.0.1/vorbisspi1.0.1.jar"/> 
    2723        <classpathentry kind="lib" path="track/tritonus/releases/0.3.6/tritonus_core-0.3.6.jar"/> 
    2824        <classpathentry kind="lib" path="track/tritonus/releases/0.3.6/tritonus_share-0.3.6.jar"/> 
    2925        <classpathentry sourcepath="/tritonus/src/classes" kind="lib" path="track/tritonus/releases/0.3.6/tritonus_vorbis-0.3.6.jar"/> 
     26        <classpathentry kind="lib" path="track/vorbisspi/releases/1.0.2/lib/jogg-0.0.7.jar"/> 
     27        <classpathentry kind="lib" path="track/vorbisspi/releases/1.0.2/lib/jorbis-0.0.15.jar"/> 
     28        <classpathentry kind="lib" path="track/vorbisspi/patches/1.0.2/vorbisspi1.0.2.jar"/> 
    3029        <classpathentry kind="output" path=".eclipse"/> 
    3130</classpath> 
  • trunk/build.xml

    r62 r70  
    135135        <target name="prepare.libraries" depends="prepare.track.optional, prepare.antlion"> 
    136136                <libraryDef> 
     137                        <type> 
     138                                <must-find/> 
     139                                <default/> 
     140                        </type> 
    137141                        <repository basedir="${track.dir}"> 
     142                                <format text="[groupid]/patches/[version]/[artifactid]-[version].[type]" /> 
     143                                <format text="[groupid]/patches/[version]/[artifactid].[type]" /> 
     144                                <format text="[groupid]/patches/[version]/[groupid]-[version].[type]" /> 
     145                                <format text="[groupid]/patches/[version]/[groupid].[type]" /> 
    138146                                <format text="[groupid]/releases/[version]/[artifactid]-[version].[type]" /> 
    139147                                <format text="[groupid]/releases/[version]/[artifactid].[type]" /> 
    140148                                <format text="[groupid]/releases/[version]/[groupid]-[version].[type]" /> 
    141149                                <format text="[groupid]/releases/[version]/[groupid].[type]" /> 
    142                                 <format text="[groupid]/patches/[version]/[artifactid]-[version].[type]" /> 
    143                                 <format text="[groupid]/patches/[version]/[artifactid].[type]" /> 
    144                                 <format text="[groupid]/patches/[version]/[groupid]-[version].[type]" /> 
    145                                 <format text="[groupid]/patches/[version]/[groupid].[type]" /> 
    146150                                <!-- for log4j --> 
    147151                                <format text="[groupid]/releases/[version]/dist/lib/[groupid]-[version].[type]" /> 
     
    163167 
    164168                        <library id="lib.vorbisspi"> 
    165                                 <lib-entry groupid="vorbisspi" version="1.0.1" artifactid="vorbisspi1.0.1" /> 
    166                                 <lib-entry groupid="vorbisspi" version="1.0.1" artifactid="jogg-0.0.7" /> 
    167                                 <lib-entry groupid="vorbisspi" version="1.0.1" artifactid="jorbis-0.0.13" /> 
    168                                 <lib-entry groupid="vorbisspi" version="1.0.1" artifactid="tritonus_share" /> 
     169                                <lib-entry groupid="vorbisspi" version="1.0.2" artifactid="vorbisspi1.0.2" /> 
     170                                <lib-entry groupid="vorbisspi" version="1.0.2" artifactid="jogg-0.0.7" /> 
     171                                <lib-entry groupid="vorbisspi" version="1.0.2" artifactid="jorbis-0.0.15" /> 
     172                                <lib-entry groupid="tritonus" version="0.3.6" artifactid="tritonus_share" /> 
     173                                <lib-entry groupid="tritonus" version="0.3.6" artifactid="tritonus_core" /> 
    169174                        </library> 
    170175 
    171                         <library id="lib.tritonus" groupid="tritonus" version="0.3.6"> 
    172                                 <lib-entry artifactid="tritonus_core"/> 
    173                                 <lib-entry artifactid="tritonus_share"/> 
    174                                 <lib-entry artifactid="tritonus_vorbis"/> 
     176                        <library id="lib.mp3spi"> 
     177                                <lib-entry groupid="mp3spi" version="1.9.4" artifactid="mp3spi1.9.4" /> 
     178                                <lib-entry groupid="mp3spi" version="1.9.4" artifactid="jl1.0" /> 
     179                                <lib-entry groupid="tritonus" version="0.3.6" artifactid="tritonus_share" /> 
     180                                <lib-entry groupid="tritonus" version="0.3.6" artifactid="tritonus_core" /> 
     181                        </library> 
     182 
     183                        <library id="lib.tritonus"> 
     184                                <lib-entry artifactid="tritonus_core" groupid="tritonus" version="0.3.6" /> 
     185                                <lib-entry artifactid="tritonus_share" groupid="tritonus" version="0.3.6" /> 
     186                                <lib-entry artifactid="tritonus_vorbis" groupid="tritonus" version="0.3.6" /> 
     187                        </library> 
     188 
     189                        <library id="lib.test"> 
     190                                <lib-entry groupid="junit" version="3.8.1" /> 
     191                                <lib-entry groupid="easymock" version="1.1" /> 
     192                                <lib-entry groupid="mockobjects" version="0.09" artifactid="mockobjects-core" /> 
    175193                        </library> 
    176194 
     
    179197                                <lib-entry groupid="commons-logging" version="1.0.4" /> 
    180198                                <lib-entry groupid="commons-cli" version="1.0" /> 
    181                                 <lib-entry groupid="commons-httpclient" version="3.0-rc3" /> 
    182199                                <lib-entry groupid="commons-codec" version="1.3" /> 
    183200                                <lib-entry groupid="commons-io" version="1.0" /> 
     
    186203                                <lib-entry groupid="commons-configuration" version="nightly-20050307" artifactid="commons-configuration-1.1RC2" /> 
    187204                                <lib-entry groupid="concurrent" version="kolaka" /> 
     205                        </library> 
     206 
     207                        <library id="build"> 
     208                                <library refid="core" /> 
     209                                <lib-entry groupid="commons-httpclient" version="3.0-rc3" /> 
    188210                                <lib-entry groupid="cortado" version="0.1.0" artifactid="cortado-ovt-0.1.0" /> 
    189211                                <lib-entry groupid="jdic" version="0.9" /> 
     
    191213                                <library refid="lib.jetty" /> 
    192214                                <library refid="lib.tritonus" /> 
     215                                <library refid="lib.vorbisspi" /> 
    193216                        </library> 
    194217 
    195218                        <library id="runtime"> 
    196                                 <library refid="lib.vorbisspi" /> 
    197                                 <library refid="core" /> 
     219                                <library refid="build" /> 
    198220                                <lib-entry groupid="commons-digester" version="1.7" /> 
    199221                                <lib-entry groupid="commons-beanutils" version="1.7.0" /> 
     222                                <library refid="lib.mp3spi"/> 
    200223                        </library> 
    201224 
    202225                        <library id="test"> 
    203                                 <lib-entry groupid="junit" version="3.8.1" /> 
    204                                 <lib-entry groupid="easymock" version="1.1" /> 
    205                                 <lib-entry groupid="mockobjects" version="0.09" artifactid="mockobjects-core" /> 
     226                                <library refid="lib.test" /> 
    206227                                <library refid="runtime" /> 
    207228                        </library> 
     
    229250        </target> 
    230251 
    231         <macrodef name="configvalidate"> 
    232                 <attribute name="file" /> 
    233                 <sequential> 
    234                         <pathconvert dirsep="/" property="build.validate.xsd.file"> 
    235                                 <path> 
    236                                         <pathelement location="source/org/kolaka/freecast/config/resources/config.xsd" /> 
    237                                 </path> 
    238                         </pathconvert> 
    239                         <xmlvalidate lenient="false" failonerror="true" warn="true" file="@{file}"> 
    240                                 <attribute name="http://apache.org/xml/features/validation/schema" value="true" /> 
    241                                 <attribute name="http://xml.org/sax/features/namespaces" value="true" /> 
    242                                 <property name="http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation" value="${build.validate.xsd.file}" /> 
    243                         </xmlvalidate> 
    244                 </sequential> 
    245         </macrodef> 
     252 
    246253 
    247254        <target name="build.validate"> 
     255                <macrodef name="configvalidate"> 
     256                        <attribute name="file" /> 
     257                        <sequential> 
     258                                <pathconvert dirsep="/" property="build.validate.xsd.file"> 
     259                                        <path> 
     260                                                <pathelement location="source/org/kolaka/freecast/config/resources/config.xsd" /> 
     261                                        </path> 
     262                                </pathconvert> 
     263                                <xmlvalidate lenient="false" failonerror="true" warn="true" file="@{file}"> 
     264                                        <attribute name="http://apache.org/xml/features/validation/schema" value="true" /> 
     265                                        <attribute name="http://xml.org/sax/features/namespaces" value="true" /> 
     266                                        <property name="http://apache.org/xml/properties/schema/external-noNamespaceSchemaLocation" value="${build.validate.xsd.file}" /> 
     267                                </xmlvalidate> 
     268                        </sequential> 
     269                </macrodef> 
     270 
    248271                <!-- 
    249272                <configvalidate file="source/org/kolaka/freecast/config/resources/defaults-node.xml"/> 
     
    258281                <mkdir dir="${build.core.classes.dir}" /> 
    259282                <javac target="1.4" source="1.4" srcdir="source" destdir="${build.core.classes.dir}" debug="true"> 
    260                         <classpath refid="path.core" /> 
     283                        <classpath refid="path.build" /> 
    261284                        <exclude name="**/test/*.java" /> 
    262285                </javac> 
     
    310333                        <include name="**/test/*.java" /> 
    311334                </javac> 
    312                 <copy file="build/etc/console-only/log4j.xml" tofile="${build.test.classes.dir}/log4j.xml" /> 
     335                <copy file="source/org/kolaka/freecast/test/log4j.xml" tofile="${build.test.classes.dir}/log4j.xml" /> 
    313336                <copy todir="${build.test.classes.dir}"> 
    314337                        <fileset dir="source"> 
     
    556579        </target> 
    557580 
    558         <macrodef name="thumbnails"> 
    559                 <attribute name="dest" /> 
    560                 <element name="filesets" /> 
    561                 <sequential> 
    562                         <apply executable="convert" dest="@{dest}" failonerror="true" verbose="true"> 
    563                                 <arg line="-geometry 200x200" /> 
    564                                 <srcfile /> 
    565                                 <targetfile /> 
    566                                 <filesets /> 
    567                                 <mapper type="regexp" from="^(.*)\.([^.]*)" to="\1-thumb.\2" /> 
    568                         </apply> 
    569                 </sequential> 
    570         </macrodef> 
     581 
    571582 
    572583        <target name="build.www"> 
     
    617628                        </fileset> 
    618629                </copy> 
     630 
     631                <macrodef name="thumbnails"> 
     632                        <attribute name="dest" /> 
     633                        <element name="filesets" /> 
     634                        <sequential> 
     635                                <apply executable="convert" dest="@{dest}" failonerror="true" verbose="true"> 
     636                                        <arg line="-geometry 200x200" /> 
     637                                        <srcfile /> 
     638                                        <targetfile /> 
     639                                        <filesets /> 
     640                                        <mapper type="regexp" from="^(.*)\.([^.]*)" to="\1-thumb.\2" /> 
     641                                </apply> 
     642                        </sequential> 
     643                </macrodef> 
    619644 
    620645                <thumbnails dest="${build.www.dir}"> 
     
    656681                                <path refid="path.test" /> 
    657682                        </classpath> 
    658                         <sysproperty key="java.library.path" path="${track.tritonus.dir}"/> 
     683                        <sysproperty key="java.library.path" path="${track.tritonus.dir}" /> 
    659684                </junit> 
     685        </target> 
     686 
     687        <target name="test.oggdecoders" depends="build.test"> 
     688                <property name="build.test.results.dir" value="build/test/results" /> 
     689                <mkdir dir="${build.test.results.dir}" /> 
     690                <property name="test.oggdecoders.resource" value="default" /> 
     691 
     692                <macrodef name="junit.oggdecoders"> 
     693                        <attribute name="name" /> 
     694                        <element name="paths" optional="false" /> 
     695                        <element name="properties" optional="true" /> 
     696                        <sequential> 
     697                                <path id="path.test.oggdecoders.@{name}"> 
     698                                        <pathelement path="build/core/classes" /> 
     699                                        <pathelement path="build/test/classes" /> 
     700                                        <path refid="path.core" /> 
     701                                        <paths /> 
     702                                </path> 
     703                                <pathconvert property="path.test.oggdecoders.@{name}"  
     704                                        refid="path.test.oggdecoders.@{name}"> 
     705                                        <map from="${basedir}/" to=""/> 
     706                                </pathconvert> 
     707                                <!-- <echo message="path ${path.test.oggdecoders.@{name}}"/> --> 
     708                                <junit printsummary="yes" haltonfailure="${test.haltonfailure}" includeantruntime="yes" fork="yes" showoutput="true"> 
     709                                        <formatter type="plain" /> 
     710                                        <test name="org.kolaka.freecast.ogg.test.OggDecoderTest" todir="${build.test.results.dir}" outfile="TEST-OggProviders-@{name}" /> 
     711                                        <classpath refid="path.test.oggdecoders.@{name}"/> 
     712                                        <sysproperty key="log4.configuration" value="org/kolaka/freecast/test/log4j.xml" /> 
     713                                        <sysproperty key="java.library.path" path="${track.tritonus.dir}" /> 
     714                                        <sysproperty key="org.kolaka.freecast.ogg.test.OggProviderTest.resource" value="${test.oggdecoders.resource}" /> 
     715                                        <properties /> 
     716                                </junit> 
     717                        </sequential> 
     718                </macrodef> 
     719 
     720                <junit.oggdecoders name="all"> 
     721                        <paths> 
     722                                <path refid="path.lib.vorbisspi" /> 
     723                                <path refid="path.lib.tritonus" /> 
     724                        </paths> 
     725                </junit.oggdecoders> 
     726                <junit.oggdecoders name="javazoom"> 
     727                        <paths> 
     728                                <path refid="path.lib.vorbisspi" /> 
     729                        </paths> 
     730                        <properties> 
     731                                <sysproperty key="org.kolaka.freecast.ogg.test.OggDecoderTest.tritonus" value="false" /> 
     732                        </properties> 
     733                </junit.oggdecoders> 
     734                <junit.oggdecoders name="tritonus"> 
     735                        <paths> 
     736                                <path refid="path.lib.tritonus" /> 
     737                        </paths> 
     738                        <properties> 
     739                                <sysproperty key="org.kolaka.freecast.ogg.test.OggDecoderTest.javazoom" value="false" /> 
     740                        </properties> 
     741                </junit.oggdecoders> 
     742                <junit.oggdecoders name="all-reverse"> 
     743                        <paths> 
     744                                <path refid="path.lib.tritonus" /> 
     745                                <path refid="path.lib.vorbisspi" /> 
     746                        </paths> 
     747                </junit.oggdecoders> 
    660748        </target> 
    661749 
     
    801889                <copy todir="dist/lib/linux/x86"> 
    802890                        <fileset dir="${track.tritonus.dir}"> 
    803                                 <include name="*.so"/> 
     891                                <include name="*.so" /> 
    804892                        </fileset> 
    805893                </copy> 
  • trunk/source/org/kolaka/freecast/NodeConfigurator.java

    r1 r70  
    7575        } 
    7676 
     77        /** 
     78         * @param node 
     79         * @param configuration 
     80         * @throws ConfigurationException 
     81         * @throws IOException 
     82         */ 
    7783        public void configure(ConfigurableNode node, Configuration configuration) 
    7884        throws ConfigurationException, IOException 
     
    129135        if (receiverClass.equals("shoutclient")) { 
    130136            receiver = new ShoutClientReceiver(receiverConfiguration.getURL("url")); 
    131         } else if (receiverClass.equals("playlist")) { 
     137        } else if (receiverClass.equals("playlist") || receiverClass.equals("encoder-playlist")) { 
    132138                        String playlistURIString = receiverConfiguration.getString("url"); 
    133139                        URI playlistURI = null; 
     
    137143                                throw new ConfigurationException("invalid playlist url: '" + playlistURIString,e); 
    138144                        } 
    139                         receiver = new PlaylistReceiver(new ResourcePlaylist(resourceLocator, playlistURI)); 
    140             // TODO remove this StaticBandwidthControler usage  
    141             LogFactory.getLog(getClass()).warn("the playlist receiver uses a static bandwidth controler"); 
    142                         int bandwidth = receiverConfiguration.getInt("bandwidth",35); 
    143             BandwidthControler bandwidthControler = new StaticBandwidthControler((int) (bandwidth * FileUtils.ONE_KB)); 
    144             ((PlaylistReceiver) receiver).setBandwidthControler(bandwidthControler); 
     145                         
     146                        Playlist playlist = ResourcePlaylist.getInstance(resourceLocator, playlistURI); 
     147                         
     148                        if (receiverClass.equals("playlist")) { 
     149                                receiver = new PlaylistReceiver(playlist); 
     150                                int bandwidth = receiverConfiguration.getInt("bandwidth",35); 
     151                    LogFactory.getLog(getClass()).warn("the playlist receiver uses a static bandwidth controler at " + bandwidth); 
     152                    BandwidthControler bandwidthControler = new StaticBandwidthControler((int) (bandwidth * FileUtils.ONE_KB)); 
     153                    ((PlaylistReceiver) receiver).setBandwidthControler(bandwidthControler); 
     154                        } else { 
     155                                int channels = receiverConfiguration.getInt("channels",2); 
     156                                int sampleRate = receiverConfiguration.getInt("sampleRate",44100); 
     157                                float quality = receiverConfiguration.getFloat("quality",0); 
     158                                EncoderFormat format = new EncoderFormat(channels, sampleRate, quality); 
     159                                receiver = new PlaylistEncoderReceiver(playlist, format); 
     160                        } 
    145161        } else if (receiverClass.equals("shoutserver")) { 
    146162            InetSocketAddress listenAddress = loadInetSocketAddress(receiverConfiguration.subset("listenaddress")); 
  • trunk/source/org/kolaka/freecast/ogg/DefaultOggPage.java

    r69 r70  
    2727import org.apache.commons.lang.builder.HashCodeBuilder; 
    2828import org.apache.commons.lang.builder.ToStringBuilder; 
    29 import org.kolaka.freecast.player.StereoPCMAudioInputStream; 
    3029 
    3130/** 
  • trunk/source/org/kolaka/freecast/ogg/EncoderOggSource.java

    r60 r70  
    3636import org.apache.commons.lang.UnhandledException; 
    3737import org.apache.commons.lang.Validate; 
     38import org.apache.commons.logging.LogFactory; 
    3839import org.tritonus.lowlevel.ogg.Packet; 
    3940import org.tritonus.lowlevel.ogg.Page; 
     
    8990        private void init() throws IOException { 
    9091                AudioFormat inputFormat = audioInput.getFormat(); 
     92                LogFactory.getLog(getClass()).debug("initialize ogg encoder to encode " + inputFormat); 
    9193 
    9294                readBuffer = new byte[READ * audioInput.getFormat().getFrameSize()]; 
     
    169171                } 
    170172 
    171                 if (endOfStream) { 
    172                         throw new EOFException(); 
    173                 } 
    174  
    175173                if (pages.isEmpty()) { 
     174                        if (endOfStream) { 
     175                                throw new EOFException(); 
     176                        } 
     177 
    176178                        fillCache(); 
     179                         
    177180                        if (pages.isEmpty()) { 
    178181                                throw new EOFException(); 
     
    226229 
    227230        } 
    228  
     231         
    229232        private void fillCache() throws IOException { 
    230233                boolean cacheFilled = false; 
     
    234237                        if (read == 0 || read == -1) { 
    235238                                dspState.write(null, 0); 
     239                                LogFactory.getLog(getClass()).debug("end of the read stream"); 
    236240                                endOfStream = true; 
    237241                        } else { 
  • trunk/source/org/kolaka/freecast/ogg/test/EncoderOggSourceTest.java

    r61 r70  
    2525 
    2626import java.io.EOFException; 
    27 import java.io.FileOutputStream; 
    2827import java.io.InputStream; 
    29 import java.io.OutputStream; 
    3028 
    3129import javax.sound.sampled.AudioFormat; 
     
    4240 
    4341        public void testEncoding() throws Exception { 
    44                 InputStream inputResources = getClass().getResourceAsStream( 
    45                                 "resources/sample.ogg"); 
    46                 assertNotNull(inputResources); 
     42                InputStream inputResources = OggTestResources.getResourceAsStream("sample.ogg"); 
     43 
    4744                AudioFormat pcmFormat = new AudioFormat(44100, 16, 1, true, false); 
    4845                AudioInputStream audioInput = AudioSystem.getAudioInputStream( 
     
    5148                OggSource oggSource = new EncoderOggSource(audioInput, 0); 
    5249                 
    53                 OutputStream testOutput = new FileOutputStream("/tmp/test.ogg"); 
     50                // OutputStream testOutput = new FileOutputStream("/tmp/test.ogg"); 
    5451 
    5552                try { 
    5653                        while (true) { 
    5754                                OggPage page = oggSource.next(); 
    58                                 System.out.println(page); 
    59                                 testOutput.write(page.getRawBytes()); 
     55                                // testOutput.write(page.getRawBytes()); 
    6056                        } 
    6157                } catch (EOFException e) { 
    6258 
    6359                } finally { 
    64                         testOutput.close(); 
     60                        // testOutput.close(); 
    6561                        oggSource.close(); 
    6662                        audioInput.close(); 
  • trunk/source/org/kolaka/freecast/packet/DefaultLogicalPageDescriptor.java

    r57 r70  
    2323 
    2424package org.kolaka.freecast.packet; 
     25 
     26import org.apache.commons.lang.builder.ToStringBuilder; 
    2527 
    2628/** 
     
    8284    } 
    8385     
     86    public String toString() { 
     87                return ToStringBuilder.reflectionToString(this);  
     88    } 
     89     
    8490} 
  • trunk/source/org/kolaka/freecast/packet/LogicalPageBuilder.java

    r57 r70  
    2525 
    2626import org.apache.commons.lang.Validate; 
     27import org.apache.commons.lang.builder.ToStringBuilder; 
    2728import org.kolaka.freecast.collections.SortedList; 
    2829 
     
    7576    } 
    7677     
     78    public String toString() { 
     79                return ToStringBuilder.reflectionToString(this);  
     80    } 
     81     
    7782} 
  • trunk/source/org/kolaka/freecast/pipe/ConsumerInputStreamFactory.java

    r1 r70  
    7676 
    7777        Stream(LogicalPage readPage) { 
    78             Validate.isTrue(readPage.isFirstPage()); 
     78            Validate.isTrue(readPage.isFirstPage(), "Read page isn't first page: " + readPage); 
    7979            this.readPage = readPage; 
    8080        } 
  • trunk/source/org/kolaka/freecast/player/AudioPlayer.java

    r1 r70  
    2424package org.kolaka.freecast.player; 
    2525 
     26import java.util.Date; 
     27 
     28import javax.sound.sampled.AudioFormat; 
     29import javax.sound.sampled.AudioInputStream; 
     30import javax.sound.sampled.DataLine; 
     31import javax.sound.sampled.LineUnavailableException; 
     32import javax.sound.sampled.SourceDataLine; 
     33 
    2634import org.apache.commons.logging.LogFactory; 
     35import org.kolaka.freecast.ogg.OggDecoder; 
    2736import org.kolaka.freecast.pipe.Consumer; 
    2837import org.kolaka.freecast.pipe.ConsumerInputStreamFactory; 
    2938import org.kolaka.freecast.service.BaseService; 
    3039import org.kolaka.freecast.service.ControlException; 
    31  
    32 import javax.sound.sampled.*; 
    33 import java.util.Date; 
     40import org.kolaka.freecast.sound.AudioSystem; 
     41import org.kolaka.freecast.sound.StereoPCMAudioInputStream; 
    3442 
    3543/** 
     
    7078                OUTPUT_FORMAT); 
    7179 
    72         if (!AudioSystem.isLineSupported(info)) { 
     80        if (!javax.sound.sampled.AudioSystem.isLineSupported(info)) { 
    7381            throw new ControlException("Can't find a compatible sound ouput"); 
    7482        } 
    7583 
    7684        try { 
    77             line = (SourceDataLine) AudioSystem.getLine(info); 
     85            line = (SourceDataLine) javax.sound.sampled.AudioSystem.getLine(info); 
    7886        } catch (LineUnavailableException e) { 
    7987            throw new ControlException("Can't obtain a sound ouput", e); 
     
    163171                while (!stopped) { 
    164172                    if (audioInput == null) { 
    165                         AudioInputStream oggAudioInputStream = AudioSystem 
    166                                                 .getAudioInputStream(consumerInputStreamFactory 
    167                                                         .next()); 
    168                         AudioFormat oggFormat = oggAudioInputStream.getFormat(); 
    169                         LogFactory.getLog(getClass()).debug( 
    170                         "sound stream started (format: " + oggFormat + ")"); 
    171                          
    172                         if (oggFormat.getChannels() == 1) { 
    173                             AudioFormat pcmFormat =  
    174                                 new AudioFormat(OUTPUT_FORMAT.getSampleRate(), OUTPUT_FORMAT.getSampleSizeInBits(), oggFormat.getChannels(),true, false); 
    175                             audioInput = new StereoPCMAudioInputStream(AudioSystem 
    176                                     .getAudioInputStream( 
    177                                             pcmFormat, 
    178                                             oggAudioInputStream)); 
    179                         } else { 
    180                             audioInput = AudioSystem.getAudioInputStream(OUTPUT_FORMAT, oggAudioInputStream); 
    181                         } 
     173                        audioInput = OggDecoder.getInstance().decode(OUTPUT_FORMAT, consumerInputStreamFactory 
     174                                .next());  
    182175                    } 
    183176 
  • trunk/source/org/kolaka/freecast/resource/CompositeResourceLocator.java

    r38 r70  
    5151                                return resourceLocator.openResource(uri); 
    5252                        } catch (Exception e) { 
    53                                 LogFactory.getLog(getClass()).trace("inner ResourceLocator can't open " + uri, e); 
     53                                LogFactory.getLog(getClass()).trace(resourceLocator + " can't open " + uri); 
    5454                                continue; 
    5555                        } 
  • trunk/source/org/kolaka/freecast/resource/FileResourceLocator.java

    r1 r70  
    2323package org.kolaka.freecast.resource; 
    2424 
    25 import org.apache.commons.lang.SystemUtils; 
    26 import org.apache.commons.lang.Validate; 
    27  
    28 import java.io.InputStream; 
     25import java.io.BufferedInputStream; 
    2926import java.io.File; 
    3027import java.io.FileInputStream; 
    3128import java.io.FileNotFoundException; 
     29import java.io.InputStream; 
    3230import java.net.URI; 
     31import java.util.Iterator; 
     32import java.util.LinkedList; 
     33import java.util.List; 
     34 
     35import org.apache.commons.lang.SystemUtils; 
     36import org.apache.commons.lang.Validate; 
     37import org.apache.commons.logging.LogFactory; 
    3338 
    3439/** 
     
    3742public class FileResourceLocator implements ResourceLocator { 
    3843 
    39         private final File baseDirectory
     44        private final FileResolver fileResolver
    4045 
    4146        public FileResourceLocator() { 
    42                 this(new File(SystemUtils.USER_DIR)); 
     47                fileResolver = new DefautFileResolver(); 
    4348        } 
    4449 
    4550        public FileResourceLocator(File baseDirectory) { 
    46                 this.baseDirectory = baseDirectory
     51                fileResolver = new BasedFileResolver(baseDirectory)
    4752        } 
    4853 
     
    5055                Validate.notNull(uri, "No specified URI"); 
    5156                if (uri.getScheme() != null) { 
    52                         MalformedURIException.checkScheme(uri,"file"); 
     57                        MalformedURIException.checkScheme(uri, "file"); 
    5358                } 
    5459 
    55                 File file = findFile(uri); 
    56  
     60                File file = fileResolver.resolve(uri); 
     61                LogFactory.getLog(getClass()).debug("open " + file); 
    5762                try { 
    58             return new FileInputStream(file); 
    59         } catch (FileNotFoundException e) { 
    60             throw new NoSuchResourceException(uri); 
    61         } 
    62     } 
    63  
    64         private File findFile(URI uri) { 
    65                 if (uri.isAbsolute()) { 
    66                         return new File(uri.getPath()); 
    67                 } else { </