Class SavedHeadSeekableInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
-
- com.sedmelluq.discord.lavaplayer.tools.io.SavedHeadSeekableInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class SavedHeadSeekableInputStream extends SeekableInputStream
A wrapper around a seekable input stream which saves the beginning of the stream into a buffer. Seeking within the saved beginning does not cause any IO to be done on the underlying input stream.
-
-
Field Summary
-
Fields inherited from class com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
contentLength
-
-
Constructor Summary
Constructors Constructor Description SavedHeadSeekableInputStream(SeekableInputStream delegate, int savedSize)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()booleancanSeekHard()voidclose()longgetPosition()java.util.List<AudioTrackInfoProvider>getTrackInfoProviders()voidloadHead()Load the number of bytes specified in the constructor into the saved buffer.booleanmarkSupported()intread()intread(byte[] b, int off, int len)protected voidseekHard(long position)voidsetAllowDirectReads(boolean allowDirectReads)longskip(long n)-
Methods inherited from class com.sedmelluq.discord.lavaplayer.tools.io.SeekableInputStream
getContentLength, getMaxSkipDistance, seek, skipFully
-
-
-
-
Constructor Detail
-
SavedHeadSeekableInputStream
public SavedHeadSeekableInputStream(SeekableInputStream delegate, int savedSize)
- Parameters:
delegate- The seekable stream to delegate reading tosavedSize- Number of bytes to buffer
-
-
Method Detail
-
setAllowDirectReads
public void setAllowDirectReads(boolean allowDirectReads)
-
loadHead
public void loadHead() throws java.io.IOExceptionLoad the number of bytes specified in the constructor into the saved buffer.- Throws:
java.io.IOException- On IO error
-
getPosition
public long getPosition()
- Specified by:
getPositionin classSeekableInputStream- Returns:
- Current position in the stream
-
seekHard
protected void seekHard(long position) throws java.io.IOException- Specified by:
seekHardin classSeekableInputStream- Throws:
java.io.IOException
-
canSeekHard
public boolean canSeekHard()
- Specified by:
canSeekHardin classSeekableInputStream- Returns:
trueif it is possible to seek to an arbitrary position in this stream, even when it is behind the current position.
-
getTrackInfoProviders
public java.util.List<AudioTrackInfoProvider> getTrackInfoProviders()
- Specified by:
getTrackInfoProvidersin classSeekableInputStream
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
skip
public long skip(long n) throws java.io.IOException- Overrides:
skipin classjava.io.InputStream- Throws:
java.io.IOException
-
available
public int available() throws java.io.IOException- Overrides:
availablein classjava.io.InputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException
-
markSupported
public boolean markSupported()
- Overrides:
markSupportedin classjava.io.InputStream
-
-