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 2f11d92769bbffc922efe4ab232c7426da1ddcaa..89b3bac2f99e3039bcf914d804dca9960a36d786 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 0000000000000000000000000000000000000000..a1f43c09aecf7e5ce9e495673ad9e0a484ec5e49 --- /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_cencinfo.h" ] +} + +ohos_ndk_library("libnative_media_avcencinfo") { + ndk_description_file = "./libnative_media_avcencinfo.ndk.json" + min_compact_version = "12" + output_name = "native_media_avcencinfo" + output_extension = "so" + + system_capability = "SystemCapability.Multimedia.Media.Spliter" + system_capability_headers = + [ "multimedia/player_framework/native_cencinfo.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 0000000000000000000000000000000000000000..be84ad9ae96c279090b4cd56d8f141199e1d781f --- /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/avdemuxer/libnative_media_avdemuxer.ndk.json b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json index 2a3cb212f6ff277c6801502b05a573e86a028c25..dcddf3df46b0da2831e34e107322d476701bc311 100644 --- a/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json +++ b/multimedia/av_codec/avdemuxer/libnative_media_avdemuxer.ndk.json @@ -34,5 +34,9 @@ { "first_introduced": "11", "name": "OH_AVDemuxer_GetMediaKeySystemInfo" + }, + { + "first_introduced": "12", + "name": "OH_AVDemuxer_SetDemuxerMediaKeySystemInfoCallback" } ] diff --git a/multimedia/av_codec/native_avcodec_audiodecoder.h b/multimedia/av_codec/native_avcodec_audiodecoder.h index e834aa233de12015f84951bee3363bebd4487aff..66bc8203f1c80a9fb6de8ddb2f21ba4df6e32a64 100644 --- a/multimedia/av_codec/native_avcodec_audiodecoder.h +++ b/multimedia/av_codec/native_avcodec_audiodecoder.h @@ -24,6 +24,13 @@ extern "C" { #endif +/** + * @brief MediaKeySession field. + * @since 12 + * @version 1.0 + */ +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 +252,21 @@ 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/av_codec/native_avdemuxer.h b/multimedia/av_codec/native_avdemuxer.h index 84634687e987dbfa241f494a726351ff3fa3bbdf..96717cf969da97a8cba0fa9cd51a01f6d8d09a8b 100644 --- a/multimedia/av_codec/native_avdemuxer.h +++ b/multimedia/av_codec/native_avdemuxer.h @@ -28,6 +28,16 @@ typedef struct OH_AVDemuxer OH_AVDemuxer; typedef struct DRM_MediaKeySystemInfo DRM_MediaKeySystemInfo; 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); + /** * @brief Creates an OH_AVDemuxer instance for getting samples from source. * Free the resources of the instance by calling OH_AVDemuxer_Destroy. @@ -140,6 +150,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 diff --git a/multimedia/av_codec/native_cencinfo.h b/multimedia/av_codec/native_cencinfo.h new file mode 100644 index 0000000000000000000000000000000000000000..b7dbf5fbacc4369c552ac59bc372618d3e11bf0f --- /dev/null +++ b/multimedia/av_codec/native_cencinfo.h @@ -0,0 +1,210 @@ +/* + * 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 + +/** + * @brief AVBuffer Structure. + * @since 12 + * @version 1.0 + */ +typedef struct OH_AVBuffer OH_AVBuffer; +/** + * @brief AVCencInfo Structure. + * @since 12 + * @version 1.0 + */ +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 { + /** + * Unencrypted. + */ + 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_SetAlgorithm(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 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 encryptedBlockCount, + uint32_t skippedBlockCount, uint32_t firstEncryptedOffset, uint32_t subsampleCount, 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/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index f634ebf107c8caa6ed9df0889225151b20797389..11c34fd8eb007cab4fa3cadb90fe8fc9478a7b8a 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_MediaKeySystemDescription { + /* Name of DRM plugin. */ + char name[MAX_MEDIA_KEY_SYSTEM_NAME_LEN]; + /* uuid. */ + uint8_t uuid[DRM_UUID_LEN]; +} DRM_MediaKeySystemDescription; + #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 185f5e08dbe6b260b1435ba1c6bf9a0c94215845..46a7c326a0d707b784816f5d511d29accad79f33 100644 --- a/multimedia/drm_framework/libnative_drm.ndk.json +++ b/multimedia/drm_framework/libnative_drm.ndk.json @@ -113,10 +113,18 @@ }, { "first_introduced": "11", + "name": "OH_MediaKeySession_Destroy" + }, + { + "first_introduced": "12", + "name": "OH_MediaKeySystem_GetMediaKeySystems" + }, + { + "first_introduced": "12", "name": "OH_MediaKeySession_SetMediaKeySessionCallback" }, { - "first_introduced": "11", - "name": "OH_MediaKeySession_Destroy" + "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 463e50e0b2382f38cd6306678e0a200aa8b62e42..49e374e1a4e3a71c7e7968fc7772facc7fe0b129 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. @@ -278,4 +312,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 e8db017f06a7689d127e9966c8a6faa63271472b..0939a6516453772642bb0d9e7c08cdc292cdef5c 100644 --- a/multimedia/player_framework/avplayer.h +++ b/multimedia/player_framework/avplayer.h @@ -48,6 +48,29 @@ extern "C" { #endif +/** + * @brief MediaKeySession field. + * @since 12 + * @version 1.0 + */ +typedef struct MediaKeySession MediaKeySession; +/** + * @brief DRM_MediaKeySystemInfo field. + * @since 12 + * @version 1.0 + */ +typedef struct DRM_MediaKeySystemInfo DRM_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 * @syscap SystemCapability.Multimedia.Media.AVPlayer @@ -427,6 +450,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, + Player_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 {@link AV_ERR_OK} if set successfully; returns an error code defined + * in {@link native_averrors.h} otherwise. + * @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 d622cc601c308aa2d630fac0e76e9e7d42098ea8..75ea8e8d4085c76e0bf644164cb3fabbb336525a 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" + } +]