From f67aaa3dcaae004f323e342198ac88542cfd1cad Mon Sep 17 00:00:00 2001 From: qiu-qiu-wang Date: Fri, 22 Mar 2024 23:31:45 +0800 Subject: [PATCH 01/15] add drm CAPI for audio decryption, avplayer capi, get supported drm system name and uuid, cencinfo Signed-off-by: qiu-qiu-wang --- .../libnative_media_adec.ndk.json | 4 + multimedia/av_codec/avcencinfo/BUILD.gn | 30 +++ .../libnative_media_avcencinfo.ndk.json | 30 +++ multimedia/av_codec/native_avcencinfo.h | 200 ++++++++++++++++++ .../av_codec/native_avcodec_audiodecoder.h | 19 +- .../drm_framework/common/native_drm_common.h | 29 ++- .../drm_framework/libnative_drm.ndk.json | 7 +- .../drm_framework/native_mediakeysystem.h | 12 +- multimedia/player_framework/avplayer.h | 43 ++++ .../avplayer/libavplayer.ndk.json | 16 +- 10 files changed, 384 insertions(+), 6 deletions(-) create mode 100644 multimedia/av_codec/avcencinfo/BUILD.gn create mode 100644 multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json create mode 100644 multimedia/av_codec/native_avcencinfo.h diff --git a/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json b/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json index 2f11d9276..89b3bac2f 100644 --- a/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json +++ b/multimedia/av_codec/audio_decoder/libnative_media_adec.ndk.json @@ -58,5 +58,9 @@ { "first_introduced": "10", "name": "OH_AudioDecoder_IsValid" + }, + { + "first_introduced": "12", + "name": "OH_AudioDecoder_SetDecryptionConfig" } ] diff --git a/multimedia/av_codec/avcencinfo/BUILD.gn b/multimedia/av_codec/avcencinfo/BUILD.gn new file mode 100644 index 000000000..07be72343 --- /dev/null +++ b/multimedia/av_codec/avcencinfo/BUILD.gn @@ -0,0 +1,30 @@ +# Copyright (C) 2022 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import("//build/ohos.gni") +import("//build/ohos/ndk/ndk.gni") +ohos_ndk_headers("native_media_avcencinfo_header") { + dest_dir = "$ndk_headers_out_dir/multimedia/player_framework" + sources = [ "../native_avcencinfo.h" ] +} + +ohos_ndk_library("libnative_media_avcencinfo") { + ndk_description_file = "./libnative_media_avcencinfo.ndk.json" + min_compact_version = "1" + output_name = "native_media_avcencinfo" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.Spliter" + system_capability_headers = + [ "multimedia/player_framework/native_avcencinfo.h" ] +} diff --git a/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json b/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json new file mode 100644 index 000000000..be84ad9ae --- /dev/null +++ b/multimedia/av_codec/avcencinfo/libnative_media_avcencinfo.ndk.json @@ -0,0 +1,30 @@ +[ + { + "first_introduced": "12", + "name": "OH_AVCencInfo_Create" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetAlgo" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetKeyIdAndIv" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetSubsampleInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetMode" + }, + { + "first_introduced": "12", + "name": "OH_AVCencInfo_SetAVBuffer" + } +] diff --git a/multimedia/av_codec/native_avcencinfo.h b/multimedia/av_codec/native_avcencinfo.h new file mode 100644 index 000000000..af08e39a8 --- /dev/null +++ b/multimedia/av_codec/native_avcencinfo.h @@ -0,0 +1,200 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef NATIVE_AVCENCINFO_H +#define NATIVE_AVCENCINFO_H + +#include +#include "native_averrors.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct OH_AVBuffer OH_AVBuffer; +typedef struct OH_AVCencInfo OH_AVCencInfo; +/** + * @brief Key id size. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_ID_SIZE 16 +/** + * @brief Iv size. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_IV_SIZE 16 +/** + * @brief Max subsample num. + * @since 12 + * @version 1.0 + */ +#define DRM_KEY_MAX_SUB_SAMPLE_NUM 64 + +/** + * @brief Drm cenc algorithm type. + * @since 12 + * @version 1.0 + */ +typedef enum DrmCencAlgorithm { + /** + * Uncrypted. + */ + DRM_ALG_CENC_UNENCRYPTED = 0x0, + /** + * Aes ctr. + */ + DRM_ALG_CENC_AES_CTR = 0x1, + /** + * Aes wv. + */ + DRM_ALG_CENC_AES_WV = 0x2, + /** + * Aes cbc. + */ + DRM_ALG_CENC_AES_CBC = 0x3, + /** + * Sm4 cbc. + */ + DRM_ALG_CENC_SM4_CBC = 0x4, + /** + * Sm4 ctr. + */ + DRM_ALG_CENC_SM4_CTR = 0x5 +} DrmCencAlgorithm; + +/** + * @brief Mode of cend info like set or not. + * @since 12 + * @version 1.0 + */ +typedef enum DrmCencInfoMode { + /* key/iv/subsample set. */ + DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET = 0x0, + /* key/iv/subsample not set. */ + DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET = 0x1 +} DrmCencInfoMode; + +/** + * @brief Subsample info of media. + * @since 12 + * @version 1.0 + */ +typedef struct DrmSubSample { + /* Clear header len. */ + uint32_t clearHeaderLen; + /* Payload Len. */ + uint32_t payLoadLen; +} DrmSubSample; + +/** + * @brief Creates an OH_AVCencInfo instance for setting cencinfo. + * Free the resources of the instance by calling OH_AVCencInfo_Destory. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @return Returns a pointer to an OH_AVCencInfo instance + * @since 12 + * @version 1.0 + */ +OH_AVCencInfo *OH_AVCencInfo_Create(); + +/** + * @brief Destroy the OH_AVCencInfo instance and free the internal resources. + * The same instance can only be destroyed once. The destroyed instance + * should not be used before it is created again. It is recommended setting + * the instance pointer to NULL right after the instance is destroyed successfully. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 12 + * @version 1.0 +*/ +OH_AVErrCode OH_AVCencInfo_Destroy(OH_AVCencInfo *cencInfo); + +/** + * @brief Method to set algo of cencinfo. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param algo Cenc algo. + * @return Returns {@link AV_ERR_OK} if the algo is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetAlgo(OH_AVCencInfo *cencInfo, enum DrmCencAlgorithm algo); + +/** + * @brief Method to set key id and iv of cencinfo. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param keyId Key id. + * @param keyIdLen Key id len. + * @param iv Iv. + * @param ivLen Iv len. + * @return Returns {@link AV_ERR_OK} if the key id and iv is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetKeyIdAndIv(OH_AVCencInfo *cencInfo, uint8_t *keyId, + uint32_t keyIdLen, uint8_t *iv, uint32_t ivLen); + +/** + * @brief Method to set subsample info of cencinfo. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param encryptBlocks Number of encrypted blocks. + * @param skipBlocks Number of skip(clear) blocks. + * @param firstEncryptOffset Offset of first encrypted payload. + * @param subsampleNum Subsample num. + * @param subSamples Subsample info + * @return Returns {@link AV_ERR_OK} if the subsample info is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetSubsampleInfo(OH_AVCencInfo *cencInfo, uint32_t encryptBlocks, + uint32_t skipBlocks, uint32_t firstEncryptOffset, uint32_t subsampleNum, DrmSubSample *subSamples); + +/** + * @brief Method to set mode of cencinfo. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param mode Cenc mode, indicate whether key/iv/subsample set or not. + * @return Returns {@link AV_ERR_OK} if the mode is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetMode(OH_AVCencInfo *cencInfo, enum DrmCencInfoMode mode); + +/** + * @brief Method to attach cencinfo to AVBuffer. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param cencInfo Pointer to an OH_AVCencInfo instance. + * @param buffer AVBuffer to attach cencinfo. + * @return Returns {@link AV_ERR_OK} if the cencinfo is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVCencInfo_SetAVBuffer(OH_AVCencInfo *cencInfo, OH_AVBuffer *buffer); + +#ifdef __cplusplus +} +#endif + +#endif // NATIVE_AVCENCINFO_H diff --git a/multimedia/av_codec/native_avcodec_audiodecoder.h b/multimedia/av_codec/native_avcodec_audiodecoder.h index e834aa233..4d33384b6 100644 --- a/multimedia/av_codec/native_avcodec_audiodecoder.h +++ b/multimedia/av_codec/native_avcodec_audiodecoder.h @@ -24,6 +24,8 @@ extern "C" { #endif +typedef struct MediaKeySession MediaKeySession; + /** * @brief Creates an audio decoder instance from the mime type, which is recommended in most cases. * @syscap SystemCapability.Multimedia.Media.AudioDecoder @@ -245,7 +247,22 @@ OH_AVErrCode OH_AudioDecoder_FreeOutputData(OH_AVCodec *codec, uint32_t index); */ OH_AVErrCode OH_AudioDecoder_IsValid(OH_AVCodec *codec, bool *isValid); +/** + * @brief Set decryption info. + * + * @syscap SystemCapability.Multimedia.Media.AudioDecoder + * @param codec Pointer to an OH_AVCodec instance + * @param mediaKeySession A media key session instance with decryption function. + * @param secureAudio Require secure decoder or not. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 12 + * @version 1.0 +*/ +OH_AVErrCode OH_AudioDecoder_SetDecryptionConfig(OH_AVCodec *codec, MediaKeySession *mediaKeySession, + bool secureAudio); + #ifdef __cplusplus } #endif -#endif // NATIVE_AVCODEC_AUDIODECODER_H \ No newline at end of file +#endif // NATIVE_AVCODEC_AUDIODECODER_H diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index f634ebf10..0d72ed658 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -502,8 +502,35 @@ typedef struct MediaKeySystem MediaKeySystem; */ typedef struct MediaKeySession MediaKeySession; +/** + * @brief Max len of media key system name. + * @since 12 + * @version 1.0 + */ +#define MAX_MEDIA_KEY_SYSTEM_NAME_LEN 128 + +/** + * @brief Max num of media key system supported + * @since 12 + * @version 1.0 + */ +#define MAX_MEDIA_KEY_SYSTEM_NUM 8 + + +/** + * @brief Name and UUID of DRM plugin. + * @since 12 + * @version 1.0 + */ +typedef struct DRM_MediaKeySystemMapInfo { + /* Name of DRM plugin. */ + char name[MAX_MEDIA_KEY_SYSTEM_NAME_LEN]; + /* uuid. */ + uint8_t uuid[DRM_UUID_LEN]; +} DRM_MediaKeySystemMapInfo; + #ifdef __cplusplus } #endif -#endif // NATIVE_DRM_COMMON_H \ No newline at end of file +#endif // NATIVE_DRM_COMMON_H diff --git a/multimedia/drm_framework/libnative_drm.ndk.json b/multimedia/drm_framework/libnative_drm.ndk.json index 185f5e08d..6e89767ca 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -118,5 +118,10 @@ { "first_introduced": "11", "name": "OH_MediaKeySession_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySystem_GetMediaKeySystems" } -] \ No newline at end of file + +] diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 463e50e0b..0de3a5438 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -62,6 +62,16 @@ extern "C" { typedef Drm_ErrCode (*MediaKeySystem_Callback)(DRM_EventType eventType, uint8_t *info, int32_t infoLen, char *extra); +/** + * @brief Acquire supported media key systems' name and uuid. + * @param infos Array used to save media key systems' name and uuid. + * @param count Used to indicate count of struct DRM_MediaKeySystemMapInfo. + * @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_MediaKeySystemMapInfo *infos, uint32_t *count); + /** * @brief Query if media key system is supported. * @param name Used to point a Digital Right Management solution. @@ -278,4 +288,4 @@ Drm_ErrCode OH_MediaKeySystem_Destroy(MediaKeySystem *mediaKeySystem); } #endif -#endif // OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H \ No newline at end of file +#endif // OHOS_DRM_NATIVE_MEDIA_KEY_SYSTEM_H diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index e8db017f0..32badd962 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -48,6 +48,10 @@ extern "C" { #endif +typedef struct MediaKeySession MediaKeySession; +typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; +typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); + /** * @brief Create a player * @syscap SystemCapability.Multimedia.Media.AVPlayer @@ -427,6 +431,45 @@ OH_AVErrCode OH_AVPlayer_DeselectTrack(OH_AVPlayer *player, int32_t index); */ OH_AVErrCode OH_AVPlayer_GetCurrentTrack(OH_AVPlayer *player, int32_t trackType, int32_t *index); +/** + * @brief Method to set player media key system info callback. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param callback object pointer. + * @return Returns {@link AV_ERR_OK} if the drm info callback is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_SetMediaKeySystemInfoCallback(OH_AVPlayer *player, + DRM_MediaKeySystemInfoCallback callback); + +/** + * @brief Obtains media key system info to create media key session. + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param mediaKeySystemInfo Media key system info. + * @return Returns {@link AV_ERR_OK} if the current position is get; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVPlayer_GetMediaKeySystemInfo(OH_AVPlayer *player, DRM_MediaKeySystemInfo *mediaKeySystemInfo); + +/** + * @brief Set decryption info. + * + * @syscap SystemCapability.Multimedia.Media.AVPlayer + * @param player Pointer to an OH_AVPlayer instance + * @param mediaKeySession A media key session instance with decryption function. + * @param secureVideoPath Require secure decoder or not. + * @return Returns AV_ERR_OK if the execution is successful, + * otherwise returns a specific error code, refer to {@link OH_AVErrCode} + * @since 12 + * @version 1.0 +*/ +OH_AVErrCode OH_AVPlayer_SetDecryptionConfig(OH_AVPlayer *player, MediaKeySession *mediaKeySession, + bool secureVideoPath); #ifdef __cplusplus } diff --git a/multimedia/player_framework/avplayer/libavplayer.ndk.json b/multimedia/player_framework/avplayer/libavplayer.ndk.json index d622cc601..75ea8e8d4 100644 --- a/multimedia/player_framework/avplayer/libavplayer.ndk.json +++ b/multimedia/player_framework/avplayer/libavplayer.ndk.json @@ -26,5 +26,17 @@ { "name": "OH_AVPlayer_SetPlayerCallback" }, { "name": "OH_AVPlayer_SelectTrack" }, { "name": "OH_AVPlayer_DeselectTrack" }, - { "name": "OH_AVPlayer_GetCurrentTrack" } -] \ No newline at end of file + { "name": "OH_AVPlayer_GetCurrentTrack" }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetMediaKeySystemInfoCallback" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_GetMediaKeySystemInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVPlayer_SetDecryptionConfig" + } +] -- Gitee From 8e526a9544fe7358398bd3c4fe802712f51a8781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 09:52:13 +0000 Subject: [PATCH 02/15] update multimedia/player_framework/avplayer.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/player_framework/avplayer.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/multimedia/player_framework/avplayer.h b/multimedia/player_framework/avplayer.h index 32badd962..5c3ba237e 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -50,7 +50,16 @@ extern "C" { typedef struct MediaKeySession MediaKeySession; typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; -typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); + +/** + * @brief Call back will be invoked when updating DRM information. + * @param player Player instance. + * @param mediaKeySystemInfo DRM information. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ +typedef void (*Player_MediaKeySystemInfoCallback)(OH_AVPlayer *player, DRM_MediaKeySystemInfo* mediaKeySystemInfo); /** * @brief Create a player @@ -442,7 +451,7 @@ OH_AVErrCode OH_AVPlayer_GetCurrentTrack(OH_AVPlayer *player, int32_t trackType, * @version 1.0 */ OH_AVErrCode OH_AVPlayer_SetMediaKeySystemInfoCallback(OH_AVPlayer *player, - DRM_MediaKeySystemInfoCallback callback); + Player_MediaKeySystemInfoCallback callback); /** * @brief Obtains media key system info to create media key session. -- Gitee From ab0a5480fe2168ba19b6c2b065850fadbcfabbfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 12:00:07 +0000 Subject: [PATCH 03/15] update multimedia/drm_framework/native_mediakeysystem.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/drm_framework/native_mediakeysystem.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 0de3a5438..214ba87c6 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -62,6 +62,19 @@ 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 Acquire supported media key systems' name and uuid. * @param infos Array used to save media key systems' name and uuid. -- Gitee From a8ce84f2c6a9b52d812d1daa8f8a017a18b211c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 12:10:37 +0000 Subject: [PATCH 04/15] update multimedia/drm_framework/native_mediakeysystem.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/drm_framework/native_mediakeysystem.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 214ba87c6..2e10edecc 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -75,6 +75,16 @@ typedef Drm_ErrCode (*MediaKeySystem_Callback)(DRM_EventType eventType, uint8_t */ 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 infos Array used to save media key systems' name and uuid. -- Gitee From 7bb89bb5f86fec88dddacc3499de06a17be9f1bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 12:28:18 +0000 Subject: [PATCH 05/15] update multimedia/drm_framework/native_mediakeysession.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- .../drm_framework/native_mediakeysession.h | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/multimedia/drm_framework/native_mediakeysession.h b/multimedia/drm_framework/native_mediakeysession.h index 999aa04e1..490bfdcc1 100644 --- a/multimedia/drm_framework/native_mediakeysession.h +++ b/multimedia/drm_framework/native_mediakeysession.h @@ -86,6 +86,47 @@ 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 OH_MediaKeySession_Callback struct, used to listen event like key expired and key change etc.. + * @since 11 + * @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 +249,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_SetMediaKeySessionCallback(MediaKeySession *mediaKeySessoin, + OH_MediaKeySession_Callback *callback); + /** * @brief Release the resource before the session gonna be unused. * @param mediaKeySession Media key session instance. -- Gitee From b3217207bce56cd979bf35c1eca5b7356ee8faea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 12:36:24 +0000 Subject: [PATCH 06/15] update multimedia/av_codec/native_avdemuxer.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/av_codec/native_avdemuxer.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/multimedia/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index 84634687e..c5401353a 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -27,6 +27,7 @@ extern "C" { typedef struct OH_AVDemuxer OH_AVDemuxer; typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); +typedef void (*Demuxer_MediaKeySystemInfoCallback)(OH_AVDemuxer *demuxer, DRM_MediaKeySystemInfo *mediaKeySystemInfo); /** * @brief Creates an OH_AVDemuxer instance for getting samples from source. @@ -140,6 +141,19 @@ OH_AVErrCode OH_AVDemuxer_SeekToTime(OH_AVDemuxer *demuxer, int64_t millisecond, OH_AVErrCode OH_AVDemuxer_SetMediaKeySystemInfoCallback(OH_AVDemuxer *demuxer, DRM_MediaKeySystemInfoCallback callback); +/** + * @brief Method to set player media key system info callback. + * @syscap SystemCapability.Multimedia.Media.Spliter + * @param demuxer Pointer to an OH_AVDemuxer instance + * @param callback object pointer. + * @return Returns {@link AV_ERR_OK} if the drm info callback is set; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @since 12 + * @version 1.0 + */ +OH_AVErrCode OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback(OH_AVDemuxer *demuxer, + Demuxer_MediaKeySystemInfoCallback callback); + /** * @brief Obtains media key system info to create media key session. * @syscap SystemCapability.Multimedia.Media.Spliter -- Gitee From adbb6f8fa60fad59a2471e1f93406bd76f1d9eac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 12:39:44 +0000 Subject: [PATCH 07/15] update multimedia/av_codec/native_avdemuxer.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/av_codec/native_avdemuxer.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/multimedia/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index c5401353a..696716e6c 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -26,7 +26,24 @@ extern "C" { typedef struct OH_AVDemuxer OH_AVDemuxer; typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; + +/** + * @brief Call back will be invoked when updating DRM information. + * @param mediaKeySystemInfo DRM information. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 11 + * @version 1.0 + */ typedef void (*DRM_MediaKeySystemInfoCallback)(DRM_MediaKeySystemInfo* mediaKeySystemInfo); + +/** + * @brief Call back will be invoked when updating DRM information. + * @param demuxer Player OH_AVDemuxer. + * @param mediaKeySystemInfo DRM information. + * @return DRM_ERR_INVALID_VAL when the params checked failure, return DRM_ERR_OK when function called successfully. + * @since 12 + * @version 1.0 + */ typedef void (*Demuxer_MediaKeySystemInfoCallback)(OH_AVDemuxer *demuxer, DRM_MediaKeySystemInfo *mediaKeySystemInfo); /** -- Gitee From d80145bb4d58f01be3815d0d47d6cc34d6197208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 12:42:27 +0000 Subject: [PATCH 08/15] update multimedia/drm_framework/native_mediakeysystem.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/drm_framework/native_mediakeysystem.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 2e10edecc..31cf17dc5 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -87,13 +87,13 @@ Drm_ErrCode OH_MediaKeySystem_SetCallback(MediaKeySystem *mediaKeySystem, OH_Med /** * @brief Acquire supported media key systems' name and uuid. - * @param infos Array used to save 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_MediaKeySystemMapInfo. * @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_MediaKeySystemMapInfo *infos, uint32_t *count); +Drm_ErrCode OH_MediaKeySystem_GetMediaKeySystems(DRM_MediaKeySystemDescription *descs, uint32_t *count); /** * @brief Query if media key system is supported. -- Gitee From c36b7fad6ae8541ed8133da87ba60801cfc5ba32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 12:43:49 +0000 Subject: [PATCH 09/15] update multimedia/drm_framework/common/native_drm_common.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/drm_framework/common/native_drm_common.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index 0d72ed658..11c34fd8e 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -522,12 +522,12 @@ typedef struct MediaKeySession MediaKeySession; * @since 12 * @version 1.0 */ -typedef struct DRM_MediaKeySystemMapInfo { +typedef struct DRM_MediaKeySystemDescription { /* Name of DRM plugin. */ char name[MAX_MEDIA_KEY_SYSTEM_NAME_LEN]; /* uuid. */ uint8_t uuid[DRM_UUID_LEN]; -} DRM_MediaKeySystemMapInfo; +} DRM_MediaKeySystemDescription; #ifdef __cplusplus } -- Gitee From 975ed6b1070ce06977301d23fca5ca0d60a7b47d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Tue, 16 Apr 2024 13:02:27 +0000 Subject: [PATCH 10/15] update multimedia/drm_framework/native_mediakeysystem.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/drm_framework/native_mediakeysystem.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/drm_framework/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 31cf17dc5..5f9d73d6f 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -88,7 +88,7 @@ Drm_ErrCode OH_MediaKeySystem_SetCallback(MediaKeySystem *mediaKeySystem, OH_Med /** * @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_MediaKeySystemMapInfo. + * @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 -- Gitee From 7e9bcec4328a61bf33d7c7469e03da63b92b3fd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Wed, 17 Apr 2024 01:42:34 +0000 Subject: [PATCH 11/15] update multimedia/av_codec/native_avcencinfo.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/av_codec/native_avcencinfo.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/multimedia/av_codec/native_avcencinfo.h b/multimedia/av_codec/native_avcencinfo.h index af08e39a8..941af5934 100644 --- a/multimedia/av_codec/native_avcencinfo.h +++ b/multimedia/av_codec/native_avcencinfo.h @@ -93,12 +93,12 @@ typedef enum DrmCencInfoMode { * @since 12 * @version 1.0 */ -typedef struct DrmSubSample { +typedef struct DrmSubsample { /* Clear header len. */ uint32_t clearHeaderLen; /* Payload Len. */ uint32_t payLoadLen; -} DrmSubSample; +} DrmSubsample; /** * @brief Creates an OH_AVCencInfo instance for setting cencinfo. @@ -134,7 +134,7 @@ OH_AVErrCode OH_AVCencInfo_Destroy(OH_AVCencInfo *cencInfo); * @since 12 * @version 1.0 */ -OH_AVErrCode OH_AVCencInfo_SetAlgo(OH_AVCencInfo *cencInfo, enum DrmCencAlgorithm algo); +OH_AVErrCode OH_AVCencInfo_SetAlgorithm(OH_AVCencInfo *cencInfo, enum DrmCencAlgorithm algo); /** * @brief Method to set key id and iv of cencinfo. @@ -156,18 +156,18 @@ OH_AVErrCode OH_AVCencInfo_SetKeyIdAndIv(OH_AVCencInfo *cencInfo, uint8_t *keyId * @brief Method to set subsample info of cencinfo. * @syscap SystemCapability.Multimedia.Media.Spliter * @param cencInfo Pointer to an OH_AVCencInfo instance. - * @param encryptBlocks Number of encrypted blocks. - * @param skipBlocks Number of skip(clear) blocks. - * @param firstEncryptOffset Offset of first encrypted payload. - * @param subsampleNum Subsample num. - * @param subSamples Subsample info + * @param encryptedBlockCount Number of encrypted blocks. + * @param skippedBlockCount Number of skip(clear) blocks. + * @param firstEncryptedOffset Offset of first encrypted payload. + * @param subsampleCount Subsample num. + * @param subsamples Subsample info * @return Returns {@link AV_ERR_OK} if the subsample info is set; returns an error code defined * in {@link native_averrors.h} otherwise. * @since 12 * @version 1.0 */ -OH_AVErrCode OH_AVCencInfo_SetSubsampleInfo(OH_AVCencInfo *cencInfo, uint32_t encryptBlocks, - uint32_t skipBlocks, uint32_t firstEncryptOffset, uint32_t subsampleNum, DrmSubSample *subSamples); +OH_AVErrCode OH_AVCencInfo_SetSubsampleInfo(OH_AVCencInfo *cencInfo, uint32_t encryptedBlockCount, + uint32_t skippedBlockCount, uint32_t firstEncryptedOffset, uint32_t subsampleCount, DrmSubSample *subsamples); /** * @brief Method to set mode of cencinfo. -- Gitee From cdde20ee1019acb6f884d1f1787b6a2eed7b577b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Wed, 17 Apr 2024 03:17:27 +0000 Subject: [PATCH 12/15] rename multimedia/av_codec/native_avcencinfo.h to multimedia/av_codec/native_cencinfo.h. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/av_codec/{native_avcencinfo.h => native_cencinfo.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename multimedia/av_codec/{native_avcencinfo.h => native_cencinfo.h} (100%) diff --git a/multimedia/av_codec/native_avcencinfo.h b/multimedia/av_codec/native_cencinfo.h similarity index 100% rename from multimedia/av_codec/native_avcencinfo.h rename to multimedia/av_codec/native_cencinfo.h -- Gitee From c2e62c0497ac3d0c2280c88ac9e659ccc4adc40a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Thu, 18 Apr 2024 12:23:50 +0000 Subject: [PATCH 13/15] update multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- .../av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json index 2a3cb212f..74498ea3d 100644 --- a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json +++ b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json @@ -35,4 +35,8 @@ "first_introduced": "11", "name": "OH_AVDemuxer_GetMediaKeySystemInfo" } + { + "first_introduced": "12", + "name": "OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback" + }, ] -- Gitee From 56147d9c27c453c168d5b70fa0080f1152c85ae4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Thu, 18 Apr 2024 12:25:37 +0000 Subject: [PATCH 14/15] update multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- .../av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json index 74498ea3d..d27632826 100644 --- a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json +++ b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json @@ -34,7 +34,7 @@ { "first_introduced": "11", "name": "OH_AVDemuxer_GetMediaKeySystemInfo" - } + }, { "first_introduced": "12", "name": "OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback" -- Gitee From 838bdd9a549e97c03e91f9afcf4faa69412f6fc9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=B8=98=E4=B8=98?= Date: Thu, 18 Apr 2024 12:26:09 +0000 Subject: [PATCH 15/15] update multimedia/drm_framework/libnative_drm.ndk.json. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 王丘丘 --- multimedia/drm_framework/libnative_drm.ndk.json | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/multimedia/drm_framework/libnative_drm.ndk.json b/multimedia/drm_framework/libnative_drm.ndk.json index 6e89767ca..e6d8c1d29 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -122,6 +122,13 @@ { "first_introduced": "12", "name": "OH_MediaKeySystem_GetMediaKeySystems" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySession_SetMediaKeySessionCallback" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySystem_SetCallback" } - ] -- Gitee