Commit 5ebb3d44 by olly Committed by Oliver Woodman

Correct allowTimeBeyondBuffer values for skipToKeyframeBefore calls

The only case where we should pass false is if we want to know
whether the passed time is within the buffered media. This is
relevant within seekTo implementations only.

This is related to (but does not fix) issue #2582

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=151315676
parent abcd177e
......@@ -229,20 +229,6 @@ public final class DefaultTrackOutput implements TrackOutput {
/**
* Attempts to skip to the keyframe before or at the specified time. Succeeds only if the buffer
* contains a keyframe with a timestamp of {@code timeUs} or earlier, and if {@code timeUs} falls
* within the currently buffered media.
* <p>
* This method is equivalent to {@code skipToKeyframeBefore(timeUs, false)}.
*
* @param timeUs The seek time.
* @return Whether the skip was successful.
*/
public boolean skipToKeyframeBefore(long timeUs) {
return skipToKeyframeBefore(timeUs, false);
}
/**
* Attempts to skip to the keyframe before or at the specified time. Succeeds only if the buffer
* contains a keyframe with a timestamp of {@code timeUs} or earlier. If
* {@code allowTimeBeyondBuffer} is {@code false} then it is also required that {@code timeUs}
* falls within the buffer.
......
......@@ -301,7 +301,7 @@ import java.io.IOException;
boolean seekInsideBuffer = !isPendingReset();
for (int i = 0; seekInsideBuffer && i < trackCount; i++) {
if (trackEnabledStates[i]) {
seekInsideBuffer = sampleQueues.valueAt(i).skipToKeyframeBefore(positionUs);
seekInsideBuffer = sampleQueues.valueAt(i).skipToKeyframeBefore(positionUs, false);
}
}
// If we failed to seek within the sample queues, we need to restart.
......@@ -340,6 +340,10 @@ import java.io.IOException;
loadingFinished, lastSeekPositionUs);
}
/* package */ void skipToKeyframeBefore(int track, long timeUs) {
sampleQueues.valueAt(track).skipToKeyframeBefore(timeUs, true);
}
// Loader.Callback implementation.
@Override
......@@ -566,7 +570,7 @@ import java.io.IOException;
@Override
public void skipToKeyframeBefore(long timeUs) {
sampleQueues.valueAt(track).skipToKeyframeBefore(timeUs);
ExtractorMediaPeriod.this.skipToKeyframeBefore(track, timeUs);
}
}
......
......@@ -193,7 +193,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
// TODO: For this to work correctly, the embedded streams must not discard anything from their
// sample queues beyond the current read position of the primary stream.
for (DefaultTrackOutput embeddedSampleQueue : embeddedSampleQueues) {
embeddedSampleQueue.skipToKeyframeBefore(positionUs);
embeddedSampleQueue.skipToKeyframeBefore(positionUs, true);
}
} else {
// We failed, and need to restart.
......@@ -252,7 +252,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
@Override
public void skipToKeyframeBefore(long timeUs) {
primarySampleQueue.skipToKeyframeBefore(timeUs);
primarySampleQueue.skipToKeyframeBefore(timeUs, true);
}
// Loader.Callback implementation.
......@@ -449,7 +449,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
@Override
public void skipToKeyframeBefore(long timeUs) {
sampleQueue.skipToKeyframeBefore(timeUs);
sampleQueue.skipToKeyframeBefore(timeUs, true);
}
@Override
......
......@@ -313,7 +313,7 @@ import java.util.LinkedList;
}
/* package */ void skipToKeyframeBefore(int group, long timeUs) {
sampleQueues.valueAt(group).skipToKeyframeBefore(timeUs);
sampleQueues.valueAt(group).skipToKeyframeBefore(timeUs, true);
}
private boolean finishedReadingChunk(HlsMediaChunk chunk) {
......
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