Class BaseTrackSelection

    • Field Detail

      • length

        protected final int length
        The number of selected tracks within the TrackGroup. Always greater than zero.
      • tracks

        protected final int[] tracks
        The indices of the selected tracks in group, in order of decreasing bandwidth.
    • Constructor Detail

      • BaseTrackSelection

        public BaseTrackSelection​(TrackGroup group,
                                  int... tracks)
        Parameters:
        group - The TrackGroup. Must not be null.
        tracks - The indices of the selected tracks within the TrackGroup. Must not be null or empty. May be in any order.
      • BaseTrackSelection

        public BaseTrackSelection​(TrackGroup group,
                                  int[] tracks,
                                  @com.google.android.exoplayer2.trackselection.TrackSelection.Type int type)
        Parameters:
        group - The TrackGroup. Must not be null.
        tracks - The indices of the selected tracks within the TrackGroup. Must not be null or empty. May be in any order.
        type - The type that will be returned from TrackSelection.getType().
    • Method Detail

      • getType

        public final int getType()
        Description copied from interface: TrackSelection
        Returns an integer specifying the type of the selection, or TrackSelection.TYPE_UNSET if not specified.

        Track selection types are specific to individual applications, but should be defined starting from TrackSelection.TYPE_CUSTOM_BASE to ensure they don't conflict with any types that may be added to the library in the future.

        Specified by:
        getType in interface TrackSelection
      • length

        public final int length()
        Description copied from interface: TrackSelection
        Returns the number of tracks in the selection.
        Specified by:
        length in interface TrackSelection
      • getFormat

        public final Format getFormat​(int index)
        Description copied from interface: TrackSelection
        Returns the format of the track at a given index in the selection.
        Specified by:
        getFormat in interface TrackSelection
        Parameters:
        index - The index in the selection.
        Returns:
        The format of the selected track.
      • getIndexInTrackGroup

        public final int getIndexInTrackGroup​(int index)
        Description copied from interface: TrackSelection
        Returns the index in the track group of the track at a given index in the selection.
        Specified by:
        getIndexInTrackGroup in interface TrackSelection
        Parameters:
        index - The index in the selection.
        Returns:
        The index of the selected track.
      • indexOf

        public final int indexOf​(Format format)
        Description copied from interface: TrackSelection
        Returns the index in the selection of the track with the specified format. The format is located by identity so, for example, selection.indexOf(selection.getFormat(index)) == index even if multiple selected tracks have formats that contain the same values.
        Specified by:
        indexOf in interface TrackSelection
        Parameters:
        format - The format.
        Returns:
        The index in the selection, or C.INDEX_UNSET if the track with the specified format is not part of the selection.
      • indexOf

        public final int indexOf​(int indexInTrackGroup)
        Description copied from interface: TrackSelection
        Returns the index in the selection of the track with the specified index in the track group.
        Specified by:
        indexOf in interface TrackSelection
        Parameters:
        indexInTrackGroup - The index in the track group.
        Returns:
        The index in the selection, or C.INDEX_UNSET if the track with the specified index is not part of the selection.
      • onPlaybackSpeed

        public void onPlaybackSpeed​(float playbackSpeed)
        Description copied from interface: ExoTrackSelection
        Called to notify the selection of the current playback speed. The playback speed may affect adaptive track selection.
        Specified by:
        onPlaybackSpeed in interface ExoTrackSelection
        Parameters:
        playbackSpeed - The factor by which playback is sped up.
      • evaluateQueueSize

        public int evaluateQueueSize​(long playbackPositionUs,
                                     List<? extends MediaChunk> queue)
        Description copied from interface: ExoTrackSelection
        Returns the number of chunks that should be retained in the queue.

        May be called by sources that load media in discrete MediaChunks and support discarding of buffered chunks.

        To avoid excessive re-buffering, implementations should normally return the size of the queue. An example of a case where a smaller value may be returned is if network conditions have improved dramatically, allowing chunks to be discarded and re-buffered in a track of significantly higher quality. Discarding chunks may allow faster switching to a higher quality track in this case.

        Note that even if the source supports discarding of buffered chunks, the actual number of discarded chunks is not guaranteed. The source will call ExoTrackSelection.updateSelectedTrack(long, long, long, List, MediaChunkIterator[]) with the updated queue of chunks before loading a new chunk to allow switching to another quality.

        This method will only be called when the selection is enabled and none of the MediaChunks in the queue are currently loading.

        Specified by:
        evaluateQueueSize in interface ExoTrackSelection
        Parameters:
        playbackPositionUs - The current playback position in microseconds. If playback of the period to which this track selection belongs has not yet started, the value will be the starting position in the period minus the duration of any media in previous periods still to be played.
        queue - The queue of buffered MediaChunks. Must not be modified.
        Returns:
        The number of chunks to retain in the queue.
      • isBlacklisted

        public boolean isBlacklisted​(int index,
                                     long nowMs)
        Description copied from interface: ExoTrackSelection
        Returns whether the track at the specified index in the selection is excluded.
        Specified by:
        isBlacklisted in interface ExoTrackSelection
        Parameters:
        index - The index of the track in the selection.
        nowMs - The current time in the timebase of SystemClock.elapsedRealtime().
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • equals

        public boolean equals​(@Nullable
                              Object obj)
        Overrides:
        equals in class Object