OfflineLicenseHelper


@UnstableApi
class OfflineLicenseHelper


Helper class to download, renew and release offline licenses.

Summary

Public constructors

OfflineLicenseHelper(
    defaultDrmSessionManager: DefaultDrmSessionManager!,
    eventDispatcher: DrmSessionEventListener.EventDispatcher!
)

Constructs an instance.

Public functions

synchronized ByteArray<Byte>!

Downloads an offline license.

synchronized Pair<Long!, Long!>!
getLicenseDurationRemainingSec(offlineLicenseKeySetId: ByteArray!)

Returns the remaining license and playback durations in seconds, for an offline license.

java-static OfflineLicenseHelper!
newWidevineInstance(
    defaultLicenseUrl: String!,
    dataSourceFactory: DataSource.Factory!,
    eventDispatcher: DrmSessionEventListener.EventDispatcher!
)

Instantiates a new instance which uses Widevine CDM.

java-static OfflineLicenseHelper!
newWidevineInstance(
    defaultLicenseUrl: String!,
    forceDefaultLicenseUrl: Boolean,
    dataSourceFactory: DataSource.Factory!,
    eventDispatcher: DrmSessionEventListener.EventDispatcher!
)

Instantiates a new instance which uses Widevine CDM.

java-static OfflineLicenseHelper!
newWidevineInstance(
    defaultLicenseUrl: String!,
    forceDefaultLicenseUrl: Boolean,
    dataSourceFactory: DataSource.Factory!,
    optionalKeyRequestParameters: (Mutable)Map<String!, String!>?,
    eventDispatcher: DrmSessionEventListener.EventDispatcher!
)

Instantiates a new instance which uses Widevine CDM.

Unit

Releases the helper.

synchronized Unit
releaseLicense(offlineLicenseKeySetId: ByteArray!)

Releases an offline license.

synchronized ByteArray<Byte>!
renewLicense(offlineLicenseKeySetId: ByteArray!)

Renews an offline license.

Public constructors

OfflineLicenseHelper

OfflineLicenseHelper(
    defaultDrmSessionManager: DefaultDrmSessionManager!,
    eventDispatcher: DrmSessionEventListener.EventDispatcher!
)

Constructs an instance. Call release when the instance is no longer required.

Parameters
defaultDrmSessionManager: DefaultDrmSessionManager!

The DefaultDrmSessionManager used to download licenses.

eventDispatcher: DrmSessionEventListener.EventDispatcher!

A DrmSessionEventListener.EventDispatcher used to distribute DRM-related events.

Public functions

downloadLicense

synchronized fun downloadLicense(format: Format!): ByteArray<Byte>!

Downloads an offline license.

Parameters
format: Format!

The Format of the content whose license is to be downloaded. Must contain a non-null drmInitData.

Returns
ByteArray<Byte>!

The key set id for the downloaded license.

Throws
androidx.media3.exoplayer.drm.DrmSession.DrmSessionException

Thrown when a DRM session error occurs.

getLicenseDurationRemainingSec

synchronized fun getLicenseDurationRemainingSec(offlineLicenseKeySetId: ByteArray!): Pair<Long!, Long!>!

Returns the remaining license and playback durations in seconds, for an offline license.

Parameters
offlineLicenseKeySetId: ByteArray!

The key set id of the license.

Returns
Pair<Long!, Long!>!

The remaining license and playback durations, in seconds.

Throws
androidx.media3.exoplayer.drm.DrmSession.DrmSessionException

Thrown when a DRM session error occurs.

newWidevineInstance

java-static fun newWidevineInstance(
    defaultLicenseUrl: String!,
    dataSourceFactory: DataSource.Factory!,
    eventDispatcher: DrmSessionEventListener.EventDispatcher!
): OfflineLicenseHelper!

Instantiates a new instance which uses Widevine CDM. Call release when the instance is no longer required.

Parameters
defaultLicenseUrl: String!

The default license URL. Used for key requests that do not specify their own license URL.

dataSourceFactory: DataSource.Factory!

A factory from which to obtain DataSource instances.

eventDispatcher: DrmSessionEventListener.EventDispatcher!

A DrmSessionEventListener.EventDispatcher used to distribute DRM-related events.

Returns
OfflineLicenseHelper!

A new instance which uses Widevine CDM.

newWidevineInstance

java-static fun newWidevineInstance(
    defaultLicenseUrl: String!,
    forceDefaultLicenseUrl: Boolean,
    dataSourceFactory: DataSource.Factory!,
    eventDispatcher: DrmSessionEventListener.EventDispatcher!
): OfflineLicenseHelper!

Instantiates a new instance which uses Widevine CDM. Call release when the instance is no longer required.

Parameters
defaultLicenseUrl: String!

The default license URL. Used for key requests that do not specify their own license URL.

forceDefaultLicenseUrl: Boolean

Whether to use defaultLicenseUrl for key requests that include their own license URL.

dataSourceFactory: DataSource.Factory!

A factory from which to obtain DataSource instances.

eventDispatcher: DrmSessionEventListener.EventDispatcher!

A DrmSessionEventListener.EventDispatcher used to distribute DRM-related events.

Returns
OfflineLicenseHelper!

A new instance which uses Widevine CDM.

newWidevineInstance

java-static fun newWidevineInstance(
    defaultLicenseUrl: String!,
    forceDefaultLicenseUrl: Boolean,
    dataSourceFactory: DataSource.Factory!,
    optionalKeyRequestParameters: (Mutable)Map<String!, String!>?,
    eventDispatcher: DrmSessionEventListener.EventDispatcher!
): OfflineLicenseHelper!

Instantiates a new instance which uses Widevine CDM. Call release when the instance is no longer required.

Parameters
defaultLicenseUrl: String!

The default license URL. Used for key requests that do not specify their own license URL.

forceDefaultLicenseUrl: Boolean

Whether to use defaultLicenseUrl for key requests that include their own license URL.

dataSourceFactory: DataSource.Factory!

A factory from which to obtain DataSource instances.

optionalKeyRequestParameters: (Mutable)Map<String!, String!>?

An optional map of parameters to pass as the last argument to getKeyRequest. May be null.

eventDispatcher: DrmSessionEventListener.EventDispatcher!

A DrmSessionEventListener.EventDispatcher used to distribute DRM-related events.

Returns
OfflineLicenseHelper!

A new instance which uses Widevine CDM.

release

fun release(): Unit

Releases the helper. Should be called when the helper is no longer required.

releaseLicense

synchronized fun releaseLicense(offlineLicenseKeySetId: ByteArray!): Unit

Releases an offline license.

Parameters
offlineLicenseKeySetId: ByteArray!

The key set id of the license to be released.

Throws
androidx.media3.exoplayer.drm.DrmSession.DrmSessionException

Thrown when a DRM session error occurs.

renewLicense

synchronized fun renewLicense(offlineLicenseKeySetId: ByteArray!): ByteArray<Byte>!

Renews an offline license.

Parameters
offlineLicenseKeySetId: ByteArray!

The key set id of the license to be renewed.

Returns
ByteArray<Byte>!

The renewed offline license key set id.

Throws
androidx.media3.exoplayer.drm.DrmSession.DrmSessionException

Thrown when a DRM session error occurs.