Search in sources :

Example 1 with DEFAULT_LOCATION_EXCLUSION_MS

use of androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project media by androidx.

the class BaseUrlExclusionListTest method getPriorityCountAfterExclusion_correctPriorityCount.

@Test
public void getPriorityCountAfterExclusion_correctPriorityCount() {
    List<BaseUrl> baseUrls = ImmutableList.of(new BaseUrl(/* url= */
    "a", /* serviceLocation= */
    "a", /* priority= */
    1, /* weight= */
    1), new BaseUrl(/* url= */
    "b", /* serviceLocation= */
    "b", /* priority= */
    2, /* weight= */
    1), new BaseUrl(/* url= */
    "c", /* serviceLocation= */
    "c", /* priority= */
    2, /* weight= */
    1), new BaseUrl(/* url= */
    "d", /* serviceLocation= */
    "d", /* priority= */
    3, /* weight= */
    1), new BaseUrl(/* url= */
    "e", /* serviceLocation= */
    "e", /* priority= */
    3, /* weight= */
    1));
    BaseUrlExclusionList baseUrlExclusionList = new BaseUrlExclusionList();
    // Empty base URL list.
    assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(ImmutableList.of())).isEqualTo(0);
    assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(3);
    // Exclude base urls.
    baseUrlExclusionList.exclude(baseUrls.get(0), DEFAULT_LOCATION_EXCLUSION_MS);
    assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(2);
    baseUrlExclusionList.exclude(baseUrls.get(1), 2 * DEFAULT_LOCATION_EXCLUSION_MS);
    assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(1);
    baseUrlExclusionList.exclude(baseUrls.get(3), 3 * DEFAULT_LOCATION_EXCLUSION_MS);
    assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(0);
    // Time passes.
    ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS));
    assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(1);
    ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS));
    assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(2);
    ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS));
    assertThat(baseUrlExclusionList.getPriorityCountAfterExclusion(baseUrls)).isEqualTo(3);
}
Also used : BaseUrl(androidx.media3.exoplayer.dash.manifest.BaseUrl) Test(org.junit.Test)

Example 2 with DEFAULT_LOCATION_EXCLUSION_MS

use of androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project media by androidx.

the class DefaultLoadErrorHandlingPolicyTest method getFallbackSelectionFor_responseCode500.

@Test
public void getFallbackSelectionFor_responseCode500() {
    InvalidResponseCodeException exception = buildInvalidResponseCodeException(500, "Internal server error");
    @Nullable LoadErrorHandlingPolicy.FallbackSelection defaultPolicyFallbackSelection = getDefaultPolicyFallbackSelection(exception, /* numberOfLocations= */
    1, /* numberOfExcludedLocations= */
    0, /* numberOfTracks= */
    10, /* numberOfExcludedTracks= */
    0);
    assertThat(defaultPolicyFallbackSelection.type).isEqualTo(FALLBACK_TYPE_TRACK);
    assertThat(defaultPolicyFallbackSelection.exclusionDurationMs).isEqualTo(DEFAULT_TRACK_EXCLUSION_MS);
    defaultPolicyFallbackSelection = getDefaultPolicyFallbackSelection(exception, /* numberOfLocations= */
    2, /* numberOfExcludedLocations= */
    0, /* numberOfTracks= */
    4, /* numberOfExcludedTracks= */
    1);
    assertThat(defaultPolicyFallbackSelection.type).isEqualTo(FALLBACK_TYPE_LOCATION);
    assertThat(defaultPolicyFallbackSelection.exclusionDurationMs).isEqualTo(DEFAULT_LOCATION_EXCLUSION_MS);
}
Also used : InvalidResponseCodeException(androidx.media3.datasource.HttpDataSource.InvalidResponseCodeException) Nullable(androidx.annotation.Nullable) Test(org.junit.Test)

Example 3 with DEFAULT_LOCATION_EXCLUSION_MS

use of androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project media by androidx.

the class DefaultLoadErrorHandlingPolicyTest method getFallbackSelectionFor_responseCode403.

@Test
public void getFallbackSelectionFor_responseCode403() {
    InvalidResponseCodeException exception = buildInvalidResponseCodeException(403, "Forbidden");
    @Nullable LoadErrorHandlingPolicy.FallbackSelection defaultPolicyFallbackSelection = getDefaultPolicyFallbackSelection(exception, /* numberOfLocations= */
    1, /* numberOfExcludedLocations= */
    0, /* numberOfTracks= */
    10, /* numberOfExcludedTracks= */
    0);
    assertThat(defaultPolicyFallbackSelection.type).isEqualTo(FALLBACK_TYPE_TRACK);
    assertThat(defaultPolicyFallbackSelection.exclusionDurationMs).isEqualTo(DEFAULT_TRACK_EXCLUSION_MS);
    defaultPolicyFallbackSelection = getDefaultPolicyFallbackSelection(exception, /* numberOfLocations= */
    2, /* numberOfExcludedLocations= */
    0, /* numberOfTracks= */
    4, /* numberOfExcludedTracks= */
    1);
    assertThat(defaultPolicyFallbackSelection.type).isEqualTo(FALLBACK_TYPE_LOCATION);
    assertThat(defaultPolicyFallbackSelection.exclusionDurationMs).isEqualTo(DEFAULT_LOCATION_EXCLUSION_MS);
}
Also used : InvalidResponseCodeException(androidx.media3.datasource.HttpDataSource.InvalidResponseCodeException) Nullable(androidx.annotation.Nullable) Test(org.junit.Test)

Example 4 with DEFAULT_LOCATION_EXCLUSION_MS

use of androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project media by androidx.

the class DefaultLoadErrorHandlingPolicyTest method getFallbackSelectionFor_responseCode410.

@Test
public void getFallbackSelectionFor_responseCode410() {
    InvalidResponseCodeException exception = buildInvalidResponseCodeException(410, "Gone");
    @Nullable LoadErrorHandlingPolicy.FallbackSelection defaultPolicyFallbackSelection = getDefaultPolicyFallbackSelection(exception, /* numberOfLocations= */
    1, /* numberOfExcludedLocations= */
    0, /* numberOfTracks= */
    10, /* numberOfExcludedTracks= */
    0);
    assertThat(defaultPolicyFallbackSelection.type).isEqualTo(FALLBACK_TYPE_TRACK);
    assertThat(defaultPolicyFallbackSelection.exclusionDurationMs).isEqualTo(DEFAULT_TRACK_EXCLUSION_MS);
    defaultPolicyFallbackSelection = getDefaultPolicyFallbackSelection(exception, /* numberOfLocations= */
    2, /* numberOfExcludedLocations= */
    0, /* numberOfTracks= */
    4, /* numberOfExcludedTracks= */
    1);
    assertThat(defaultPolicyFallbackSelection.type).isEqualTo(FALLBACK_TYPE_LOCATION);
    assertThat(defaultPolicyFallbackSelection.exclusionDurationMs).isEqualTo(DEFAULT_LOCATION_EXCLUSION_MS);
}
Also used : InvalidResponseCodeException(androidx.media3.datasource.HttpDataSource.InvalidResponseCodeException) Nullable(androidx.annotation.Nullable) Test(org.junit.Test)

Example 5 with DEFAULT_LOCATION_EXCLUSION_MS

use of androidx.media3.exoplayer.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project media by androidx.

the class DefaultLoadErrorHandlingPolicyTest method getFallbackSelectionFor_responseCode404.

@Test
public void getFallbackSelectionFor_responseCode404() {
    InvalidResponseCodeException exception = buildInvalidResponseCodeException(404, "Not found");
    @Nullable LoadErrorHandlingPolicy.FallbackSelection defaultPolicyFallbackSelection = getDefaultPolicyFallbackSelection(exception, /* numberOfLocations= */
    1, /* numberOfExcludedLocations= */
    0, /* numberOfTracks= */
    10, /* numberOfExcludedTracks= */
    0);
    assertThat(defaultPolicyFallbackSelection.type).isEqualTo(FALLBACK_TYPE_TRACK);
    assertThat(defaultPolicyFallbackSelection.exclusionDurationMs).isEqualTo(DEFAULT_TRACK_EXCLUSION_MS);
    defaultPolicyFallbackSelection = getDefaultPolicyFallbackSelection(exception, /* numberOfLocations= */
    2, /* numberOfExcludedLocations= */
    0, /* numberOfTracks= */
    4, /* numberOfExcludedTracks= */
    1);
    assertThat(defaultPolicyFallbackSelection.type).isEqualTo(FALLBACK_TYPE_LOCATION);
    assertThat(defaultPolicyFallbackSelection.exclusionDurationMs).isEqualTo(DEFAULT_LOCATION_EXCLUSION_MS);
}
Also used : InvalidResponseCodeException(androidx.media3.datasource.HttpDataSource.InvalidResponseCodeException) Nullable(androidx.annotation.Nullable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)7 Nullable (androidx.annotation.Nullable)6 InvalidResponseCodeException (androidx.media3.datasource.HttpDataSource.InvalidResponseCodeException)5 Uri (android.net.Uri)1 SystemClock (android.os.SystemClock)1 C (androidx.media3.common.C)1 Format (androidx.media3.common.Format)1 TrackGroup (androidx.media3.common.TrackGroup)1 Assertions (androidx.media3.common.util.Assertions)1 Assertions.checkNotNull (androidx.media3.common.util.Assertions.checkNotNull)1 Util (androidx.media3.common.util.Util)1 DataSpec (androidx.media3.datasource.DataSpec)1 HttpDataSource (androidx.media3.datasource.HttpDataSource)1 PlayerId (androidx.media3.exoplayer.analytics.PlayerId)1 BaseUrl (androidx.media3.exoplayer.dash.manifest.BaseUrl)1 DashManifest (androidx.media3.exoplayer.dash.manifest.DashManifest)1 DashManifestParser (androidx.media3.exoplayer.dash.manifest.DashManifestParser)1 LoadEventInfo (androidx.media3.exoplayer.source.LoadEventInfo)1 MediaLoadData (androidx.media3.exoplayer.source.MediaLoadData)1 BundledChunkExtractor (androidx.media3.exoplayer.source.chunk.BundledChunkExtractor)1