objc2-vision 0.3.2

Bindings to the Vision framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// An object that defines the cadence at which the video stream is processed.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnvideoprocessorcadence?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct VNVideoProcessorCadence;
);

extern_conformance!(
    unsafe impl NSCopying for VNVideoProcessorCadence {}
);

unsafe impl CopyingHelper for VNVideoProcessorCadence {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for VNVideoProcessorCadence {}
);

impl VNVideoProcessorCadence {
    extern_methods!();
}

/// Methods declared on superclass `NSObject`.
impl VNVideoProcessorCadence {
    extern_methods!(
        #[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>;
    );
}

extern_class!(
    /// An object that defines a frame-based cadence for processing the video stream.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnvideoprocessorframeratecadence?language=objc)
    #[unsafe(super(VNVideoProcessorCadence, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct VNVideoProcessorFrameRateCadence;
);

extern_conformance!(
    unsafe impl NSCopying for VNVideoProcessorFrameRateCadence {}
);

unsafe impl CopyingHelper for VNVideoProcessorFrameRateCadence {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for VNVideoProcessorFrameRateCadence {}
);

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

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

        #[unsafe(method(frameRate))]
        #[unsafe(method_family = none)]
        pub unsafe fn frameRate(&self) -> NSInteger;
    );
}

/// Methods declared on superclass `NSObject`.
impl VNVideoProcessorFrameRateCadence {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// An object that defines a time-based cadence for processing the video stream.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnvideoprocessortimeintervalcadence?language=objc)
    #[unsafe(super(VNVideoProcessorCadence, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct VNVideoProcessorTimeIntervalCadence;
);

extern_conformance!(
    unsafe impl NSCopying for VNVideoProcessorTimeIntervalCadence {}
);

unsafe impl CopyingHelper for VNVideoProcessorTimeIntervalCadence {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for VNVideoProcessorTimeIntervalCadence {}
);

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

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(initWithTimeInterval:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTimeInterval(
            this: Allocated<Self>,
            time_interval: CFTimeInterval,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(timeInterval))]
        #[unsafe(method_family = none)]
        pub unsafe fn timeInterval(&self) -> CFTimeInterval;
    );
}

/// Methods declared on superclass `NSObject`.
impl VNVideoProcessorTimeIntervalCadence {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Options applied to a request's processing of the video.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnvideoprocessorrequestprocessingoptions?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct VNVideoProcessorRequestProcessingOptions;
);

extern_conformance!(
    unsafe impl NSCopying for VNVideoProcessorRequestProcessingOptions {}
);

unsafe impl CopyingHelper for VNVideoProcessorRequestProcessingOptions {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for VNVideoProcessorRequestProcessingOptions {}
);

impl VNVideoProcessorRequestProcessingOptions {
    extern_methods!(
        /// The cadence at which the request should be performed.
        ///
        /// If this property is not defined, then every frame will be processed.
        #[unsafe(method(cadence))]
        #[unsafe(method_family = none)]
        pub unsafe fn cadence(&self) -> Option<Retained<VNVideoProcessorCadence>>;

        /// Setter for [`cadence`][Self::cadence].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setCadence:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setCadence(&self, cadence: Option<&VNVideoProcessorCadence>);
    );
}

/// Methods declared on superclass `NSObject`.
impl VNVideoProcessorRequestProcessingOptions {
    extern_methods!(
        #[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>;
    );
}

extern_class!(
    /// A controller object that is used to perform one or more requests on a video stream.
    ///
    /// VNVideoProcessor handles the video decoding and buffer management, feeding the buffers to the associated requests at the best desired frame rate.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/vision/vnvideoprocessor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct VNVideoProcessor;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for VNVideoProcessor {}
);

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

        /// Creates a VNVideoProcessor to be used for performing requests against a video asset specified by it's URL.
        ///
        ///
        /// Parameter `videoURL`: A URL pointing at a video asset on which the requests will be performed. The video format has to be supported by AVFoundation.
        #[unsafe(method(initWithURL:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithURL(this: Allocated<Self>, video_url: &NSURL) -> Retained<Self>;

        #[cfg(feature = "VNRequest")]
        /// Add a VNRequest with the specified processing options to be performed on the video.
        ///
        /// This method can be called either before calling -analyzeTimeRange:error: or from within one of the already associated request's completion handlers.
        ///
        ///
        /// Parameter `request`: The VNRequest to be added to the processing pipeline. If added from within a completionHandler, it will be processed on the same frame that is currently being processed.
        ///
        /// Parameter `processingOptions`: The options applied to the request's processing of the video.
        ///
        /// Parameter `error`: Returns an error that happened during scheduling of the requests. Check individual requests results and errors for their respective success and failures. This parameter is optional.
        ///
        /// Returns: Returns true if the request added to the processing pipeline.
        ///
        /// Note: The VNRequest must have completion handler set otherwise no results can be returned.
        #[unsafe(method(addRequest:processingOptions:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn addRequest_processingOptions_error(
            &self,
            request: &VNRequest,
            processing_options: &VNVideoProcessorRequestProcessingOptions,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(all(feature = "VNRequest", feature = "VNTypes"))]
        /// # Safety
        ///
        /// `processing_options` generic should be of the correct type.
        #[deprecated]
        #[unsafe(method(addRequest:withProcessingOptions:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn addRequest_withProcessingOptions_error(
            &self,
            request: &VNRequest,
            processing_options: &NSDictionary<VNVideoProcessingOption, AnyObject>,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "VNRequest")]
        /// Remove a VNRequest from the video processor, which means it won't be performed anymore.
        ///
        /// This method can be called either before calling -analyzeTimeRange:error: or from within one of the already associated request's completion handlers.
        ///
        ///
        /// Parameter `request`: The VNRequest to be removed from the processing pipeline.
        ///
        /// Parameter `error`: Returns an error that happened during processing of the request, such as if the request was not found in the processing queue. This parameter is optional.
        ///
        /// Returns: Returns true if the request was found and removed from the processing pipeline.
        #[unsafe(method(removeRequest:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeRequest_error(
            &self,
            request: &VNRequest,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "objc2-core-media")]
        /// Processes the video over the specified time range.
        ///
        /// This call is synchronous and only returns after the video is processed through its duration or an error prevented the processing.
        ///
        ///
        /// Parameter `timeRange`: Start and duration of the timerange within video to process. If the duration is longer than the video (e.g., kCMTimeIndefinite) the processing stops at the end of the video.
        ///
        /// Parameter `error`: Returns an error that happened during the starting of the processing queue (for instance if the time range is not valid for the video asset). This parameter is optional.
        ///
        /// Returns: Returns true if all requests were scheduled and performed. Check individual requests results and errors for their respective success and failures.
        ///
        /// Note: The intersection of the CMTimeRangeMake(start, duration) and CMTimeRangeMake(kCMTimeZero, asset.duration) will determine the timerange of the video to process
        #[unsafe(method(analyzeTimeRange:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn analyzeTimeRange_error(
            &self,
            time_range: CMTimeRange,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(feature = "objc2-core-media")]
        #[deprecated]
        #[unsafe(method(analyzeWithTimeRange:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn analyzeWithTimeRange_error(
            &self,
            time_range: CMTimeRange,
        ) -> Result<(), Retained<NSError>>;

        /// Cancel the processing of the video. This can return before the last request has completed.
        #[unsafe(method(cancel))]
        #[unsafe(method_family = none)]
        pub unsafe fn cancel(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl VNVideoProcessor {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}