@UnstableApi
public final class HlsRedundantGroup


Represents a group of variants or renditions that are identical streams but from different locations (different playlist urls), and indicated by a shared GroupKey.

Summary

Nested types

Defines a key that groups variants or renditions into one HlsRedundantGroup.

Represents the type of a HlsRedundantGroup.

Public constructors

HlsRedundantGroup(
    HlsRedundantGroup.GroupKey groupKey,
    String pathwayId,
    Uri playlistUrl
)

Creates a HlsRedundantGroup.

Public methods

static ImmutableList<HlsRedundantGroup>

Creates a list of redundant groups for renditions.

static ImmutableList<HlsRedundantGroup>

Creates a list of redundant groups for variants.

ImmutableSet<String>

Returns all pathway IDs that belong to this HlsRedundantGroup.

ImmutableSet<Uri>

Returns all playlist urls that belong to this HlsRedundantGroup.

String

Returns the pathway ID that is currently chosen for playback.

Uri

Returns the playlist url that is associated with the currently chosen pathway ID.

@Nullable Uri

Returns the playlist url associated with the given pathwayId, or null if the given pathwayId doesn't exist in this HlsRedundantGroup.

void
put(String pathwayId, Uri playlistUrl)

Puts a playlistUrl and its associated pathwayId to the HlsRedundantGroup.

void

Sets the pathwayId that is currently chosen for playback.

int

Returns the size of the HlsRedundantGroup.

Constants

AUDIO_RENDITION

@HlsRedundantGroup.Type
public static final int AUDIO_RENDITION = 2

The HlsRedundantGroup groups audio renditions.

SUBTITLE_RENDITION

@HlsRedundantGroup.Type
public static final int SUBTITLE_RENDITION = 3

The HlsRedundantGroup groups subtitle renditions.

VARIANT

@HlsRedundantGroup.Type
public static final int VARIANT = 0

The HlsRedundantGroup groups variants.

VIDEO_RENDITION

@HlsRedundantGroup.Type
public static final int VIDEO_RENDITION = 1

The HlsRedundantGroup groups video renditions.

Public fields

currentPathwayId

public String currentPathwayId

groupKey

public final HlsRedundantGroup.GroupKey groupKey

The GroupKey that the grouped variants or grouped renditions share.

Public constructors

HlsRedundantGroup

public HlsRedundantGroup(
    HlsRedundantGroup.GroupKey groupKey,
    String pathwayId,
    Uri playlistUrl
)

Creates a HlsRedundantGroup.

Parameters
HlsRedundantGroup.GroupKey groupKey

See groupKey.

String pathwayId

The ID of the default current pathway.

Uri playlistUrl

The playlist url that is associated with the default current pathway.

Public methods

createRenditionRedundantGroupList

public static ImmutableList<HlsRedundantGroupcreateRenditionRedundantGroupList(
    List<HlsMultivariantPlaylist.Rendition> renditions
)

Creates a list of redundant groups for renditions.

For each Rendition with a non-null url, a generated pathway ID will be used. The first is '.', and the subsequent ones for the same group are '..', '...', according to the order they are listed in the HlsMultivariantPlaylist.

Parameters
List<HlsMultivariantPlaylist.Rendition> renditions

The renditions.

createVariantRedundantGroupList

public static ImmutableList<HlsRedundantGroupcreateVariantRedundantGroupList(
    List<HlsMultivariantPlaylist.Variant> variants
)

Creates a list of redundant groups for variants.

If a Variant has a non-null pathway ID, then its url will be associated with that pathway ID when added to the HlsRedundantGroup. Otherwise, a generated pathway ID will be used. The first is '.', and the subsequent ones for the same group are '..', '...', according to the order they are listed in the HlsMultivariantPlaylist.

Parameters
List<HlsMultivariantPlaylist.Variant> variants

The variants.

Throws
androidx.media3.common.ParserException

If two variants grouped into one HlsRedundantGroup have the same pathwayId but different urls.

getAllPathwayIds

public ImmutableSet<StringgetAllPathwayIds()

Returns all pathway IDs that belong to this HlsRedundantGroup.

getAllPlaylistUrls

public ImmutableSet<UrigetAllPlaylistUrls()

Returns all playlist urls that belong to this HlsRedundantGroup.

getCurrentPathwayId

public String getCurrentPathwayId()

Returns the pathway ID that is currently chosen for playback.

getCurrentPlaylistUrl

public Uri getCurrentPlaylistUrl()

Returns the playlist url that is associated with the currently chosen pathway ID.

getPlaylistUrl

public @Nullable Uri getPlaylistUrl(String pathwayId)

Returns the playlist url associated with the given pathwayId, or null if the given pathwayId doesn't exist in this HlsRedundantGroup.

put

public void put(String pathwayId, Uri playlistUrl)

Puts a playlistUrl and its associated pathwayId to the HlsRedundantGroup.

setCurrentPathwayId

public void setCurrentPathwayId(String pathwayId)

Sets the pathwayId that is currently chosen for playback.

size

public int size()

Returns the size of the HlsRedundantGroup.