Skip to content

Commit

Permalink
Fix large timestamps for HLS playbacks
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
ojw28 committed Dec 19, 2016
1 parent 4bb8793 commit ab88821
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,14 @@ public void onPrimaryPlaylistRefreshed(HlsMediaPlaylist playlist) {
SinglePeriodTimeline timeline;
if (playlistTracker.isLive()) {
// TODO: fix windowPositionInPeriodUs when playlist is empty.
long windowPositionInPeriodUs = playlist.startTimeUs;
List<HlsMediaPlaylist.Segment> 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);
}
Expand Down

0 comments on commit ab88821

Please sign in to comment.