public class MP4InputStream
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
MASK16 |
static int |
MASK8 |
static java.lang.String |
UTF16 |
static java.lang.String |
UTF8 |
Modifier and Type | Method and Description |
---|---|
long |
getOffset()
Returns the current offset in the stream.
|
boolean |
hasLeft()
Indicates, if the input has some data left.
|
boolean |
hasRandomAccess()
Indicates, if random access is available.
|
int |
read()
Reads the next byte of data from the input.
|
void |
read(byte[] b,
int off,
int len)
Reads
len bytes of data from the input into the array
b . |
void |
readBytes(byte[] b)
Reads data from the input stream and stores them into the buffer array b.
|
long |
readBytes(int n)
Reads up to eight bytes as a long value.
|
double |
readFixedPoint(int m,
int n)
Reads a fixed point number from the input.
|
java.lang.String |
readString(int n)
Reads
n bytes from the input as a String. |
byte[] |
readTerminated(int max,
int terminator)
Reads a byte array from the input that is terminated by a specific byte
(the 'terminator').
|
java.lang.String |
readUTFString(int max)
Reads a null-terminated UTF-encoded String from the input.
|
java.lang.String |
readUTFString(int max,
java.lang.String encoding)
Reads a null-terminated UTF-encoded String from the input.
|
void |
seek(long pos)
Seeks to a specific offset in the stream.
|
void |
skipBytes(long n)
Skips
n bytes in the input. |
public static final int MASK8
public static final int MASK16
public static final java.lang.String UTF8
public static final java.lang.String UTF16
public int read() throws java.io.IOException
java.io.IOException
- If the end of the stream is detected or any I/O error occurs.public void read(byte[] b, int off, int len) throws java.io.IOException
len
bytes of data from the input into the array
b
. If len is zero, then no bytes are read.
This method blocks until all bytes could be read, the end of the stream
is detected, or an I/O error occurs.
If the stream ends before len
bytes could be read an
EOFException is thrown.b
- the buffer into which the data is read.off
- the start offset in array b
at which the data is written.len
- the number of bytes to read.java.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.public long readBytes(int n) throws java.io.IOException
n
- the number of bytes to read >0 and <=8java.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.java.lang.IndexOutOfBoundsException
- if n
is not in the range
[1...8] inclusive.public void readBytes(byte[] b) throws java.io.IOException
b
- the buffer into which the data is read.java.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.public java.lang.String readString(int n) throws java.io.IOException
n
bytes from the input as a String. The bytes are
directly converted into characters. If not enough bytes could be read, an
EOFException is thrown.
This method blocks until all bytes could be read, the end of the stream
is detected, or an I/O error occurs.n
- the length of the String.java.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.public java.lang.String readUTFString(int max, java.lang.String encoding) throws java.io.IOException
max
- the maximum number of bytes to read, before the null-terminator
must appear.encoding
- the charset used to encode the Stringjava.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.public java.lang.String readUTFString(int max) throws java.io.IOException
max
- the maximum number of bytes to read, before the null-terminator
must appear.java.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.public byte[] readTerminated(int max, int terminator) throws java.io.IOException
max
- the maximum number of bytes to read, before the terminator
must appear.terminator
- the byte that indicates the end of the arrayjava.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.public double readFixedPoint(int m, int n) throws java.io.IOException
m.n
value, that results from deviding an integer by
2n.m
- the number of bits before the pointn
- the number of bits after the pointjava.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.java.lang.IllegalArgumentException
- if the total number of bits (m+n) is not
a multiple of eightpublic void skipBytes(long n) throws java.io.IOException
n
bytes in the input. This method blocks until all
bytes could be skipped, the end of the stream is detected, or an I/O
error occurs.n
- the number of bytes to skipjava.io.IOException
- If the end of the stream is detected, the input
stream has been closed, or if some other I/O error occurs.public long getOffset() throws java.io.IOException
java.io.IOException
- if an I/O error occurs (only when using a RandomAccessFile)public void seek(long pos) throws java.io.IOException
pos
- the offset position, measured in bytes from the beginning of the
streamjava.io.IOException
- if an InputStream is used, pos is less than 0 or an
I/O error occurspublic boolean hasRandomAccess()
MP4InputStream
was constructed with a RandomAccessFile. If
this method returns false, seeking is not possible.public boolean hasLeft() throws java.io.IOException
java.io.IOException
- if an I/O error occurs