Class Mp3FrameReader
- java.lang.Object
-
- com.sedmelluq.discord.lavaplayer.container.mp3.Mp3FrameReader
-
public class Mp3FrameReader extends java.lang.ObjectHandles reading MP3 frames from a stream.
-
-
Constructor Summary
Constructors Constructor Description Mp3FrameReader(SeekableInputStream inputStream, byte[] frameBuffer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappendToScanBuffer(byte[] data, int offset, int length)Append some bytes to the frame sync scan buffer.booleanfillFrameBuffer()Fills the buffer for the current frame.intgetFrameSize()longgetFrameStartPosition()voidnextFrame()Forget the current frame and make next calls look for the next frame.booleanscanForFrame(int bytesToCheck, boolean throwOnLimit)
-
-
-
Constructor Detail
-
Mp3FrameReader
public Mp3FrameReader(SeekableInputStream inputStream, byte[] frameBuffer)
- Parameters:
inputStream- Input buffer to read fromframeBuffer- Array to store the frame data in
-
-
Method Detail
-
scanForFrame
public boolean scanForFrame(int bytesToCheck, boolean throwOnLimit) throws java.io.IOException- Parameters:
bytesToCheck- The maximum number of bytes to check before throwing an IllegalStateExceptionthrowOnLimit- Whether to throw an exception when maximum number of bytes is reached, but no frame has been found and EOF has not been reached.- Returns:
- True if a frame was found, false if EOF was encountered.
- Throws:
java.io.IOException- On IO errorjava.lang.IllegalStateException- If the maximum number of bytes to check was reached before a frame was found
-
fillFrameBuffer
public boolean fillFrameBuffer() throws java.io.IOExceptionFills the buffer for the current frame. If no frame header has been read previously, it will first scan for the sync bytes of the next frame in the stream.- Returns:
- False if EOF was encountered while looking for the next frame, true otherwise
- Throws:
java.io.IOException- On IO error
-
nextFrame
public void nextFrame()
Forget the current frame and make next calls look for the next frame.
-
getFrameStartPosition
public long getFrameStartPosition()
- Returns:
- The start position of the current frame in the stream.
-
getFrameSize
public int getFrameSize()
- Returns:
- Size of the current frame in bytes.
-
appendToScanBuffer
public void appendToScanBuffer(byte[] data, int offset, int length)Append some bytes to the frame sync scan buffer. This must be called when some bytes have been read externally that may actually be part of the next frame header.- Parameters:
data- The buffer to copy fromoffset- The offset in the bufferlength- The length of the region to copy
-
-