A few bug fixes.
1. Suppress onContinueLoadingRequested until a source is prepared (since such calls are not supposed to be made until after preparation has completed). 2. Don't use the format evaluator in HlsChunkSource prior to prepration completing. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=126794616
This commit is contained in:
parent
8c0e0b690e
commit
1a3de408ac
@ -192,6 +192,10 @@ public final class MultiSampleSource implements SampleSource, SampleSource.Callb
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContinueLoadingRequested(SampleSource ignored) {
|
public void onContinueLoadingRequested(SampleSource ignored) {
|
||||||
|
if (trackGroups == null) {
|
||||||
|
// Still preparing.
|
||||||
|
return;
|
||||||
|
}
|
||||||
callback.onContinueLoadingRequested(this);
|
callback.onContinueLoadingRequested(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,6 @@ public class HlsChunkSource {
|
|||||||
private final Variant[] variants;
|
private final Variant[] variants;
|
||||||
private final HlsMediaPlaylist[] variantPlaylists;
|
private final HlsMediaPlaylist[] variantPlaylists;
|
||||||
private final long[] variantLastPlaylistLoadTimesMs;
|
private final long[] variantLastPlaylistLoadTimesMs;
|
||||||
private final int initialEnabledVariantIndex;
|
|
||||||
|
|
||||||
private boolean seenFirstExternalTrackSelection;
|
private boolean seenFirstExternalTrackSelection;
|
||||||
private byte[] scratchSpace;
|
private byte[] scratchSpace;
|
||||||
@ -119,7 +118,6 @@ public class HlsChunkSource {
|
|||||||
initialTrackSelection[i] = i;
|
initialTrackSelection[i] = i;
|
||||||
}
|
}
|
||||||
selectTracksInternal(initialTrackSelection, false);
|
selectTracksInternal(initialTrackSelection, false);
|
||||||
initialEnabledVariantIndex = getEnabledVariantIndex(variants[0].format);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -440,6 +438,10 @@ public class HlsChunkSource {
|
|||||||
enabledVariantBlacklistTimes = new long[enabledVariants.length];
|
enabledVariantBlacklistTimes = new long[enabledVariants.length];
|
||||||
enabledVariantBlacklistFlags = new boolean[enabledVariants.length];
|
enabledVariantBlacklistFlags = new boolean[enabledVariants.length];
|
||||||
|
|
||||||
|
if (!isExternal) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (enabledVariants.length > 1) {
|
if (enabledVariants.length > 1) {
|
||||||
Format[] formats = new Format[enabledVariants.length];
|
Format[] formats = new Format[enabledVariants.length];
|
||||||
for (int i = 0; i < formats.length; i++) {
|
for (int i = 0; i < formats.length; i++) {
|
||||||
@ -458,11 +460,26 @@ public class HlsChunkSource {
|
|||||||
|
|
||||||
private void updateFormatEvaluation(HlsMediaChunk previous, long playbackPositionUs) {
|
private void updateFormatEvaluation(HlsMediaChunk previous, long playbackPositionUs) {
|
||||||
clearStaleBlacklistedVariants();
|
clearStaleBlacklistedVariants();
|
||||||
if (!seenFirstExternalTrackSelection
|
if (!seenFirstExternalTrackSelection) {
|
||||||
&& !enabledVariantBlacklistFlags[initialEnabledVariantIndex]) {
|
if (!enabledVariantBlacklistFlags[getEnabledVariantIndex(variants[0].format)]) {
|
||||||
// Use the first variant prior to external track selection, unless it's been blacklisted.
|
// Use the first variant prior to external track selection, unless it's been blacklisted.
|
||||||
evaluation.format = variants[0].format;
|
evaluation.format = variants[0].format;
|
||||||
} else if (enabledVariants.length > 1) {
|
return;
|
||||||
|
}
|
||||||
|
// Try from lowest bitrate to highest.
|
||||||
|
for (int i = enabledVariants.length - 1; i >= 0; i--) {
|
||||||
|
if (!enabledVariantBlacklistFlags[i]) {
|
||||||
|
evaluation.format = enabledVariants[i].format;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Should never happen.
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
if (enabledVariants.length == 1) {
|
||||||
|
evaluation.format = enabledVariants[0].format;
|
||||||
|
return;
|
||||||
|
}
|
||||||
long bufferedDurationUs;
|
long bufferedDurationUs;
|
||||||
if (previous != null) {
|
if (previous != null) {
|
||||||
// Use start time of the previous chunk rather than its end time because switching format
|
// Use start time of the previous chunk rather than its end time because switching format
|
||||||
@ -473,9 +490,6 @@ public class HlsChunkSource {
|
|||||||
}
|
}
|
||||||
adaptiveFormatEvaluator.evaluateFormat(bufferedDurationUs, enabledVariantBlacklistFlags,
|
adaptiveFormatEvaluator.evaluateFormat(bufferedDurationUs, enabledVariantBlacklistFlags,
|
||||||
evaluation);
|
evaluation);
|
||||||
} else {
|
|
||||||
evaluation.format = enabledVariants[0].format;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean shouldRerequestLiveMediaPlaylist(int variantIndex) {
|
private boolean shouldRerequestLiveMediaPlaylist(int variantIndex) {
|
||||||
|
@ -284,6 +284,10 @@ public final class HlsSampleSource implements SampleSource,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onContinueLoadingRequested(HlsTrackStreamWrapper trackStreamWrapper) {
|
public void onContinueLoadingRequested(HlsTrackStreamWrapper trackStreamWrapper) {
|
||||||
|
if (trackGroups == null) {
|
||||||
|
// Still preparing.
|
||||||
|
return;
|
||||||
|
}
|
||||||
callback.onContinueLoadingRequested(this);
|
callback.onContinueLoadingRequested(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user