@UnstableApi
public final class H264Reader implements ElementaryStreamReader


Parses a continuous H264 byte stream and extracts individual frames.

Summary

Public constructors

H264Reader(
    SeiReader seiReader,
    boolean allowNonIdrKeyframes,
    boolean detectAccessUnits
)

Public methods

void

Consumes (possibly partial) data from the current packet.

void
createTracks(
    ExtractorOutput extractorOutput,
    TsPayloadReader.TrackIdGenerator idGenerator
)

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

void

Called when a packet ends.

void
packetStarted(long pesTimeUs, @TsPayloadReader.Flags int flags)

Called when a packet starts.

void

Notifies the reader that a seek has occurred.

Public constructors

H264Reader

public H264Reader(
    SeiReader seiReader,
    boolean allowNonIdrKeyframes,
    boolean detectAccessUnits
)
Parameters
SeiReader seiReader

An SEI reader for consuming closed caption channels.

boolean allowNonIdrKeyframes

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

boolean detectAccessUnits

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 methods

consume

public void consume(ParsableByteArray data)

Consumes (possibly partial) data from the current packet.

Parameters
ParsableByteArray data

The data to consume.

Throws
androidx.media3.common.ParserException

If the data could not be parsed.

createTracks

public void createTracks(
    ExtractorOutput extractorOutput,
    TsPayloadReader.TrackIdGenerator idGenerator
)

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

Parameters
ExtractorOutput extractorOutput

The ExtractorOutput that receives the extracted data.

TsPayloadReader.TrackIdGenerator idGenerator

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

packetFinished

public void packetFinished()

Called when a packet ends.

packetStarted

public void packetStarted(long pesTimeUs, @TsPayloadReader.Flags int flags)

Called when a packet starts.

Parameters
long pesTimeUs

The timestamp associated with the packet.

@TsPayloadReader.Flags int flags

See TsPayloadReader.Flags.

seek

public void seek()

Notifies the reader that a seek has occurred.