Commit ab888216 by olly Committed by Oliver Woodman

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
parent 4bb87932
...@@ -104,15 +104,14 @@ public final class HlsMediaSource implements MediaSource, ...@@ -104,15 +104,14 @@ public final class HlsMediaSource implements MediaSource,
SinglePeriodTimeline timeline; SinglePeriodTimeline timeline;
if (playlistTracker.isLive()) { if (playlistTracker.isLive()) {
// TODO: fix windowPositionInPeriodUs when playlist is empty. // TODO: fix windowPositionInPeriodUs when playlist is empty.
long windowPositionInPeriodUs = playlist.startTimeUs;
List<HlsMediaPlaylist.Segment> segments = playlist.segments; List<HlsMediaPlaylist.Segment> segments = playlist.segments;
long windowDefaultStartPositionUs = segments.isEmpty() ? 0 long windowDefaultStartPositionUs = segments.isEmpty() ? 0
: segments.get(Math.max(0, segments.size() - 3)).relativeStartTimeUs; : segments.get(Math.max(0, segments.size() - 3)).relativeStartTimeUs;
timeline = new SinglePeriodTimeline(C.TIME_UNSET, playlist.durationUs, timeline = new SinglePeriodTimeline(C.TIME_UNSET, playlist.durationUs,
windowPositionInPeriodUs, windowDefaultStartPositionUs, true, !playlist.hasEndTag); playlist.startTimeUs, windowDefaultStartPositionUs, true, !playlist.hasEndTag);
} else /* not live */ { } else /* not live */ {
timeline = new SinglePeriodTimeline(playlist.durationUs, playlist.durationUs, 0, 0, true, timeline = new SinglePeriodTimeline(playlist.startTimeUs + playlist.durationUs,
false); playlist.durationUs, playlist.startTimeUs, 0, true, false);
} }
sourceListener.onSourceInfoRefreshed(timeline, playlist); sourceListener.onSourceInfoRefreshed(timeline, playlist);
} }
......
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