Package com.castlabs.android.player

# Class ExtendedTrackSelector

java.lang.Object
com.google.android.exoplayer2.trackselection.TrackSelector
com.castlabs.android.player.ExtendedTrackSelector

All Implemented Interfaces:
  `DrmEventListener`, `VideoRendererListener`, `com.google.android.exoplayer2.RendererCapabilities.Listener`

public class ExtendedTrackSelector extends com.google.android.exoplayer2.trackselection.TrackSelector implements DrmEventListener, VideoRendererListener, com.google.android.exoplayer2.RendererCapabilities.Listener
Extended Track Selector that provides advanced track selection capabilities. It supports video, audio, and subtitle track selection with various filters, preselection options, and configuration settings.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `ExtendedTrackSelector.EventListener`
  Interface which receives Track Selection-related callbacks.
  `class`
  `ExtendedTrackSelector.ModelSelection`
  Represents the selection of tracks and other related information for a media item.
  `static interface`
  `ExtendedTrackSelector.PlayerInfoProvider`
  Provides information about the player.

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

  `com.google.android.exoplayer2.trackselection.TrackSelector.InvalidationListener`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ExtendedTrackSelector(Point displaySize)`
  Constructs an ExtendedTrackSelector with default video track selection factory.
  `ExtendedTrackSelector(Point displaySize, VideoTrackSelection.Factory videoTrackSelectionFactory, ExtendedTrackSelector.PlayerInfoProvider playerInfoProvider, ExtendedTrackSelector.EventListener eventListener, PlayerConfig playerConfig)`
  Constructs an ExtendedTrackSelector.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ExtendedTrackSelector.ModelSelection`
  `createModel(com.google.android.exoplayer2.trackselection.TrackSelectorResult trackSelectorResult)`
  Creates a model selection from the `TrackSelectorResult` if it is of type `ExtendedTrackSelector.ModelSelection`.
  `static void`
  `extractDashThumbnails(com.google.android.exoplayer2.source.dash.manifest.DashManifest dashManifest, com.google.android.exoplayer2.Timeline timeline, PlayerModel playerModel)`
  Extracts the embedded thumbnail tracks in the DASH manifest, and updates the provided player model with them.
  `String`
  `getPreferredAudioLanguage()`
  Get the preferred audio language
  `String`
  `getPreferredSubtitleLanguage()`
  Get the preferred subtitles language
  `com.google.android.exoplayer2.RendererCapabilities.Listener`
  `getRendererCapabilitiesListener()`
  `void`
  `onDroppedFrames(int count, long elapsedMs)`
  Called to report the number of frames dropped by the renderer.
  `void`
  `onLicenseKeysChanged()`
  Called when keys are changed e.g.
  `void`
  `onLicenseKeysLoaded()`
  Called when a key was loaded successfully
  `void`
  `onLicenseLoadError(int currentAttempt, int maxAttempts, DownloadException downloadException)`
  Called when license load error occurred
  `void`
  `onRenderedFirstFrame(Object object)`
  Called when a frame is rendered for the first time since setting the output, or since the renderer was reset, or since the stream being rendered was changed.
  `void`
  `onRendererCapabilitiesChanged(com.google.android.exoplayer2.Renderer renderer)`
  `void`
  `onSelectionActivated(Object info)`
  `void`
  `onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs)`
  Called when a decoder is created.
  `void`
  `onVideoDecoderReleased(String decoderName, long releasedTimestampMs, long releaseDurationMs)`
  Called when a decoder is released.
  `void`
  `onVideoDisabled(com.google.android.exoplayer2.decoder.DecoderCounters counters)`
  Called when the renderer is disabled.
  `void`
  `onVideoEnabled(com.google.android.exoplayer2.decoder.DecoderCounters counters)`
  Called when the renderer is enabled.
  `void`
  `onVideoInputFormatChanged(com.google.android.exoplayer2.Format format)`
  Called when the format of the media being consumed by the renderer changes.
  `void`
  `reset()`
  Resets the track selector to its initial state.
  `com.google.android.exoplayer2.trackselection.TrackSelectorResult`
  `selectTracks(com.google.android.exoplayer2.RendererCapabilities[] rendererCapabilities, com.google.android.exoplayer2.source.TrackGroupArray trackGroups, com.google.android.exoplayer2.source.MediaSource.MediaPeriodId periodId, com.google.android.exoplayer2.Timeline timeline, Object manifest)`
  `void`
  `setAudioCodecFilter(int audioCodecFilter)`
  Set the audio codec filtering policy, one of `SdkConsts.AudioCodecFilter`.
  `void`
  `setAudioTrackIndexOverride(TrackIndexOverride trackIndexOverride)`
  Set audio track indices override to be used during audio selection
  `void`
  `setAudioTrackOverride(AudioTrack audioTrack)`
  Set audio track override to be used during audio selection
  `void`
  `setDisabledRendererIndices(List<Integer> disabledRendererIndices)`
  Disable renderers by indices such that the tracks of the corresponding type will not be selected
  `void`
  `setInitialVideoTrackGroupIndex(int initialVideoTrackGroupIndex)`
  Set video track group index override to be used during video selection.
  `void`
  `setPreselectedAudio(List<TrackIndexOverride> preselectedAudio)`
  Preselect audio tracks available for the selection
  `void`
  `setPreselectedSideloadedTracks(List<SubtitleTrack> sideloadedTracks)`
  Preselect sideloaded subtitle tracks available for the selection
  `void`
  `setPreselectedSubtitle(List<TrackIndexOverride> preselectedSubtitle)`
  Preselect subtitle tracks available for the selection
  `void`
  `setPreselectedVideoQualities(int[] preselectedVideoQualityIndices)`
  Preselect video qualities available for the selection
  `void`
  `setSubtitleTrackIndexOverride(TrackIndexOverride trackIndexOverride)`
  Set subtitle track indices override to be used during subtitle selection
  `void`
  `setSubtitleTrackOverride(SubtitleTrack subtitleTrack)`
  Set subtitle track override to be used during subtitle selection
  `void`
  `setVideoCodecFilter(int videoCodecFilter)`
  Set the video codec filtering policy, one of `SdkConsts.VideoCodecFilter`.
  `void`
  `setVideoFilter(VideoFilterConfiguration contentFilter, VideoFilterConfiguration adsFilter)`
  Sets the video filter for content and ads.
  `void`
  `setVideoHdEnabled(boolean isHdPlaybackEnabled)`
  Enable or disable the video HD tracks.
  `void`
  `setVideoMaxResolution(int maxVideoWidth, int maxVideoHeight)`
  Set the max video tracks resolution in pixels such that the video tracks with higher resolutions will not be available for the selection
  `void`
  `setVideoTrackOverride(VideoTrack videoTrack)`
  Set video track override to be used during video selection

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

  `getParameters, init, isSetParametersSupported, release, selectTracks, setAudioAttributes, setParameters`

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

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

- ## Constructor Details

  - ### ExtendedTrackSelector

    public ExtendedTrackSelector(@NonNull Point displaySize)
    Constructs an ExtendedTrackSelector with default video track selection factory.
    Parameters:
      `displaySize` - the display size in pixels to be used for video track selection

  - ### ExtendedTrackSelector

    public ExtendedTrackSelector(@NonNull Point displaySize, @NonNull VideoTrackSelection.Factory videoTrackSelectionFactory, @Nullable ExtendedTrackSelector.PlayerInfoProvider playerInfoProvider, @Nullable ExtendedTrackSelector.EventListener eventListener, @Nullable PlayerConfig playerConfig)
    Constructs an ExtendedTrackSelector.
    Parameters:
      `displaySize` - the display size in pixels to be used for video track selection
      `videoTrackSelectionFactory` - the factory for creating video track selections
      `playerInfoProvider` - the provider for player information, can be `null`
      `eventListener` - the listener for track selection events, can be `null`
      `playerConfig` - the player configuration, can be `null`

- ## Method Details

  - ### reset

    public void reset()
    Resets the track selector to its initial state. This clears all preselected tracks, filters, and configurations.

  - ### setPreselectedVideoQualities

    public void setPreselectedVideoQualities(@Nullable int[] preselectedVideoQualityIndices)
    Preselect video qualities available for the selection
    Parameters:
      `preselectedVideoQualityIndices` - video qualities indices or `null` to reset previous values

  - ### setPreselectedAudio

    public void setPreselectedAudio(@Nullable List<TrackIndexOverride> preselectedAudio)
    Preselect audio tracks available for the selection
    Parameters:
      `preselectedAudio` - audio indices or `null` to reset previous values

  - ### setPreselectedSubtitle

    public void setPreselectedSubtitle(@Nullable List<TrackIndexOverride> preselectedSubtitle)
    Preselect subtitle tracks available for the selection
    Parameters:
      `preselectedSubtitle` - audio indices or `null` to reset previous values

  - ### setPreselectedSideloadedTracks

    public void setPreselectedSideloadedTracks(@Nullable List<SubtitleTrack> sideloadedTracks)
    Preselect sideloaded subtitle tracks available for the selection
    Parameters:
      `sideloadedTracks` - audio indices or `null` to reset previous values

  - ### setDisabledRendererIndices

    public void setDisabledRendererIndices(@Nullable List<Integer> disabledRendererIndices)
    Disable renderers by indices such that the tracks of the corresponding type will not be selected
    Parameters:
      `disabledRendererIndices` - renderers indices or `null` to reset previous values

  - ### setVideoHdEnabled

    public void setVideoHdEnabled(boolean isHdPlaybackEnabled)
    Enable or disable the video HD tracks. Note that this has to be called before the initial track selection. The current selection will not be invalidated.
    Parameters:
      `isHdPlaybackEnabled` - `true` to enable otherwise `false`

  - ### setVideoMaxResolution

    public void setVideoMaxResolution(int maxVideoWidth, int maxVideoHeight)
    Set the max video tracks resolution in pixels such that the video tracks with higher resolutions will not be available for the selection
    Parameters:
      `maxVideoWidth` - max video width in pixels
      `maxVideoHeight` - max video height in pixels

  - ### setVideoFilter

    public void setVideoFilter(@NonNull VideoFilterConfiguration contentFilter, @Nullable VideoFilterConfiguration adsFilter)
    Sets the video filter for content and ads. In case the `adsFilter` is `null` then the content video filter is used for both content and ads tracks filtering
    Parameters:
      `contentFilter` - The video filter for content
      `adsFilter` - The video filter for ads or `null` to use content filter for ads

  - ### setVideoCodecFilter

    public void setVideoCodecFilter(int videoCodecFilter)
    Set the video codec filtering policy, one of `SdkConsts.VideoCodecFilter`. Note that this has to be called before the initial track selection. The current selection will not be invalidated.
    Parameters:
      `videoCodecFilter` - video codec filter, one of `SdkConsts.VideoCodecFilter`

  - ### setAudioCodecFilter

    public void setAudioCodecFilter(int audioCodecFilter)
    Set the audio codec filtering policy, one of `SdkConsts.AudioCodecFilter`. Note that this has to be called before the initial track selection. The current selection will not be invalidated.
    Parameters:
      `audioCodecFilter` - audio codec filter, one of `SdkConsts.AudioCodecFilter`

  - ### setVideoTrackOverride

    public void setVideoTrackOverride(@Nullable VideoTrack videoTrack)
    Set video track override to be used during video selection
    Parameters:
      `videoTrack` - video track override

  - ### onLicenseKeysLoaded

    public void onLicenseKeysLoaded()
    Description copied from interface: `DrmEventListener`
    Called when a key was loaded successfully
    Specified by:
      `onLicenseKeysLoaded` in interface `DrmEventListener`

  - ### onLicenseKeysChanged

    public void onLicenseKeysChanged()
    Description copied from interface: `DrmEventListener`
    Called when keys are changed e.g. when license is renewed or expires
    Specified by:
      `onLicenseKeysChanged` in interface `DrmEventListener`

  - ### onLicenseLoadError

    public void onLicenseLoadError(int currentAttempt, int maxAttempts, @Nullable DownloadException downloadException)
    Description copied from interface: `DrmEventListener`
    Called when license load error occurred
    Specified by:
      `onLicenseLoadError` in interface `DrmEventListener`
    Parameters:
      `currentAttempt` - The current loading attempt
      `maxAttempts` - The max number of attempts
      `downloadException` - The download exception

  - ### onVideoEnabled

    public void onVideoEnabled(com.google.android.exoplayer2.decoder.DecoderCounters counters)
    Description copied from interface: `VideoRendererListener`
    Called when the renderer is enabled.
    Specified by:
      `onVideoEnabled` in interface `VideoRendererListener`
    Parameters:
      `counters` - `DecoderCounters` that will be updated by the renderer for as long as it remains enabled.

  - ### onVideoDecoderInitialized

    public void onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs)
    Description copied from interface: `VideoRendererListener`
    Called when a decoder is created.
    Specified by:
      `onVideoDecoderInitialized` in interface `VideoRendererListener`
    Parameters:
      `decoderName` - The decoder that was created.
      `initializedTimestampMs` - `SystemClock.elapsedRealtime()` when initialization finished.
      `initializationDurationMs` - The time taken to initialize the decoder in milliseconds.

  - ### onVideoDecoderReleased

    public void onVideoDecoderReleased(@NonNull String decoderName, long releasedTimestampMs, long releaseDurationMs)
    Description copied from interface: `VideoRendererListener`
    Called when a decoder is released.
    Specified by:
      `onVideoDecoderReleased` in interface `VideoRendererListener`
    Parameters:
      `decoderName` - The decoder that was released.
      `releasedTimestampMs` - `SystemClock.elapsedRealtime()` when release finished.
      `releaseDurationMs` - The time taken to release the decoder in milliseconds.

  - ### onVideoInputFormatChanged

    public void onVideoInputFormatChanged(com.google.android.exoplayer2.Format format)
    Description copied from interface: `VideoRendererListener`
    Called when the format of the media being consumed by the renderer changes.
    Specified by:
      `onVideoInputFormatChanged` in interface `VideoRendererListener`
    Parameters:
      `format` - The new format.

  - ### onDroppedFrames

    public void onDroppedFrames(int count, long elapsedMs)
    Description copied from interface: `VideoRendererListener`
    Called to report the number of frames dropped by the renderer. Dropped frames are reported whenever the renderer is stopped having dropped frames, and optionally, whenever the count reaches a specified threshold whilst the renderer is started.
    Specified by:
      `onDroppedFrames` in interface `VideoRendererListener`
    Parameters:
      `count` - The number of dropped frames.
      `elapsedMs` - The duration in milliseconds over which the frames were dropped. This duration is timed from when the renderer was started or from when dropped frames were last reported (whichever was more recent), and not from when the first of the reported drops occurred.

  - ### onRenderedFirstFrame

    public void onRenderedFirstFrame(@NonNull Object object)
    Description copied from interface: `VideoRendererListener`
    Called when a frame is rendered for the first time since setting the output, or since the renderer was reset, or since the stream being rendered was changed.
    Specified by:
      `onRenderedFirstFrame` in interface `VideoRendererListener`
    Parameters:
      `object` - The output of the video renderer. Normally a Surface, however some video renderers may have other output types.

  - ### onVideoDisabled

    public void onVideoDisabled(@NonNull com.google.android.exoplayer2.decoder.DecoderCounters counters)
    Description copied from interface: `VideoRendererListener`
    Called when the renderer is disabled.
    Specified by:
      `onVideoDisabled` in interface `VideoRendererListener`
    Parameters:
      `counters` - `DecoderCounters` that were updated by the renderer.

  - ### setInitialVideoTrackGroupIndex

    public void setInitialVideoTrackGroupIndex(int initialVideoTrackGroupIndex)
    Set video track group index override to be used during video selection. Note that this has to be called before the initial track selection. The current selection will not be invalidated.
    Parameters:
      `initialVideoTrackGroupIndex` - video track group index override

  - ### setAudioTrackOverride

    public void setAudioTrackOverride(@Nullable AudioTrack audioTrack)
    Set audio track override to be used during audio selection
    Parameters:
      `audioTrack` - audio track override

  - ### setAudioTrackIndexOverride

    public void setAudioTrackIndexOverride(@Nullable TrackIndexOverride trackIndexOverride)
    Set audio track indices override to be used during audio selection
    Parameters:
      `trackIndexOverride` - audio track indices override

  - ### setSubtitleTrackOverride

    public void setSubtitleTrackOverride(@Nullable SubtitleTrack subtitleTrack)
    Set subtitle track override to be used during subtitle selection
    Parameters:
      `subtitleTrack` - subtitle track override

  - ### setSubtitleTrackIndexOverride

    public void setSubtitleTrackIndexOverride(@Nullable TrackIndexOverride trackIndexOverride)
    Set subtitle track indices override to be used during subtitle selection
    Parameters:
      `trackIndexOverride` - subtitle track indices override

  - ### getPreferredAudioLanguage

    @Nullable public String getPreferredAudioLanguage()
    Get the preferred audio language
    Returns:
      preferred audio language

  - ### getPreferredSubtitleLanguage

    @Nullable public String getPreferredSubtitleLanguage()
    Get the preferred subtitles language
    Returns:
      preferred subtitles language

  - ### getRendererCapabilitiesListener

    @Nullable public com.google.android.exoplayer2.RendererCapabilities.Listener getRendererCapabilitiesListener()
    Overrides:
      `getRendererCapabilitiesListener` in class `com.google.android.exoplayer2.trackselection.TrackSelector`

  - ### onRendererCapabilitiesChanged

    public void onRendererCapabilitiesChanged(@NonNull com.google.android.exoplayer2.Renderer renderer)
    Specified by:
      `onRendererCapabilitiesChanged` in interface `com.google.android.exoplayer2.RendererCapabilities.Listener`

  - ### selectTracks

    @NonNull public com.google.android.exoplayer2.trackselection.TrackSelectorResult selectTracks(com.google.android.exoplayer2.RendererCapabilities[] rendererCapabilities, com.google.android.exoplayer2.source.TrackGroupArray trackGroups, com.google.android.exoplayer2.source.MediaSource.MediaPeriodId periodId, com.google.android.exoplayer2.Timeline timeline, Object manifest) throws com.google.android.exoplayer2.ExoPlaybackException
    Specified by:
      `selectTracks` in class `com.google.android.exoplayer2.trackselection.TrackSelector`
    Throws:
      `com.google.android.exoplayer2.ExoPlaybackException`

  - ### onSelectionActivated

    public void onSelectionActivated(Object info)
    Specified by:
      `onSelectionActivated` in class `com.google.android.exoplayer2.trackselection.TrackSelector`

  - ### createModel

    @Nullable public ExtendedTrackSelector.ModelSelection createModel(@NonNull com.google.android.exoplayer2.trackselection.TrackSelectorResult trackSelectorResult)
    Creates a model selection from the `TrackSelectorResult` if it is of type `ExtendedTrackSelector.ModelSelection`.
    Parameters:
      `trackSelectorResult` - the track selector result to create the model selection from
    Returns:
      the created model selection or null if the info is not of type `ExtendedTrackSelector.ModelSelection`

  - ### extractDashThumbnails

    public static void extractDashThumbnails(com.google.android.exoplayer2.source.dash.manifest.DashManifest dashManifest, com.google.android.exoplayer2.Timeline timeline, PlayerModel playerModel)
    Extracts the embedded thumbnail tracks in the DASH manifest, and updates the provided player model with them.
    Parameters:
      `dashManifest` - the DASH manifest which contains the thumbnail tracks to extract
      `timeline` - timeline representing provided manifest
      `playerModel` - player model to update with thumbnail tracks