Merge pull request #536 from T-Pham/dev

Fetch next Dash manifest using URL in Location directive if exists
This commit is contained in:
ojw28 2015-06-15 16:16:41 +01:00
commit 04d6672e2c
3 changed files with 15 additions and 5 deletions

View file

@ -298,6 +298,10 @@ public class DashChunkSource implements ChunkSource {
if (finishedCurrentManifest && (android.os.SystemClock.elapsedRealtime() if (finishedCurrentManifest && (android.os.SystemClock.elapsedRealtime()
> manifestFetcher.getManifestLoadTimestamp() + minUpdatePeriod)) { > manifestFetcher.getManifestLoadTimestamp() + minUpdatePeriod)) {
String newManifestURL = currentManifest.location;
if (newManifestURL != null) {
manifestFetcher.updateManifestUrl(newManifestURL);
}
manifestFetcher.requestRefresh(); manifestFetcher.requestRefresh();
} }
} }
@ -589,7 +593,7 @@ public class DashChunkSource implements ChunkSource {
firstRepresentation.periodDurationMs, Collections.singletonList(adaptationSet)); firstRepresentation.periodDurationMs, Collections.singletonList(adaptationSet));
long duration = firstRepresentation.periodDurationMs - firstRepresentation.periodStartMs; long duration = firstRepresentation.periodDurationMs - firstRepresentation.periodStartMs;
return new MediaPresentationDescription(-1, duration, -1, false, -1, -1, null, return new MediaPresentationDescription(-1, duration, -1, false, -1, -1, null,
Collections.singletonList(period)); Collections.singletonList(period), null);
} }
private static class RepresentationHolder { private static class RepresentationHolder {

View file

@ -39,9 +39,11 @@ public class MediaPresentationDescription {
public final UtcTimingElement utcTiming; public final UtcTimingElement utcTiming;
public final String location;
public MediaPresentationDescription(long availabilityStartTime, long duration, long minBufferTime, public MediaPresentationDescription(long availabilityStartTime, long duration, long minBufferTime,
boolean dynamic, long minUpdatePeriod, long timeShiftBufferDepth, UtcTimingElement utcTiming, boolean dynamic, long minUpdatePeriod, long timeShiftBufferDepth, UtcTimingElement utcTiming,
List<Period> periods) { List<Period> periods, String location) {
this.availabilityStartTime = availabilityStartTime; this.availabilityStartTime = availabilityStartTime;
this.duration = duration; this.duration = duration;
this.minBufferTime = minBufferTime; this.minBufferTime = minBufferTime;
@ -50,6 +52,7 @@ public class MediaPresentationDescription {
this.timeShiftBufferDepth = timeShiftBufferDepth; this.timeShiftBufferDepth = timeShiftBufferDepth;
this.utcTiming = utcTiming; this.utcTiming = utcTiming;
this.periods = Collections.unmodifiableList(periods); this.periods = Collections.unmodifiableList(periods);
this.location = location;
} }
} }

View file

@ -111,6 +111,7 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
long timeShiftBufferDepthMs = (dynamic) ? parseDuration(xpp, "timeShiftBufferDepth", -1) long timeShiftBufferDepthMs = (dynamic) ? parseDuration(xpp, "timeShiftBufferDepth", -1)
: -1; : -1;
UtcTimingElement utcTiming = null; UtcTimingElement utcTiming = null;
String location = null;
List<Period> periods = new ArrayList<>(); List<Period> periods = new ArrayList<>();
do { do {
@ -121,19 +122,21 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
utcTiming = parseUtcTiming(xpp); utcTiming = parseUtcTiming(xpp);
} else if (isStartTag(xpp, "Period")) { } else if (isStartTag(xpp, "Period")) {
periods.add(parsePeriod(xpp, baseUrl, durationMs)); periods.add(parsePeriod(xpp, baseUrl, durationMs));
} else if (isStartTag(xpp, "Location")) {
location = xpp.nextText();
} }
} while (!isEndTag(xpp, "MPD")); } while (!isEndTag(xpp, "MPD"));
return buildMediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs, return buildMediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs,
dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, periods); dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, periods, location);
} }
protected MediaPresentationDescription buildMediaPresentationDescription( protected MediaPresentationDescription buildMediaPresentationDescription(
long availabilityStartTime, long durationMs, long minBufferTimeMs, boolean dynamic, long availabilityStartTime, long durationMs, long minBufferTimeMs, boolean dynamic,
long minUpdateTimeMs, long timeShiftBufferDepthMs, UtcTimingElement utcTiming, long minUpdateTimeMs, long timeShiftBufferDepthMs, UtcTimingElement utcTiming,
List<Period> periods) { List<Period> periods, String location) {
return new MediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs, return new MediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs,
dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, periods); dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, periods, location);
} }
protected UtcTimingElement parseUtcTiming(XmlPullParser xpp) { protected UtcTimingElement parseUtcTiming(XmlPullParser xpp) {