ohos-media-sys 0.1.0

Raw Bindings to the media framework on OpenHarmony
Documentation
// automatically generated by rust-bindgen 0.71.1

#![allow(non_upper_case_globals)]
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
#![allow(deprecated)]
#[allow(unused_imports)]
use crate::averrors::OH_AVErrCode;

pub const DRM_KEY_ID_SIZE: u32 = 16;
pub const DRM_KEY_IV_SIZE: u32 = 16;
pub const DRM_KEY_MAX_SUB_SAMPLE_NUM: u32 = 64;
/// AVBuffer Structure.
///
/// Available since API-level: 12
///
/// Version: 1.0
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
pub struct OH_AVBuffer {
    _unused: [u8; 0],
}
/// AVCencInfo Structure.
///
/// Available since API-level: 12
///
/// Version: 1.0
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
pub struct OH_AVCencInfo {
    _unused: [u8; 0],
}
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
impl DrmCencAlgorithm {
    /// Unencrypted.
    pub const DRM_ALG_CENC_UNENCRYPTED: DrmCencAlgorithm = DrmCencAlgorithm(0);
    /// Aes ctr.
    pub const DRM_ALG_CENC_AES_CTR: DrmCencAlgorithm = DrmCencAlgorithm(1);
    /// Aes wv.
    pub const DRM_ALG_CENC_AES_WV: DrmCencAlgorithm = DrmCencAlgorithm(2);
    /// Aes cbc.
    pub const DRM_ALG_CENC_AES_CBC: DrmCencAlgorithm = DrmCencAlgorithm(3);
    /// Sm4 cbc.
    pub const DRM_ALG_CENC_SM4_CBC: DrmCencAlgorithm = DrmCencAlgorithm(4);
    /// Sm4 ctr.
    pub const DRM_ALG_CENC_SM4_CTR: DrmCencAlgorithm = DrmCencAlgorithm(5);
}
#[repr(transparent)]
/// Drm cenc algorithm type.
///
/// Available since API-level: 12
///
/// Version: 1.0
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct DrmCencAlgorithm(pub ::core::ffi::c_uint);
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
impl DrmCencInfoMode {
    pub const DRM_CENC_INFO_KEY_IV_SUBSAMPLES_SET: DrmCencInfoMode = DrmCencInfoMode(0);
    pub const DRM_CENC_INFO_KEY_IV_SUBSAMPLES_NOT_SET: DrmCencInfoMode = DrmCencInfoMode(1);
}
#[repr(transparent)]
/// Mode of cend info like set or not.
///
/// Available since API-level: 12
///
/// Version: 1.0
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct DrmCencInfoMode(pub ::core::ffi::c_uint);
/// Subsample info of media.
///
/// Available since API-level: 12
///
/// Version: 1.0
#[cfg(feature = "api-12")]
#[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct DrmSubsample {
    pub clearHeaderLen: u32,
    pub payLoadLen: u32,
}
extern "C" {
    /// Creates an OH_AVCencInfo instance for setting cencinfo.
    ///
    /// Free the resources of the instance by calling OH_AVCencInfo_Destory.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Spliter
    ///
    /// # Returns
    ///
    /// * Returns the newly created OH_AVCencInfo object. If nullptr is returned, the object failed to be created.
    /// The possible failure is due to the application address space being full,
    /// or the data in the initialization object has failed.
    ///
    /// Available since API-level: 12
    ///
    /// Version: 1.0
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AVCencInfo_Create() -> *mut OH_AVCencInfo;
    /// 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.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Spliter
    /// # Arguments
    ///
    /// * `cencInfo` - Pointer to an OH_AVCencInfo instance.
    ///
    /// # Returns
    ///
    /// * [`AV_ERR_OK`] 0 - Success
    /// [`AV_ERR_INVALID_VAL`] 3 - cencInfo is nullptr.
    ///
    /// Available since API-level: 12
    ///
    /// Version: 1.0
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AVCencInfo_Destroy(cencInfo: *mut OH_AVCencInfo) -> OH_AVErrCode;
    /// Method to set algo of cencinfo.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Spliter
    /// # Arguments
    ///
    /// * `cencInfo` - Pointer to an OH_AVCencInfo instance.
    ///
    /// * `algo` - Cenc algo.
    ///
    /// # Returns
    ///
    /// * [`AV_ERR_OK`] 0 - Success
    /// [`AV_ERR_INVALID_VAL`] 3 - cencInfo is nullptr.
    ///
    /// Available since API-level: 12
    ///
    /// Version: 1.0
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AVCencInfo_SetAlgorithm(
        cencInfo: *mut OH_AVCencInfo,
        algo: DrmCencAlgorithm,
    ) -> OH_AVErrCode;
    /// Method to set key id and iv of cencinfo.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Spliter
    /// # Arguments
    ///
    /// * `cencInfo` - Pointer to an OH_AVCencInfo instance.
    ///
    /// * `keyId` - Key id.
    ///
    /// * `keyIdLen` - Key id len.
    ///
    /// * `iv` - Iv.
    ///
    /// * `ivLen` - Iv len.
    ///
    /// # Returns
    ///
    /// * [`AV_ERR_OK`] 0 - Success
    /// [`AV_ERR_INVALID_VAL`] 3 - If cencInfo is nullptr, or keyId is nullptr, or keyIdLen != DRM_KEY_ID_SIZE,
    /// or iv is nullptr, or ivLen != DRM_KEY_IV_SIZE, or keyId copy fails, or iv copy fails.
    ///
    /// Available since API-level: 12
    ///
    /// Version: 1.0
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AVCencInfo_SetKeyIdAndIv(
        cencInfo: *mut OH_AVCencInfo,
        keyId: *mut u8,
        keyIdLen: u32,
        iv: *mut u8,
        ivLen: u32,
    ) -> OH_AVErrCode;
    /// Method to set subsample info of cencinfo.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Spliter
    /// # Arguments
    ///
    /// * `cencInfo` - Pointer to an OH_AVCencInfo instance.
    ///
    /// * `encryptedBlockCount` - Number of encrypted blocks.
    ///
    /// * `skippedBlockCount` - Number of skip(clear) blocks.
    ///
    /// * `firstEncryptedOffset` - Offset of first encrypted payload.
    ///
    /// * `subsampleCount` - Subsample num.
    ///
    /// * `subsamples` - Subsample info
    ///
    /// # Returns
    ///
    /// * [`AV_ERR_OK`] 0 - Success
    /// [`AV_ERR_INVALID_VAL`] 3 - If cencInfo is nullptr, or subsampleCount > DRM_KEY_MAX_SUB_SAMPLE_NUM,
    /// or subsamples is nullptr.
    ///
    /// Available since API-level: 12
    ///
    /// Version: 1.0
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AVCencInfo_SetSubsampleInfo(
        cencInfo: *mut OH_AVCencInfo,
        encryptedBlockCount: u32,
        skippedBlockCount: u32,
        firstEncryptedOffset: u32,
        subsampleCount: u32,
        subsamples: *mut DrmSubsample,
    ) -> OH_AVErrCode;
    /// Method to set mode of cencinfo.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Spliter
    /// # Arguments
    ///
    /// * `cencInfo` - Pointer to an OH_AVCencInfo instance.
    ///
    /// * `mode` - Cenc mode, indicate whether key/iv/subsample set or not.
    ///
    /// # Returns
    ///
    /// * [`AV_ERR_OK`] 0 - Success
    /// [`AV_ERR_INVALID_VAL`] 3 - cencInfo is nullptr.
    ///
    /// Available since API-level: 12
    ///
    /// Version: 1.0
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AVCencInfo_SetMode(
        cencInfo: *mut OH_AVCencInfo,
        mode: DrmCencInfoMode,
    ) -> OH_AVErrCode;
    /// Method to attach cencinfo to AVBuffer.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Spliter
    /// # Arguments
    ///
    /// * `cencInfo` - Pointer to an OH_AVCencInfo instance.
    ///
    /// * `buffer` - AVBuffer to attach cencinfo.
    ///
    /// # Returns
    ///
    /// * [`AV_ERR_OK`] 0 - Success
    /// [`AV_ERR_INVALID_VAL`] 3 - If cencInfo is nullptr, or buffer is nullptr, or buffer->buffer_ is nullptr,
    /// or buffer->buffer_->meta_ is nullptr.
    ///
    /// Available since API-level: 12
    ///
    /// Version: 1.0
    #[cfg(feature = "api-12")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-12")))]
    pub fn OH_AVCencInfo_SetAVBuffer(
        cencInfo: *mut OH_AVCencInfo,
        buffer: *mut OH_AVBuffer,
    ) -> OH_AVErrCode;
}