use of androidx.media3.exoplayer.trackselection.FixedTrackSelection in project media by androidx.
the class DefaultDashChunkSourceTest method getNextChunk_forVodManifest_doesNotSetMayNotLoadAtFullNetworkSpeedFlag.
@Test
public void getNextChunk_forVodManifest_doesNotSetMayNotLoadAtFullNetworkSpeedFlag() 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_VOD));
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);
ChunkHolder output = new ChunkHolder();
chunkSource.getNextChunk(/* playbackPositionUs= */
0, /* loadPositionUs= */
0, /* queue= */
ImmutableList.of(), output);
assertThat(output.chunk.dataSpec.flags & DataSpec.FLAG_MIGHT_NOT_USE_FULL_NETWORK_SPEED).isEqualTo(0);
}
use of androidx.media3.exoplayer.trackselection.FixedTrackSelection in project media by androidx.
the class DefaultTrackSelectorTest method selectTrack_withMixedEmptyAndNonEmptyTrackOverrides_appliesNonEmptyOverride.
@Test
public void selectTrack_withMixedEmptyAndNonEmptyTrackOverrides_appliesNonEmptyOverride() throws Exception {
TrackGroup videoGroupHighBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(1_000_000).build());
TrackGroup videoGroupMidBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(500_000).build());
TrackGroup videoGroupLowBitrate = new TrackGroup(VIDEO_FORMAT.buildUpon().setAverageBitrate(100_000).build());
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().addOverride(new TrackSelectionOverride(videoGroupHighBitrate, /* trackIndices= */
ImmutableList.of())).addOverride(new TrackSelectionOverride(videoGroupMidBitrate, /* trackIndices= */
ImmutableList.of(0))).addOverride(new TrackSelectionOverride(videoGroupLowBitrate, /* trackIndices= */
ImmutableList.of())).build()));
TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, new TrackGroupArray(videoGroupHighBitrate, videoGroupMidBitrate, videoGroupLowBitrate), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(new FixedTrackSelection(videoGroupMidBitrate, /* track= */
0), null).inOrder();
}
use of androidx.media3.exoplayer.trackselection.FixedTrackSelection in project media by androidx.
the class MappingTrackSelectorTest method buildTrackInfos_withTestValues_isAsExpected.
@Test
public void buildTrackInfos_withTestValues_isAsExpected() {
MappingTrackSelector.MappedTrackInfo mappedTrackInfo = new MappingTrackSelector.MappedTrackInfo(new String[] { "1", "2" }, new int[] { C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO }, new TrackGroupArray[] { new TrackGroupArray(new TrackGroup("0", new Format.Builder().build()), new TrackGroup("1", new Format.Builder().build())), new TrackGroupArray(new TrackGroup("2", new Format.Builder().build(), new Format.Builder().build())) }, new int[] { RendererCapabilities.ADAPTIVE_SEAMLESS, RendererCapabilities.ADAPTIVE_NOT_SUPPORTED }, new int[][][] { new int[][] { new int[] { C.FORMAT_HANDLED }, new int[] { C.FORMAT_UNSUPPORTED_SUBTYPE } }, new int[][] { new int[] { C.FORMAT_UNSUPPORTED_DRM, C.FORMAT_EXCEEDS_CAPABILITIES } } }, new TrackGroupArray(new TrackGroup(new Format.Builder().build())));
TrackSelection[] selections = new TrackSelection[] { new FixedTrackSelection(mappedTrackInfo.getTrackGroups(0).get(1), 0), new FixedTrackSelection(mappedTrackInfo.getTrackGroups(1).get(0), 1) };
TracksInfo tracksInfo = MappingTrackSelector.buildTracksInfo(selections, mappedTrackInfo);
ImmutableList<TrackGroupInfo> trackGroupInfos = tracksInfo.getTrackGroupInfos();
assertThat(trackGroupInfos).hasSize(4);
assertThat(trackGroupInfos.get(0).getTrackGroup()).isEqualTo(mappedTrackInfo.getTrackGroups(0).get(0));
assertThat(trackGroupInfos.get(1).getTrackGroup()).isEqualTo(mappedTrackInfo.getTrackGroups(0).get(1));
assertThat(trackGroupInfos.get(2).getTrackGroup()).isEqualTo(mappedTrackInfo.getTrackGroups(1).get(0));
assertThat(trackGroupInfos.get(3).getTrackGroup()).isEqualTo(mappedTrackInfo.getUnmappedTrackGroups().get(0));
assertThat(trackGroupInfos.get(0).getTrackSupport(0)).isEqualTo(C.FORMAT_HANDLED);
assertThat(trackGroupInfos.get(1).getTrackSupport(0)).isEqualTo(C.FORMAT_UNSUPPORTED_SUBTYPE);
assertThat(trackGroupInfos.get(2).getTrackSupport(0)).isEqualTo(C.FORMAT_UNSUPPORTED_DRM);
assertThat(trackGroupInfos.get(2).getTrackSupport(1)).isEqualTo(C.FORMAT_EXCEEDS_CAPABILITIES);
assertThat(trackGroupInfos.get(3).getTrackSupport(0)).isEqualTo(C.FORMAT_UNSUPPORTED_TYPE);
assertThat(trackGroupInfos.get(0).isTrackSelected(0)).isFalse();
assertThat(trackGroupInfos.get(1).isTrackSelected(0)).isTrue();
assertThat(trackGroupInfos.get(2).isTrackSelected(0)).isFalse();
assertThat(trackGroupInfos.get(2).isTrackSelected(1)).isTrue();
assertThat(trackGroupInfos.get(3).isTrackSelected(0)).isFalse();
assertThat(trackGroupInfos.get(0).getTrackType()).isEqualTo(C.TRACK_TYPE_AUDIO);
assertThat(trackGroupInfos.get(1).getTrackType()).isEqualTo(C.TRACK_TYPE_AUDIO);
assertThat(trackGroupInfos.get(2).getTrackType()).isEqualTo(C.TRACK_TYPE_VIDEO);
assertThat(trackGroupInfos.get(3).getTrackType()).isEqualTo(C.TRACK_TYPE_UNKNOWN);
}
use of androidx.media3.exoplayer.trackselection.FixedTrackSelection in project media by androidx.
the class DefaultTrackSelectorTest method selectTrack_withOverrideForDifferentRenderer_clearsDefaultSelectionOfSameType.
@Test
public void selectTrack_withOverrideForDifferentRenderer_clearsDefaultSelectionOfSameType() throws Exception {
Format videoFormatH264 = VIDEO_FORMAT.buildUpon().setId("H264").setSampleMimeType(MimeTypes.VIDEO_H264).build();
Format videoFormatAv1 = VIDEO_FORMAT.buildUpon().setId("AV1").setSampleMimeType(MimeTypes.VIDEO_AV1).build();
TrackGroup videoGroupH264 = new TrackGroup(videoFormatH264);
TrackGroup videoGroupAv1 = new TrackGroup(videoFormatAv1);
Map<String, Integer> rendererCapabilitiesMap = ImmutableMap.of(videoFormatH264.id, FORMAT_HANDLED, videoFormatAv1.id, FORMAT_UNSUPPORTED_TYPE);
RendererCapabilities rendererCapabilitiesH264 = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
rendererCapabilitiesMap = ImmutableMap.of(videoFormatH264.id, FORMAT_UNSUPPORTED_TYPE, videoFormatAv1.id, FORMAT_HANDLED);
RendererCapabilities rendererCapabilitiesAv1 = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
// Try to force selection of one TrackGroup in both directions to ensure the default gets
// overridden without having to know what the default is.
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(videoGroupH264)).build()));
TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilitiesH264, rendererCapabilitiesAv1 }, new TrackGroupArray(videoGroupH264, videoGroupAv1), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(new FixedTrackSelection(videoGroupH264, /* track= */
0), null).inOrder();
trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(videoGroupAv1)).build()));
result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilitiesH264, rendererCapabilitiesAv1 }, new TrackGroupArray(videoGroupH264, videoGroupAv1), periodId, TIMELINE);
assertThat(result.selections).asList().containsExactly(null, new FixedTrackSelection(videoGroupAv1, /* track= */
0)).inOrder();
}
use of androidx.media3.exoplayer.trackselection.FixedTrackSelection in project media by androidx.
the class MergingMediaPeriodTest method selectTracks_createsSampleStreamsFromChildPeriods.
@Test
public void selectTracks_createsSampleStreamsFromChildPeriods() throws Exception {
MergingMediaPeriod mergingMediaPeriod = prepareMergingPeriod(new MergingPeriodDefinition(/* timeOffsetUs= */
0, /* singleSampleTimeUs= */
0, childFormat11, childFormat12), new MergingPeriodDefinition(/* timeOffsetUs= */
0, /* singleSampleTimeUs= */
0, childFormat21, childFormat22));
ExoTrackSelection selectionForChild1 = new FixedTrackSelection(mergingMediaPeriod.getTrackGroups().get(1), /* track= */
0);
ExoTrackSelection selectionForChild2 = new FixedTrackSelection(mergingMediaPeriod.getTrackGroups().get(2), /* track= */
0);
SampleStream[] streams = new SampleStream[4];
mergingMediaPeriod.selectTracks(/* selections= */
new ExoTrackSelection[] { null, selectionForChild1, selectionForChild2, null }, /* mayRetainStreamFlags= */
new boolean[] { false, false, false, false }, streams, /* streamResetFlags= */
new boolean[] { false, false, false, false }, /* positionUs= */
0);
mergingMediaPeriod.continueLoading(/* positionUs= */
0);
assertThat(streams[0]).isNull();
assertThat(streams[3]).isNull();
FormatHolder formatHolder = new FormatHolder();
DecoderInputBuffer inputBuffer = new DecoderInputBuffer(DecoderInputBuffer.BUFFER_REPLACEMENT_MODE_NORMAL);
assertThat(streams[1].readData(formatHolder, inputBuffer, FLAG_REQUIRE_FORMAT)).isEqualTo(C.RESULT_FORMAT_READ);
assertThat(formatHolder.format).isEqualTo(childFormat12);
assertThat(streams[2].readData(formatHolder, inputBuffer, FLAG_REQUIRE_FORMAT)).isEqualTo(C.RESULT_FORMAT_READ);
assertThat(formatHolder.format).isEqualTo(childFormat21);
}
Aggregations