MappingTrackSelector


@UnstableApi
public abstract class MappingTrackSelector extends TrackSelector

Known direct subclasses
DefaultTrackSelector

A default TrackSelector suitable for most use cases.

Known indirect subclasses

Base class for TrackSelectors that first establish a mapping between TrackGroups and Renderers, and then from that mapping create a ExoTrackSelection for each renderer.

Summary

Nested types

Provides mapped track information for each renderer.

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = )
@IntDef(value = )
public annotation MappingTrackSelector.MappedTrackInfo.RendererSupport

Levels of renderer support.

Public constructors

Public methods

final @Nullable MappingTrackSelector.MappedTrackInfo

Returns the mapping information for the currently active track selection, or null if no selection is currently active.

final void

Called by the player when a TrackSelectorResult previously generated by selectTracks is activated.

final TrackSelectorResult
selectTracks(
    RendererCapabilities[] rendererCapabilities,
    TrackGroupArray trackGroups,
    MediaSource.MediaPeriodId periodId,
    Timeline timeline
)

Called by the player to perform a track selection.

Protected methods

abstract Pair<RendererConfiguration[], ExoTrackSelection[]>
selectTracks(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @RendererCapabilities.Capabilities int[][][] rendererFormatSupports,
    @RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupport,
    MediaSource.MediaPeriodId mediaPeriodId,
    Timeline timeline
)

Given mapped track information, returns a track selection and configuration for each renderer.

Inherited methods

From androidx.media3.exoplayer.trackselection.TrackSelector
final BandwidthMeter

Returns a bandwidth meter which can be used by track selections to select tracks.

TrackSelectionParameters

Returns the current parameters for track selection.

@Nullable RendererCapabilities.Listener

Returns the RendererCapabilities.Listener that the concrete instance uses to listen to the renderer capabilities changes.

void
@CallSuper
init(
    TrackSelector.InvalidationListener listener,
    BandwidthMeter bandwidthMeter
)

Called by the player to initialize the selector.

final void

Calls onTrackSelectionsInvalidated to invalidate all previously generated track selections.

final void

Calls onRendererCapabilitiesChanged to invalidate all previously generated track selections because a renderer's capabilities have changed.

boolean

Returns if this TrackSelector supports setParameters.

void

Called by the player to release the selector.

void

Called by the player to set the AudioAttributes that will be used for playback.

void

Called by the player to provide parameters for track selection.

Public fields

Public constructors

MappingTrackSelector

public MappingTrackSelector()

Public methods

getCurrentMappedTrackInfo

public final @Nullable MappingTrackSelector.MappedTrackInfo getCurrentMappedTrackInfo()

Returns the mapping information for the currently active track selection, or null if no selection is currently active.

onSelectionActivated

public final void onSelectionActivated(@Nullable Object info)

Called by the player when a TrackSelectorResult previously generated by selectTracks is activated.

Parameters
@Nullable Object info

The value of info in the activated selection.

selectTracks

public final TrackSelectorResult selectTracks(
    RendererCapabilities[] rendererCapabilities,
    TrackGroupArray trackGroups,
    MediaSource.MediaPeriodId periodId,
    Timeline timeline
)

Called by the player to perform a track selection.

Parameters
RendererCapabilities[] rendererCapabilities

The RendererCapabilities of the renderers for which tracks are to be selected.

TrackGroupArray trackGroups

The available track groups.

MediaSource.MediaPeriodId periodId

The MediaPeriodId of the period for which tracks are to be selected.

Timeline timeline

The Timeline holding the period for which tracks are to be selected.

Returns
TrackSelectorResult

A TrackSelectorResult describing the track selections.

Throws
androidx.media3.exoplayer.ExoPlaybackException

If an error occurs selecting tracks.

Protected methods

selectTracks

protected abstract Pair<RendererConfiguration[], ExoTrackSelection[]> selectTracks(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @RendererCapabilities.Capabilities int[][][] rendererFormatSupports,
    @RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupport,
    MediaSource.MediaPeriodId mediaPeriodId,
    Timeline timeline
)

Given mapped track information, returns a track selection and configuration for each renderer.

Parameters
MappingTrackSelector.MappedTrackInfo mappedTrackInfo

Mapped track information.

@RendererCapabilities.Capabilities int[][][] rendererFormatSupports

The Capabilities for each mapped track, indexed by renderer, track group and track (in that order).

@RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupport

The AdaptiveSupport for mixed MIME type adaptation for the renderer.

MediaSource.MediaPeriodId mediaPeriodId

The MediaPeriodId of the period for which tracks are to be selected.

Timeline timeline

The Timeline holding the period for which tracks are to be selected.

Returns
Pair<RendererConfiguration[], ExoTrackSelection[]>

A pair consisting of the track selections and configurations for each renderer. A null configuration indicates the renderer should be disabled, in which case the track selection must also be null. A track selection may also be null for a non-disabled renderer if getTrackType is TRACK_TYPE_NONE.

Throws
androidx.media3.exoplayer.ExoPlaybackException

If an error occurs while selecting the tracks.