openh264-sys2 0.9.6

Low-level bindings for OpenH264.
Documentation
/* automatically generated by rust-bindgen 0.71.1 */

use super::types::*;

pub struct APILoader {
    __library: ::libloading::Library,
    pub WelsCreateSVCEncoder:
        Result<unsafe extern "C" fn(ppEncoder: *mut *mut ISVCEncoder) -> ::std::os::raw::c_int, ::libloading::Error>,
    pub WelsDestroySVCEncoder: Result<unsafe extern "C" fn(pEncoder: *mut ISVCEncoder), ::libloading::Error>,
    pub WelsGetDecoderCapability:
        Result<unsafe extern "C" fn(pDecCapability: *mut SDecoderCapability) -> ::std::os::raw::c_int, ::libloading::Error>,
    pub WelsCreateDecoder:
        Result<unsafe extern "C" fn(ppDecoder: *mut *mut ISVCDecoder) -> ::std::os::raw::c_long, ::libloading::Error>,
    pub WelsDestroyDecoder: Result<unsafe extern "C" fn(pDecoder: *mut ISVCDecoder), ::libloading::Error>,
    pub WelsGetCodecVersion: Result<unsafe extern "C" fn() -> OpenH264Version, ::libloading::Error>,
    pub WelsGetCodecVersionEx: Result<unsafe extern "C" fn(pVersion: *mut OpenH264Version), ::libloading::Error>,
}
impl APILoader {
    pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
    where
        P: AsRef<::std::ffi::OsStr>,
    {
        let library = unsafe { ::libloading::Library::new(path) }?;
        unsafe { Self::from_library(library) }
    }
    pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
    where
        L: Into<::libloading::Library>,
    {
        let __library = library.into();
        let WelsCreateSVCEncoder = unsafe { __library.get(b"WelsCreateSVCEncoder\0") }.map(|sym| *sym);
        let WelsDestroySVCEncoder = unsafe { __library.get(b"WelsDestroySVCEncoder\0") }.map(|sym| *sym);
        let WelsGetDecoderCapability = unsafe { __library.get(b"WelsGetDecoderCapability\0") }.map(|sym| *sym);
        let WelsCreateDecoder = unsafe { __library.get(b"WelsCreateDecoder\0") }.map(|sym| *sym);
        let WelsDestroyDecoder = unsafe { __library.get(b"WelsDestroyDecoder\0") }.map(|sym| *sym);
        let WelsGetCodecVersion = unsafe { __library.get(b"WelsGetCodecVersion\0") }.map(|sym| *sym);
        let WelsGetCodecVersionEx = unsafe { __library.get(b"WelsGetCodecVersionEx\0") }.map(|sym| *sym);
        Ok(APILoader {
            __library,
            WelsCreateSVCEncoder,
            WelsDestroySVCEncoder,
            WelsGetDecoderCapability,
            WelsCreateDecoder,
            WelsDestroyDecoder,
            WelsGetCodecVersion,
            WelsGetCodecVersionEx,
        })
    }
    #[doc = " @brief   Create encoder\n  @param   ppEncoder encoder\n  @return  0 - success; otherwise - failed;"]
    pub unsafe fn WelsCreateSVCEncoder(&self, ppEncoder: *mut *mut ISVCEncoder) -> ::std::os::raw::c_int {
        unsafe { (self.WelsCreateSVCEncoder.as_ref().expect("Expected function, got error."))(ppEncoder) }
    }
    #[doc = " @brief   Destroy encoder\n   @param   pEncoder encoder\n  @return  void"]
    pub unsafe fn WelsDestroySVCEncoder(&self, pEncoder: *mut ISVCEncoder) {
        unsafe { (self.WelsDestroySVCEncoder.as_ref().expect("Expected function, got error."))(pEncoder) }
    }
    #[doc = " @brief   Get the capability of decoder\n  @param   pDecCapability  decoder capability\n  @return  0 - success; otherwise - failed;"]
    pub unsafe fn WelsGetDecoderCapability(&self, pDecCapability: *mut SDecoderCapability) -> ::std::os::raw::c_int {
        unsafe { (self.WelsGetDecoderCapability.as_ref().expect("Expected function, got error."))(pDecCapability) }
    }
    #[doc = " @brief   Create decoder\n  @param   ppDecoder decoder\n  @return  0 - success; otherwise - failed;"]
    pub unsafe fn WelsCreateDecoder(&self, ppDecoder: *mut *mut ISVCDecoder) -> ::std::os::raw::c_long {
        unsafe { (self.WelsCreateDecoder.as_ref().expect("Expected function, got error."))(ppDecoder) }
    }
    #[doc = " @brief   Destroy decoder\n  @param   pDecoder  decoder\n  @return  void"]
    pub unsafe fn WelsDestroyDecoder(&self, pDecoder: *mut ISVCDecoder) {
        unsafe { (self.WelsDestroyDecoder.as_ref().expect("Expected function, got error."))(pDecoder) }
    }
    #[doc = " @brief   Get codec version\n           Note, old versions of Mingw (GCC < 4.7) are buggy and use an\n           incorrect/different ABI for calling this function, making it\n           incompatible with MSVC builds.\n  @return  The linked codec version"]
    pub unsafe fn WelsGetCodecVersion(&self) -> OpenH264Version {
        unsafe { (self.WelsGetCodecVersion.as_ref().expect("Expected function, got error."))() }
    }
    #[doc = " @brief   Get codec version\n  @param   pVersion  struct to fill in with the version"]
    pub unsafe fn WelsGetCodecVersionEx(&self, pVersion: *mut OpenH264Version) {
        unsafe { (self.WelsGetCodecVersionEx.as_ref().expect("Expected function, got error."))(pVersion) }
    }
}