Class OggPacketInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.sedmelluq.discord.lavaplayer.container.ogg.OggPacketInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class OggPacketInputStream extends java.io.InputStreamThis provides a stream for OGG packets where the stream is always bounded to the current packet, and the next packet can be started with startNewPacket(). The same way it is bound to a specific track and the next track can be started with startNewTrack() when the previous one has ended (startNewPacket() has returned false).
-
-
Constructor Summary
Constructors Constructor Description OggPacketInputStream(SeekableInputStream inputStream, boolean closeDelegated)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()java.util.List<OggSeekPoint>createSeekTable(int sampleRate)booleanisPacketComplete()intread()intread(byte[] buffer, int initialOffset, int length)longseek(long timecode)Seeks the stream to the specified timecode.OggStreamSizeInfoseekForSizeInfo(int sampleRate)If it is possible to seek backwards on this stream, and the length of the stream is known, seeks to the end of the track to determine the stream length both in bytes and samples.voidsetSeekPoints(java.util.List<OggSeekPoint> seekPoints)booleanstartNewPacket()Load the next packet from the stream.booleanstartNewTrack()Load the next track from the stream.
-
-
-
Constructor Detail
-
OggPacketInputStream
public OggPacketInputStream(SeekableInputStream inputStream, boolean closeDelegated)
- Parameters:
inputStream- Input stream to read in as OGG packetscloseDelegated- Whether closing this stream should close the inputStream as well
-
-
Method Detail
-
setSeekPoints
public void setSeekPoints(java.util.List<OggSeekPoint> seekPoints)
-
startNewTrack
public boolean startNewTrack()
Load the next track from the stream. This is only valid when the stream is in a track boundary state.- Returns:
- True if next track is present in the stream, false if the stream has terminated.
-
startNewPacket
public boolean startNewPacket() throws java.io.IOExceptionLoad the next packet from the stream. This is only valid when the stream is in a packet boundary state.- Returns:
- True if next packet is present in the track. State is PACKET_READ. False if the track is finished. State is either TRACK_BOUNDARY or TERMINATED.
- Throws:
java.io.IOException- On read error.
-
isPacketComplete
public boolean isPacketComplete()
-
read
public int read() throws java.io.IOException- Specified by:
readin classjava.io.InputStream- Throws:
java.io.IOException
-
read
public int read(byte[] buffer, int initialOffset, int length) throws java.io.IOException- Overrides:
readin 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
-
seek
public long seek(long timecode) throws java.io.IOExceptionSeeks the stream to the specified timecode.- Parameters:
timecode- Timecode in milliseconds to seek to.- Returns:
- The actual timecode in milliseconds to which the stream was seeked.
- Throws:
java.io.IOException- On read error.
-
createSeekTable
public java.util.List<OggSeekPoint> createSeekTable(int sampleRate) throws java.io.IOException
- Throws:
java.io.IOException
-
seekForSizeInfo
public OggStreamSizeInfo seekForSizeInfo(int sampleRate) throws java.io.IOException
If it is possible to seek backwards on this stream, and the length of the stream is known, seeks to the end of the track to determine the stream length both in bytes and samples.- Parameters:
sampleRate- Sample rate of the track in this stream.- Returns:
- OGG stream size information.
- Throws:
java.io.IOException- On read error.
-
-