openharmony 鸿蒙 capi-native-cencinfo-h

2026-08-25 浏览 (1)

native_cencinfo.h

Overview

The file declares the native APIs used to set decryption parameters.

File to include: <multimedia/player_framework/native_cencinfo.h>

Library: libnative_media_avcencinfo.so

System capability: SystemCapability.Multimedia.Media.Spliter

Since: 12

Related module: Multimedia_Drm

Summary

Structs

Nametypedef KeywordDescription
DrmSubsampleDrmSubsampleDescribes the subsample type.
OH_AVBufferOH_AVBufferDescribes the audio/video buffer.
OH_AVCencInfoOH_AVCencInfoDescribes the audio/video Common Encryption Scheme (CENC) information.

Enums

Nametypedef KeywordDescription
DrmCencAlgorithmDrmCencAlgorithmEnumerates the DRM CENC algorithm types.
DrmCencInfoModeDrmCencInfoModeEnumerates the modes for setting the key ID, IV, and subsample in the CENC information.

Macros

NameDescription
DRM_KEY_ID_SIZE 16The length of the key ID is 16 bytes.
Since: 12
DRM_KEY_IV_SIZE 16The length of the Initialization Vector (IV) is 16 bytes.
Since: 12
DRM_KEY_MAX_SUB_SAMPLE_NUM 64The maximum number of subsamples is 64.
Since: 12

Functions

NameDescription
OH_AVCencInfo *OH_AVCencInfo_Create()Creates an OH_AVCencInfo instance for setting the CENC information.
OH_AVErrCode OH_AVCencInfo_Destroy(OH_AVCencInfo *cencInfo)Destroys an OH_AVCencInfo instance and clears internal resources.
An instance can be destroyed only once. Do not use the instance until it is created again. You are advised to set the instance pointer to nullptr once the instance is destroyed.
OH_AVErrCode OH_AVCencInfo_SetAlgorithm(OH_AVCencInfo *cencInfo, enum DrmCencAlgorithm algo)Sets an encryption algorithm of the CENC information.
OH_AVErrCode OH_AVCencInfo_SetKeyIdAndIv(OH_AVCencInfo *cencInfo, uint8_t *keyId, uint32_t keyIdLen, uint8_t *iv, uint32_t ivLen)Sets the key ID and IV in the CENC information.
OH_AVErrCode OH_AVCencInfo_SetSubsampleInfo(OH_AVCencInfo *cencInfo, uint32_t encryptedBlockCount, uint32_t skippedBlockCount, uint32_t firstEncryptedOffset, uint32_t subsampleCount, DrmSubsample *subsamples)Sets the subsample information in the CENC information.
OH_AVErrCode OH_AVCencInfo_SetMode(OH_AVCencInfo *cencInfo, enum DrmCencInfoMode mode)Sets the CENC information mode.
OH_AVErrCode OH_AVCencInfo_SetAVBuffer(OH_AVCencInfo *cencInfo, OH_AVBuffer *buffer)Sets the CENC information to an AVBuffer.

Enum Description

DrmCencAlgorithm

enum DrmCencAlgorithm

Description

Enumerates the DRM CENC algorithm types.

Since: 12

ValueDescription
DRM_ALG_CENC_UNENCRYPTED = 0x0No encryption algorithm is used.
DRM_ALG_CENC_AES_CTR = 0x1AES CTR algorithm.
DRM_ALG_CENC_AES_WV = 0x2AES WV algorithm.
DRM_ALG_CENC_AES_CBC = 0x3AES CBC algorithm.
DRM_ALG_CENC_SM4_CBC = 0x4SM4 CBC algorithm.
DRM_ALG_CENC_SM4_CTR = 0x5SM4 CTR algorithm.

DrmCencInfoMode

enum DrmCencInfoMode

Description

Enumerates the modes for setting the key ID, IV, and subsample in the CENC information.

Since: 12

ValueDescription
DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET = 0x0The key ID, IV, and subsample are set.
DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET = 0x1The key ID, IV, and subsample are not set.

Function Description

OH_AVCencInfo_Create()

OH_AVCencInfo *OH_AVCencInfo_Create()

Description

Creates an OH_AVCencInfo instance for setting the CENC information.

System capability: SystemCapability.Multimedia.Media.Spliter

Since: 12

Returns

TypeDescription
OH_AVCencInfo *Pointer to the OH_AVCencInfo instance created. If the operation fails, nullptr is returned.
The possible causes of an operation failure are as follows: The application address space is full, or the data in the object fails to be initialized.

OH_AVCencInfo_Destroy()

OH_AVErrCode OH_AVCencInfo_Destroy(OH_AVCencInfo *cencInfo)

Description

Destroys an OH_AVCencInfo instance and clears internal resources.
An instance can be destroyed only once. Do not use the instance until it is created again. You are advised to set the instance pointer to nullptr once the instance is destroyed.

System capability: SystemCapability.Multimedia.Media.Spliter

Since: 12

Parameters

NameDescription
OH_AVCencInfo *cencInfoPointer to an OH_AVCencInfo instance.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The operation is successful.
AV_ERR_INVALID_VAL: The value of cencInfo is null.

OH_AVCencInfo_SetAlgorithm()

OH_AVErrCode OH_AVCencInfo_SetAlgorithm(OH_AVCencInfo *cencInfo, enum DrmCencAlgorithm algo)

Description

Sets an encryption algorithm of the CENC information.

System capability: SystemCapability.Multimedia.Media.Spliter

Since: 12

Parameters

NameDescription
OH_AVCencInfo *cencInfoPointer to an OH_AVCencInfo instance.
enum DrmCencAlgorithm algoEncryption algorithm.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The operation is successful.
AV_ERR_INVALID_VAL: The value of cencInfo is null.

OH_AVCencInfo_SetKeyIdAndIv()

OH_AVErrCode OH_AVCencInfo_SetKeyIdAndIv(OH_AVCencInfo *cencInfo, uint8_t *keyId, uint32_t keyIdLen, uint8_t *iv, uint32_t ivLen)

Description

Sets the key ID and IV in the CENC information.

System capability: SystemCapability.Multimedia.Media.Spliter

Since: 12

Parameters

NameDescription
OH_AVCencInfo *cencInfoPointer to an OH_AVCencInfo instance.
uint8_t *keyIdPointer to the key ID.
uint32_t keyIdLenLength of the key ID.
uint8_t *ivPointer to the IV.
uint32_t ivLenLength of the IV.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The operation is successful.
AV_ERR_INVALID_VAL: The value of cencInfo, keyId, or iv is null, keyIdLen is not equal to DRM_KEY_ID_SIZE, ivLen is not equal to DRM_KEY_IV_SIZE, the key ID or IV fails to be copied.

OH_AVCencInfo_SetSubsampleInfo()

OH_AVErrCode OH_AVCencInfo_SetSubsampleInfo(OH_AVCencInfo *cencInfo, uint32_t encryptedBlockCount, uint32_t skippedBlockCount, uint32_t firstEncryptedOffset, uint32_t subsampleCount, DrmSubsample *subsamples)

Description

Sets the subsample information in the CENC information.

System capability: SystemCapability.Multimedia.Media.Spliter

Since: 12

Parameters

NameDescription
OH_AVCencInfo *cencInfoPointer to an OH_AVCencInfo instance.
uint32_t encryptedBlockCountNumber of encrypted blocks.
uint32_t skippedBlockCountNumber of non-encrypted blocks.
uint32_t firstEncryptedOffsetOffset of the first encrypted payload.
uint32_t subsampleCountNumber of subsamples.
DrmSubsample *subsamplesPointer to the subsamples.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The operation is successful.
AV_ERR_INVALID_VAL: The value of cencInfo is null, subsampleCount is greater than DRM_KEY_MAX_SUB_SAMPLE_NUM, or subsamples is null.

OH_AVCencInfo_SetMode()

OH_AVErrCode OH_AVCencInfo_SetMode(OH_AVCencInfo *cencInfo, enum DrmCencInfoMode mode)

Description

Sets the CENC information mode.

System capability: SystemCapability.Multimedia.Media.Spliter

Since: 12

Parameters

NameDescription
OH_AVCencInfo *cencInfoPointer to an OH_AVCencInfo instance.
enum DrmCencInfoMode modeCENC information mode, indicating whether the key ID, IV, and subsample are set.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The operation is successful.
AV_ERR_INVALID_VAL: The value of cencInfo is null.

OH_AVCencInfo_SetAVBuffer()

OH_AVErrCode OH_AVCencInfo_SetAVBuffer(OH_AVCencInfo *cencInfo, OH_AVBuffer *buffer)

Description

Sets the CENC information to an AVBuffer.

System capability: SystemCapability.Multimedia.Media.Spliter

Since: 12

Parameters

NameDescription
OH_AVCencInfo *cencInfoPointer to an OH_AVCencInfo instance.
OH_AVBuffer *bufferPointer to the frame buffer that carries data.

Returns

TypeDescription
OH_AVErrCodeAV_ERR_OK: The operation is successful.
AV_ERR_INVALID_VAL: The value of cencInfo, buffer, buffer->buffer_, or buffer->buffer_->meta_ is null.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-native-avcodec-audiocodec-h

openharmony 鸿蒙 capi-avsource-oh-avsource

openharmony 鸿蒙 capi-avmuxer

openharmony 鸿蒙 capi-multimedia-drm-oh-avcencinfo

openharmony 鸿蒙 capi-native-avdemuxer-h

openharmony 鸿蒙 capi-media-types-h

openharmony 鸿蒙 capi-native-audio-channel-layout-h

openharmony 鸿蒙 capi-native-avbuffer-info-h

openharmony 鸿蒙 capi-codecbase-oh-avcodecasynccallback

openharmony 鸿蒙 capi-avdemuxer-oh-avdemuxer

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/fRcSadsg