Move getBufferedPositionUs into SequenceableLoader.
All implementations of SequenceableLoader already implement this method. Moreover, all composite media periods contained an exact copy of an implementation that now moved to CompositeSequencableLoader. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=162349083
This commit is contained in:
parent
e26b8824dd
commit
3ff9695a73
@ -29,7 +29,19 @@ public final class CompositeSequenceableLoader implements SequenceableLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextLoadPositionUs() {
|
||||
public final long getBufferedPositionUs() {
|
||||
long bufferedPositionUs = Long.MAX_VALUE;
|
||||
for (SequenceableLoader loader : loaders) {
|
||||
long loaderBufferedPositionUs = loader.getBufferedPositionUs();
|
||||
if (loaderBufferedPositionUs != C.TIME_END_OF_SOURCE) {
|
||||
bufferedPositionUs = Math.min(bufferedPositionUs, loaderBufferedPositionUs);
|
||||
}
|
||||
}
|
||||
return bufferedPositionUs == Long.MAX_VALUE ? C.TIME_END_OF_SOURCE : bufferedPositionUs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final long getNextLoadPositionUs() {
|
||||
long nextLoadPositionUs = Long.MAX_VALUE;
|
||||
for (SequenceableLoader loader : loaders) {
|
||||
long loaderNextLoadPositionUs = loader.getNextLoadPositionUs();
|
||||
@ -41,7 +53,7 @@ public final class CompositeSequenceableLoader implements SequenceableLoader {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean continueLoading(long positionUs) {
|
||||
public final boolean continueLoading(long positionUs) {
|
||||
boolean madeProgress = false;
|
||||
boolean madeProgressThisIteration;
|
||||
do {
|
||||
|
@ -128,16 +128,6 @@ public interface MediaPeriod extends SequenceableLoader {
|
||||
*/
|
||||
long readDiscontinuity();
|
||||
|
||||
/**
|
||||
* Returns an estimate of the position up to which data is buffered for the enabled tracks.
|
||||
* <p>
|
||||
* This method should only be called when at least one track is selected.
|
||||
*
|
||||
* @return An estimate of the absolute position in microseconds up to which data is buffered, or
|
||||
* {@link C#TIME_END_OF_SOURCE} if the track is fully buffered.
|
||||
*/
|
||||
long getBufferedPositionUs();
|
||||
|
||||
/**
|
||||
* Attempts to seek to the specified position in microseconds.
|
||||
* <p>
|
||||
@ -153,6 +143,17 @@ public interface MediaPeriod extends SequenceableLoader {
|
||||
|
||||
// SequenceableLoader interface. Overridden to provide more specific documentation.
|
||||
|
||||
/**
|
||||
* Returns an estimate of the position up to which data is buffered for the enabled tracks.
|
||||
* <p>
|
||||
* This method should only be called when at least one track is selected.
|
||||
*
|
||||
* @return An estimate of the absolute position in microseconds up to which data is buffered, or
|
||||
* {@link C#TIME_END_OF_SOURCE} if the track is fully buffered.
|
||||
*/
|
||||
@Override
|
||||
long getBufferedPositionUs();
|
||||
|
||||
/**
|
||||
* Returns the next load time, or {@link C#TIME_END_OF_SOURCE} if loading has finished.
|
||||
* <p>
|
||||
|
@ -168,14 +168,7 @@ import java.util.IdentityHashMap;
|
||||
|
||||
@Override
|
||||
public long getBufferedPositionUs() {
|
||||
long bufferedPositionUs = Long.MAX_VALUE;
|
||||
for (MediaPeriod period : enabledPeriods) {
|
||||
long rendererBufferedPositionUs = period.getBufferedPositionUs();
|
||||
if (rendererBufferedPositionUs != C.TIME_END_OF_SOURCE) {
|
||||
bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
|
||||
}
|
||||
}
|
||||
return bufferedPositionUs == Long.MAX_VALUE ? C.TIME_END_OF_SOURCE : bufferedPositionUs;
|
||||
return sequenceableLoader.getBufferedPositionUs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -36,6 +36,14 @@ public interface SequenceableLoader {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an estimate of the position up to which data is buffered.
|
||||
*
|
||||
* @return An estimate of the absolute position in microseconds up to which data is buffered, or
|
||||
* {@link C#TIME_END_OF_SOURCE} if the data is fully buffered.
|
||||
*/
|
||||
long getBufferedPositionUs();
|
||||
|
||||
/**
|
||||
* Returns the next load time, or {@link C#TIME_END_OF_SOURCE} if loading has finished.
|
||||
*/
|
||||
|
@ -209,14 +209,7 @@ import java.util.List;
|
||||
|
||||
@Override
|
||||
public long getBufferedPositionUs() {
|
||||
long bufferedPositionUs = Long.MAX_VALUE;
|
||||
for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
|
||||
long rendererBufferedPositionUs = sampleStream.getBufferedPositionUs();
|
||||
if (rendererBufferedPositionUs != C.TIME_END_OF_SOURCE) {
|
||||
bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
|
||||
}
|
||||
}
|
||||
return bufferedPositionUs == Long.MAX_VALUE ? C.TIME_END_OF_SOURCE : bufferedPositionUs;
|
||||
return sequenceableLoader.getBufferedPositionUs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -203,14 +203,7 @@ public final class HlsMediaPeriod implements MediaPeriod, HlsSampleStreamWrapper
|
||||
|
||||
@Override
|
||||
public long getBufferedPositionUs() {
|
||||
long bufferedPositionUs = Long.MAX_VALUE;
|
||||
for (HlsSampleStreamWrapper sampleStreamWrapper : enabledSampleStreamWrappers) {
|
||||
long rendererBufferedPositionUs = sampleStreamWrapper.getBufferedPositionUs();
|
||||
if (rendererBufferedPositionUs != C.TIME_END_OF_SOURCE) {
|
||||
bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
|
||||
}
|
||||
}
|
||||
return bufferedPositionUs == Long.MAX_VALUE ? C.TIME_END_OF_SOURCE : bufferedPositionUs;
|
||||
return sequenceableLoader.getBufferedPositionUs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -159,14 +159,7 @@ import java.util.ArrayList;
|
||||
|
||||
@Override
|
||||
public long getBufferedPositionUs() {
|
||||
long bufferedPositionUs = Long.MAX_VALUE;
|
||||
for (ChunkSampleStream<SsChunkSource> sampleStream : sampleStreams) {
|
||||
long rendererBufferedPositionUs = sampleStream.getBufferedPositionUs();
|
||||
if (rendererBufferedPositionUs != C.TIME_END_OF_SOURCE) {
|
||||
bufferedPositionUs = Math.min(bufferedPositionUs, rendererBufferedPositionUs);
|
||||
}
|
||||
}
|
||||
return bufferedPositionUs == Long.MAX_VALUE ? C.TIME_END_OF_SOURCE : bufferedPositionUs;
|
||||
return sequenceableLoader.getBufferedPositionUs();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
x
Reference in New Issue
Block a user