BaseContentSteeringTracker


@UnstableApi
public abstract class BaseContentSteeringTracker

Known direct subclasses
DashContentSteeringTracker

Tracks the content steering states for a DASH stream.

HlsContentSteeringTracker

Tracks the content steering states for an HLS stream.


Abstract base class for Content Steering tracker implementations.

It provides common state management for steering manifest tracking, pathway evaluation, and pathway cloning.

Summary

Public fields

boolean

Protected constructors

BaseContentSteeringTracker(
    DataSource.Factory dataSourceFactory,
    @Nullable Supplier<ReleasableExecutor> downloadExecutorSupplier
)

Creates a BaseContentSteeringTracker.

Public methods

final boolean

Returns whether the Content Steering tracker is active.

final void

Releases the Content Steering tracker.

final void
start(
    Uri initialSteeringManifestUri,
    ImmutableList<String> initialPathwayIds,
    MediaSourceEventListener.EventDispatcher eventDispatcher
)

Starts the Content Steering tracker.

Protected methods

static Uri
applyUriReplacement(
    Uri baseUri,
    SteeringManifest.UriReplacement uriReplacement
)

Applies a SteeringManifest.UriReplacement to a base URI.

final @Nullable ImmutableList<String>

Returns the current pathway priority.

abstract ImmutableMap<String, String>

Returns the query parameters to include in the steering manifest request.

abstract boolean

Returns whether the given pathway is currently available.

abstract void
onStart(ImmutableList<String> initialPathwayIds)

Called when the tracker is started.

abstract void

Called when tracking is stopped.

abstract void

Performs a pathway clone defined in the steering manifest.

abstract void

Performs a pathway evaluation based on the passed pathway priority.

Public fields

isActive

public boolean isActive

Protected fields

currentPathwayPriority

protected @Nullable ImmutableList<String> currentPathwayPriority

Protected constructors

BaseContentSteeringTracker

protected BaseContentSteeringTracker(
    DataSource.Factory dataSourceFactory,
    @Nullable Supplier<ReleasableExecutor> downloadExecutorSupplier
)

Creates a BaseContentSteeringTracker.

Parameters
DataSource.Factory dataSourceFactory

The DataSource.Factory to load steering manifests.

@Nullable Supplier<ReleasableExecutor> downloadExecutorSupplier

A supplier for a ReleasableExecutor to download steering manifests.

Public methods

isActive

public final boolean isActive()

Returns whether the Content Steering tracker is active.

If this method returns false, the caller of the tracker should behave as if content steering is absent.

release

public final void release()

Releases the Content Steering tracker.

Once released, the tracker cannot be used again.

start

public final void start(
    Uri initialSteeringManifestUri,
    ImmutableList<String> initialPathwayIds,
    MediaSourceEventListener.EventDispatcher eventDispatcher
)

Starts the Content Steering tracker.

Parameters
Uri initialSteeringManifestUri

The initial Uri of the steering manifest.

ImmutableList<String> initialPathwayIds

The IDs of the initial pathways to use before the first steering manifest is loaded.

MediaSourceEventListener.EventDispatcher eventDispatcher

A MediaSourceEventListener.EventDispatcher for reporting load events.

Protected methods

applyUriReplacement

protected static Uri applyUriReplacement(
    Uri baseUri,
    SteeringManifest.UriReplacement uriReplacement
)

Applies a SteeringManifest.UriReplacement to a base URI.

Parameters
Uri baseUri

The base Uri.

SteeringManifest.UriReplacement uriReplacement

The SteeringManifest.UriReplacement.

Returns
Uri

The updated Uri.

getCurrentPathwayPriority

protected final @Nullable ImmutableList<String> getCurrentPathwayPriority()

Returns the current pathway priority.

Returns
@Nullable ImmutableList<String>

The current pathway priority, or null if the tracker is not active.

getSteeringQueryParameters

protected abstract ImmutableMap<String, String> getSteeringQueryParameters()

Returns the query parameters to include in the steering manifest request.

isPathwayAvailable

protected abstract boolean isPathwayAvailable(String pathwayId)

Returns whether the given pathway is currently available.

Parameters
String pathwayId

The ID of the pathway to check.

Returns
boolean

Whether the given pathway is available.

onStart

protected abstract void onStart(ImmutableList<String> initialPathwayIds)

Called when the tracker is started.

Parameters
ImmutableList<String> initialPathwayIds

The IDs of the initial pathways to be used before the first steering manifest is loaded.

onStop

protected abstract void onStop()

Called when tracking is stopped.

This can be either externally called by release or internally due to an unrecoverable error.

performPathwayClone

protected abstract void performPathwayClone(SteeringManifest.PathwayClone pathwayClone)

Performs a pathway clone defined in the steering manifest.

Parameters
SteeringManifest.PathwayClone pathwayClone

The SteeringManifest.PathwayClone to perform.

performPathwayEvaluation

protected abstract void performPathwayEvaluation(ImmutableList<String> pathwayPriority)

Performs a pathway evaluation based on the passed pathway priority.

Parameters
ImmutableList<String> pathwayPriority

The pathway priority to use for evaluation.