Search in sources :

Example 11 with TrackSelectorResult

use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.

the class DefaultTrackSelectorTest method selectTracksWithMultipleVideoTracksWithNonSeamlessAdaptiveness.

@Test
public void selectTracksWithMultipleVideoTracksWithNonSeamlessAdaptiveness() throws Exception {
    FakeRendererCapabilities nonSeamlessVideoCapabilities = new FakeRendererCapabilities(C.TRACK_TYPE_VIDEO, RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED));
    // Should do non-seamless adaptiveness by default, so expect an adaptive selection.
    Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
    TrackGroupArray trackGroups = singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build());
    trackSelector.setParameters(defaultParameters.buildUpon().setAllowVideoNonSeamlessAdaptiveness(true));
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { nonSeamlessVideoCapabilities }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
    // If we explicitly disable non-seamless adaptiveness, expect a fixed selection.
    trackSelector.setParameters(defaultParameters.buildUpon().setAllowVideoNonSeamlessAdaptiveness(false));
    result = trackSelector.selectTracks(new RendererCapabilities[] { nonSeamlessVideoCapabilities }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertFixedSelection(result.selections[0], trackGroups.get(0), 0);
}
Also used : Format(androidx.media3.common.Format) TrackGroupArray(androidx.media3.common.TrackGroupArray) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) Test(org.junit.Test)

Example 12 with TrackSelectorResult

use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.

the class DefaultTrackSelectorTest method selectTracks_multipleRenderer_allSelected.

/**
 * Tests audio track selection when there are multiple audio renderers.
 */
@Test
public void selectTracks_multipleRenderer_allSelected() throws Exception {
    RendererCapabilities[] rendererCapabilities = new RendererCapabilities[] { VIDEO_CAPABILITIES, AUDIO_CAPABILITIES, AUDIO_CAPABILITIES };
    TrackGroupArray trackGroups = new TrackGroupArray(AUDIO_TRACK_GROUP);
    TrackSelectorResult result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(3);
    assertThat(result.rendererConfigurations).asList().containsExactly(null, DEFAULT, null).inOrder();
    assertThat(result.selections[0]).isNull();
    assertFixedSelection(result.selections[1], trackGroups, trackGroups.get(0).getFormat(0));
    assertThat(result.selections[2]).isNull();
    ImmutableList<TracksInfo.TrackGroupInfo> trackGroupInfos = result.tracksInfo.getTrackGroupInfos();
    assertThat(trackGroupInfos).hasSize(1);
    assertThat(trackGroupInfos.get(0).getTrackGroup()).isEqualTo(AUDIO_TRACK_GROUP);
    assertThat(trackGroupInfos.get(0).isTrackSelected(0)).isTrue();
    assertThat(trackGroupInfos.get(0).getTrackSupport(0)).isEqualTo(FORMAT_HANDLED);
}
Also used : TrackGroupArray(androidx.media3.common.TrackGroupArray) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) Test(org.junit.Test)

Example 13 with TrackSelectorResult

use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.

the class DefaultTrackSelectorTest method selectVideoAudioTracks_withDisabledAudioType_onlyVideoIsSelected.

/**
 * Tests disabling a track type.
 */
@Test
public void selectVideoAudioTracks_withDisabledAudioType_onlyVideoIsSelected() throws ExoPlaybackException {
    trackSelector.setParameters(defaultParameters.buildUpon().setDisabledTrackTypes(ImmutableSet.of(C.TRACK_TYPE_AUDIO)));
    TrackSelectorResult result = trackSelector.selectTracks(RENDERER_CAPABILITIES, new TrackGroupArray(VIDEO_TRACK_GROUP, AUDIO_TRACK_GROUP), periodId, TIMELINE);
    assertThat(result.selections).asList().containsExactly(VIDEO_TRACK_SELECTION, null).inOrder();
    assertThat(result.rendererConfigurations).asList().containsExactly(DEFAULT, null);
}
Also used : TrackGroupArray(androidx.media3.common.TrackGroupArray) Test(org.junit.Test)

Example 14 with TrackSelectorResult

use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.

the class DefaultTrackSelectorTest method selectTracksExceedingCapabilitiesPreferLowerNumChannelBeforeSampleRate.

/**
 * Tests that track selector will prefer audio tracks with lower channel count over tracks with
 * lower sample rate when other factors are the same, and tracks are within renderer's
 * capabilities.
 */
@Test
public void selectTracksExceedingCapabilitiesPreferLowerNumChannelBeforeSampleRate() throws Exception {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format lowerChannelHigherSampleRateFormat = formatBuilder.setChannelCount(2).setSampleRate(44100).build();
    Format higherChannelLowerSampleRateFormat = formatBuilder.setChannelCount(6).setSampleRate(22050).build();
    TrackGroupArray trackGroups = wrapFormats(higherChannelLowerSampleRateFormat, lowerChannelHigherSampleRateFormat);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_EXCEEDED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups, lowerChannelHigherSampleRateFormat);
}
Also used : Format(androidx.media3.common.Format) TrackGroupArray(androidx.media3.common.TrackGroupArray) Test(org.junit.Test)

Example 15 with TrackSelectorResult

use of androidx.media3.exoplayer.trackselection.TrackSelectorResult in project media by androidx.

the class DefaultTrackSelectorTest method selectTracksWithinCapabilitiesSelectHigherSampleRate.

/**
 * Tests that track selector will select audio tracks with higher sample rate when other factors
 * are the same, and tracks are within renderer's capabilities.
 */
@Test
public void selectTracksWithinCapabilitiesSelectHigherSampleRate() throws Exception {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format higherSampleRateFormat = formatBuilder.setSampleRate(44100).build();
    Format lowerSampleRateFormat = formatBuilder.setSampleRate(22050).build();
    TrackGroupArray trackGroups = wrapFormats(higherSampleRateFormat, lowerSampleRateFormat);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups, higherSampleRateFormat);
}
Also used : Format(androidx.media3.common.Format) TrackGroupArray(androidx.media3.common.TrackGroupArray) Test(org.junit.Test)

Aggregations

TrackGroupArray (androidx.media3.common.TrackGroupArray)60 Test (org.junit.Test)58 Format (androidx.media3.common.Format)49 RendererCapabilities (androidx.media3.exoplayer.RendererCapabilities)29 TrackGroup (androidx.media3.common.TrackGroup)10 TrackSelectorResult (androidx.media3.exoplayer.trackselection.TrackSelectorResult)9 HashMap (java.util.HashMap)8 ParametersBuilder (androidx.media3.exoplayer.trackselection.DefaultTrackSelector.ParametersBuilder)7 TrackSelectionOverride (androidx.media3.common.TrackSelectionOverrides.TrackSelectionOverride)6 MetadataRenderer (androidx.media3.exoplayer.metadata.MetadataRenderer)4 TextRenderer (androidx.media3.exoplayer.text.TextRenderer)4 Nullable (androidx.annotation.Nullable)3 Capabilities (androidx.media3.exoplayer.RendererCapabilities.Capabilities)3 ExoTrackSelection (androidx.media3.exoplayer.trackselection.ExoTrackSelection)3 SampleStream (androidx.media3.exoplayer.source.SampleStream)2 SelectionOverride (androidx.media3.exoplayer.trackselection.DefaultTrackSelector.SelectionOverride)2 CheckResult (androidx.annotation.CheckResult)1 Metadata (androidx.media3.common.Metadata)1 Timeline (androidx.media3.common.Timeline)1 TracksInfo (androidx.media3.common.TracksInfo)1