Commit c4f7a2d6 by olly Committed by Oliver Woodman

Correctly transition to ended state

This fixes transitioning into the ended state if we see
endOfStream from the chunk source whilst in the pending
reset state. Prior to this fix we'd still be pending a
reset, and so readData would never allow EOS to be read
by the consuming renderer.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=157101755
parent eb3a31c8
...@@ -336,6 +336,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S ...@@ -336,6 +336,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
nextChunkHolder.clear(); nextChunkHolder.clear();
if (endOfStream) { if (endOfStream) {
pendingResetPositionUs = C.TIME_UNSET;
loadingFinished = true; loadingFinished = true;
return true; return true;
} }
...@@ -389,18 +390,20 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S ...@@ -389,18 +390,20 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
} }
private void discardDownstreamMediaChunks(int primaryStreamReadIndex) { private void discardDownstreamMediaChunks(int primaryStreamReadIndex) {
while (mediaChunks.size() > 1 if (!mediaChunks.isEmpty()) {
&& mediaChunks.get(1).getFirstSampleIndex(0) <= primaryStreamReadIndex) { while (mediaChunks.size() > 1
mediaChunks.removeFirst(); && mediaChunks.get(1).getFirstSampleIndex(0) <= primaryStreamReadIndex) {
} mediaChunks.removeFirst();
BaseMediaChunk currentChunk = mediaChunks.getFirst(); }
Format trackFormat = currentChunk.trackFormat; BaseMediaChunk currentChunk = mediaChunks.getFirst();
if (!trackFormat.equals(primaryDownstreamTrackFormat)) { Format trackFormat = currentChunk.trackFormat;
eventDispatcher.downstreamFormatChanged(primaryTrackType, trackFormat, if (!trackFormat.equals(primaryDownstreamTrackFormat)) {
currentChunk.trackSelectionReason, currentChunk.trackSelectionData, eventDispatcher.downstreamFormatChanged(primaryTrackType, trackFormat,
currentChunk.startTimeUs); currentChunk.trackSelectionReason, currentChunk.trackSelectionData,
currentChunk.startTimeUs);
}
primaryDownstreamTrackFormat = trackFormat;
} }
primaryDownstreamTrackFormat = trackFormat;
} }
/** /**
......
...@@ -625,9 +625,9 @@ public final class DashMediaSource implements MediaSource { ...@@ -625,9 +625,9 @@ public final class DashMediaSource implements MediaSource {
private final long windowDefaultStartPositionUs; private final long windowDefaultStartPositionUs;
private final DashManifest manifest; private final DashManifest manifest;
public DashTimeline(long presentationStartTimeMs, long windowStartTimeMs, public DashTimeline(long presentationStartTimeMs, long windowStartTimeMs, int firstPeriodId,
int firstPeriodId, long offsetInFirstPeriodUs, long windowDurationUs, long offsetInFirstPeriodUs, long windowDurationUs, long windowDefaultStartPositionUs,
long windowDefaultStartPositionUs, DashManifest manifest) { DashManifest manifest) {
this.presentationStartTimeMs = presentationStartTimeMs; this.presentationStartTimeMs = presentationStartTimeMs;
this.windowStartTimeMs = windowStartTimeMs; this.windowStartTimeMs = windowStartTimeMs;
this.firstPeriodId = firstPeriodId; this.firstPeriodId = firstPeriodId;
......
...@@ -296,17 +296,19 @@ import java.util.LinkedList; ...@@ -296,17 +296,19 @@ import java.util.LinkedList;
return C.RESULT_NOTHING_READ; return C.RESULT_NOTHING_READ;
} }
while (mediaChunks.size() > 1 && finishedReadingChunk(mediaChunks.getFirst())) { if (!mediaChunks.isEmpty()) {
mediaChunks.removeFirst(); while (mediaChunks.size() > 1 && finishedReadingChunk(mediaChunks.getFirst())) {
} mediaChunks.removeFirst();
HlsMediaChunk currentChunk = mediaChunks.getFirst(); }
Format trackFormat = currentChunk.trackFormat; HlsMediaChunk currentChunk = mediaChunks.getFirst();
if (!trackFormat.equals(downstreamTrackFormat)) { Format trackFormat = currentChunk.trackFormat;
eventDispatcher.downstreamFormatChanged(trackType, trackFormat, if (!trackFormat.equals(downstreamTrackFormat)) {
currentChunk.trackSelectionReason, currentChunk.trackSelectionData, eventDispatcher.downstreamFormatChanged(trackType, trackFormat,
currentChunk.startTimeUs); currentChunk.trackSelectionReason, currentChunk.trackSelectionData,
currentChunk.startTimeUs);
}
downstreamTrackFormat = trackFormat;
} }
downstreamTrackFormat = trackFormat;
return sampleQueues.valueAt(group).readData(formatHolder, buffer, requireFormat, return sampleQueues.valueAt(group).readData(formatHolder, buffer, requireFormat,
loadingFinished, lastSeekPositionUs); loadingFinished, lastSeekPositionUs);
...@@ -348,6 +350,7 @@ import java.util.LinkedList; ...@@ -348,6 +350,7 @@ import java.util.LinkedList;
nextChunkHolder.clear(); nextChunkHolder.clear();
if (endOfStream) { if (endOfStream) {
pendingResetPositionUs = C.TIME_UNSET;
loadingFinished = true; loadingFinished = true;
return true; return true;
} }
......
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