Commit 490519a4 by tonihei Committed by Oliver Woodman

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
parent 7027e75c
...@@ -536,7 +536,6 @@ public final class HlsMediaSource extends BaseMediaSource ...@@ -536,7 +536,6 @@ public final class HlsMediaSource extends BaseMediaSource
} else if (windowDefaultStartPositionUs == C.TIME_UNSET) { } else if (windowDefaultStartPositionUs == C.TIME_UNSET) {
windowDefaultStartPositionUs = 0; windowDefaultStartPositionUs = 0;
} }
timeline = timeline =
new SinglePeriodTimeline( new SinglePeriodTimeline(
presentationStartTimeMs, presentationStartTimeMs,
......
...@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.drm.DrmInitData; ...@@ -25,6 +25,7 @@ import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.offline.StreamKey; import com.google.android.exoplayer2.offline.StreamKey;
import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Iterables;
import java.lang.annotation.Documented; import java.lang.annotation.Documented;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy; import java.lang.annotation.RetentionPolicy;
...@@ -475,9 +476,12 @@ public final class HlsMediaPlaylist extends HlsPlaylist { ...@@ -475,9 +476,12 @@ public final class HlsMediaPlaylist extends HlsPlaylist {
this.skippedSegmentCount = skippedSegmentCount; this.skippedSegmentCount = skippedSegmentCount;
this.trailingParts = ImmutableList.copyOf(trailingParts); this.trailingParts = ImmutableList.copyOf(trailingParts);
this.renditionReports = ImmutableMap.copyOf(renditionReports); this.renditionReports = ImmutableMap.copyOf(renditionReports);
if (!segments.isEmpty()) { if (!trailingParts.isEmpty()) {
Segment last = segments.get(segments.size() - 1); Part lastPart = Iterables.getLast(trailingParts);
durationUs = last.relativeStartTimeUs + last.durationUs; durationUs = lastPart.relativeStartTimeUs + lastPart.durationUs;
} else if (!segments.isEmpty()) {
Segment lastSegment = Iterables.getLast(segments);
durationUs = lastSegment.relativeStartTimeUs + lastSegment.durationUs;
} else { } else {
durationUs = 0; durationUs = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment