# DefaultTsPayloadReaderFactory

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

*** ** * ** ***


```
@UnstableApi
public final class DefaultTsPayloadReaderFactory implements TsPayloadReader.Factory
```

<br />

*** ** * ** ***

Default `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.Factory` implementation.

## Summary

| ### Nested types |
|---|
| `@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/DefaultTsPayloadReaderFactory.Flags` Flags controlling elementary stream readers' behavior. |

| ### Constants |
|---|---|
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#FLAG_ALLOW_NON_IDR_KEYFRAMES() = 1` When extracting H.264 samples, whether to treat samples consisting of non-IDR I slices as synchronization samples (key-frames). |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#FLAG_DETECT_ACCESS_UNITS() = 8` When extracting H.264 samples, whether to split the input stream into access units (samples) based on slice headers. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS() = 64` Sets whether HDMV DTS audio streams will be handled. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#FLAG_IGNORE_AAC_STREAM() = 2` Prevents the creation of `https://developer.android.com/reference/androidx/media3/extractor/ts/AdtsReader` and `https://developer.android.com/reference/androidx/media3/extractor/ts/LatmReader` instances. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#FLAG_IGNORE_H264_STREAM() = 4` Prevents the creation of `https://developer.android.com/reference/androidx/media3/extractor/ts/H264Reader` instances. |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#FLAG_IGNORE_SPLICE_INFO_STREAM() = 16` Prevents the creation of `https://developer.android.com/reference/androidx/media3/extractor/ts/SectionPayloadReader`s for splice information sections (SCTE-35). |
| `static final int` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#FLAG_OVERRIDE_CAPTION_DESCRIPTORS() = 32` Whether the list of `closedCaptionFormats` passed to `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#DefaultTsPayloadReaderFactory(int,java.util.List<androidx.media3.common.Format>)` should be used in spite of any closed captions service descriptors. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#DefaultTsPayloadReaderFactory()()` |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#DefaultTsPayloadReaderFactory(int)( @https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory.Flags int flags )` |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#DefaultTsPayloadReaderFactory(int,java.util.List<androidx.media3.common.Format>)( @https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory.Flags int flags, https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Format> closedCaptionFormats )` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/android/util/SparseArray.html<https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader>` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#createInitialPayloadReaders()()` Returns the initial mapping from PIDs to payload readers. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader` | `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#createPayloadReader(int,androidx.media3.extractor.ts.TsPayloadReader.EsInfo)(int streamType, https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.EsInfo esInfo)` Returns a `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader` for a given stream type and elementary stream information. |

## Constants

### FLAG_ALLOW_NON_IDR_KEYFRAMES

```
public static final int FLAG_ALLOW_NON_IDR_KEYFRAMES = 1
```

When extracting H.264 samples, whether to treat samples consisting of non-IDR I slices as synchronization samples (key-frames).

### FLAG_DETECT_ACCESS_UNITS

```
public static final int FLAG_DETECT_ACCESS_UNITS = 8
```

When extracting H.264 samples, whether to split the input stream into access units (samples) based on slice headers. This flag should be disabled if the stream contains access unit delimiters (AUDs).

### FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS

```
public static final int FLAG_ENABLE_HDMV_DTS_AUDIO_STREAMS = 64
```

Sets whether HDMV DTS audio streams will be handled. If this flag is set, SCTE subtitles will not be detected, as they share the same elementary stream type as HDMV DTS.

### FLAG_IGNORE_AAC_STREAM

```
public static final int FLAG_IGNORE_AAC_STREAM = 2
```

Prevents the creation of `https://developer.android.com/reference/androidx/media3/extractor/ts/AdtsReader` and `https://developer.android.com/reference/androidx/media3/extractor/ts/LatmReader` instances. This flag should be enabled if the transport stream contains no packets for an AAC elementary stream that is declared in the PMT.

### FLAG_IGNORE_H264_STREAM

```
public static final int FLAG_IGNORE_H264_STREAM = 4
```

Prevents the creation of `https://developer.android.com/reference/androidx/media3/extractor/ts/H264Reader` instances. This flag should be enabled if the transport stream contains no packets for an H.264 elementary stream that is declared in the PMT.

### FLAG_IGNORE_SPLICE_INFO_STREAM

```
public static final int FLAG_IGNORE_SPLICE_INFO_STREAM = 16
```

Prevents the creation of `https://developer.android.com/reference/androidx/media3/extractor/ts/SectionPayloadReader`s for splice information sections (SCTE-35).

### FLAG_OVERRIDE_CAPTION_DESCRIPTORS

```
public static final int FLAG_OVERRIDE_CAPTION_DESCRIPTORS = 32
```

Whether the list of `closedCaptionFormats` passed to `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#DefaultTsPayloadReaderFactory(int,java.util.List<androidx.media3.common.Format>)` should be used in spite of any closed captions service descriptors. If this flag is disabled, `
closedCaptionFormats` will be ignored if the PMT contains closed captions service descriptors.

## Public constructors

### DefaultTsPayloadReaderFactory

```
public DefaultTsPayloadReaderFactory()
```

### DefaultTsPayloadReaderFactory

```
public DefaultTsPayloadReaderFactory(
    @DefaultTsPayloadReaderFactory.Flags int flags
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory.Flags int flags` | A combination of `FLAG_*` values that control the behavior of the created readers. |

### DefaultTsPayloadReaderFactory

```
public DefaultTsPayloadReaderFactory(
    @DefaultTsPayloadReaderFactory.Flags int flags,
    List<Format> closedCaptionFormats
)
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory.Flags int flags` | A combination of `FLAG_*` values that control the behavior of the created readers. |
| `https://developer.android.com/reference/java/util/List.html<https://developer.android.com/reference/androidx/media3/common/Format> closedCaptionFormats` | `https://developer.android.com/reference/androidx/media3/common/Format`s to be exposed by payload readers for streams with embedded closed captions when no caption service descriptors are provided. If `https://developer.android.com/reference/androidx/media3/extractor/ts/DefaultTsPayloadReaderFactory#FLAG_OVERRIDE_CAPTION_DESCRIPTORS()` is set, `closedCaptionFormats` overrides any descriptor information. If not set, and `closedCaptionFormats` is empty, a closed caption track with `https://developer.android.com/reference/androidx/media3/common/Format#accessibilityChannel()``https://developer.android.com/reference/androidx/media3/common/Format#NO_VALUE()` will be exposed. |

## Public methods

### createInitialPayloadReaders

```
public SparseArray<TsPayloadReader> createInitialPayloadReaders()
```

Returns the initial mapping from PIDs to payload readers.

This method allows the injection of payload readers for reserved PIDs, excluding PID 0.

| Returns |
|---|---|
| `https://developer.android.com/reference/android/util/SparseArray.html<https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader>` | A `https://developer.android.com/reference/android/util/SparseArray.html` that maps PIDs to payload readers. |

### createPayloadReader

```
public @Nullable TsPayloadReader createPayloadReader(int streamType, TsPayloadReader.EsInfo esInfo)
```

Returns a `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader` for a given stream type and elementary stream information. May return null if the stream type is not supported.

| Parameters |
|---|---|
| `int streamType` | Stream type value as defined in the PMT entry or associated descriptors. |
| `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader.EsInfo esInfo` | Information associated to the elementary stream provided in the PMT. |

| Returns |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader` | A `https://developer.android.com/reference/androidx/media3/extractor/ts/TsPayloadReader` for the packet stream carried by the provided pid, or `null` if the stream is not supported. |