FakeTrackSelector


@UnstableApi
public class FakeTrackSelector extends DefaultTrackSelector


A fake MappingTrackSelector that returns FakeTrackSelections.

Summary

Public constructors

FakeTrackSelector(boolean mayReuseTrackSelection)

Public methods

List<FakeTrackSelection>

Returns list of all FakeTrackSelections that this track selector has made so far.

Protected methods

ExoTrackSelection.Definition[]
selectAllTracks(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @RendererCapabilities.Capabilities int[][][] rendererFormatSupports,
    @RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports,
    DefaultTrackSelector.Parameters params
)

Called from selectTracks to make a track selection for each renderer, prior to overrides and disabled flags being applied.

Inherited Constants

From androidx.media3.exoplayer.trackselection.DefaultTrackSelector
static final int

Track is eligible for both a fixed selection and as part of an adaptive selection with multiple tracks.

static final int

Track is eligible for a fixed selection with one track.

static final int

Track is not eligible for selection.

Inherited methods

From androidx.media3.exoplayer.trackselection.DefaultTrackSelector
DefaultTrackSelector.Parameters.Builder

Returns a new Parameters.Builder initialized with the current selection parameters.

static int
getFormatLanguageScore(
    Format format,
    @Nullable String language,
    boolean allowUndeterminedFormatLanguage
)

Returns a score for how well a language specified in a Format matches a given language.

DefaultTrackSelector.Parameters

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.

boolean

Returns if this TrackSelector supports setParameters.

static boolean
isSupported(
    @RendererCapabilities.Capabilities int formatSupport,
    boolean allowExceedsCapabilities
)

Returns true if the FormatSupport in the given Capabilities is FORMAT_HANDLED or if allowExceedsCapabilities is set and the format support is FORMAT_EXCEEDS_CAPABILITIES.

static @Nullable String

Normalizes the input string to null if it does not define a language, or returns it otherwise.

void

Called when the renderer capabilities are changed.

void

Called by the player to release the selector.

@Nullable Pair<ExoTrackSelection.DefinitionInteger>
selectAudioTrack(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @RendererCapabilities.Capabilities int[][][] rendererFormatSupports,
    @RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports,
    DefaultTrackSelector.Parameters params
)

Called by selectAllTracks to create a ExoTrackSelection.Definition for an audio track selection.

@Nullable Pair<ExoTrackSelection.DefinitionInteger>
selectImageTrack(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @RendererCapabilities.Capabilities int[][][] rendererFormatSupports,
    DefaultTrackSelector.Parameters params
)

Called by selectAllTracks to create a ExoTrackSelection.Definition for an image track selection.

@Nullable ExoTrackSelection.Definition
selectOtherTrack(
    int trackType,
    TrackGroupArray groups,
    @RendererCapabilities.Capabilities int[][] formatSupport,
    DefaultTrackSelector.Parameters params
)

Called by selectAllTracks to create a ExoTrackSelection for a renderer whose type is neither video, audio or text.

@Nullable Pair<ExoTrackSelection.DefinitionInteger>
selectTextTrack(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @RendererCapabilities.Capabilities int[][][] rendererFormatSupports,
    DefaultTrackSelector.Parameters params,
    @Nullable String selectedAudioLanguage
)

Called by selectAllTracks to create a ExoTrackSelection.Definition for a text track selection.

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

@Nullable Pair<ExoTrackSelection.DefinitionInteger>
selectVideoTrack(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @RendererCapabilities.Capabilities int[][][] rendererFormatSupports,
    @RendererCapabilities.AdaptiveSupport int[] mixedMimeTypeSupports,
    DefaultTrackSelector.Parameters params
)

Called by selectAllTracks to create a ExoTrackSelection.Definition for a video track selection.

void

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

void

Atomically sets the provided parameters for track selection.

void

This method is deprecated.

Use setParameters instead.

void

Called by the player to provide parameters for track selection.

From androidx.media3.exoplayer.trackselection.MappingTrackSelector
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.

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.

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.

Public constructors

FakeTrackSelector

public FakeTrackSelector()

FakeTrackSelector

public FakeTrackSelector(boolean mayReuseTrackSelection)
Parameters
boolean mayReuseTrackSelection

Whether this FakeTrackSelector will reuse s during track selection, when it finds previously-selected track selection using the same TrackGroup.

Public methods

getAllTrackSelections

public List<FakeTrackSelectiongetAllTrackSelections()

Returns list of all FakeTrackSelections that this track selector has made so far.

Protected methods

selectAllTracks

protected ExoTrackSelection.Definition[] selectAllTracks(
    MappingTrackSelector.MappedTrackInfo mappedTrackInfo,
    @RendererCapabilities.Capabilities int[][][] rendererFormatSupports,
    @RendererCapabilities.AdaptiveSupport int[] rendererMixedMimeTypeAdaptationSupports,
    DefaultTrackSelector.Parameters params
)

Called from selectTracks to make a track selection for each renderer, prior to overrides and disabled flags being applied.

The implementation should not account for overrides and disabled flags. Track selections generated by this method will be overridden to account for these properties.

If selection parameters include audioOffloadPreferences with audioOffloadMode set to AUDIO_OFFLOAD_MODE_REQUIRED then only audio tracks will be selected. If no audio track is supported in offload, then no track will be selected.

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[] rendererMixedMimeTypeAdaptationSupports

The AdaptiveSupport for mixed MIME type adaptation for the renderer.

DefaultTrackSelector.Parameters params

The parameters to use for the track selection.

Returns
ExoTrackSelection.Definition[]

The ExoTrackSelection.Definitions for the renderers. A null entry indicates no selection was made.

Throws
androidx.media3.exoplayer.ExoPlaybackException

If an error occurs while selecting the tracks.