@UnstableApi
class H264Reader : ElementaryStreamReader


Parses a continuous H264 byte stream and extracts individual frames.

Summary

Public constructors

H264Reader(
    seiReader: SeiReader!,
    allowNonIdrKeyframes: Boolean,
    detectAccessUnits: Boolean
)

Public functions

Unit

Consumes (possibly partial) data from the current packet.

Unit
createTracks(
    extractorOutput: ExtractorOutput!,
    idGenerator: TsPayloadReader.TrackIdGenerator!
)

Initializes the reader by providing outputs and ids for the tracks.

Unit

Called when a packet ends.

Unit

Called when a packet starts.

Unit

Notifies the reader that a seek has occurred.

Public constructors

H264Reader

H264Reader(
    seiReader: SeiReader!,
    allowNonIdrKeyframes: Boolean,
    detectAccessUnits: Boolean
)
Parameters
seiReader: SeiReader!

An SEI reader for consuming closed caption channels.

allowNonIdrKeyframes: Boolean

Whether to treat samples consisting of non-IDR I slices as synchronization samples (key-frames).

detectAccessUnits: Boolean

Whether to split the input stream into access units (samples) based on slice headers. Pass false if the stream contains access unit delimiters (AUDs).

Public functions

consume

fun consume(data: ParsableByteArray!): Unit

Consumes (possibly partial) data from the current packet.

Parameters
data: ParsableByteArray!

The data to consume.

Throws
androidx.media3.common.ParserException

If the data could not be parsed.

createTracks

fun createTracks(
    extractorOutput: ExtractorOutput!,
    idGenerator: TsPayloadReader.TrackIdGenerator!
): Unit

Initializes the reader by providing outputs and ids for the tracks.

Parameters
extractorOutput: ExtractorOutput!

The ExtractorOutput that receives the extracted data.

idGenerator: TsPayloadReader.TrackIdGenerator!

A PesReader.TrackIdGenerator that generates unique track ids for the TrackOutputs.

packetFinished

fun packetFinished(): Unit

Called when a packet ends.

packetStarted

fun packetStarted(pesTimeUs: Long, @TsPayloadReader.Flags flags: Int): Unit

Called when a packet starts.

Parameters
pesTimeUs: Long

The timestamp associated with the packet.

@TsPayloadReader.Flags flags: Int

See TsPayloadReader.Flags.

seek

fun seek(): Unit

Notifies the reader that a seek has occurred.