Commit 164d8b42 by Oliver Woodman

Rework application of Mpd.Location + fix test.

parent 04d6672e
......@@ -298,10 +298,6 @@ public class DashChunkSource implements ChunkSource {
if (finishedCurrentManifest && (android.os.SystemClock.elapsedRealtime()
> manifestFetcher.getManifestLoadTimestamp() + minUpdatePeriod)) {
String newManifestURL = currentManifest.location;
if (newManifestURL != null) {
manifestFetcher.updateManifestUrl(newManifestURL);
}
manifestFetcher.requestRefresh();
}
}
......@@ -592,8 +588,8 @@ public class DashChunkSource implements ChunkSource {
Period period = new Period(null, firstRepresentation.periodStartMs,
firstRepresentation.periodDurationMs, Collections.singletonList(adaptationSet));
long duration = firstRepresentation.periodDurationMs - firstRepresentation.periodStartMs;
return new MediaPresentationDescription(-1, duration, -1, false, -1, -1, null,
Collections.singletonList(period), null);
return new MediaPresentationDescription(-1, duration, -1, false, -1, -1, null, null,
Collections.singletonList(period));
}
private static class RepresentationHolder {
......
......@@ -15,13 +15,15 @@
*/
package com.google.android.exoplayer.dash.mpd;
import com.google.android.exoplayer.util.ManifestFetcher.RedirectingManifest;
import java.util.Collections;
import java.util.List;
/**
* Represents a DASH media presentation description (mpd).
*/
public class MediaPresentationDescription {
public class MediaPresentationDescription implements RedirectingManifest {
public final long availabilityStartTime;
......@@ -35,15 +37,15 @@ public class MediaPresentationDescription {
public final long timeShiftBufferDepth;
public final List<Period> periods;
public final UtcTimingElement utcTiming;
public final String location;
public final List<Period> periods;
public MediaPresentationDescription(long availabilityStartTime, long duration, long minBufferTime,
boolean dynamic, long minUpdatePeriod, long timeShiftBufferDepth, UtcTimingElement utcTiming,
List<Period> periods, String location) {
String location, List<Period> periods) {
this.availabilityStartTime = availabilityStartTime;
this.duration = duration;
this.minBufferTime = minBufferTime;
......@@ -51,8 +53,13 @@ public class MediaPresentationDescription {
this.minUpdatePeriod = minUpdatePeriod;
this.timeShiftBufferDepth = timeShiftBufferDepth;
this.utcTiming = utcTiming;
this.periods = Collections.unmodifiableList(periods);
this.location = location;
this.periods = Collections.unmodifiableList(periods);
}
@Override
public String getNextManifestUrl() {
return location;
}
}
......@@ -128,15 +128,15 @@ public class MediaPresentationDescriptionParser extends DefaultHandler
} while (!isEndTag(xpp, "MPD"));
return buildMediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs,
dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, periods, location);
dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, location, periods);
}
protected MediaPresentationDescription buildMediaPresentationDescription(
long availabilityStartTime, long durationMs, long minBufferTimeMs, boolean dynamic,
long minUpdateTimeMs, long timeShiftBufferDepthMs, UtcTimingElement utcTiming,
List<Period> periods, String location) {
String location, List<Period> periods) {
return new MediaPresentationDescription(availabilityStartTime, durationMs, minBufferTimeMs,
dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, periods, location);
dynamic, minUpdateTimeMs, timeShiftBufferDepthMs, utcTiming, location, periods);
}
protected UtcTimingElement parseUtcTiming(XmlPullParser xpp) {
......
......@@ -23,6 +23,7 @@ import com.google.android.exoplayer.upstream.UriLoadable;
import android.os.Handler;
import android.os.Looper;
import android.os.SystemClock;
import android.text.TextUtils;
import android.util.Pair;
import java.io.IOException;
......@@ -83,6 +84,20 @@ public class ManifestFetcher<T> implements Loader.Callback {
}
/**
* Interface for manifests that are able to specify that subsequent loads should use a different
* URL.
*/
public interface RedirectingManifest {
/**
* Returns the URL from which subsequent manifests should be requested, or null to continue
* using the current URL.
*/
public String getNextManifestUrl();
}
private final UriLoadable.Parser<T> parser;
private final UriDataSource uriDataSource;
private final Handler eventHandler;
......@@ -237,6 +252,14 @@ public class ManifestFetcher<T> implements Loader.Callback {
loadExceptionCount = 0;
loadException = null;
if (manifest instanceof RedirectingManifest) {
RedirectingManifest redirectingManifest = (RedirectingManifest) manifest;
String nextLocation = redirectingManifest.getNextManifestUrl();
if (!TextUtils.isEmpty(nextLocation)) {
manifestUrl = nextLocation;
}
}
notifyManifestRefreshed();
}
......
......@@ -248,7 +248,7 @@ public class DashChunkSourceTest extends InstrumentationTestCase {
long duration = (live) ? TrackRenderer.UNKNOWN_TIME_US
: firstRepresentation.periodDurationMs - firstRepresentation.periodStartMs;
return new MediaPresentationDescription(AVAILABILITY_START_TIME, duration, -1, live, -1, -1,
null, Collections.singletonList(period));
null, null, Collections.singletonList(period));
}
private static MediaPresentationDescription generateVodMpd() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment