mirror of
https://github.com/samsonjs/media.git
synced 2026-03-27 09:45:47 +00:00
Propagate playlist loading error if it prevents playback
This imitates DashMediaSource's behavior. Issue:#2623 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=155485738
This commit is contained in:
parent
51132f58f9
commit
70b628526a
3 changed files with 23 additions and 5 deletions
|
|
@ -92,6 +92,7 @@ import java.util.Locale;
|
|||
private boolean isTimestampMaster;
|
||||
private byte[] scratchSpace;
|
||||
private IOException fatalError;
|
||||
private HlsUrl expectedPlaylistUrl;
|
||||
|
||||
private Uri encryptionKeyUri;
|
||||
private byte[] encryptionKey;
|
||||
|
|
@ -143,6 +144,9 @@ import java.util.Locale;
|
|||
if (fatalError != null) {
|
||||
throw fatalError;
|
||||
}
|
||||
if (expectedPlaylistUrl != null) {
|
||||
playlistTracker.maybeThrowPlaylistRefreshError(expectedPlaylistUrl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -195,6 +199,7 @@ import java.util.Locale;
|
|||
public void getNextChunk(HlsMediaChunk previous, long playbackPositionUs, HlsChunkHolder out) {
|
||||
int oldVariantIndex = previous == null ? C.INDEX_UNSET
|
||||
: trackGroup.indexOf(previous.trackFormat);
|
||||
expectedPlaylistUrl = null;
|
||||
// Use start time of the previous chunk rather than its end time because switching format will
|
||||
// require downloading overlapping segments.
|
||||
long bufferedDurationUs = previous == null ? 0
|
||||
|
|
@ -208,6 +213,7 @@ import java.util.Locale;
|
|||
HlsUrl selectedUrl = variants[selectedVariantIndex];
|
||||
if (!playlistTracker.isSnapshotValid(selectedUrl)) {
|
||||
out.playlist = selectedUrl;
|
||||
expectedPlaylistUrl = selectedUrl;
|
||||
// Retry when playlist is refreshed.
|
||||
return;
|
||||
}
|
||||
|
|
@ -247,6 +253,7 @@ import java.util.Locale;
|
|||
out.endOfStream = true;
|
||||
} else /* Live */ {
|
||||
out.playlist = selectedUrl;
|
||||
expectedPlaylistUrl = selectedUrl;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public final class HlsMediaSource implements MediaSource,
|
|||
|
||||
@Override
|
||||
public void maybeThrowSourceInfoRefreshError() throws IOException {
|
||||
playlistTracker.maybeThrowPlaylistRefreshError();
|
||||
playlistTracker.maybeThrowPrimaryPlaylistRefreshError();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -200,18 +200,29 @@ public final class HlsPlaylistTracker implements Loader.Callback<ParsingLoadable
|
|||
}
|
||||
|
||||
/**
|
||||
* If the tracker is having trouble refreshing the primary playlist or loading an irreplaceable
|
||||
* playlist, this method throws the underlying error. Otherwise, does nothing.
|
||||
* If the tracker is having trouble refreshing the master playlist or the primary playlist, this
|
||||
* method throws the underlying error. Otherwise, does nothing.
|
||||
*
|
||||
* @throws IOException The underlying error.
|
||||
*/
|
||||
public void maybeThrowPlaylistRefreshError() throws IOException {
|
||||
public void maybeThrowPrimaryPlaylistRefreshError() throws IOException {
|
||||
initialPlaylistLoader.maybeThrowError();
|
||||
if (primaryHlsUrl != null) {
|
||||
playlistBundles.get(primaryHlsUrl).mediaPlaylistLoader.maybeThrowError();
|
||||
maybeThrowPlaylistRefreshError(primaryHlsUrl);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the playlist is having trouble loading the playlist referenced by the given {@link HlsUrl},
|
||||
* this method throws the underlying error.
|
||||
*
|
||||
* @param url The {@link HlsUrl}.
|
||||
* @throws IOException The underyling error.
|
||||
*/
|
||||
public void maybeThrowPlaylistRefreshError(HlsUrl url) throws IOException {
|
||||
playlistBundles.get(url).mediaPlaylistLoader.maybeThrowError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Triggers a playlist refresh and whitelists it.
|
||||
*
|
||||
|
|
|
|||
Loading…
Reference in a new issue