TtmlParser
@UnstableApi
public final class TtmlParser implements SubtitleParser
A SimpleSubtitleDecoder for TTML supporting the DFXP presentation profile. Features supported by this decoder are:
- content
- core
- presentation
- profile
- structure
- time-offset
- timing
- tickRate
- time-clock-with-frames
- time-clock
- time-offset-with-frames
- time-offset-with-ticks
- cell-resolution
See the TTML specification
Summary
Constants |
|
|---|---|
static final int |
The |
Public constructors |
|---|
Public methods |
|
|---|---|
int |
Returns the |
void |
parse(Parses |
Subtitle |
parseToLegacySubtitle(byte[] data, int offset, int length)Parses |
Inherited methods |
||||
|---|---|---|---|---|
|
Constants
CUE_REPLACEMENT_BEHAVIOR
@Format.CueReplacementBehavior
public static final int CUE_REPLACEMENT_BEHAVIOR = 1
The CueReplacementBehavior for consecutive CuesWithTiming emitted by this implementation.
Public constructors
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 |
int length |
The number of bytes to read from |
SubtitleParser.OutputOptions outputOptions |
Options to control how instances are emitted to |
Consumer<CuesWithTiming> output |
A consumer for |
parseToLegacySubtitle
public Subtitle parseToLegacySubtitle(byte[] data, int offset, int length)
Parses data to a legacy Subtitle instance.
This method only exists temporarily to support the transition away from SubtitleDecoder and Subtitle. It will be removed in a future release.
The default implementation delegates to parse. Implementations can override this to provide a more efficient implementation if desired.
| 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 |
int length |
The number of bytes to read from |