# DiscardingTrackOutput

# DiscardingTrackOutput

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/DiscardingTrackOutput.java+class:androidx.media3.extractor.DiscardingTrackOutput)

*** ** * ** ***

Kotlin \|[Java](https://developer.android.com/reference/androidx/media3/extractor/DiscardingTrackOutput "View this page in Java")


```
@UnstableApi
class DiscardingTrackOutput : TrackOutput
```

<br />

*** ** * ** ***

A [TrackOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput) that consumes and discards all reported samples.

## Summary

|                                                                               ### Public constructors                                                                                |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [DiscardingTrackOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/DiscardingTrackOutput#DiscardingTrackOutput())`()` Creates discarding track output. |

|                             ### Public functions                              |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [format](https://developer.android.com/reference/kotlin/androidx/media3/extractor/DiscardingTrackOutput#format(androidx.media3.common.Format))`(format: `[Format](https://developer.android.com/reference/kotlin/androidx/media3/common/Format)`!)` Called when the [Format](https://developer.android.com/reference/kotlin/androidx/media3/common/Format) of the track has been extracted from the stream.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [sampleData](https://developer.android.com/reference/kotlin/androidx/media3/extractor/DiscardingTrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int,int))`(` ` data: `[ParsableByteArray](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray)`!,` ` length: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` @`[TrackOutput.SampleDataPart](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput.SampleDataPart)` sampleDataPart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Called to write sample data to the output.                                                                                                                                                                                                                          |
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [sampleData](https://developer.android.com/reference/kotlin/androidx/media3/extractor/DiscardingTrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean,int))`(` ` input: `[DataReader](https://developer.android.com/reference/kotlin/androidx/media3/common/DataReader)`!,` ` length: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` allowEndOfInput: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`,` ` @`[TrackOutput.SampleDataPart](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput.SampleDataPart)` sampleDataPart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) `)` Called to write sample data to the output.                                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [sampleMetadata](https://developer.android.com/reference/kotlin/androidx/media3/extractor/DiscardingTrackOutput#sampleMetadata(long,int,int,int,androidx.media3.extractor.TrackOutput.CryptoData))`(` ` timeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`,` ` @`[C.BufferFlags](https://developer.android.com/reference/kotlin/androidx/media3/common/C.BufferFlags)` flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` size: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` offset: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`,` ` cryptoData: `[TrackOutput.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. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ### Inherited Constants                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From [androidx.media3.extractor.TrackOutput](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput) |-------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SAMPLE_DATA_PART_ENCRYPTION](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#SAMPLE_DATA_PART_ENCRYPTION())` = 1` Sample encryption data.       | | `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SAMPLE_DATA_PART_MAIN](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#SAMPLE_DATA_PART_MAIN())` = 0` Main media sample data.                   | | `const `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | [SAMPLE_DATA_PART_SUPPLEMENTAL](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) |-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [durationUs](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#durationUs(long))`(durationUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)`)` Called to set the duration of the track in microseconds.                                                                                                                                                                                                                                                                                                                                                                                                                                    | | [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [sampleData](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.util.ParsableByteArray,int))`(data: `[ParsableByteArray](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray)`!, length: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Equivalent to [sampleData](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)}.                                                                                     | | [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | [sampleData](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean))`(input: `[DataReader](https://developer.android.com/reference/kotlin/androidx/media3/common/DataReader)`!, length: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, allowEndOfInput: `[Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`)` Equivalent to [sampleData(input, length, allowEndOfInput, SAMPLE_DATA_PART_MAIN)](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean,int)). | |

## Public constructors

### DiscardingTrackOutput

```
DiscardingTrackOutput()
```

Creates discarding track output.  

## Public functions

### format

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

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

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

### sampleData

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

Called to write sample data to the output.  

|                                                                                                             Parameters                                                                                                             |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `data: `[ParsableByteArray](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray)`!`                                                                                                       | A [ParsableByteArray](https://developer.android.com/reference/kotlin/androidx/media3/common/util/ParsableByteArray) from which to read the sample data. |
| `length: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                              | The number of bytes to read, starting from `data.getPosition()`.                                                                                        |
| `@`[TrackOutput.SampleDataPart](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput.SampleDataPart)` sampleDataPart: `[Int](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: `[DataReader](https://developer.android.com/reference/kotlin/androidx/media3/common/DataReader)`!`                                                                                                                         | A [DataReader](https://developer.android.com/reference/kotlin/androidx/media3/common/DataReader) from which to read the sample data.                                                                                                                                                                                                                                                      |
| `length: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                                                              | The maximum length to read from the input.                                                                                                                                                                                                                                                                                                                                                |
| `allowEndOfInput: `[Boolean](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 [RESULT_END_OF_INPUT](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 [EOFException](https://developer.android.com/reference/java/io/EOFException.html) to be thrown. |
| `@`[TrackOutput.SampleDataPart](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput.SampleDataPart)` sampleDataPart: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The part of the sample data to which this call corresponds.                                                                                                                                                                                                                                                                                                                               |

|                                   Returns                                   |
|-----------------------------------------------------------------------------|-------------------------------|
| [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The number of bytes appended. |

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

|                                                                                          Parameters                                                                                          |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `timeUs: `[Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html)                                                                                                      | The media timestamp associated with the sample, in microseconds.                                                                                                                                                                                                                                                                                                                                                                                          |
| `@`[C.BufferFlags](https://developer.android.com/reference/kotlin/androidx/media3/common/C.BufferFlags)` flags: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | Flags associated with the sample. See `C.BUFFER_FLAG_*`.                                                                                                                                                                                                                                                                                                                                                                                                  |
| `size: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                          | The size of the sample data, in bytes.                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `offset: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)                                                                                                        | The number of bytes that have been passed to [sampleData](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput#sampleData(androidx.media3.common.DataReader,int,boolean)) or [sampleData](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: `[TrackOutput.CryptoData](https://developer.android.com/reference/kotlin/androidx/media3/extractor/TrackOutput.CryptoData)`?`                                                   | The encryption data required to decrypt the sample. May be null.                                                                                                                                                                                                                                                                                                                                                                                          |