HttpMediaDrmCallback


@UnstableApi
public final class HttpMediaDrmCallback implements MediaDrmCallback


A MediaDrmCallback that makes requests using DataSource instances.

Summary

Public constructors

HttpMediaDrmCallback(
    @Nullable String defaultLicenseUrl,
    DataSource.Factory dataSourceFactory
)

Constructs an instance.

HttpMediaDrmCallback(
    @Nullable String defaultLicenseUrl,
    boolean forceDefaultLicenseUrl,
    DataSource.Factory dataSourceFactory
)

Constructs an instance.

Public methods

void

Clears all headers for key requests made by the callback.

void

Clears a header for key requests made by the callback.

byte[]

Executes a key request.

byte[]

Executes a provisioning request.

void

Sets a header for key requests made by the callback.

Public constructors

HttpMediaDrmCallback

public HttpMediaDrmCallback(
    @Nullable String defaultLicenseUrl,
    DataSource.Factory dataSourceFactory
)

Constructs an instance.

Parameters
@Nullable String defaultLicenseUrl

The default license URL. Used for key requests that do not specify their own license URL. May be null if it's known that all key requests will specify their own URLs.

DataSource.Factory dataSourceFactory

A factory from which to obtain DataSource instances. This will usually be an HTTP-based DataSource.

HttpMediaDrmCallback

public HttpMediaDrmCallback(
    @Nullable String defaultLicenseUrl,
    boolean forceDefaultLicenseUrl,
    DataSource.Factory dataSourceFactory
)

Constructs an instance.

Parameters
@Nullable String defaultLicenseUrl

The default license URL. Used for key requests that do not specify their own license URL, or for all key requests if forceDefaultLicenseUrl is set to true. May be null if forceDefaultLicenseUrl is false and if it's known that all key requests will specify their own URLs.

boolean forceDefaultLicenseUrl

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

DataSource.Factory dataSourceFactory

A factory from which to obtain DataSource instances. This will * usually be an HTTP-based DataSource.

Public methods

clearAllKeyRequestProperties

public void clearAllKeyRequestProperties()

Clears all headers for key requests made by the callback.

clearKeyRequestProperty

public void clearKeyRequestProperty(String name)

Clears a header for key requests made by the callback.

Parameters
String name

The name of the header field.

executeKeyRequest

public byte[] executeKeyRequest(UUID uuid, ExoMediaDrm.KeyRequest request)

Executes a key request.

Parameters
UUID uuid

The UUID of the content protection scheme.

ExoMediaDrm.KeyRequest request

The request.

Returns
byte[]

The response data.

Throws
androidx.media3.exoplayer.drm.MediaDrmCallbackException

If an error occurred executing the request.

executeProvisionRequest

public byte[] executeProvisionRequest(
    UUID uuid,
    ExoMediaDrm.ProvisionRequest request
)

Executes a provisioning request.

Parameters
UUID uuid

The UUID of the content protection scheme.

ExoMediaDrm.ProvisionRequest request

The request.

Returns
byte[]

The response data.

Throws
androidx.media3.exoplayer.drm.MediaDrmCallbackException

If an error occurred executing the request.

setKeyRequestProperty

public void setKeyRequestProperty(String name, String value)

Sets a header for key requests made by the callback.

Parameters
String name

The name of the header field.

String value

The value of the field.