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);
}
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);
}
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);
}
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);
}
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);
}
Aggregations