Interface ExtractorInput
-
- All Superinterfaces:
DataReader
- All Known Implementing Classes:
DefaultExtractorInput
,FakeExtractorInput
,ForwardingExtractorInput
@Deprecated public interface ExtractorInput extends DataReader
Deprecated.com.google.android.exoplayer2 is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.Provides data to be consumed by anExtractor
.This interface provides two modes of accessing the underlying input. See the subheadings below for more info about each mode.
- The
read()/peek()
andskip()
methods provideInputStream
-like byte-level access operations. - The
read/skip/peekFully()
andadvancePeekPosition()
methods assume the user wants to read an entire block/frame/header of known length.
InputStream
-like methodsThe
read()/peek()
andskip()
methods provideInputStream
-like byte-level access operations. Thelength
parameter is a maximum, and each method returns the number of bytes actually processed. This may be less thanlength
because the end of the input was reached, or the method was interrupted, or the operation was aborted early for another reason.Block-based methods
The
read/skip/peekFully()
andadvancePeekPosition()
methods assume the user wants to read an entire block/frame/header of known length.These methods all have a variant that takes a boolean
allowEndOfInput
parameter. This parameter is intended to be set to true when the caller believes the input might be fully exhausted before the call is made (i.e. they've previously read/skipped/peeked the final block/frame/header). It's not intended to allow a partial read (i.e. greater than 0 bytes, but less thanlength
) to succeed - this will always throw anEOFException
from these methods (a partial read is assumed to indicate a malformed block/frame/header - and therefore a malformed file).The expected behaviour of the block-based methods is therefore:
- Already at end-of-input and
allowEndOfInput=false
: ThrowEOFException
. - Already at end-of-input and
allowEndOfInput=true
: Returnfalse
. - Encounter end-of-input during read/skip/peek/advance: Throw
EOFException
(regardless ofallowEndOfInput
).
-
-
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description void
advancePeekPosition(int length)
Deprecated.Advances the peek position bylength
bytes.boolean
advancePeekPosition(int length, boolean allowEndOfInput)
Deprecated.Advances the peek position bylength
bytes.long
getLength()
Deprecated.Returns the length of the source stream, orC.LENGTH_UNSET
if it is unknown.long
getPeekPosition()
Deprecated.Returns the current peek position (byte offset) in the stream.long
getPosition()
Deprecated.Returns the current read position (byte offset) in the stream.int
peek(byte[] target, int offset, int length)
Deprecated.Peeks up tolength
bytes from the peek position.void
peekFully(byte[] target, int offset, int length)
Deprecated.Equivalent topeekFully(target, offset, length, false)
.boolean
peekFully(byte[] target, int offset, int length, boolean allowEndOfInput)
Deprecated.Likepeek(byte[], int, int)
, but peeks the requestedlength
in full.int
read(byte[] buffer, int offset, int length)
Deprecated.Reads up tolength
bytes from the input and resets the peek position.void
readFully(byte[] target, int offset, int length)
Deprecated.Equivalent toreadFully(target, offset, length, false)
.boolean
readFully(byte[] target, int offset, int length, boolean allowEndOfInput)
Deprecated.Likeread(byte[], int, int)
, but reads the requestedlength
in full.void
resetPeekPosition()
Deprecated.Resets the peek position to equal the current read position.<E extends Throwable>
voidsetRetryPosition(long position, E e)
Deprecated.Called when reading fails and the required retry position is different from the last position.int
skip(int length)
Deprecated.Likeread(byte[], int, int)
, except the data is skipped instead of read.void
skipFully(int length)
Deprecated.LikereadFully(byte[], int, int)
, except the data is skipped instead of read.boolean
skipFully(int length, boolean allowEndOfInput)
Deprecated.LikereadFully(byte[], int, int, boolean)
, except the data is skipped instead of read.
-
-
-
Method Detail
-
read
int read(byte[] buffer, int offset, int length) throws IOException
Deprecated.Reads up tolength
bytes from the input and resets the peek position.This method blocks until at least one byte of data can be read, the end of the input is detected, or an exception is thrown.
- Specified by:
read
in interfaceDataReader
- Parameters:
buffer
- A target array into which data should be written.offset
- The offset into the target array at which to write.length
- The maximum number of bytes to read from the input.- Returns:
- The number of bytes read, or
C.RESULT_END_OF_INPUT
if the input has ended. - Throws:
IOException
- If an error occurs reading from the input.
-
readFully
boolean readFully(byte[] target, int offset, int length, boolean allowEndOfInput) throws IOException
Deprecated.Likeread(byte[], int, int)
, but reads the requestedlength
in full.- Parameters:
target
- A target array into which data should be written.offset
- The offset into the target array at which to write.length
- The number of bytes to read from the input.allowEndOfInput
- True if encountering the end of the input having read no data is allowed, and should result infalse
being returned. False if it should be considered an error, causing anEOFException
to be thrown. See note in class Javadoc.- Returns:
- True if the read was successful. False if
allowEndOfInput=true
and the end of the input was encountered having read no data. - Throws:
EOFException
- If the end of input was encountered having partially satisfied the read (i.e. having read at least one byte, but fewer thanlength
), or if no bytes were read andallowEndOfInput
is false.IOException
- If an error occurs reading from the input.
-
readFully
void readFully(byte[] target, int offset, int length) throws IOException
Deprecated.Equivalent toreadFully(target, offset, length, false)
.- Parameters:
target
- A target array into which data should be written.offset
- The offset into the target array at which to write.length
- The number of bytes to read from the input.- Throws:
EOFException
- If the end of input was encountered.IOException
- If an error occurs reading from the input.
-
skip
int skip(int length) throws IOException
Deprecated.Likeread(byte[], int, int)
, except the data is skipped instead of read.- Parameters:
length
- The maximum number of bytes to skip from the input.- Returns:
- The number of bytes skipped, or
C.RESULT_END_OF_INPUT
if the input has ended. - Throws:
IOException
- If an error occurs reading from the input.
-
skipFully
boolean skipFully(int length, boolean allowEndOfInput) throws IOException
Deprecated.LikereadFully(byte[], int, int, boolean)
, except the data is skipped instead of read.- Parameters:
length
- The number of bytes to skip from the input.allowEndOfInput
- True if encountering the end of the input having skipped no data is allowed, and should result infalse
being returned. False if it should be considered an error, causing anEOFException
to be thrown. See note in class Javadoc.- Returns:
- True if the skip was successful. False if
allowEndOfInput=true
and the end of the input was encountered having skipped no data. - Throws:
EOFException
- If the end of input was encountered having partially satisfied the skip (i.e. having skipped at least one byte, but fewer thanlength
), or if no bytes were skipped andallowEndOfInput
is false.IOException
- If an error occurs reading from the input.
-
skipFully
void skipFully(int length) throws IOException
Deprecated.LikereadFully(byte[], int, int)
, except the data is skipped instead of read.Encountering the end of input is always considered an error, and will result in an
EOFException
being thrown.- Parameters:
length
- The number of bytes to skip from the input.- Throws:
EOFException
- If the end of input was encountered.IOException
- If an error occurs reading from the input.
-
peek
int peek(byte[] target, int offset, int length) throws IOException
Deprecated.Peeks up tolength
bytes from the peek position. The current read position is left unchanged.This method blocks until at least one byte of data can be peeked, the end of the input is detected, or an exception is thrown.
Calling
resetPeekPosition()
resets the peek position to equal the current read position, so the caller can peek the same data again. Reading or skipping also resets the peek position.- Parameters:
target
- A target array into which data should be written.offset
- The offset into the target array at which to write.length
- The maximum number of bytes to peek from the input.- Returns:
- The number of bytes peeked, or
C.RESULT_END_OF_INPUT
if the input has ended. - Throws:
IOException
- If an error occurs peeking from the input.
-
peekFully
boolean peekFully(byte[] target, int offset, int length, boolean allowEndOfInput) throws IOException
Deprecated.Likepeek(byte[], int, int)
, but peeks the requestedlength
in full.- Parameters:
target
- A target array into which data should be written.offset
- The offset into the target array at which to write.length
- The number of bytes to peek from the input.allowEndOfInput
- True if encountering the end of the input having peeked no data is allowed, and should result infalse
being returned. False if it should be considered an error, causing anEOFException
to be thrown. See note in class Javadoc.- Returns:
- True if the peek was successful. False if
allowEndOfInput=true
and the end of the input was encountered having peeked no data. - Throws:
EOFException
- If the end of input was encountered having partially satisfied the peek (i.e. having peeked at least one byte, but fewer thanlength
), or if no bytes were peeked andallowEndOfInput
is false.IOException
- If an error occurs peeking from the input.
-
peekFully
void peekFully(byte[] target, int offset, int length) throws IOException
Deprecated.Equivalent topeekFully(target, offset, length, false)
.- Parameters:
target
- A target array into which data should be written.offset
- The offset into the target array at which to write.length
- The number of bytes to peek from the input.- Throws:
EOFException
- If the end of input was encountered.IOException
- If an error occurs peeking from the input.
-
advancePeekPosition
boolean advancePeekPosition(int length, boolean allowEndOfInput) throws IOException
Deprecated.Advances the peek position bylength
bytes. LikepeekFully(byte[], int, int, boolean)
except the data is skipped instead of read.- Parameters:
length
- The number of bytes by which to advance the peek position.allowEndOfInput
- True if encountering the end of the input before advancing is allowed, and should result infalse
being returned. False if it should be considered an error, causing anEOFException
to be thrown. See note in class Javadoc.- Returns:
- True if advancing the peek position was successful. False if
allowEndOfInput=true
and the end of the input was encountered before advancing over any data. - Throws:
EOFException
- If the end of input was encountered having partially advanced (i.e. having advanced by at least one byte, but fewer thanlength
), or if the end of input was encountered before advancing andallowEndOfInput
is false.IOException
- If an error occurs advancing the peek position.
-
advancePeekPosition
void advancePeekPosition(int length) throws IOException
Deprecated.Advances the peek position bylength
bytes. LikepeekFully(byte[], int, int)
except the data is skipped instead of read.- Parameters:
length
- The number of bytes to peek from the input.- Throws:
EOFException
- If the end of input was encountered.IOException
- If an error occurs peeking from the input.
-
resetPeekPosition
void resetPeekPosition()
Deprecated.Resets the peek position to equal the current read position.
-
getPeekPosition
long getPeekPosition()
Deprecated.Returns the current peek position (byte offset) in the stream.- Returns:
- The peek position (byte offset) in the stream.
-
getPosition
long getPosition()
Deprecated.Returns the current read position (byte offset) in the stream.- Returns:
- The read position (byte offset) in the stream.
-
getLength
long getLength()
Deprecated.Returns the length of the source stream, orC.LENGTH_UNSET
if it is unknown.- Returns:
- The length of the source stream, or
C.LENGTH_UNSET
.
-
-