# 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
class FakeTrackOutput : TrackOutput, Dumper.Dumpable
```

<br />

*** ** * ** ***

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

## Summary

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

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

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput#FakeTrackOutput(int,boolean)( @https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType type: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, deduplicateConsecutiveFormats: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html )` |

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

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput#durationUs()` |
| `https://developer.android.com/reference/kotlin/androidx/media3/common/Format?` | `https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput#lastFormat()` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `@https://developer.android.com/reference/kotlin/androidx/media3/common/C.TrackType https://developer.android.com/reference/kotlin/androidx/media3/test/utils/FakeTrackOutput#type()` |

### Inherited Constants

From [androidx.media3.extractor.TrackOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput) `const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#SAMPLE_DATA_PART_ENCRYPTION() = 1`

Sample encryption data.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#SAMPLE_DATA_PART_MAIN() = 0`

Main media sample data.
`const https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#SAMPLE_DATA_PART_SUPPLEMENTAL() = 2`

Sample supplemental data.

### Inherited functions

From [androidx.media3.extractor.TrackOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int)(data: https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray!, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Equivalent to `https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int,int)` sampleData(data, length, SAMPLE_DATA_PART_MAIN)}.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` `https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean)(input: https://developer.android.com/reference/kotlin/androidx/media3/common/DataReader!, length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, allowEndOfInput: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

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

## Constants

### DEFAULT_FACTORY

```
const val DEFAULT_FACTORY: FakeTrackOutput.Factory!
```

## Public constructors

### FakeTrackOutput

```
FakeTrackOutput(
    @C.TrackType type: Int,
    deduplicateConsecutiveFormats: Boolean
)
```

## Public functions

### assertSample

```
fun assertSample(
    index: Int,
    data: ByteArray<Byte>!,
    timeUs: Long,
    flags: Int,
    cryptoData: TrackOutput.CryptoData?
): Unit
```

### assertSampleCount

```
fun assertSampleCount(count: Int): Unit
```

### clear

```
fun clear(): Unit
```

### dump

```
fun dump(dumper: Dumper!): Unit
```

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

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

### durationUs

```
fun durationUs(durationUs: Long): Unit
```

Called to set the duration of the track in microseconds.

| Parameters |
|---|---|
| `durationUs: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` | The duration of the track in microseconds. |

### format

```
fun format(format: Format!): Unit
```

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

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

### getSampleCount

```
fun getSampleCount(): Int
```

### getSampleCryptoData

```
fun getSampleCryptoData(index: Int): TrackOutput.CryptoData?
```

### getSampleData

```
fun getSampleData(index: Int): Array<Byte>!
```

### getSampleFlags

```
fun getSampleFlags(index: Int): Int
```

### getSampleTimeUs

```
fun getSampleTimeUs(index: Int): Long
```

### getSampleTimesUs

```
fun getSampleTimesUs(): ImmutableList<Long!>!
```

### sampleData

```
fun sampleData(
    data: ParsableByteArray!,
    length: Int,
    @TrackOutput.SampleDataPart sampleDataPart: Int
): Unit
```

Called to write sample data to the output.

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

### sampleData

```
fun sampleData(
    input: DataReader!,
    length: Int,
    allowEndOfInput: Boolean,
    @TrackOutput.SampleDataPart sampleDataPart: Int
): Int
```

Called to write sample data to the output.

| Parameters |
|---|---|
| `input: https://developer.android.com/reference/kotlin/androidx/media3/common/DataReader!` | A `https://developer.android.com/reference/kotlin/androidx/media3/common/DataReader` from which to read the sample data. |
| `length: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The maximum length to read from the input. |
| `allowEndOfInput: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | True if encountering the end of the input having read no data is allowed, and should result in `https://developer.android.com/reference/kotlin/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/kotlin/androidx/media3/extractor/TrackOutput.SampleDataPart sampleDataPart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The part of the sample data to which this call corresponds. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The number of bytes appended. |

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

### sampleMetadata

```
fun sampleMetadata(
    timeUs: Long,
    @C.BufferFlags flags: Int,
    size: Int,
    offset: Int,
    cryptoData: TrackOutput.CryptoData?
): Unit
```

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/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean)` or `https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int)`.

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

## Public properties

### durationUs

```
val durationUs: Long
```

### lastFormat

```
val lastFormat: Format?
```

### type

```
@C.TrackType
val type: Int
```