Skip to content

Commit

Permalink
Calculate HLS live playlist refresh interval accurately
Browse files Browse the repository at this point in the history
Previously, we calculated the next playlist reload time by adding the target duration (or half of it, depending on whether there is a real update in the new playlist snapshot) from the last load completion time, which makes the reload interval as long as `targetDuration(or half of it) + lastLoadDuration`. While still complying to the standard that "the client MUST wait for at least the target duration before attempting to reload the Playlist file again", this could cause buffering when the playback position is close to the end of live window. This change is to calculate the reload interval accurately by not adding the term `lastLoadDuration`.

Issue: #663

#minor-release

PiperOrigin-RevId: 573300009
(cherry picked from commit 58a63c8)
  • Loading branch information
tianyif authored and rohitjoins committed Oct 23, 2023
1 parent b65136e commit 2a7d85e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@
* Cronet Extension:
* RTMP Extension:
* HLS Extension:
* Refresh the HLS live playlist with an interval calculated from the last
load start time rather than the last load completed time
([#663](https://github.com/androidx/media/issues/663)).
* DASH Extension:
* Smooth Streaming Extension:
* RTSP Extension:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,8 @@ private void processLoadedPlaylist(
? playlistSnapshot.targetDurationUs
: (playlistSnapshot.targetDurationUs / 2);
}
earliestNextLoadTimeMs = currentTimeMs + Util.usToMs(durationUntilNextLoadUs);
earliestNextLoadTimeMs =
currentTimeMs + Util.usToMs(durationUntilNextLoadUs) - loadEventInfo.loadDurationMs;
// Schedule a load if this is the primary playlist or a playlist of a low-latency stream and
// it doesn't have an end tag. Else the next load will be scheduled when refreshPlaylist is
// called, or when this playlist becomes the primary.
Expand Down

0 comments on commit 2a7d85e

Please sign in to comment.