Commit a049382c by olly Committed by Oliver Woodman

Treat seeks in HLS live to be at t=0, as in ExtractorSampleSource.

This makes sense until we need to support seeking in the live window.

Issue: #676
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=112402026
parent cef0f7a0
......@@ -261,6 +261,17 @@ public class HlsChunkSource implements HlsTrackSelector.Output {
}
/**
* Returns whether this is a live playback.
* <p>
* This method should only be called after the source has been prepared.
*
* @return True if this is a live playback. False otherwise.
*/
public boolean isLive() {
return live;
}
/**
* Returns the duration of the source, or {@link C#UNKNOWN_TIME_US} if the duration is unknown.
* <p>
* This method should only be called after the source has been prepared.
......
......@@ -206,6 +206,8 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
loadControl.register(this, bufferSizeContribution);
loadControlRegistered = true;
}
// Treat enabling of a live stream as occurring at t=0 in both of the blocks below.
positionUs = chunkSource.isLive() ? 0 : positionUs;
int chunkSourceTrack = chunkSourceTrackIndices[track];
if (chunkSourceTrack != -1 && chunkSourceTrack != chunkSource.getSelectedTrackIndex()) {
// This is a primary track whose corresponding chunk source track is different to the one
......@@ -359,6 +361,8 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
public void seekToUs(long positionUs) {
Assertions.checkState(prepared);
Assertions.checkState(enabledTrackCount > 0);
// Treat all seeks into live streams as being to t=0.
positionUs = chunkSource.isLive() ? 0 : positionUs;
// Ignore seeks to the current position.
long currentPositionUs = isPendingReset() ? pendingResetPositionUs : downstreamPositionUs;
......
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