Update HLS window duration with trailing parts.

If we have trailing parts the available window should reach to
the end of all trailing parts and not only to the last finished
segment.

Issue: #5011
PiperOrigin-RevId: 347996626
This commit is contained in:
tonihei 2020-12-17 12:16:15 +00:00 committed by Oliver Woodman
parent 7027e75ce8
commit 490519a49a
2 changed files with 7 additions and 4 deletions

View file

@ -536,7 +536,6 @@ public final class HlsMediaSource extends BaseMediaSource
} else if (windowDefaultStartPositionUs == C.TIME_UNSET) {
windowDefaultStartPositionUs = 0;
}
timeline =
new SinglePeriodTimeline(
presentationStartTimeMs,

View file

@ -25,6 +25,7 @@ import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.offline.StreamKey;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@ -475,9 +476,12 @@ public final class HlsMediaPlaylist extends HlsPlaylist {
this.skippedSegmentCount = skippedSegmentCount;
this.trailingParts = ImmutableList.copyOf(trailingParts);
this.renditionReports = ImmutableMap.copyOf(renditionReports);
if (!segments.isEmpty()) {
Segment last = segments.get(segments.size() - 1);
durationUs = last.relativeStartTimeUs + last.durationUs;
if (!trailingParts.isEmpty()) {
Part lastPart = Iterables.getLast(trailingParts);
durationUs = lastPart.relativeStartTimeUs + lastPart.durationUs;
} else if (!segments.isEmpty()) {
Segment lastSegment = Iterables.getLast(segments);
durationUs = lastSegment.relativeStartTimeUs + lastSegment.durationUs;
} else {
durationUs = 0;
}