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);
}
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);
}
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);
}
Aggregations