Package org.red5.io.mp3.impl
Class MP3Stream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- java.io.PushbackInputStream
-
- org.red5.io.mp3.impl.MP3Stream
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class MP3Stream extends PushbackInputStream
A specialized stream class which can be used to extract single frames of MPEG audio files.
Instances of this class are constructed with an underlying stream which should point to an audio file. Read operations are possible in the usual way. However, there are special methods for searching and extracting headers of MPEG frames. Some meta information of frames can be queried.
This class was copied from Apache Tika and modified for Red5.
-
-
Field Summary
-
Fields inherited from class java.io.PushbackInputStream
buf, pos
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description MP3Stream(InputStream in)Creates a new instance ofMpegStreamand initializes it with the underlying stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleaneos()org.apache.tika.parser.mp3.AudioFramenextFrame()Searches for the next MPEG frame header from the current stream position on.booleanskipFrame()Skips the current MPEG frame.-
Methods inherited from class java.io.PushbackInputStream
available, close, mark, markSupported, read, read, reset, skip, unread, unread, unread
-
Methods inherited from class java.io.FilterInputStream
read
-
Methods inherited from class java.io.InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, transferTo
-
-
-
-
Constructor Detail
-
MP3Stream
public MP3Stream(InputStream in)
Creates a new instance ofMpegStreamand initializes it with the underlying stream.- Parameters:
in- the underlying audio stream
-
-
Method Detail
-
eos
public boolean eos()
-
nextFrame
public org.apache.tika.parser.mp3.AudioFrame nextFrame() throws IOExceptionSearches for the next MPEG frame header from the current stream position on. This method advances the underlying input stream until it finds a valid frame header or the end of the stream is reached. In the former case a correspondingAudioFrameobject is created. In the latter case there are no more headers, so the end of the stream is probably reached.- Returns:
- the next
AudioFrameor null - Throws:
IOException- if an IO error occurs
-
skipFrame
public boolean skipFrame() throws IOExceptionSkips the current MPEG frame. This method can be called after a valid MPEG header has been retrieved usingnextFrame(). In this case the underlying stream is advanced to the end of the associated MPEG frame. Otherwise, this method has no effect. The return value indicates whether a frame could be skipped.- Returns:
- true if a frame could be skipped, false otherwise
- Throws:
IOException- if an IO error occurs
-
-