ElementaryStreamReader


@UnstableApi
public interface ElementaryStreamReader

Known direct subclasses
Ac3Reader

Parses a continuous (E-)AC-3 byte stream and extracts individual samples.

Ac4Reader

Parses a continuous AC-4 byte stream and extracts individual samples.

AdtsReader

Parses a continuous ADTS byte stream and extracts individual frames.

DtsReader

Parses a continuous DTS or DTS UHD byte stream and extracts individual samples.

DvbSubtitleReader

Parses DVB subtitle data and extracts individual frames.

H262Reader

Parses a continuous H262 byte stream and extracts individual frames.

H263Reader

Parses an ISO/IEC 14496-2 (MPEG-4 Part 2) or ITU-T Recommendation H.263 byte stream and extracts individual frames.

H264Reader

Parses a continuous H264 byte stream and extracts individual frames.

H265Reader

Parses a continuous H.265 byte stream and extracts individual frames.

Id3Reader

Parses ID3 data and extracts individual text information frames.

LatmReader

Parses and extracts samples from an AAC/LATM elementary stream.

MpegAudioReader

Parses a continuous MPEG Audio byte stream and extracts individual frames.

MpeghReader

Parses a continuous MPEG-H audio byte stream and extracts MPEG-H frames.


Extracts individual samples from an elementary media stream, preserving original order.

The expected sequence of method calls is as follows:

  1. createTracks (once at initialization)
  2. seek (optional, to reset the state)
  3. packetStarted (to signal the start of a new packet)
  4. consume (zero or more times, to provide packet data)
  5. packetFinished (to signal the end of the current packet)
  6. Repeat steps 3-5 for subsequent packets

Summary

Public methods

abstract void

Consumes (possibly partial) data from the current packet.

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

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

abstract void
packetFinished(boolean isEndOfInput)

Called when a packet ends.

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

Called when a packet starts.

abstract void

Notifies the reader that a seek has occurred.

Public methods

consume

abstract 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

abstract 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

abstract void packetFinished(boolean isEndOfInput)

Called when a packet ends.

packetStarted

abstract 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

abstract void seek()

Notifies the reader that a seek has occurred.