Class MatroskaFileReader
- java.lang.Object
-
- com.sedmelluq.discord.lavaplayer.container.matroska.format.MatroskaFileReader
-
public class MatroskaFileReader extends java.lang.ObjectHandles reading of elements and their content from an MKV file.
-
-
Constructor Summary
Constructors Constructor Description MatroskaFileReader(SeekableInputStream inputStream)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]asBytes(MatroskaElement element)doubleasDouble(MatroskaElement element)floatasFloat(MatroskaElement element)intasInteger(MatroskaElement element)longasLong(MatroskaElement element)java.lang.StringasString(MatroskaElement element)java.lang.StringasString(MatroskaElement element, java.nio.charset.Charset forceCharset)java.io.DataInputgetDataInput()longgetPosition()MatroskaBlockreadBlockHeader(MatroskaElement parent, int trackFilter)Reads one Matroska block header.MatroskaElementreadNextElement(MatroskaElement parent)voidseek(long position)Seeks to the specified position.voidskip(MatroskaElement element)
-
-
-
Constructor Detail
-
MatroskaFileReader
public MatroskaFileReader(SeekableInputStream inputStream)
- Parameters:
inputStream- Input stream to read from.
-
-
Method Detail
-
readNextElement
public MatroskaElement readNextElement(MatroskaElement parent) throws java.io.IOException
- Parameters:
parent- The parent element to use for bounds checking, null is valid.- Returns:
- The element whose header was read. Null if the parent/file has ended. The contents of this element are only
valid until the next element at the same level is read, use
MatroskaElement.frozen()to get a permanent instance. - Throws:
java.io.IOException- On read error
-
readBlockHeader
public MatroskaBlock readBlockHeader(MatroskaElement parent, int trackFilter) throws java.io.IOException
Reads one Matroska block header. The data is of the block is not read, but can be read frame by frame usingMatroskaBlock.getNextFrameBuffer(MatroskaFileReader, int).- Parameters:
parent- The block parent element.trackFilter- The ID of the track to read data for from the block.- Returns:
- An instance of a block if it contains data for the requested track,
nullotherwise. - Throws:
java.io.IOException- On read error.
-
asInteger
public int asInteger(MatroskaElement element) throws java.io.IOException
- Parameters:
element- Element to read from- Returns:
- The contents of the element as an integer
- Throws:
java.io.IOException- On read error
-
asLong
public long asLong(MatroskaElement element) throws java.io.IOException
- Parameters:
element- Element to read from- Returns:
- The contents of the element as a long
- Throws:
java.io.IOException- On read error
-
asFloat
public float asFloat(MatroskaElement element) throws java.io.IOException
- Parameters:
element- Element to read from- Returns:
- The contents of the element as a float
- Throws:
java.io.IOException- On read error
-
asDouble
public double asDouble(MatroskaElement element) throws java.io.IOException
- Parameters:
element- Element to read from- Returns:
- The contents of the element as a double
- Throws:
java.io.IOException- On read error
-
asString
public java.lang.String asString(MatroskaElement element) throws java.io.IOException
- Throws:
java.io.IOException
-
asString
public java.lang.String asString(MatroskaElement element, java.nio.charset.Charset forceCharset) throws java.io.IOException
- Parameters:
element- Element to read fromforceCharset- The charset to use, or null for default.- Returns:
- The contents of the element as a string
- Throws:
java.io.IOException- On read error
-
asBytes
public byte[] asBytes(MatroskaElement element) throws java.io.IOException
- Parameters:
element- Element to read from- Returns:
- The contents of the element as a byte array
- Throws:
java.io.IOException- On read error
-
skip
public void skip(MatroskaElement element) throws java.io.IOException
- Parameters:
element- Element to skip over- Throws:
java.io.IOException- On read error
-
getPosition
public long getPosition()
- Returns:
- Returns the current absolute position of the file.
-
seek
public void seek(long position) throws java.io.IOExceptionSeeks to the specified position.- Parameters:
position- The position in bytes.- Throws:
java.io.IOException- On read error
-
getDataInput
public java.io.DataInput getDataInput()
-
-