Class 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.
    • Constructor Detail

      • MP3Stream

        public MP3Stream​(InputStream in)
        Creates a new instance of MpegStream and 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 IOException
        Searches 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 corresponding AudioFrame object is created. In the latter case there are no more headers, so the end of the stream is probably reached.
        Returns:
        the next AudioFrame or null
        Throws:
        IOException - if an IO error occurs
      • skipFrame

        public boolean skipFrame()
                          throws IOException
        Skips the current MPEG frame. This method can be called after a valid MPEG header has been retrieved using nextFrame(). 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