diff --git a/multimedia/drm_framework/libnative_drm.ndk.json b/multimedia/drm_framework/libnative_drm.ndk.json index 41e94c3abad1fd20c7e37737c20a4c2a78b2f249..0e453e4d5b3fbae7c6a4ecacf67c026dfcd97746 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -111,10 +111,6 @@ "first_introduced": "11", "name": "OH_MediaKeySession_RequireSecureDecoderModule" }, - { - "first_introduced": "11", - "name": "OH_MediaKeySession_SetMediaKeySessionCallback" - }, { "first_introduced": "11", "name": "OH_MediaKeySession_Destroy" @@ -122,5 +118,13 @@ { "first_introduced": "12", "name": "OH_MediaKeySystem_GetMediaKeySystems" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySystem_SetCallback" } ] \ No newline at end of file diff --git a/multimedia/drm_framework/native_mediakeysession.h b/multimedia/drm_framework/native_mediakeysession.h index 999aa04e1f36e8364863d01a41f88b92d5c3ee40..8394da5da077133b8a18f2f7ab5ed701c9c89528 100644 --- a/multimedia/drm_framework/native_mediakeysession.h +++ b/multimedia/drm_framework/native_mediakeysession.h @@ -86,6 +86,48 @@ typedef struct MediaKeySession_Callback { MediaKeySession_KeyChangeCallback keyChangeCallback; } MediaKeySession_Callback; +/** + * @brief Call back will be invoked when event triggers. + * @param mediaKeySessoin MediaKeySession instance. + * @param eventType Event type. + * @param info Event info gotten from media key session. + * @param infoLen Event info len. + * @param extra Extra info gotten from media key session. + * @return Drm_ErrCode. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySession_EventCallback)(MediaKeySession *mediaKeySessoin, DRM_EventType eventType, + uint8_t *info, int32_t infoLen, char *extra); + +/** + * @brief Call back will be invoked when key changes. + * @param mediaKeySessoin MediaKeySession instance. + * @param keysInfo Key info gotten from media key system. + * @param newKeysAvailable Whether new keys available. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySession_KeyChangeCallback)(MediaKeySession *mediaKeySessoin, DRM_KeysInfo *keysInfo, + bool newKeysAvailable); + +/** + * @brief MediaKeySession_Callback struct, used to listen event like key expired and key change etc.. + * @since 12 + * @version 1.0 + */ +typedef struct OH_MediaKeySession_Callback { + /** + * Normal event callback like key expired etc.. + */ + OH_MediaKeySession_EventCallback eventCallback; + /** + * Key change callback for keys change event. + */ + OH_MediaKeySession_KeyChangeCallback keyChangeCallback; +} OH_MediaKeySession_Callback; + /** * @brief Generate media key request. * @param mediaKeySession Media key session instance. @@ -208,6 +250,17 @@ Drm_ErrCode OH_MediaKeySession_RequireSecureDecoderModule(MediaKeySession *media Drm_ErrCode OH_MediaKeySession_SetMediaKeySessionCallback(MediaKeySession *mediaKeySessoin, MediaKeySession_Callback *callback); +/** + * @brief Set media key session event callback. + * @param mediaKeySession Media key session instance. + * @param callback Callback to be set to the media key session. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySession_SetCallback(MediaKeySession *mediaKeySessoin, + OH_MediaKeySession_Callback *callback); + /** * @brief Release the resource before the session gonna be unused. * @param mediaKeySession Media key session instance. diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 88f27fdf9aedd66eb6825773d6835220fb9256f1..9f84618f05a62af6514cca4b5ec712f8716068f9 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -62,6 +62,40 @@ extern "C" { typedef Drm_ErrCode (*MediaKeySystem_Callback)(DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra); +/** + * @brief Call back will be invoked when event triggers. + * @param mediaKeySystem MediaKeySystem instance. + * @param eventType Event type. + * @param info Event info gotten from media key system. + * @param infoLen Event info len. + * @param extra Extra info gotten from media key system. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef Drm_ErrCode (*OH_MediaKeySystem_Callback)(MediaKeySystem *mediaKeySystem, DRM_EventType eventType, + uint8_t *info, int32_t infoLen, char *extra); + +/** + * @brief Set media key system event callback. + * @param mediaKeySystem Media key system instance. + * @param callback Callback to be set to the media key system. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySystem_SetCallback(MediaKeySystem *mediaKeySystem, OH_MediaKeySystem_Callback callback); + +/** + * @brief Acquire supported media key systems' name and uuid. + * @param descs Array used to save media key systems' name and uuid. + * @param count Used to indicate count of struct DRM_MediaKeySystemDescription. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *descs, uint32_t *count); + /** * @brief Query if media key system is supported. * @param name Used to point a Digital Right Management solution. @@ -273,15 +307,6 @@ Drm_ErrCode OH_MediaKeySystem_GetCertificateStatus(MediaKeySystem *mediaKeySyste */ Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem); -/** - * @brief Acquire supported media key systems' name and uuid. - * @param descs Array used to save media key systems' name and uuid. - * @param count Used to indicate count of struct DRM_MediaKeySystemDescription. - * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. - * @since 12 - * @version 1.0 - */ -Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *descs, uint32_t *count); #ifdef __cplusplus }