objc2-video-toolbox 0.3.2

Bindings to the VideoToolbox framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::cell::UnsafeCell;
use core::ffi::*;
use core::marker::{PhantomData, PhantomPinned};
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-video")]
use objc2_core_video::*;

use crate::*;

/// Video Toolbox HDR Metadata Generation Session
///
///
/// This file defines the public API for the VTHDRPerFrameMetadataGenerationSession.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vthdrperframemetadatagenerationhdrformattype?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type VTHDRPerFrameMetadataGenerationHDRFormatType = CFString;

extern "C" {
    /// Specifies that DolbyVision data should be generated and attached for each pixel buffer.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvthdrperframemetadatagenerationhdrformattype_dolbyvision?language=objc)
    pub static kVTHDRPerFrameMetadataGenerationHDRFormatType_DolbyVision:
        &'static VTHDRPerFrameMetadataGenerationHDRFormatType;
}

extern "C" {
    /// Specifies an array of HDR formats that should be generated.
    ///
    /// This key represents a CFArrayRef. Only one key is supported ( kVTHDRPerFrameMetadataGenerationHDRFormatType_DolbyVision ).
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvthdrperframemetadatagenerationoptionskey_hdrformats?language=objc)
    pub static kVTHDRPerFrameMetadataGenerationOptionsKey_HDRFormats: &'static CFString;
}

/// A mechanism for generating HDR Per Frame Metadata and attaching that metadata to a CVPixelBuffer and the backing IOSurface.
///
/// VTHDRPerFrameMetadataGenerationSessionRef is a CF type, so call CFRelease to release your object reference.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vthdrperframemetadatagenerationsession?language=objc)
#[doc(alias = "VTHDRPerFrameMetadataGenerationSessionRef")]
#[repr(C)]
pub struct VTHDRPerFrameMetadataGenerationSession {
    inner: [u8; 0],
    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}

cf_type!(
    unsafe impl VTHDRPerFrameMetadataGenerationSession {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
    unsafe impl RefEncode<"OpaqueVTHDRPerFrameMetadataGenerationSession">
        for VTHDRPerFrameMetadataGenerationSession
    {
    }
);

unsafe impl ConcreteType for VTHDRPerFrameMetadataGenerationSession {
    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionGetTypeID")]
    #[inline]
    fn type_id() -> CFTypeID {
        extern "C-unwind" {
            fn VTHDRPerFrameMetadataGenerationSessionGetTypeID() -> CFTypeID;
        }
        unsafe { VTHDRPerFrameMetadataGenerationSessionGetTypeID() }
    }
}

impl VTHDRPerFrameMetadataGenerationSession {
    /// Creates a VTHDRPerFrameMetadataGenerationSession object.
    ///
    /// The returned VTHDRPerFrameMetadataGenerationSession object may be used to perform HDR Per Frame Metadata Generation
    /// Call CFRelease to release your object reference.
    ///
    /// Parameter `framesPerSecond`: Value must be greater than 0.0
    ///
    /// Parameter `options`: CFDictionary may contain the key kVTHDRPerFrameMetadataGenerationOptionsHDRFormatsKey.
    ///
    /// # Safety
    ///
    /// - `options` generics must be of the correct type.
    /// - `hdr_per_frame_metadata_generation_session_out` must be a valid pointer.
    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionCreate")]
    #[inline]
    pub unsafe fn create(
        allocator: Option<&CFAllocator>,
        frames_per_second: c_float,
        options: Option<&CFDictionary>,
        hdr_per_frame_metadata_generation_session_out: NonNull<
            *mut VTHDRPerFrameMetadataGenerationSession,
        >,
    ) -> OSStatus {
        extern "C-unwind" {
            fn VTHDRPerFrameMetadataGenerationSessionCreate(
                allocator: Option<&CFAllocator>,
                frames_per_second: c_float,
                options: Option<&CFDictionary>,
                hdr_per_frame_metadata_generation_session_out: NonNull<
                    *mut VTHDRPerFrameMetadataGenerationSession,
                >,
            ) -> OSStatus;
        }
        unsafe {
            VTHDRPerFrameMetadataGenerationSessionCreate(
                allocator,
                frames_per_second,
                options,
                hdr_per_frame_metadata_generation_session_out,
            )
        }
    }

    /// Attaches the Per Frame Metadata to the CVPixelBuffer and the backing IOSurface
    ///
    /// Call this to analyze and attach HDR Metadata. This call will change CVPixelBuffer attachments and backing IOSurface attachments.
    ///
    /// Parameter `hdrPerFrameMetadataGenerationSession`:
    /// Parameter `pixelBuffer`:
    /// Parameter `sceneChange`: If this frame changes significantly in brightness from the previous frame, for example going from an indoor scene to an outdoor scene or
    /// from a night scene to a daytime scene, set this to true.
    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionAttachMetadata")]
    #[cfg(feature = "objc2-core-video")]
    #[inline]
    pub unsafe fn attach_metadata(
        &self,
        pixel_buffer: &CVPixelBuffer,
        scene_change: bool,
    ) -> OSStatus {
        extern "C-unwind" {
            fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
                hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
                pixel_buffer: &CVPixelBuffer,
                scene_change: Boolean,
            ) -> OSStatus;
        }
        unsafe {
            VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
                self,
                pixel_buffer,
                scene_change as _,
            )
        }
    }
}

extern "C-unwind" {
    #[deprecated = "renamed to `VTHDRPerFrameMetadataGenerationSession::create`"]
    pub fn VTHDRPerFrameMetadataGenerationSessionCreate(
        allocator: Option<&CFAllocator>,
        frames_per_second: c_float,
        options: Option<&CFDictionary>,
        hdr_per_frame_metadata_generation_session_out: NonNull<
            *mut VTHDRPerFrameMetadataGenerationSession,
        >,
    ) -> OSStatus;
}

#[cfg(feature = "objc2-core-video")]
#[deprecated = "renamed to `VTHDRPerFrameMetadataGenerationSession::attach_metadata`"]
#[inline]
pub unsafe extern "C-unwind" fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
    hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
    pixel_buffer: &CVPixelBuffer,
    scene_change: bool,
) -> OSStatus {
    extern "C-unwind" {
        fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
            hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
            pixel_buffer: &CVPixelBuffer,
            scene_change: Boolean,
        ) -> OSStatus;
    }
    unsafe {
        VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
            hdr_per_frame_metadata_generation_session,
            pixel_buffer,
            scene_change as _,
        )
    }
}