mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Match SequenceableLoader method order in HlsSampleStreamWrapper
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=177146923
This commit is contained in:
parent
20567633a0
commit
69f8b250d5
1 changed files with 54 additions and 54 deletions
|
|
@ -324,28 +324,6 @@ import java.util.Arrays;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getBufferedPositionUs() {
|
|
||||||
if (loadingFinished) {
|
|
||||||
return C.TIME_END_OF_SOURCE;
|
|
||||||
} else if (isPendingReset()) {
|
|
||||||
return pendingResetPositionUs;
|
|
||||||
} else {
|
|
||||||
long bufferedPositionUs = lastSeekPositionUs;
|
|
||||||
HlsMediaChunk lastMediaChunk = getLastMediaChunk();
|
|
||||||
HlsMediaChunk lastCompletedMediaChunk = lastMediaChunk.isLoadCompleted() ? lastMediaChunk
|
|
||||||
: mediaChunks.size() > 1 ? mediaChunks.get(mediaChunks.size() - 2) : null;
|
|
||||||
if (lastCompletedMediaChunk != null) {
|
|
||||||
bufferedPositionUs = Math.max(bufferedPositionUs, lastCompletedMediaChunk.endTimeUs);
|
|
||||||
}
|
|
||||||
for (SampleQueue sampleQueue : sampleQueues) {
|
|
||||||
bufferedPositionUs = Math.max(bufferedPositionUs,
|
|
||||||
sampleQueue.getLargestQueuedTimestampUs());
|
|
||||||
}
|
|
||||||
return bufferedPositionUs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void release() {
|
public void release() {
|
||||||
boolean releasedSynchronously = loader.release(this);
|
boolean releasedSynchronously = loader.release(this);
|
||||||
if (prepared && !releasedSynchronously) {
|
if (prepared && !releasedSynchronously) {
|
||||||
|
|
@ -447,6 +425,37 @@ import java.util.Arrays;
|
||||||
|
|
||||||
// SequenceableLoader implementation
|
// SequenceableLoader implementation
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getBufferedPositionUs() {
|
||||||
|
if (loadingFinished) {
|
||||||
|
return C.TIME_END_OF_SOURCE;
|
||||||
|
} else if (isPendingReset()) {
|
||||||
|
return pendingResetPositionUs;
|
||||||
|
} else {
|
||||||
|
long bufferedPositionUs = lastSeekPositionUs;
|
||||||
|
HlsMediaChunk lastMediaChunk = getLastMediaChunk();
|
||||||
|
HlsMediaChunk lastCompletedMediaChunk = lastMediaChunk.isLoadCompleted() ? lastMediaChunk
|
||||||
|
: mediaChunks.size() > 1 ? mediaChunks.get(mediaChunks.size() - 2) : null;
|
||||||
|
if (lastCompletedMediaChunk != null) {
|
||||||
|
bufferedPositionUs = Math.max(bufferedPositionUs, lastCompletedMediaChunk.endTimeUs);
|
||||||
|
}
|
||||||
|
for (SampleQueue sampleQueue : sampleQueues) {
|
||||||
|
bufferedPositionUs = Math.max(bufferedPositionUs,
|
||||||
|
sampleQueue.getLargestQueuedTimestampUs());
|
||||||
|
}
|
||||||
|
return bufferedPositionUs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getNextLoadPositionUs() {
|
||||||
|
if (isPendingReset()) {
|
||||||
|
return pendingResetPositionUs;
|
||||||
|
} else {
|
||||||
|
return loadingFinished ? C.TIME_END_OF_SOURCE : getLastMediaChunk().endTimeUs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean continueLoading(long positionUs) {
|
public boolean continueLoading(long positionUs) {
|
||||||
if (loadingFinished || loader.isLoading()) {
|
if (loadingFinished || loader.isLoading()) {
|
||||||
|
|
@ -494,15 +503,6 @@ import java.util.Arrays;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getNextLoadPositionUs() {
|
|
||||||
if (isPendingReset()) {
|
|
||||||
return pendingResetPositionUs;
|
|
||||||
} else {
|
|
||||||
return loadingFinished ? C.TIME_END_OF_SOURCE : getLastMediaChunk().endTimeUs;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Loader.Callback implementation.
|
// Loader.Callback implementation.
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -755,33 +755,10 @@ import java.util.Arrays;
|
||||||
enabledSampleQueueCount = enabledSampleQueueCount + (enabledState ? 1 : -1);
|
enabledSampleQueueCount = enabledSampleQueueCount + (enabledState ? 1 : -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Derives a track format corresponding to a given container format, by combining it with sample
|
|
||||||
* level information obtained from the samples.
|
|
||||||
*
|
|
||||||
* @param containerFormat The container format for which the track format should be derived.
|
|
||||||
* @param sampleFormat A sample format from which to obtain sample level information.
|
|
||||||
* @return The derived track format.
|
|
||||||
*/
|
|
||||||
private static Format deriveFormat(Format containerFormat, Format sampleFormat) {
|
|
||||||
if (containerFormat == null) {
|
|
||||||
return sampleFormat;
|
|
||||||
}
|
|
||||||
int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType);
|
|
||||||
String codecs = Util.getCodecsOfType(containerFormat.codecs, sampleTrackType);
|
|
||||||
return sampleFormat.copyWithContainerInfo(containerFormat.id, codecs, containerFormat.bitrate,
|
|
||||||
containerFormat.width, containerFormat.height, containerFormat.selectionFlags,
|
|
||||||
containerFormat.language);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HlsMediaChunk getLastMediaChunk() {
|
private HlsMediaChunk getLastMediaChunk() {
|
||||||
return mediaChunks.get(mediaChunks.size() - 1);
|
return mediaChunks.get(mediaChunks.size() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isMediaChunk(Chunk chunk) {
|
|
||||||
return chunk instanceof HlsMediaChunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isPendingReset() {
|
private boolean isPendingReset() {
|
||||||
return pendingResetPositionUs != C.TIME_UNSET;
|
return pendingResetPositionUs != C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
|
|
@ -810,4 +787,27 @@ import java.util.Arrays;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Derives a track format corresponding to a given container format, by combining it with sample
|
||||||
|
* level information obtained from the samples.
|
||||||
|
*
|
||||||
|
* @param containerFormat The container format for which the track format should be derived.
|
||||||
|
* @param sampleFormat A sample format from which to obtain sample level information.
|
||||||
|
* @return The derived track format.
|
||||||
|
*/
|
||||||
|
private static Format deriveFormat(Format containerFormat, Format sampleFormat) {
|
||||||
|
if (containerFormat == null) {
|
||||||
|
return sampleFormat;
|
||||||
|
}
|
||||||
|
int sampleTrackType = MimeTypes.getTrackType(sampleFormat.sampleMimeType);
|
||||||
|
String codecs = Util.getCodecsOfType(containerFormat.codecs, sampleTrackType);
|
||||||
|
return sampleFormat.copyWithContainerInfo(containerFormat.id, codecs, containerFormat.bitrate,
|
||||||
|
containerFormat.width, containerFormat.height, containerFormat.selectionFlags,
|
||||||
|
containerFormat.language);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isMediaChunk(Chunk chunk) {
|
||||||
|
return chunk instanceof HlsMediaChunk;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue