# FakeTrackOutput

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

*** ** * ** ***

<br />

```
@UnstableApi
public final class FakeTrackOutput implements TrackOutput, Dumper.Dumpable
```

<br />

*** ** * ** ***

A fake `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`.

## Summary

| ### Nested types |
|---|
| `public interface https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput.Factory` Factory for `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput` instances. |

| ### Constants |
|---|---|
| `static final https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput.Factory` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#DEFAULT_FACTORY()` |

| ### Public fields |
|---|---|
| `long` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#durationUs()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/common/Format` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#lastFormat()` |
| `final int` | `@https://developer.android.com/reference/androidx/media3/common/C.TrackType https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#type()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#FakeTrackOutput(int,boolean)( @https://developer.android.com/reference/androidx/media3/common/C.TrackType int type, boolean deduplicateConsecutiveFormats )` |

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#assertSample(int,byte[],long,int,androidx.media3.extractor.TrackOutput.CryptoData)( int index, byte[] data, long timeUs, int flags, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData cryptoData )` |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#assertSampleCount(int)(int count)` |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#clear()()` |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#dump(androidx.media3.test.utils.Dumper)(https://developer.android.com/reference/androidx/media3/test/utils/Dumper dumper)` Dumps the fields of the object using the `dumper`. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#durationUs(long)(long durationUs)` Called to set the duration of the track in microseconds. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#format(androidx.media3.common.Format)(https://developer.android.com/reference/androidx/media3/common/Format format)` Called when the `https://developer.android.com/reference/androidx/media3/common/Format` of the track has been extracted from the stream. |
| `long` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#getDurationUs()()` |
| `int` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#getSampleCount()()` |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#getSampleCryptoData(int)(int index)` |
| `byte[]` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#getSampleData(int)(int index)` |
| `int` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#getSampleFlags(int)(int index)` |
| `long` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#getSampleTimeUs(int)(int index)` |
| `https://guava.dev/releases/snapshot-android/api/docs/com/google/common/collect/ImmutableList.html<https://developer.android.com/reference/java/lang/Long.html>` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#getSampleTimesUs()()` |
| `int` | `@https://developer.android.com/reference/androidx/media3/common/C.TrackType https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#getType()()` |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int,int)( https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data, int length, @https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.SampleDataPart int sampleDataPart )` Called to write sample data to the output. |
| `int` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean,int)( https://developer.android.com/reference/androidx/media3/common/DataReader input, int length, boolean allowEndOfInput, @https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.SampleDataPart int sampleDataPart )` Called to write sample data to the output. |
| `void` | `https://developer.android.com/reference/androidx/media3/test/utils/FakeTrackOutput#sampleMetadata(long,int,int,int,androidx.media3.extractor.TrackOutput.CryptoData)( long timeUs, @https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flags, int size, int offset, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData cryptoData )` Called when metadata associated with a sample has been extracted from the stream. |

### Inherited Constants

From [androidx.media3.extractor.TrackOutput](https://developer.android.com/reference/androidx/media3/extractor/TrackOutput) `static final int` `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#SAMPLE_DATA_PART_ENCRYPTION() = 1`

Sample encryption data.
`static final int` `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#SAMPLE_DATA_PART_MAIN() = 0`

Main media sample data.
`static final int` `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#SAMPLE_DATA_PART_SUPPLEMENTAL() = 2`

Sample supplemental data.

### Inherited methods

From [androidx.media3.extractor.TrackOutput](https://developer.android.com/reference/androidx/media3/extractor/TrackOutput) `void` `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int)(https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data, int length)`

Equivalent to `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int,int)` sampleData(data, length, SAMPLE_DATA_PART_MAIN)}.
`int` `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean)(https://developer.android.com/reference/androidx/media3/common/DataReader input, int length, boolean allowEndOfInput)`

Equivalent to `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean,int)`.

## Constants

### DEFAULT_FACTORY

```
public static final FakeTrackOutput.Factory DEFAULT_FACTORY
```

## Public fields

### durationUs

```
public long durationUs
```

### lastFormat

```
public @Nullable Format lastFormat
```

### type

```
@C.TrackType
public final int type
```

## Public constructors

### FakeTrackOutput

```
public FakeTrackOutput(
    @C.TrackType int type,
    boolean deduplicateConsecutiveFormats
)
```

## Public methods

### assertSample

```
public void assertSample(
    int index,
    byte[] data,
    long timeUs,
    int flags,
    @Nullable TrackOutput.CryptoData cryptoData
)
```

### assertSampleCount

```
public void assertSampleCount(int count)
```

### clear

```
public void clear()
```

### dump

```
public void dump(Dumper dumper)
```

Dumps the fields of the object using the `dumper`.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/test/utils/Dumper dumper` | The `https://developer.android.com/reference/androidx/media3/test/utils/Dumper` to be used to dump fields. |

### durationUs

```
public void durationUs(long durationUs)
```

Called to set the duration of the track in microseconds.

| Parameters |
|---|---|
| `long durationUs` | The duration of the track in microseconds. |

### format

```
public void format(Format format)
```

Called when the `https://developer.android.com/reference/androidx/media3/common/Format` of the track has been extracted from the stream.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/Format format` | The extracted `https://developer.android.com/reference/androidx/media3/common/Format`. |

### getDurationUs

```
public long getDurationUs()
```

### getSampleCount

```
public int getSampleCount()
```

### getSampleCryptoData

```
public @Nullable TrackOutput.CryptoData getSampleCryptoData(int index)
```

### getSampleData

```
public byte[] getSampleData(int index)
```

### getSampleFlags

```
public int getSampleFlags(int index)
```

### getSampleTimeUs

```
public long getSampleTimeUs(int index)
```

### getSampleTimesUs

```
public ImmutableList<Long> getSampleTimesUs()
```

### getType

```
@C.TrackType
public int getType()
```

### sampleData

```
public void sampleData(
    ParsableByteArray data,
    int length,
    @TrackOutput.SampleDataPart int sampleDataPart
)
```

Called to write sample data to the output.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data` | A `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray` from which to read the sample data. |
| `int length` | The number of bytes to read, starting from `data.getPosition()`. |
| `@https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.SampleDataPart int sampleDataPart` | The part of the sample data to which this call corresponds. |

### sampleData

```
public int sampleData(
    DataReader input,
    int length,
    boolean allowEndOfInput,
    @TrackOutput.SampleDataPart int sampleDataPart
)
```

Called to write sample data to the output.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/DataReader input` | A `https://developer.android.com/reference/androidx/media3/common/DataReader` from which to read the sample data. |
| `int length` | The maximum length 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 `https://developer.android.com/reference/androidx/media3/common/C#RESULT_END_OF_INPUT()` being returned. False if it should be considered an error, causing an `https://developer.android.com/reference/java/io/EOFException.html` to be thrown. |
| `@https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.SampleDataPart int sampleDataPart` | The part of the sample data to which this call corresponds. |

| Returns |
|---|---|
| `int` | The number of bytes appended. |

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

### sampleMetadata

```
public void sampleMetadata(
    long timeUs,
    @C.BufferFlags int flags,
    int size,
    int offset,
    @Nullable TrackOutput.CryptoData cryptoData
)
```

Called when metadata associated with a sample has been extracted from the stream.

The corresponding sample data will have already been passed to the output via calls to `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean)` or `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int)`.

| Parameters |
|---|---|
| `long timeUs` | The media timestamp associated with the sample, in microseconds. |
| `@https://developer.android.com/reference/androidx/media3/common/C.BufferFlags int flags` | Flags associated with the sample. See `C.BUFFER_FLAG_*`. |
| `int size` | The size of the sample data, in bytes. |
| `int offset` | The number of bytes that have been passed to `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean)` or `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int)` since the last byte belonging to the sample whose metadata is being passed. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/TrackOutput.CryptoData cryptoData` | The encryption data required to decrypt the sample. May be null. |