Search in sources :

Example 11 with LoadErrorInfo

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();
}
Also used : Util(com.google.android.exoplayer2.util.Util) LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) Uri(android.net.Uri) RunWith(org.junit.runner.RunWith) SystemClock(android.os.SystemClock) Random(java.util.Random) AndroidJUnit4(androidx.test.ext.junit.runners.AndroidJUnit4) TestUtil(com.google.android.exoplayer2.testutil.TestUtil) ApplicationProvider(androidx.test.core.app.ApplicationProvider) ArrayList(java.util.ArrayList) Format(com.google.android.exoplayer2.Format) FixedTrackSelection(com.google.android.exoplayer2.trackselection.FixedTrackSelection) PlayerId(com.google.android.exoplayer2.analytics.PlayerId) Lists(com.google.common.collect.Lists) ImmutableList(com.google.common.collect.ImmutableList) DashManifestParser(com.google.android.exoplayer2.source.dash.manifest.DashManifestParser) Duration(java.time.Duration) AdaptiveTrackSelection(com.google.android.exoplayer2.trackselection.AdaptiveTrackSelection) C(com.google.android.exoplayer2.C) BundledChunkExtractor(com.google.android.exoplayer2.source.chunk.BundledChunkExtractor) DefaultLoadErrorHandlingPolicy(com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy) DEFAULT_LOCATION_EXCLUSION_MS(com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS) ImmutableMap(com.google.common.collect.ImmutableMap) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) DataSpec(com.google.android.exoplayer2.upstream.DataSpec) IOException(java.io.IOException) Test(org.junit.Test) Truth.assertThat(com.google.common.truth.Truth.assertThat) HttpDataSource(com.google.android.exoplayer2.upstream.HttpDataSource) ChunkHolder(com.google.android.exoplayer2.source.chunk.ChunkHolder) FakeDataSource(com.google.android.exoplayer2.testutil.FakeDataSource) DefaultBandwidthMeter(com.google.android.exoplayer2.upstream.DefaultBandwidthMeter) List(java.util.List) Nullable(androidx.annotation.Nullable) Chunk(com.google.android.exoplayer2.source.chunk.Chunk) DashManifest(com.google.android.exoplayer2.source.dash.manifest.DashManifest) LoadErrorHandlingPolicy(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy) ShadowSystemClock(org.robolectric.shadows.ShadowSystemClock) MediaLoadData(com.google.android.exoplayer2.source.MediaLoadData) Assertions.checkNotNull(com.google.android.exoplayer2.util.Assertions.checkNotNull) Assertions(com.google.android.exoplayer2.util.Assertions) LoaderErrorThrower(com.google.android.exoplayer2.upstream.LoaderErrorThrower) DefaultLoadErrorHandlingPolicy(com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy) ChunkHolder(com.google.android.exoplayer2.source.chunk.ChunkHolder) ArrayList(java.util.ArrayList) Chunk(com.google.android.exoplayer2.source.chunk.Chunk) Test(org.junit.Test)

Example 12 with LoadErrorInfo

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;
}
Also used : LoadEventInfo(com.google.android.exoplayer2.source.LoadEventInfo) MediaLoadData(com.google.android.exoplayer2.source.MediaLoadData) LoadErrorInfo(com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo) LoadErrorAction(com.google.android.exoplayer2.upstream.Loader.LoadErrorAction)

Aggregations

LoadErrorInfo (com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy.LoadErrorInfo)8 LoadEventInfo (com.google.android.exoplayer2.source.LoadEventInfo)7 MediaLoadData (com.google.android.exoplayer2.source.MediaLoadData)7 Nullable (androidx.annotation.Nullable)6 LoadErrorAction (com.google.android.exoplayer2.upstream.Loader.LoadErrorAction)6 LoadErrorHandlingPolicy (com.google.android.exoplayer2.upstream.LoadErrorHandlingPolicy)4 ChunkHolder (com.google.android.exoplayer2.source.chunk.ChunkHolder)3 DefaultLoadErrorHandlingPolicy (com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy)3 HttpDataSource (com.google.android.exoplayer2.upstream.HttpDataSource)3 Uri (android.net.Uri)2 SystemClock (android.os.SystemClock)2 ApplicationProvider (androidx.test.core.app.ApplicationProvider)2 AndroidJUnit4 (androidx.test.ext.junit.runners.AndroidJUnit4)2 C (com.google.android.exoplayer2.C)2 Format (com.google.android.exoplayer2.Format)2 PlayerId (com.google.android.exoplayer2.analytics.PlayerId)2 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)2 BundledChunkExtractor (com.google.android.exoplayer2.source.chunk.BundledChunkExtractor)2 Chunk (com.google.android.exoplayer2.source.chunk.Chunk)2 DashManifest (com.google.android.exoplayer2.source.dash.manifest.DashManifest)2