DashManifestParser


@UnstableApi
public class DashManifestParser extends DefaultHandler implements ParsingLoadable.Parser


A parser of media presentation description files.

Summary

Nested types

A parsed Representation element.

Public constructors

Public methods

static void

If the provided XmlPullParser is currently positioned at the start of a tag, skips forward to the end of that tag.

DashManifest
parse(Uri uri, InputStream inputStream)

Parses an object from a response.

Protected methods

AdaptationSet
buildAdaptationSet(
    long id,
    @C.TrackType int contentType,
    List<Representation> representations,
    List<Descriptor> accessibilityDescriptors,
    List<Descriptor> essentialProperties,
    List<Descriptor> supplementalProperties
)
EventMessage
buildEvent(
    String schemeIdUri,
    String value,
    long id,
    long durationMs,
    byte[] messageData
)
EventStream
buildEventStream(
    String schemeIdUri,
    String value,
    long timescale,
    long[] presentationTimesUs,
    EventMessage[] events
)
Format
buildFormat(
    @Nullable String id,
    @Nullable String containerMimeType,
    int width,
    int height,
    float frameRate,
    int audioChannels,
    int audioSamplingRate,
    int bitrate,
    @Nullable String language,
    List<Descriptor> roleDescriptors,
    List<Descriptor> accessibilityDescriptors,
    @Nullable String codecs,
    @Nullable String supplementalCodecs,
    @Nullable String supplementalProfiles,
    List<Descriptor> essentialProperties,
    List<Descriptor> supplementalProperties
)
DashManifest
buildMediaPresentationDescription(
    long availabilityStartTime,
    long durationMs,
    long minBufferTimeMs,
    boolean dynamic,
    long minUpdateTimeMs,
    long timeShiftBufferDepthMs,
    long suggestedPresentationDelayMs,
    long publishTimeMs,
    @Nullable ProgramInformation programInformation,
    @Nullable UtcTimingElement utcTiming,
    @Nullable ServiceDescriptionElement serviceDescription,
    @Nullable Uri location,
    List<Period> periods
)
Period
buildPeriod(
    @Nullable String id,
    long startMs,
    List<AdaptationSet> adaptationSets,
    List<EventStream> eventStreams,
    @Nullable Descriptor assetIdentifier
)
RangedUri
buildRangedUri(String urlText, long rangeStart, long rangeLength)
Representation
buildRepresentation(
    DashManifestParser.RepresentationInfo representationInfo,
    @Nullable String label,
    List<Label> labels,
    @Nullable String extraDrmSchemeType,
    ArrayList<DrmInitData.SchemeData> extraDrmSchemeDatas,
    ArrayList<Descriptor> extraInbandEventStreams
)
SegmentBase.SegmentList
buildSegmentList(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    @Nullable List<SegmentBase.SegmentTimelineElement> timeline,
    long availabilityTimeOffsetUs,
    @Nullable List<RangedUri> segments,
    long timeShiftBufferDepthMs,
    long periodStartUnixTimeMs
)
SegmentBase.SegmentTemplate
buildSegmentTemplate(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long endNumber,
    long duration,
    List<SegmentBase.SegmentTimelineElement> timeline,
    long availabilityTimeOffsetUs,
    @Nullable UrlTemplate initializationTemplate,
    @Nullable UrlTemplate mediaTemplate,
    long timeShiftBufferDepthMs,
    long periodStartUnixTimeMs
)
SegmentBase.SegmentTimelineElement
buildSegmentTimelineElement(long startTime, long duration)
SegmentBase.SingleSegmentBase
buildSingleSegmentBase(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long indexStart,
    long indexLength
)
UtcTimingElement
buildUtcTimingElement(String schemeIdUri, String value)
AdaptationSet
parseAdaptationSet(
    XmlPullParser xpp,
    List<BaseUrl> parentBaseUrls,
    @Nullable SegmentBase segmentBase,
    long periodDurationMs,
    long baseUrlAvailabilityTimeOffsetUs,
    long segmentBaseAvailabilityTimeOffsetUs,
    long periodStartUnixTimeMs,
    long timeShiftBufferDepthMs,
    boolean dvbProfileDeclared
)
void

Parses a child of an AdaptationSet element.

int
long
parseAvailabilityTimeOffsetUs(
    XmlPullParser xpp,
    long parentAvailabilityTimeOffsetUs
)

Parses the availabilityTimeOffset value and returns the parsed value or the parent value if it doesn't exist.

List<BaseUrl>
parseBaseUrl(
    XmlPullParser xpp,
    List<BaseUrl> parentBaseUrls,
    boolean dvbProfileDeclared
)

Parses a BaseURL element.

static int
parseCea608AccessibilityChannel(
    List<Descriptor> accessibilityDescriptors
)
static int
parseCea708AccessibilityChannel(
    List<Descriptor> accessibilityDescriptors
)
Pair<@NullableType String, @NullableType DrmInitData.SchemeData>

Parses a ContentProtection element.

int
static long
parseDateTime(XmlPullParser xpp, String name, long defaultValue)
static Descriptor

Parses a Descriptor from an element.

static int

Parses the number of channels from the value attribute of an AudioChannelConfiguration with schemeIdUri "tag:dolby.com,2015:dash:audio_channel_configuration:2015" as defined by table A.27 in ETSI TS 103 190-2 v1.2.1.

static int

Parses the number of channels from the value attribute of an AudioChannelConfiguration with schemeIdUri "tag:dolby.com,2014:dash:audio_channel_configuration:2011" as defined by table E.5 in ETSI TS 102 366, or by the legacy schemeIdUri "urn:dolby:dash:audio_channel_configuration:2011".

static int

Parses the number of channels from the value attribute of an AudioChannelConfiguration with schemeIdUri "tag:dts.com,2014:dash:audio_channel_configuration:2012" as defined by Annex G (3.2) in ETSI TS 102 114 V1.6.1, or by the legacy schemeIdUri "urn:dts:dash:audio_channel_configuration:2012".

static int

Parses the number of channels from the value attribute of an AudioChannelConfiguration with schemeIdUri "tag:dts.com,2018:uhd:audio_channel_configuration" as defined by table B-5 in ETSI TS 103 491 v1.2.1.

static long
parseDuration(XmlPullParser xpp, String name, long defaultValue)
static String
parseEac3SupplementalProperties(
    List<Descriptor> supplementalProperties
)
Pair<LongEventMessage>
parseEvent(
    XmlPullParser xpp,
    String schemeIdUri,
    String value,
    long timescale,
    long presentationTimeOffset,
    ByteArrayOutputStream scratchOutputStream
)

Parses a single Event node in the manifest.

byte[]
parseEventObject(
    XmlPullParser xpp,
    ByteArrayOutputStream scratchOutputStream
)

Parses an event object.

EventStream

Parses a single EventStream node in the manifest.

static float
parseFloat(XmlPullParser xpp, String name, float defaultValue)
static float
parseFrameRate(XmlPullParser xpp, float defaultValue)
RangedUri
static int
parseInt(XmlPullParser xpp, String name, int defaultValue)
Label

Parses a Label element.

static long
static long
parseLong(XmlPullParser xpp, String name, long defaultValue)
DashManifest
parseMediaPresentationDescription(
    XmlPullParser xpp,
    Uri documentBaseUri
)
static int

Parses the number of channels from the value attribute of an AudioChannelConfiguration with schemeIdUri "urn:mpeg:mpegB:cicp:ChannelConfiguration", as defined by ISO 23091-3:2018 clause 6.2.

Pair<PeriodLong>
parsePeriod(
    XmlPullParser xpp,
    List<BaseUrl> parentBaseUrls,
    long defaultStartMs,
    long baseUrlAvailabilityTimeOffsetUs,
    long availabilityStartTimeMs,
    long timeShiftBufferDepthMs,
    boolean dvbProfileDeclared
)
String[]
parseProfiles(
    XmlPullParser xpp,
    String attributeName,
    String[] defaultValue
)
ProgramInformation
RangedUri
parseRangedUrl(
    XmlPullParser xpp,
    String urlAttribute,
    String rangeAttribute
)
DashManifestParser.RepresentationInfo
parseRepresentation(
    XmlPullParser xpp,
    List<BaseUrl> parentBaseUrls,
    @Nullable String adaptationSetMimeType,
    @Nullable String adaptationSetCodecs,
    @Nullable String adaptationSetSupplementalCodecs,
    @Nullable String adaptationSetSupplementalProfiles,
    int adaptationSetWidth,
    int adaptationSetHeight,
    float adaptationSetFrameRate,
    int adaptationSetAudioChannels,
    int adaptationSetAudioSamplingRate,
    @Nullable String adaptationSetLanguage,
    List<Descriptor> adaptationSetRoleDescriptors,
    List<Descriptor> adaptationSetAccessibilityDescriptors,
    List<Descriptor> adaptationSetEssentialProperties,
    List<Descriptor> adaptationSetSupplementalProperties,
    @Nullable SegmentBase segmentBase,
    long periodStartUnixTimeMs,
    long periodDurationMs,
    long baseUrlAvailabilityTimeOffsetUs,
    long segmentBaseAvailabilityTimeOffsetUs,
    long timeShiftBufferDepthMs,
    boolean dvbProfileDeclared
)
int
int
int
@C.RoleFlags
parseRoleFlagsFromProperties(
    List<Descriptor> accessibilityDescriptors
)
int
SegmentBase.SingleSegmentBase
SegmentBase.SegmentList
parseSegmentList(
    XmlPullParser xpp,
    @Nullable SegmentBase.SegmentList parent,
    long periodStartUnixTimeMs,
    long periodDurationMs,
    long baseUrlAvailabilityTimeOffsetUs,
    long segmentBaseAvailabilityTimeOffsetUs,
    long timeShiftBufferDepthMs
)
SegmentBase.SegmentTemplate
parseSegmentTemplate(
    XmlPullParser xpp,
    @Nullable SegmentBase.SegmentTemplate parent,
    List<Descriptor> adaptationSetSupplementalProperties,
    long periodStartUnixTimeMs,
    long periodDurationMs,
    long baseUrlAvailabilityTimeOffsetUs,
    long segmentBaseAvailabilityTimeOffsetUs,
    long timeShiftBufferDepthMs
)
List<SegmentBase.SegmentTimelineElement>
parseSegmentTimeline(
    XmlPullParser xpp,
    long timescale,
    long periodDurationMs
)
RangedUri
int
int
ServiceDescriptionElement
static String
parseString(XmlPullParser xpp, String name, String defaultValue)
static String
@Nullable Pair<IntegerInteger>

Parses given descriptors for thumbnail tile information.

int
@Nullable UrlTemplate
parseUrlTemplate(
    XmlPullParser xpp,
    String name,
    @Nullable UrlTemplate defaultValue
)
UtcTimingElement

Inherited methods

From org.xml.sax.helpers.DefaultHandler
void
characters(char[] ch, int start, int length)
void
void
endElement(String uri, String localName, String qName)
void
void
void
void
ignorableWhitespace(char[] ch, int start, int length)
void
notationDecl(String name, String publicId, String systemId)
void
InputSource
resolveEntity(String publicId, String systemId)
void
void
void
void
startElement(
    String uri,
    String localName,
    String qName,
    Attributes attributes
)
void
void
unparsedEntityDecl(
    String name,
    String publicId,
    String systemId,
    String notationName
)
void

Public constructors

DashManifestParser

public DashManifestParser()

Public methods

maybeSkipTag

public static void maybeSkipTag(XmlPullParser xpp)

If the provided XmlPullParser is currently positioned at the start of a tag, skips forward to the end of that tag.

Parameters
XmlPullParser xpp

The XmlPullParser.

Throws
org.xmlpull.v1.XmlPullParserException

If an error occurs parsing the stream.

java.io.IOException

If an error occurs reading the stream.

parse

public DashManifest parse(Uri uri, InputStream inputStream)

Parses an object from a response.

Parameters
Uri uri

The source Uri of the response, after any redirection.

InputStream inputStream

An InputStream from which the response data can be read.

Returns
DashManifest

The parsed object.

Throws
androidx.media3.common.ParserException

If an error occurs parsing the data.

java.io.IOException

If an error occurs reading data from the stream.

Protected methods

buildAdaptationSet

protected AdaptationSet buildAdaptationSet(
    long id,
    @C.TrackType int contentType,
    List<Representation> representations,
    List<Descriptor> accessibilityDescriptors,
    List<Descriptor> essentialProperties,
    List<Descriptor> supplementalProperties
)

buildEvent

protected EventMessage buildEvent(
    String schemeIdUri,
    String value,
    long id,
    long durationMs,
    byte[] messageData
)

buildEventStream

protected EventStream buildEventStream(
    String schemeIdUri,
    String value,
    long timescale,
    long[] presentationTimesUs,
    EventMessage[] events
)

buildFormat

protected Format buildFormat(
    @Nullable String id,
    @Nullable String containerMimeType,
    int width,
    int height,
    float frameRate,
    int audioChannels,
    int audioSamplingRate,
    int bitrate,
    @Nullable String language,
    List<Descriptor> roleDescriptors,
    List<Descriptor> accessibilityDescriptors,
    @Nullable String codecs,
    @Nullable String supplementalCodecs,
    @Nullable String supplementalProfiles,
    List<Descriptor> essentialProperties,
    List<Descriptor> supplementalProperties
)

buildMediaPresentationDescription

protected DashManifest buildMediaPresentationDescription(
    long availabilityStartTime,
    long durationMs,
    long minBufferTimeMs,
    boolean dynamic,
    long minUpdateTimeMs,
    long timeShiftBufferDepthMs,
    long suggestedPresentationDelayMs,
    long publishTimeMs,
    @Nullable ProgramInformation programInformation,
    @Nullable UtcTimingElement utcTiming,
    @Nullable ServiceDescriptionElement serviceDescription,
    @Nullable Uri location,
    List<Period> periods
)

buildPeriod

protected Period buildPeriod(
    @Nullable String id,
    long startMs,
    List<AdaptationSet> adaptationSets,
    List<EventStream> eventStreams,
    @Nullable Descriptor assetIdentifier
)

buildRangedUri

protected RangedUri buildRangedUri(String urlText, long rangeStart, long rangeLength)

buildRepresentation

protected Representation buildRepresentation(
    DashManifestParser.RepresentationInfo representationInfo,
    @Nullable String label,
    List<Label> labels,
    @Nullable String extraDrmSchemeType,
    ArrayList<DrmInitData.SchemeData> extraDrmSchemeDatas,
    ArrayList<Descriptor> extraInbandEventStreams
)

buildSegmentList

protected SegmentBase.SegmentList buildSegmentList(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long duration,
    @Nullable List<SegmentBase.SegmentTimelineElement> timeline,
    long availabilityTimeOffsetUs,
    @Nullable List<RangedUri> segments,
    long timeShiftBufferDepthMs,
    long periodStartUnixTimeMs
)

buildSegmentTemplate

protected SegmentBase.SegmentTemplate buildSegmentTemplate(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long startNumber,
    long endNumber,
    long duration,
    List<SegmentBase.SegmentTimelineElement> timeline,
    long availabilityTimeOffsetUs,
    @Nullable UrlTemplate initializationTemplate,
    @Nullable UrlTemplate mediaTemplate,
    long timeShiftBufferDepthMs,
    long periodStartUnixTimeMs
)

buildSegmentTimelineElement

protected SegmentBase.SegmentTimelineElement buildSegmentTimelineElement(long startTime, long duration)

buildSingleSegmentBase

protected SegmentBase.SingleSegmentBase buildSingleSegmentBase(
    RangedUri initialization,
    long timescale,
    long presentationTimeOffset,
    long indexStart,
    long indexLength
)

buildUtcTimingElement

protected UtcTimingElement buildUtcTimingElement(String schemeIdUri, String value)

parseAdaptationSet

protected AdaptationSet parseAdaptationSet(
    XmlPullParser xpp,
    List<BaseUrl> parentBaseUrls,
    @Nullable SegmentBase segmentBase,
    long periodDurationMs,
    long baseUrlAvailabilityTimeOffsetUs,
    long segmentBaseAvailabilityTimeOffsetUs,
    long periodStartUnixTimeMs,
    long timeShiftBufferDepthMs,
    boolean dvbProfileDeclared
)

parseAdaptationSetChild

protected void parseAdaptationSetChild(XmlPullParser xpp)

Parses a child of an AdaptationSet element.

Called for child elements that are not specifically parsed elsewhere.

Parameters
XmlPullParser xpp

The XmlPullParser from which the child should be parsed.

Throws
org.xmlpull.v1.XmlPullParserException

If an error occurs parsing the element.

java.io.IOException

If an error occurs reading the element.

parseAudioChannelConfiguration

protected int parseAudioChannelConfiguration(XmlPullParser xpp, String codecs)

parseAvailabilityTimeOffsetUs

protected long parseAvailabilityTimeOffsetUs(
    XmlPullParser xpp,
    long parentAvailabilityTimeOffsetUs
)

Parses the availabilityTimeOffset value and returns the parsed value or the parent value if it doesn't exist.

Parameters
XmlPullParser xpp

The parser from which to read.

long parentAvailabilityTimeOffsetUs

The availability time offset of a parent element in microseconds.

Returns
long

The parsed availabilityTimeOffset in microseconds.

parseBaseUrl

protected List<BaseUrlparseBaseUrl(
    XmlPullParser xpp,
    List<BaseUrl> parentBaseUrls,
    boolean dvbProfileDeclared
)

Parses a BaseURL element.

Parameters
XmlPullParser xpp

The parser from which to read.

List<BaseUrl> parentBaseUrls

The parent base URLs for resolving the parsed URLs.

boolean dvbProfileDeclared

Whether the dvb profile is declared.

Returns
List<BaseUrl>

The list of parsed and resolved URLs.

Throws
org.xmlpull.v1.XmlPullParserException

If an error occurs parsing the element.

java.io.IOException

If an error occurs reading the element.

parseCea608AccessibilityChannel

protected static int parseCea608AccessibilityChannel(
    List<Descriptor> accessibilityDescriptors
)