use of androidx.media3.exoplayer.source.chunk.ChunkHolder in project media by androidx.
the class DefaultDashChunkSourceTest method getNextChunk_onChunkLoadErrorExclusionDisabled_neverRequestReplacementChunk.
@Test
public void getNextChunk_onChunkLoadErrorExclusionDisabled_neverRequestReplacementChunk() throws Exception {
DefaultLoadErrorHandlingPolicy loadErrorHandlingPolicy = new DefaultLoadErrorHandlingPolicy() {
@Override
@Nullable
public FallbackSelection getFallbackSelectionFor(FallbackOptions fallbackOptions, LoadErrorInfo loadErrorInfo) {
// Never exclude, neither tracks nor locations.
return null;
}
};
DashChunkSource chunkSource = createDashChunkSource(/* numberOfTracks= */
2);
ChunkHolder output = new ChunkHolder();
chunkSource.getNextChunk(/* playbackPositionUs= */
0, /* loadPositionUs= */
0, /* queue= */
ImmutableList.of(), output);
boolean requestReplacementChunk = chunkSource.onChunkLoadError(checkNotNull(output.chunk), /* cancelable= */
true, createFakeLoadErrorInfo(output.chunk.dataSpec, /* httpResponseCode= */
404, /* errorCount= */
1), loadErrorHandlingPolicy);
assertThat(requestReplacementChunk).isFalse();
}
use of androidx.media3.exoplayer.source.chunk.ChunkHolder in project media by androidx.
the class DefaultDashChunkSourceTest method getNextChunk_forLowLatencyManifest_setsCorrectMayNotLoadAtFullNetworkSpeedFlag.
@Test
public void getNextChunk_forLowLatencyManifest_setsCorrectMayNotLoadAtFullNetworkSpeedFlag() throws Exception {
long nowMs = 2_000_000_000_000L;
SystemClock.setCurrentTimeMillis(nowMs);
DashManifest manifest = new DashManifestParser().parse(Uri.parse("https://example.com/test.mpd"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_MPD_LIVE_WITH_OFFSET_INSIDE_WINDOW));
DefaultDashChunkSource chunkSource = new DefaultDashChunkSource(BundledChunkExtractor.FACTORY, new LoaderErrorThrower.Dummy(), manifest, new BaseUrlExclusionList(), /* periodIndex= */
0, /* adaptationSetIndices= */
new int[] { 0 }, new FixedTrackSelection(new TrackGroup(new Format.Builder().build()), /* track= */
0), C.TRACK_TYPE_VIDEO, new FakeDataSource(), /* elapsedRealtimeOffsetMs= */
0, /* maxSegmentsPerLoad= */
1, /* enableEventMessageTrack= */
false, /* closedCaptionFormats */
ImmutableList.of(), /* playerTrackEmsgHandler= */
null, PlayerId.UNSET);
long nowInPeriodUs = Util.msToUs(nowMs - manifest.availabilityStartTimeMs);
ChunkHolder output = new ChunkHolder();
chunkSource.getNextChunk(/* playbackPositionUs= */
nowInPeriodUs - 5 * C.MICROS_PER_SECOND, /* loadPositionUs= */
nowInPeriodUs - 5 * C.MICROS_PER_SECOND, /* queue= */
ImmutableList.of(), output);
assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isEqualTo(0);
chunkSource.getNextChunk(/* playbackPositionUs= */
nowInPeriodUs, /* loadPositionUs= */
nowInPeriodUs, /* queue= */
ImmutableList.of(), output);
assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isNotEqualTo(0);
}
use of androidx.media3.exoplayer.source.chunk.ChunkHolder in project media by androidx.
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");
}
Aggregations