# TsPayloadReader

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

*** ** * ** ***


```
@UnstableApi
public interface TsPayloadReader
```

<br />

Known direct subclasses [PesReader](https://developer.android.com/reference/androidx/media3/extractor/ts/PesReader), [SectionReader](https://developer.android.com/reference/androidx/media3/extractor/ts/SectionReader)

|---|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ts/PesReader` | Parses PES packet data and extracts samples. |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/SectionReader` | Reads section data packets and feeds the whole sections to a given `https://developer.android.com/reference/androidx/media3/extractor/ts/SectionPayloadReader`. |

*** ** * ** ***

Parses TS packet payload data.

## Summary

| ### Nested types |
|---|
| `public final class https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.DvbSubtitleInfo` Holds information about a DVB subtitle, as defined in ETSI EN 300 468 V1.11.1 section 6.2.41. |
| `public final class https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.EsInfo` Holds information associated with a PMT entry. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(value = ) public annotation https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.EsInfo.AudioType` The audio type of the stream, as defined by ISO/IEC 13818-1, section 2.6.18. |
| `public interface https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.Factory` Factory of `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader` instances. |
| `@https://developer.android.com/reference/java/lang/annotation/Documented.html @https://developer.android.com/reference/java/lang/annotation/Retention.html(value = https://developer.android.com/reference/java/lang/annotation/RetentionPolicy.html#SOURCE) @https://developer.android.com/reference/java/lang/annotation/Target.html(value = https://developer.android.com/reference/java/lang/annotation/ElementType.html#TYPE_USE) @https://developer.android.com/reference/androidx/annotation/IntDef(flag = true, value = ) public annotation https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.Flags` Contextual flags indicating the presence of indicators in the TS packet or PES packet headers. |
| `public final class https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.TrackIdGenerator` Generates track ids for initializing `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader`s' `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`s. |

| ### Constants |
|---|---|
| `default static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader#FLAG_DATA_ALIGNMENT_INDICATOR() = 4` Indicates the presence of the data_alignment_indicator in the PES header. |
| `default static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader#FLAG_PAYLOAD_UNIT_START_INDICATOR() = 1` Indicates the presence of the payload_unit_start_indicator in the TS packet header. |
| `default static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader#FLAG_RANDOM_ACCESS_INDICATOR() = 2` Indicates the presence of the random_access_indicator in the TS packet header adaptation field. |

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader#consume(androidx.media3.common.util.ParsableByteArray,int)(https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data, @https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.Flags int flags)` Consumes the payload of a TS packet. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader#init(androidx.media3.common.util.TimestampAdjuster,androidx.media3.extractor.ExtractorOutput,androidx.media3.extractor.ts.TsPayloadReader.TrackIdGenerator)( https://developer.android.com/reference/androidx/media3/common/util/TimestampAdjuster timestampAdjuster, https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput extractorOutput, https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.TrackIdGenerator idGenerator )` Initializes the payload reader. |
| `abstract void` | `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader#seek()()` Notifies the reader that a seek has occurred. |

## Constants

### FLAG_DATA_ALIGNMENT_INDICATOR

```
default static final int FLAG_DATA_ALIGNMENT_INDICATOR = 4
```

Indicates the presence of the data_alignment_indicator in the PES header.

### FLAG_PAYLOAD_UNIT_START_INDICATOR

```
default static final int FLAG_PAYLOAD_UNIT_START_INDICATOR = 1
```

Indicates the presence of the payload_unit_start_indicator in the TS packet header.

### FLAG_RANDOM_ACCESS_INDICATOR

```
default static final int FLAG_RANDOM_ACCESS_INDICATOR = 2
```

Indicates the presence of the random_access_indicator in the TS packet header adaptation field.

## Public methods

### consume

```
abstract void consume(ParsableByteArray data, @TsPayloadReader.Flags int flags)
```

Consumes the payload of a TS packet.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/ParsableByteArray data` | The TS packet. The position will be set to the start of the payload. |
| `@https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.Flags int flags` | See `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.Flags`. |

| Throws |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/ParserException` | If the payload could not be parsed. |

### init

```
abstract void init(
    TimestampAdjuster timestampAdjuster,
    ExtractorOutput extractorOutput,
    TsPayloadReader.TrackIdGenerator idGenerator
)
```

Initializes the payload reader.

| Parameters |
|---|---|
| `https://developer.android.com/reference/androidx/media3/common/util/TimestampAdjuster timestampAdjuster` | A timestamp adjuster for offsetting and scaling sample timestamps. |
| `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput extractorOutput` | The `https://developer.android.com/reference/androidx/media3/extractor/ExtractorOutput` that receives the extracted data. |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.TrackIdGenerator idGenerator` | A `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.TrackIdGenerator` that generates unique track ids for the `https://developer.android.com/reference/androidx/media3/extractor/TrackOutput`s. |

### seek

```
abstract void seek()
```

Notifies the reader that a seek has occurred.

Following a call to this method, the data passed to the next invocation of `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader#consume(androidx.media3.common.util.ParsableByteArray,int)` will not be a continuation of the data that was previously passed. Hence the reader should reset any internal state.