Package com.google.android.exoplayer2.trackselection

## Class MappingTrackSelector

- java.lang.Object
- - com.google.android.exoplayer2.trackselection.TrackSelector
  - - com.google.android.exoplayer2.trackselection.MappingTrackSelector

- Direct Known Subclasses:
    `DefaultTrackSelector`

      public abstract class MappingTrackSelector
      extends TrackSelector

  Base class for `TrackSelector`s that first establish a mapping between `TrackGroup`s and `Renderer`s, and then from that mapping create a `ExoTrackSelection` for each renderer.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `MappingTrackSelector.MappedTrackInfo` | Provides mapped track information for each renderer.

    - ### Nested classes/interfaces inherited from class com.google.android.exoplayer2.trackselection.TrackSelector

      `TrackSelector.InvalidationListener`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `MappingTrackSelector()` |

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `MappingTrackSelector.MappedTrackInfo` | `getCurrentMappedTrackInfo()` | Returns the mapping information for the currently active track selection, or null if no selection is currently active.
    `void` | `onSelectionActivated​(Object info)` | Called by the player when a `TrackSelectorResult` previously generated by `TrackSelector.selectTracks(RendererCapabilities[], TrackGroupArray, MediaPeriodId, Timeline)` is activated.
    `TrackSelectorResult` | `selectTracks​(RendererCapabilities[] rendererCapabilities, TrackGroupArray trackGroups, MediaSource.MediaPeriodId mediaPeriodId, Timeline timeline)` | Called by the player to perform a track selection.
    `protected abstract Pair<@NullableType RendererConfiguration[],​@NullableType ExoTrackSelection[]>` | `selectTracks​(MappingTrackSelector.MappedTrackInfo mappedTrackInfo, int[][][] rendererFormatSupports, int[] rendererMixedMimeTypeAdaptationSupport, MediaSource.MediaPeriodId mediaPeriodId, Timeline timeline)` | Given mapped track information, returns a track selection and configuration for each renderer.

    - ### Methods inherited from class com.google.android.exoplayer2.trackselection.TrackSelector

      `getBandwidthMeter, init, invalidate`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MappingTrackSelector

          public MappingTrackSelector()

  - ### Method Detail

    - #### getCurrentMappedTrackInfo

          @Nullable
          public final 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)

      Description copied from class: `TrackSelector`
      Called by the player when a `TrackSelectorResult` previously generated by `TrackSelector.selectTracks(RendererCapabilities[], TrackGroupArray, MediaPeriodId, Timeline)` is activated.
      Specified by:
        `onSelectionActivated` in class `TrackSelector`
      Parameters:
        `info` - The value of `TrackSelectorResult.info` in the activated selection.

    - #### selectTracks

          public final TrackSelectorResult selectTracks​(RendererCapabilities[] rendererCapabilities,
                                                        TrackGroupArray trackGroups,
                                                        MediaSource.MediaPeriodId mediaPeriodId,
                                                        Timeline timeline)
                                                 throws ExoPlaybackException

      Description copied from class: `TrackSelector`
      Called by the player to perform a track selection.
      Specified by:
        `selectTracks` in class `TrackSelector`
      Parameters:
        `rendererCapabilities` - The `RendererCapabilities` of the renderers for which tracks are to be selected.
        `trackGroups` - The available track groups.
        `mediaPeriodId` - The `MediaSource.MediaPeriodId` of the period for which tracks are to be selected.
        `timeline` - The `Timeline` holding the period for which tracks are to be selected.
      Returns:
        A `TrackSelectorResult` describing the track selections.
      Throws:
        `ExoPlaybackException` - If an error occurs selecting tracks.

    - #### selectTracks

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

      Given mapped track information, returns a track selection and configuration for each renderer.
      Parameters:
        `mappedTrackInfo` - Mapped track information.
        `rendererFormatSupports` - The `RendererCapabilities.Capabilities` for ach mapped track, indexed by renderer, track group and track (in that order).
        `rendererMixedMimeTypeAdaptationSupport` - The `RendererCapabilities.AdaptiveSupport` for mixed MIME type adaptation for the renderer.
        `mediaPeriodId` - The `MediaSource.MediaPeriodId` of the period for which tracks are to be selected.
        `timeline` - The `Timeline` holding the period for which tracks are to be selected.
      Returns:
        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 will also be null. A track selection may also be null for a non-disabled renderer if `RendererCapabilities.getTrackType()` is `C.TRACK_TYPE_NONE`.
      Throws:
        `ExoPlaybackException` - If an error occurs while selecting the tracks.