From ab88821614cd2762b4fb4f79234b8963c4deb11c Mon Sep 17 00:00:00 2001 From: olly Date: Mon, 19 Dec 2016 06:56:04 -0800 Subject: [PATCH] Fix large timestamps for HLS playbacks - If there's no program-date-time then this change is a no-op. - If there is a program-date-time this change considers the period as having started at the epoch rather than at the start of the content. The window is then set to start at the start of the content. This is a little weird, but is required so that the period sample timestamps match the start of the period. Note that this also brings the handling of on-demand in line with how the live case is handled, meaning there wont be weird changes if a live stream changes into an on-demand one. Issue: #2224 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=142442719 --- .../android/exoplayer2/source/hls/HlsMediaSource.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java b/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java index 2f46fc694c..869efa6cdc 100644 --- a/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java +++ b/library/src/main/java/com/google/android/exoplayer2/source/hls/HlsMediaSource.java @@ -104,15 +104,14 @@ public final class HlsMediaSource implements MediaSource, SinglePeriodTimeline timeline; if (playlistTracker.isLive()) { // TODO: fix windowPositionInPeriodUs when playlist is empty. - long windowPositionInPeriodUs = playlist.startTimeUs; List segments = playlist.segments; long windowDefaultStartPositionUs = segments.isEmpty() ? 0 : segments.get(Math.max(0, segments.size() - 3)).relativeStartTimeUs; timeline = new SinglePeriodTimeline(C.TIME_UNSET, playlist.durationUs, - windowPositionInPeriodUs, windowDefaultStartPositionUs, true, !playlist.hasEndTag); + playlist.startTimeUs, windowDefaultStartPositionUs, true, !playlist.hasEndTag); } else /* not live */ { - timeline = new SinglePeriodTimeline(playlist.durationUs, playlist.durationUs, 0, 0, true, - false); + timeline = new SinglePeriodTimeline(playlist.startTimeUs + playlist.durationUs, + playlist.durationUs, playlist.startTimeUs, 0, true, false); } sourceListener.onSourceInfoRefreshed(timeline, playlist); }