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::*;

/// Configuration value you set to prioritize quality or performance.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowconfigurationqualityprioritization?language=objc)
// NS_ENUM
#[cfg(feature = "objc2")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VTOpticalFlowConfigurationQualityPrioritization(pub NSInteger);
#[cfg(feature = "objc2")]
impl VTOpticalFlowConfigurationQualityPrioritization {
    #[doc(alias = "VTOpticalFlowConfigurationQualityPrioritizationNormal")]
    pub const Normal: Self = Self(1);
    #[doc(alias = "VTOpticalFlowConfigurationQualityPrioritizationQuality")]
    pub const Quality: Self = Self(2);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for VTOpticalFlowConfigurationQualityPrioritization {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for VTOpticalFlowConfigurationQualityPrioritization {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Available algorithm revisions.
///
/// A new enum case with higher revision number is added when the processing algorithm is updated.
/// The ``VTOpticalFlowConfiguration/defaultRevision`` property provides the default algorithm revision.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowconfigurationrevision?language=objc)
// NS_ENUM
#[cfg(feature = "objc2")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VTOpticalFlowConfigurationRevision(pub NSInteger);
#[cfg(feature = "objc2")]
impl VTOpticalFlowConfigurationRevision {
    #[doc(alias = "VTOpticalFlowConfigurationRevision1")]
    pub const Revision1: Self = Self(1);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for VTOpticalFlowConfigurationRevision {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for VTOpticalFlowConfigurationRevision {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// Indicates the order of input frames.
///
/// When submitting ``VTOpticalFlowParameters`` to the processor, you need to provide one of these values based on how
/// the input frames are related to each other.
///
/// Use ``VTOpticalFlowParametersSubmissionModeSequential`` to indicate that the current submission follows presentation
/// time order without jump or skip, when compared to previous submissions. This value provides better processor
/// performance than other values.
///
/// Use ``VTOpticalFlowParametersSubmissionModeRandom`` to indicate that the current submission has no relation to the
/// previous submission. Typically, this indicates a jump or a skip in the frame sequence. The processor clears internal
/// caches when it receives this value in ``VTFrameProcessor/processWithParameters`` function call.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowparameterssubmissionmode?language=objc)
// NS_ENUM
#[cfg(feature = "objc2")]
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct VTOpticalFlowParametersSubmissionMode(pub NSInteger);
#[cfg(feature = "objc2")]
impl VTOpticalFlowParametersSubmissionMode {
    #[doc(alias = "VTOpticalFlowParametersSubmissionModeRandom")]
    pub const Random: Self = Self(1);
    #[doc(alias = "VTOpticalFlowParametersSubmissionModeSequential")]
    pub const Sequential: Self = Self(2);
}

#[cfg(feature = "objc2")]
unsafe impl Encode for VTOpticalFlowParametersSubmissionMode {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

#[cfg(feature = "objc2")]
unsafe impl RefEncode for VTOpticalFlowParametersSubmissionMode {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

#[cfg(feature = "objc2")]
extern_class!(
    /// Configuration that you use to set up an optical flow processor
    ///
    /// This configuration enables the optical flow on a `VTFrameProcessor` session.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct VTOpticalFlowConfiguration;
);

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

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

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

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

#[cfg(feature = "objc2")]
impl VTOpticalFlowConfiguration {
    extern_methods!(
        /// Creates a new optical flow configuration.
        ///
        /// Returns ``nil`` if dimensions are out of range or revision is unsupported.
        ///
        /// - Parameters:
        /// - frameWidth: Width of source frame in pixels; the maximum value is 8192 for macOS, and 4096 for iOS.
        /// - frameHeight: Height of source frame in pixels; the maximum value is 4320 for macOS, and 2160 for iOS.
        /// - qualityPrioritization: A level you use to prioritize quality or performance; for more information about supported
        /// levels, see ``VTOpticalFlowConfigurationQualityPrioritization``.
        /// - revision: The specific algorithm or configuration revision you use to perform the request.
        #[unsafe(method(initWithFrameWidth:frameHeight:qualityPrioritization:revision:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrameWidth_frameHeight_qualityPrioritization_revision(
            this: Allocated<Self>,
            frame_width: NSInteger,
            frame_height: NSInteger,
            quality_prioritization: VTOpticalFlowConfigurationQualityPrioritization,
            revision: VTOpticalFlowConfigurationRevision,
        ) -> 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 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;

        /// A parameter you use to control quality and performance levels.
        ///
        /// For more information about supported levels, see ``VTOpticalFlowConfigurationQualityPrioritization``.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(qualityPrioritization))]
        #[unsafe(method_family = none)]
        pub unsafe fn qualityPrioritization(
            &self,
        ) -> VTOpticalFlowConfigurationQualityPrioritization;

        /// The specific algorithm or configuration revision you use to perform the request.
        ///
        /// This property is not atomic.
        ///
        /// # Safety
        ///
        /// This might not be thread-safe.
        #[unsafe(method(revision))]
        #[unsafe(method_family = none)]
        pub unsafe fn revision(&self) -> VTOpticalFlowConfigurationRevision;

        #[cfg(feature = "objc2-foundation")]
        /// Provides the collection of currently supported algorithms or configuration revisions for the class of configuration.
        ///
        /// A property you use to introspect at runtime which revisions are available for each configuration.
        #[unsafe(method(supportedRevisions))]
        #[unsafe(method_family = none)]
        pub unsafe fn supportedRevisions() -> Retained<NSIndexSet>;

        /// Provides the default revision of a specific algorithm or configuration.
        #[unsafe(method(defaultRevision))]
        #[unsafe(method_family = none)]
        pub unsafe fn defaultRevision() -> VTOpticalFlowConfigurationRevision;

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

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

        #[deprecated]
        #[unsafe(method(processorSupported))]
        #[unsafe(method_family = none)]
        pub unsafe fn processorSupported() -> Boolean;
    );
}

#[cfg(feature = "objc2")]
extern_class!(
    /// An object that contains both input and output parameters the frame processor needs to generate optical flow between two frames.
    ///
    /// Use this object in the `processWithParameters` call of `VTFrameProcessor` class. The output parameter for this class is `destinationOpticalFlow` where the processor returns the output flow (as mutable `VTFrameProcessorOpticalFlow`) back to you once the `processWithParameters` completes.
    ///
    /// `VTOpticalFlowParameters` are frame-level parameters.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtopticalflowparameters?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct VTOpticalFlowParameters;
);

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

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

#[cfg(feature = "objc2")]
impl VTOpticalFlowParameters {
    extern_methods!(
        #[cfg(feature = "VTFrameProcessorFrame")]
        /// Creates a new optical flow parameters object.
        ///
        /// Returns `nil` if `sourceFrame` or `nextFrame` is `nil`, or if `sourceFrame` and `nextFrame` have different pixel formats.
        ///
        /// - Parameters:
        /// - sourceFrame: Current source frame; must be non `nil`.
        /// - nextFrame: Next source frame in presentation time order.
        /// - submissionMode: Provides a hint to let the processor know whether you are submitting frames in presentation
        /// sequence. For more information about supported modes see ``VTOpticalFlowParametersSubmissionMode``.
        /// - destinationOpticalFlow: User allocated `VTFrameProcessorOpticalFlow` that receives the results.
        #[unsafe(method(initWithSourceFrame:nextFrame:submissionMode:destinationOpticalFlow:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSourceFrame_nextFrame_submissionMode_destinationOpticalFlow(
            this: Allocated<Self>,
            source_frame: &VTFrameProcessorFrame,
            next_frame: &VTFrameProcessorFrame,
            submission_mode: VTOpticalFlowParametersSubmissionMode,
            destination_optical_flow: &VTFrameProcessorOpticalFlow,
        ) -> 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")]
        /// 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")]
        /// The next source frame in presentation time order.
        #[unsafe(method(nextFrame))]
        #[unsafe(method_family = none)]
        pub unsafe fn nextFrame(&self) -> Retained<VTFrameProcessorFrame>;

        /// Ordering of the input frames in this submission relative to the previous submission.
        #[unsafe(method(submissionMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn submissionMode(&self) -> VTOpticalFlowParametersSubmissionMode;

        #[cfg(feature = "VTFrameProcessorFrame")]
        /// Output optical flow calculated by the processor.
        #[unsafe(method(destinationOpticalFlow))]
        #[unsafe(method_family = none)]
        pub unsafe fn destinationOpticalFlow(&self) -> Retained<VTFrameProcessorOpticalFlow>;
    );
}