mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
[Patch V3] Support signalling of last segment number via supplemental descriptor in mpd.
This commit is contained in:
parent
5b02f92dad
commit
5f6a7fc7f1
2 changed files with 44 additions and 20 deletions
|
|
@ -242,7 +242,7 @@ public class DashManifestParser extends DefaultHandler
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
|
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
|
||||||
segmentBase = parseSegmentList(xpp, null);
|
segmentBase = parseSegmentList(xpp, null);
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
|
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
|
||||||
segmentBase = parseSegmentTemplate(xpp, null,null);
|
segmentBase = parseSegmentTemplate(xpp, null,null,null);
|
||||||
} else {
|
} else {
|
||||||
maybeSkipTag(xpp);
|
maybeSkipTag(xpp);
|
||||||
}
|
}
|
||||||
|
|
@ -333,7 +333,8 @@ public class DashManifestParser extends DefaultHandler
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
|
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentList")) {
|
||||||
segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
|
segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
|
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
|
||||||
segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase,supplementalProperties);
|
segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase,
|
||||||
|
supplementalProperties,null);
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
|
} else if (XmlPullParserUtil.isStartTag(xpp, "InbandEventStream")) {
|
||||||
inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
|
inbandEventStreams.add(parseDescriptor(xpp, "InbandEventStream"));
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp)) {
|
} else if (XmlPullParserUtil.isStartTag(xpp)) {
|
||||||
|
|
@ -487,7 +488,7 @@ public class DashManifestParser extends DefaultHandler
|
||||||
List<Descriptor> adaptationSetRoleDescriptors,
|
List<Descriptor> adaptationSetRoleDescriptors,
|
||||||
List<Descriptor> adaptationSetAccessibilityDescriptors,
|
List<Descriptor> adaptationSetAccessibilityDescriptors,
|
||||||
SegmentBase segmentBase,
|
SegmentBase segmentBase,
|
||||||
ArrayList<Descriptor> parentSupplementalProperties)
|
ArrayList<Descriptor> adaptationSetSupplementalProperties)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
String id = xpp.getAttributeValue(null, "id");
|
String id = xpp.getAttributeValue(null, "id");
|
||||||
int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);
|
int bandwidth = parseInt(xpp, "bandwidth", Format.NO_VALUE);
|
||||||
|
|
@ -520,7 +521,7 @@ public class DashManifestParser extends DefaultHandler
|
||||||
segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
|
segmentBase = parseSegmentList(xpp, (SegmentList) segmentBase);
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
|
} else if (XmlPullParserUtil.isStartTag(xpp, "SegmentTemplate")) {
|
||||||
segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase,
|
segmentBase = parseSegmentTemplate(xpp, (SegmentTemplate) segmentBase,
|
||||||
parentSupplementalProperties);
|
adaptationSetSupplementalProperties,supplementalProperties);
|
||||||
} else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
|
} else if (XmlPullParserUtil.isStartTag(xpp, "ContentProtection")) {
|
||||||
Pair<String, SchemeData> contentProtection = parseContentProtection(xpp);
|
Pair<String, SchemeData> contentProtection = parseContentProtection(xpp);
|
||||||
if (contentProtection.first != null) {
|
if (contentProtection.first != null) {
|
||||||
|
|
@ -760,7 +761,8 @@ public class DashManifestParser extends DefaultHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SegmentTemplate parseSegmentTemplate(XmlPullParser xpp, SegmentTemplate parent,
|
protected SegmentTemplate parseSegmentTemplate(XmlPullParser xpp, SegmentTemplate parent,
|
||||||
ArrayList<Descriptor> parentSupplementalProperties)
|
ArrayList<Descriptor> adaptationSetSupplementalProperties,
|
||||||
|
ArrayList<Descriptor> representationSupplementalProperties)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
|
long timescale = parseLong(xpp, "timescale", parent != null ? parent.timescale : 1);
|
||||||
long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
|
long presentationTimeOffset = parseLong(xpp, "presentationTimeOffset",
|
||||||
|
|
@ -793,7 +795,18 @@ public class DashManifestParser extends DefaultHandler
|
||||||
|
|
||||||
return buildSegmentTemplate(initialization, timescale, presentationTimeOffset,
|
return buildSegmentTemplate(initialization, timescale, presentationTimeOffset,
|
||||||
startNumber, duration, timeline, initializationTemplate, mediaTemplate,
|
startNumber, duration, timeline, initializationTemplate, mediaTemplate,
|
||||||
parentSupplementalProperties);
|
adaptationSetSupplementalProperties,representationSupplementalProperties);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected String parseLastSegmentNumberSupplementalProperty
|
||||||
|
(List<Descriptor> supplementalProperties){
|
||||||
|
for (Descriptor descriptor : supplementalProperties) {
|
||||||
|
if (descriptor.schemeIdUri.equalsIgnoreCase
|
||||||
|
("http://dashif.org/guidelines/last-segment-number")) {
|
||||||
|
return descriptor.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected SegmentTemplate buildSegmentTemplate(
|
protected SegmentTemplate buildSegmentTemplate(
|
||||||
|
|
@ -804,16 +817,28 @@ public class DashManifestParser extends DefaultHandler
|
||||||
long duration,
|
long duration,
|
||||||
List<SegmentTimelineElement> timeline,
|
List<SegmentTimelineElement> timeline,
|
||||||
UrlTemplate initializationTemplate,
|
UrlTemplate initializationTemplate,
|
||||||
UrlTemplate mediaTemplate,ArrayList<Descriptor> supplementalProperties ) {
|
UrlTemplate mediaTemplate,ArrayList<Descriptor> adaptationSetSupplementalProperties,
|
||||||
|
ArrayList<Descriptor> representationSupplementalProperties ) {
|
||||||
|
|
||||||
if (supplementalProperties != null) {
|
if (representationSupplementalProperties != null) {
|
||||||
for (Descriptor descriptor : supplementalProperties) {
|
if (parseLastSegmentNumberSupplementalProperty
|
||||||
if (descriptor.schemeIdUri.equalsIgnoreCase
|
(representationSupplementalProperties) != null) {
|
||||||
("http://dashif.org/guidelines/last-segment-number")) {
|
String lastSegment = parseLastSegmentNumberSupplementalProperty
|
||||||
return new SegmentTemplate(initialization, timescale, presentationTimeOffset,
|
(representationSupplementalProperties);
|
||||||
startNumber, Integer.valueOf(descriptor.value),duration, timeline,
|
return new SegmentTemplate(initialization, timescale, presentationTimeOffset,
|
||||||
initializationTemplate, mediaTemplate);
|
startNumber, Integer.valueOf(lastSegment),duration, timeline,
|
||||||
}
|
initializationTemplate, mediaTemplate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adaptationSetSupplementalProperties != null) {
|
||||||
|
if (parseLastSegmentNumberSupplementalProperty(adaptationSetSupplementalProperties) != null)
|
||||||
|
{
|
||||||
|
String lastSegment = parseLastSegmentNumberSupplementalProperty
|
||||||
|
(adaptationSetSupplementalProperties);
|
||||||
|
return new SegmentTemplate(initialization, timescale, presentationTimeOffset,
|
||||||
|
startNumber, Integer.valueOf(lastSegment),duration, timeline,
|
||||||
|
initializationTemplate, mediaTemplate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -140,7 +140,7 @@ public abstract class SegmentBase {
|
||||||
* division of this value and {@code timescale}.
|
* division of this value and {@code timescale}.
|
||||||
* @param startNumber The sequence number of the first segment.
|
* @param startNumber The sequence number of the first segment.
|
||||||
* @param endNumber The sequence number of the last segment specified by SupplementalProperty
|
* @param endNumber The sequence number of the last segment specified by SupplementalProperty
|
||||||
* schemeIdUri="http://dashif.org/guidelines/last-segment-number"
|
* schemeIdUri="http://dashif.org/guidelines/last-segment-number"
|
||||||
* @param duration The duration of each segment in the case of fixed duration segments. The
|
* @param duration The duration of each segment in the case of fixed duration segments. The
|
||||||
* value in seconds is the division of this value and {@code timescale}. If {@code
|
* value in seconds is the division of this value and {@code timescale}. If {@code
|
||||||
* segmentTimeline} is non-null then this parameter is ignored.
|
* segmentTimeline} is non-null then this parameter is ignored.
|
||||||
|
|
@ -408,10 +408,10 @@ public abstract class SegmentBase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSegmentCount(long periodDurationUs) {
|
public int getSegmentCount(long periodDurationUs) {
|
||||||
if( endNumber != C.INDEX_UNSET) {
|
if (segmentTimeline != null) {
|
||||||
return endNumber;
|
|
||||||
} else if (segmentTimeline != null) {
|
|
||||||
return segmentTimeline.size();
|
return segmentTimeline.size();
|
||||||
|
} else if (endNumber != C.INDEX_UNSET) {
|
||||||
|
return endNumber - (int) startNumber + 1;
|
||||||
} else if (periodDurationUs != C.TIME_UNSET) {
|
} else if (periodDurationUs != C.TIME_UNSET) {
|
||||||
long durationUs = (duration * C.MICROS_PER_SECOND) / timescale;
|
long durationUs = (duration * C.MICROS_PER_SECOND) / timescale;
|
||||||
return (int) Util.ceilDivide(periodDurationUs, durationUs);
|
return (int) Util.ceilDivide(periodDurationUs, durationUs);
|
||||||
|
|
@ -419,7 +419,6 @@ public abstract class SegmentBase {
|
||||||
return DashSegmentIndex.INDEX_UNBOUNDED;
|
return DashSegmentIndex.INDEX_UNBOUNDED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue