libmp3spi-java-1.9.5.orig/0000755000175000017500000000000011455365704015256 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/srctest/0000755000175000017500000000000011451704254016736 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/srctest/javazoom/0000755000175000017500000000000011451704254020564 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/srctest/javazoom/spi/0000755000175000017500000000000011451704254021357 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/srctest/javazoom/spi/mpeg/0000755000175000017500000000000011451704254022307 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/srctest/javazoom/spi/mpeg/sampled/0000755000175000017500000000000011451704254023734 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/srctest/javazoom/spi/mpeg/sampled/file/0000755000175000017500000000000011451704254024653 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/srctest/javazoom/spi/mpeg/sampled/file/SkipTest.java0000644000175000017500000001255110322251462027262 0ustar twernertwerner/* * SkipTest - JavaZOOM : http://www.javazoom.net * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ package javazoom.spi.mpeg.sampled.file; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.util.Properties; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.SourceDataLine; import junit.framework.TestCase; /** * Skip bytes before playing. */ public class SkipTest extends TestCase { private String basefile=null; private String baseurl=null; private String filename=null; private String fileurl=null; private String name=null; private Properties props = null; private PrintStream out = null; /** * Constructor for PropertiesTest. * @param arg0 */ public SkipTest(String arg0) { super(arg0); } /* * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); props = new Properties(); InputStream pin = getClass().getClassLoader().getResourceAsStream("test.mp3.properties"); props.load(pin); basefile = (String) props.getProperty("basefile"); baseurl = (String) props.getProperty("baseurl"); name = (String) props.getProperty("filename"); filename = basefile + name; fileurl = baseurl + name; out = System.out; } /* * @see TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } public void testSkipFile() { if (out != null) out.println("-> Filename : "+filename+" <-"); try { File file = new File(filename); AudioFileFormat aff = AudioSystem.getAudioFileFormat(file); AudioInputStream in = AudioSystem.getAudioInputStream(file); AudioInputStream din = null; AudioFormat baseFormat = in.getFormat(); if (out != null) out.println("Source Format : "+baseFormat.toString()); AudioFormat decodedFormat = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false); if (out != null) out.println("Target Format : "+decodedFormat.toString()); din = AudioSystem.getAudioInputStream(decodedFormat, in); long toSkip = (long)(file.length()/2); long skipped = skip(din,toSkip); if (out != null) out.println("Skip : "+skipped+"/"+toSkip+" (Total="+file.length()+")"); if (out != null) out.println("Start playing"); rawplay(decodedFormat, din); in.close(); if (out != null) out.println("Played"); assertTrue("testSkip : OK",true); } catch (Exception e) { assertTrue(e.getMessage(),false); } } private long skip(AudioInputStream in, long bytes) throws IOException { long SKIP_INACCURACY_SIZE = 1200; long totalSkipped = 0; long skipped = 0; while (totalSkipped < (bytes - SKIP_INACCURACY_SIZE)) { skipped = in.skip(bytes - totalSkipped); if (skipped == 0) break; totalSkipped = totalSkipped + skipped; } return totalSkipped; } private SourceDataLine getLine(AudioFormat audioFormat) throws LineUnavailableException { SourceDataLine res = null; DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); res = (SourceDataLine) AudioSystem.getLine(info); res.open(audioFormat); return res; } private void rawplay(AudioFormat targetFormat, AudioInputStream din) throws IOException, LineUnavailableException { byte[] data = new byte[4096]; SourceDataLine line = getLine(targetFormat); if (line != null) { // Start line.start(); int nBytesRead = 0, nBytesWritten = 0; while (nBytesRead != -1) { nBytesRead = din.read(data, 0, data.length); if (nBytesRead != -1) nBytesWritten = line.write(data, 0, nBytesRead); } // Stop line.drain(); line.stop(); line.close(); din.close(); } } } libmp3spi-java-1.9.5.orig/srctest/javazoom/spi/mpeg/sampled/file/MpegAudioFileReaderTest.java0000644000175000017500000002615110321563724032160 0ustar twernertwerner/* * MpegAudioFileReaderTest - JavaZOOM : http://www.javazoom.net * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ package javazoom.spi.mpeg.sampled.file; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.net.URL; import java.util.Properties; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; import junit.framework.TestCase; /** * MpegAudioFileReader unit test. * It matches test.mp3 properties to test.mp3.properties expected results. * As we don't ship test.mp3, you have to generate your own test.mp3.properties * Uncomment out = System.out; in setUp() method to generated it on stdout from * your own MP3 file. */ public class MpegAudioFileReaderTest extends TestCase { private String basefile=null; private String baseurl=null; private String filename=null; private String fileurl=null; private String name=null; private Properties props = null; private PrintStream out = null; /** * Constructor for MpegAudioFileReaderTest. * @param arg0 */ public MpegAudioFileReaderTest(String arg0) { super(arg0); } /* * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); props = new Properties(); InputStream pin = getClass().getClassLoader().getResourceAsStream("test.mp3.properties"); props.load(pin); basefile = (String) props.getProperty("basefile"); baseurl = (String) props.getProperty("baseurl"); name = (String) props.getProperty("filename"); filename = basefile + name; fileurl = baseurl + name; //out = System.out; } /* * @see TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } public void testGetAudioFileFormat() { _testGetAudioFileFormatFile(); _testGetAudioFileFormatURL(); _testGetAudioFileFormatInputStream(); } public void testGetAudioInputStream() { _testGetAudioInputStreamFile(); _testGetAudioInputStreamURL(); _testGetAudioInputStreamInputStream(); } /* * Test for AudioFileFormat getAudioFileFormat(File) */ public void _testGetAudioFileFormatFile() { if (out!=null) out.println("*** testGetAudioFileFormatFile ***"); try { File file = new File(filename); AudioFileFormat baseFileFormat= AudioSystem.getAudioFileFormat(file); dumpAudioFileFormat(baseFileFormat,out,file.toString()); assertEquals("FrameLength",Integer.parseInt((String)props.getProperty("FrameLength")),baseFileFormat.getFrameLength()); assertEquals("ByteLength",Integer.parseInt((String)props.getProperty("ByteLength")),baseFileFormat.getByteLength()); } catch (UnsupportedAudioFileException e) { assertTrue("testGetAudioFileFormatFile:"+e.getMessage(),false); } catch (IOException e) { assertTrue("testGetAudioFileFormatFile:"+e.getMessage(),false); } } /* * Test for AudioFileFormat getAudioFileFormat(URL) */ public void _testGetAudioFileFormatURL() { if (out!=null) out.println("*** testGetAudioFileFormatURL ***"); try { URL url = new URL(fileurl); AudioFileFormat baseFileFormat= AudioSystem.getAudioFileFormat(url); dumpAudioFileFormat(baseFileFormat,out,url.toString()); assertEquals("FrameLength",-1,baseFileFormat.getFrameLength()); assertEquals("ByteLength",-1,baseFileFormat.getByteLength()); } catch (UnsupportedAudioFileException e) { assertTrue("testGetAudioFileFormatURL:"+e.getMessage(),false); } catch (IOException e) { assertTrue("testGetAudioFileFormatURL:"+e.getMessage(),false); } } /* * Test for AudioFileFormat getAudioFileFormat(InputStream) */ public void _testGetAudioFileFormatInputStream() { if (out!=null) out.println("*** testGetAudioFileFormatInputStream ***"); try { InputStream in = new BufferedInputStream(new FileInputStream(filename)); AudioFileFormat baseFileFormat= AudioSystem.getAudioFileFormat(in); dumpAudioFileFormat(baseFileFormat,out,in.toString()); in.close(); assertEquals("FrameLength",-1,baseFileFormat.getFrameLength()); assertEquals("ByteLength",-1,baseFileFormat.getByteLength()); } catch (UnsupportedAudioFileException e) { assertTrue("testGetAudioFileFormatInputStream:"+e.getMessage(),false); } catch (IOException e) { assertTrue("testGetAudioFileFormatInputStream:"+e.getMessage(),false); } } /* * Test for AudioInputStream getAudioInputStream(InputStream) */ public void _testGetAudioInputStreamInputStream() { if (out!=null) out.println("*** testGetAudioInputStreamInputStream ***"); try { InputStream fin = new BufferedInputStream(new FileInputStream(filename)); AudioInputStream in= AudioSystem.getAudioInputStream(fin); dumpAudioInputStream(in,out,fin.toString()); assertEquals("FrameLength",-1,in.getFrameLength()); assertEquals("Available",Integer.parseInt((String)props.getProperty("Available")),in.available()); fin.close(); in.close(); } catch (UnsupportedAudioFileException e) { assertTrue("testGetAudioInputStreamInputStream:"+e.getMessage(),false); } catch (IOException e) { assertTrue("testGetAudioInputStreamInputStream:"+e.getMessage(),false); } } /* * Test for AudioInputStream getAudioInputStream(File) */ public void _testGetAudioInputStreamFile() { if (out!=null) out.println("*** testGetAudioInputStreamFile ***"); try { File file = new File(filename); AudioInputStream in= AudioSystem.getAudioInputStream(file); dumpAudioInputStream(in,out,file.toString()); assertEquals("FrameLength",-1,in.getFrameLength()); assertEquals("Available",Integer.parseInt((String)props.getProperty("Available")),in.available()); in.close(); } catch (UnsupportedAudioFileException e) { assertTrue("testGetAudioInputStreamFile:"+e.getMessage(),false); } catch (IOException e) { assertTrue("testGetAudioInputStreamFile:"+e.getMessage(),false); } } /* * Test for AudioInputStream getAudioInputStream(URL) */ public void _testGetAudioInputStreamURL() { if (out!=null) out.println("*** testGetAudioInputStreamURL ***"); try { URL url = new URL(fileurl); AudioInputStream in= AudioSystem.getAudioInputStream(url); dumpAudioInputStream(in,out,url.toString()); assertEquals("FrameLength",-1,in.getFrameLength()); assertEquals("Available",Integer.parseInt((String)props.getProperty("Available")),in.available()); in.close(); } catch (UnsupportedAudioFileException e) { assertTrue("testGetAudioInputStreamURL:"+e.getMessage(),false); } catch (IOException e) { assertTrue("testGetAudioInputStreamURL:"+e.getMessage(),false); } } private void dumpAudioFileFormat(AudioFileFormat baseFileFormat, PrintStream out, String info) throws UnsupportedAudioFileException { AudioFormat baseFormat = baseFileFormat.getFormat(); if (out != null) { // AudioFileFormat out.println(" ----- "+info+" -----"); out.println(" ByteLength="+ baseFileFormat.getByteLength()); out.println(" FrameLength="+ baseFileFormat.getFrameLength()); out.println(" Type="+ baseFileFormat.getType()); // AudioFormat out.println(" SourceFormat="+baseFormat.toString()); out.println(" Channels="+ baseFormat.getChannels()); out.println(" FrameRate="+ baseFormat.getFrameRate()); out.println(" FrameSize="+ baseFormat.getFrameSize()); out.println(" SampleRate="+ baseFormat.getSampleRate()); out.println(" SampleSizeInBits="+ baseFormat.getSampleSizeInBits()); out.println(" Encoding="+ baseFormat.getEncoding()); } assertEquals("Type",(String)props.getProperty("Type"),baseFileFormat.getType().toString()); assertEquals("SourceFormat",(String)props.getProperty("SourceFormat"),baseFormat.toString()); assertEquals("Channels",Integer.parseInt((String)props.getProperty("Channels")),baseFormat.getChannels()); assertTrue("FrameRate",Float.parseFloat((String)props.getProperty("FrameRate"))==baseFormat.getFrameRate()); assertEquals("FrameSize",Integer.parseInt((String)props.getProperty("FrameSize")),baseFormat.getFrameSize()); assertTrue("SampleRate",Float.parseFloat((String)props.getProperty("SampleRate"))==baseFormat.getSampleRate()); assertEquals("SampleSizeInBits",Integer.parseInt((String)props.getProperty("SampleSizeInBits")),baseFormat.getSampleSizeInBits()); assertEquals("Encoding",(String)props.getProperty("Encoding"),baseFormat.getEncoding().toString()); } private void dumpAudioInputStream(AudioInputStream in, PrintStream out, String info) throws IOException { AudioFormat baseFormat = in.getFormat(); if (out != null) { out.println(" ----- "+info+" -----"); out.println(" Available="+in.available()); out.println(" FrameLength="+in.getFrameLength()); // AudioFormat out.println(" SourceFormat="+baseFormat.toString()); out.println(" Channels="+ baseFormat.getChannels()); out.println(" FrameRate="+ baseFormat.getFrameRate()); out.println(" FrameSize="+ baseFormat.getFrameSize()); out.println(" SampleRate="+ baseFormat.getSampleRate()); out.println(" SampleSizeInBits="+ baseFormat.getSampleSizeInBits()); out.println(" Encoding="+ baseFormat.getEncoding()); } assertEquals("SourceFormat",(String)props.getProperty("SourceFormat"),baseFormat.toString()); assertEquals("Channels",Integer.parseInt((String)props.getProperty("Channels")),baseFormat.getChannels()); assertTrue("FrameRate",Float.parseFloat((String)props.getProperty("FrameRate"))==baseFormat.getFrameRate()); assertEquals("FrameSize",Integer.parseInt((String)props.getProperty("FrameSize")),baseFormat.getFrameSize()); assertTrue("SampleRate",Float.parseFloat((String)props.getProperty("SampleRate"))==baseFormat.getSampleRate()); assertEquals("SampleSizeInBits",Integer.parseInt((String)props.getProperty("SampleSizeInBits")),baseFormat.getSampleSizeInBits()); assertEquals("Encoding",(String)props.getProperty("Encoding"),baseFormat.getEncoding().toString()); } } libmp3spi-java-1.9.5.orig/srctest/javazoom/spi/mpeg/sampled/file/PropertiesTest.java0000644000175000017500000002361210322536546030521 0ustar twernertwernerpackage javazoom.spi.mpeg.sampled.file; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.net.URL; import java.util.Iterator; import java.util.Map; import java.util.Properties; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; import junit.framework.TestCase; import org.tritonus.share.sampled.TAudioFormat; import org.tritonus.share.sampled.file.TAudioFileFormat; /** * PropertiesContainer unit test. * It matches test.mp3 properties to test.mp3.properties expected results. * As we don't ship test.mp3, you have to generate your own test.mp3.properties * Uncomment out = System.out; in setUp() method to generated it on stdout from * your own MP3 file. */ public class PropertiesTest extends TestCase { private String basefile=null; private String baseurl=null; private String filename=null; private String fileurl=null; private String name=null; private Properties props = null; private PrintStream out = null; /** * Constructor for PropertiesTest. * @param arg0 */ public PropertiesTest(String arg0) { super(arg0); } /* * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); props = new Properties(); InputStream pin = getClass().getClassLoader().getResourceAsStream("test.mp3.properties"); props.load(pin); basefile = (String) props.getProperty("basefile"); baseurl = (String) props.getProperty("baseurl"); name = (String) props.getProperty("filename"); filename = basefile + name; fileurl = baseurl + name; out = System.out; } /* * @see TestCase#tearDown() */ protected void tearDown() throws Exception { super.tearDown(); } public void testPropertiesFile() { String[] testPropsAFF = {"duration","title","author","album","date","comment", "copyright","mp3.framerate.fps","mp3.copyright","mp3.padding", "mp3.original","mp3.length.bytes","mp3.frequency.hz", "mp3.length.frames","mp3.mode","mp3.channels","mp3.version.mpeg", "mp3.framesize.bytes","mp3.vbr.scale","mp3.version.encoding", "mp3.header.pos","mp3.version.layer","mp3.crc"}; String[] testPropsAF = {"vbr", "bitrate"}; File file = new File(filename); AudioFileFormat baseFileFormat = null; AudioFormat baseFormat = null; try { baseFileFormat = AudioSystem.getAudioFileFormat(file); baseFormat = baseFileFormat.getFormat(); if (out != null) out.println("-> Filename : "+filename+" <-"); if (out != null) out.println(baseFileFormat); if (baseFileFormat instanceof TAudioFileFormat) { Map properties = ((TAudioFileFormat)baseFileFormat).properties(); if (out != null) out.println(properties); for (int i=0;i URL : "+filename+" <-"); if (out != null) out.println(baseFileFormat); if (baseFileFormat instanceof TAudioFileFormat) { Map properties = ((TAudioFileFormat)baseFileFormat).properties(); for (int i=0;i URL : "+url.toString()+" <-"); if (out != null) out.println(baseFileFormat); if (baseFileFormat instanceof TAudioFileFormat) { Map properties = ((TAudioFileFormat)baseFileFormat).properties(); Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); String val = null; if (properties.get(key) != null) val=(properties.get(key)).toString(); if (out != null) out.println(key+"='"+val+"'"); } } else { assertTrue("testPropertiesShoutcast : TAudioFileFormat expected",false); } if (baseFormat instanceof TAudioFormat) { Map properties = ((TAudioFormat)baseFormat).properties(); Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); String val = null; if (properties.get(key) != null) val=(properties.get(key)).toString(); if (out != null) out.println(key+"='"+val+"'"); } } else { assertTrue("testPropertiesShoutcast : TAudioFormat expected",false); } } catch (UnsupportedAudioFileException e) { assertTrue("testPropertiesShoutcast : "+e.getMessage(),false); } catch (IOException e) { assertTrue("testPropertiesShoutcast : "+e.getMessage(),false); } } public void _testDumpPropertiesFile() { File file = new File(filename); AudioFileFormat baseFileFormat = null; AudioFormat baseFormat = null; try { baseFileFormat = AudioSystem.getAudioFileFormat(file); baseFormat = baseFileFormat.getFormat(); if (out != null) out.println("-> Filename : "+filename+" <-"); if (baseFileFormat instanceof TAudioFileFormat) { Map properties = ((TAudioFileFormat)baseFileFormat).properties(); Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); String val=(properties.get(key)).toString(); if (out != null) out.println(key+"='"+val+"'"); } } else { assertTrue("testDumpPropertiesFile : TAudioFileFormat expected",false); } if (baseFormat instanceof TAudioFormat) { Map properties = ((TAudioFormat)baseFormat).properties(); Iterator it = properties.keySet().iterator(); while (it.hasNext()) { String key = (String) it.next(); String val=(properties.get(key)).toString(); if (out != null) out.println(key+"='"+val+"'"); } } else { assertTrue("testDumpPropertiesFile : TAudioFormat expected",false); } } catch (UnsupportedAudioFileException e) { assertTrue("testDumpPropertiesFile : "+e.getMessage(),false); } catch (IOException e) { assertTrue("testDumpPropertiesFile : "+e.getMessage(),false); } } } libmp3spi-java-1.9.5.orig/srctest/AllSPITests.java0000644000175000017500000000111110321563724021702 0ustar twernertwernerimport javazoom.spi.mpeg.sampled.file.PropertiesTest; import javazoom.spi.mpeg.sampled.file.MpegAudioFileReaderTest; import junit.framework.Test; import junit.framework.TestSuite; /** * @author Administrateur * */ public class AllSPITests { public static Test suite() { TestSuite suite = new TestSuite("Test for default package"); //$JUnit-BEGIN$ suite.addTest(new TestSuite(MpegAudioFileReaderTest.class)); suite.addTest(new TestSuite(PropertiesTest.class)); suite.addTest(new TestSuite(PlayerTest.class)); //$JUnit-END$ return suite; } } libmp3spi-java-1.9.5.orig/srctest/test.mp3.properties0000644000175000017500000000222510322536664022536 0ustar twernertwerner# MP3 file basefile=d:/data/ baseurl=file:///d:/data/ filename=test.mp3 shoutcast=http://64.236.34.97:80/stream/1003 shoutcast96=http://64.236.34.97:80/stream/1003 shoutcast128=http://160.79.128.35:7012/ # AudioFileFormat and AudioFormat properties ByteLength=6078464 FrameLength=8122 Type=MP3 SourceFormat=MPEG1L3, 44100.0 Hz, -1 bit, stereo, audio data Channels=2 FrameRate=38.28125 FrameSize=-1 SampleRate=44100.0 SampleSizeInBits=-1 Encoding=MPEG1L3 # AudioInputStream properties Available=6078464 # Extented Normalized (JDK1.5) AudioFormat properties vbr=true bitrate=229000 # Extented Normalized (JDK1.5) AudioFileFormat properties duration=212167000 title=We author=Scer album=The Sta no Expe date=2003 comment=Test Comments ! copyright=copy # Extented MP3 AudioFileFormat properties mp3.framerate.fps=38.28125 mp3.copyright=false mp3.padding=false mp3.original=false mp3.length.bytes=6078464 mp3.frequency.hz=44100 mp3.length.frames=8122 mp3.mode=1 mp3.channels=2 mp3.version.mpeg=1 mp3.framesize.bytes=413 mp3.vbr.scale=78 mp3.version.encoding=MPEG1L3 mp3.header.pos=2150 mp3.version.layer=3 mp3.crc=false libmp3spi-java-1.9.5.orig/srctest/PlayerTest.java0000644000175000017500000001111510321563724021674 0ustar twernertwerner/* * PlayerTest - JavaZOOM : http://www.javazoom.net * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * */ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; import java.util.Properties; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.SourceDataLine; import javazoom.spi.PropertiesContainer; import junit.framework.TestCase; /** * Simple player (based on MP3 SPI) unit test. * It takes around 2-5% of CPU and 16MB RAM under Win2K/P4/1.6GHz/JDK1.5 beta * It takes around 10-12% of CPU and 10MB RAM under Win2K/PIII/1GHz/JDK1.4.1 * It takes around 8-10% of CPU and 10MB RAM under Win2K/PIII/1GHz/JDK1.3.1 */ public class PlayerTest extends TestCase { private String basefile=null; private String filename=null; private String name=null; private Properties props = null; private PrintStream out = null; /** * Constructor for PlayerTest. * @param arg0 */ public PlayerTest(String arg0) { super(arg0); } /* * @see TestCase#setUp() */ protected void setUp() throws Exception { super.setUp(); props = new Properties(); InputStream pin = getClass().getClassLoader().getResourceAsStream("test.mp3.properties"); props.load(pin); basefile = (String) props.getProperty("basefile"); name = (String) props.getProperty("filename"); filename = basefile + name; out = System.out; } public void testPlay() { try { if (out != null) out.println("--- Start : "+filename+" ---"); File file = new File(filename); //URL file = new URL(props.getProperty("shoutcast")); AudioFileFormat aff = AudioSystem.getAudioFileFormat(file); if (out != null) out.println("Audio Type : "+aff.getType()); AudioInputStream in= AudioSystem.getAudioInputStream(file); AudioInputStream din = null; if (in != null) { AudioFormat baseFormat = in.getFormat(); if (out != null) out.println("Source Format : "+baseFormat.toString()); AudioFormat decodedFormat = new AudioFormat( AudioFormat.Encoding.PCM_SIGNED, baseFormat.getSampleRate(), 16, baseFormat.getChannels(), baseFormat.getChannels() * 2, baseFormat.getSampleRate(), false); if (out != null) out.println("Target Format : "+decodedFormat.toString()); din = AudioSystem.getAudioInputStream(decodedFormat, in); if (din instanceof PropertiesContainer) { assertTrue("PropertiesContainer : OK",true); } else { assertTrue("Wrong PropertiesContainer instance",false); } rawplay(decodedFormat, din); in.close(); if (out != null) out.println("--- Stop : "+filename+" ---"); assertTrue("testPlay : OK",true); } } catch (Exception e) { assertTrue("testPlay : "+e.getMessage(),false); } } private SourceDataLine getLine(AudioFormat audioFormat) throws LineUnavailableException { SourceDataLine res = null; DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat); res = (SourceDataLine) AudioSystem.getLine(info); res.open(audioFormat); return res; } private void rawplay(AudioFormat targetFormat, AudioInputStream din) throws IOException, LineUnavailableException { byte[] data = new byte[4096]; SourceDataLine line = getLine(targetFormat); if (line != null) { // Start line.start(); int nBytesRead = 0, nBytesWritten = 0; while (nBytesRead != -1) { nBytesRead = din.read(data, 0, data.length); if (nBytesRead != -1) nBytesWritten = line.write(data, 0, nBytesRead); } // Stop line.drain(); line.stop(); line.close(); din.close(); } } } libmp3spi-java-1.9.5.orig/README.txt0000644000175000017500000000612211455365750016756 0ustar twernertwernerMP3SPI 1.9.5 Project Homepage : http://www.javazoom.net/mp3spi/mp3spi.html JAVA and MP3 online Forums : http://www.javazoom.net/services/forums/index.jsp ----------------------------------------------------- DESCRIPTION : ----------- MP3SPI is a SPI (Service Provider Interface) that adds MP3 support for JavaSound. It allows to play MPEG 1/2/2.5 Layer 1/2/3 files thanks to underlying JLayer and Tritonus libraries. This is a non-commercial project and anyone can add his contribution. MP3SPI is licensed under LGPL (see LICENSE.txt). FAQ : --- - How to install MP3SPI ? Before running MP3SPI you must set PATH and CLASSPATH for JAVA and you must add jl1.0.1.jar, tritonus_share.jar and mp3spi1.9.5.jar to the CLASSPATH. - Do I need JMF to run MP3SPI player ? No, JMF is not required. You just need a JVM JavaSound 1.0 compliant. (i.e. JVM1.3 or higher). However, MP3SPI is not JMF compliant. - Does MP3SPI support streaming ? Yes, it has been successfully tested with SHOUTCast and ICEcast streaming servers. - Does MP3SPI support MPEG 2.5 ? Yes, MP3SPI includes same features as JLayer. - Does MP3SPI support VBR ? Yes, It supports XING and VBRI VBR header too. - How to get ID3v2 tags from MP3SPI API ? MP3SPI exposes many audio properties such as ID3v1/v2 frames, VBR, bitrate ... See online examples from MP3SPI homepage to learn how to get them. MP3SPI supports most used ID3v1.0, v1.1, v2.2, v2.3, v2.4 tags. - How to skip frames to have a seek feature ? Call skip(long bytes) on AudioInputStream. - How to run jUnit tests ? See ANT script included (ant test). You need to update test.mp3.properties file with the audio properties of the MP3 you want to use for testing. You could generate test.mp3.properties by uncommenting //out=System.out in jUnit test sources. - How much memory/CPU MP3SPI needs to run ? Here are our benchmark notes : - Heap use range : 1380KB to 1900KB - 370 classes loaded. - Footprint : ~8MB under WinNT4/Win2K + J2SE 1.3 (Hotspot). ~10MB under WinNT4/Win2K + J2SE 1.4.1 (Hotspot). - CPU usage : ~12% under PIII 800Mhz/WinNT4+J2SE 1.3 (Hotspot). ~8% under PIII 1Ghz/Win2K+J2SE 1.3.1 (Hotspot). ~12% under PIII 1Ghz/Win2K+J2SE 1.4.1 (Hotspot). ~1% under PIII 1Ghz/Win2K+J2SE 1.5.0 (Hotspot). - How to enable debug/traces for the MP3SPI ? Set the following system variable : "tritonus.TraceAudioFileReader=true" It means java.exe -Dtritonus.TraceAudioFileReader=true your.package.Player - How to contact MP3SPI developers ? Try to post a thread on Java&MP3 online forums at : http://www.javazoom.net/services/forums/index.jsp You can also contact us at mp3spi@javazoom.net for contributions. KNOWN PROBLEMS : -------------- 99% of MP3 plays well with JLayer but some (1%) return an ArrayIndexOutOfBoundsException while playing. It might come from invalid audio frames. Workaround : Just try/catch ArrayIndexOutOfBoundsException in your code to skip non-detected invalid frames.libmp3spi-java-1.9.5.orig/doc/0000755000175000017500000000000011455016670016016 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/setenv.bat0000644000175000017500000000015511455365400017244 0ustar twernertwernerset ANT_HOME=C:\java\ant1.7 set JAVA_HOME=C:\java\j2sdk1.4.2_19 set PATH=%JAVA_HOME%\bin;%ANT_HOME%\bin libmp3spi-java-1.9.5.orig/src/0000755000175000017500000000000011455024352016034 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/javazoom/0000755000175000017500000000000011455024352017662 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/javazoom/spi/0000755000175000017500000000000011455024352020455 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/0000755000175000017500000000000011455024352021405 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/0000755000175000017500000000000011455024352023032 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/0000755000175000017500000000000011455024352023751 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/MpegEncoding.java0000644000175000017500000000377711451704772027200 0ustar twernertwerner/* * MpegEncoding. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file; import javax.sound.sampled.AudioFormat; /** * Encodings used by the MPEG audio decoder. */ public class MpegEncoding extends AudioFormat.Encoding { public static final AudioFormat.Encoding MPEG1L1 = new MpegEncoding("MPEG1L1"); public static final AudioFormat.Encoding MPEG1L2 = new MpegEncoding("MPEG1L2"); public static final AudioFormat.Encoding MPEG1L3 = new MpegEncoding("MPEG1L3"); public static final AudioFormat.Encoding MPEG2L1 = new MpegEncoding("MPEG2L1"); public static final AudioFormat.Encoding MPEG2L2 = new MpegEncoding("MPEG2L2"); public static final AudioFormat.Encoding MPEG2L3 = new MpegEncoding("MPEG2L3"); public static final AudioFormat.Encoding MPEG2DOT5L1 = new MpegEncoding("MPEG2DOT5L1"); public static final AudioFormat.Encoding MPEG2DOT5L2 = new MpegEncoding("MPEG2DOT5L2"); public static final AudioFormat.Encoding MPEG2DOT5L3 = new MpegEncoding("MPEG2DOT5L3"); public MpegEncoding(String strName) { super(strName); } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/MpegFileFormatType.java0000644000175000017500000000276611451704772030341 0ustar twernertwerner/* * MpegFileFormatType. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file; import javax.sound.sampled.AudioFileFormat; /** * FileFormatTypes used by the MPEG audio decoder. */ public class MpegFileFormatType extends AudioFileFormat.Type { public static final AudioFileFormat.Type MPEG = new MpegFileFormatType("MPEG", "mpeg"); public static final AudioFileFormat.Type MP3 = new MpegFileFormatType("MP3", "mp3"); public MpegFileFormatType(String strName, String strExtension) { super(strName, strExtension); } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/0000755000175000017500000000000011455024352024524 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/MP3Tag.java0000644000175000017500000000316711451704772026440 0ustar twernertwerner/* * MP3Tag. * * jicyshout : http://sourceforge.net/projects/jicyshout/ * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file.tag; /** An individual piece of mp3 metadata, as a name/value pair. Abstract just so that subclasses will indicate their tagging scheme (Icy, ID3, etc.). */ public abstract class MP3Tag extends Object { protected String name; protected Object value; public MP3Tag(String name, Object value) { this.name = name; this.value = value; } public String getName() { return name; } public Object getValue() { return value; } public String toString() { return getClass().getName() + " -- " + getName() + ":" + getValue().toString(); } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/IcyTag.java0000644000175000017500000000303111451704772026553 0ustar twernertwerner/* * IcyTag. * * jicyshout : http://sourceforge.net/projects/jicyshout/ * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file.tag; /** * A tag parsed from an icecast tag. */ public class IcyTag extends MP3Tag implements StringableTag { /** Create a new tag, from the parsed name and (String) value. It looks like all Icecast tags are Strings (safe to assume this going forward?) */ public IcyTag(String name, String stringValue) { super(name, stringValue); } // so far as I know, all Icecast tags are strings public String getValueAsString() { return (String) getValue(); } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/MP3TagParseSupport.java0000644000175000017500000000406411451704772031025 0ustar twernertwerner/* * MP3TagParseSupport. * * jicyshout : http://sourceforge.net/projects/jicyshout/ * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file.tag; import java.util.ArrayList; /** */ public class MP3TagParseSupport extends Object { ArrayList tagParseListeners; /** trivial constructor, sets up listeners list. */ public MP3TagParseSupport() { super(); tagParseListeners = new ArrayList(); } /** Adds a TagParseListener to be notified when a stream parses MP3Tags. */ public void addTagParseListener(TagParseListener tpl) { tagParseListeners.add(tpl); } /** Removes a TagParseListener, so it won't be notified when a stream parses MP3Tags. */ public void removeTagParseListener(TagParseListener tpl) { tagParseListeners.add(tpl); } /** Fires the given event to all registered listeners */ public void fireTagParseEvent(TagParseEvent tpe) { for (int i = 0; i < tagParseListeners.size(); i++) { TagParseListener l = (TagParseListener) tagParseListeners.get(i); l.tagParsed(tpe); } } public void fireTagParsed(Object source, MP3Tag tag) { fireTagParseEvent(new TagParseEvent(source, tag)); } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/StringableTag.java0000644000175000017500000000254511451704772030132 0ustar twernertwerner/* * StringableTag. * * jicyshout : http://sourceforge.net/projects/jicyshout/ * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file.tag; /** Indicates that the value of a tag is a string, and provides a getValueAsString() method to get it. Appropriate for tags like artist, title, etc. */ public interface StringableTag { /** Return the value of this tag as a string. */ public String getValueAsString(); } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/TagParseListener.java0000644000175000017500000000263511451704772030620 0ustar twernertwerner/* * TagParseListener. * * jicyshout : http://sourceforge.net/projects/jicyshout/ * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file.tag; import java.util.EventListener; /** EventListener to be implemented by objects that want to get callbacks when MP3 tags are received. */ public interface TagParseListener extends EventListener { /** Called when a tag is found (parsed from the stream, received via UDP, etc.) */ public void tagParsed(TagParseEvent tpe); } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/IcyInputStream.java0000644000175000017500000003355711451704772030333 0ustar twernertwerner/* * IcyInputStream. * * jicyshout : http://sourceforge.net/projects/jicyshout/ * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file.tag; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLConnection; import java.util.HashMap; import java.util.StringTokenizer; /** An BufferedInputStream that parses Shoutcast's "icy" metadata from the stream. Gets headers at the beginning and if the "icy-metaint" tag is found, it parses and strips in-stream metadata.

The deal with metaint: Icy streams don't try to put tags between MP3 frames the way that ID3 does. Instead, it requires the client to strip metadata from the stream before it hits the decoder. You get an icy-metaint name/val in the beginning of the stream iff you sent "Icy-Metadata" with value "1" in the request headers (SimpleMP3DataSource does this if the "parseStreamMetadata" boolean is true). If this is the case then the value of icy-metaint is the amount of real data between metadata blocks. Each block begins with an int indicating how much metadata there is -- the block is this value times 16 (it can be, and often is, 0).

Originally thought that "icy" implied Icecast, but this is completely wrong -- real Icecast servers, found through www.icecast.net and typified by URLs with a trailing directory (like CalArts School of Music - http://65.165.174.100:8000/som) do not have the "ICY 200 OK" magic string or any of the CRLF-separated headers. Apparently, "icy" means "Shoutcast". Yep, that's weird. @author Chris Adamson, invalidname@mac.com */ public class IcyInputStream extends BufferedInputStream implements MP3MetadataParser { public static boolean DEBUG = false; MP3TagParseSupport tagParseSupport; /** inline tags are delimited by ';', also filter out null bytes */ protected static final String INLINE_TAG_SEPARATORS = ";\u0000"; /* looks like icy streams start start with ICY 200 OK\r\n then the tags are like icy-notice1:
This stream requires Winamp
\r\n icy-notice2:SHOUTcast Distributed Network Audio Server/win32 v1.8.2
\r\n icy-name:Core-upt Radio\r\n icy-genre:Punk Ska Emo\r\n icy-url:http://www.core-uptrecords.com\r\n icy-pub:1\r\n icy-metaint:8192\r\n icy-br:56\r\n \r\n (signifies end of headers) we only get icy-metaint if the http request that created this stream sent the header "icy-metadata:1" // in in-line metadata, we read a byte that tells us how many 16-byte blocks there are (presumably, we still use \r\n for the separator... the block is padded out with 0x00's that we can ignore) // when server is full/down/etc, we get the following for // one of the notice lines: icy-notice2:This server has reached its user limit
or icy-notice2:The resource requested is currently unavailable
*/ /** Tags that have been discovered in the stream. */ HashMap tags; /** Buffer for readCRLF line... note this limits lines to 1024 chars (I've read that WinAmp barfs at 128, so this is generous) */ protected byte[] crlfBuffer = new byte[1024]; /** value of the "metaint" tag, which tells us how many bytes of real data are between the metadata tags. if -1, this stream does not have metadata after the header. */ protected int metaint = -1; /** how many bytes of real data remain before the next block of metadata. Only meaningful if metaint != -1. */ protected int bytesUntilNextMetadata = -1; // TODO: comment for constructor /** Reads the initial headers of the stream and adds tags appropriatly. Gets set up to find, read, and strip blocks of in-line metadata if the icy-metaint header is found. */ public IcyInputStream(InputStream in) throws IOException { super(in); tags = new HashMap(); tagParseSupport = new MP3TagParseSupport(); // read the initial tags here, including the metaint // and set the counter for how far we read until // the next metadata block (if any). readInitialHeaders(); IcyTag metaIntTag = (IcyTag) getTag("icy-metaint"); if (DEBUG) System.out.println("METATAG:"+metaIntTag); if (metaIntTag != null) { String metaIntString = metaIntTag.getValueAsString(); try { metaint = Integer.parseInt(metaIntString.trim()); if (DEBUG) System.out.println("METAINT:"+metaint); bytesUntilNextMetadata = metaint; } catch (NumberFormatException nfe) { } } } /** * IcyInputStream constructor for know meta-interval (Icecast 2) * @param in * @param metaint * @throws IOException */ public IcyInputStream(InputStream in, String metaIntString) throws IOException { super(in); tags = new HashMap(); tagParseSupport = new MP3TagParseSupport(); try { metaint = Integer.parseInt(metaIntString.trim()); if (DEBUG) System.out.println("METAINT:"+metaint); bytesUntilNextMetadata = metaint; } catch (NumberFormatException nfe) { } } /** Assuming we're at the top of the stream, read lines one by one until we hit a completely blank \r\n. Parse the data as IcyTags. */ protected void readInitialHeaders() throws IOException { String line = null; while (!((line = readCRLFLine()).equals(""))) { int colonIndex = line.indexOf(':'); // does it have a ':' separator if (colonIndex == -1) continue; IcyTag tag = new IcyTag( line.substring(0, colonIndex), line.substring(colonIndex + 1)); //System.out.println(tag); addTag(tag); } } /** Read everything up to the next CRLF, return it as a String. */ protected String readCRLFLine() throws IOException { int i = 0; for (; i < crlfBuffer.length; i++) { byte aByte = (byte) read(); if (aByte == '\r') { // possible end of line byte anotherByte = (byte) read(); i++; // since we read again if (anotherByte == '\n') { break; // break out of while } else { // oops, not end of line - put these in array crlfBuffer[i - 1] = aByte; crlfBuffer[i] = anotherByte; } } else { // if not \r crlfBuffer[i] = aByte; } } // for // get the string from the byte[]. i is 1 too high because of // read-ahead in crlf block return new String(crlfBuffer, 0, i - 1); } /** Reads and returns a single byte. If the next byte is a metadata block, then that block is read, stripped, and parsed before reading and returning the first byte after the metadata block. */ public int read() throws IOException { if (bytesUntilNextMetadata > 0) { bytesUntilNextMetadata--; return super.read(); } else if (bytesUntilNextMetadata == 0) { // we need to read next metadata block readMetadata(); bytesUntilNextMetadata = metaint - 1; // -1 because we read byte on next line return super.read(); } else { // no metadata in this stream return super.read(); } } /** Reads a block of bytes. If the next byte is known to be a block of metadata, then that is read, parsed, and stripped, and then a block of bytes is read and returned. Otherwise, it may read up to but not into the next metadata block if bytesUntilNextMetadata < length */ public int read(byte[] buf, int offset, int length) throws IOException { // if not on metadata, do the usual read so long as we // don't read past metadata if (bytesUntilNextMetadata > 0) { int adjLength = Math.min(length, bytesUntilNextMetadata); int got = super.read(buf, offset, adjLength); bytesUntilNextMetadata -= got; return got; } else if (bytesUntilNextMetadata == 0) { // read/parse the metadata readMetadata(); // now as above, except that we reset // bytesUntilNextMetadata differently //int adjLength = Math.min(length, bytesUntilNextMetadata); //int got = super.read(buf, offset, adjLength); //bytesUntilNextMetadata = metaint - got; // Chop Fix - JavaZOOM (3 lines above seem buggy) bytesUntilNextMetadata = metaint; int adjLength = Math.min(length, bytesUntilNextMetadata); int got = super.read(buf, offset, adjLength); bytesUntilNextMetadata -= got; // End fix - JavaZOOM return got; } else { // not even reading metadata return super.read(buf, offset, length); } } /** trivial return read (buf, 0, buf.length) */ public int read(byte[] buf) throws IOException { return read(buf, 0, buf.length); } /** Read the next segment of metadata. The stream must be right on the segment, ie, the next byte to read is the metadata block count. The metadata is parsed and new tags are added with addTag(), which fires events */ protected void readMetadata() throws IOException { int blockCount = super.read(); if (DEBUG) System.out.println("BLOCKCOUNT:"+blockCount); // System.out.println ("blocks to read: " + blockCount); int byteCount = (blockCount * 16); // 16 bytes per block if (byteCount < 0) return; // WTF?! byte[] metadataBlock = new byte[byteCount]; int index = 0; // build an array of this metadata while (byteCount > 0) { int bytesRead = super.read(metadataBlock, index, byteCount); index += bytesRead; byteCount -= bytesRead; } // now parse it if (blockCount > 0) parseInlineIcyTags(metadataBlock); } // readMetadata /** Parse metadata from an in-stream "block" of bytes, add a tag for each one.

Hilariously, the inline data format is totally different than the top-of-stream header. For example, here's a block I saw on "Final Fantasy Radio":

	StreamTitle='Final Fantasy 8 - Nobuo Uematsu - Blue Fields';StreamUrl='';
	
In other words:
  1. Tags are delimited by semicolons
  2. Keys/values are delimited by equals-signs
  3. Values are wrapped in single-quotes
  4. Key names are in SentenceCase, not lowercase-dashed
*/ protected void parseInlineIcyTags(byte[] tagBlock) { String blockString = null; try { // Parse string as ISO-8859-1 even if meta-data are in US-ASCII. blockString = new String(tagBlock,"ISO-8859-1"); } catch(UnsupportedEncodingException e) { blockString = new String(tagBlock); } if (DEBUG) System.out.println("BLOCKSTR:"+blockString); StringTokenizer izer = new StringTokenizer(blockString, INLINE_TAG_SEPARATORS); int i = 0; while (izer.hasMoreTokens()) { String tagString = izer.nextToken(); int separatorIdx = tagString.indexOf('='); if (separatorIdx == -1) continue; // bogus tagString if no '=' // try to strip single-quotes around value, if present int valueStartIdx = (tagString.charAt(separatorIdx + 1) == '\'') ? separatorIdx + 2 : separatorIdx + 1; int valueEndIdx = (tagString.charAt(tagString.length() - 1)) == '\'' ? tagString.length() - 1 : tagString.length(); String name = tagString.substring(0, separatorIdx); String value = tagString.substring(valueStartIdx, valueEndIdx); // System.out.println (i++ + " " + name + ":" + value); IcyTag tag = new IcyTag(name, value); addTag(tag); } } /** adds the tag to the HashMap of tags we have encountered either in-stream or as headers, replacing any previous tag with this name. */ protected void addTag(IcyTag tag) { tags.put(tag.getName(), tag); // fire this as an event too tagParseSupport.fireTagParsed(this, tag); } /** Get the named tag from the HashMap of headers and in-line tags. Null if no such tag has been encountered. */ public MP3Tag getTag(String tagName) { return (MP3Tag) tags.get(tagName); } /** Get all tags (headers or in-stream) encountered thus far. */ public MP3Tag[] getTags() { return (MP3Tag[]) tags.values().toArray(new MP3Tag[0]); } /** Returns a HashMap of all headers and in-stream tags parsed so far. */ public HashMap getTagHash() { return tags; } /** Adds a TagParseListener to be notified when this stream parses MP3Tags. */ public void addTagParseListener(TagParseListener tpl) { tagParseSupport.addTagParseListener(tpl); } /** Removes a TagParseListener, so it won't be notified when this stream parses MP3Tags. */ public void removeTagParseListener(TagParseListener tpl) { tagParseSupport.removeTagParseListener(tpl); } /** Quickie unit-test. */ public static void main(String args[]) { byte[] chow = new byte[200]; if (args.length != 1) { //System.out.println("Usage: IcyInputStream "); return; } try { URL url = new URL(args[0]); URLConnection conn = url.openConnection(); conn.setRequestProperty("Icy-Metadata", "1"); IcyInputStream icy = new IcyInputStream( new BufferedInputStream(conn.getInputStream())); while (icy.available() > -1) { // icy.read(); icy.read(chow, 0, chow.length); } } catch (Exception e) { e.printStackTrace(); } } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/MP3MetadataParser.java0000644000175000017500000000406211451704772030615 0ustar twernertwerner/* * MP3MetadataParser. * * jicyshout : http://sourceforge.net/projects/jicyshout/ * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file.tag; /** An object that fires off TagParseEvents as they are parsed from a stream, ServerSocket, or other metadata source */ public interface MP3MetadataParser { /** Adds a TagParseListener to be notified when this object parses MP3Tags. */ public void addTagParseListener(TagParseListener tpl); /** Removes a TagParseListener, so it won't be notified when this object parses MP3Tags. */ public void removeTagParseListener(TagParseListener tpl); /** Get all tags (headers or in-stream) encountered thusfar. This is included in this otherwise Listener-like scheme because most standards are a mix of start-of-stream metadata tags (like the http headers or the stuff at the top of an ice stream) and inline data. Implementations should hang onto all tags they parse and provide them with this call. Callers should first use this call to get initial tags, then subscribe for events as the stream continues. */ public MP3Tag[] getTags(); } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/tag/TagParseEvent.java0000644000175000017500000000300311451704772030102 0ustar twernertwerner/* * TagParseEvent. * * jicyshout : http://sourceforge.net/projects/jicyshout/ * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file.tag; import java.util.EventObject; /** Event to indicate that an MP3 tag was received through some means (parsed in stream, received via UDP, whatever) and converted into an MP3Tag object. */ public class TagParseEvent extends EventObject { protected MP3Tag tag; public TagParseEvent(Object source, MP3Tag tag) { super(source); this.tag = tag; } /** Get the tag that was parsed. */ public MP3Tag getTag() { return tag; } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/MpegAudioFormat.java0000644000175000017500000000423611451704772027653 0ustar twernertwerner/* * MpegAudioFormat. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file; import java.util.Map; import javax.sound.sampled.AudioFormat; import org.tritonus.share.sampled.TAudioFormat; /** * @author JavaZOOM */ public class MpegAudioFormat extends TAudioFormat { /** * Constructor. * @param encoding * @param nFrequency * @param SampleSizeInBits * @param nChannels * @param FrameSize * @param FrameRate * @param isBigEndian * @param properties */ public MpegAudioFormat(AudioFormat.Encoding encoding, float nFrequency, int SampleSizeInBits, int nChannels, int FrameSize, float FrameRate, boolean isBigEndian, Map properties) { super(encoding, nFrequency, SampleSizeInBits, nChannels, FrameSize, FrameRate, isBigEndian, properties); } /** * MP3 audio format parameters. * Some parameters might be unavailable. So availability test is required before reading any parameter. * *
AudioFormat parameters. *
    *
  • bitrate [Integer], bitrate in bits per seconds, average bitrate for VBR enabled stream. *
  • vbr [Boolean], VBR flag. *
*/ public Map properties() { return super.properties(); } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/IcyListener.java0000644000175000017500000000566511451704772027071 0ustar twernertwerner/* * IcyListener. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file; import javazoom.spi.mpeg.sampled.file.tag.MP3Tag; import javazoom.spi.mpeg.sampled.file.tag.TagParseEvent; import javazoom.spi.mpeg.sampled.file.tag.TagParseListener; /** * This class (singleton) allow to be notified on shoutcast meta data * while playing the stream (such as song title). */ public class IcyListener implements TagParseListener { private static IcyListener instance = null; private MP3Tag lastTag = null; private String streamTitle = null; private String streamUrl = null; private IcyListener() { super(); } public static synchronized IcyListener getInstance() { if (instance == null) { instance = new IcyListener(); } return instance; } /* (non-Javadoc) * @see javazoom.spi.mpeg.sampled.file.tag.TagParseListener#tagParsed(javazoom.spi.mpeg.sampled.file.tag.TagParseEvent) */ public void tagParsed(TagParseEvent tpe) { lastTag = tpe.getTag(); String name = lastTag.getName(); if ((name != null) && (name.equalsIgnoreCase("streamtitle"))) { streamTitle = (String) lastTag.getValue(); } else if ((name != null) && (name.equalsIgnoreCase("streamurl"))) { streamUrl = (String) lastTag.getValue(); } } /** * @return */ public MP3Tag getLastTag() { return lastTag; } /** * @param tag */ public void setLastTag(MP3Tag tag) { lastTag = tag; } /** * @return */ public String getStreamTitle() { return streamTitle; } /** * @return */ public String getStreamUrl() { return streamUrl; } /** * @param string */ public void setStreamTitle(String string) { streamTitle = string; } /** * @param string */ public void setStreamUrl(String string) { streamUrl = string; } /** * Reset all properties. */ public void reset() { lastTag = null; streamTitle = null; streamUrl = null; } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/MpegAudioFileReader.java0000644000175000017500000010421211455024246030413 0ustar twernertwerner/* * MpegAudioFileReader. * * 10/10/05 : size computation bug fixed in parseID3v2Frames. * RIFF/MP3 header support added. * FLAC and MAC headers throw UnsupportedAudioFileException now. * "mp3.id3tag.publisher" (TPUB/TPB) added. * "mp3.id3tag.orchestra" (TPE2/TP2) added. * "mp3.id3tag.length" (TLEN/TLE) added. * * 08/15/05 : parseID3v2Frames improved. * * 12/31/04 : mp3spi.weak system property added to skip controls. * * 11/29/04 : ID3v2.2, v2.3 & v2.4 support improved. * "mp3.id3tag.composer" (TCOM/TCM) added * "mp3.id3tag.grouping" (TIT1/TT1) added * "mp3.id3tag.disc" (TPA/TPOS) added * "mp3.id3tag.encoded" (TEN/TENC) added * "mp3.id3tag.v2.version" added * * 11/28/04 : String encoding bug fix in chopSubstring method. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file; import java.io.BufferedInputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PushbackInputStream; import java.io.UnsupportedEncodingException; import java.net.URL; import java.net.URLConnection; import java.security.AccessControlException; import java.util.HashMap; import javax.sound.sampled.AudioFileFormat; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; import javazoom.jl.decoder.Bitstream; import javazoom.jl.decoder.Header; import javazoom.spi.mpeg.sampled.file.tag.IcyInputStream; import javazoom.spi.mpeg.sampled.file.tag.MP3Tag; import org.tritonus.share.TDebug; import org.tritonus.share.sampled.file.TAudioFileReader; /** * This class implements AudioFileReader for MP3 SPI. */ public class MpegAudioFileReader extends TAudioFileReader { public static final String VERSION = "MP3SPI 1.9.5"; private final int SYNC = 0xFFE00000; private String weak = null; private final AudioFormat.Encoding[][] sm_aEncodings = { { MpegEncoding.MPEG2L1, MpegEncoding.MPEG2L2, MpegEncoding.MPEG2L3 }, { MpegEncoding.MPEG1L1, MpegEncoding.MPEG1L2, MpegEncoding.MPEG1L3 }, { MpegEncoding.MPEG2DOT5L1, MpegEncoding.MPEG2DOT5L2, MpegEncoding.MPEG2DOT5L3 }, }; public static int INITAL_READ_LENGTH = 128000*32; private static int MARK_LIMIT = INITAL_READ_LENGTH + 1; static { String s = System.getProperty("marklimit"); if (s != null) { try { INITAL_READ_LENGTH = Integer.parseInt(s); MARK_LIMIT = INITAL_READ_LENGTH + 1; } catch (NumberFormatException e) { e.printStackTrace(); } } } private static final String[] id3v1genres = { "Blues" , "Classic Rock" , "Country" , "Dance" , "Disco" , "Funk" , "Grunge" , "Hip-Hop" , "Jazz" , "Metal" , "New Age" , "Oldies" , "Other" , "Pop" , "R&B" , "Rap" , "Reggae" , "Rock" , "Techno" , "Industrial" , "Alternative" , "Ska" , "Death Metal" , "Pranks" , "Soundtrack" , "Euro-Techno" , "Ambient" , "Trip-Hop" , "Vocal" , "Jazz+Funk" , "Fusion" , "Trance" , "Classical" , "Instrumental" , "Acid" , "House" , "Game" , "Sound Clip" , "Gospel" , "Noise" , "AlternRock" , "Bass" , "Soul" , "Punk" , "Space" , "Meditative" , "Instrumental Pop" , "Instrumental Rock" , "Ethnic" , "Gothic" , "Darkwave" , "Techno-Industrial" , "Electronic" , "Pop-Folk" , "Eurodance" , "Dream" , "Southern Rock" , "Comedy" , "Cult" , "Gangsta" , "Top 40" , "Christian Rap" , "Pop/Funk" , "Jungle" , "Native American" , "Cabaret" , "New Wave" , "Psychadelic" , "Rave" , "Showtunes" , "Trailer" , "Lo-Fi" , "Tribal" , "Acid Punk" , "Acid Jazz" , "Polka" , "Retro" , "Musical" , "Rock & Roll" , "Hard Rock" , "Folk" , "Folk-Rock" , "National Folk" , "Swing" , "Fast Fusion" , "Bebob" , "Latin" , "Revival" , "Celtic" , "Bluegrass" , "Avantgarde" , "Gothic Rock" , "Progressive Rock" , "Psychedelic Rock" , "Symphonic Rock" , "Slow Rock" , "Big Band" , "Chorus" , "Easy Listening" , "Acoustic" , "Humour" , "Speech" , "Chanson" , "Opera" , "Chamber Music" , "Sonata" , "Symphony" , "Booty Brass" , "Primus" , "Porn Groove" , "Satire" , "Slow Jam" , "Club" , "Tango" , "Samba" , "Folklore" , "Ballad" , "Power Ballad" , "Rhythmic Soul" , "Freestyle" , "Duet" , "Punk Rock" , "Drum Solo" , "A Capela" , "Euro-House" , "Dance Hall" , "Goa" , "Drum & Bass" , "Club-House" , "Hardcore" , "Terror" , "Indie" , "BritPop" , "Negerpunk" , "Polsk Punk" , "Beat" , "Christian Gangsta Rap" , "Heavy Metal" , "Black Metal" , "Crossover" , "Contemporary Christian" , "Christian Rock" , "Merengue" , "Salsa" , "Thrash Metal" , "Anime" , "JPop" , "SynthPop" }; public MpegAudioFileReader() { super(MARK_LIMIT, true); if (TDebug.TraceAudioFileReader) TDebug.out(VERSION); try { weak = System.getProperty("mp3spi.weak"); } catch (AccessControlException e) { } } /** * Returns AudioFileFormat from File. */ public AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException { return super.getAudioFileFormat(file); } /** * Returns AudioFileFormat from URL. */ public AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException { if (TDebug.TraceAudioFileReader) { TDebug.out("MpegAudioFileReader.getAudioFileFormat(URL): begin"); } long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED; URLConnection conn = url.openConnection(); // Tell shoucast server (if any) that SPI support shoutcast stream. conn.setRequestProperty("Icy-Metadata", "1"); InputStream inputStream = conn.getInputStream(); AudioFileFormat audioFileFormat = null; try { audioFileFormat = getAudioFileFormat(inputStream, lFileLengthInBytes); } finally { inputStream.close(); } if (TDebug.TraceAudioFileReader) { TDebug.out("MpegAudioFileReader.getAudioFileFormat(URL): end"); } return audioFileFormat; } /** * Returns AudioFileFormat from inputstream and medialength. */ public AudioFileFormat getAudioFileFormat(InputStream inputStream, long mediaLength) throws UnsupportedAudioFileException, IOException { if (TDebug.TraceAudioFileReader) TDebug.out(">MpegAudioFileReader.getAudioFileFormat(InputStream inputStream, long mediaLength): begin"); HashMap aff_properties = new HashMap(); HashMap af_properties = new HashMap(); int mLength = (int) mediaLength; int size = inputStream.available(); PushbackInputStream pis = new PushbackInputStream(inputStream, MARK_LIMIT); byte head[] = new byte[22]; pis.read(head); if (TDebug.TraceAudioFileReader) { TDebug.out("InputStream : " + inputStream + " =>" + new String(head)); } // Check for WAV, AU, and AIFF, Ogg Vorbis, Flac, MAC file formats. // Next check for Shoutcast (supported) and OGG (unsupported) streams. if ((head[0] == 'R') && (head[1] == 'I') && (head[2] == 'F') && (head[3] == 'F') && (head[8] == 'W') && (head[9] == 'A') && (head[10] == 'V') && (head[11] == 'E')) { if (TDebug.TraceAudioFileReader) TDebug.out("RIFF/WAV stream found"); int isPCM = ((head[21]<<8)&0x0000FF00) | ((head[20])&0x00000FF); if (weak == null) { if (isPCM == 1) throw new UnsupportedAudioFileException("WAV PCM stream found"); } } else if ((head[0] == '.') && (head[1] == 's') && (head[2] == 'n') && (head[3] == 'd')) { if (TDebug.TraceAudioFileReader) TDebug.out("AU stream found"); if (weak == null) throw new UnsupportedAudioFileException("AU stream found"); } else if ((head[0] == 'F') && (head[1] == 'O') && (head[2] == 'R') && (head[3] == 'M') && (head[8] == 'A') && (head[9] == 'I') && (head[10] == 'F') && (head[11] == 'F')) { if (TDebug.TraceAudioFileReader) TDebug.out("AIFF stream found"); if (weak == null) throw new UnsupportedAudioFileException("AIFF stream found"); } else if (((head[0] == 'M') | (head[0] == 'm')) && ((head[1] == 'A') | (head[1] == 'a')) && ((head[2] == 'C') | (head[2] == 'c'))) { if (TDebug.TraceAudioFileReader) TDebug.out("APE stream found"); if (weak == null) throw new UnsupportedAudioFileException("APE stream found"); } else if (((head[0] == 'F') | (head[0] == 'f')) && ((head[1] == 'L') | (head[1] == 'l')) && ((head[2] == 'A') | (head[2] == 'a')) && ((head[3] == 'C') | (head[3] == 'c'))) { if (TDebug.TraceAudioFileReader) TDebug.out("FLAC stream found"); if (weak == null) throw new UnsupportedAudioFileException("FLAC stream found"); } // Shoutcast stream ? else if (((head[0] == 'I') | (head[0] == 'i')) && ((head[1] == 'C') | (head[1] == 'c')) && ((head[2] == 'Y') | (head[2] == 'y'))) { pis.unread(head); // Load shoutcast meta data. loadShoutcastInfo(pis, aff_properties); } // Ogg stream ? else if (((head[0] == 'O') | (head[0] == 'o')) && ((head[1] == 'G') | (head[1] == 'g')) && ((head[2] == 'G') | (head[2] == 'g'))) { if (TDebug.TraceAudioFileReader) TDebug.out("Ogg stream found"); if (weak == null) throw new UnsupportedAudioFileException("Ogg stream found"); } // No, so pushback. else { pis.unread(head); } // MPEG header info. int nVersion = AudioSystem.NOT_SPECIFIED; int nLayer = AudioSystem.NOT_SPECIFIED; int nSFIndex = AudioSystem.NOT_SPECIFIED; int nMode = AudioSystem.NOT_SPECIFIED; int FrameSize = AudioSystem.NOT_SPECIFIED; int nFrameSize = AudioSystem.NOT_SPECIFIED; int nFrequency = AudioSystem.NOT_SPECIFIED; int nTotalFrames = AudioSystem.NOT_SPECIFIED; float FrameRate = AudioSystem.NOT_SPECIFIED; int BitRate = AudioSystem.NOT_SPECIFIED; int nChannels = AudioSystem.NOT_SPECIFIED; int nHeader = AudioSystem.NOT_SPECIFIED; int nTotalMS = AudioSystem.NOT_SPECIFIED; boolean nVBR = false; AudioFormat.Encoding encoding = null; try { Bitstream m_bitstream = new Bitstream(pis); int streamPos = m_bitstream.header_pos(); aff_properties.put("mp3.header.pos", new Integer(streamPos)); Header m_header = m_bitstream.readFrame(); // nVersion = 0 => MPEG2-LSF (Including MPEG2.5), nVersion = 1 => MPEG1 nVersion = m_header.version(); if (nVersion == 2) aff_properties.put("mp3.version.mpeg", Float.toString(2.5f)); else aff_properties.put("mp3.version.mpeg", Integer.toString(2 - nVersion)); // nLayer = 1,2,3 nLayer = m_header.layer(); aff_properties.put("mp3.version.layer", Integer.toString(nLayer)); nSFIndex = m_header.sample_frequency(); nMode = m_header.mode(); aff_properties.put("mp3.mode", new Integer(nMode)); nChannels = nMode == 3 ? 1 : 2; aff_properties.put("mp3.channels", new Integer(nChannels)); nVBR = m_header.vbr(); af_properties.put("vbr", new Boolean(nVBR)); aff_properties.put("mp3.vbr", new Boolean(nVBR)); aff_properties.put("mp3.vbr.scale", new Integer(m_header.vbr_scale())); FrameSize = m_header.calculate_framesize(); aff_properties.put("mp3.framesize.bytes", new Integer(FrameSize)); if (FrameSize < 0) throw new UnsupportedAudioFileException("Invalid FrameSize : " + FrameSize); nFrequency = m_header.frequency(); aff_properties.put("mp3.frequency.hz", new Integer(nFrequency)); FrameRate = (float) ((1.0 / (m_header.ms_per_frame())) * 1000.0); aff_properties.put("mp3.framerate.fps", new Float(FrameRate)); if (FrameRate < 0) throw new UnsupportedAudioFileException("Invalid FrameRate : " + FrameRate); // Remove heading tag length from real stream length. int tmpLength = mLength; if ((streamPos > 0) && (mLength != AudioSystem.NOT_SPECIFIED) && (streamPos < mLength)) tmpLength = tmpLength - streamPos; if (mLength != AudioSystem.NOT_SPECIFIED) { aff_properties.put("mp3.length.bytes", new Integer(mLength)); nTotalFrames = m_header.max_number_of_frames(tmpLength); aff_properties.put("mp3.length.frames", new Integer(nTotalFrames)); } BitRate = m_header.bitrate(); af_properties.put("bitrate", new Integer(BitRate)); aff_properties.put("mp3.bitrate.nominal.bps", new Integer(BitRate)); nHeader = m_header.getSyncHeader(); encoding = sm_aEncodings[nVersion][nLayer - 1]; aff_properties.put("mp3.version.encoding", encoding.toString()); if (mLength != AudioSystem.NOT_SPECIFIED) { nTotalMS = Math.round(m_header.total_ms(tmpLength)); aff_properties.put("duration", new Long((long) nTotalMS * 1000L)); } aff_properties.put("mp3.copyright", new Boolean(m_header.copyright())); aff_properties.put("mp3.original", new Boolean(m_header.original())); aff_properties.put("mp3.crc", new Boolean(m_header.checksums())); aff_properties.put("mp3.padding", new Boolean(m_header.padding())); InputStream id3v2 = m_bitstream.getRawID3v2(); if (id3v2 != null) { aff_properties.put("mp3.id3tag.v2", id3v2); parseID3v2Frames(id3v2, aff_properties); } if (TDebug.TraceAudioFileReader) TDebug.out(m_header.toString()); } catch (Exception e) { if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream:" + e.getMessage()); throw new UnsupportedAudioFileException("not a MPEG stream:" + e.getMessage()); } // Deeper checks ? int cVersion = (nHeader >> 19) & 0x3; if (cVersion == 1) { if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream: wrong version"); throw new UnsupportedAudioFileException("not a MPEG stream: wrong version"); } int cSFIndex = (nHeader >> 10) & 0x3; if (cSFIndex == 3) { if (TDebug.TraceAudioFileReader) TDebug.out("not a MPEG stream: wrong sampling rate"); throw new UnsupportedAudioFileException("not a MPEG stream: wrong sampling rate"); } // Look up for ID3v1 tag if ((size == mediaLength) && (mediaLength != AudioSystem.NOT_SPECIFIED)) { FileInputStream fis = (FileInputStream) inputStream; byte[] id3v1 = new byte[128]; long bytesSkipped = fis.skip(inputStream.available() - id3v1.length); int read = fis.read(id3v1, 0, id3v1.length); if ((id3v1[0] == 'T') && (id3v1[1] == 'A') && (id3v1[2] == 'G')) { parseID3v1Frames(id3v1, aff_properties); } } AudioFormat format = new MpegAudioFormat(encoding, (float) nFrequency, AudioSystem.NOT_SPECIFIED // SampleSizeInBits - The size of a sample , nChannels // Channels - The number of channels , -1 // The number of bytes in each frame , FrameRate // FrameRate - The number of frames played or recorded per second , true, af_properties); return new MpegAudioFileFormat(MpegFileFormatType.MP3, format, nTotalFrames, mLength, aff_properties); } /** * Returns AudioInputStream from file. */ public AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException { if (TDebug.TraceAudioFileReader) TDebug.out("getAudioInputStream(File file)"); InputStream inputStream = new FileInputStream(file); try { return getAudioInputStream(inputStream); } catch (UnsupportedAudioFileException e) { if (inputStream != null) inputStream.close(); throw e; } catch (IOException e) { if (inputStream != null) inputStream.close(); throw e; } } /** * Returns AudioInputStream from url. */ public AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException { if (TDebug.TraceAudioFileReader) { TDebug.out("MpegAudioFileReader.getAudioInputStream(URL): begin"); } long lFileLengthInBytes = AudioSystem.NOT_SPECIFIED; URLConnection conn = url.openConnection(); // Tell shoucast server (if any) that SPI support shoutcast stream. boolean isShout = false; int toRead = 4; byte[] head = new byte[toRead]; conn.setRequestProperty("Icy-Metadata", "1"); BufferedInputStream bInputStream = new BufferedInputStream(conn.getInputStream()); bInputStream.mark(toRead); int read = bInputStream.read(head, 0, toRead); if ((read > 2) && (((head[0] == 'I') | (head[0] == 'i')) && ((head[1] == 'C') | (head[1] == 'c')) && ((head[2] == 'Y') | (head[2] == 'y')))) isShout = true; bInputStream.reset(); InputStream inputStream = null; // Is is a shoutcast server ? if (isShout == true) { // Yes IcyInputStream icyStream = new IcyInputStream(bInputStream); icyStream.addTagParseListener(IcyListener.getInstance()); inputStream = icyStream; } else { // No, is Icecast 2 ? String metaint = conn.getHeaderField("icy-metaint"); if (metaint != null) { // Yes, it might be icecast 2 mp3 stream. IcyInputStream icyStream = new IcyInputStream(bInputStream, metaint); icyStream.addTagParseListener(IcyListener.getInstance()); inputStream = icyStream; } else { // No inputStream = bInputStream; } } AudioInputStream audioInputStream = null; try { audioInputStream = getAudioInputStream(inputStream, lFileLengthInBytes); } catch (UnsupportedAudioFileException e) { inputStream.close(); throw e; } catch (IOException e) { inputStream.close(); throw e; } if (TDebug.TraceAudioFileReader) { TDebug.out("MpegAudioFileReader.getAudioInputStream(URL): end"); } return audioInputStream; } /** * Return the AudioInputStream from the given InputStream. */ public AudioInputStream getAudioInputStream(InputStream inputStream) throws UnsupportedAudioFileException, IOException { if (TDebug.TraceAudioFileReader) TDebug.out("MpegAudioFileReader.getAudioInputStream(InputStream inputStream)"); if (!inputStream.markSupported()) inputStream = new BufferedInputStream(inputStream); return super.getAudioInputStream(inputStream); } /** * Parser ID3v1 frames * @param frames * @param props */ protected void parseID3v1Frames(byte[] frames, HashMap props) { if (TDebug.TraceAudioFileReader) TDebug.out("Parsing ID3v1"); String tag = null; try { tag = new String(frames, 0, frames.length, "ISO-8859-1"); } catch (UnsupportedEncodingException e) { tag = new String(frames, 0, frames.length); if (TDebug.TraceAudioFileReader) TDebug.out("Cannot use ISO-8859-1"); } if (TDebug.TraceAudioFileReader) TDebug.out("ID3v1 frame dump='" + tag + "'"); int start = 3; String titlev1 = chopSubstring(tag, start, start += 30); String titlev2 = (String) props.get("title"); if (((titlev2 == null) || (titlev2.length() == 0)) && (titlev1 != null)) props.put("title", titlev1); String artistv1 = chopSubstring(tag, start, start += 30); String artistv2 = (String) props.get("author"); if (((artistv2 == null) || (artistv2.length() == 0)) && (artistv1 != null)) props.put("author", artistv1); String albumv1 = chopSubstring(tag, start, start += 30); String albumv2 = (String) props.get("album"); if (((albumv2 == null) || (albumv2.length() == 0)) && (albumv1 != null)) props.put("album", albumv1); String yearv1 = chopSubstring(tag, start, start += 4); String yearv2 = (String) props.get("year"); if (((yearv2 == null) || (yearv2.length() == 0)) && (yearv1 != null)) props.put("date", yearv1); String commentv1 = chopSubstring(tag, start, start += 28); String commentv2 = (String) props.get("comment"); if (((commentv2 == null) || (commentv2.length() == 0)) && (commentv1 != null)) props.put("comment", commentv1); String trackv1 = "" + ((int) (frames[126] & 0xff)); String trackv2 = (String) props.get("mp3.id3tag.track"); if (((trackv2 == null) || (trackv2.length() == 0)) && (trackv1 != null)) props.put("mp3.id3tag.track", trackv1); int genrev1 = (int) (frames[127] & 0xff); if ((genrev1 >= 0) && (genrev1 < id3v1genres.length)) { String genrev2 = (String) props.get("mp3.id3tag.genre"); if (((genrev2 == null) || (genrev2.length() == 0))) props.put("mp3.id3tag.genre", id3v1genres[genrev1]); } if (TDebug.TraceAudioFileReader) TDebug.out("ID3v1 parsed"); } /** * Extract * @param s * @param start * @param end * @return */ private String chopSubstring(String s, int start, int end) { String str = null; // 11/28/04 - String encoding bug fix. try { str = s.substring(start, end); int loc = str.indexOf('\0'); if (loc != -1) str = str.substring(0, loc); } catch (StringIndexOutOfBoundsException e) { // Skip encoding issues. if (TDebug.TraceAudioFileReader) TDebug.out("Cannot chopSubString " + e.getMessage()); } return str; } /** * Parse ID3v2 frames to add album (TALB), title (TIT2), date (TYER), author (TPE1), copyright (TCOP), comment (COMM) ... * @param frames * @param props */ protected void parseID3v2Frames(InputStream frames, HashMap props) { if (TDebug.TraceAudioFileReader) TDebug.out("Parsing ID3v2"); byte[] bframes = null; int size = -1; try { size = frames.available(); bframes = new byte[size]; frames.mark(size); frames.read(bframes); frames.reset(); } catch (IOException e) { if (TDebug.TraceAudioFileReader) TDebug.out("Cannot parse ID3v2 :" + e.getMessage()); } if (!"ID3".equals(new String(bframes, 0, 3))) { TDebug.out("No ID3v2 header found!"); return; } int v2version = (int) (bframes[3] & 0xFF); props.put("mp3.id3tag.v2.version", String.valueOf(v2version)); if (v2version < 2 || v2version > 4) { TDebug.out("Unsupported ID3v2 version " + v2version + "!"); return; } try { if (TDebug.TraceAudioFileReader) TDebug.out("ID3v2 frame dump='" + new String(bframes, 0, bframes.length) + "'"); /* ID3 tags : http://www.unixgods.org/~tilo/ID3/docs/ID3_comparison.html */ String value = null; for (int i = 10; i < bframes.length && bframes[i] > 0; i += size) { if (v2version == 3 || v2version == 4) { // ID3v2.3 & ID3v2.4 String code = new String(bframes, i, 4); size = (int) ((bframes[i + 4] << 24) & 0xFF000000 | (bframes[i + 5] << 16) & 0x00FF0000 | (bframes[i + 6] << 8) & 0x0000FF00 | (bframes[i + 7]) & 0x000000FF); i += 10; if ((code.equals("TALB")) || (code.equals("TIT2")) || (code.equals("TYER")) || (code.equals("TPE1")) || (code.equals("TCOP")) || (code.equals("COMM")) || (code.equals("TCON")) || (code.equals("TRCK")) || (code.equals("TPOS")) || (code.equals("TDRC")) || (code.equals("TCOM")) || (code.equals("TIT1")) || (code.equals("TENC")) || (code.equals("TPUB")) || (code.equals("TPE2")) || (code.equals("TLEN")) ) { if (code.equals("COMM")) value = parseText(bframes, i, size, 5); else value = parseText(bframes, i, size, 1); if ((value != null) && (value.length() > 0)) { if (code.equals("TALB")) props.put("album", value); else if (code.equals("TIT2")) props.put("title", value); else if (code.equals("TYER")) props.put("date", value); // ID3v2.4 date fix. else if (code.equals("TDRC")) props.put("date", value); else if (code.equals("TPE1")) props.put("author", value); else if (code.equals("TCOP")) props.put("copyright", value); else if (code.equals("COMM")) props.put("comment", value); else if (code.equals("TCON")) props.put("mp3.id3tag.genre", value); else if (code.equals("TRCK")) props.put("mp3.id3tag.track", value); else if (code.equals("TPOS")) props.put("mp3.id3tag.disc", value); else if (code.equals("TCOM")) props.put("mp3.id3tag.composer", value); else if (code.equals("TIT1")) props.put("mp3.id3tag.grouping", value); else if (code.equals("TENC")) props.put("mp3.id3tag.encoded", value); else if (code.equals("TPUB")) props.put("mp3.id3tag.publisher", value); else if (code.equals("TPE2")) props.put("mp3.id3tag.orchestra", value); else if (code.equals("TLEN")) props.put("mp3.id3tag.length", value); } } } else { // ID3v2.2 String scode = new String(bframes, i, 3); size = (int) (0x00000000) + (bframes[i + 3] << 16) + (bframes[i + 4] << 8) + (bframes[i + 5]); i += 6; if ((scode.equals("TAL")) || (scode.equals("TT2")) || (scode.equals("TP1")) || (scode.equals("TYE")) || (scode.equals("TRK")) || (scode.equals("TPA")) || (scode.equals("TCR")) || (scode.equals("TCO")) || (scode.equals("TCM")) || (scode.equals("COM")) || (scode.equals("TT1")) || (scode.equals("TEN")) || (scode.equals("TPB")) || (scode.equals("TP2")) || (scode.equals("TLE")) ) { if (scode.equals("COM")) value = parseText(bframes, i, size, 5); else value = parseText(bframes, i, size, 1); if ((value != null) && (value.length() > 0)) { if (scode.equals("TAL")) props.put("album", value); else if (scode.equals("TT2")) props.put("title", value); else if (scode.equals("TYE")) props.put("date", value); else if (scode.equals("TP1")) props.put("author", value); else if (scode.equals("TCR")) props.put("copyright", value); else if (scode.equals("COM")) props.put("comment", value); else if (scode.equals("TCO")) props.put("mp3.id3tag.genre", value); else if (scode.equals("TRK")) props.put("mp3.id3tag.track", value); else if (scode.equals("TPA")) props.put("mp3.id3tag.disc", value); else if (scode.equals("TCM")) props.put("mp3.id3tag.composer", value); else if (scode.equals("TT1")) props.put("mp3.id3tag.grouping", value); else if (scode.equals("TEN")) props.put("mp3.id3tag.encoded", value); else if (scode.equals("TPB")) props.put("mp3.id3tag.publisher", value); else if (scode.equals("TP2")) props.put("mp3.id3tag.orchestra", value); else if (scode.equals("TLE")) props.put("mp3.id3tag.length", value); } } } } } catch (RuntimeException e) { // Ignore all parsing errors. if (TDebug.TraceAudioFileReader) TDebug.out("Cannot parse ID3v2 :" + e.getMessage()); } if (TDebug.TraceAudioFileReader) TDebug.out("ID3v2 parsed"); } /** * Parse Text Frames. * * @param bframes * @param offset * @param size * @param skip * @return */ protected String parseText(byte[] bframes, int offset, int size, int skip) { String value = null; try { String[] ENC_TYPES = { "ISO-8859-1", "UTF16", "UTF-16BE", "UTF-8" }; value = new String(bframes, offset + skip, size - skip, ENC_TYPES[bframes[offset]]); value = chopSubstring(value, 0, value.length()); } catch (UnsupportedEncodingException e) { if (TDebug.TraceAudioFileReader) TDebug.out("ID3v2 Encoding error :" + e.getMessage()); } return value; } /** * Load shoutcast (ICY) info. * * @param input * @param props * @throws IOException */ protected void loadShoutcastInfo(InputStream input, HashMap props) throws IOException { IcyInputStream icy = new IcyInputStream(new BufferedInputStream(input)); HashMap metadata = icy.getTagHash(); MP3Tag titleMP3Tag = icy.getTag("icy-name"); if (titleMP3Tag != null) props.put("title", ((String) titleMP3Tag.getValue()).trim()); MP3Tag[] meta = icy.getTags(); if (meta != null) { StringBuffer metaStr = new StringBuffer(); for (int i = 0; i < meta.length; i++) { String key = meta[i].getName(); String value = ((String) icy.getTag(key).getValue()).trim(); props.put("mp3.shoutcast.metadata." + key, value); } } } }libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/file/MpegAudioFileFormat.java0000644000175000017500000001135711451704772030455 0ustar twernertwerner/* * MpegAudioFileFormat. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.file; import java.util.Map; import javax.sound.sampled.AudioFormat; import org.tritonus.share.sampled.file.TAudioFileFormat; /** * @author JavaZOOM */ public class MpegAudioFileFormat extends TAudioFileFormat { /** * Contructor. * @param type * @param audioFormat * @param nLengthInFrames * @param nLengthInBytes */ public MpegAudioFileFormat(Type type, AudioFormat audioFormat, int nLengthInFrames, int nLengthInBytes, Map properties) { super(type, audioFormat, nLengthInFrames, nLengthInBytes, properties); } /** * MP3 audio file format parameters. * Some parameters might be unavailable. So availability test is required before reading any parameter. * *
AudioFileFormat parameters. *
    *
  • duration [Long], duration in microseconds. *
  • title [String], Title of the stream. *
  • author [String], Name of the artist of the stream. *
  • album [String], Name of the album of the stream. *
  • date [String], The date (year) of the recording or release of the stream. *
  • copyright [String], Copyright message of the stream. *
  • comment [String], Comment of the stream. *
*
MP3 parameters. *
    *
  • mp3.version.mpeg [String], mpeg version : 1,2 or 2.5 *
  • mp3.version.layer [String], layer version 1, 2 or 3 *
  • mp3.version.encoding [String], mpeg encoding : MPEG1, MPEG2-LSF, MPEG2.5-LSF *
  • mp3.channels [Integer], number of channels 1 : mono, 2 : stereo. *
  • mp3.frequency.hz [Integer], sampling rate in hz. *
  • mp3.bitrate.nominal.bps [Integer], nominal bitrate in bps. *
  • mp3.length.bytes [Integer], length in bytes. *
  • mp3.length.frames [Integer], length in frames. *
  • mp3.framesize.bytes [Integer], framesize of the first frame. framesize is not constant for VBR streams. *
  • mp3.framerate.fps [Float], framerate in frames per seconds. *
  • mp3.header.pos [Integer], position of first audio header (or ID3v2 size). *
  • mp3.vbr [Boolean], vbr flag. *
  • mp3.vbr.scale [Integer], vbr scale. *
  • mp3.crc [Boolean], crc flag. *
  • mp3.original [Boolean], original flag. *
  • mp3.copyright [Boolean], copyright flag. *
  • mp3.padding [Boolean], padding flag. *
  • mp3.mode [Integer], mode 0:STEREO 1:JOINT_STEREO 2:DUAL_CHANNEL 3:SINGLE_CHANNEL *
  • mp3.id3tag.genre [String], ID3 tag (v1 or v2) genre. *
  • mp3.id3tag.track [String], ID3 tag (v1 or v2) track info. *
  • mp3.id3tag.encoded [String], ID3 tag v2 encoded by info. *
  • mp3.id3tag.composer [String], ID3 tag v2 composer info. *
  • mp3.id3tag.grouping [String], ID3 tag v2 grouping info. *
  • mp3.id3tag.disc [String], ID3 tag v2 track info. *
  • mp3.id3tag.publisher [String], ID3 tag v2 publisher info. *
  • mp3.id3tag.orchestra [String], ID3 tag v2 orchestra info. *
  • mp3.id3tag.length [String], ID3 tag v2 file length in seconds. *
  • mp3.id3tag.v2 [InputStream], ID3v2 frames. *
  • mp3.id3tag.v2.version [String], ID3v2 major version (2=v2.2.0, 3=v2.3.0, 4=v2.4.0). *
  • mp3.shoutcast.metadata.key [String], Shoutcast meta key with matching value. *
    For instance : *
    mp3.shoutcast.metadata.icy-irc=#shoutcast *
    mp3.shoutcast.metadata.icy-metaint=8192 *
    mp3.shoutcast.metadata.icy-genre=Trance Techno Dance *
    mp3.shoutcast.metadata.icy-url=http://www.di.fm *
    and so on ... *
*/ public Map properties() { return super.properties(); } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/convert/0000755000175000017500000000000011455024352024512 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/convert/DecodedMpegAudioInputStream.java0000644000175000017500000002415711455021254032702 0ustar twernertwerner/* * DecodedMpegAudioInputStream. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *------------------------------------------------------------------------ */ package javazoom.spi.mpeg.sampled.convert; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; import java.util.Map; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javazoom.jl.decoder.Bitstream; import javazoom.jl.decoder.BitstreamException; import javazoom.jl.decoder.Decoder; import javazoom.jl.decoder.DecoderException; import javazoom.jl.decoder.Equalizer; import javazoom.jl.decoder.Header; import javazoom.jl.decoder.Obuffer; import javazoom.spi.PropertiesContainer; import javazoom.spi.mpeg.sampled.file.IcyListener; import javazoom.spi.mpeg.sampled.file.tag.TagParseEvent; import javazoom.spi.mpeg.sampled.file.tag.TagParseListener; import org.tritonus.share.TDebug; import org.tritonus.share.sampled.convert.TAsynchronousFilteredAudioInputStream; /** * Main decoder. */ public class DecodedMpegAudioInputStream extends TAsynchronousFilteredAudioInputStream implements PropertiesContainer, TagParseListener { private InputStream m_encodedStream; private Bitstream m_bitstream; private Decoder m_decoder; private Equalizer m_equalizer; private float[] m_equalizer_values; private Header m_header; private DMAISObuffer m_oBuffer; // Bytes info. private long byteslength = -1; private long currentByte = 0; // Frame info. private int frameslength = -1; private long currentFrame = 0; private int currentFramesize = 0; private int currentBitrate = -1; // Time info. private long currentMicrosecond = 0; // Shoutcast stream info private IcyListener shoutlst = null; private HashMap properties = null; public DecodedMpegAudioInputStream(AudioFormat outputFormat, AudioInputStream inputStream) { super(outputFormat, -1); if (TDebug.TraceAudioConverter) { TDebug.out(">DecodedMpegAudioInputStream(AudioFormat outputFormat, AudioInputStream inputStream)"); } try { // Try to find out inputstream length to allow skip. byteslength = inputStream.available(); } catch (IOException e) { TDebug.out("DecodedMpegAudioInputStream : Cannot run inputStream.available() : "+e.getMessage()); byteslength = -1; } m_encodedStream = inputStream; shoutlst = IcyListener.getInstance(); shoutlst.reset(); m_bitstream = new Bitstream(inputStream); m_decoder = new Decoder(null); m_equalizer = new Equalizer(); m_equalizer_values = new float[32]; for (int b=0;b 0)) frameslength = m_header.max_number_of_frames((int)byteslength); } catch (BitstreamException e) { TDebug.out("DecodedMpegAudioInputStream : Cannot read first frame : "+e.getMessage()); byteslength = -1; } properties = new HashMap(); } /** * Return dynamic properties. * *
    *
  • mp3.frame [Long], current frame position. *
  • mp3.frame.bitrate [Integer], bitrate of the current frame. *
  • mp3.frame.size.bytes [Integer], size in bytes of the current frame. *
  • mp3.position.byte [Long], current position in bytes in the stream. *
  • mp3.position.microseconds [Long], elapsed microseconds. *
  • mp3.equalizer float[32], interactive equalizer array, values could be in [-1.0, +1.0]. *
  • mp3.shoutcast.metadata.key [String], Shoutcast meta key with matching value. *
    For instance : *
    mp3.shoutcast.metadata.StreamTitle=Current song playing in stream. *
    mp3.shoutcast.metadata.StreamUrl=Url info. *
*/ public Map properties() { properties.put("mp3.frame",new Long(currentFrame)); properties.put("mp3.frame.bitrate",new Integer(currentBitrate)); properties.put("mp3.frame.size.bytes",new Integer(currentFramesize)); properties.put("mp3.position.byte",new Long(currentByte)); properties.put("mp3.position.microseconds",new Long(currentMicrosecond)); properties.put("mp3.equalizer",m_equalizer_values); // Optionnal shoutcast stream meta-data. if (shoutlst != null) { String surl = shoutlst.getStreamUrl(); String stitle = shoutlst.getStreamTitle(); if ((stitle != null) && (stitle.trim().length()>0)) properties.put("mp3.shoutcast.metadata.StreamTitle",stitle); if ((surl != null) && (surl.trim().length()>0)) properties.put("mp3.shoutcast.metadata.StreamUrl",surl); } return properties; } public void execute() { if (TDebug.TraceAudioConverter) TDebug.out("execute() : begin"); try { // Following line hangs when FrameSize is available in AudioFormat. Header header = null; if (m_header == null) header = m_bitstream.readFrame(); else header = m_header; if (TDebug.TraceAudioConverter) TDebug.out("execute() : header = "+header); if (header == null) { if (TDebug.TraceAudioConverter) { TDebug.out("header is null (end of mpeg stream)"); } getCircularBuffer().close(); return; } currentFrame++; currentBitrate = header.bitrate_instant(); currentFramesize = header.calculate_framesize(); currentByte = currentByte + currentFramesize; currentMicrosecond = (long) (currentFrame* header.ms_per_frame()*1000.0f); for (int b=0;b 0) && (frameslength > 0)) { float ratio = bytes*1.0f/byteslength*1.0f; long bytesread = skipFrames((long) (ratio*frameslength)); currentByte = currentByte + bytesread; m_header = null; return bytesread; } else return -1; } /** * Skip frames. * You don't need to call it severals times, it will exactly skip given frames number. * @param frames * @return bytes length skipped matching to frames skipped. */ public long skipFrames(long frames) { if (TDebug.TraceAudioConverter) TDebug.out("skip(long frames) : begin"); int framesRead = 0; int bytesReads = 0; try { for (int i=0;i>> 8) & 0xFF); bSecondByte = (byte) (sValue & 0xFF); } else // little endian { bFirstByte = (byte) (sValue & 0xFF); bSecondByte = (byte) ((sValue >>> 8) & 0xFF); } m_abBuffer[m_anBufferPointers[nChannel]] = bFirstByte; m_abBuffer[m_anBufferPointers[nChannel] + 1] = bSecondByte; m_anBufferPointers[nChannel] += m_nChannels * 2; } public void set_stop_flag() { } public void close() { } public void write_buffer(int nValue) { } public void clear_buffer() { } public byte[] getBuffer() { return m_abBuffer; } public int getCurrentBufferSize() { return m_anBufferPointers[0]; } public void reset() { for (int i = 0; i < m_nChannels; i++) { /* Points to byte location, * implicitely assuming 16 bit * samples. */ m_anBufferPointers[i] = i * 2; } } } public void tagParsed(TagParseEvent tpe) { System.out.println("TAG:"+tpe.getTag()); } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/mpeg/sampled/convert/MpegFormatConversionProvider.java0000644000175000017500000000776411451704772033224 0ustar twernertwerner/* * MpegFormatConversionProvider. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * * --------------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * -------------------------------------------------------------------------- */ package javazoom.spi.mpeg.sampled.convert; import java.util.Arrays; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javazoom.spi.mpeg.sampled.file.MpegEncoding; import org.tritonus.share.TDebug; import org.tritonus.share.sampled.Encodings; import org.tritonus.share.sampled.convert.TEncodingFormatConversionProvider; /** * ConversionProvider for MPEG files. */ public class MpegFormatConversionProvider extends TEncodingFormatConversionProvider { private static final AudioFormat.Encoding MP3 = Encodings.getEncoding("MP3"); private static final AudioFormat.Encoding PCM_SIGNED = Encodings.getEncoding("PCM_SIGNED"); private static final AudioFormat[] INPUT_FORMATS = { // mono new AudioFormat(MP3, -1.0F, -1, 1, -1, -1.0F, false), new AudioFormat(MP3, -1.0F, -1, 1, -1, -1.0F, true), // stereo new AudioFormat(MP3, -1.0F, -1, 2, -1, -1.0F, false), new AudioFormat(MP3, -1.0F, -1, 2, -1, -1.0F, true), }; private static final AudioFormat[] OUTPUT_FORMATS = { // mono, 16 bit signed new AudioFormat(PCM_SIGNED, -1.0F, 16, 1, 2, -1.0F, false), new AudioFormat(PCM_SIGNED, -1.0F, 16, 1, 2, -1.0F, true), // stereo, 16 bit signed new AudioFormat(PCM_SIGNED, -1.0F, 16, 2, 4, -1.0F, false), new AudioFormat(PCM_SIGNED, -1.0F, 16, 2, 4, -1.0F, true), }; /** * Constructor. */ public MpegFormatConversionProvider() { super(Arrays.asList(INPUT_FORMATS), Arrays.asList(OUTPUT_FORMATS)); if (TDebug.TraceAudioConverter) { TDebug.out(">MpegFormatConversionProvider()"); } } public AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream) { if (TDebug.TraceAudioConverter) { TDebug.out(">MpegFormatConversionProvider.getAudioInputStream(AudioFormat targetFormat, AudioInputStream audioInputStream):"); } return new DecodedMpegAudioInputStream(targetFormat, audioInputStream); } /** * Add conversion support for any MpegEncoding source with FrameRate or FrameSize not empty. * @param targetFormat * @param sourceFormat * @return */ public boolean isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat) { if (TDebug.TraceAudioConverter) { TDebug.out(">MpegFormatConversionProvider.isConversionSupported(AudioFormat targetFormat, AudioFormat sourceFormat):"); TDebug.out("checking if conversion possible"); TDebug.out("from: " + sourceFormat); TDebug.out("to: " + targetFormat); } boolean conversion = super.isConversionSupported(targetFormat, sourceFormat); if (conversion == false) { AudioFormat.Encoding enc = sourceFormat.getEncoding(); if (enc instanceof MpegEncoding) { if ((sourceFormat.getFrameRate() != AudioSystem.NOT_SPECIFIED) || (sourceFormat.getFrameSize() != AudioSystem.NOT_SPECIFIED)) { conversion = true; } } } return conversion; } } libmp3spi-java-1.9.5.orig/src/javazoom/spi/PropertiesContainer.java0000644000175000017500000000216411451704772025331 0ustar twernertwerner/* * PropertiesContainer. * * JavaZOOM : mp3spi@javazoom.net * http://www.javazoom.net * *----------------------------------------------------------------------- * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as published * by the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *---------------------------------------------------------------------- */ package javazoom.spi; import java.util.Map; public interface PropertiesContainer { public Map properties(); } libmp3spi-java-1.9.5.orig/src/META-INF/0000755000175000017500000000000011455024352017174 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/META-INF/services/0000755000175000017500000000000011455024352021017 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/src/META-INF/services/javax.sound.sampled.spi.AudioFileReader0000644000175000017500000000012611451704772030411 0ustar twernertwerner# for the javalayer mp3 decoder javazoom.spi.mpeg.sampled.file.MpegAudioFileReader libmp3spi-java-1.9.5.orig/src/META-INF/services/javax.sound.sampled.spi.FormatConversionProvider0000644000175000017500000000014111451704772032433 0ustar twernertwerner# for the javalayer mp3 decoder javazoom.spi.mpeg.sampled.convert.MpegFormatConversionProvider libmp3spi-java-1.9.5.orig/build.xml0000644000175000017500000001017311455365444017102 0ustar twernertwerner libmp3spi-java-1.9.5.orig/LICENSE.txt0000644000175000017500000006446607431336474017122 0ustar twernertwerner GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Libraries If you develop a new library, and you want it to be of the greatest possible use to the public, we recommend making it free software that everyone can redistribute and change. You can do so by permitting redistribution under these terms (or, alternatively, under the terms of the ordinary General Public License). To apply these terms, attach the following notices to the library. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the library, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the library `Frob' (a library for tweaking knobs) written by James Random Hacker. , 1 April 1990 Ty Coon, President of Vice That's all there is to it! libmp3spi-java-1.9.5.orig/CHANGES.txt0000644000175000017500000001455411455365332017075 0ustar twernertwernerMP3SPI 1.9.5 Project Homepage : http://www.javazoom.net/mp3spi/mp3spi.html JAVA and MP3 online Forums : http://www.javazoom.net/services/forums/index.jsp ----------------------------------------------------- 10/12/2010: MP3SPI 1.9.5 ------------------------ - marklimit system parameter added. (e.g. -Dmarklimit=8000000) - Default marklimit setup to 4MB - Duration bug fix. 11/04/2005: MP3SPI 1.9.4 ------------------------ - RIFF/MP3 header support added. - FLAC and MAC headers denied. - Skip bug fixed for 320kbps files. - ID3v2.x support improved : + size computation bug fixed. + "mp3.id3tag.publisher" (TPUB/TPB) added. + "mp3.id3tag.orchestra" (TPE2/TP2) added. + "mp3.id3tag.length" (TLEN/TLE) added. - Mark limit increased. 08/15/2005: MP3SPI 1.9.3 ------------------------ - ID3v2.x support improved. - ISO-8859-1 support improved for Icecast meta-data. 01/03/2005: MP3SPI 1.9.2 ------------------------ - ID3v2.x support improved : + "mp3.id3tag.composer" property added. + "mp3.id3tag.grouping" property added. + "mp3.id3tag.disc" property added. + "mp3.id3tag.encoded" property added. + "mp3.id3tag.v2.version" property added. '2' means ID3v2.2, '3' means ID3v2.3, '4' means ID3v2.4. + ID3v1 "year" property moved to "date" property. + ID3v2.2 support added. + ID3v2.4 TDRC support added for "date" property. - String encoding bug fix in chopSubstring method. - Optional "mp3spi.weak" System property added to skip some audio controls. - J2SE 1.5 support. - JLayer 1.0 included : Changes are : + VBRI frame header (Fraunhofer VBR) support added. + Frame controls improved. It fixes ArrayIndexOutOfBound bugs. + CPU usage < 1%, RAM usage < 12MB under P4/2Ghz under JRE 1.5.0. - Tritonus library updated. It fixes the 3h22m52s stream closing bug. 05/03/2004: MP3SPI 1.9.1 ------------------------ - Shoutcast stream meta-data (title, url) added. See DecodedMpegAudioInputStream : mp3.shoutcast.metadata.key [String], Shoutcast meta key with matching value. For instance : mp3.shoutcast.metadata.StreamTitle=Current song playing in stream. mp3.shoutcast.metadata.StreamUrl=Url info. - Icecast 2.0 icy-metaint support added. 04/05/2004: MP3SPI 1.9 ---------------------- - Shoutcast ICY meta-data support added. (jicylib classes included). - ID3v1 support added. - Audio parameters could be read through AudioFileFormat.properties() and AudioFormat.properties(). Here are all audio parameters provided by MP3 SPI : AudioFormat parameters : ~~~~~~~~~~~~~~~~~~~~~~ - bitrate : [Integer], bitrate in bits per seconds, average bitrate for VBR enabled stream. - vbr : [Boolean], VBR flag AudioFileFormat parameters : ~~~~~~~~~~~~~~~~~~~~~~~~~~ + Standard parameters : - duration : [Long], duration in microseconds. - title : [String], Title of the stream. - author : [String], Name of the artist of the stream. - album : [String], Name of the album of the stream. - date : [String], The date (year) of the recording or release of the stream. - copyright : [String], Copyright message of the stream. - comment : [String], Comment of the stream. + Extended MP3 parameters : - mp3.version.mpeg : [String], mpeg version : 1,2 or 2.5 - mp3.version.layer : [String], layer version 1, 2 or 3 - mp3.version.encoding : [String], mpeg encoding : MPEG1, MPEG2-LSF, MPEG2.5-LSF - mp3.channels : [Integer], number of channels 1 : mono, 2 : stereo. - mp3.frequency.hz : [Integer], sampling rate in hz. - mp3.bitrate.nominal.bps : [Integer], nominal bitrate in bps. - mp3.length.bytes : [Integer], length in bytes. - mp3.length.frames : [Integer], length in frames. - mp3.framesize.bytes : [Integer], framesize of the first frame. framesize is not constant for VBR streams. - mp3.framerate.fps : [Float], framerate in frames per seconds. - mp3.header.pos : [Integer], position of first audio header (or ID3v2 size). - mp3.vbr : [Boolean], vbr flag. - mp3.vbr.scale : [Integer], vbr scale. - mp3.crc : [Boolean], crc flag. - mp3.original : [Boolean], original flag. - mp3.copyright : [Boolean], copyright flag. - mp3.padding : [Boolean], padding flag. - mp3.mode : [Integer], mode 0:STEREO 1:JOINT_STEREO 2:DUAL_CHANNEL 3:SINGLE_CHANNEL - mp3.id3tag.genre : [String], ID3 tag (v1 or v2) genre. - mp3.id3tag.track : [String], ID3 tag (v1 or v2) track info. - mp3.id3tagv2 : [InputStream], ID3v2 frames. - mp3.shoutcast.metadata.key : [String], Shoutcast meta key with matching value. For instance : mp3.shoutcast.metadata.icy-irc=#shoutcast mp3.shoutcast.metadata.icy-metaint=8192 mp3.shoutcast.metadata.icy-genre=Trance Techno Dance mp3.shoutcast.metadata.icy-url=http://www.di.fm and so on ... DecodedMpegAudioInputStream parameters : ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - mp3.frame : [Long], current frame position. - mp3.frame.bitrate : [Integer], bitrate of the current frame. - mp3.frame.size.bytes : [Integer], size in bytes of the current frame. - mp3.position.byte : [Long], current position in bytes in the stream. - mp3.position.microseconds : [Long], elapsed microseconds. - mp3.equalizer : float[32], interactive equalizer array, values could be in [-1.0, +1.0]. 02/01/2004: MP3SPI 1.8 ---------------------- Initial official release. It targets J2SE 1.3 and J2SE 1.4. It includes a workaround to get audio properties (duration, title, author, bitrate, vbr, ...) that will be available in JDK 1.5. It provides "static" MP3 format properties such as (mp3.version.mpeg, mp3.version.layer, mp3.id3tagv2, ...). The mp3.id3tagv2 property allows to get all ID3v2 frames. MP3SPI also provides "dynamic" MP3 properties for each frame played such as (mp3.frame , mp3.frame.bitrate, mp3.frame.size.bytes, mp3.equalizer, ...). The mp3.equalizer property allows to have equalizer feature. Notes : ----- MP3SPI needs JLayer and Tritonus libraries to work. libmp3spi-java-1.9.5.orig/lib/0000755000175000017500000000000011455365674016032 5ustar twernertwernerlibmp3spi-java-1.9.5.orig/classes/0000755000175000017500000000000011455365706016715 5ustar twernertwerner