harmony 鸿蒙Drm

2025-06-12 浏览 (1)

Drm

Overview

The Digital Rights Management (DRM) module provides C APIs to implement digital rights protection.

You can refer to the corresponding development guide and samples based on your development requirements.

Since: 11

Summary

Files

NameDescription
native_drm_common.hDeclares the DRM data types.
native_drm_err.hDeclares the DRM error codes.
native_mediakeysession.hDeclares the MediaKeySession APIs.
native_mediakeysystem.hDeclares the MediaKeySystem APIs.

Structs

NameDescription
struct DRM_MediaKeyRequestInfoDescribes the information about a media key request.
struct DRM_MediaKeyRequestDescribes a media key request.
struct DRM_StatisticsDescribes the statistical information of a media key system.
struct DRM_OfflineMediakeyIdArrayDescribes an array holding the IDs of offline media keys.
struct DRM_KeysInfoDescribes the information about media keys.
struct DRM_MediaKeyStatusDescribes the media key status.
struct DRM_PsshInfoDescribes the Protection System Specific Header (PSSH) in DRM information.
struct DRM_MediaKeySystemInfoDescribes the DRM information, which is used to encrypt content.
struct MediaKeySession_CallbackDescribes a media key session callback, which is used to listen for events such as key changes. This struct applies to the scenario where a single media file is decrypted.
struct OH_MediaKeySession_CallbackDescribes a media key session callback, which is used to listen for events such as key changes. This struct applies to the scenario where multiple media files are decrypted.
struct DRM_MediaKeySystemDescriptionDescribes the DRM solution name and UUID list.

Macros

NameDescription
MAX_MEDIA_KEY_REQUEST_OPTION_COUNT   16Maximum number of optional data items in a media key request.
MAX_MEDIA_KEY_REQUEST_OPTION_NAME_LEN   64Maximum length of an optional data name in a media key request.
MAX_MEDIA_KEY_REQUEST_OPTION_DATA_LEN   128Maximum length of optional data in a media key request.
MAX_INIT_DATA_LEN   2048Maximum length of data in an initial request.
MAX_MIMETYPE_LEN   64Maximum length of a MIME type.
MAX_MEDIA_KEY_REQUEST_DATA_LEN   8192Maximum length of data in a media key request.
MAX_DEFAULT_URL_LEN   2048Maximum length of a URL.
MAX_STATISTICS_COUNT   10Maximum number of statistical items.
MAX_STATISTICS_NAME_LEN   64Maximum length of a statistical item name.
MAX_STATISTICS_BUFFER_LEN   256Maximum length of a statistical item buffer.
MAX_OFFLINE_MEDIA_KEY_ID_COUNT   512Maximum number of offline media key IDs.
MAX_OFFLINE_MEDIA_KEY_ID_LEN   64Maximum length of an offline media key ID.
MAX_KEY_INFO_COUNT   64Maximum number of pieces of media key information.
MAX_KEY_ID_LEN   16Maximum length of a media key ID.
MAX_KEY_STATUS_VALUE_LEN   128Maximum length of a key status value.
MAX_MEDIA_KEY_STATUS_COUNT   64Maximum number of media key statuses.
MAX_MEDIA_KEY_STATUS_NAME_LEN   64Maximum length of a media key status name.
MAX_MEDIA_KEY_STATUS_VALUE_LEN   256Maximum length of a media key status value.
DRM_UUID_LEN   16Length of the UUID of a DRM solution.
MAX_PSSH_DATA_LEN   2048Maximum length of PSSH data.
MAX_PSSH_INFO_COUNT   8Maximum number of pieces of PSSH data.
MAX_MEDIA_KEY_SYSTEM_NAME_LEN   128Maximum length of a MediaKeySystem instance name.
MAX_MEDIA_KEY_SYSTEM_NUM   8Maximum number of MediaKeySystem instances.

Types

NameDescription
typedef enum DRM_EventType DRM_EventTypeDefines an enum for the types of events that can be subscribed to.
typedef enum DRM_ContentProtectionLevel DRM_ContentProtectionLevelDefines an enum for the content protection levels.
typedef enum DRM_MediaKeyType DRM_MediaKeyTypeDefines an enum for the types of media keys.
typedef enum DRM_MediaKeyRequestType DRM_MediaKeyRequestTypeDefines an enum for the types of media key requests.
typedef enum DRM_OfflineMediaKeyStatus DRM_OfflineMediaKeyStatusDefines an enum for the statuses of offline media keys.
typedef enum DRM_CertificateStatus DRM_CertificateStatusDefines an enum for the DRM certificate statuses.
typedef struct DRM_MediaKeyRequestInfo DRM_MediaKeyRequestInfoDefines a struct for the information about a media key request.
typedef struct DRM_MediaKeyRequest DRM_MediaKeyRequestDefines a struct for a media key request.
typedef struct DRM_Statistics DRM_StatisticsDefines a struct for the statistical information of a media key system.
typedef struct DRM_OfflineMediakeyIdArray DRM_OfflineMediakeyIdArrayDefines a struct for the array holding the IDs of offline media keys.
typedef struct DRM_KeysInfo DRM_KeysInfoDefines a struct for the information about media keys.
typedef struct DRM_MediaKeyStatus DRM_MediaKeyStatusDefines a struct for the media key status.
typedef struct DRM_PsshInfo DRM_PsshInfoDefines a struct for PSSH data in DRM information.
typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfoDefines a struct for the DRM information, which is used to encrypt content.
typedef struct DRM_MediaKeySystemDescription DRM_MediaKeySystemDescriptionDefines a struct for the DRM solution name and UUID list.
typedef void(* DRM_MediaKeySystemInfoCallback) (DRM_MediaKeySystemInfo *mediaKeySystemInfo)Defines a callback for media key system information.
typedef struct MediaKeySystem MediaKeySystemDefines a struct for a media key system.
typedef struct MediaKeySession MediaKeySessionDefines a struct for a media key session.
typedef enum Drm_ErrCode Drm_ErrCodeDefines an enum for the DRM error codes.
typedef Drm_ErrCode(* MediaKeySession_EventCallback) (DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra)Defines the callback that is invoked when a media key session event is triggered. No MediaKeySession instance is returned. This callback applies to the scenario where a single media file is decrypted.
typedef Drm_ErrCode(* MediaKeySession_KeyChangeCallback) (DRM_KeysInfo *keysInfo, bool newKeysAvailable)Defines the callback that is invoked when the media key in a MediaKeySession instance is changed. No MediaKeySession instance is returned. This callback applies to the scenario where a single media file is decrypted.
typedef struct MediaKeySession_Callback MediaKeySession_CallbackDefines a struct for the media key session callback. This struct applies to the scenario where a single media file is decrypted.
typedef Drm_ErrCode(* OH_MediaKeySession_EventCallback) (MediaKeySession *mediaKeySession, DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra)Defines the callback that is invoked when a media key session event is triggered. A MediaKeySession instance is returned. This callback applies to the scenario where multiple media files are decrypted.
typedef Drm_ErrCode(* OH_MediaKeySession_KeyChangeCallback) (MediaKeySession *mediaKeySession, DRM_KeysInfo *keysInfo, bool newKeysAvailable)Defines the callback that is invoked when the media key in a MediaKeySession instance is changed. A MediaKeySession instance is returned. This callback applies to the scenario where multiple media files are decrypted.
typedef struct OH_MediaKeySession_Callback OH_MediaKeySession_CallbackDefines a struct for the media key session callback. This struct applies to the scenario where multiple media files are decrypted.
typedef Drm_ErrCode(* MediaKeySystem_Callback) (DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra)Defines the callback that is invoked when a media key system event is triggered. No MediaKeySystem instance is returned. This callback applies to the scenario where a single MediaKeySystem instance is used.
typedef Drm_ErrCode(* OH_MediaKeySystem_Callback) (MediaKeySystem *mediaKeySystem, DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra)Defines the callback that is invoked when a media key system event is triggered. A MediaKeySystem instance is returned. This callback applies to the scenario where multiple MediaKeySystem instances are used.

Enums

NameDescription
DRM_EventType {
EVENT_DRM_BASE = 200,
EVENT_PROVISION_REQUIRED = 201,
EVENT_KEY_REQUIRED = 202,
EVENT_KEY_EXPIRED = 203,
EVENT_VENDOR_DEFINED = 204,
EVENT_EXPIRATION_UPDATE = 206
}
Enumerates the event types.
DRM_ContentProtectionLevel {
CONTENT_PROTECTION_LEVEL_UNKNOWN = 0,
CONTENT_PROTECTION_LEVEL_SW_CRYPTO,
CONTENT_PROTECTION_LEVEL_HW_CRYPTO,
CONTENT_PROTECTION_LEVEL_ENHANCED_HW_CRYPTO,
CONTENT_PROTECTION_LEVEL_MAX
}
Enumerates the content protection levels.
DRM_MediaKeyType {
MEDIA_KEY_TYPE_OFFLINE = 0,
MEDIA_KEY_TYPE_ONLINE
}
Enumerates the types of media keys.
DRM_MediaKeyRequestType {
MEDIA_KEY_REQUEST_TYPE_UNKNOWN = 0,
MEDIA_KEY_REQUEST_TYPE_INITIAL,
MEDIA_KEY_REQUEST_TYPE_RENEWAL,
MEDIA_KEY_REQUEST_TYPE_RELEASE,
MEDIA_KEY_REQUEST_TYPE_NONE,
MEDIA_KEY_REQUEST_TYPE_UPDATE
}
Enumerates the types of media key requests.
DRM_OfflineMediaKeyStatus {
OFFLINE_MEDIA_KEY_STATUS_UNKNOWN = 0,
OFFLINE_MEDIA_KEY_STATUS_USABLE,
OFFLINE_MEDIA_KEY_STATUS_INACTIVE }
Enumerates the statuses of offline media keys.
DRM_CertificateStatus {
CERT_STATUS_PROVISIONED = 0,
CERT_STATUS_NOT_PROVISIONED,
CERT_STATUS_EXPIRED,
CERT_STATUS_INVALID,
CERT_STATUS_UNAVAILABLE
}
Enumerates the DRM certificate statuses.
Drm_ErrCode {
DRM_ERR_OK = 0,
DRM_CAPI_ERR_BASE = 24700500,
DRM_ERR_NO_MEMORY = DRM_CAPI_ERR_BASE + 1,
DRM_ERR_OPERATION_NOT_PERMITTED = DRM_CAPI_ERR_BASE + 2,
DRM_ERR_INVALID_VAL = DRM_CAPI_ERR_BASE + 3,
DRM_ERR_IO = DRM_CAPI_ERR_BASE + 4,
DRM_ERR_TIMEOUT = DRM_CAPI_ERR_BASE + 5,
DRM_ERR_UNKNOWN = DRM_CAPI_ERR_BASE + 6,
DRM_ERR_SERVICE_DIED = DRM_CAPI_ERR_BASE + 7,
DRM_ERR_INVALID_STATE = DRM_CAPI_ERR_BASE + 8,
DRM_ERR_UNSUPPORTED = DRM_CAPI_ERR_BASE + 9,
DRM_ERR_MAX_SYSTEM_NUM_REACHED = DRM_CAPI_ERR_BASE + 10,
DRM_ERR_MAX_SESSION_NUM_REACHED = DRM_CAPI_ERR_BASE + 11,
DRM_ERR_EXTEND_START = DRM_CAPI_ERR_BASE + 100
}
Enumerates the DRM error codes.

Functions

NameDescription
Drm_ErrCode OH_MediaKeySession_GenerateMediaKeyRequest (MediaKeySession *mediaKeySession, DRM_MediaKeyRequestInfo *info, DRM_MediaKeyRequest *mediaKeyRequest)Generates a media key request.
Drm_ErrCode OH_MediaKeySession_ProcessMediaKeyResponse (MediaKeySession *mediaKeySession, uint8_t *response, int32_t responseLen, uint8_t *offlineMediaKeyId, int32_t *offlineMediaKeyIdLen)Processes a media key response.
Drm_ErrCode OH_MediaKeySession_CheckMediaKeyStatus (MediaKeySession *mediaKeySession, DRM_MediaKeyStatus *mediaKeyStatus)Checks the status of media keys.
Drm_ErrCode OH_MediaKeySession_ClearMediaKeys (MediaKeySession *mediaKeySession)Clears media keys.
Drm_ErrCode OH_MediaKeySession_GenerateOfflineReleaseRequest (MediaKeySession *mediaKeySession, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, uint8_t *releaseRequest, int32_t *releaseRequestLen)Generates a request to release offline media keys.
Drm_ErrCode OH_MediaKeySession_ProcessOfflineReleaseResponse (MediaKeySession *mediaKeySession, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, uint8_t *releaseReponse, int32_t releaseReponseLen)Processes a response to a request for releasing offline media keys.
Drm_ErrCode OH_MediaKeySession_RestoreOfflineMediaKeys (MediaKeySession *mediaKeySession, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen)Restores offline media keys.
Drm_ErrCode OH_MediaKeySession_GetContentProtectionLevel (MediaKeySession *mediaKeySession, DRM_ContentProtectionLevel *contentProtectionLevel)Obtains the content protection level of a media key session.
Drm_ErrCode OH_MediaKeySession_RequireSecureDecoderModule (MediaKeySession *mediaKeySession, const char *mimeType, bool *status)Checks whether secure decoding is required.
Drm_ErrCode OH_MediaKeySession_SetMediaKeySessionCallback (MediaKeySession *mediaKeySession, MediaKeySession_Callback *callback)Sets a media key session event callback. It applies to the scenario where a single media file is decrypted.
Drm_ErrCode OH_MediaKeySession_SetCallback (MediaKeySession *mediaKeySession, OH_MediaKeySession_Callback *callback)Sets a media key session event callback. It applies to the scenario where multiple media files are decrypted.
Drm_ErrCode OH_MediaKeySession_Destroy (MediaKeySession *mediaKeySession)Releases a MediaKeySession instance.
Drm_ErrCode OH_MediaKeySystem_SetCallback (MediaKeySystem *mediaKeySystem, OH_MediaKeySystem_Callback callback)Sets a media key system event callback.
bool OH_MediaKeySystem_IsSupported (const char *name)Checks whether the device supports the specified DRM solution.
bool OH_MediaKeySystem_IsSupported2 (const char *name, const char *mimeType)Checks whether the device supports the combination of the DRM solution and MIME type.
bool OH_MediaKeySystem_IsSupported3 (const char *name, const char *mimeType, DRM_ContentProtectionLevel contentProtectionLevel)Checks whether the device supports the combination of the DRM solution, MIME type, and content protection level.
Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems (DRM_MediaKeySystemDescription *infos, uint32_t *count)Obtains the list of DRM solutions supported by the device.
Drm_ErrCode OH_MediaKeySystem_Create (const char *name, MediaKeySystem **mediaKeySystem)Creates a MediaKeySystem instance.
Drm_ErrCode OH_MediaKeySystem_SetConfigurationString (MediaKeySystem *mediaKeySystem, const char *configName, const char *value)Sets a configuration item in the form of a string.
Drm_ErrCode OH_MediaKeySystem_GetConfigurationString (MediaKeySystem *mediaKeySystem, const char *configName, char *value, int32_t valueLen)Obtains the value of a configuration item in the form of a string.
Drm_ErrCode OH_MediaKeySystem_SetConfigurationByteArray (MediaKeySystem *mediaKeySystem, const char *configName, uint8_t *value, int32_t valueLen)Sets a configuration item in the form of a byte array.
Drm_ErrCode OH_MediaKeySystem_GetConfigurationByteArray (MediaKeySystem *mediaKeySystem, const char *configName, uint8_t *value, int32_t *valueLen)Obtains the value of a configuration item in the form of a byte array.
Drm_ErrCode OH_MediaKeySystem_GetStatistics (MediaKeySystem *mediaKeySystem, DRM_Statistics *statistics)Obtains the statistical information of a media key system.
Drm_ErrCode OH_MediaKeySystem_GetMaxContentProtectionLevel (MediaKeySystem *mediaKeySystem, DRM_ContentProtectionLevel *contentProtectionLevel)Obtains the maximum content protection level supported by the current DRM solution.
Drm_ErrCode OH_MediaKeySystem_SetMediaKeySystemCallback (MediaKeySystem *mediaKeySystem, MediaKeySystem_Callback callback)Sets a media key system event callback.
Drm_ErrCode OH_MediaKeySystem_CreateMediaKeySession (MediaKeySystem *mediaKeySystem, DRM_ContentProtectionLevel *level, MediaKeySession **mediaKeySession)Creates a MediaKeySession instance.
Drm_ErrCode OH_MediaKeySystem_GenerateKeySystemRequest (MediaKeySystem *mediaKeySystem, uint8_t *request, int32_t *requestLen, char *defaultUrl, int32_t defaultUrlLen)Generates a provision request.
Drm_ErrCode OH_MediaKeySystem_ProcessKeySystemResponse (MediaKeySystem *mediaKeySystem, uint8_t *response, int32_t responseLen)Processes a provision response.
Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyIds (MediaKeySystem *mediaKeySystem, DRM_OfflineMediakeyIdArray *offlineMediaKeyIds)Obtains the IDs of offline media keys.
Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyStatus (MediaKeySystem *mediaKeySystem, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, DRM_OfflineMediaKeyStatus *status)Obtains the status of an offline media key.
Drm_ErrCode OH_MediaKeySystem_ClearOfflineMediaKeys (MediaKeySystem *mediaKeySystem, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen)Clears offline media keys.
Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus (MediaKeySystem *mediaKeySystem, DRM_CertificateStatus *certStatus)Obtains the status of a DRM certificate.
Drm_ErrCode OH_MediaKeySystem_Destroy (MediaKeySystem *mediaKeySystem)Destroys a MediaKeySystem instance.

Variables

NameDescription
DRM_MediaKeyType DRM_MediaKeyRequestInfo::typeType of the media key in a media key request.
int32_t DRM_MediaKeyRequestInfo::initDataLenInitial data length.
uint8_t DRM_MediaKeyRequestInfo::initData [MAX_INIT_DATA_LEN]Initial data.
char DRM_MediaKeyRequestInfo::mimeType [MAX_MIMETYPE_LEN]MIME type.
uint32_t DRM_MediaKeyRequestInfo::optionsCountNumber of optional data items.
char DRM_MediaKeyRequestInfo::optionName [MAX_MEDIA_KEY_REQUEST_OPTION_COUNT][MAX_MEDIA_KEY_REQUEST_OPTION_NAME_LEN]Array of optional data names.
char DRM_MediaKeyRequestInfo::optionData [MAX_MEDIA_KEY_REQUEST_OPTION_COUNT][MAX_MEDIA_KEY_REQUEST_OPTION_DATA_LEN]Array of optional data.
DRM_MediaKeyRequestType DRM_MediaKeyRequest::typeType of a media key request.
int32_t DRM_MediaKeyRequest::dataLenLength of data in a media key request.
uint8_t DRM_MediaKeyRequest::data [MAX_MEDIA_KEY_REQUEST_DATA_LEN]Data carried in a media key request.
char DRM_MediaKeyRequest::defaultUrl [MAX_DEFAULT_URL_LEN]DRM service URL.
uint32_t DRM_Statistics::statisticsCountNumber of statistical items.
char DRM_Statistics::statisticsName [MAX_STATISTICS_COUNT][MAX_STATISTICS_NAME_LEN]Array of statistical item names.
char DRM_Statistics::statisticsDescription [MAX_STATISTICS_COUNT][MAX_STATISTICS_BUFFER_LEN]Array of statistical descriptors.
uint32_t DRM_OfflineMediakeyIdArray::idsCountNumber of offline media key IDs.
int32_t DRM_OfflineMediakeyIdArray::idsLen [MAX_OFFLINE_MEDIA_KEY_ID_COUNT]Length of offline media key IDs.
uint8_t DRM_OfflineMediakeyIdArray::ids [MAX_OFFLINE_MEDIA_KEY_ID_COUNT][MAX_OFFLINE_MEDIA_KEY_ID_LEN]Array of offline media key IDs.
uint32_t DRM_KeysInfo::keysInfoCountNumber of media keys in the key information.
uint8_t DRM_KeysInfo::keyId [MAX_KEY_INFO_COUNT][MAX_KEY_ID_LEN]Array of offline media key IDs.
char DRM_KeysInfo::statusValue [MAX_KEY_INFO_COUNT][MAX_KEY_STATUS_VALUE_LEN]Media key status in the key information.
uint32_t DRM_MediaKeyStatus::statusCountNumber of media key statuses.
char DRM_MediaKeyStatus::statusName [MAX_MEDIA_KEY_STATUS_COUNT][MAX_MEDIA_KEY_STATUS_NAME_LEN]Array of media key status names.
char DRM_MediaKeyStatus::statusValue [MAX_MEDIA_KEY_STATUS_COUNT][MAX_MEDIA_KEY_STATUS_VALUE_LEN]Array of media key status values.
uint8_t DRM_PsshInfo::uuid [DRM_UUID_LEN]UUID of a DRM solution.
int32_t DRM_PsshInfo::dataLenLength of PSSH data.
uint8_t DRM_PsshInfo::data [MAX_PSSH_DATA_LEN]PSSH data.
uint32_t DRM_MediaKeySystemInfo::psshCountNumber of pieces of PSSH data.
DRM_PsshInfo DRM_MediaKeySystemInfo::psshInfo [MAX_PSSH_INFO_COUNT]PSSH data.
char DRM_MediaKeySystemDescription::name [MAX_MEDIA_KEY_SYSTEM_NAME_LEN]DRM solution name.
uint8_t DRM_MediaKeySystemDescription::uuid [DRM_UUID_LEN]UUID of a DRM solution.
MediaKeySession_EventCallback MediaKeySession_Callback::eventCallbackMedia key session event callback, for example, a media key expiry event.
MediaKeySession_KeyChangeCallback MediaKeySession_Callback::keyChangeCallbackCallback of the media key change event
OH_MediaKeySession_EventCallback OH_MediaKeySession_Callback::eventCallbackMedia key session event callback, for example, a media key expiry event.
OH_MediaKeySession_KeyChangeCallback OH_MediaKeySession_Callback::keyChangeCallbackCallback of the media key change event

Macro Description

DRM_UUID_LEN

#define DRM_UUID_LEN   16

Description

Length of the UUID of a DRM solution.

Since: 11

MAX_DEFAULT_URL_LEN

#define MAX_DEFAULT_URL_LEN   2048

Description

Maximum length of the URL of the DRM service.

Since: 11

MAX_INIT_DATA_LEN

#define MAX_INIT_DATA_LEN   2048

Description

Maximum length of data in an initial request.

Since: 11

MAX_KEY_ID_LEN

#define MAX_KEY_ID_LEN   16

Description

Maximum length of a media key ID.

Since: 11

MAX_KEY_INFO_COUNT

#define MAX_KEY_INFO_COUNT   64

Description

Maximum number of pieces of media key information.

Since: 11

MAX_KEY_STATUS_VALUE_LEN

#define MAX_KEY_STATUS_VALUE_LEN   128

Description

Maximum length of a media key status value.

Since: 11

MAX_MEDIA_KEY_REQUEST_DATA_LEN

#define MAX_MEDIA_KEY_REQUEST_DATA_LEN   8192

Description

Maximum length of a media key request.

Since: 11

MAX_MEDIA_KEY_REQUEST_OPTION_COUNT

#define MAX_MEDIA_KEY_REQUEST_OPTION_COUNT   16

Description

Maximum number of optional data items in a media key request.

Since: 11

MAX_MEDIA_KEY_REQUEST_OPTION_DATA_LEN

#define MAX_MEDIA_KEY_REQUEST_OPTION_DATA_LEN   128

Description

Maximum length of optional data in a media key request.

Since: 11

MAX_MEDIA_KEY_REQUEST_OPTION_NAME_LEN

#define MAX_MEDIA_KEY_REQUEST_OPTION_NAME_LEN   64

Description

Maximum length of an optional data name in a media key request.

Since: 11

MAX_MEDIA_KEY_STATUS_COUNT

#define MAX_MEDIA_KEY_STATUS_COUNT   64

Description

Maximum number of media key statuses.

Since: 11

MAX_MEDIA_KEY_STATUS_NAME_LEN

#define MAX_MEDIA_KEY_STATUS_NAME_LEN   64

Description

Maximum length of a media key status name.

Since: 11

MAX_MEDIA_KEY_STATUS_VALUE_LEN

#define MAX_MEDIA_KEY_STATUS_VALUE_LEN   256

Description

Maximum length of a media key status value.

Since: 11

MAX_MEDIA_KEY_SYSTEM_NAME_LEN

#define MAX_MEDIA_KEY_SYSTEM_NAME_LEN   128

Description

Maximum length of a DRM solution name.

Since: 12

MAX_MEDIA_KEY_SYSTEM_NUM

#define MAX_MEDIA_KEY_SYSTEM_NUM   8

Description

Maximum number of DRM solutions supported.

Since: 12

MAX_MIMETYPE_LEN

#define MAX_MIMETYPE_LEN   64

Description

Maximum length of a MIME type.

Since: 11

MAX_OFFLINE_MEDIA_KEY_ID_COUNT

#define MAX_OFFLINE_MEDIA_KEY_ID_COUNT   512

Description

Maximum number of offline media key IDs.

Since: 11

MAX_OFFLINE_MEDIA_KEY_ID_LEN

#define MAX_OFFLINE_MEDIA_KEY_ID_LEN   64

Description

Maximum length of an offline media key ID.

Since: 11

MAX_PSSH_DATA_LEN

#define MAX_PSSH_DATA_LEN   2048

Description

Maximum length of PSSH data.

Since: 11

MAX_PSSH_INFO_COUNT

#define MAX_PSSH_INFO_COUNT   8

Description

Maximum number of pieces of PSSH data.

Since: 11

MAX_STATISTICS_BUFFER_LEN

#define MAX_STATISTICS_BUFFER_LEN   256

Description

Maximum length of a statistical item buffer.

Since: 11

MAX_STATISTICS_COUNT

#define MAX_STATISTICS_COUNT   10

Description

Maximum number of statistical items.

Since: 11

MAX_STATISTICS_NAME_LEN

#define MAX_STATISTICS_NAME_LEN   64

Description

Maximum length of a statistical item name.

Since: 11

Type Description

DRM_CertificateStatus

typedef enum DRM_CertificateStatus DRM_CertificateStatus

Description

Defines an enum for the DRM certificate statuses.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

DRM_ContentProtectionLevel

typedef enum DRM_ContentProtectionLevel DRM_ContentProtectionLevel

Description

Defines an enum for the content protection levels.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

Drm_ErrCode

typedef enum Drm_ErrCode Drm_ErrCode

Description

Defines an enum for the DRM error codes.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

DRM_EventType

typedef enum DRM_EventType DRM_EventType

Description

Defines an enum for the types of events that can be subscribed to.

Since: 11

DRM_KeysInfo

typedef struct DRM_KeysInfo DRM_KeysInfo

Description

Defines a struct for the information about media keys.

Since: 11

DRM_MediaKeyRequest

typedef struct DRM_MediaKeyRequest DRM_MediaKeyRequest

Description

Defines a struct for a media key request.

Since: 11

DRM_MediaKeyRequestInfo

typedef struct DRM_MediaKeyRequestInfo DRM_MediaKeyRequestInfo

Description

Defines a struct for the information about a media key request.

Since: 11

DRM_MediaKeyRequestType

typedef enum DRM_MediaKeyRequestType DRM_MediaKeyRequestType

Description

Defines an enum for the types of media key requests.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

DRM_MediaKeyStatus

typedef struct DRM_MediaKeyStatus DRM_MediaKeyStatus

Description

Defines a struct for the media key status.

Since: 11

DRM_MediaKeySystemDescription

typedef struct DRM_MediaKeySystemDescription DRM_MediaKeySystemDescription

Description

Defines a struct for the name and UUID of a DRM solution.

Since: 12

DRM_MediaKeySystemInfo

typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo

Description

Defines a struct for the DRM information obtained by the player from a media source.

Since: 11

DRM_MediaKeySystemInfoCallback

typedef void(* DRM_MediaKeySystemInfoCallback) (DRM_MediaKeySystemInfo *mediaKeySystemInfo)

Description

Defines the callback used to obtain DRM information from a media source.

Since: 11

Parameters

NameDescription
mediaKeySystemInfoPointer to the DRM information obtained from the media source.

DRM_MediaKeyType

typedef enum DRM_MediaKeyType DRM_MediaKeyType

Description

Defines an enum for the types of media keys.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

DRM_OfflineMediakeyIdArray

typedef struct DRM_OfflineMediakeyIdArray DRM_OfflineMediakeyIdArray

Description

Defines a struct for an array holding the IDs of offline media keys.

Since: 11

DRM_OfflineMediaKeyStatus

typedef enum DRM_OfflineMediaKeyStatus DRM_OfflineMediaKeyStatus

Description

Defines an enum for the statuses of offline media keys.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

DRM_PsshInfo

typedef struct DRM_PsshInfo DRM_PsshInfo

Description

Defines a struct for the PSSH data that contains the UUID of a DRM solution.

Since: 11

DRM_Statistics

typedef struct DRM_Statistics DRM_Statistics

Description

Defines a struct for the statistical information of a media key system.

Since: 11

MediaKeySession

typedef struct MediaKeySession MediaKeySession

Description

Defines a struct for a media key session.

Since: 11

MediaKeySession_Callback

typedef struct MediaKeySession_Callback MediaKeySession_Callback

Description

Defines the callback used to listen for events such as media key expiry, without returning media key session instances. It applies to the scenario where a single media key session needs to be decrypted.

Since: 11

MediaKeySession_EventCallback

typedef Drm_ErrCode(* MediaKeySession_EventCallback) (DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra)

Description

Defines the callback used to listen for media key session events, for example, a key expiration event.

Since: 11

Parameters

NameDescription
eventTypeEvent type.
infoPointer to the event information obtained from the media key session.
infoLenLength of the event information.
extraPointer to the additional information obtained from the media key session.

Returns

Returns an error code defined in Drm_ErrCode.

MediaKeySession_KeyChangeCallback

typedef Drm_ErrCode(* MediaKeySession_KeyChangeCallback) (DRM_KeysInfo *keysInfo, bool newKeysAvailable)

Description

Defines the callback that is invoked when the key is changed.

Since: 11

Parameters

NameDescription
keysInfoPointer to the media key information.
newKeysAvailableWhether the new key is available.

Returns

Returns DRM_ERR_OK is the call is successful; returns DRM_ERR_INVALID_VAL if the parameter check fails.

MediaKeySystem

typedef struct MediaKeySystem MediaKeySystem

Description

Defines a struct for a media key system.

Since: 11

MediaKeySystem_Callback

typedef Drm_ErrCode(* MediaKeySystem_Callback) (DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra)

Description

Defines the callback used to listen for media key system events. No MediaKeySystem instance is returned. This callback applies to the scenario where a single MediaKeySystem instance is used.

Since: 11

Parameters

NameDescription
eventTypeEvent type.
infoPointer to the event information.
infoLenLength of the event information.
extraPointer to extended event information.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: An input parameter is invalid.

OH_MediaKeySession_Callback

typedef struct OH_MediaKeySession_CallbackOH_MediaKeySession_Callback

Description

Defines the callback used to listen for events such as media key expiry, with media key session instances returned. It applies to the scenario where multiple media key sessions need to be decrypted.

Since: 12

OH_MediaKeySession_EventCallback

typedef Drm_ErrCode(* OH_MediaKeySession_EventCallback) (MediaKeySession *mediaKeySession, DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra)

Description

Defines the callback that is invoked when a media key system event is triggered.

Since: 12

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
eventTypeEvent type.
infoPointer to the event information.
infoLenLength of the event information.
extraPointer to extended event information.

Returns

Returns an error code defined in Drm_ErrCode.

OH_MediaKeySession_KeyChangeCallback

typedef Drm_ErrCode(* OH_MediaKeySession_KeyChangeCallback) (MediaKeySession *mediaKeySession, DRM_KeysInfo *keysInfo, bool newKeysAvailable)

Description

Defines the callback that is invoked when the key is changed.

Since: 12

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
keysInfoPointer to the media key information.
newKeysAvailableWhether the new keys are available. The value true means that the new keys are available, and false means the opposite.

Returns

Returns DRM_ERR_OK is the call is successful; returns DRM_ERR_INVALID_VAL if the parameter check fails.

OH_MediaKeySystem_Callback

typedef Drm_ErrCode(* OH_MediaKeySystem_Callback) (MediaKeySystem *mediaKeySystem, DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra)

Description

Defines the callback used to listen for media key system events. A MediaKeySystem instance is returned. This callback applies to the scenario where multiple MediaKeySystem instances are used.

Since: 12

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
eventTypeEvent type.
infoPointer to the event information.
infoLenLength of the event information.
extraPointer to extended event information.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: An input parameter is invalid.

Enum Description

DRM_CertificateStatus

enum DRM_CertificateStatus

Description

Enumerates the DRM certificate statuses.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

ValueDescription
CERT_STATUS_PROVISIONEDA DRM certificate has been installed on the device.
CERT_STATUS_NOT_PROVISIONEDNo device certificate is installed on the device or the certificate status is abnormal.
CERT_STATUS_EXPIREDThe DRM certificate has expired.
CERT_STATUS_INVALIDThe DRM certificate is invalid.
CERT_STATUS_UNAVAILABLEThe DRM certificate is unavailable.

DRM_ContentProtectionLevel

enum DRM_ContentProtectionLevel

Description

Enumerates the content protection levels.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

ValueDescription
CONTENT_PROTECTION_LEVEL_UNKNOWNUnknown/Default content protection level.
CONTENT_PROTECTION_LEVEL_SW_CRYPTOSoftware content protection level.
CONTENT_PROTECTION_LEVEL_HW_CRYPTOHardware content protection level.
CONTENT_PROTECTION_LEVEL_ENHANCED_HW_CRYPTOHardware enhancement level.
CONTENT_PROTECTION_LEVEL_MAXHighest content protection level.

Drm_ErrCode

enum Drm_ErrCode

Description

Enumerates the DRM error codes.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

ValueDescription
DRM_ERR_OKOperation successful.
DRM_CAPI_ERR_BASEBasic error.
DRM_ERR_NO_MEMORYInsufficient memory.
DRM_ERR_OPERATION_NOT_PERMITTEDOperation not allowed.
DRM_ERR_INVALID_VALInvalid parameters.
DRM_ERR_IOI/O error.
DRM_ERR_TIMEOUTNetwork timeout.
DRM_ERR_UNKNOWNUnknown error.
DRM_ERR_SERVICE_DIEDDRM service error.
DRM_ERR_INVALID_STATEInvalid operation status.
DRM_ERR_UNSUPPORTEDUnsupported operation.
DRM_ERR_MAX_SYSTEM_NUM_REACHEDToo many MediaKeySystem instances.
DRM_ERR_MAX_SESSION_NUM_REACHEDToo many MediaKeySession instances.
DRM_ERR_EXTEND_STARTExtended error.

DRM_EventType

enum DRM_EventType

Description

Enumerates the types of events that can be subscribed to.

Since: 11

ValueDescription
EVENT_DRM_BASEDRM event.
EVENT_PROVISION_REQUIREDEvent indicating that the application needs to request a DRM certificate.
EVENT_KEY_REQUIREDEvent indicating that the application needs to request a media key.
EVENT_KEY_EXPIREDEvent indicating that the media key expires.
EVENT_VENDOR_DEFINEDVendor-defined event.
EVENT_EXPIRATION_UPDATEEvent indicating that the media key updates on expiry.

DRM_MediaKeyRequestType

enum DRM_MediaKeyRequestType

Description

Enumerates the types of media key requests.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

ValueDescription
MEDIA_KEY_REQUEST_TYPE_UNKNOWNUnknown type.
MEDIA_KEY_REQUEST_TYPE_INITIALInitial request.
MEDIA_KEY_REQUEST_TYPE_RENEWALRenewal request.
MEDIA_KEY_REQUEST_TYPE_RELEASERelease request.
MEDIA_KEY_REQUEST_TYPE_NONENone.
MEDIA_KEY_REQUEST_TYPE_UPDATEUpdate request.

DRM_MediaKeyType

enum DRM_MediaKeyType

Description

Enumerates the types of media keys.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

ValueDescription
MEDIA_KEY_TYPE_OFFLINEOffline.
MEDIA_KEY_TYPE_ONLINEOnline.

DRM_OfflineMediaKeyStatus

enum DRM_OfflineMediaKeyStatus

Description

Enumerates the statuses of offline media keys.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

ValueDescription
OFFLINE_MEDIA_KEY_STATUS_UNKNOWNUnknown status.
OFFLINE_MEDIA_KEY_STATUS_USABLEThe media key is available.
OFFLINE_MEDIA_KEY_STATUS_INACTIVEThe media key is inactive.

Function Description

OH_MediaKeySession_CheckMediaKeyStatus()

Drm_ErrCode OH_MediaKeySession_CheckMediaKeyStatus (MediaKeySession *mediaKeySession, DRM_MediaKeyStatus *mediaKeyStatus)

Description

Checks the status of media keys.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
mediaKeyStatusPointer to the media key status obtained.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of mediaKeyStatus is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySession_ClearMediaKeys()

Drm_ErrCode OH_MediaKeySession_ClearMediaKeys (MediaKeySession *mediaKeySession)

Description

Clears media keys.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySession_Destroy()

Drm_ErrCode OH_MediaKeySession_Destroy (MediaKeySession *mediaKeySession)

Description

Destroys a MediaKeySession instance.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySession_GenerateMediaKeyRequest()

Drm_ErrCode OH_MediaKeySession_GenerateMediaKeyRequest (MediaKeySession *mediaKeySession, DRM_MediaKeyRequestInfo *info, DRM_MediaKeyRequest *mediaKeyRequest)

Description

Generates a media key request.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
infoPointer to the information about the media key request.
mediaKeyRequestPointer to the media key request.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of info or mediaKeyRequest is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySession_GenerateOfflineReleaseRequest()

Drm_ErrCode OH_MediaKeySession_GenerateOfflineReleaseRequest (MediaKeySession *mediaKeySession, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, uint8_t *releaseRequest, int32_t *releaseRequestLen)

Description

Generates a request to release offline media keys.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
offlineMediaKeyIdPointer to the ID of an offline media key.
offlineMediaKeyIdLenLength of the offline media key ID.
releaseRequestPointer to a request to release offline media keys.
releaseRequestLenLength of the request to release offline media keys.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of another parameter of the pointer type is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs or the DRM solution on the device does not support offline media key release. Check the log details.

OH_MediaKeySession_GetContentProtectionLevel()

Drm_ErrCode OH_MediaKeySession_GetContentProtectionLevel (MediaKeySession *mediaKeySession, DRM_ContentProtectionLevel *contentProtectionLevel)

Description

Obtains the content protection level of a media key session.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
contentProtectionLevelPointer to the content protection level.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of contentProtectionLevel is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySession_ProcessMediaKeyResponse()

Drm_ErrCode OH_MediaKeySession_ProcessMediaKeyResponse (MediaKeySession *mediaKeySession, uint8_t *response, int32_t responseLen, uint8_t *offlineMediaKeyId, int32_t *offlineMediaKeyIdLen)

Description

Processes a media key response.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
responsePointer to a media key response.
responseLenPointer to the length of the media key response.
offlineMediaKeyIdPointer to the ID of an offline media key.
offlineMediaKeyIdLenLength of the offline media key ID.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of another parameter of the pointer type is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySession_ProcessOfflineReleaseResponse()

Drm_ErrCode OH_MediaKeySession_ProcessOfflineReleaseResponse (MediaKeySession *mediaKeySession, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, uint8_t *releaseReponse, int32_t releaseReponseLen)

Description

Processes a response to a request for releasing offline media keys.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
offlineMediaKeyIdPointer to the ID of an offline media key.
offlineMediaKeyIdLenLength of the offline media key ID.
releaseReponsePointer to the response.
releaseReponseLenLength of the response.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of another parameter of the pointer type is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs or the DRM solution on the device does not support offline media key release. Check the log details.

OH_MediaKeySession_RequireSecureDecoderModule()

Drm_ErrCode OH_MediaKeySession_RequireSecureDecoderModule (MediaKeySession *mediaKeySession, const char *mimeType, bool *status)

Description

Checks whether secure decoding is required.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
mimeTypePointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev.
statusPointer to the result indicating whether secure decoding is required.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of another parameter of the pointer type is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySession_RestoreOfflineMediaKeys()

Drm_ErrCode OH_MediaKeySession_RestoreOfflineMediaKeys (MediaKeySession *mediaKeySession, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen)

Description

Restores offline media keys.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
offlineMediaKeyIdPointer to the ID of an offline media key.
offlineMediaKeyIdLenLength of the offline media key ID.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of another parameter of the pointer type is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySession_SetCallback()

Drm_ErrCode OH_MediaKeySession_SetCallback (MediaKeySession *mediaKeySession, OH_MediaKeySession_Callback *callback)

Description

Sets a media key session event callback.

Since: 12

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
callbackPointer to the callback for the media key session event.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of callback is a null pointer.

OH_MediaKeySession_SetMediaKeySessionCallback()

Drm_ErrCode OH_MediaKeySession_SetMediaKeySessionCallback (MediaKeySession *mediaKeySession, MediaKeySession_Callback *callback)

Description

Sets a media key session event callback.

Since: 11

Parameters

NameDescription
mediaKeySessionPointer to the MediaKeySession instance.
callbackPointer to the callback for the media key session event.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySession is a null pointer or invalid, or the value of callback is a null pointer.

OH_MediaKeySystem_ClearOfflineMediaKeys()

Drm_ErrCode OH_MediaKeySystem_ClearOfflineMediaKeys (MediaKeySystem *mediaKeySystem, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen)

Description

Clears offline media keys by ID.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
offlineMediaKeyIdPointer to the ID of an offline media key.
offlineMediaKeyIdLenLength of the offline media key ID.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of offlineMediaKeyId is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_Create()

Drm_ErrCode OH_MediaKeySystem_Create (const char *name, MediaKeySystem **mediaKeySystem)

Description

Creates a MediaKeySystem instance.

Since: 11

Parameters

NameDescription
namePointer to the DRM solution name.
mediaKeySystemDouble pointer to the MediaKeySystem instance.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of name is a null pointer or its length is 0, or the value of mediaKeySystem is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.
  • DRM_ERR_SERVICE_DIED: The service is dead.
  • DRM_ERR_MAX_SYSTEM_NUM_REACHED: The number of created MediaKeySystem instances has reached the upper limit (64).

OH_MediaKeySystem_CreateMediaKeySession()

Drm_ErrCode OH_MediaKeySystem_CreateMediaKeySession (MediaKeySystem *mediaKeySystem, DRM_ContentProtectionLevel *level, MediaKeySession **mediaKeySession)

Description

Creates a MediaKeySession instance.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
levelPointer to the content protection level.
mediaKeySessionDouble pointer to the MediaKeySession instance created.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, the value of level is out of range, or the value of mediaKeySession is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.
  • DRM_ERR_SERVICE_DIED: The service is dead.
  • DRM_ERR_MAX_SESSION_NUM_REACHED: The number of MediaKeySession instances created by the MediaKeySystem instance reaches the upper limit (64).

OH_MediaKeySystem_Destroy()

Drm_ErrCode OH_MediaKeySystem_Destroy (MediaKeySystem *mediaKeySystem)

Description

Destroys a MediaKeySystem instance.

Since: 11

Parameters

NameDescription
mediaKeySystemDouble pointer to the MediaKeySystem instance created.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GenerateKeySystemRequest()

Drm_ErrCode OH_MediaKeySystem_GenerateKeySystemRequest (MediaKeySystem *mediaKeySystem, uint8_t *request, int32_t *requestLen, char *defaultUrl, int32_t defaultUrlLen)

Description

Generates a provision request.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
requestPointer to the provision request, which is used to request a DRM certificate from a provisioning server.
requestLenPointer to the length of the provision request.
defaultUrlPointer to the URL of the provisioning server.
defaultUrlLenLength of the URL of the provisioning server.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of another parameter of the pointer type is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GetCertificateStatus()

Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus (MediaKeySystem *mediaKeySystem, DRM_CertificateStatus *certStatus)

Description

Obtains the status of a DRM certificate.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
certStatusPointer to the DRM certificate status.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of certStatus is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GetConfigurationByteArray()

Drm_ErrCode OH_MediaKeySystem_GetConfigurationByteArray (MediaKeySystem *mediaKeySystem, const char *configName, uint8_t *value, int32_t *valueLen)

Description

Obtains the value of a configuration item in the form of an array.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
configNamePointer to the name of the configuration item in the form of a character array. It is determined by the DRM solution on the device and cannot be empty.
valuePointer to the value of the configuration item.
valueLenPointer to the length of the value.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of configName, value, or valueLen is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GetConfigurationString()

Drm_ErrCode OH_MediaKeySystem_GetConfigurationString (MediaKeySystem *mediaKeySystem, const char *configName, char *value, int32_t valueLen)

Description

Obtains the value of a configuration item in the form of a string.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
configNamePointer to the name of the configuration item.
valuePointer to the value of the configuration item.
valueLenLength of the value.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of configName or value is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GetMaxContentProtectionLevel()

Drm_ErrCode OH_MediaKeySystem_GetMaxContentProtectionLevel (MediaKeySystem *mediaKeySystem, DRM_ContentProtectionLevel *contentProtectionLevel)

Description

Obtains the maximum content protection level supported by the device.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
contentProtectionLevelPointer to the content protection level.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of contentProtectionLevel is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GetMediaKeySystems()

Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems (DRM_MediaKeySystemDescription *infos, uint32_t *count)

Description

Obtains the name and ID list of the DRM solutions supported by the device.

Since: 12

Parameters

NameDescription
infosPointer to the list of the names and UUIDs of DRM solutions.
countPointer to the length of the list.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of infos or count is a null pointer, or the length of infos is insufficient.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GetOfflineMediaKeyIds()

Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyIds (MediaKeySystem *mediaKeySystem, DRM_OfflineMediakeyIdArray *offlineMediaKeyIds)

Description

Obtains the list of offline media key IDs, which are used to manage offline media keys.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
offlineMediaKeyIdsPointer to the IDs of offline media keys.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of offlineMediaKeyIds is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GetOfflineMediaKeyStatus()

Drm_ErrCode OH_MediaKeySystem_GetOfflineMediaKeyStatus (MediaKeySystem *mediaKeySystem, uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, DRM_OfflineMediaKeyStatus *status)

Description

Obtains the status of an offline media key.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
offlineMediaKeyIdPointer to the ID of an offline media key.
offlineMediaKeyIdLenLength of the offline media key ID.
statusPointer to the media key status obtained.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of another parameter of the pointer type is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_GetStatistics()

Drm_ErrCode OH_MediaKeySystem_GetStatistics (MediaKeySystem *mediaKeySystem, DRM_Statistics *statistics)

Description

Obtains the statistical information of a media key system.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
statisticsPointer to the statistical information.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of statistics is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_IsSupported()

bool OH_MediaKeySystem_IsSupported (const char *name)

Description

Checks whether the device supports the specified DRM solution.

Since: 11

Parameters

NameDescription
namePointer to the DRM solution name.

Returns

Returns true if the device supports the DRM solution; returns false otherwise.

OH_MediaKeySystem_IsSupported2()

bool OH_MediaKeySystem_IsSupported2 (const char *name, const char *mimeType)

Description

Checks whether the device supports the combination of the specified DRM solution and MIME type.

Since: 11

Parameters

NameDescription
namePointer to the DRM solution name.
mimeTypePointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev.

Returns

Returns true if the device supports the combination; returns false otherwise.

OH_MediaKeySystem_IsSupported3()

bool OH_MediaKeySystem_IsSupported3 (const char *name, const char *mimeType, DRM_ContentProtectionLevel contentProtectionLevel)

Description

Checks whether the device supports the combination of the specified DRM solution, MIME type, and content protection level.

Since: 11

Parameters

NameDescription
namePointer to the DRM solution name.
mimeTypePointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev.
contentProtectionLevelContent protection level.

Returns

Returns true if the device supports the combination; returns false otherwise.

OH_MediaKeySystem_ProcessKeySystemResponse()

Drm_ErrCode OH_MediaKeySystem_ProcessKeySystemResponse (MediaKeySystem *mediaKeySystem, uint8_t *response, int32_t responseLen)

Description

Processes a provision response.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
responsePointer to the provision response.
responseLenLength of the provision response.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of response is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_SetCallback()

Drm_ErrCode OH_MediaKeySystem_SetCallback (MediaKeySystem *mediaKeySystem, OH_MediaKeySystem_Callback callback)

Description

Sets a media key system event callback.

Since: 12

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
callbackCallback.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: An input parameter is invalid.

OH_MediaKeySystem_SetConfigurationByteArray()

Drm_ErrCode OH_MediaKeySystem_SetConfigurationByteArray (MediaKeySystem *mediaKeySystem, const char *configName, uint8_t *value, int32_t valueLen)

Description

Sets a configuration item in the form of an array.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
configNamePointer to the name of the configuration item in the form of a character array. It is determined by the DRM solution on the device and cannot be empty.
valuePointer to the value of the configuration item in the form of a character array. It is determined by the DRM solution on the device and cannot be empty.
valueLenLength of the value.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_NO_MEMORY: The memory fails to be allocated due to insufficient memory.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of configName or value is a null pointer.
  • DRM_ERR_UNKNOWN: An internal error occurs. Check the log details.

OH_MediaKeySystem_SetConfigurationString()

Drm_ErrCode OH_MediaKeySystem_SetConfigurationString (MediaKeySystem *mediaKeySystem, const char *configName, const char *value)

Description

Sets a configuration item in the form of a string.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
configNamePointer to the name of the configuration item in the form of a string. It is determined by the DRM solution on the device and cannot be empty.
valuePointer to the value of the configuration item in the form of a string. It is determined by the DRM solution on the device and cannot be empty.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid, or the value of configName or value is a null pointer.

OH_MediaKeySystem_SetMediaKeySystemCallback()

Drm_ErrCode OH_MediaKeySystem_SetMediaKeySystemCallback (MediaKeySystem *mediaKeySystem, MediaKeySystem_Callback callback)

Description

Sets a media key system event callback.

Since: 11

Parameters

NameDescription
mediaKeySystemPointer to the MediaKeySystem instance.
callbackCallback.

Returns

Returns a result code defined in Drm_ErrCode.

  • DRM_ERR_OK: The operation is successful.
  • DRM_ERR_INVALID_VAL: The value of mediaKeySystem is a null pointer or invalid.

Variable Description

data [1/2]

uint8_t DRM_MediaKeyRequest::data[MAX_MEDIA_KEY_REQUEST_DATA_LEN]

Description

Data in a media key request sent to the DRM service.

data [2/2]

uint8_t DRM_PsshInfo::data[MAX_PSSH_DATA_LEN]

Description

PSSH data.

dataLen [1/2]

int32_t DRM_MediaKeyRequest::dataLen

Description

Length of data in a media key request.

dataLen [2/2]

int32_t DRM_PsshInfo::dataLen

Description

Length of PSSH data.

defaultUrl

char DRM_MediaKeyRequest::defaultUrl[MAX_DEFAULT_URL_LEN]

Description

URL of the license server (which provisions media keys).

eventCallback [1/2]

MediaKeySession_EventCallback MediaKeySession_Callback::eventCallback

Description

Media key session event callback, for example, a media key expiry event.

eventCallback [2/2]

OH_MediaKeySession_EventCallback OH_MediaKeySession_Callback::eventCallback

Description

Media key session event callback, for example, a media key expiry event.

ids

uint8_t DRM_OfflineMediakeyIdArray::ids[MAX_OFFLINE_MEDIA_KEY_ID_COUNT][MAX_OFFLINE_MEDIA_KEY_ID_LEN]

Description

Array of offline media key IDs.

idsCount

uint32_t DRM_OfflineMediakeyIdArray::idsCount

Description

Number of offline media key IDs.

idsLen

int32_t DRM_OfflineMediakeyIdArray::idsLen[MAX_OFFLINE_MEDIA_KEY_ID_COUNT]

Description

Length of offline media key IDs.

initData

uint8_t DRM_MediaKeyRequestInfo::initData[MAX_INIT_DATA_LEN]

Description

Initial data in a media key request.

initDataLen

int32_t DRM_MediaKeyRequestInfo::initDataLen

Description

Length of the initial data in a media key request.

keyChangeCallback [1/2]

MediaKeySession_KeyChangeCallback MediaKeySession_Callback::keyChangeCallback

Description

Key change callback.

keyChangeCallback [2/2]

OH_MediaKeySession_KeyChangeCallback OH_MediaKeySession_Callback::keyChangeCallback

Description

Key change callback.

keyId

uint8_t DRM_KeysInfo::keyId[MAX_KEY_INFO_COUNT][MAX_KEY_ID_LEN]

Description

Media key ID array.

keysInfoCount

uint32_t DRM_KeysInfo::keysInfoCount

Description

Number of media keys.

mimeType

char DRM_MediaKeyRequestInfo::mimeType[MAX_MIMETYPE_LEN]

Description

Media key type.

name

char DRM_MediaKeySystemDescription::name[MAX_MEDIA_KEY_SYSTEM_NAME_LEN]

Description DRM solution name.

optionData

char DRM_MediaKeyRequestInfo::optionData[MAX_MEDIA_KEY_REQUEST_OPTION_COUNT][MAX_MEDIA_KEY_REQUEST_OPTION_DATA_LEN]

Description

Optional data set.

optionName

char DRM_MediaKeyRequestInfo::optionName[MAX_MEDIA_KEY_REQUEST_OPTION_COUNT][MAX_MEDIA_KEY_REQUEST_OPTION_NAME_LEN]

Description

Optional data name set.

optionsCount

uint32_t DRM_MediaKeyRequestInfo::optionsCount

Description

Number of optional data items.

psshCount

uint32_t DRM_MediaKeySystemInfo::psshCount

Description

Number of pieces of PSSH data in DRM information.

psshInfo

DRM_PsshInfo DRM_MediaKeySystemInfo::psshInfo[MAX_PSSH_INFO_COUNT]

Description

Array of PSSH data in DRM information.

statisticsCount

uint32_t DRM_Statistics::statisticsCount

Description

Number of statistical items.

statisticsDescription

char DRM_Statistics::statisticsDescription[MAX_STATISTICS_COUNT][MAX_STATISTICS_BUFFER_LEN]

Description

Statistical information set.

statisticsName

char DRM_Statistics::statisticsName[MAX_STATISTICS_COUNT][MAX_STATISTICS_NAME_LEN]

Description

Statistical item name set.

statusCount

uint32_t DRM_MediaKeyStatus::statusCount

Description

Length of the media key status array.

statusName

char DRM_MediaKeyStatus::statusName[MAX_MEDIA_KEY_STATUS_COUNT][MAX_MEDIA_KEY_STATUS_NAME_LEN]

Description

Array of media key status names.

statusValue [1/2]

char DRM_KeysInfo::statusValue[MAX_KEY_INFO_COUNT][MAX_KEY_STATUS_VALUE_LEN]

Description

Array of media key status values in the media key information.

statusValue [2/2]

char DRM_MediaKeyStatus::statusValue[MAX_MEDIA_KEY_STATUS_COUNT][MAX_MEDIA_KEY_STATUS_VALUE_LEN]

Description

Array of media key status values in a media key session.

type [1/2]

DRM_MediaKeyType DRM_MediaKeyRequestInfo::type

Description

Media key type, which can be online or offline, in a media key request.

type [2/2]

DRM_MediaKeyRequestType DRM_MediaKeyRequest::type

Description

Type of a media key request.

uuid [1/2]

uint8_t DRM_PsshInfo::uuid[DRM_UUID_LEN]

Description UUID of a DRM solution in PSSH data.

uuid [2/2]

uint8_t DRM_MediaKeySystemDescription::uuid[DRM_UUID_LEN]

Description UUID of a DRM solution supported by the device.

你可能感兴趣的鸿蒙文章

harmony 鸿蒙DRM Kit

harmony 鸿蒙DRM_KeysInfo

harmony 鸿蒙DRM_MediaKeyRequest

harmony 鸿蒙DRM_MediaKeyRequestInfo

harmony 鸿蒙DRM_MediaKeyStatus

harmony 鸿蒙DRM_MediaKeySystemDescription

harmony 鸿蒙DRM_MediaKeySystemInfo

harmony 鸿蒙DRM_OfflineMediakeyIdArray

harmony 鸿蒙DRM_PsshInfo

harmony 鸿蒙DRM_Statistics

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/rMayqz