# ForwardingExtractorInput

Artifact: [androidx.media3:media3-extractor](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/extractor/ForwardingExtractorInput.java+class:androidx.media3.extractor.ForwardingExtractorInput)

*** ** * ** ***


```
@UnstableApi
public class ForwardingExtractorInput implements ExtractorInput
```

<br />

*** ** * ** ***

An overridable `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput` implementation forwarding all methods to another input.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#ForwardingExtractorInput(androidx.media3.extractor.ExtractorInput)(https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput input)` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#advancePeekPosition(int)(int length)` Advances the peek position by `length` bytes. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#advancePeekPosition(int,boolean)(int length, boolean allowEndOfInput)` Advances the peek position by `length` bytes. |
| `long` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#getLength()()` Returns the length of the source stream, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if it is unknown. |
| `long` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#getPeekPosition()()` Returns the current peek position (byte offset) in the stream. |
| `long` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#getPosition()()` Returns the current read position (byte offset) in the stream. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#peek(byte[],int,int)(byte[] target, int offset, int length)` Peeks up to `length` bytes from the peek position. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#peekFully(byte[],int,int)(byte[] target, int offset, int length)` Equivalent to `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#peekFully(byte[],int,int,boolean)`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#peekFully(byte[],int,int,boolean)(byte[] target, int offset, int length, boolean allowEndOfInput)` Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#peek(byte[],int,int)`, but peeks the requested `length` in full. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#read(byte[],int,int)(byte[] buffer, int offset, int length)` Reads up to `length` bytes from the input and resets the peek position. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#readFully(byte[],int,int)(byte[] target, int offset, int length)` Equivalent to `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#readFully(byte[],int,int,boolean)`. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#readFully(byte[],int,int,boolean)(byte[] target, int offset, int length, boolean allowEndOfInput)` Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#read(byte[],int,int)`, but reads the requested `length` in full. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#resetPeekPosition()()` Resets the peek position to equal the current read position. |
| `void` | `<E extends https://developer.android.com/reference/java/lang/Throwable.html> https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#setRetryPosition(long,E)(long position, E e)` Called when reading fails and the required retry position is different from the last position. |
| `int` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#skip(int)(int length)` Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#read(byte[],int,int)`, except the data is skipped instead of read. |
| `void` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#skipFully(int)(int length)` Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#readFully(byte[],int,int)`, except the data is skipped instead of read. |
| `boolean` | `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#skipFully(int,boolean)(int length, boolean allowEndOfInput)` Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#readFully(byte[],int,int,boolean)`, except the data is skipped instead of read. |

## Public constructors

### ForwardingExtractorInput

```
public ForwardingExtractorInput(ExtractorInput input)
```

## Public methods

### advancePeekPosition

```
public void advancePeekPosition(int length)
```

Advances the peek position by `length` bytes. Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#peekFully(byte[],int,int)` except the data is skipped instead of read.

| Parameters |
|---|---|
| `int length` | The number of bytes to peek from the input. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/EOFException.html` | If the end of input was encountered. |
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs peeking from the input. |

### advancePeekPosition

```
public boolean advancePeekPosition(int length, boolean allowEndOfInput)
```

Advances the peek position by `length` bytes. Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#peekFully(byte[],int,int,boolean)` except the data is skipped instead of read.

| Parameters |
|---|---|
| `int length` | The number of bytes by which to advance the peek position. |
| `boolean allowEndOfInput` | True if encountering the end of the input before advancing is allowed, and should result in `false` being returned. False if it should be considered an error, causing an `https://developer.android.com/reference/java/io/EOFException.html` to be thrown. See note in class Javadoc. |

| Returns |
|---|---|
| `boolean` | 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 |
|---|---|
| `https://developer.android.com/reference/java/io/EOFException.html` | If the end of input was encountered having partially advanced (i.e. having advanced by at least one byte, but fewer than `length`), or if the end of input was encountered before advancing and `allowEndOfInput` is false. |
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs advancing the peek position. |

### getLength

```
public long getLength()
```

Returns the length of the source stream, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()` if it is unknown.

| Returns |
|---|---|
| `long` | The length of the source stream, or `https://developer.android.com/reference/androidx/media3/common/C#LENGTH_UNSET()`. |

### getPeekPosition

```
public long getPeekPosition()
```

Returns the current peek position (byte offset) in the stream.

| Returns |
|---|---|
| `long` | The peek position (byte offset) in the stream. |

### getPosition

```
public long getPosition()
```

Returns the current read position (byte offset) in the stream.

| Returns |
|---|---|
| `long` | The read position (byte offset) in the stream. |

### peek

```
public int peek(byte[] target, int offset, int length)
```

Peeks up to `length` 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 `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#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 |
|---|---|
| `byte[] target` | A target array into which data should be written. |
| `int offset` | The offset into the target array at which to write. |
| `int length` | The maximum number of bytes to peek from the input. |

| Returns |
|---|---|
| `int` | The number of bytes peeked, or `https://developer.android.com/reference/androidx/media3/common/C#RESULT_END_OF_INPUT()` if the input has ended. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs peeking from the input. |

### peekFully

```
public void peekFully(byte[] target, int offset, int length)
```

Equivalent to `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#peekFully(byte[],int,int,boolean)`.

| Parameters |
|---|---|
| `byte[] target` | A target array into which data should be written. |
| `int offset` | The offset into the target array at which to write. |
| `int length` | The number of bytes to peek from the input. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/EOFException.html` | If the end of input was encountered. |
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs peeking from the input. |

### peekFully

```
public boolean peekFully(byte[] target, int offset, int length, boolean allowEndOfInput)
```

Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#peek(byte[],int,int)`, but peeks the requested `length` in full.

| Parameters |
|---|---|
| `byte[] target` | A target array into which data should be written. |
| `int offset` | The offset into the target array at which to write. |
| `int length` | The number of bytes to peek from the input. |
| `boolean allowEndOfInput` | True if encountering the end of the input having peeked no data is allowed, and should result in `false` being returned. False if it should be considered an error, causing an `https://developer.android.com/reference/java/io/EOFException.html` to be thrown. See note in class Javadoc. |

| Returns |
|---|---|
| `boolean` | True if the peek was successful. False if `allowEndOfInput=true` and the end of the input was encountered having peeked no data. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/EOFException.html` | If the end of input was encountered having partially satisfied the peek (i.e. having peeked at least one byte, but fewer than `length`), or if no bytes were peeked and `allowEndOfInput` is false. |
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs peeking from the input. |

### read

```
public int read(byte[] buffer, int offset, int length)
```

Reads up to `length` 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.

| Parameters |
|---|---|
| `byte[] buffer` | A target array into which data should be written. |
| `int offset` | The offset into the target array at which to write. |
| `int length` | The maximum number of bytes to read from the input. |

| Returns |
|---|---|
| `int` | The number of bytes read, or `https://developer.android.com/reference/androidx/media3/common/C#RESULT_END_OF_INPUT()` if the input has ended. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs reading from the input. |

### readFully

```
public void readFully(byte[] target, int offset, int length)
```

Equivalent to `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#readFully(byte[],int,int,boolean)`.

| Parameters |
|---|---|
| `byte[] target` | A target array into which data should be written. |
| `int offset` | The offset into the target array at which to write. |
| `int length` | The number of bytes to read from the input. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/EOFException.html` | If the end of input was encountered. |
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs reading from the input. |

### readFully

```
public boolean readFully(byte[] target, int offset, int length, boolean allowEndOfInput)
```

Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#read(byte[],int,int)`, but reads the requested `length` in full.

| Parameters |
|---|---|
| `byte[] target` | A target array into which data should be written. |
| `int offset` | The offset into the target array at which to write. |
| `int length` | The number of bytes to read from the input. |
| `boolean allowEndOfInput` | True if encountering the end of the input having read no data is allowed, and should result in `false` being returned. False if it should be considered an error, causing an `https://developer.android.com/reference/java/io/EOFException.html` to be thrown. See note in class Javadoc. |

| Returns |
|---|---|
| `boolean` | True if the read was successful. False if `allowEndOfInput=true` and the end of the input was encountered having read no data. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/EOFException.html` | If the end of input was encountered having partially satisfied the read (i.e. having read at least one byte, but fewer than `length`), or if no bytes were read and `allowEndOfInput` is false. |
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs reading from the input. |

### resetPeekPosition

```
public void resetPeekPosition()
```

Resets the peek position to equal the current read position.

### setRetryPosition

```
public void <E extends Throwable> setRetryPosition(long position, E e)
```

Called when reading fails and the required retry position is different from the last position. After setting the retry position it throws the given `https://developer.android.com/reference/java/lang/Throwable.html`.

| Parameters |
|---|---|
| `<E extends https://developer.android.com/reference/java/lang/Throwable.html>` | Type of `https://developer.android.com/reference/java/lang/Throwable.html` to be thrown. |
| `long position` | The required retry position. |
| `E e` | `https://developer.android.com/reference/java/lang/Throwable.html` to be thrown. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#setRetryPosition(long,E)` | The given `https://developer.android.com/reference/java/lang/Throwable.html` object. |
| `https://developer.android.com/reference/androidx/media3/extractor/ForwardingExtractorInput#setRetryPosition(long,E)` |   |

### skip

```
public int skip(int length)
```

Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#read(byte[],int,int)`, except the data is skipped instead of read.

| Parameters |
|---|---|
| `int length` | The maximum number of bytes to skip from the input. |

| Returns |
|---|---|
| `int` | The number of bytes skipped, or `https://developer.android.com/reference/androidx/media3/common/C#RESULT_END_OF_INPUT()` if the input has ended. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs reading from the input. |

### skipFully

```
public void skipFully(int length)
```

Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#readFully(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 `https://developer.android.com/reference/java/io/EOFException.html` being thrown.

| Parameters |
|---|---|
| `int length` | The number of bytes to skip from the input. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/EOFException.html` | If the end of input was encountered. |
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs reading from the input. |

### skipFully

```
public boolean skipFully(int length, boolean allowEndOfInput)
```

Like `https://developer.android.com/reference/androidx/media3/extractor/ExtractorInput#readFully(byte[],int,int,boolean)`, except the data is skipped instead of read.

| Parameters |
|---|---|
| `int length` | The number of bytes to skip from the input. |
| `boolean allowEndOfInput` | True if encountering the end of the input having skipped no data is allowed, and should result in `false` being returned. False if it should be considered an error, causing an `https://developer.android.com/reference/java/io/EOFException.html` to be thrown. See note in class Javadoc. |

| Returns |
|---|---|
| `boolean` | True if the skip was successful. False if `allowEndOfInput=true` and the end of the input was encountered having skipped no data. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/io/EOFException.html` | If the end of input was encountered having partially satisfied the skip (i.e. having skipped at least one byte, but fewer than `length`), or if no bytes were skipped and `allowEndOfInput` is false. |
| `https://developer.android.com/reference/java/io/IOException.html` | If an error occurs reading from the input. |