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::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "objc2")]
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
#[cfg(feature = "objc2-foundation")]
use objc2_foundation::*;

use crate::*;

#[cfg(feature = "objc2")]
extern_class!(
    /// An object you use to configure frame processor for low-latency super-resolution scaler processing.
    ///
    /// Use this object to configure a ``VTFrameProcessor``. Query this interface also for important operating details, like
    /// the pixel buffer attributes required for frames you submit to the processor.
    ///
    /// > Important: When calling ``VTFrameProcessor/startSessionWithConfiguration:error:`` to create a `VTLowLatencySuperResolutionScaler`
    /// session, ML model loading may take longer than a frame time. Avoid blocking the UI thread or stalling frame rendering
    /// pipelines during this call.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtlowlatencysuperresolutionscalerconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct VTLowLatencySuperResolutionScalerConfiguration;
);

#[cfg(feature = "objc2")]
unsafe impl Send for VTLowLatencySuperResolutionScalerConfiguration {}

#[cfg(feature = "objc2")]
unsafe impl Sync for VTLowLatencySuperResolutionScalerConfiguration {}

#[cfg(feature = "objc2")]
extern_conformance!(
    unsafe impl NSObjectProtocol for VTLowLatencySuperResolutionScalerConfiguration {}
);

#[cfg(all(feature = "VTFrameProcessorConfiguration", feature = "objc2"))]
extern_conformance!(
    unsafe impl VTFrameProcessorConfiguration for VTLowLatencySuperResolutionScalerConfiguration {}
);

#[cfg(feature = "objc2")]
impl VTLowLatencySuperResolutionScalerConfiguration {
    extern_methods!(
        /// Creates a new low-latency super-resolution scaler configuration with specified frame width and height.
        ///
        /// - Parameters:
        /// - frameWidth: Width of source frame in pixels.
        /// - frameHeight: Height of source frame in pixels.
        /// - scaleFactor: The scale factor to apply. This must be a supported value that ``supportedScaleFactorsForFrameWidth:frameHeight:`` returns.
        #[unsafe(method(initWithFrameWidth:frameHeight:scaleFactor:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrameWidth_frameHeight_scaleFactor(
            this: Allocated<Self>,
            frame_width: NSInteger,
            frame_height: NSInteger,
            scale_factor: c_float,
        ) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        /// Width of source frame in pixels.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(frameWidth))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameWidth(&self) -> NSInteger;

        /// Height of source frame in pixels.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(frameHeight))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameHeight(&self) -> NSInteger;

        #[cfg(feature = "objc2-foundation")]
        /// Available supported pixel formats for source frames for current configuration.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(frameSupportedPixelFormats))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameSupportedPixelFormats(&self) -> Retained<NSArray<NSNumber>>;

        #[cfg(feature = "objc2-foundation")]
        /// Pixel buffer attributes dictionary that describes requirements for pixel buffers which represent source frames and reference frames.
        ///
        /// Use ``CVPixelBufferCreateResolvedAttributesDictionary`` to combine this dictionary with your pixel buffer attributes dictionary.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(sourcePixelBufferAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn sourcePixelBufferAttributes(
            &self,
        ) -> Retained<NSDictionary<NSString, AnyObject>>;

        #[cfg(feature = "objc2-foundation")]
        /// Pixel buffer attributes dictionary that describes requirements for pixel buffers which represent destination frames.
        ///
        /// Use ``CVPixelBufferCreateResolvedAttributesDictionary`` to combine this dictionary with your pixel buffer attributes dictionary.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(destinationPixelBufferAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn destinationPixelBufferAttributes(
            &self,
        ) -> Retained<NSDictionary<NSString, AnyObject>>;

        /// Scale factor with which you initialized the configuration.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(scaleFactor))]
        #[unsafe(method_family = none)]
        pub unsafe fn scaleFactor(&self) -> c_float;

        #[cfg(feature = "objc2-core-media")]
        /// Maximum dimensions for a source frame for the processor.
        #[unsafe(method(maximumDimensions))]
        #[unsafe(method_family = none)]
        pub unsafe fn maximumDimensions() -> CMVideoDimensions;

        #[cfg(feature = "objc2-core-media")]
        /// Minimum dimensions for a source frame for the processor.
        #[unsafe(method(minimumDimensions))]
        #[unsafe(method_family = none)]
        pub unsafe fn minimumDimensions() -> CMVideoDimensions;

        /// Reports whether the system supports this processor on the current configuration.
        #[unsafe(method(isSupported))]
        #[unsafe(method_family = none)]
        pub unsafe fn isSupported() -> bool;

        #[cfg(feature = "objc2-foundation")]
        /// Returns an array of supported scale factors values, or an empty list if the processor doesn't support the dimensions.
        #[unsafe(method(supportedScaleFactorsForFrameWidth:frameHeight:))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportedScaleFactorsForFrameWidth_frameHeight(
            frame_width: NSInteger,
            frame_height: NSInteger,
        ) -> Retained<NSArray<NSNumber>>;
    );
}

#[cfg(feature = "objc2")]
extern_class!(
    /// An object that contains both input and output parameters that the low-latency super-resolution scaler frame processor needs.
    ///
    /// Use this object in the `processWithParameters` call of `VTFrameProcessor` class.
    ///
    /// `VTLowLatencySuperResolutionScalerParameters` are frame-level parameters.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtlowlatencysuperresolutionscalerparameters?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct VTLowLatencySuperResolutionScalerParameters;
);

#[cfg(feature = "objc2")]
extern_conformance!(
    unsafe impl NSObjectProtocol for VTLowLatencySuperResolutionScalerParameters {}
);

#[cfg(all(feature = "VTFrameProcessorParameters", feature = "objc2"))]
extern_conformance!(
    unsafe impl VTFrameProcessorParameters for VTLowLatencySuperResolutionScalerParameters {}
);

#[cfg(feature = "objc2")]
impl VTLowLatencySuperResolutionScalerParameters {
    extern_methods!(
        #[cfg(feature = "VTFrameProcessorFrame")]
        /// Creates a new low-latency, super-resolution scaler parameters object.
        ///
        /// - Parameters:
        /// - sourceFrame: Current source frame; must be non `nil`.
        /// - destinationFrame: User-allocated pixel buffer that receives the scaled processor output; must be non `nil`.
        #[unsafe(method(initWithSourceFrame:destinationFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSourceFrame_destinationFrame(
            this: Allocated<Self>,
            source_frame: &VTFrameProcessorFrame,
            destination_frame: &VTFrameProcessorFrame,
        ) -> Retained<Self>;

        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;

        #[cfg(feature = "VTFrameProcessorFrame")]
        /// Current source frame, which must be non `nil`.
        #[unsafe(method(sourceFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn sourceFrame(&self) -> Retained<VTFrameProcessorFrame>;

        #[cfg(feature = "VTFrameProcessorFrame")]
        /// Destination frame that contains user-allocated pixel buffer that receives the scaled processor output.
        #[unsafe(method(destinationFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn destinationFrame(&self) -> Retained<VTFrameProcessorFrame>;
    );
}