native_mediakeysession.h
Overview
The file declares the MediaKeySession APIs for DRM operations.
The APIs can be used to generate media key requests, process responses to media key requests, listen for events, obtain content protection levels, check media key status, and remove media keys.
File to include: <multimedia/drm_framework/native_mediakeysession.h>
Library: libnative_drm.so
System capability: SystemCapability.Multimedia.Drm.Core
Since: 11
Related module: Drm
Summary
Structs
| Name | typedef Keyword | Description |
|---|---|---|
| MediaKeySession_Callback | MediaKeySession_Callback | Defines the callbacks for media key session events such as key expiration and key changes. It does not provide a MediaKeySession instance, making it suitable for single-session decryption scenarios. |
| OH_MediaKeySession_Callback | OH_MediaKeySession_Callback | Defines the callbacks for media key session events such as key expiration and key changes. It provides a MediaKeySession instance, making it suitable for multi-session decryption scenarios. |
Functions
Function Description
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, key expiration events.
Since: 11
Parameters
| Name | Description |
|---|---|
| DRM_EventType eventType | Event type. |
| uint8_t *info | Pointer to the event information obtained from the media key session. |
| int32_t infoLen | Length of the event information. |
| char *extra | Pointer to the additional information obtained from the media key session. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | Error code. |
MediaKeySession_KeyChangeCallback()
typedef Drm_ErrCode (*MediaKeySession_KeyChangeCallback)(DRM_KeysInfo *keysInfo, bool newKeysAvailable)
Description
Defines the callback used to listen for media key change events.
Since: 11
Parameters
| Name | Description |
|---|---|
| DRM_KeysInfo *keysInfo | Pointer to the media key information. |
| bool newKeysAvailable | Whether the new keys are available. true if available, false otherwise. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: Parameter check fails. |
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 used to listen for media key session events.
Since: 12
Parameters
| Name | Description |
|---|---|
| MediaKeySession *mediaKeySession | Pointer to the MediaKeySession 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 | Error code. |
OH_MediaKeySession_KeyChangeCallback()
typedef Drm_ErrCode (*OH_MediaKeySession_KeyChangeCallback)(MediaKeySession *mediaKeySession, DRM_KeysInfo *keysInfo,bool newKeysAvailable)
Description
Defines the callback used to listen for media key change events.
Since: 12
Parameters
| Name | Description |
|---|---|
| MediaKeySession *mediaKeySession | Pointer to the MediaKeySession instance. |
| DRM_KeysInfo *keysInfo | Pointer to the media key information. |
| bool newKeysAvailable | Whether the new keys are available. true if available, false otherwise. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: Parameter check fails. |
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 *mediaKeySession | Pointer to the MediaKeySession instance. |
| DRM_MediaKeyRequestInfo *info | Pointer to the information about the media key request. |
| DRM_MediaKeyRequest *mediaKeyRequest | Pointer to the media key request. |
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 mediaKeySession is nullptr or invalid, or info or mediaKeyRequest is nullptr. 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 the response to a media key request.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySession *mediaKeySession | Pointer to the MediaKeySession instance. |
| uint8_t *response | Pointer to the response to a media key request. |
| int32_t responseLen | Pointer to the length of the response. |
| 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_NO_MEMORY: Memory allocation fails due to insufficient system memory. DRM_ERR_INVALID_VAL: The input parameter mediaKeySession 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_MediaKeySession_CheckMediaKeyStatus()
Drm_ErrCode OH_MediaKeySession_CheckMediaKeyStatus(MediaKeySession *mediaKeySession,DRM_MediaKeyStatus *mediaKeyStatus)
Description
Checks the status of a media key.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySession *mediaKeySession | Pointer to the MediaKeySession instance. |
| DRM_MediaKeyStatus *mediaKeyStatus | Pointer to the media key status obtained. |
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 mediaKeySession is nullptr or invalid, or mediaKeyStatus is nullptr. 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 *mediaKeySession | Pointer to the MediaKeySession instance. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySession is nullptr or invalid. 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 *mediaKeySession | Pointer to the MediaKeySession instance. |
| uint8_t *offlineMediaKeyId | Pointer to the ID of an offline media key. |
| int32_t *releaseRequestLen | Length of the offline media key ID. |
| uint8_t *releaseRequest | Pointer to the request to release offline media keys. |
| int32_t *releaseRequestLen | Length of the request to release 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 mediaKeySession is nullptr or invalid, or another parameter of the pointer type is nullptr. DRM_ERR_UNKNOWN: An internal error occurs or the DRM solution on the device does not support the release of offline media keys. Check the log details. |
OH_MediaKeySession_ProcessOfflineReleaseResponse()
Drm_ErrCode OH_MediaKeySession_ProcessOfflineReleaseResponse(MediaKeySession *mediaKeySession,uint8_t *offlineMediaKeyId, int32_t offlineMediaKeyIdLen, uint8_t *releaseResponse,int32_t releaseResponseLen)
Description
Processes the response to a request for releasing offline media keys.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySession *mediaKeySession | Pointer to the MediaKeySession instance. |
| uint8_t *offlineMediaKeyId | Pointer to the ID of an offline media key. |
| int32_t offlineMediaKeyIdLen | Length of the offline media key ID. |
| uint8_t *releaseResponse | Pointer to the response. |
| int32_t releaseResponseLen | Length of the response. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySession is nullptr or invalid, or another parameter of the pointer type is nullptr. DRM_ERR_UNKNOWN: An internal error occurs or the DRM solution on the device does not support the release of offline media keys. 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 *mediaKeySession | Pointer to the MediaKeySession 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 mediaKeySession 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_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 *mediaKeySession | Pointer to the MediaKeySession 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 mediaKeySession is nullptr or invalid, or contentProtectionLevel is nullptr. DRM_ERR_UNKNOWN: An internal error occurs. 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 *mediaKeySession | Pointer to the MediaKeySession instance. |
| 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. |
| bool *status | Pointer to the result indicating whether secure decoding is required. The value true means that secure decoding is required, and the value false means the opposite. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySession 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_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 *mediaKeySession | Pointer to the MediaKeySession instance. |
| MediaKeySession_Callback *callback | Pointer to the callback for the media key session event. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySession is nullptr or invalid, or callback is nullptr. |
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 *mediaKeySession | Pointer to the MediaKeySession instance. |
| OH_MediaKeySession_Callback *callback | Pointer to the callback for the media key session event. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySession is nullptr or invalid, or callback is nullptr. |
OH_MediaKeySession_Destroy()
Drm_ErrCode OH_MediaKeySession_Destroy(MediaKeySession *mediaKeySession)
Description
Destroys a MediaKeySession instance.
Since: 11
Parameters
| Name | Description |
|---|---|
| MediaKeySession *mediaKeySession | Pointer to the MediaKeySession instance. |
Returns
| Type | Description |
|---|---|
| Drm_ErrCode | DRM_ERR_OK: The operation is successful. DRM_ERR_INVALID_VAL: The input parameter mediaKeySession 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-native-mediakeysystem-h
openharmony 鸿蒙 capi-drm-drm-mediakeyrequest
openharmony 鸿蒙 capi-drm-drm-mediakeyrequestinfo