Search in sources :

Example 46 with MappedTrackInfo

use of com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo in project Telegram-FOSS by Telegram-FOSS-Team.

the class DefaultTrackSelector method selectTracks.

// MappingTrackSelector implementation.
@Override
protected final Pair<@NullableType RendererConfiguration[], @NullableType TrackSelection[]> selectTracks(MappedTrackInfo mappedTrackInfo, @Capabilities int[][][] rendererFormatSupports, @AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports) throws ExoPlaybackException {
    Parameters params = parametersReference.get();
    int rendererCount = mappedTrackInfo.getRendererCount();
    TrackSelection.@NullableType Definition[] definitions = selectAllTracks(mappedTrackInfo, rendererFormatSupports, rendererMixedMimeTypeAdaptationSupports, params);
    // Apply track disabling and overriding.
    for (int i = 0; i < rendererCount; i++) {
        if (params.getRendererDisabled(i)) {
            definitions[i] = null;
            continue;
        }
        TrackGroupArray rendererTrackGroups = mappedTrackInfo.getTrackGroups(i);
        if (params.hasSelectionOverride(i, rendererTrackGroups)) {
            SelectionOverride override = params.getSelectionOverride(i, rendererTrackGroups);
            definitions[i] = override == null ? null : new TrackSelection.Definition(rendererTrackGroups.get(override.groupIndex), override.tracks, override.reason, override.data);
        }
    }
    @NullableType TrackSelection[] rendererTrackSelections = trackSelectionFactory.createTrackSelections(definitions, getBandwidthMeter());
    // Initialize the renderer configurations to the default configuration for all renderers with
    // selections, and null otherwise.
    @NullableType RendererConfiguration[] rendererConfigurations = new RendererConfiguration[rendererCount];
    for (int i = 0; i < rendererCount; i++) {
        boolean forceRendererDisabled = params.getRendererDisabled(i);
        boolean rendererEnabled = !forceRendererDisabled && (mappedTrackInfo.getRendererType(i) == C.TRACK_TYPE_NONE || rendererTrackSelections[i] != null);
        rendererConfigurations[i] = rendererEnabled ? RendererConfiguration.DEFAULT : null;
    }
    // Configure audio and video renderers to use tunneling if appropriate.
    maybeConfigureRenderersForTunneling(mappedTrackInfo, rendererFormatSupports, rendererConfigurations, rendererTrackSelections, params.tunnelingAudioSessionId);
    return Pair.create(rendererConfigurations, rendererTrackSelections);
}
Also used : TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray) RendererConfiguration(com.google.android.exoplayer2.RendererConfiguration) NullableType(org.checkerframework.checker.nullness.compatqual.NullableType) Point(android.graphics.Point)

Example 47 with MappedTrackInfo

use of com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo in project drchannels by clhols.

the class TrackSelectionDialog method showTabForRenderer.

private static boolean showTabForRenderer(MappedTrackInfo mappedTrackInfo, int rendererIndex) {
    TrackGroupArray trackGroupArray = mappedTrackInfo.getTrackGroups(rendererIndex);
    if (trackGroupArray.length == 0) {
        return false;
    }
    int trackType = mappedTrackInfo.getRendererType(rendererIndex);
    return isSupportedTrackType(trackType);
}
Also used : TrackGroupArray(com.google.android.exoplayer2.source.TrackGroupArray)

Example 48 with MappedTrackInfo

use of com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo in project bolan by qiusunshine.

the class StyledPlayerControlView method initTrackSelectionAdapter.

private void initTrackSelectionAdapter() {
    textTrackSelectionAdapter.clear();
    audioTrackSelectionAdapter.clear();
    if (player == null || trackSelector == null) {
        return;
    }
    DefaultTrackSelector trackSelector = this.trackSelector;
    @Nullable MappedTrackInfo mappedTrackInfo = trackSelector.getCurrentMappedTrackInfo();
    if (mappedTrackInfo == null) {
        return;
    }
    List<TrackInfo> textTracks = new ArrayList<>();
    List<TrackInfo> audioTracks = new ArrayList<>();
    List<Integer> textRendererIndices = new ArrayList<>();
    List<Integer> audioRendererIndices = new ArrayList<>();
    for (int rendererIndex = 0; rendererIndex < mappedTrackInfo.getRendererCount(); rendererIndex++) {
        if (mappedTrackInfo.getRendererType(rendererIndex) == C.TRACK_TYPE_TEXT && controlViewLayoutManager.getShowButton(subtitleButton)) {
            // Get TrackSelection at the corresponding renderer index.
            gatherTrackInfosForAdapter(mappedTrackInfo, rendererIndex, textTracks);
            textRendererIndices.add(rendererIndex);
        } else if (mappedTrackInfo.getRendererType(rendererIndex) == C.TRACK_TYPE_AUDIO) {
            gatherTrackInfosForAdapter(mappedTrackInfo, rendererIndex, audioTracks);
            audioRendererIndices.add(rendererIndex);
        }
    }
    textTrackSelectionAdapter.init(textRendererIndices, textTracks, mappedTrackInfo);
    audioTrackSelectionAdapter.init(audioRendererIndices, audioTracks, mappedTrackInfo);
}
Also used : MappedTrackInfo(com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) DefaultTrackSelector(com.google.android.exoplayer2.trackselection.DefaultTrackSelector) MappedTrackInfo(com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo) Nullable(androidx.annotation.Nullable) SuppressLint(android.annotation.SuppressLint)

Aggregations

TrackGroupArray (com.google.android.exoplayer2.source.TrackGroupArray)25 MappedTrackInfo (com.google.android.exoplayer2.trackselection.MappingTrackSelector.MappedTrackInfo)21 TrackGroup (com.google.android.exoplayer2.source.TrackGroup)19 Nullable (androidx.annotation.Nullable)11 DefaultTrackSelector (com.google.android.exoplayer2.trackselection.DefaultTrackSelector)11 Point (android.graphics.Point)10 RendererCapabilities (com.google.android.exoplayer2.RendererCapabilities)10 Format (com.google.android.exoplayer2.Format)8 Capabilities (com.google.android.exoplayer2.RendererCapabilities.Capabilities)8 SuppressLint (android.annotation.SuppressLint)7 SelectionOverride (com.google.android.exoplayer2.trackselection.DefaultTrackSelector.SelectionOverride)7 CheckedTextView (android.widget.CheckedTextView)6 ArrayList (java.util.ArrayList)6 RendererConfiguration (com.google.android.exoplayer2.RendererConfiguration)5 TrackSelection (com.google.android.exoplayer2.trackselection.TrackSelection)5 List (java.util.List)5 SparseArray (android.util.SparseArray)3 TracksInfo (com.google.android.exoplayer2.TracksInfo)3 Metadata (com.google.android.exoplayer2.metadata.Metadata)3 NullableType (org.checkerframework.checker.nullness.compatqual.NullableType)3