use of com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo in project ExoPlayer by google.
the class DefaultDashChunkSourceTest method getNextChunk_onChunkLoadErrorTrackExclusionEnabled_correctFallbackBehavior.
@Test
public void getNextChunk_onChunkLoadErrorTrackExclusionEnabled_correctFallbackBehavior() throws Exception {
DefaultLoadErrorHandlingPolicy loadErrorHandlingPolicy = new DefaultLoadErrorHandlingPolicy() {
@Override
public FallbackSelection getFallbackSelectionFor(FallbackOptions fallbackOptions, LoadErrorInfo loadErrorInfo) {
// Exclude tracks only.
return new FallbackSelection(FALLBACK_TYPE_TRACK, DefaultLoadErrorHandlingPolicy.DEFAULT_TRACK_EXCLUSION_MS);
}
};
DashChunkSource chunkSource = createDashChunkSource(/* numberOfTracks= */
4);
ChunkHolder output = new ChunkHolder();
List<Chunk> chunks = new ArrayList<>();
boolean requestReplacementChunk = true;
while (requestReplacementChunk) {
chunkSource.getNextChunk(/* playbackPositionUs= */
0, /* loadPositionUs= */
0, /* queue= */
ImmutableList.of(), output);
chunks.add(output.chunk);
requestReplacementChunk = chunkSource.onChunkLoadError(checkNotNull(output.chunk), /* cancelable= */
true, createFakeLoadErrorInfo(output.chunk.dataSpec, /* httpResponseCode= */
404, /* errorCount= */
1), loadErrorHandlingPolicy);
}
assertThat(Lists.transform(chunks, (chunk) -> chunk.dataSpec.uri.toString())).containsExactly("http://video.com/baseUrl/a/video/video_0_700000.m4s", "http://video.com/baseUrl/a/video/video_0_452000.m4s", "http://video.com/baseUrl/a/video/video_0_250000.m4s", "http://video.com/baseUrl/a/video/video_0_1300000.m4s").inOrder();
}
use of com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo in project ExoPlayer by google.
the class SsMediaSource method onLoadError.
@Override
public LoadErrorAction onLoadError(ParsingLoadable<SsManifest> loadable, long elapsedRealtimeMs, long loadDurationMs, IOException error, int errorCount) {
LoadEventInfo loadEventInfo = new LoadEventInfo(loadable.loadTaskId, loadable.dataSpec, loadable.getUri(), loadable.getResponseHeaders(), elapsedRealtimeMs, loadDurationMs, loadable.bytesLoaded());
MediaLoadData mediaLoadData = new MediaLoadData(loadable.type);
long retryDelayMs = loadErrorHandlingPolicy.getRetryDelayMsFor(new LoadErrorInfo(loadEventInfo, mediaLoadData, error, errorCount));
LoadErrorAction loadErrorAction = retryDelayMs == C.TIME_UNSET ? Loader.DONT_RETRY_FATAL : Loader.createRetryAction(/* resetErrorCount= */
false, retryDelayMs);
boolean wasCanceled = !loadErrorAction.isRetry();
manifestEventDispatcher.loadError(loadEventInfo, loadable.type, error, wasCanceled);
if (wasCanceled) {
loadErrorHandlingPolicy.onLoadTaskConcluded(loadable.loadTaskId);
}
return loadErrorAction;
}
Aggregations