Fixed issue in which the segment/chunk shift value could become incorrect.
This commit is contained in:
parent
99edc6a4b4
commit
aa249e9f7f
@ -309,10 +309,26 @@ public class DashChunkSource implements ChunkSource {
|
|||||||
RepresentationHolder representationHolder =
|
RepresentationHolder representationHolder =
|
||||||
representationHolders.get(representation.format.id);
|
representationHolders.get(representation.format.id);
|
||||||
DashSegmentIndex oldIndex = representationHolder.segmentIndex;
|
DashSegmentIndex oldIndex = representationHolder.segmentIndex;
|
||||||
|
int oldIndexLastSegmentNum = oldIndex.getLastSegmentNum();
|
||||||
|
long oldIndexEndTimeUs = oldIndex.getTimeUs(oldIndexLastSegmentNum)
|
||||||
|
+ oldIndex.getDurationUs(oldIndexLastSegmentNum);
|
||||||
DashSegmentIndex newIndex = representation.getIndex();
|
DashSegmentIndex newIndex = representation.getIndex();
|
||||||
int newFirstSegmentNum = newIndex.getFirstSegmentNum();
|
int newIndexFirstSegmentNum = newIndex.getFirstSegmentNum();
|
||||||
int segmentNumShift = oldIndex.getSegmentNum(newIndex.getTimeUs(newFirstSegmentNum))
|
long newIndexStartTimeUs = newIndex.getTimeUs(newIndexFirstSegmentNum);
|
||||||
- newFirstSegmentNum;
|
if (oldIndexEndTimeUs < newIndexStartTimeUs) {
|
||||||
|
// There's a gap between the old manifest and the new one which means we've slipped behind
|
||||||
|
// the live window and can't proceed.
|
||||||
|
fatalError = new BehindLiveWindowException();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int segmentNumShift;
|
||||||
|
if (oldIndexEndTimeUs == newIndexStartTimeUs) {
|
||||||
|
// The new manifest continues where the old one ended, with no overlap.
|
||||||
|
segmentNumShift = oldIndex.getLastSegmentNum() + 1 - newIndexFirstSegmentNum;
|
||||||
|
} else {
|
||||||
|
// The new manifest overlaps with the old one.
|
||||||
|
segmentNumShift = oldIndex.getSegmentNum(newIndexStartTimeUs) - newIndexFirstSegmentNum;
|
||||||
|
}
|
||||||
representationHolder.segmentNumShift += segmentNumShift;
|
representationHolder.segmentNumShift += segmentNumShift;
|
||||||
representationHolder.segmentIndex = newIndex;
|
representationHolder.segmentIndex = newIndex;
|
||||||
}
|
}
|
||||||
|
@ -217,11 +217,22 @@ public class SmoothStreamingChunkSource implements ChunkSource {
|
|||||||
SmoothStreamingManifest newManifest = manifestFetcher.getManifest();
|
SmoothStreamingManifest newManifest = manifestFetcher.getManifest();
|
||||||
if (currentManifest != newManifest && newManifest != null) {
|
if (currentManifest != newManifest && newManifest != null) {
|
||||||
StreamElement currentElement = getElement(currentManifest);
|
StreamElement currentElement = getElement(currentManifest);
|
||||||
|
int currentElementChunkCount = currentElement.chunkCount;
|
||||||
StreamElement newElement = getElement(newManifest);
|
StreamElement newElement = getElement(newManifest);
|
||||||
if (newElement.chunkCount == 0) {
|
if (currentElementChunkCount == 0 || newElement.chunkCount == 0) {
|
||||||
currentManifestChunkOffset += currentElement.chunkCount;
|
// There's no overlap between the old and new elements because at least one is empty.
|
||||||
} else if (currentElement.chunkCount > 0) {
|
currentManifestChunkOffset += currentElementChunkCount;
|
||||||
currentManifestChunkOffset += currentElement.getChunkIndex(newElement.getStartTimeUs(0));
|
} else {
|
||||||
|
long currentElementEndTimeUs = currentElement.getStartTimeUs(currentElementChunkCount - 1)
|
||||||
|
+ currentElement.getChunkDurationUs(currentElementChunkCount - 1);
|
||||||
|
long newElementStartTimeUs = newElement.getStartTimeUs(0);
|
||||||
|
if (currentElementEndTimeUs <= newElementStartTimeUs) {
|
||||||
|
// There's no overlap between the old and new elements.
|
||||||
|
currentManifestChunkOffset += currentElementChunkCount;
|
||||||
|
} else {
|
||||||
|
// The new element overlaps with the old one.
|
||||||
|
currentManifestChunkOffset += currentElement.getChunkIndex(newElementStartTimeUs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
currentManifest = newManifest;
|
currentManifest = newManifest;
|
||||||
finishedCurrentManifest = false;
|
finishedCurrentManifest = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user