sk.baka.ambient.stream.shoutcast
Class ShoutcastInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by sk.baka.ambient.stream.shoutcast.ShoutcastInputStream
All Implemented Interfaces:
Closeable

public class ShoutcastInputStream
extends InputStream

Polls a SHOUTcast server on given URL address. The stream itself will contain mp3 data only - all shoutcast-related metadata are reported as events and filtered out.

Throws RadioStreamCorruptedException when the stream corruption is detected.

Author:
Martin Vysny

Field Summary
 URL url
          The SHOUTcast server URL.
 
Constructor Summary
ShoutcastInputStream(InputStream stream, IShoutcastListener listener)
          Creates the object.
ShoutcastInputStream(URL url, IShoutcastListener listener)
          Creates the object.
 
Method Summary
 void close()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int offset, int length)
           
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

url

public final URL url
The SHOUTcast server URL.

Constructor Detail

ShoutcastInputStream

public ShoutcastInputStream(URL url,
                            IShoutcastListener listener)
Creates the object. The SHOUTcast server is polled on first invocation of the read method.

Parameters:
url - the server URL, must be a http (or file - for debugging purposes) protocol.
listener - the listener.

ShoutcastInputStream

ShoutcastInputStream(InputStream stream,
                     IShoutcastListener listener)
               throws IOException
Creates the object.

Parameters:
stream - the SHOUTcast stream.
listener - the listener.
Throws:
IOException
Method Detail

read

public int read(byte[] b,
                int offset,
                int length)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException


Copyright © 2007-2008. All Rights Reserved.