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

use crate::*;

#[cfg(feature = "objc2")]
extern_class!(
    /// Configuration that you use to program Video Toolbox frame processor for low-latency frame interpolation.
    ///
    /// This configuration can do either purely temporal interpolation (frame-rate conversion) or temporal and spatial
    /// interpolation (scaling and frame-rate conversion). This processor requires a source frame and a previous frame. It
    /// does temporal scaling, which interpolates frames between the previous frame and the source frame. When performing
    /// both temporal and spatial interpolation, the processor can only perform 2x upscaling, and a single frame of temporal
    /// interpolation. When performing spatial scaling, the processor produces upscaled intermediate frames and an upscaled
    /// `sourceFrame`, but it does not upscale the previous reference frame you provided.
    ///
    /// > Important: When calling ``VTFrameProcessor/startSessionWithConfiguration:error:`` to create a `VTLowLatencyFrameInterpolation`
    /// 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/vtlowlatencyframeinterpolationconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct VTLowLatencyFrameInterpolationConfiguration;
);

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

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

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

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

#[cfg(feature = "objc2")]
impl VTLowLatencyFrameInterpolationConfiguration {
    extern_methods!(
        /// Creates a new low-latency frame interpolation configuration for frame-rate conversion.
        ///
        /// The available interpolation points are the equal to the value of (2^x - 1), where x is equal to `numberOfInterpolatedFrames`.
        /// For example,
        /// - If you request 1 interpolated frame, 1 interpolation point at 0.5 is available.
        /// - If you request 2 interpolated frames, 3 interpolation points at 0.25, 0.5 and 0.75 are available.
        /// You don't need to use all available interpolation points. Setting a higher `numberOfInterpolatedFrames` increases
        /// the resolution of interpolation in some cases, but also increases latency.
        ///
        /// - Parameters:
        /// - frameWidth: Width of source frame in pixels.
        /// - frameHeight: Height of source frame in pixels.
        /// - numberOfInterpolatedFrames: The number of uniformly spaced frames that you want to be used for interpolation.
        #[unsafe(method(initWithFrameWidth:frameHeight:numberOfInterpolatedFrames:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrameWidth_frameHeight_numberOfInterpolatedFrames(
            this: Allocated<Self>,
            frame_width: NSInteger,
            frame_height: NSInteger,
            number_of_interpolated_frames: NSInteger,
        ) -> Option<Retained<Self>>;

        /// Creates a new low-latency frame interpolation configuration for spatial scaling and temporal scaling.
        ///
        /// When you configure the processor for spatial scaling, the low-latency frame interpolation processor only supports 2x
        /// spatial upscaling and a single frame of temporal interpolation at a 0.5 interpolation phase.
        ///
        /// - Parameters:
        /// - frameWidth: Width of source frame in pixels.
        /// - frameHeight: Height of source frame in pixels.
        /// - spatialScaleFactor: The requested spatial scale factor as an integer. Currently, the processor supports only 2x spatial scaling.
        #[unsafe(method(initWithFrameWidth:frameHeight:spatialScaleFactor:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrameWidth_frameHeight_spatialScaleFactor(
            this: Allocated<Self>,
            frame_width: NSInteger,
            frame_height: NSInteger,
            spatial_scale_factor: NSInteger,
        ) -> Option<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 frames 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 frames 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;

        /// Configured spatial scale factor as an integer.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(spatialScaleFactor))]
        #[unsafe(method_family = none)]
        pub unsafe fn spatialScaleFactor(&self) -> NSInteger;

        /// Number of uniformly spaced frames for which you configured the processor.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(numberOfInterpolatedFrames))]
        #[unsafe(method_family = none)]
        pub unsafe fn numberOfInterpolatedFrames(&self) -> NSInteger;

        #[cfg(feature = "objc2-foundation")]
        /// Available supported pixel formats 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>>;

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

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

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

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

#[cfg(feature = "objc2")]
impl VTLowLatencyFrameInterpolationParameters {
    extern_methods!(
        #[cfg(all(feature = "VTFrameProcessorFrame", feature = "objc2-foundation"))]
        /// Creates a new low-latency frame interpolation parameters object.
        ///
        /// - Parameters:
        /// - sourceFrame: Current frame to use for interpolation; must be non `nil`.
        /// - previousFrame: Previous frame used for interpolation; must be non `nil`.
        /// - interpolationPhase: Array of float numbers that indicate interpolation phase locations at which the processor
        /// interpolates the frames. Must be greater than 0 and less than 1.0; for example 0.5 is midway between the previous
        /// frame and the source frame. If you enable spatial scaling, the only supported interpolation phase is 0.5.
        /// - destinationFrames: Caller-allocated array of `VTFrameProcessorFrame` to receive the interpolated frames. This
        /// must have the same number of elements as the the `interpolationPhase`. If you enable spatial scaling, it must also
        /// contain an element to hold the scaled version of sourceFrame.
        #[unsafe(method(initWithSourceFrame:previousFrame:interpolationPhase:destinationFrames:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSourceFrame_previousFrame_interpolationPhase_destinationFrames(
            this: Allocated<Self>,
            source_frame: &VTFrameProcessorFrame,
            previous_frame: &VTFrameProcessorFrame,
            interpolation_phase: &NSArray<NSNumber>,
            destination_frames: &NSArray<VTFrameProcessorFrame>,
        ) -> Option<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")]
        /// Source frame that you provided when creating the low-latency frame interpolation parameters object.
        #[unsafe(method(sourceFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn sourceFrame(&self) -> Retained<VTFrameProcessorFrame>;

        #[cfg(feature = "VTFrameProcessorFrame")]
        /// Previous frame that you provided when creating the low-latency frame interpolation parameters object.
        #[unsafe(method(previousFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn previousFrame(&self) -> Retained<VTFrameProcessorFrame>;

        #[cfg(feature = "objc2-foundation")]
        /// Array of interpolation phases that you provided when creating the low-latency frame interpolation parameters object.
        #[unsafe(method(interpolationPhase))]
        #[unsafe(method_family = none)]
        pub unsafe fn interpolationPhase(&self) -> Retained<NSArray<NSNumber>>;

        #[cfg(all(feature = "VTFrameProcessorFrame", feature = "objc2-foundation"))]
        /// Array of destination frames that you provided when creating the low-latency frame interpolation parameters object.
        #[unsafe(method(destinationFrames))]
        #[unsafe(method_family = none)]
        pub unsafe fn destinationFrames(&self) -> Retained<NSArray<VTFrameProcessorFrame>>;
    );
}