native_mediakeysystem.h
Overview
The file declares the MediaKeySystem APIs for DRM operations.
The APIs can be used to check the support for a DRM solution, create a media key session, obtain and set configurations, obtain DRM metrics, obtain the content protection level, generate media key system requests, process responses to media key system requests, listen for events, and manage offline media keys.
File to include: <multimedia/drm_framework/native_mediakeysystem.h>
Library: libnative_drm.so
System capability: SystemCapability.Multimedia.Drm.Core
Since: 11
Related module: Drm
Summary
Functions
Function Description
MediaKeySystem_Callback()
typedef Drm_ErrCode (*MediaKeySystem_Callback)(DRM_EventType eventType, uint8_t *info,int32_t infoLen, char *extra)
Description
Defines the callbacks for media key system events. It does not provide a MediaKeySystem instance, making it suitable for single-system scenarios.
Since: 11
Parameters
| Name | Description |
|---|---|
| DRM_EventType eventType | Event type. |
| uint8_t *info | Pointer to the event information. |
| int32_t infoLen | Length of the event information. |
| char *extra | Pointer to the additional information. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: An input parameter is invalid. |
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 callbacks for media key system events. It provides a MediaKeySystem instance, making it suitable for multi-system scenarios.
Since: 12
Parameters
| Name | Description |
|---|---|
| MediaKeySystem *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| DRM_EventType eventType | Event type. |
| uint8_t *info | Pointer to the event information. |
| int32_t infoLen | Length of the event information. |
| char *extra | Pointer to the additional information. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: An input parameter is invalid. |
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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| OH_MediaKeySystem_Callback callback | Callback. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid. |
OH_MediaKeySystem_GetMediaKeySystems()
Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *descs, uint32_t *count)
Description
Obtains the name and ID list of DRM solutions supported by the device.
Since: 12
Parameters
| Name | Description |
|---|---|
| DRM_MediaKeySystemDescription *descs | Pointer to the list of the names and UUIDs of DRM solutions. |
| uint32_t *count | Pointer to the number of DRM solutions in the list. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: Possible causes: 1. The input parameter descs or count is a null pointer. 2. The length of the input parameter descs is insufficient. 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 |
|---|---|
| const char *name | Pointer to the DRM solution name. |
Returns
| Type | Description |
|---|---|
| bool | Check result for the support of the DRM solution. true if supported, 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 DRM solution and MIME type.
Since: 11
Parameters
| Name | Description |
|---|---|
| const char *name | Pointer to the DRM solution name. |
| const char *mimeType | Pointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev. |
Returns
| Type | Description |
|---|---|
| bool | Check result for the support of the combination. true if supported, 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 DRM solution, MIME type, and content protection level.
Since: 11
Parameters
| Name | Description |
|---|---|
| const char *name | Pointer to the DRM solution name. |
| const char *mimeType | Pointer to the MIME type. The supported MIME types depend on the DRM solution. Example types are video/avc and video/hev. |
| DRM_ContentProtectionLevel contentProtectionLevel | Content protection level. |
Returns
| Type | Description |
|---|---|
| bool | Check result for the support of the combination. true if supported, false otherwise. |
OH_MediaKeySystem_Create()
Drm_ErrCode OH_MediaKeySystem_Create(const char *name, MediaKeySystem **mediaKeySystem)
Description
Creates a MediaKeySystem instance.
Since: 11
Parameters
| Name | Description |
|---|---|
| const char *name | Pointer to the DRM solution name. |
| MediaKeySystem **mediaKeySystem | Double pointer to the MediaKeySystem instance. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: Possible causes: 1. The input parameter name is nullptr or its length is 0. 2. The input parameter mediaKeySystem is nullptr. 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_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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| const char *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. |
| const char *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
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or configName or value is nullptr. |
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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| const char *configName | Pointer to the name of the configuration item. |
| char *value | Pointer to the value of the configuration item. |
| int32_t valueLen | Length of the value. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_NO_MEMORY: Memory allocation fails due to insufficient system memory. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or configName or value is nullptr. DRM_ERR_UNKNOWN: An internal error occurs. Check the log details. |
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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| const char *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. |
| uint8_t *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. |
| int32_t valueLen | Length of the value. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_NO_MEMORY: Memory allocation fails due to insufficient system memory. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or configName or value is nullptr. 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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| const char *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. |
| uint8_t *value | Pointer to the value of the configuration item. |
| int32_t *valueLen | Pointer to the length of the value. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_NO_MEMORY: Memory allocation fails due to insufficient system memory. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or configName, value, or valueLen is nullptr. 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 metrics of a media key system.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySystem *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| DRM_Statistics *statistics | Pointer to the metrics. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_NO_MEMORY: Memory allocation fails due to insufficient system memory. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or statistics is nullptr. 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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| DRM_ContentProtectionLevel *contentProtectionLevel | Pointer to the content protection level. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or contentProtectionLevel is nullptr. DRM_ERR_UNKNOWN: An internal error occurs. Check the log details. |
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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| MediaKeySystem_Callback callback | Callback. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid. |
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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| DRM_ContentProtectionLevel *level | Pointer to the content protection level. |
| MediaKeySession **mediaKeySession | Double pointer to the MediaKeySession instance created. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_NO_MEMORY: Memory allocation fails due to insufficient system memory. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, level is out of range, or mediaKeySession is nullptr. 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_GenerateKeySystemRequest()
Drm_ErrCode OH_MediaKeySystem_GenerateKeySystemRequest(MediaKeySystem *mediaKeySystem, uint8_t *request,int32_t *requestLen, char *defaultUrl, int32_t defaultUrlLen)
Description
Generates a request to obtain a device certificate.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySystem *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| uint8_t *request | Pointer to the device certificate request. |
| int32_t *requestLen | Pointer to the length of the device certificate request. |
| char *defaultUrl | Pointer to the URL of the provisioning server. |
| int32_t defaultUrlLen | Length of the URL of the provisioning server. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_NO_MEMORY: Memory allocation fails due to insufficient system memory. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or another parameter of the pointer type is nullptr. DRM_ERR_UNKNOWN: An internal error occurs. Check the log details. |
OH_MediaKeySystem_ProcessKeySystemResponse()
Drm_ErrCode OH_MediaKeySystem_ProcessKeySystemResponse(MediaKeySystem *mediaKeySystem,uint8_t *response, int32_t responseLen)
Description
Processes the response to a previously generated device certificate request.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySystem *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| uint8_t *response | Pointer to the response to a previously generated device certificate request. |
| int32_t responseLen | Length of the response. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or response is nullptr. 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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| DRM_OfflineMediakeyIdArray *offlineMediaKeyIds | Pointer to the IDs of offline media keys. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_NO_MEMORY: Memory allocation fails due to insufficient system memory. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or offlineMediaKeyIds is nullptr. 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 *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| uint8_t *offlineMediaKeyId | Pointer to the ID of an offline media key. |
| int32_t offlineMediaKeyIdLen | Length of the offline media key ID. |
| DRM_OfflineMediaKeyStatus *status | Pointer to the media key status obtained. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or another parameter of the pointer type is nullptr. DRM_ERR_UNKNOWN: An internal error occurs. Check the log details. |
OH_MediaKeySystem_ClearOfflineMediaKeys()
Drm_ErrCode OH_MediaKeySystem_ClearOfflineMediaKeys(MediaKeySystem *mediaKeySystem,uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen)
Description
Clears offline media keys with the specified IDs.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySystem *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| uint8_t *offlineMediaKeyId | Pointer to the ID of an offline media key. |
| int32_t offlineMediaKeyIdLen | Length of the offline media key ID. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or offlineMediaKeyId is nullptr. 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 device certificate.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySystem *mediaKeySystem | Pointer to the MediaKeySystem instance. |
| DRM_CertificateStatus *certStatus | Pointer to the device certificate status. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid, or certStatus is nullptr. DRM_ERR_UNKNOWN: An internal error occurs. Check the log details. |
OH_MediaKeySystem_Destroy()
Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem)
Description
Destroys a MediaKeySystem instance.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySystem *mediaKeySystem | Pointer to the MediaKeySystem instance. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySystem is nullptr or invalid. DRM_ERR_UNKNOWN: An internal error occurs. Check the log details. |
你可能感兴趣的鸿蒙文章
openharmony 鸿蒙 capi-drm-drm-mediakeysystemdescription
openharmony 鸿蒙 capi-drm-drm-offlinemediakeyidarray
openharmony 鸿蒙 arkts-apis-drm-MediaKeySession
openharmony 鸿蒙 capi-drm-drm-keysinfo
openharmony 鸿蒙 capi-drm-drm-mediakeyrequest
openharmony 鸿蒙 capi-native-mediakeysession-h
openharmony 鸿蒙 capi-drm-drm-mediakeyrequestinfo