Search in sources :

Example 6 with TrackGroupInfo

use of com.google.android.exoplayer2.TracksInfo.TrackGroupInfo in project ExoPlayer by google.

the class DashMediaPeriod method buildManifestEventTrackGroupInfos.

private static void buildManifestEventTrackGroupInfos(List<EventStream> eventStreams, TrackGroup[] trackGroups, TrackGroupInfo[] trackGroupInfos, int existingTrackGroupCount) {
    for (int i = 0; i < eventStreams.size(); i++) {
        EventStream eventStream = eventStreams.get(i);
        Format format = new Format.Builder().setId(eventStream.id()).setSampleMimeType(MimeTypes.APPLICATION_EMSG).build();
        String uniqueTrackGroupId = eventStream.id() + ":" + i;
        trackGroups[existingTrackGroupCount] = new TrackGroup(uniqueTrackGroupId, format);
        trackGroupInfos[existingTrackGroupCount++] = TrackGroupInfo.mpdEventTrack(i);
    }
}
Also used : Format(com.google.android.exoplayer2.Format) EventStream(com.google.android.exoplayer2.source.dash.manifest.EventStream) TrackGroup(com.google.android.exoplayer2.source.TrackGroup)

Example 7 with TrackGroupInfo

use of com.google.android.exoplayer2.TracksInfo.TrackGroupInfo in project ExoPlayer by google.

the class MappingTrackSelectorTest method buildTrackInfos_withTestValues_isAsExpected.

@Test
public void buildTrackInfos_withTestValues_isAsExpected() {
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo = new MappingTrackSelector.MappedTrackInfo(new String[] { "1", "2" }, new int[] { C.TRACK_TYPE_AUDIO, C.TRACK_TYPE_VIDEO }, new TrackGroupArray[] { new TrackGroupArray(new TrackGroup("0", new Format.Builder().build()), new TrackGroup("1", new Format.Builder().build())), new TrackGroupArray(new TrackGroup("2", new Format.Builder().build(), new Format.Builder().build())) }, new int[] { RendererCapabilities.ADAPTIVE_SEAMLESS, RendererCapabilities.ADAPTIVE_NOT_SUPPORTED }, new int[][][] { new int[][] { new int[] { C.FORMAT_HANDLED }, new int[] { C.FORMAT_UNSUPPORTED_SUBTYPE } }, new int[][] { new int[] { C.FORMAT_UNSUPPORTED_DRM, C.FORMAT_EXCEEDS_CAPABILITIES } } }, new TrackGroupArray(new TrackGroup(new Format.Builder().build())));
    TrackSelection[] selections = new TrackSelection[] { new FixedTrackSelection(mappedTrackInfo.getTrackGroups(0).get(1), 0), new FixedTrackSelection(mappedTrackInfo.getTrackGroups(1).get(0), 1) };
    TracksInfo tracksInfo = MappingTrackSelector.buildTracksInfo(selections, mappedTrackInfo);
    ImmutableList<TrackGroupInfo> trackGroupInfos = tracksInfo.getTrackGroupInfos();
    assertThat(trackGroupInfos).hasSize(4);
    assertThat(trackGroupInfos.get(0).getTrackGroup()).isEqualTo(mappedTrackInfo.getTrackGroups(0).get(0));
    assertThat(trackGroupInfos.get(1).getTrackGroup()).isEqualTo(mappedTrackInfo.getTrackGroups(0).get(1));
    assertThat(trackGroupInfos.get(2).getTrackGroup()).isEqualTo(mappedTrackInfo.getTrackGroups(1).get(0));
    assertThat(trackGroupInfos.get(3).getTrackGroup()).isEqualTo(mappedTrackInfo.getUnmappedTrackGroups().get(0));
    assertThat(trackGroupInfos.get(0).getTrackSupport(0)).isEqualTo(C.FORMAT_HANDLED);
    assertThat(trackGroupInfos.get(1).getTrackSupport(0)).isEqualTo(C.FORMAT_UNSUPPORTED_SUBTYPE);
    assertThat(trackGroupInfos.get(2).getTrackSupport(0)).isEqualTo(C.FORMAT_UNSUPPORTED_DRM);
    assertThat(trackGroupInfos.get(2).getTrackSupport(1)).isEqualTo(C.FORMAT_EXCEEDS_CAPABILITIES);
    assertThat(trackGroupInfos.get(3).getTrackSupport(0)).isEqualTo(C.FORMAT_UNSUPPORTED_TYPE);
    assertThat(trackGroupInfos.get(0).isTrackSelected(0)).isFalse();
    assertThat(trackGroupInfos.get(1).isTrackSelected(0)).isTrue();
    assertThat(trackGroupInfos.get(2).isTrackSelected(0)).isFalse();
    assertThat(trackGroupInfos.get(2).isTrackSelected(1)).isTrue();
    assertThat(trackGroupInfos.get(3).isTrackSelected(0)).isFalse();
    assertThat(trackGroupInfos.get(0).getTrackType()).isEqualTo(C.TRACK_TYPE_AUDIO);
    assertThat(trackGroupInfos.get(1).getTrackType()).isEqualTo(C.TRACK_TYPE_AUDIO);
    assertThat(trackGroupInfos.get(2).getTrackType()).isEqualTo(C.TRACK_TYPE_VIDEO);
    assertThat(trackGroupInfos.get(3).getTrackType()).isEqualTo(C.TRACK_TYPE_UNKNOWN);
}
Also used : TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) TrackGroupInfo(com.google.android.exoplayer2.TracksInfo.TrackGroupInfo) TracksInfo(com.google.android.exoplayer2.TracksInfo) Test(org.junit.Test)

Example 8 with TrackGroupInfo

use of com.google.android.exoplayer2.TracksInfo.TrackGroupInfo in project ExoPlayer by google.

the class StyledPlayerControlView method gatherSupportedTrackInfosOfType.

private ImmutableList<TrackInformation> gatherSupportedTrackInfosOfType(TracksInfo tracksInfo, @C.TrackType int trackType) {
    ImmutableList.Builder<TrackInformation> tracks = new ImmutableList.Builder<>();
    List<TrackGroupInfo> trackGroupInfos = tracksInfo.getTrackGroupInfos();
    for (int trackGroupIndex = 0; trackGroupIndex < trackGroupInfos.size(); trackGroupIndex++) {
        TrackGroupInfo trackGroupInfo = trackGroupInfos.get(trackGroupIndex);
        if (trackGroupInfo.getTrackType() != trackType) {
            continue;
        }
        TrackGroup trackGroup = trackGroupInfo.getTrackGroup();
        for (int trackIndex = 0; trackIndex < trackGroup.length; trackIndex++) {
            if (!trackGroupInfo.isTrackSupported(trackIndex)) {
                continue;
            }
            String trackName = trackNameProvider.getTrackName(trackGroup.getFormat(trackIndex));
            tracks.add(new TrackInformation(tracksInfo, trackGroupIndex, trackIndex, trackName));
        }
    }
    return tracks.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) TrackGroup(com.google.android.exoplayer2.source.TrackGroup) TrackGroupInfo(com.google.android.exoplayer2.TracksInfo.TrackGroupInfo) SuppressLint(android.annotation.SuppressLint)

Aggregations

TrackGroup (com.google.android.exoplayer2.source.TrackGroup)6 Format (com.google.android.exoplayer2.Format)5 ArrayList (java.util.ArrayList)3 TrackGroupInfo (com.google.android.exoplayer2.TracksInfo.TrackGroupInfo)2 TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)2 ChunkSampleStream (com.google.android.exoplayer2.source.chunk.ChunkSampleStream)2 AdaptationSet (com.google.android.exoplayer2.source.dash.manifest.AdaptationSet)2 EventStream (com.google.android.exoplayer2.source.dash.manifest.EventStream)2 ExoTrackSelection (com.google.android.exoplayer2.trackselection.ExoTrackSelection)2 SuppressLint (android.annotation.SuppressLint)1 TracksInfo (com.google.android.exoplayer2.TracksInfo)1 StreamKey (com.google.android.exoplayer2.offline.StreamKey)1 EmptySampleStream (com.google.android.exoplayer2.source.EmptySampleStream)1 PlayerTrackEmsgHandler (com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler)1 Representation (com.google.android.exoplayer2.source.dash.manifest.Representation)1 ImmutableList (com.google.common.collect.ImmutableList)1 Test (org.junit.Test)1