Search in sources :

Example 6 with RendererCapabilities

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

the class DefaultTrackSelectorTest method selectTracksWithMultipleVideoTracks.

@Test
public void selectTracksWithMultipleVideoTracks() throws Exception {
    Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
    TrackGroupArray trackGroups = singleTrackGroup(formatBuilder.setId("0").build(), formatBuilder.setId("1").build());
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
}
Also used : Format(androidx.media3.common.Format) TrackGroupArray(androidx.media3.common.TrackGroupArray) Test(org.junit.Test)

Example 7 with RendererCapabilities

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

the class DefaultTrackSelectorTest method selectTracksWithMultipleAudioTracksWithMixedDecoderSupportLevels.

@Test
public void selectTracksWithMultipleAudioTracksWithMixedDecoderSupportLevels() throws Exception {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format format0 = formatBuilder.setId("0").setAverageBitrate(200).build();
    Format format1 = formatBuilder.setId("1").setAverageBitrate(400).build();
    Format format2 = formatBuilder.setId("2").setAverageBitrate(600).build();
    Format format3 = formatBuilder.setId("3").setAverageBitrate(800).build();
    TrackGroupArray trackGroups = singleTrackGroup(format0, format1, format2, format3);
    @Capabilities int unsupported = RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
    @Capabilities int primaryHardware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_SUPPORTED, DECODER_SUPPORT_PRIMARY);
    @Capabilities int primarySoftware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_NOT_SUPPORTED, DECODER_SUPPORT_PRIMARY);
    @Capabilities int fallbackHardware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_SUPPORTED, DECODER_SUPPORT_FALLBACK);
    @Capabilities int fallbackSoftware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_NOT_SUPPORTED, DECODER_SUPPORT_FALLBACK);
    // Select all tracks supported by primary, hardware decoder by default.
    ImmutableMap<String, Integer> rendererCapabilitiesMap = ImmutableMap.of("0", primaryHardware, "1", primaryHardware, "2", primarySoftware, "3", fallbackHardware);
    RendererCapabilities rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, rendererCapabilitiesMap);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 1, 0);
    // Select all tracks supported by primary, software decoder by default if no primary, hardware
    // decoder is available.
    rendererCapabilitiesMap = ImmutableMap.of("0", fallbackHardware, "1", fallbackHardware, "2", primarySoftware, "3", fallbackSoftware);
    rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, rendererCapabilitiesMap);
    result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups.get(0), 2);
    // Select all tracks supported by fallback, hardware decoder if no primary decoder is
    // available.
    rendererCapabilitiesMap = ImmutableMap.of("0", fallbackHardware, "1", unsupported, "2", fallbackSoftware, "3", fallbackHardware);
    rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, rendererCapabilitiesMap);
    result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 0);
    // Select all tracks supported by fallback, software decoder if no other decoder is available.
    rendererCapabilitiesMap = ImmutableMap.of("0", fallbackSoftware, "1", fallbackSoftware, "2", unsupported, "3", fallbackSoftware);
    rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, rendererCapabilitiesMap);
    result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 1, 0);
    // Select all tracks if mixed decoder support is allowed.
    rendererCapabilitiesMap = ImmutableMap.of("0", primaryHardware, "1", unsupported, "2", primarySoftware, "3", fallbackHardware);
    rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, rendererCapabilitiesMap);
    trackSelector.setParameters(defaultParameters.buildUpon().setAllowAudioMixedDecoderSupportAdaptiveness(true));
    result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 2, 0);
}
Also used : Format(androidx.media3.common.Format) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) Capabilities(androidx.media3.exoplayer.RendererCapabilities.Capabilities) TrackGroupArray(androidx.media3.common.TrackGroupArray) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) Test(org.junit.Test)

Example 8 with RendererCapabilities

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

the class DefaultTrackSelectorTest method selectTracksExceedingCapabilitiesSelectLowerBitrate.

/**
 * Tests that track selector will select audio tracks with lower bit-rate when other factors are
 * the same, and tracks exceed renderer's capabilities.
 */
@Test
public void selectTracksExceedingCapabilitiesSelectLowerBitrate() throws Exception {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format lowerBitrateFormat = formatBuilder.setAverageBitrate(15000).build();
    Format higherBitrateFormat = formatBuilder.setAverageBitrate(30000).build();
    TrackGroupArray trackGroups = wrapFormats(lowerBitrateFormat, higherBitrateFormat);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_EXCEEDED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups, lowerBitrateFormat);
}
Also used : Format(androidx.media3.common.Format) TrackGroupArray(androidx.media3.common.TrackGroupArray) Test(org.junit.Test)

Example 9 with RendererCapabilities

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

the class DefaultTrackSelectorTest method selectTracks_withoutPreferredAudioRoleFlagsOrDefaultTrack_selectsFirstTrack.

/**
 * Tests that track selector with select the first audio track if no role flag preference is
 * specified by {@link Parameters} and no default track exists.
 */
@Test
public void selectTracks_withoutPreferredAudioRoleFlagsOrDefaultTrack_selectsFirstTrack() throws Exception {
    Format firstFormat = AUDIO_FORMAT;
    Format roleFlagFormat = AUDIO_FORMAT.buildUpon().setRoleFlags(C.ROLE_FLAG_CAPTION).build();
    TrackGroupArray trackGroups = wrapFormats(firstFormat, roleFlagFormat);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups, firstFormat);
}
Also used : Format(androidx.media3.common.Format) TrackGroupArray(androidx.media3.common.TrackGroupArray) Test(org.junit.Test)

Example 10 with RendererCapabilities

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

the class DefaultTrackSelectorTest method selectTracksWithMultipleVideoTracksWithMixedDecoderSupportLevels.

@Test
public void selectTracksWithMultipleVideoTracksWithMixedDecoderSupportLevels() throws Exception {
    Format.Builder formatBuilder = VIDEO_FORMAT.buildUpon();
    Format format0 = formatBuilder.setId("0").setAverageBitrate(200).build();
    Format format1 = formatBuilder.setId("1").setAverageBitrate(400).build();
    Format format2 = formatBuilder.setId("2").setAverageBitrate(600).build();
    Format format3 = formatBuilder.setId("3").setAverageBitrate(800).build();
    TrackGroupArray trackGroups = singleTrackGroup(format0, format1, format2, format3);
    @Capabilities int unsupported = RendererCapabilities.create(FORMAT_UNSUPPORTED_TYPE);
    @Capabilities int primaryHardware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_SUPPORTED, DECODER_SUPPORT_PRIMARY);
    @Capabilities int primarySoftware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_NOT_SUPPORTED, DECODER_SUPPORT_PRIMARY);
    @Capabilities int fallbackHardware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_SUPPORTED, DECODER_SUPPORT_FALLBACK);
    @Capabilities int fallbackSoftware = RendererCapabilities.create(FORMAT_HANDLED, ADAPTIVE_NOT_SEAMLESS, TUNNELING_NOT_SUPPORTED, HARDWARE_ACCELERATION_NOT_SUPPORTED, DECODER_SUPPORT_FALLBACK);
    // Select all tracks supported by primary, hardware decoder by default.
    ImmutableMap<String, Integer> rendererCapabilitiesMap = ImmutableMap.of("0", primaryHardware, "1", primaryHardware, "2", primarySoftware, "3", fallbackHardware);
    RendererCapabilities rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 1, 0);
    // Select all tracks supported by primary, software decoder by default if no primary, hardware
    // decoder is available.
    rendererCapabilitiesMap = ImmutableMap.of("0", fallbackHardware, "1", fallbackHardware, "2", primarySoftware, "3", fallbackSoftware);
    rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
    result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups.get(0), 2);
    // Select all tracks supported by fallback, hardware decoder if no primary decoder is
    // available.
    rendererCapabilitiesMap = ImmutableMap.of("0", fallbackHardware, "1", unsupported, "2", fallbackSoftware, "3", fallbackHardware);
    rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
    result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 0);
    // Select all tracks supported by fallback, software decoder if no other decoder is available.
    rendererCapabilitiesMap = ImmutableMap.of("0", fallbackSoftware, "1", fallbackSoftware, "2", unsupported, "3", fallbackSoftware);
    rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
    result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 1, 0);
    // Select all tracks if mixed decoder support is allowed.
    rendererCapabilitiesMap = ImmutableMap.of("0", primaryHardware, "1", unsupported, "2", primarySoftware, "3", fallbackHardware);
    rendererCapabilities = new FakeMappedRendererCapabilities(C.TRACK_TYPE_VIDEO, rendererCapabilitiesMap);
    trackSelector.setParameters(defaultParameters.buildUpon().setAllowVideoMixedDecoderSupportAdaptiveness(true));
    result = trackSelector.selectTracks(new RendererCapabilities[] { rendererCapabilities }, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 3, 2, 0);
}
Also used : Format(androidx.media3.common.Format) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) Capabilities(androidx.media3.exoplayer.RendererCapabilities.Capabilities) TrackGroupArray(androidx.media3.common.TrackGroupArray) RendererCapabilities(androidx.media3.exoplayer.RendererCapabilities) 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