|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.OutputStream
java.io.FilterOutputStream
org.musicontroller.streaming.MpegOutputStream
public class MpegOutputStream
An MpegOutputStream filters all (meta)data from a stream, so that a clean stream of Mpeg-frames remains. This class tries to achieve this by detecting and decoding mp3-frame-headers in the stream. Correct headers and the subsequent data are let through, whereas incorrect data is filtered. This method has a downside: metadata in a mp3-file could in theory contain data which looks like a valid mp3-frame-header too. The solution is to not only read mp3-frame-headers, but metadata-headers as well. If we encounter an ID3-header, we just skip the following data.
Field Summary |
---|
Fields inherited from class java.io.FilterOutputStream |
---|
out |
Constructor Summary | |
---|---|
MpegOutputStream(java.io.OutputStream out)
Creates a new MpegOutputStream. |
Method Summary | |
---|---|
void |
flush()
|
long |
getBytesStreamed()
Gets the number of bytes streamed. |
int |
getStreamedLengthInMillis()
Gets the playtime. |
void |
reset()
Resets the internal state of the MpegOutputStream. |
void |
write(byte[] b,
int off,
int len)
Disregards bytes until a valid Mpeg-header is found. |
void |
write(int b)
|
Methods inherited from class java.io.FilterOutputStream |
---|
close, write |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MpegOutputStream(java.io.OutputStream out)
out
- The OutputStream to filter.Method Detail |
---|
public void reset()
Resets the internal state of the MpegOutputStream. This is particularly useful when skipping songs. In the case of skipping, the stream is cut off at an arbitrary position, causing the mpeg-stream to become distorted.
This method also sets the seconds-counter back to 0.
When this class is busy copying an mpeg-frame which is only partly handed over, the output can still contain pops. The new frame would come too early, causing bogus-data to be played as music. A call to this reset method invalidates the current mpeg frame, and therefore rules out another source of nasty popping sounds.
public void write(int b) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void write(byte[] b, int off, int len) throws java.io.IOException
write
in class java.io.FilterOutputStream
java.io.IOException
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
flush
in class java.io.FilterOutputStream
java.io.IOException
public int getStreamedLengthInMillis()
public long getBytesStreamed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |