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::*;
#[cfg(feature = "objc2-metal")]
use objc2_metal::*;

use crate::*;

#[cfg(feature = "objc2")]
extern_class!(
    /// Provides a unified interface you can use to apply video effects to frames.
    ///
    /// The VTFrameProcessor gives access to a set of powerful video processing implementation suitable for different use cases.
    /// A configuration object (conforming to the ``VTFrameProcessorConfiguration`` protocol) passes initialization and
    /// configuration parameters for the processor. A Parameter object (conforming to the ``VTFrameProcessorParameters``
    /// protocol) provides the parameters for each individual processing operation. A Configuration object and a Parameter
    /// object define each processor implementation. These Configuration and Parameters objects for each implementation are
    /// defined in a processor-specific header file.
    ///
    /// Use an instance of this class to apply configured video effects either directly to pixel buffers or as a
    /// part of Metal pipeline. The video effect must be specified as a ``VTFrameProcessorConfiguration`` instance at session
    /// startup. Once a session is started, you need to call one of the process methods for each input frame. After all input
    /// frames have been provided, session must be ended for the system to finish all pending processing.
    ///
    /// After you call the process function, you must not modify input and output buffers (including attachments) before the
    /// function returns or the system receives the callback, in the case of asynchronous processing.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtframeprocessor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2")]
    pub struct VTFrameProcessor;
);

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

#[cfg(feature = "objc2")]
impl VTFrameProcessor {
    extern_methods!(
        /// Create a new instance of the frame processor.
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[cfg(all(
            feature = "VTFrameProcessorConfiguration",
            feature = "objc2-foundation"
        ))]
        /// Starts a new session and configures the processor pipeline for an effect.
        ///
        /// - Parameters:
        /// - configuration: The system uses this parameter to create an effect pipeline for processing frames. This object
        /// must conform to the ``VTFrameProcessorConfiguration`` interface.
        /// - error: Contains error information if any. You may specify NULL for this parameter if you do not want the error information.
        #[unsafe(method(startSessionWithConfiguration:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn startSessionWithConfiguration_error(
            &self,
            configuration: &ProtocolObject<dyn VTFrameProcessorConfiguration>,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(all(feature = "VTFrameProcessorParameters", feature = "objc2-foundation"))]
        /// Synchronously performs the processor effects.
        ///
        /// Use the respective ``VTFrameProcessorParameters`` to pass frame level settings and frame level input/output parameters
        /// for the effect that you configured this session for by calling ``startSessionWithConfiguration:error``.
        ///
        /// - Parameters:
        /// - parameters: A `VTFrameProcessorParameters` based object to specify additional frame based parameters to use
        /// during processing. It needs to match the configuration type used during start session.
        /// - error: Contains error information if any. You may specify NULL for this parameter if you do not want the error information.
        #[unsafe(method(processWithParameters:error:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn processWithParameters_error(
            &self,
            parameters: &ProtocolObject<dyn VTFrameProcessorParameters>,
        ) -> Result<(), Retained<NSError>>;

        #[cfg(all(
            feature = "VTFrameProcessorParameters",
            feature = "block2",
            feature = "objc2-foundation"
        ))]
        /// Asynchronously performs the processor effects.
        ///
        /// - Parameters:
        /// - parameters: A `VTFrameProcessorParameters` based object to specify additional frame based parameters to use
        /// during processing. It needs to match the configuration type used during start session.
        /// - completionHandler: This completion handler is called when frame processing is completed. The completion handler
        /// receives the same parameters object that you provided to the original call, as well as an `NSError` which contains
        /// an error code if processing was not successful.
        #[unsafe(method(processWithParameters:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn processWithParameters_completionHandler(
            &self,
            parameters: &ProtocolObject<dyn VTFrameProcessorParameters>,
            completion_handler: &block2::DynBlock<
                dyn Fn(NonNull<ProtocolObject<dyn VTFrameProcessorParameters>>, *mut NSError),
            >,
        );

        #[cfg(all(
            feature = "VTFrameProcessorParameters",
            feature = "block2",
            feature = "objc2-core-media",
            feature = "objc2-foundation"
        ))]
        /// Asynchronously performs the processor effects and outputs each frame separately.
        ///
        /// Use with frame processor configurations which allow multiple output frames from a single processing call, such
        /// as frame rate conversion processor cases when you need access to output frames as they become available, rather than
        /// waiting for all output frames to be complete.
        ///
        /// This interface is suitable for low-latency scenarios when a call would generate multiple output frames, but waiting
        /// for all frames to be generated before beginning to use the frames is not ideal. Because the processor may use the
        /// output frames as references for frames still being generated, the output frames are strictly read-only. If you want
        /// to modify the frames, you must create a copy first.
        ///
        /// - Parameters:
        /// - parameters: A `VTFrameProcessorParameters` based object to specify additional frame based parameters to use
        /// during processing. It needs to match the configuration type used during start session.
        /// - frameOutputHandler: This frame output handler is called once for each destination frame in the provided parameters
        /// if no errors are encountered. The output handler receives the same parameters object that you provided to the
        /// original call, a flag indicating if this is the final output to be called for this processing request, and the
        /// presentation timestamp associated with the `VTFrameProcessorFrame` that it is being called for. The `NSError`
        /// parameter contains an error code if processing was not successful.
        #[unsafe(method(processWithParameters:frameOutputHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn processWithParameters_frameOutputHandler(
            &self,
            parameters: &ProtocolObject<dyn VTFrameProcessorParameters>,
            frame_output_handler: &block2::DynBlock<
                dyn Fn(
                    NonNull<ProtocolObject<dyn VTFrameProcessorParameters>>,
                    CMTime,
                    Bool,
                    *mut NSError,
                ),
            >,
        );

        #[cfg(all(feature = "VTFrameProcessorParameters", feature = "objc2-metal"))]
        /// Performs effects in a Metal command buffer.
        ///
        /// This function allows you to add the effect to an existing Metal command buffer. The clients that have an existing
        /// Metal pipeline and want to add this effect to it can use this function.
        ///
        /// > Note: this function waits until all previously inserted tasks in the command buffer finish before running. Tasks
        /// inserted after the `processWithCommandBuffer` returns are run by the system after the effect is applied. Processing
        /// does not happen until the commandBuffer is executed.
        ///
        /// - Parameters:
        /// - commandBuffer: An existing Metal command buffer where the frame processing is inserted.
        /// - parameters: A `VTFrameProcessorParameters` based object to specify additional frame based parameters to use
        /// during processing. It needs to match the configuration type used during start session.
        #[unsafe(method(processWithCommandBuffer:parameters:))]
        #[unsafe(method_family = none)]
        pub unsafe fn processWithCommandBuffer_parameters(
            &self,
            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
            parameters: &ProtocolObject<dyn VTFrameProcessorParameters>,
        );

        /// Performs all necessary tasks to end the session.
        ///
        /// After this call completes, you can process no new frames unless you call ``startSessionWithConfiguration`` again.
        #[unsafe(method(endSession))]
        #[unsafe(method_family = none)]
        pub unsafe fn endSession(&self);
    );
}

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