mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +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.
|
* @return Whether the skip was successful.
|
||||||
*/
|
*/
|
||||||
public boolean skipToKeyframeBefore(long timeUs) {
|
public boolean skipToKeyframeBefore(long timeUs) {
|
||||||
long nextOffset = infoQueue.skipToKeyframeBefore(timeUs, false);
|
return infoQueue.skipToKeyframeBefore(timeUs, false);
|
||||||
if (nextOffset == C.POSITION_UNSET) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
dropDownstreamTo(nextOffset);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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.
|
* Seeks to the specified position in microseconds.
|
||||||
*
|
*
|
||||||
|
|
@ -137,7 +123,7 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
||||||
lastSeekPositionUs = positionUs;
|
lastSeekPositionUs = positionUs;
|
||||||
// If we're not pending a reset, see if we can seek within the sample queue.
|
// If we're not pending a reset, see if we can seek within the sample queue.
|
||||||
boolean seekInsideBuffer = !isPendingReset() &&
|
boolean seekInsideBuffer = !isPendingReset() &&
|
||||||
sampleQueue.skipToKeyframeBefore(positionUs, isWithinLastChunk(positionUs));
|
sampleQueue.skipToKeyframeBefore(positionUs, (positionUs < getNextLoadPositionUs()));
|
||||||
if (seekInsideBuffer) {
|
if (seekInsideBuffer) {
|
||||||
// We succeeded. All we need to do is discard any chunks that we've moved past.
|
// We succeeded. All we need to do is discard any chunks that we've moved past.
|
||||||
while (mediaChunks.size() > 1
|
while (mediaChunks.size() > 1
|
||||||
|
|
@ -299,14 +285,6 @@ public class ChunkSampleStream<T extends ChunkSource> implements SampleStream, S
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getCurrentLoadPositionUs() {
|
|
||||||
if (isPendingReset()) {
|
|
||||||
return pendingResetPositionUs;
|
|
||||||
} else {
|
|
||||||
return loadingFinished ? C.TIME_END_OF_SOURCE : mediaChunks.getLast().startTimeUs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getNextLoadPositionUs() {
|
public long getNextLoadPositionUs() {
|
||||||
if (isPendingReset()) {
|
if (isPendingReset()) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue