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`

public class ExtendedTrackSelector extends com.google.android.exoplayer2.trackselection.TrackSelector implements DrmEventListener, VideoRendererListener

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static interface`
  `ExtendedTrackSelector.EventListener`
  Interface which receives Track Selection-related callbacks.
  `class`
  `ExtendedTrackSelector.ModelSelection`
  `static interface`
  `ExtendedTrackSelector.PlayerInfoProvider`

  ## 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()`
  `ExtendedTrackSelector(com.castlabs.android.player.VideoTrackSelection.Factory videoTrackSelectionFactory, ExtendedTrackSelector.PlayerInfoProvider playerInfoProvider, ExtendedTrackSelector.EventListener eventListener, PlayerConfig playerConfig)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ExtendedTrackSelector.ModelSelection`
  `createModel(com.google.android.exoplayer2.trackselection.TrackSelectorResult trackSelectorResult)`
  `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
  `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(Surface surface)`
  Called when a frame is rendered for the first time since setting the surface, and when a frame is rendered for the first time since the renderer was reset.
  `void`
  `onSelectionActivated(Object info)`
  `void`
  `onVideoDecoderInitialized(String decoderName, long initializedTimestampMs, long initializationDurationMs)`
  Called when a decoder is created.
  `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.
  `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`
  `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`
  `setDisplaySize(Point size)`
  `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

  `init, selectTracks`

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

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

- ## Constructor Details

  - ### ExtendedTrackSelector

    public ExtendedTrackSelector()

  - ### ExtendedTrackSelector

    public ExtendedTrackSelector(@NonNull com.castlabs.android.player.VideoTrackSelection.Factory videoTrackSelectionFactory, @Nullable ExtendedTrackSelector.PlayerInfoProvider playerInfoProvider, @Nullable ExtendedTrackSelector.EventListener eventListener, @Nullable PlayerConfig playerConfig)

- ## Method Details

  - ### setDisplaySize

    public void setDisplaySize(@NonNull Point size)

  - ### 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`

  - ### 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.

  - ### 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(Surface surface)
    Description copied from interface: `VideoRendererListener`
    Called when a frame is rendered for the first time since setting the surface, and when a frame is rendered for the first time since the renderer was reset.
    Specified by:
      `onRenderedFirstFrame` in interface `VideoRendererListener`
    Parameters:
      `surface` - The `Surface` to which a first frame has been rendered, or `null` if the renderer renders to something that isn't a `Surface`.

  - ### onVideoDisabled

    public void onVideoDisabled(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

  - ### 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)

  - ### 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