ElementaryStreamReader


@UnstableApi
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.


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 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 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.