mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
DashChunkSource: Workaround for missing segment at the end of the period.
Issue: #836 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=124832221
This commit is contained in:
parent
266c0dce40
commit
61df9aeb26
1 changed files with 16 additions and 1 deletions
|
|
@ -41,6 +41,7 @@ import com.google.android.exoplayer.extractor.mkv.MatroskaExtractor;
|
||||||
import com.google.android.exoplayer.extractor.mp4.FragmentedMp4Extractor;
|
import com.google.android.exoplayer.extractor.mp4.FragmentedMp4Extractor;
|
||||||
import com.google.android.exoplayer.upstream.DataSource;
|
import com.google.android.exoplayer.upstream.DataSource;
|
||||||
import com.google.android.exoplayer.upstream.DataSpec;
|
import com.google.android.exoplayer.upstream.DataSpec;
|
||||||
|
import com.google.android.exoplayer.upstream.HttpDataSource.InvalidResponseCodeException;
|
||||||
import com.google.android.exoplayer.upstream.Loader;
|
import com.google.android.exoplayer.upstream.Loader;
|
||||||
import com.google.android.exoplayer.util.MimeTypes;
|
import com.google.android.exoplayer.util.MimeTypes;
|
||||||
import com.google.android.exoplayer.util.Util;
|
import com.google.android.exoplayer.util.Util;
|
||||||
|
|
@ -71,6 +72,7 @@ public class DashChunkSource implements ChunkSource {
|
||||||
|
|
||||||
private boolean lastChunkWasInitialization;
|
private boolean lastChunkWasInitialization;
|
||||||
private IOException fatalError;
|
private IOException fatalError;
|
||||||
|
private boolean missingLastSegment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param manifestLoader The {@link Loader} being used to load manifests.
|
* @param manifestLoader The {@link Loader} being used to load manifests.
|
||||||
|
|
@ -232,7 +234,8 @@ public class DashChunkSource implements ChunkSource {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (segmentNum > lastAvailableSegmentNum) {
|
if (segmentNum > lastAvailableSegmentNum
|
||||||
|
|| (missingLastSegment && segmentNum >= lastAvailableSegmentNum)) {
|
||||||
// This is beyond the last chunk in the current manifest.
|
// This is beyond the last chunk in the current manifest.
|
||||||
out.endOfStream = !manifest.dynamic;
|
out.endOfStream = !manifest.dynamic;
|
||||||
return;
|
return;
|
||||||
|
|
@ -269,6 +272,18 @@ public class DashChunkSource implements ChunkSource {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onChunkLoadError(Chunk chunk, boolean cancelable, Exception e) {
|
public boolean onChunkLoadError(Chunk chunk, boolean cancelable, Exception e) {
|
||||||
|
// Workaround for missing segment at the end of the period
|
||||||
|
if (cancelable && !manifest.dynamic && chunk instanceof MediaChunk
|
||||||
|
&& e instanceof InvalidResponseCodeException
|
||||||
|
&& ((InvalidResponseCodeException) e).responseCode == 404) {
|
||||||
|
RepresentationHolder representationHolder =
|
||||||
|
representationHolders[getTrackIndex(chunk.format)];
|
||||||
|
int lastAvailableSegmentNum = representationHolder.getLastSegmentNum();
|
||||||
|
if (((MediaChunk) chunk).chunkIndex >= lastAvailableSegmentNum) {
|
||||||
|
missingLastSegment = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
// TODO: Consider implementing representation blacklisting.
|
// TODO: Consider implementing representation blacklisting.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue