Search in sources :

Example 26 with RendererCapabilities

use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.

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(com.google.android.exoplayer2.source.TrackGroupArray) RendererCapabilities(com.google.android.exoplayer2.RendererCapabilities) Test(org.junit.Test)

Example 27 with RendererCapabilities

use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.

the class DefaultTrackSelectorTest method selectTracks_withOverrideForUnmappedGroup_disablesAllRenderersOfSameType.

@Test
public void selectTracks_withOverrideForUnmappedGroup_disablesAllRenderersOfSameType() throws Exception {
    Format audioSupported = AUDIO_FORMAT.buildUpon().setId("supported").build();
    Format audioUnsupported = AUDIO_FORMAT.buildUpon().setId("unsupported").build();
    TrackGroup audioGroupSupported = new TrackGroup(audioSupported);
    TrackGroup audioGroupUnsupported = new TrackGroup(audioUnsupported);
    Map<String, Integer> audioRendererCapabilitiesMap = ImmutableMap.of(audioSupported.id, FORMAT_HANDLED, audioUnsupported.id, FORMAT_UNSUPPORTED_TYPE);
    RendererCapabilities audioRendererCapabilties = new FakeMappedRendererCapabilities(C.TRACK_TYPE_AUDIO, audioRendererCapabilitiesMap);
    trackSelector.setParameters(trackSelector.buildUponParameters().setTrackSelectionOverrides(new TrackSelectionOverrides.Builder().setOverrideForType(new TrackSelectionOverride(audioGroupUnsupported)).build()));
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES, audioRendererCapabilties }, new TrackGroupArray(VIDEO_TRACK_GROUP, audioGroupSupported, audioGroupUnsupported), periodId, TIMELINE);
    assertThat(result.selections).asList().containsExactly(VIDEO_TRACK_SELECTION, null).inOrder();
}
Also used : Format(com.google.android.exoplayer2.Format) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) ParametersBuilder(com.google.android.exoplayer2.trackselection.DefaultTrackSelector.ParametersBuilder) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) RendererCapabilities(com.google.android.exoplayer2.RendererCapabilities) Test(org.junit.Test)

Example 28 with RendererCapabilities

use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.

the class DefaultTrackSelectorTest method selectAdaptiveAudioTrackGroupWithMaxBitrate.

/**
 * Tests that adaptive audio track selections respect the maximum audio bitrate.
 */
@Test
public void selectAdaptiveAudioTrackGroupWithMaxBitrate() throws ExoPlaybackException {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format format128k = formatBuilder.setAverageBitrate(128 * 1024).build();
    Format format192k = formatBuilder.setAverageBitrate(192 * 1024).build();
    Format format256k = formatBuilder.setAverageBitrate(256 * 1024).build();
    RendererCapabilities[] rendererCapabilities = { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES };
    TrackGroupArray trackGroups = new TrackGroupArray(new TrackGroup(format192k, format128k, format256k));
    TrackSelectorResult result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 2, 0, 1);
    trackSelector.setParameters(trackSelector.buildUponParameters().setMaxAudioBitrate(256 * 1024 - 1));
    result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
    trackSelector.setParameters(trackSelector.buildUponParameters().setMaxAudioBitrate(192 * 1024));
    result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
    trackSelector.setParameters(trackSelector.buildUponParameters().setMaxAudioBitrate(192 * 1024 - 1));
    result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups.get(0), 1);
    trackSelector.setParameters(trackSelector.buildUponParameters().setMaxAudioBitrate(10));
    result = trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups.get(0), 1);
}
Also used : Format(com.google.android.exoplayer2.Format) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) RendererCapabilities(com.google.android.exoplayer2.RendererCapabilities) Test(org.junit.Test)

Example 29 with RendererCapabilities

use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.

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();
}
Also used : Format(com.google.android.exoplayer2.Format) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) ParametersBuilder(com.google.android.exoplayer2.trackselection.DefaultTrackSelector.ParametersBuilder) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) TrackSelectionOverride(com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride) RendererCapabilities(com.google.android.exoplayer2.RendererCapabilities) Test(org.junit.Test)

Example 30 with RendererCapabilities

use of com.google.android.exoplayer2.RendererCapabilities in project ExoPlayer by google.

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(com.google.android.exoplayer2.Format) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) Test(org.junit.Test)

Aggregations

TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)59 Test (org.junit.Test)57 Format (com.google.android.exoplayer2.Format)47 RendererCapabilities (com.google.android.exoplayer2.RendererCapabilities)36 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)11 HashMap (java.util.HashMap)8 ParametersBuilder (com.google.android.exoplayer2.trackselection.DefaultTrackSelector.ParametersBuilder)5 TrackSelectionOverride (com.google.android.exoplayer2.trackselection.TrackSelectionOverrides.TrackSelectionOverride)4 Capabilities (com.google.android.exoplayer2.RendererCapabilities.Capabilities)3 Nullable (androidx.annotation.Nullable)2 RendererConfiguration (com.google.android.exoplayer2.RendererConfiguration)2 SelectionOverride (com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride)2 TrackSelectorResult (com.google.android.exoplayer2.trackselection.TrackSelectorResult)2 Point (android.graphics.Point)1 Handler (android.os.Handler)1 FormatSupport (com.google.android.exoplayer2.C.FormatSupport)1 ExoPlaybackException (com.google.android.exoplayer2.ExoPlaybackException)1 Renderer (com.google.android.exoplayer2.Renderer)1 AdaptiveSupport (com.google.android.exoplayer2.RendererCapabilities.AdaptiveSupport)1 TracksInfo (com.google.android.exoplayer2.TracksInfo)1