MediaPeriod.getDurationUs must report duration when known.

As per the spec of MediaPeriod.getDurationUs, when a live
stream ends we need to start returning the correct final
duration.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=128471183
This commit is contained in:
olly 2016-07-26 07:55:41 -07:00 committed by Oliver Woodman
parent c5aa376bc4
commit dae87b66dd
2 changed files with 3 additions and 4 deletions

View File

@ -47,7 +47,6 @@ import java.util.List;
private final EventDispatcher eventDispatcher;
private final long elapsedRealtimeOffset;
private final Loader loader;
private final long durationUs;
private final TrackGroupArray trackGroups;
private ChunkSampleStream<DashChunkSource>[] sampleStreams;
@ -55,6 +54,7 @@ import java.util.List;
private Callback callback;
private Allocator allocator;
private DashManifest manifest;
private long durationUs;
private int index;
private Period period;
@ -76,6 +76,7 @@ import java.util.List;
public void updateManifest(DashManifest manifest, int index) {
this.manifest = manifest;
this.index = index;
durationUs = manifest.dynamic ? C.UNSET_TIME_US : manifest.getPeriodDuration(index) * 1000;
period = manifest.getPeriod(index);
if (sampleStreams != null) {
for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {

View File

@ -48,7 +48,6 @@ import java.util.List;
private final Loader manifestLoader;
private final int minLoadableRetryCount;
private final EventDispatcher eventDispatcher;
private final long durationUs;
private final TrackGroupArray trackGroups;
private final TrackEncryptionBox[] trackEncryptionBoxes;
@ -65,7 +64,6 @@ import java.util.List;
this.manifestLoader = manifestLoader;
this.minLoadableRetryCount = minLoadableRetryCount;
this.eventDispatcher = eventDispatcher;
durationUs = manifest.durationUs;
trackGroups = buildTrackGroups(manifest);
ProtectionElement protectionElement = manifest.protectionElement;
if (protectionElement != null) {
@ -103,7 +101,7 @@ import java.util.List;
@Override
public long getDurationUs() {
return durationUs;
return manifest.durationUs;
}
@Override