diff --git a/multimedia/drm_framework/common/native_drm_common.h b/multimedia/drm_framework/common/native_drm_common.h index f634ebf107c8caa6ed9df0889225151b20797389..a7c9148f4638169cf4731e7bb2f00e096e320559 100644 --- a/multimedia/drm_framework/common/native_drm_common.h +++ b/multimedia/drm_framework/common/native_drm_common.h @@ -502,8 +502,141 @@ typedef struct MediaKeySystem MediaKeySystem; */ typedef struct MediaKeySession MediaKeySession; +/** + * @brief Media key id size. + * @since 12 + * @version 1.0 + */ +#define META_DRM_KEY_ID_SIZE 16 +/** + * @brief Media key iv size. + * @since 12 + * @version 1.0 + */ +#define META_DRM_IV_SIZE 16 +/** + * @brief Max count of sub samples. + * @since 12 + * @version 1.0 + */ +#define META_DRM_MAX_SUB_SAMPLE_NUM 64 + +/** + * @brief Key string of drm cenc info used as param key by {@link OH_AVFormat_SetBuffer}. + * @since 12 + * @version 1.0 + */ +const char DRM_CENC_INFO[] = "drm_cenc_info"; + +/** + * @brief Drm cenc algorithm type. + * @syscap SystemCapability.Multimedia.Drm.Core + * @since 12 + * @version 1.0 + */ +enum MetaDrmCencAlgorithm { + /** + * Uncrypted. + */ + META_DRM_ALG_CENC_UNENCRYPTED = 0x0, + /** + * Aes ctr. + */ + META_DRM_ALG_CENC_AES_CTR = 0x1, + /** + * Aes wv. + */ + META_DRM_ALG_CENC_AES_WV = 0x2, + /** + * Aes cbc. + */ + META_DRM_ALG_CENC_AES_CBC = 0x3, + /** + * Sm4 cbc. + */ + META_DRM_ALG_CENC_SM4_CBC = 0x4, + /** + * Sm4 ctr. + */ + META_DRM_ALG_CENC_SM4_CTR, +}; + +/** + * @brief Subsample info of media. + * @since 12 + * @version 1.0 + */ +struct MetaDrmSubSample { + /* Clear header len. */ + uint32_t clearHeaderLen; + /* Payload Len. */ + uint32_t payLoadLen; +}; +/** + * @brief Struct MetaDrmSubSample alias. + * @since 12 + * @version 1.0 + */ +typedef struct MetaDrmSubSample MetaDrmSubSample; + +/** + * @brief Cenc info of media. + * @since 12 + * @version 1.0 + */ +struct MetaDrmCencInfo { + /* Cenc algorithm used. */ + MetaDrmCencAlgorithm algo; + /* Key id. */ + uint8_t keyId[META_DRM_KEY_ID_SIZE]; + /* Key id len. */ + uint32_t keyIdLen; + /* Iv. */ + uint8_t iv[META_DRM_IV_SIZE]; + /* Iv len. */ + uint32_t ivLen; + /* Whether ambiguity content exists, only used in TS format. */ + uint32_t isAmbiguity; + /* Encrytped blocks num. */ + uint32_t encryptBlocks; + /* Clear blocks num. */ + uint32_t skipBlocks; + /* First encrypted payload offset. */ + uint32_t firstEncryptOffset; + /* Subsamples info. */ + MetaDrmSubSample subSample[META_DRM_MAX_SUB_SAMPLE_NUM]; + /* Subsamples num. */ + uint32_t subSampleNum; +}; +/** + * @brief Struct MetaDrmCencInfo alias. + * @since 12 + * @version 1.0 + */ +typedef struct MetaDrmCencInfo MetaDrmCencInfo; + +/** + * @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 + +typedef struct DRM_MediaKeySystemNameList { + /* Media key system count. */ + uint32_t mediaKeySystemCount; + /* Media key system name list. */ + char nameList[MAX_MEDIA_KEY_SYSTEM_NUM][MAX_MEDIA_KEY_SYSTEM_NAME_LEN]; +} DRM_MediaKeySystemNameList; + #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/native_mediakeysystem.h b/multimedia/drm_framework/native_mediakeysystem.h index 463e50e0b2382f38cd6306678e0a200aa8b62e42..6154f5979d4f44131c3a2ace96af6eb1203f7f2c 100644 --- a/multimedia/drm_framework/native_mediakeysystem.h +++ b/multimedia/drm_framework/native_mediakeysystem.h @@ -62,6 +62,26 @@ 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. + * @param nameList Used to save media key systems' name. + * @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_MediaKeySystemNameList *nameList); + +/** + * @brief Acquire media key system's uuid. + * @param name Media key systems' name. + * @param uuid Array to store uuid. + * @param uuidLen Uuid array len for in buffer. + * @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_GetMediaKeySystemUuid(const char *name, char *uuid, int32_t uuidLen); + /** * @brief Query if media key system is supported. * @param name Used to point a Digital Right Management solution. @@ -278,4 +298,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