harmony 鸿蒙Drm

  • 2025-06-12
  • 浏览 (5)

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

Name Description
native_drm_common.h Declares the DRM data types.
native_drm_err.h Declares the DRM error codes.
native_mediakeysession.h Declares the MediaKeySession APIs.
native_mediakeysystem.h Declares the MediaKeySystem APIs.

Structs

Name Description
struct DRM_MediaKeyRequestInfo Describes the information about a media key request.
struct DRM_MediaKeyRequest Describes a media key request.
struct DRM_Statistics Describes the statistical information of a media key system.
struct DRM_OfflineMediakeyIdArray Describes an array holding the IDs of offline media keys.
struct DRM_KeysInfo Describes the information about media keys.
struct DRM_MediaKeyStatus Describes the media key status.
struct DRM_PsshInfo Describes the Protection System Specific Header (PSSH) in DRM information.
struct DRM_MediaKeySystemInfo Describes the DRM information, which is used to encrypt content.
struct MediaKeySession_Callback Describes 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_Callback Describes 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_MediaKeySystemDescription Describes the DRM solution name and UUID list.

Macros

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

Types

Name Description
typedef enum DRM_EventType DRM_EventType Defines an enum for the types of events that can be subscribed to.
typedef enum DRM_ContentProtectionLevel DRM_ContentProtectionLevel Defines an enum for the content protection levels.
typedef enum DRM_MediaKeyType DRM_MediaKeyType Defines an enum for the types of media keys.
typedef enum DRM_MediaKeyRequestType DRM_MediaKeyRequestType Defines an enum for the types of media key requests.
typedef enum DRM_OfflineMediaKeyStatus DRM_OfflineMediaKeyStatus Defines an enum for the statuses of offline media keys.
typedef enum DRM_CertificateStatus DRM_CertificateStatus Defines an enum for the DRM certificate statuses.
typedef struct DRM_MediaKeyRequestInfo DRM_MediaKeyRequestInfo Defines a struct for the information about a media key request.
typedef struct DRM_MediaKeyRequest DRM_MediaKeyRequest Defines a struct for a media key request.
typedef struct DRM_Statistics DRM_Statistics Defines a struct for the statistical information of a media key system.
typedef struct DRM_OfflineMediakeyIdArray DRM_OfflineMediakeyIdArray Defines a struct for the array holding the IDs of offline media keys.
typedef struct DRM_KeysInfo DRM_KeysInfo Defines a struct for the information about media keys.
typedef struct DRM_MediaKeyStatus DRM_MediaKeyStatus Defines a struct for the media key status.
typedef struct DRM_PsshInfo DRM_PsshInfo Defines a struct for PSSH data in DRM information.
typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo Defines a struct for the DRM information, which is used to encrypt content.
typedef struct DRM_MediaKeySystemDescription DRM_MediaKeySystemDescription Defines 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 MediaKeySystem Defines a struct for a media key system.
typedef struct MediaKeySession MediaKeySession Defines a struct for a media key session.
typedef enum Drm_ErrCode Drm_ErrCode Defines 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_Callback Defines 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_Callback Defines 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

Name Description
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

Name Description
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

Name Description
DRM_MediaKeyType DRM_MediaKeyRequestInfo::type Type of the media key in a media key request.
int32_t DRM_MediaKeyRequestInfo::initDataLen Initial 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::optionsCount Number 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::type Type of a media key request.
int32_t DRM_MediaKeyRequest::dataLen Length 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::statisticsCount Number 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::idsCount Number 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::keysInfoCount Number 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::statusCount Number 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::dataLen Length of PSSH data.
uint8_t DRM_PsshInfo::data [MAX_PSSH_DATA_LEN] PSSH data.
uint32_t DRM_MediaKeySystemInfo::psshCount Number 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::eventCallback Media key session event callback, for example, a media key expiry event.
MediaKeySession_KeyChangeCallback MediaKeySession_Callback::keyChangeCallback Callback of the media key change event
OH_MediaKeySession_EventCallback OH_MediaKeySession_Callback::eventCallback Media key session event callback, for example, a media key expiry event.
OH_MediaKeySession_KeyChangeCallback OH_MediaKeySession_Callback::keyChangeCallback Callback 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

Name Description
mediaKeySystemInfo Pointer 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

Name Description
eventType Event type.
info Pointer to the event information obtained from the media key session.
infoLen Length of the event information.
extra Pointer 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

Name Description
keysInfo Pointer to the media key information.
newKeysAvailable Whether 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

Name Description
eventType Event type.
info Pointer to the event information.
infoLen Length of the event information.
extra Pointer 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
eventType Event type.
info Pointer to the event information.
infoLen Length of the event information.
extra Pointer 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
keysInfo Pointer to the media key information.
newKeysAvailable Whether 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
eventType Event type.
info Pointer to the event information.
infoLen Length of the event information.
extra Pointer 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

Value Description
CERT_STATUS_PROVISIONED A DRM certificate has been installed on the device.
CERT_STATUS_NOT_PROVISIONED No device certificate is installed on the device or the certificate status is abnormal.
CERT_STATUS_EXPIRED The DRM certificate has expired.
CERT_STATUS_INVALID The DRM certificate is invalid.
CERT_STATUS_UNAVAILABLE The DRM certificate is unavailable.

DRM_ContentProtectionLevel

enum DRM_ContentProtectionLevel

Description

Enumerates the content protection levels.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

Value Description
CONTENT_PROTECTION_LEVEL_UNKNOWN Unknown/Default content protection level.
CONTENT_PROTECTION_LEVEL_SW_CRYPTO Software content protection level.
CONTENT_PROTECTION_LEVEL_HW_CRYPTO Hardware content protection level.
CONTENT_PROTECTION_LEVEL_ENHANCED_HW_CRYPTO Hardware enhancement level.
CONTENT_PROTECTION_LEVEL_MAX Highest content protection level.

Drm_ErrCode

enum Drm_ErrCode

Description

Enumerates the DRM error codes.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

Value Description
DRM_ERR_OK Operation successful.
DRM_CAPI_ERR_BASE Basic error.
DRM_ERR_NO_MEMORY Insufficient memory.
DRM_ERR_OPERATION_NOT_PERMITTED Operation not allowed.
DRM_ERR_INVALID_VAL Invalid parameters.
DRM_ERR_IO I/O error.
DRM_ERR_TIMEOUT Network timeout.
DRM_ERR_UNKNOWN Unknown error.
DRM_ERR_SERVICE_DIED DRM service error.
DRM_ERR_INVALID_STATE Invalid operation status.
DRM_ERR_UNSUPPORTED Unsupported operation.
DRM_ERR_MAX_SYSTEM_NUM_REACHED Too many MediaKeySystem instances.
DRM_ERR_MAX_SESSION_NUM_REACHED Too many MediaKeySession instances.
DRM_ERR_EXTEND_START Extended error.

DRM_EventType

enum DRM_EventType

Description

Enumerates the types of events that can be subscribed to.

Since: 11

Value Description
EVENT_DRM_BASE DRM event.
EVENT_PROVISION_REQUIRED Event indicating that the application needs to request a DRM certificate.
EVENT_KEY_REQUIRED Event indicating that the application needs to request a media key.
EVENT_KEY_EXPIRED Event indicating that the media key expires.
EVENT_VENDOR_DEFINED Vendor-defined event.
EVENT_EXPIRATION_UPDATE Event 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

Value Description
MEDIA_KEY_REQUEST_TYPE_UNKNOWN Unknown type.
MEDIA_KEY_REQUEST_TYPE_INITIAL Initial request.
MEDIA_KEY_REQUEST_TYPE_RENEWAL Renewal request.
MEDIA_KEY_REQUEST_TYPE_RELEASE Release request.
MEDIA_KEY_REQUEST_TYPE_NONE None.
MEDIA_KEY_REQUEST_TYPE_UPDATE Update request.

DRM_MediaKeyType

enum DRM_MediaKeyType

Description

Enumerates the types of media keys.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

Value Description
MEDIA_KEY_TYPE_OFFLINE Offline.
MEDIA_KEY_TYPE_ONLINE Online.

DRM_OfflineMediaKeyStatus

enum DRM_OfflineMediaKeyStatus

Description

Enumerates the statuses of offline media keys.

System capability: SystemCapability.Multimedia.Drm.Core

Since: 11

Value Description
OFFLINE_MEDIA_KEY_STATUS_UNKNOWN Unknown status.
OFFLINE_MEDIA_KEY_STATUS_USABLE The media key is available.
OFFLINE_MEDIA_KEY_STATUS_INACTIVE The 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
mediaKeyStatus Pointer 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

Name Description
mediaKeySession Pointer 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

Name Description
mediaKeySession Pointer 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
info Pointer to the information about the media key request.
mediaKeyRequest Pointer 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
offlineMediaKeyId Pointer to the ID of an offline media key.
offlineMediaKeyIdLen Length of the offline media key ID.
releaseRequest Pointer to a request to release offline media keys.
releaseRequestLen Length 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
contentProtectionLevel Pointer 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
response Pointer to a media key response.
responseLen Pointer to the length of the media key response.
offlineMediaKeyId Pointer to the ID of an offline media key.
offlineMediaKeyIdLen Length 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
offlineMediaKeyId Pointer to the ID of an offline media key.
offlineMediaKeyIdLen Length of the offline media key ID.
releaseReponse Pointer to the response.
releaseReponseLen Length 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
mimeType Pointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev.
status Pointer 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
offlineMediaKeyId Pointer to the ID of an offline media key.
offlineMediaKeyIdLen Length 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
callback Pointer 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

Name Description
mediaKeySession Pointer to the MediaKeySession instance.
callback Pointer 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
offlineMediaKeyId Pointer to the ID of an offline media key.
offlineMediaKeyIdLen Length 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

Name Description
name Pointer to the DRM solution name.
mediaKeySystem Double 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
level Pointer to the content protection level.
mediaKeySession Double 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

Name Description
mediaKeySystem Double 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
request Pointer to the provision request, which is used to request a DRM certificate from a provisioning server.
requestLen Pointer to the length of the provision request.
defaultUrl Pointer to the URL of the provisioning server.
defaultUrlLen Length 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
certStatus Pointer 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
configName Pointer 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.
value Pointer to the value of the configuration item.
valueLen Pointer 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
configName Pointer to the name of the configuration item.
value Pointer to the value of the configuration item.
valueLen 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 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
contentProtectionLevel Pointer 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

Name Description
infos Pointer to the list of the names and UUIDs of DRM solutions.
count Pointer 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
offlineMediaKeyIds Pointer 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
offlineMediaKeyId Pointer to the ID of an offline media key.
offlineMediaKeyIdLen Length of the offline media key ID.
status Pointer 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
statistics Pointer 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

Name Description
name Pointer 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

Name Description
name Pointer to the DRM solution name.
mimeType Pointer 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

Name Description
name Pointer to the DRM solution name.
mimeType Pointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev.
contentProtectionLevel Content 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
response Pointer to the provision response.
responseLen Length 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
callback Callback.

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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
configName Pointer 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.
value Pointer 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.
valueLen 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 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
configName Pointer 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.
value Pointer 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

Name Description
mediaKeySystem Pointer to the MediaKeySystem instance.
callback Callback.

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 [12]

uint8_t DRM_MediaKeyRequest::data[MAX_MEDIA_KEY_REQUEST_DATA_LEN]

Description

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

data [22]

uint8_t DRM_PsshInfo::data[MAX_PSSH_DATA_LEN]

Description

PSSH data.

dataLen [12]

int32_t DRM_MediaKeyRequest::dataLen

Description

Length of data in a media key request.

dataLen [22]

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 [12]

MediaKeySession_EventCallback MediaKeySession_Callback::eventCallback

Description

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

eventCallback [22]

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 [12]

MediaKeySession_KeyChangeCallback MediaKeySession_Callback::keyChangeCallback

Description

Key change callback.

keyChangeCallback [22]

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 [12]

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 [22]

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 [12]

DRM_MediaKeyType DRM_MediaKeyRequestInfo::type

Description

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

type [22]

DRM_MediaKeyRequestType DRM_MediaKeyRequest::type

Description

Type of a media key request.

uuid [12]

uint8_t DRM_PsshInfo::uuid[DRM_UUID_LEN]

Description UUID of a DRM solution in PSSH data.

uuid [22]

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

0  赞