Be robust against manifests that don't define top level duration explicitly.

I think such manifests are invalid, and I haven't seen any examples,
but given it's trivial to fill in the duration if the periods define
durations, it seems worth being robust.
This commit is contained in:
Oliver Woodman 2015-09-01 14:19:06 +01:00
parent 2f4c96781d
commit fae6c65367

View File

@ -144,6 +144,16 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
}
} while (!isEndTag(xpp, "MPD"));
if (!dynamic && durationMs == -1) {
// The manifest is static and doesn't define a duration. This is unexpected.
if (nextPeriodStartMs != -1) {
// If we know the end time of the final period, we can use it as the duration.
durationMs = nextPeriodStartMs;
} else {
throw new ParserException("Unable to determine duration of static manifest.");
}
}
return buildMediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs,
dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, location, periods);
}