@UnstableApi
public final class DvbParser implements SubtitleParser


A SubtitleParser for DVB subtitles.

Summary

Constants

static final int

The CueReplacementBehavior for consecutive CuesWithTiming emitted by this implementation.

Public constructors

DvbParser(List<byte[]> initializationData)

Constructs an instance for the given initialization data.

Public methods

int

Returns the CueReplacementBehavior for consecutive CuesWithTiming emitted by this implementation.

void
parse(
    byte[] data,
    int offset,
    int length,
    SubtitleParser.OutputOptions outputOptions,
    Consumer<CuesWithTiming> output
)

Parses data (and any data stored from previous invocations) and emits any resulting complete CuesWithTiming instances via output.

void

Clears any data stored inside this parser from previous parse calls.

Inherited methods

From androidx.media3.extractor.text.SubtitleParser
void
parse(
    byte[] data,
    SubtitleParser.OutputOptions outputOptions,
    Consumer<CuesWithTiming> output
)

Parses data (and any data stored from previous invocations) and emits resulting instances.

Subtitle
parseToLegacySubtitle(byte[] data, int offset, int length)

Parses data to a legacy Subtitle instance.

Constants

CUE_REPLACEMENT_BEHAVIOR

@Format.CueReplacementBehavior
public static final int CUE_REPLACEMENT_BEHAVIOR = 2

The CueReplacementBehavior for consecutive CuesWithTiming emitted by this implementation.

Public constructors

DvbParser

public DvbParser(List<byte[]> initializationData)

Constructs an instance for the given initialization data.

Parameters
List<byte[]> initializationData

The initialization data for the parser. It must consist of a single byte array containing 4 bytes: composition_page (2) and ancillary_page (2).

Public methods

getCueReplacementBehavior

@Format.CueReplacementBehavior
public int getCueReplacementBehavior()

Returns the CueReplacementBehavior for consecutive CuesWithTiming emitted by this implementation.

A given instance must always return the same value from this method.

parse

public void parse(
    byte[] data,
    int offset,
    int length,
    SubtitleParser.OutputOptions outputOptions,
    Consumer<CuesWithTiming> output
)

Parses data (and any data stored from previous invocations) and emits any resulting complete CuesWithTiming instances via output.

Any samples not used from data will be persisted and used during subsequent calls to this method.

startTimeUs in an emitted instance is derived only from the provided sample data, so has to be considered together with any relevant subsampleOffsetUs. If the provided sample doesn't contain any timing information then at most one CuesWithTiming instance will be emitted, with startTimeUs set to TIME_UNSET, in which case subsampleOffsetUsmust be OFFSET_SAMPLE_RELATIVE.

Parameters
byte[] data

The subtitle data to parse. This must contain only complete samples. For subtitles muxed inside a media container, a sample is usually defined by the container. For subtitles read from a text file, a sample is usually the entire contents of the text file.

int offset

The index in data to start reading from (inclusive).

int length

The number of bytes to read from data.

SubtitleParser.OutputOptions outputOptions

Options to control how instances are emitted to output.

Consumer<CuesWithTiming> output

A consumer for CuesWithTiming instances emitted by this method. All calls will be made on the thread that called this method, and will be completed before this method returns.

reset

public void reset()

Clears any data stored inside this parser from previous parse calls.

This must be called after a seek or other similar discontinuity in the source data.

The default implementation is a no-op.