Search in sources :

Example 11 with RendererCapabilities

use of androidx.media3.exoplayer.RendererCapabilities 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 RendererCapabilities

use of androidx.media3.exoplayer.RendererCapabilities 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 RendererCapabilities

use of androidx.media3.exoplayer.RendererCapabilities in project media by androidx.

the class MappingTrackSelectorTest method selectTracks_multipleVideoAndAudioTracks_mappedToSameRenderer.

@Test
public void selectTracks_multipleVideoAndAudioTracks_mappedToSameRenderer() throws ExoPlaybackException {
    TrackGroup videoGroup0 = VIDEO_TRACK_GROUP.copyWithId("0");
    TrackGroup videoGroup1 = VIDEO_TRACK_GROUP.copyWithId("1");
    TrackGroup audioGroup0 = AUDIO_TRACK_GROUP.copyWithId("0");
    TrackGroup audioGroup1 = AUDIO_TRACK_GROUP.copyWithId("1");
    FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector();
    TrackGroupArray trackGroups = new TrackGroupArray(videoGroup0, audioGroup0, audioGroup1, videoGroup1);
    RendererCapabilities[] rendererCapabilities = new RendererCapabilities[] { VIDEO_CAPABILITIES, AUDIO_CAPABILITIES, VIDEO_CAPABILITIES, AUDIO_CAPABILITIES };
    trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
    trackSelector.assertMappedTrackGroups(0, videoGroup0, videoGroup1);
    trackSelector.assertMappedTrackGroups(1, audioGroup0, audioGroup1);
}
Also used : TrackGroup(androidx.media3.common.TrackGroup) TrackGroupArray(androidx.media3.common.TrackGroupArray) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) Test(org.junit.Test)

Example 14 with RendererCapabilities

use of androidx.media3.exoplayer.RendererCapabilities in project media by androidx.

the class MappingTrackSelectorTest method selectTracks_audioAndVideo_reverseOrderToRenderers_mappedToCorrectRenderer.

@Test
public void selectTracks_audioAndVideo_reverseOrderToRenderers_mappedToCorrectRenderer() throws ExoPlaybackException {
    FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector();
    TrackGroupArray trackGroups = new TrackGroupArray(VIDEO_TRACK_GROUP, AUDIO_TRACK_GROUP);
    RendererCapabilities[] reverseOrderRendererCapabilities = new RendererCapabilities[] { AUDIO_CAPABILITIES, VIDEO_CAPABILITIES };
    trackSelector.selectTracks(reverseOrderRendererCapabilities, trackGroups, periodId, TIMELINE);
    trackSelector.assertMappedTrackGroups(/* rendererIndex= */
    0, AUDIO_TRACK_GROUP);
    trackSelector.assertMappedTrackGroups(/* rendererIndex= */
    1, VIDEO_TRACK_GROUP);
}
Also used : TrackGroupArray(androidx.media3.common.TrackGroupArray) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) Test(org.junit.Test)

Example 15 with RendererCapabilities

use of androidx.media3.exoplayer.RendererCapabilities 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)

Aggregations

TrackGroupArray (androidx.media3.common.TrackGroupArray)58 Test (org.junit.Test)57 Format (androidx.media3.common.Format)47 RendererCapabilities (androidx.media3.exoplayer.RendererCapabilities)35 TrackGroup (androidx.media3.common.TrackGroup)9 HashMap (java.util.HashMap)8 ParametersBuilder (androidx.media3.exoplayer.trackselection.DefaultTrackSelector.ParametersBuilder)5 TrackSelectionOverride (androidx.media3.common.TrackSelectionOverrides.TrackSelectionOverride)4 Capabilities (androidx.media3.exoplayer.RendererCapabilities.Capabilities)3 Nullable (androidx.annotation.Nullable)2 SelectionOverride (androidx.media3.exoplayer.trackselection.DefaultTrackSelector.SelectionOverride)2 TrackSelectorResult (androidx.media3.exoplayer.trackselection.TrackSelectorResult)2 Handler (android.os.Handler)1 FormatSupport (androidx.media3.common.C.FormatSupport)1 TracksInfo (androidx.media3.common.TracksInfo)1 ExoPlaybackException (androidx.media3.exoplayer.ExoPlaybackException)1 Renderer (androidx.media3.exoplayer.Renderer)1 AdaptiveSupport (androidx.media3.exoplayer.RendererCapabilities.AdaptiveSupport)1 AnalyticsCollector (androidx.media3.exoplayer.analytics.AnalyticsCollector)1 DefaultAnalyticsCollector (androidx.media3.exoplayer.analytics.DefaultAnalyticsCollector)1