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)]
#[cfg(feature = "api-11")]
#[allow(unused_imports)]
use crate::avbuffer::OH_AVBuffer;
#[allow(unused_imports)]
use crate::avbuffer_info::OH_AVCodecBufferAttr;
#[allow(unused_imports)]
use crate::avcodec_base::OH_AVOutputFormat;
#[allow(unused_imports)]
use crate::averrors::OH_AVErrCode;
#[allow(unused_imports)]
use crate::avformat::OH_AVFormat;
#[allow(unused_imports)]
use crate::avmemory::OH_AVMemory;

/// Forward declaration of OH_AVMuxer.
///
///
/// Available since API-level: 10
#[repr(C)]
pub struct OH_AVMuxer {
    _unused: [u8; 0],
}
extern "C" {
    /// Create an OH_AVMuxer instance by output file description and format.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `fd` - Must be opened with read and write permission. Caller is responsible for closing fd.
    ///
    /// * `format` - The output format is [`OH_AVOutputFormat`] .
    ///
    /// # Returns
    ///
    /// * Returns a pointer to an OH_AVMuxer instance, needs to be freed by OH_AVMuxer_Destroy.
    ///
    /// Available since API-level: 10
    pub fn OH_AVMuxer_Create(fd: i32, format: OH_AVOutputFormat) -> *mut OH_AVMuxer;
    /// Set the rotation for output video playback.
    /// Note: This interface can only be called before OH_AVMuxer_Start.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `muxer` - Pointer to an OH_AVMuxer instance.
    ///
    /// * `rotation` - The supported angles are 0, 90, 180, and 270 degrees.
    ///
    /// # Returns
    ///
    /// * Returns AV_ERR_OK if the execution is successful,
    /// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
    /// [`AV_ERR_INVALID_VAL`], the muxer or rotation invalid.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
    ///
    /// Available since API-level: 10
    pub fn OH_AVMuxer_SetRotation(muxer: *mut OH_AVMuxer, rotation: i32) -> OH_AVErrCode;
    /// Set format to the muxer.
    ///
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `muxer` - Pointer to an OH_AVMuxer instance
    ///
    /// * `format` - OH_AVFormat handle pointer contain format
    ///
    /// # Returns
    ///
    /// * Returns AV_ERR_OK if the execution is successful
    /// [`AV_ERR_INVALID_VAL`], the muxer or format is invalid
    /// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state
    ///
    /// Available since API-level: 14
    #[cfg(feature = "api-14")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-14")))]
    pub fn OH_AVMuxer_SetFormat(muxer: *mut OH_AVMuxer, format: *mut OH_AVFormat) -> OH_AVErrCode;
    /// Add track format to the muxer.
    /// Note: This interface can only be called before OH_AVMuxer_Start.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `muxer` - Pointer to an OH_AVMuxer instance
    ///
    /// * `trackIndex` - The int32_t handle pointer used to get the track index for this newly added track,
    /// and it should be used in the OH_AVMuxer_WriteSample. The track index is greater than or equal to 0,
    /// others is error index.
    ///
    /// * `trackFormat` - OH_AVFormat handle pointer contain track format
    ///
    /// # Returns
    ///
    /// * Returns AV_ERR_OK if the execution is successful,
    /// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
    /// [`AV_ERR_INVALID_VAL`], the muxer or trackIndex or trackFormat invalid.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
    /// [`AV_ERR_UNSUPPORT`], the mime type is not supported.
    /// [`AV_ERR_NO_MEMORY`], failed to malloc memory.
    /// [`AV_ERR_UNKNOWN`], unknown error.
    ///
    /// Available since API-level: 10
    pub fn OH_AVMuxer_AddTrack(
        muxer: *mut OH_AVMuxer,
        trackIndex: *mut i32,
        trackFormat: *mut OH_AVFormat,
    ) -> OH_AVErrCode;
    /// Start the muxer.
    /// Note: This interface is called after OH_AVMuxer_AddTrack and before OH_AVMuxer_WriteSample.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `muxer` - Pointer to an OH_AVMuxer instance
    ///
    /// # Returns
    ///
    /// * Returns AV_ERR_OK if the execution is successful,
    /// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
    /// [`AV_ERR_INVALID_VAL`], the muxer invalid.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
    /// [`AV_ERR_UNKNOWN`], unknown error.
    ///
    /// Available since API-level: 10
    pub fn OH_AVMuxer_Start(muxer: *mut OH_AVMuxer) -> OH_AVErrCode;
    /// Write an encoded sample to the muxer.
    /// Note: This interface can only be called after OH_AVMuxer_Start and before OH_AVMuxer_Stop. The application needs to
    /// make sure that the samples are written to the right tacks. Also, it needs to make sure the samples for each track are
    /// written in chronological order.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `muxer` - Pointer to an OH_AVMuxer instance
    ///
    /// * `trackIndex` - The track index for this sample
    ///
    /// * `sample` - The encoded or demuxer sample
    ///
    /// * `info` - The buffer information related to this sample [`OH_AVCodecBufferAttr`]
    ///
    /// # Returns
    ///
    /// * Returns AV_ERR_OK if the execution is successful,
    /// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
    /// [`AV_ERR_INVALID_VAL`], the muxer or trackIndex or sample or info invalid.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
    /// [`AV_ERR_NO_MEMORY`], failed to request memory.
    /// [`AV_ERR_UNKNOWN`], unknown error.
    ///
    /// **Deprecated** since 11
    /// OH_AVMuxer_WriteSampleBuffer
    ///
    /// Available since API-level: 10
    #[deprecated(since = "11")]
    pub fn OH_AVMuxer_WriteSample(
        muxer: *mut OH_AVMuxer,
        trackIndex: u32,
        sample: *mut OH_AVMemory,
        info: OH_AVCodecBufferAttr,
    ) -> OH_AVErrCode;
    /// Write an encoded sample to the muxer.
    /// Note: This interface can only be called after OH_AVMuxer_Start and before OH_AVMuxer_Stop. The application needs to
    /// make sure that the samples are written to the right tracks. Also, it needs to make sure the samples for each track
    /// are written in chronological order.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `muxer` - Pointer to an OH_AVMuxer instance
    ///
    /// * `trackIndex` - The track index for this sample
    ///
    /// * `sample` - The encoded or demuxer sample, which including data and buffer information
    ///
    /// # Returns
    ///
    /// * Returns AV_ERR_OK if the execution is successful,
    /// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
    /// [`AV_ERR_INVALID_VAL`], the muxer or trackIndex or sample invalid.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
    /// [`AV_ERR_NO_MEMORY`], failed to request memory.
    /// [`AV_ERR_UNKNOWN`], unknown error.
    ///
    /// Available since API-level: 11
    #[cfg(feature = "api-11")]
    #[cfg_attr(docsrs, doc(cfg(feature = "api-11")))]
    pub fn OH_AVMuxer_WriteSampleBuffer(
        muxer: *mut OH_AVMuxer,
        trackIndex: u32,
        sample: *const OH_AVBuffer,
    ) -> OH_AVErrCode;
    /// Stop the muxer.
    /// Note: Once the muxer stops, it can not be restarted.
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `muxer` - Pointer to an OH_AVMuxer instance
    ///
    /// # Returns
    ///
    /// * Returns AV_ERR_OK if the execution is successful,
    /// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
    /// [`AV_ERR_INVALID_VAL`], the muxer invalid.
    /// [`AV_ERR_OPERATE_NOT_PERMIT`], not permit to call the interface, it was called in invalid state.
    ///
    /// Available since API-level: 10
    pub fn OH_AVMuxer_Stop(muxer: *mut OH_AVMuxer) -> OH_AVErrCode;
    /// Clear the internal resources of the muxer and destroy the muxer instance
    ///
    /// Required System Capabilities: SystemCapability.Multimedia.Media.Muxer
    /// # Arguments
    ///
    /// * `muxer` - Pointer to an OH_AVMuxer instance
    ///
    /// # Returns
    ///
    /// * Returns AV_ERR_OK if the execution is successful,
    /// otherwise returns a specific error code, refer to [`OH_AVErrCode`]
    /// [`AV_ERR_INVALID_VAL`], the muxer invalid.
    ///
    /// Available since API-level: 10
    pub fn OH_AVMuxer_Destroy(muxer: *mut OH_AVMuxer) -> OH_AVErrCode;
}