use of com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project ExoPlayer by google.
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 com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project ExoPlayer by google.
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 com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project ExoPlayer by google.
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 com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project ExoPlayer by google.
the class DefaultDashChunkSourceTest method getNextChunk_onChunkLoadErrorLocationExclusionEnabled_correctFallbackBehavior.
@Test
public void getNextChunk_onChunkLoadErrorLocationExclusionEnabled_correctFallbackBehavior() throws Exception {
DefaultLoadErrorHandlingPolicy loadErrorHandlingPolicy = new DefaultLoadErrorHandlingPolicy() {
@Override
public FallbackSelection getFallbackSelectionFor(FallbackOptions fallbackOptions, LoadErrorInfo loadErrorInfo) {
return new FallbackSelection(FALLBACK_TYPE_LOCATION, DEFAULT_LOCATION_EXCLUSION_MS);
}
};
List<Chunk> chunks = new ArrayList<>();
DashChunkSource chunkSource = createDashChunkSource(/* numberOfTracks= */
1);
ChunkHolder output = new ChunkHolder();
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_1300000.m4s", "http://video.com/baseUrl/b/video/video_0_1300000.m4s", "http://video.com/baseUrl/d/video/video_0_1300000.m4s").inOrder();
// Assert expiration of exclusions.
ShadowSystemClock.advanceBy(Duration.ofMillis(DEFAULT_LOCATION_EXCLUSION_MS));
chunkSource.onChunkLoadError(checkNotNull(output.chunk), /* cancelable= */
true, createFakeLoadErrorInfo(output.chunk.dataSpec, /* httpResponseCode= */
404, /* errorCount= */
1), loadErrorHandlingPolicy);
chunkSource.getNextChunk(/* playbackPositionUs= */
0, /* loadPositionUs= */
0, /* queue= */
ImmutableList.of(), output);
assertThat(output.chunk.dataSpec.uri.toString()).isEqualTo("http://video.com/baseUrl/a/video/video_0_1300000.m4s");
}
use of com.google.android.exoplayer2.upstream.DefaultLoadErrorHandlingPolicy.DEFAULT_LOCATION_EXCLUSION_MS in project ExoPlayer by google.
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);
}
Aggregations