Search in sources :

Example 56 with RendererCapabilities

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

the class MappingTrackSelectorTest method selectTracks_multipleMetadataTracks_mappedToDifferentRenderers.

@Test
public void selectTracks_multipleMetadataTracks_mappedToDifferentRenderers() throws ExoPlaybackException {
    TrackGroup metadataGroup0 = METADATA_TRACK_GROUP.copyWithId("0");
    TrackGroup metadataGroup1 = METADATA_TRACK_GROUP.copyWithId("1");
    FakeMappingTrackSelector trackSelector = new FakeMappingTrackSelector();
    TrackGroupArray trackGroups = new TrackGroupArray(VIDEO_TRACK_GROUP, metadataGroup0, metadataGroup1);
    RendererCapabilities[] rendererCapabilities = new RendererCapabilities[] { VIDEO_CAPABILITIES, METADATA_CAPABILITIES, METADATA_CAPABILITIES };
    trackSelector.selectTracks(rendererCapabilities, trackGroups, periodId, TIMELINE);
    trackSelector.assertMappedTrackGroups(0, VIDEO_TRACK_GROUP);
    trackSelector.assertMappedTrackGroups(1, metadataGroup0);
    trackSelector.assertMappedTrackGroups(2, metadataGroup1);
}
Also used : 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 57 with RendererCapabilities

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

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

Example 58 with RendererCapabilities

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

the class DefaultTrackSelectorTest method selectTracks_withPreferredVideoMimeTypes_selectsTrackWithPreferredMimeType.

@Test
public void selectTracks_withPreferredVideoMimeTypes_selectsTrackWithPreferredMimeType() throws Exception {
    Format formatAv1 = new Format.Builder().setSampleMimeType(MimeTypes.VIDEO_AV1).build();
    Format formatVp9 = new Format.Builder().setSampleMimeType(MimeTypes.VIDEO_VP9).build();
    Format formatH264Low = new Format.Builder().setSampleMimeType(MimeTypes.VIDEO_H264).setAverageBitrate(400).build();
    Format formatH264High = new Format.Builder().setSampleMimeType(MimeTypes.VIDEO_H264).setAverageBitrate(800).build();
    // Use an adaptive group to check that MIME type has a higher priority than number of tracks.
    TrackGroup adaptiveGroup = new TrackGroup(formatH264Low, formatH264High);
    TrackGroupArray trackGroups = new TrackGroupArray(new TrackGroup(formatAv1), new TrackGroup(formatVp9), adaptiveGroup);
    trackSelector.setParameters(defaultParameters.buildUpon().setPreferredVideoMimeType(MimeTypes.VIDEO_VP9));
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertFixedSelection(result.selections[0], trackGroups, formatVp9);
    trackSelector.setParameters(defaultParameters.buildUpon().setPreferredVideoMimeTypes(MimeTypes.VIDEO_VP9, MimeTypes.VIDEO_AV1));
    result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertFixedSelection(result.selections[0], trackGroups, formatVp9);
    trackSelector.setParameters(defaultParameters.buildUpon().setPreferredVideoMimeTypes(MimeTypes.VIDEO_DIVX, MimeTypes.VIDEO_H264));
    result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertAdaptiveSelection(result.selections[0], adaptiveGroup, /* expectedTracks...= */
    1, 0);
    // Select default (=most tracks) if no preference is specified.
    trackSelector.setParameters(defaultParameters.buildUpon().setPreferredVideoMimeType(null));
    result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertAdaptiveSelection(result.selections[0], adaptiveGroup, /* expectedTracks...= */
    1, 0);
}
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) RendererCapabilities(com.google.android.exoplayer2.RendererCapabilities) Test(org.junit.Test)

Example 59 with RendererCapabilities

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

the class DefaultTrackSelectorTest method selectTracksWithMultipleAudioTracksWithMixedSampleRates.

@Test
public void selectTracksWithMultipleAudioTracksWithMixedSampleRates() throws Exception {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format highSampleRateAudioFormat = formatBuilder.setSampleRate(44100).build();
    Format lowSampleRateAudioFormat = formatBuilder.setSampleRate(22050).build();
    // Should not adapt between mixed sample rates by default, so we expect a fixed selection
    // containing the higher sample rate stream.
    TrackGroupArray trackGroups = singleTrackGroup(highSampleRateAudioFormat, lowSampleRateAudioFormat);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { AUDIO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertFixedSelection(result.selections[0], trackGroups, highSampleRateAudioFormat);
    // The same applies if the tracks are provided in the opposite order.
    trackGroups = singleTrackGroup(lowSampleRateAudioFormat, highSampleRateAudioFormat);
    result = trackSelector.selectTracks(new RendererCapabilities[] { AUDIO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertFixedSelection(result.selections[0], trackGroups, highSampleRateAudioFormat);
    // If we explicitly enable mixed sample rate adaptiveness, expect an adaptive selection.
    trackSelector.setParameters(defaultParameters.buildUpon().setAllowAudioMixedSampleRateAdaptiveness(true));
    result = trackSelector.selectTracks(new RendererCapabilities[] { AUDIO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertAdaptiveSelection(result.selections[0], trackGroups.get(0), 0, 1);
}
Also used : Format(com.google.android.exoplayer2.Format) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) RendererCapabilities(com.google.android.exoplayer2.RendererCapabilities) Test(org.junit.Test)

Example 60 with RendererCapabilities

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

the class DefaultTrackSelectorTest method selectTracksPreferHigherNumChannelBeforeSampleRate.

/**
 * Tests that track selector will prefer audio tracks with higher channel count over tracks with
 * higher sample rate when other factors are the same, and tracks are within renderer's
 * capabilities.
 */
@Test
public void selectTracksPreferHigherNumChannelBeforeSampleRate() throws Exception {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format higherChannelLowerSampleRateFormat = formatBuilder.setChannelCount(6).setSampleRate(22050).build();
    Format lowerChannelHigherSampleRateFormat = formatBuilder.setChannelCount(2).setSampleRate(44100).build();
    TrackGroupArray trackGroups = wrapFormats(higherChannelLowerSampleRateFormat, lowerChannelHigherSampleRateFormat);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups, higherChannelLowerSampleRateFormat);
}
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