Commit d6b6600a by olly Committed by Andrew Lewis

Fix unnecessary media playlist requests when playing live streams

Issue: #5059
PiperOrigin-RevId: 222803511
parent 40c65dbc
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
### dev-v2 (not yet released) ### ### dev-v2 (not yet released) ###
* HLS: Fix issue causing unnecessary media playlist requests when playing live
streams ([#5059](https://github.com/google/ExoPlayer/issues/5059)).
* MP4: Support Opus and FLAC in the MP4 container, and in DASH * MP4: Support Opus and FLAC in the MP4 container, and in DASH
([#4883](https://github.com/google/ExoPlayer/issues/4883)). ([#4883](https://github.com/google/ExoPlayer/issues/4883)).
* DASH: Fix detecting the end of live events * DASH: Fix detecting the end of live events
......
...@@ -262,7 +262,8 @@ import java.util.List; ...@@ -262,7 +262,8 @@ import java.util.List;
// Retry when playlist is refreshed. // Retry when playlist is refreshed.
return; return;
} }
HlsMediaPlaylist mediaPlaylist = playlistTracker.getPlaylistSnapshot(selectedUrl); HlsMediaPlaylist mediaPlaylist =
playlistTracker.getPlaylistSnapshot(selectedUrl, /* isForPlayback= */ true);
independentSegments = mediaPlaylist.hasIndependentSegments; independentSegments = mediaPlaylist.hasIndependentSegments;
updateLiveEdgeTimeUs(mediaPlaylist); updateLiveEdgeTimeUs(mediaPlaylist);
...@@ -279,7 +280,7 @@ import java.util.List; ...@@ -279,7 +280,7 @@ import java.util.List;
// behind the live window. // behind the live window.
selectedVariantIndex = oldVariantIndex; selectedVariantIndex = oldVariantIndex;
selectedUrl = variants[selectedVariantIndex]; selectedUrl = variants[selectedVariantIndex];
mediaPlaylist = playlistTracker.getPlaylistSnapshot(selectedUrl); mediaPlaylist = playlistTracker.getPlaylistSnapshot(selectedUrl, /* isForPlayback= */ true);
startOfPlaylistInPeriodUs = startOfPlaylistInPeriodUs =
mediaPlaylist.startTimeUs - playlistTracker.getInitialStartTimeUs(); mediaPlaylist.startTimeUs - playlistTracker.getInitialStartTimeUs();
chunkMediaSequence = previous.getNextChunkIndex(); chunkMediaSequence = previous.getNextChunkIndex();
...@@ -435,7 +436,8 @@ import java.util.List; ...@@ -435,7 +436,8 @@ import java.util.List;
chunkIterators[i] = MediaChunkIterator.EMPTY; chunkIterators[i] = MediaChunkIterator.EMPTY;
continue; continue;
} }
HlsMediaPlaylist playlist = playlistTracker.getPlaylistSnapshot(variantUrl); HlsMediaPlaylist playlist =
playlistTracker.getPlaylistSnapshot(variantUrl, /* isForPlayback= */ false);
long startOfPlaylistInPeriodUs = long startOfPlaylistInPeriodUs =
playlist.startTimeUs - playlistTracker.getInitialStartTimeUs(); playlist.startTimeUs - playlistTracker.getInitialStartTimeUs();
boolean switchingVariant = variantIndex != oldVariantIndex; boolean switchingVariant = variantIndex != oldVariantIndex;
......
...@@ -162,9 +162,9 @@ public final class DefaultHlsPlaylistTracker ...@@ -162,9 +162,9 @@ public final class DefaultHlsPlaylistTracker
} }
@Override @Override
public HlsMediaPlaylist getPlaylistSnapshot(HlsUrl url) { public HlsMediaPlaylist getPlaylistSnapshot(HlsUrl url, boolean isForPlayback) {
HlsMediaPlaylist snapshot = playlistBundles.get(url).getPlaylistSnapshot(); HlsMediaPlaylist snapshot = playlistBundles.get(url).getPlaylistSnapshot();
if (snapshot != null) { if (snapshot != null && isForPlayback) {
maybeSetPrimaryUrl(url); maybeSetPrimaryUrl(url);
} }
return snapshot; return snapshot;
......
...@@ -167,11 +167,13 @@ public interface HlsPlaylistTracker { ...@@ -167,11 +167,13 @@ public interface HlsPlaylistTracker {
* HlsUrl}. * HlsUrl}.
* *
* @param url The {@link HlsUrl} corresponding to the requested media playlist. * @param url The {@link HlsUrl} corresponding to the requested media playlist.
* @param isForPlayback Whether the caller might use the snapshot to request media segments for
* playback. If true, the primary playlist may be updated to the one requested.
* @return The most recent snapshot of the playlist referenced by the provided {@link HlsUrl}. May * @return The most recent snapshot of the playlist referenced by the provided {@link HlsUrl}. May
* be null if no snapshot has been loaded yet. * be null if no snapshot has been loaded yet.
*/ */
@Nullable @Nullable
HlsMediaPlaylist getPlaylistSnapshot(HlsUrl url); HlsMediaPlaylist getPlaylistSnapshot(HlsUrl url, boolean isForPlayback);
/** /**
* Returns the start time of the first loaded primary playlist, or {@link C#TIME_UNSET} if no * Returns the start time of the first loaded primary playlist, or {@link C#TIME_UNSET} if no
......
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