mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Fix retry count for live streams in ExtractorMediaPeriod
Also simplify boolean condition in ExtractorMediaSource ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=173247443
This commit is contained in:
parent
e5e984f4c6
commit
ea764b1b79
2 changed files with 13 additions and 13 deletions
|
|
@ -93,6 +93,7 @@ import java.util.Arrays;
|
||||||
private int[] sampleQueueTrackIds;
|
private int[] sampleQueueTrackIds;
|
||||||
private boolean sampleQueuesBuilt;
|
private boolean sampleQueuesBuilt;
|
||||||
private boolean prepared;
|
private boolean prepared;
|
||||||
|
private int actualMinLoadableRetryCount;
|
||||||
|
|
||||||
private boolean seenFirstTrackSelection;
|
private boolean seenFirstTrackSelection;
|
||||||
private boolean notifyDiscontinuity;
|
private boolean notifyDiscontinuity;
|
||||||
|
|
@ -160,6 +161,11 @@ import java.util.Arrays;
|
||||||
sampleQueues = new SampleQueue[0];
|
sampleQueues = new SampleQueue[0];
|
||||||
pendingResetPositionUs = C.TIME_UNSET;
|
pendingResetPositionUs = C.TIME_UNSET;
|
||||||
length = C.LENGTH_UNSET;
|
length = C.LENGTH_UNSET;
|
||||||
|
// Assume on-demand for MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA, until prepared.
|
||||||
|
actualMinLoadableRetryCount =
|
||||||
|
minLoadableRetryCount == ExtractorMediaSource.MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA
|
||||||
|
? ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND
|
||||||
|
: minLoadableRetryCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void release() {
|
public void release() {
|
||||||
|
|
@ -359,7 +365,7 @@ import java.util.Arrays;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ void maybeThrowError() throws IOException {
|
/* package */ void maybeThrowError() throws IOException {
|
||||||
loader.maybeThrowError();
|
loader.maybeThrowError(actualMinLoadableRetryCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* package */ int readData(int track, FormatHolder formatHolder, DecoderInputBuffer buffer,
|
/* package */ int readData(int track, FormatHolder formatHolder, DecoderInputBuffer buffer,
|
||||||
|
|
@ -491,6 +497,10 @@ import java.util.Arrays;
|
||||||
haveAudioVideoTracks |= isAudioVideo;
|
haveAudioVideoTracks |= isAudioVideo;
|
||||||
}
|
}
|
||||||
tracks = new TrackGroupArray(trackArray);
|
tracks = new TrackGroupArray(trackArray);
|
||||||
|
if (minLoadableRetryCount == ExtractorMediaSource.MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA
|
||||||
|
&& length == C.LENGTH_UNSET && seekMap.getDurationUs() == C.TIME_UNSET) {
|
||||||
|
actualMinLoadableRetryCount = ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE;
|
||||||
|
}
|
||||||
prepared = true;
|
prepared = true;
|
||||||
listener.onSourceInfoRefreshed(durationUs, seekMap.isSeekable());
|
listener.onSourceInfoRefreshed(durationUs, seekMap.isSeekable());
|
||||||
callback.onPrepared(this);
|
callback.onPrepared(this);
|
||||||
|
|
@ -516,16 +526,7 @@ import java.util.Arrays;
|
||||||
pendingResetPositionUs = C.TIME_UNSET;
|
pendingResetPositionUs = C.TIME_UNSET;
|
||||||
}
|
}
|
||||||
extractedSamplesCountAtStartOfLoad = getExtractedSamplesCount();
|
extractedSamplesCountAtStartOfLoad = getExtractedSamplesCount();
|
||||||
|
loader.startLoading(loadable, this, actualMinLoadableRetryCount);
|
||||||
int minRetryCount = minLoadableRetryCount;
|
|
||||||
if (minRetryCount == ExtractorMediaSource.MIN_RETRY_COUNT_DEFAULT_FOR_MEDIA) {
|
|
||||||
// We assume on-demand before we're prepared.
|
|
||||||
minRetryCount = !prepared || length != C.LENGTH_UNSET
|
|
||||||
|| (seekMap != null && seekMap.getDurationUs() != C.TIME_UNSET)
|
|
||||||
? ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_ON_DEMAND
|
|
||||||
: ExtractorMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT_LIVE;
|
|
||||||
}
|
|
||||||
loader.startLoading(loadable, this, minRetryCount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureRetry(ExtractingLoadable loadable) {
|
private void configureRetry(ExtractingLoadable loadable) {
|
||||||
|
|
|
||||||
|
|
@ -184,8 +184,7 @@ public final class ExtractorMediaSource implements MediaSource, ExtractorMediaPe
|
||||||
public void onSourceInfoRefreshed(long durationUs, boolean isSeekable) {
|
public void onSourceInfoRefreshed(long durationUs, boolean isSeekable) {
|
||||||
// If we already have the duration from a previous source info refresh, use it.
|
// If we already have the duration from a previous source info refresh, use it.
|
||||||
durationUs = durationUs == C.TIME_UNSET ? timelineDurationUs : durationUs;
|
durationUs = durationUs == C.TIME_UNSET ? timelineDurationUs : durationUs;
|
||||||
if ((timelineDurationUs == durationUs && timelineIsSeekable == isSeekable)
|
if (timelineDurationUs == durationUs && timelineIsSeekable == isSeekable) {
|
||||||
|| (timelineDurationUs != C.TIME_UNSET && durationUs == C.TIME_UNSET)) {
|
|
||||||
// Suppress no-op source info changes.
|
// Suppress no-op source info changes.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue