From fae6c65367c6154d15b5c99a9eeb866ee36ba568 Mon Sep 17 00:00:00 2001 From: Oliver Woodman Date: Tue, 1 Sep 2015 14:19:06 +0100 Subject: [PATCH] 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. --- .../dash/mpd/MediaPresentationDescriptionParser.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java b/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java index 1305db85ce..4d45967a43 100644 --- a/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java +++ b/library/src/main/java/com/google/android/exoplayer/dash/mpd/MediaPresentationDescriptionParser.java @@ -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); }