@UnstableApi
public final class DrmUtil


DRM-related utility methods.

Summary

Nested types

@Documented
@Retention(value = RetentionPolicy.SOURCE)
@Target(value = )
@IntDef(value = )
public annotation DrmUtil.ErrorSource

Identifies the operation which caused a DRM-related error.

Constants

static final int

Corresponds to failures caused by an ExoMediaDrm method call.

static final int

Corresponds to failures caused by an operation related to obtaining DRM licenses.

static final int

Corresponds to failures caused by an operation related to provisioning the device.

Public methods

static byte[]
executePost(
    DataSource dataSource,
    String url,
    @Nullable byte[] httpBody,
    Map<StringString> requestProperties
)

Executes a HTTP POST request with retry handling and returns the entire response in a byte buffer.

static int

Returns the PlaybackException.ErrorCode that corresponds to the given DRM-related exception.

static boolean

Returns true if e represents a failure to construct a NotProvisionedException.

static boolean

Returns true if e represents a failure to construct a ResourceBusyException.

Constants

ERROR_SOURCE_EXO_MEDIA_DRM

public static final int ERROR_SOURCE_EXO_MEDIA_DRM = 1

Corresponds to failures caused by an ExoMediaDrm method call.

ERROR_SOURCE_LICENSE_ACQUISITION

public static final int ERROR_SOURCE_LICENSE_ACQUISITION = 2

Corresponds to failures caused by an operation related to obtaining DRM licenses.

ERROR_SOURCE_PROVISIONING

public static final int ERROR_SOURCE_PROVISIONING = 3

Corresponds to failures caused by an operation related to provisioning the device.

Public methods

executePost

public static byte[] executePost(
    DataSource dataSource,
    String url,
    @Nullable byte[] httpBody,
    Map<StringString> requestProperties
)

Executes a HTTP POST request with retry handling and returns the entire response in a byte buffer.

Note that this method is executing the request synchronously and blocks until finished.

Parameters
DataSource dataSource

A DataSource.

String url

The requested URL.

@Nullable byte[] httpBody

The HTTP request payload.

Map<StringString> requestProperties

A keyed map of HTTP header request properties.

Returns
byte[]

A byte array that holds the response payload.

Throws
androidx.media3.exoplayer.drm.MediaDrmCallbackException

if an exception was encountered during the download.

getErrorCodeForMediaDrmException

@PlaybackException.ErrorCode
public static int getErrorCodeForMediaDrmException(
    Throwable exception,
    @DrmUtil.ErrorSource int errorSource
)

Returns the PlaybackException.ErrorCode that corresponds to the given DRM-related exception.

Parameters
Throwable exception

The DRM-related exception for which to obtain a corresponding .

@DrmUtil.ErrorSource int errorSource

The ErrorSource for the given exception.

Returns
int

The PlaybackException.ErrorCode that corresponds to the given DRM-related exception.

isFailureToConstructNotProvisionedException

public static boolean isFailureToConstructNotProvisionedException(@Nullable Throwable e)

Returns true if e represents a failure to construct a NotProvisionedException. See b/291440132.

isFailureToConstructResourceBusyException

public static boolean isFailureToConstructResourceBusyException(@Nullable Throwable e)

Returns true if e represents a failure to construct a ResourceBusyException. See b/291440132.