Search in sources :

Example 41 with TrackGroupArray

use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.

the class DownloadHelperTest method getTrackGroups_returnsTrackGroups.

@Test
public void getTrackGroups_returnsTrackGroups() throws Exception {
    prepareDownloadHelper(downloadHelper);
    TrackGroupArray trackGroupArrayPeriod0 = downloadHelper.getTrackGroups(/* periodIndex= */
    0);
    TrackGroupArray trackGroupArrayPeriod1 = downloadHelper.getTrackGroups(/* periodIndex= */
    1);
    assertThat(trackGroupArrayPeriod0).isEqualTo(trackGroupArrays[0]);
    assertThat(trackGroupArrayPeriod1).isEqualTo(trackGroupArrays[1]);
}
Also used : TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) Test(org.junit.Test)

Example 42 with TrackGroupArray

use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.

the class DashMediaPeriod method buildTrackGroups.

private static Pair<TrackGroupArray, TrackGroupInfo[]> buildTrackGroups(DrmSessionManager drmSessionManager, List<AdaptationSet> adaptationSets, List<EventStream> eventStreams) {
    int[][] groupedAdaptationSetIndices = getGroupedAdaptationSetIndices(adaptationSets);
    int primaryGroupCount = groupedAdaptationSetIndices.length;
    boolean[] primaryGroupHasEventMessageTrackFlags = new boolean[primaryGroupCount];
    Format[][] primaryGroupClosedCaptionTrackFormats = new Format[primaryGroupCount][];
    int totalEmbeddedTrackGroupCount = identifyEmbeddedTracks(primaryGroupCount, adaptationSets, groupedAdaptationSetIndices, primaryGroupHasEventMessageTrackFlags, primaryGroupClosedCaptionTrackFormats);
    int totalGroupCount = primaryGroupCount + totalEmbeddedTrackGroupCount + eventStreams.size();
    TrackGroup[] trackGroups = new TrackGroup[totalGroupCount];
    TrackGroupInfo[] trackGroupInfos = new TrackGroupInfo[totalGroupCount];
    int trackGroupCount = buildPrimaryAndEmbeddedTrackGroupInfos(drmSessionManager, adaptationSets, groupedAdaptationSetIndices, primaryGroupCount, primaryGroupHasEventMessageTrackFlags, primaryGroupClosedCaptionTrackFormats, trackGroups, trackGroupInfos);
    buildManifestEventTrackGroupInfos(eventStreams, trackGroups, trackGroupInfos, trackGroupCount);
    return Pair.create(new TrackGroupArray(trackGroups), trackGroupInfos);
}
Also used : Format(com.google.android.exoplayer2.Format) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray)

Example 43 with TrackGroupArray

use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.

the class DefaultTrackSelectorTest method selectTracksPreferHigherSampleRateBeforeBitrate.

/**
 * Tests that track selector will prefer audio tracks with higher sample rate over tracks with
 * higher bitrate when other factors are the same, and tracks are within renderer's capabilities.
 */
@Test
public void selectTracksPreferHigherSampleRateBeforeBitrate() throws Exception {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format higherSampleRateLowerBitrateFormat = formatBuilder.setAverageBitrate(15000).setSampleRate(44100).build();
    Format lowerSampleRateHigherBitrateFormat = formatBuilder.setAverageBitrate(30000).setSampleRate(22050).build();
    TrackGroupArray trackGroups = wrapFormats(higherSampleRateLowerBitrateFormat, lowerSampleRateHigherBitrateFormat);
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups, higherSampleRateLowerBitrateFormat);
}
Also used : Format(com.google.android.exoplayer2.Format) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) Test(org.junit.Test)

Example 44 with TrackGroupArray

use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.

the class DefaultTrackSelectorTest method selectTracks_multipleVideoTracksWithoutBitrate_onlySelectsSingleTrack.

@Test
public void selectTracks_multipleVideoTracksWithoutBitrate_onlySelectsSingleTrack() throws Exception {
    TrackGroupArray trackGroups = singleTrackGroup(VIDEO_FORMAT.buildUpon().setId("0").setAverageBitrate(Format.NO_VALUE).build(), VIDEO_FORMAT.buildUpon().setId("1").setAverageBitrate(Format.NO_VALUE).build());
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { VIDEO_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertThat(result.length).isEqualTo(1);
    assertFixedSelection(result.selections[0], trackGroups.get(0), /* expectedTrack= */
    0);
}
Also used : TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) Test(org.junit.Test)

Example 45 with TrackGroupArray

use of com.google.android.exoplayer2.source.TrackGroupArray in project ExoPlayer by google.

the class DefaultTrackSelectorTest method selectTracks_withPreferredAudioRoleFlags_selectPreferredTrack.

/**
 * Tests that track selector will select the audio track with the highest number of matching role
 * flags given by {@link Parameters}.
 */
@Test
public void selectTracks_withPreferredAudioRoleFlags_selectPreferredTrack() throws Exception {
    Format.Builder formatBuilder = AUDIO_FORMAT.buildUpon();
    Format noRoleFlags = formatBuilder.build();
    Format lessRoleFlags = formatBuilder.setRoleFlags(C.ROLE_FLAG_CAPTION).build();
    Format moreRoleFlags = formatBuilder.setRoleFlags(C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_COMMENTARY | C.ROLE_FLAG_DUB).build();
    TrackGroupArray trackGroups = wrapFormats(noRoleFlags, moreRoleFlags, lessRoleFlags);
    trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioRoleFlags(C.ROLE_FLAG_CAPTION | C.ROLE_FLAG_COMMENTARY));
    TrackSelectorResult result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups, moreRoleFlags);
    // Also verify that exact match between parameters and tracks is preferred.
    trackSelector.setParameters(defaultParameters.buildUpon().setPreferredAudioRoleFlags(C.ROLE_FLAG_CAPTION));
    result = trackSelector.selectTracks(new RendererCapabilities[] { ALL_AUDIO_FORMAT_SUPPORTED_RENDERER_CAPABILITIES }, trackGroups, periodId, TIMELINE);
    assertFixedSelection(result.selections[0], trackGroups, lessRoleFlags);
}
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)

Aggregations

TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)126 Test (org.junit.Test)92 Format (com.google.android.exoplayer2.Format)67 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)50 RendererCapabilities (com.google.android.exoplayer2.RendererCapabilities)36 Nullable (androidx.annotation.Nullable)18 FakeMediaSource (com.google.android.exoplayer2.testutil.FakeMediaSource)17 FakeTimeline (com.google.android.exoplayer2.testutil.FakeTimeline)17 TransferListener (com.google.android.exoplayer2.upstream.TransferListener)14 DrmSessionManager (com.google.android.exoplayer2.drm.DrmSessionManager)13 MediaSource (com.google.android.exoplayer2.source.MediaSource)13 MediaPeriodId (com.google.android.exoplayer2.source.MediaSource.MediaPeriodId)13 FakeMediaPeriod (com.google.android.exoplayer2.testutil.FakeMediaPeriod)13 TestExoPlayerBuilder (com.google.android.exoplayer2.testutil.TestExoPlayerBuilder)13 Allocator (com.google.android.exoplayer2.upstream.Allocator)12 ArrayList (java.util.ArrayList)11 ClippingMediaSource (com.google.android.exoplayer2.source.ClippingMediaSource)9 CompositeMediaSource (com.google.android.exoplayer2.source.CompositeMediaSource)9 ConcatenatingMediaSource (com.google.android.exoplayer2.source.ConcatenatingMediaSource)9 MaskingMediaSource (com.google.android.exoplayer2.source.MaskingMediaSource)9