mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +00:00
Fix unnecessary media playlist requests when playing live streams
Issue: #5059 PiperOrigin-RevId: 222803511
This commit is contained in:
parent
40c65dbcea
commit
d6b6600a28
4 changed files with 12 additions and 6 deletions
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
### 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
|
||||
([#4883](https://github.com/google/ExoPlayer/issues/4883)).
|
||||
* DASH: Fix detecting the end of live events
|
||||
|
|
|
|||
|
|
@ -262,7 +262,8 @@ import java.util.List;
|
|||
// Retry when playlist is refreshed.
|
||||
return;
|
||||
}
|
||||
HlsMediaPlaylist mediaPlaylist = playlistTracker.getPlaylistSnapshot(selectedUrl);
|
||||
HlsMediaPlaylist mediaPlaylist =
|
||||
playlistTracker.getPlaylistSnapshot(selectedUrl, /* isForPlayback= */ true);
|
||||
independentSegments = mediaPlaylist.hasIndependentSegments;
|
||||
|
||||
updateLiveEdgeTimeUs(mediaPlaylist);
|
||||
|
|
@ -279,7 +280,7 @@ import java.util.List;
|
|||
// behind the live window.
|
||||
selectedVariantIndex = oldVariantIndex;
|
||||
selectedUrl = variants[selectedVariantIndex];
|
||||
mediaPlaylist = playlistTracker.getPlaylistSnapshot(selectedUrl);
|
||||
mediaPlaylist = playlistTracker.getPlaylistSnapshot(selectedUrl, /* isForPlayback= */ true);
|
||||
startOfPlaylistInPeriodUs =
|
||||
mediaPlaylist.startTimeUs - playlistTracker.getInitialStartTimeUs();
|
||||
chunkMediaSequence = previous.getNextChunkIndex();
|
||||
|
|
@ -435,7 +436,8 @@ import java.util.List;
|
|||
chunkIterators[i] = MediaChunkIterator.EMPTY;
|
||||
continue;
|
||||
}
|
||||
HlsMediaPlaylist playlist = playlistTracker.getPlaylistSnapshot(variantUrl);
|
||||
HlsMediaPlaylist playlist =
|
||||
playlistTracker.getPlaylistSnapshot(variantUrl, /* isForPlayback= */ false);
|
||||
long startOfPlaylistInPeriodUs =
|
||||
playlist.startTimeUs - playlistTracker.getInitialStartTimeUs();
|
||||
boolean switchingVariant = variantIndex != oldVariantIndex;
|
||||
|
|
|
|||
|
|
@ -162,9 +162,9 @@ public final class DefaultHlsPlaylistTracker
|
|||
}
|
||||
|
||||
@Override
|
||||
public HlsMediaPlaylist getPlaylistSnapshot(HlsUrl url) {
|
||||
public HlsMediaPlaylist getPlaylistSnapshot(HlsUrl url, boolean isForPlayback) {
|
||||
HlsMediaPlaylist snapshot = playlistBundles.get(url).getPlaylistSnapshot();
|
||||
if (snapshot != null) {
|
||||
if (snapshot != null && isForPlayback) {
|
||||
maybeSetPrimaryUrl(url);
|
||||
}
|
||||
return snapshot;
|
||||
|
|
|
|||
|
|
@ -167,11 +167,13 @@ public interface HlsPlaylistTracker {
|
|||
* HlsUrl}.
|
||||
*
|
||||
* @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
|
||||
* be null if no snapshot has been loaded yet.
|
||||
*/
|
||||
@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
|
||||
|
|
|
|||
Loading…
Reference in a new issue