mirror of
https://github.com/samsonjs/media.git
synced 2026-04-17 13:15:47 +00:00
'refine_to_make_flow_simpler'
This commit is contained in:
parent
cb0394b9cf
commit
2214a4c152
2 changed files with 2 additions and 29 deletions
|
|
@ -248,12 +248,7 @@ public final class DefaultTrackOutput implements TrackOutput {
|
|||
* @return Whether the skip was successful.
|
||||
*/
|
||||
public boolean skipToKeyframeBefore(long timeUs) {
|
||||
long nextOffset = infoQueue.skipToKeyframeBefore(timeUs, false);
|
||||
if (nextOffset == C.POSITION_UNSET) {
|
||||
return false;
|
||||
}
|
||||
dropDownstreamTo(nextOffset);
|
||||
return true;
|
||||
return infoQueue.skipToKeyframeBefore(timeUs, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -114,20 +114,6 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the input position locates within the chunk we are downloading now.
|
||||
*
|
||||
* @param positionUs The target position in microseconds.
|
||||
* @return Whether the input position locates within the chunk we are downloading now.
|
||||
*/
|
||||
public boolean isWithinLastChunk(long positionUs) {
|
||||
if (isPendingReset() || loadingFinished) {
|
||||
return false;
|
||||
} else {
|
||||
return ((positionUs >= getCurrentLoadPositionUs()) && (positionUs < getNextLoadPositionUs()));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Seeks to the specified position in microseconds.
|
||||
*
|
||||
|
|
@ -137,7 +123,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
|||
lastSeekPositionUs = positionUs;
|
||||
// If we're not pending a reset, see if we can seek within the sample queue.
|
||||
boolean seekInsideBuffer = !isPendingReset() &&
|
||||
sampleQueue.skipToKeyframeBefore(positionUs, isWithinLastChunk(positionUs));
|
||||
sampleQueue.skipToKeyframeBefore(positionUs, (positionUs < getNextLoadPositionUs()));
|
||||
if (seekInsideBuffer) {
|
||||
// We succeeded. All we need to do is discard any chunks that we've moved past.
|
||||
while (mediaChunks.size() > 1
|
||||
|
|
@ -299,14 +285,6 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
|||
return true;
|
||||
}
|
||||
|
||||
public long getCurrentLoadPositionUs() {
|
||||
if (isPendingReset()) {
|
||||
return pendingResetPositionUs;
|
||||
} else {
|
||||
return loadingFinished ? C.TIME_END_OF_SOURCE : mediaChunks.getLast().startTimeUs;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
if (isPendingReset()) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue