From c2d9960a6e3a6a790a11a3842e72f8cda5d6e946 Mon Sep 17 00:00:00 2001 From: Cai Yuanqing Date: Wed, 2 Oct 2019 13:25:26 +1300 Subject: [PATCH 1/3] Issue: #6501 Wrong segmentNumShift was calculated in copyWithNewRepresentation In DefaultDashChunkSource.copyWithNewRepresentation, it will handle the logic that new MPD manifest file is updated and calculate a newSegmentNumShift for furthermore segNum index calculation in getSegmentUrl, when a shorter window MPD updated and then back to a longer window MPD, copyWithNewRepresentation will go into the overlap case but the new index actually contains the old index.. --- .../android/exoplayer2/source/dash/DefaultDashChunkSource.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java index cd39c9538a..14fe81f605 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java @@ -700,6 +700,8 @@ public class DefaultDashChunkSource implements DashChunkSource { // There's a gap between the old index and the new one which means we've slipped behind the // live window and can't proceed. throw new BehindLiveWindowException(); + } else if (oldIndex.getFirstSegmentNum() >= newIndexFirstSegmentNum) { + // The new index contains the old one, continue process the next segment } else { // The new index overlaps with the old one. newSegmentNumShift += From 9ec94a4bdc0678ec4a894d7adde7379b494a65af Mon Sep 17 00:00:00 2001 From: Cai Yuanqing Date: Fri, 4 Oct 2019 13:55:25 +1300 Subject: [PATCH 2/3] Check the new index contains the old index based on stat time instead of segNum --- .../exoplayer2/source/dash/DefaultDashChunkSource.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java index 14fe81f605..6218fb01d0 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java @@ -686,6 +686,8 @@ public class DefaultDashChunkSource implements DashChunkSource { newPeriodDurationUs, newRepresentation, extractorWrapper, segmentNumShift, newIndex); } + long oldIndexFirstSegmentNum = oldIndex.getFirstSegmentNum(); + long oldIndexStartTimeUs = oldIndex.getTimeUs(oldIndexFirstSegmentNum); long oldIndexLastSegmentNum = oldIndex.getFirstSegmentNum() + oldIndexSegmentCount - 1; long oldIndexEndTimeUs = oldIndex.getTimeUs(oldIndexLastSegmentNum) @@ -700,8 +702,10 @@ public class DefaultDashChunkSource implements DashChunkSource { // There's a gap between the old index and the new one which means we've slipped behind the // live window and can't proceed. throw new BehindLiveWindowException(); - } else if (oldIndex.getFirstSegmentNum() >= newIndexFirstSegmentNum) { - // The new index contains the old one, continue process the next segment + } else if (oldIndexStartTimeUs >= newIndexStartTimeUs) { + // The new index overlaps with (but does not have a start position contained within) the old + // index. This can only happen if extra segments have been added to the start of the index. + // Continue process the next segment as is. } else { // The new index overlaps with the old one. newSegmentNumShift += From d2b221b95be69dd1e412155504a66d8ebc0dbffe Mon Sep 17 00:00:00 2001 From: Cai Yuanqing Date: Mon, 7 Oct 2019 12:05:50 +1300 Subject: [PATCH 3/3] Issue: #6501 Wrong segmentNumShift was calculated in copyWithNewRepresentation When newIndex overlaps oldIndex with newstarttime < oldstarttime, according to the segNum of endtime in newIndex and oldIndexLastSegnum to calculate the segmentNumShift. --- .../exoplayer2/source/dash/DefaultDashChunkSource.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java index 6218fb01d0..ccecf8048e 100644 --- a/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java +++ b/library/dash/src/main/java/com/google/android/exoplayer2/source/dash/DefaultDashChunkSource.java @@ -702,12 +702,14 @@ public class DefaultDashChunkSource implements DashChunkSource { // There's a gap between the old index and the new one which means we've slipped behind the // live window and can't proceed. throw new BehindLiveWindowException(); - } else if (oldIndexStartTimeUs >= newIndexStartTimeUs) { + } else if (newIndexStartTimeUs < oldIndexStartTimeUs) { // The new index overlaps with (but does not have a start position contained within) the old // index. This can only happen if extra segments have been added to the start of the index. - // Continue process the next segment as is. + newSegmentNumShift -= + newIndex.getSegmentNum(oldIndexStartTimeUs, newPeriodDurationUs) + - oldIndexFirstSegmentNum; } else { - // The new index overlaps with the old one. + // The new index overlaps with (and has a start position contained within) the old index. newSegmentNumShift += oldIndex.getSegmentNum(newIndexStartTimeUs, newPeriodDurationUs) - newIndexFirstSegmentNum;