From c283506c0937528249495478512db97e12c82809 Mon Sep 17 00:00:00 2001 From: tonihei Date: Tue, 7 Mar 2023 15:05:20 +0000 Subject: [PATCH] Make DefaultDashChunkSource more robust against empty segment timelines Segment timelines are technically allowed to be empty, but not all places add the necessary checks. Issue: google/ExoPlayer#11014 PiperOrigin-RevId: 514722205 (cherry picked from commit 0113174788eae17e47e70544d14fc97535d9558e) --- .../exoplayer2/source/dash/DefaultDashChunkSource.java | 7 +++++-- 1 file changed, 5 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 0bdc49d76d1..84860cb5253 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 @@ -234,9 +234,12 @@ public long getAdjustedSeekPositionUs(long positionUs, SeekParameters seekParame // Segments are aligned across representations, so any segment index will do. for (RepresentationHolder representationHolder : representationHolders) { if (representationHolder.segmentIndex != null) { + long segmentCount = representationHolder.getSegmentCount(); + if (segmentCount == 0) { + continue; + } long segmentNum = representationHolder.getSegmentNum(positionUs); long firstSyncUs = representationHolder.getSegmentStartTimeUs(segmentNum); - long segmentCount = representationHolder.getSegmentCount(); long secondSyncUs = firstSyncUs < positionUs && (segmentCount == DashSegmentIndex.INDEX_UNBOUNDED @@ -592,7 +595,7 @@ private ArrayList getRepresentations() { } private long getAvailableLiveDurationUs(long nowUnixTimeUs, long playbackPositionUs) { - if (!manifest.dynamic) { + if (!manifest.dynamic || representationHolders[0].getSegmentCount() == 0) { return C.TIME_UNSET; } long lastSegmentNum = representationHolders[0].getLastAvailableSegmentNum(nowUnixTimeUs);