mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
parent
fb8f0113c6
commit
5c0745cedf
2 changed files with 26 additions and 0 deletions
|
|
@ -138,6 +138,7 @@ public class HlsChunkSource {
|
||||||
private byte[] scratchSpace;
|
private byte[] scratchSpace;
|
||||||
private boolean live;
|
private boolean live;
|
||||||
private long durationUs;
|
private long durationUs;
|
||||||
|
private IOException fatalError;
|
||||||
|
|
||||||
private Uri encryptionKeyUri;
|
private Uri encryptionKeyUri;
|
||||||
private byte[] encryptionKey;
|
private byte[] encryptionKey;
|
||||||
|
|
@ -223,6 +224,18 @@ public class HlsChunkSource {
|
||||||
return live ? C.UNKNOWN_TIME_US : durationUs;
|
return live ? C.UNKNOWN_TIME_US : durationUs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If the source is currently having difficulty providing chunks, then this method throws the
|
||||||
|
* underlying error. Otherwise does nothing.
|
||||||
|
*
|
||||||
|
* @throws IOException The underlying error.
|
||||||
|
*/
|
||||||
|
public void maybeThrowError() throws IOException {
|
||||||
|
if (fatalError != null) {
|
||||||
|
throw fatalError;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the next {@link Chunk} that should be loaded.
|
* Returns the next {@link Chunk} that should be loaded.
|
||||||
*
|
*
|
||||||
|
|
@ -262,9 +275,15 @@ public class HlsChunkSource {
|
||||||
chunkMediaSequence = switchingVariantSpliced
|
chunkMediaSequence = switchingVariantSpliced
|
||||||
? previousTsChunk.chunkIndex : previousTsChunk.chunkIndex + 1;
|
? previousTsChunk.chunkIndex : previousTsChunk.chunkIndex + 1;
|
||||||
if (chunkMediaSequence < mediaPlaylist.mediaSequence) {
|
if (chunkMediaSequence < mediaPlaylist.mediaSequence) {
|
||||||
|
// TODO: Decide what we want to do with: https://github.com/google/ExoPlayer/issues/765
|
||||||
|
// if (allowSkipAhead) {
|
||||||
// If the chunk is no longer in the playlist. Skip ahead and start again.
|
// If the chunk is no longer in the playlist. Skip ahead and start again.
|
||||||
chunkMediaSequence = getLiveStartChunkMediaSequence(nextVariantIndex);
|
chunkMediaSequence = getLiveStartChunkMediaSequence(nextVariantIndex);
|
||||||
liveDiscontinuity = true;
|
liveDiscontinuity = true;
|
||||||
|
// } else {
|
||||||
|
// fatalError = new BehindLiveWindowException();
|
||||||
|
// return null;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -414,6 +433,10 @@ public class HlsChunkSource {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void reset() {
|
||||||
|
fatalError = null;
|
||||||
|
}
|
||||||
|
|
||||||
private int getNextVariantIndex(TsChunk previousTsChunk, long playbackPositionUs) {
|
private int getNextVariantIndex(TsChunk previousTsChunk, long playbackPositionUs) {
|
||||||
clearStaleBlacklistedVariants();
|
clearStaleBlacklistedVariants();
|
||||||
long bitrateEstimate = bandwidthMeter.getBitrateEstimate();
|
long bitrateEstimate = bandwidthMeter.getBitrateEstimate();
|
||||||
|
|
|
||||||
|
|
@ -206,6 +206,7 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
|
||||||
enabledTrackCount--;
|
enabledTrackCount--;
|
||||||
trackEnabledStates[track] = false;
|
trackEnabledStates[track] = false;
|
||||||
if (enabledTrackCount == 0) {
|
if (enabledTrackCount == 0) {
|
||||||
|
chunkSource.reset();
|
||||||
downstreamPositionUs = Long.MIN_VALUE;
|
downstreamPositionUs = Long.MIN_VALUE;
|
||||||
if (loadControlRegistered) {
|
if (loadControlRegistered) {
|
||||||
loadControl.unregister(this);
|
loadControl.unregister(this);
|
||||||
|
|
@ -317,6 +318,8 @@ public final class HlsSampleSource implements SampleSource, SampleSourceReader,
|
||||||
public void maybeThrowError() throws IOException {
|
public void maybeThrowError() throws IOException {
|
||||||
if (currentLoadableException != null && currentLoadableExceptionCount > minLoadableRetryCount) {
|
if (currentLoadableException != null && currentLoadableExceptionCount > minLoadableRetryCount) {
|
||||||
throw currentLoadableException;
|
throw currentLoadableException;
|
||||||
|
} else if (currentLoadable == null) {
|
||||||
|
chunkSource.maybeThrowError();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue