objc2-cinematic 0.3.2

Bindings to the Cinematic 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-av-foundation")]
use objc2_av_foundation::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
#[cfg(feature = "objc2-core-video")]
use objc2_core_video::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-metal")]
use objc2_metal::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnrenderingquality?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CNRenderingQuality(pub NSInteger);
impl CNRenderingQuality {
    #[doc(alias = "CNRenderingQualityThumbnail")]
    pub const Thumbnail: Self = Self(0);
    #[doc(alias = "CNRenderingQualityPreview")]
    pub const Preview: Self = Self(1);
    #[doc(alias = "CNRenderingQualityExport")]
    pub const Export: Self = Self(2);
    #[doc(alias = "CNRenderingQualityExportHigh")]
    pub const ExportHigh: Self = Self(3);
}

unsafe impl Encode for CNRenderingQuality {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for CNRenderingQuality {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Movie-wide information required by the rendering session.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnrenderingsessionattributes?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CNRenderingSessionAttributes;
);

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

impl CNRenderingSessionAttributes {
    extern_methods!(
        #[cfg(all(feature = "block2", feature = "objc2-av-foundation"))]
        /// Load rendering session attributes from an asset asynchronously.
        #[unsafe(method(loadFromAsset:completionHandler:))]
        #[unsafe(method_family = none)]
        pub unsafe fn loadFromAsset_completionHandler(
            asset: &AVAsset,
            completion_handler: &block2::DynBlock<
                dyn Fn(*mut CNRenderingSessionAttributes, *mut NSError),
            >,
        );

        /// Rendering version used to render the original.
        #[unsafe(method(renderingVersion))]
        #[unsafe(method_family = none)]
        pub unsafe fn renderingVersion(&self) -> NSInteger;

        #[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!(
    /// Frame-specific information required to render a frame in a rendering session.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnrenderingsessionframeattributes?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CNRenderingSessionFrameAttributes;
);

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

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

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

impl CNRenderingSessionFrameAttributes {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Initialize rendering frame attributes from a sample buffer read from a cinematic metadata track.
        /// - Parameters:
        /// - sampleBuffer: A sample buffer read from the timed cinematic metadata track of a cinematic asset.
        /// - sessionAttributes: Rendering session attributes loaded from a cinematic asset.
        #[unsafe(method(initWithSampleBuffer:sessionAttributes:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithSampleBuffer_sessionAttributes(
            this: Allocated<Self>,
            sample_buffer: &CMSampleBuffer,
            session_attributes: &CNRenderingSessionAttributes,
        ) -> Option<Retained<Self>>;

        #[cfg(feature = "objc2-av-foundation")]
        /// Initialize rendering frame attributes from a timed metadata group read from a cinematic metadata track.
        /// - Parameters:
        /// - metadataGroup: An AVTimedMetadataGroup read from the timed cinematic metadata track of a cinematic asset.
        /// - sessionAttributes: Rendering session attributes loaded from a cinematic asset.
        #[unsafe(method(initWithTimedMetadataGroup:sessionAttributes:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithTimedMetadataGroup_sessionAttributes(
            this: Allocated<Self>,
            metadata_group: &AVTimedMetadataGroup,
            session_attributes: &CNRenderingSessionAttributes,
        ) -> Option<Retained<Self>>;

        /// The disparity value which represents the focus plane at which the rendered image should be in focus.
        ///
        /// A larger disparity results in the focus plane being closer to the camera. The scale and offset of disparity is not defined.
        /// It is best practice to obtain disparity values from detections or by interpolation between known disparity values.
        #[unsafe(method(focusDisparity))]
        #[unsafe(method_family = none)]
        pub unsafe fn focusDisparity(&self) -> c_float;

        /// Setter for [`focusDisparity`][Self::focusDisparity].
        #[unsafe(method(setFocusDisparity:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFocusDisparity(&self, focus_disparity: c_float);

        /// The f-stop value which inversely affects the aperture used to render the image.
        ///
        /// A smaller f/ number results in larger bokeh and a shallower depth of field in the rendered image.
        #[unsafe(method(fNumber))]
        #[unsafe(method_family = none)]
        pub unsafe fn fNumber(&self) -> c_float;

        /// Setter for [`fNumber`][Self::fNumber].
        #[unsafe(method(setFNumber:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFNumber(&self, f_number: c_float);

        #[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!(
    /// [Apple's documentation](https://developer.apple.com/documentation/cinematic/cnrenderingsession?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct CNRenderingSession;
);

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

impl CNRenderingSession {
    extern_methods!(
        #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-metal"))]
        #[unsafe(method(initWithCommandQueue:sessionAttributes:preferredTransform:quality:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCommandQueue_sessionAttributes_preferredTransform_quality(
            this: Allocated<Self>,
            command_queue: &ProtocolObject<dyn MTLCommandQueue>,
            session_attributes: &CNRenderingSessionAttributes,
            preferred_transform: CGAffineTransform,
            quality: CNRenderingQuality,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-metal")]
        #[unsafe(method(commandQueue))]
        #[unsafe(method_family = none)]
        pub unsafe fn commandQueue(&self) -> Retained<ProtocolObject<dyn MTLCommandQueue>>;

        #[unsafe(method(sessionAttributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn sessionAttributes(&self) -> Retained<CNRenderingSessionAttributes>;

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

        #[unsafe(method(quality))]
        #[unsafe(method_family = none)]
        pub unsafe fn quality(&self) -> CNRenderingQuality;

        #[cfg(all(feature = "objc2-core-video", feature = "objc2-metal"))]
        /// Encode a command to render a shallow depth of field (SDoF) image to a pixel buffer.
        /// - Parameters:
        /// - commandBuffer: the metal command buffer on which to encode the command
        /// - frameAttributes: controls the focus distance and aperture of the rendering
        /// - sourceImage: a pixel buffer read from the cinematicVideoTrack
        /// - sourceDisparity: a pixel buffer read from the cinematicDisparityTrack
        /// - destinationImage: the pixel buffer to which the SDoF image is rendered
        /// - Returns: whether encoding the render command was successful
        #[unsafe(method(encodeRenderToCommandBuffer:frameAttributes:sourceImage:sourceDisparity:destinationImage:))]
        #[unsafe(method_family = none)]
        pub unsafe fn encodeRenderToCommandBuffer_frameAttributes_sourceImage_sourceDisparity_destinationImage(
            &self,
            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
            frame_attributes: &CNRenderingSessionFrameAttributes,
            source_image: &CVPixelBuffer,
            source_disparity: &CVPixelBuffer,
            destination_image: &CVPixelBuffer,
        ) -> bool;

        #[cfg(all(feature = "objc2-core-video", feature = "objc2-metal"))]
        /// Encode a command to render a shallow depth of field (SDoF) image to a metal texture as RGBA.
        /// - Parameters:
        /// - commandBuffer: the metal command buffer on which to encode the command
        /// - frameAttributes: controls the focus distance and aperture of the rendering
        /// - sourceImage: a pixel buffer read from the cinematicVideoTrack
        /// - sourceDisparity: a pixel buffer read from the cinematicDisparityTrack
        /// - destinationRGBA: a metal texture to which the SDoF image is rendered in RGBA format
        /// - Returns: whether encoding the render command was successful
        ///
        /// # Safety
        ///
        /// - `destination_rgba` may need to be synchronized.
        /// - `destination_rgba` may be unretained, you must ensure it is kept alive while in use.
        #[unsafe(method(encodeRenderToCommandBuffer:frameAttributes:sourceImage:sourceDisparity:destinationRGBA:))]
        #[unsafe(method_family = none)]
        pub unsafe fn encodeRenderToCommandBuffer_frameAttributes_sourceImage_sourceDisparity_destinationRGBA(
            &self,
            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
            frame_attributes: &CNRenderingSessionFrameAttributes,
            source_image: &CVPixelBuffer,
            source_disparity: &CVPixelBuffer,
            destination_rgba: &ProtocolObject<dyn MTLTexture>,
        ) -> bool;

        #[cfg(all(feature = "objc2-core-video", feature = "objc2-metal"))]
        /// Encode a command to render a shallow depth of field (SDoF) image to two metal textures as luma and chroma.
        /// - Parameters:
        /// - commandBuffer: the metal command buffer on which to encode the command
        /// - frameAttributes: controls the focus distance and aperture of the rendering
        /// - sourceImage: a pixel buffer read from the cinematicVideoTrack
        /// - sourceDisparity: a pixel buffer read from the cinematicDisparityTrack
        /// - destinationLuma: a metal texture to which the luma of the SDoF image is rendered
        /// - destinationChroma: a metal texture to which the chroma of the SDoF image is rendered
        /// - Returns: whether encoding the render command was successful
        ///
        /// # Safety
        ///
        /// - `destination_luma` may need to be synchronized.
        /// - `destination_luma` may be unretained, you must ensure it is kept alive while in use.
        /// - `destination_chroma` may need to be synchronized.
        /// - `destination_chroma` may be unretained, you must ensure it is kept alive while in use.
        #[unsafe(method(encodeRenderToCommandBuffer:frameAttributes:sourceImage:sourceDisparity:destinationLuma:destinationChroma:))]
        #[unsafe(method_family = none)]
        pub unsafe fn encodeRenderToCommandBuffer_frameAttributes_sourceImage_sourceDisparity_destinationLuma_destinationChroma(
            &self,
            command_buffer: &ProtocolObject<dyn MTLCommandBuffer>,
            frame_attributes: &CNRenderingSessionFrameAttributes,
            source_image: &CVPixelBuffer,
            source_disparity: &CVPixelBuffer,
            destination_luma: &ProtocolObject<dyn MTLTexture>,
            destination_chroma: &ProtocolObject<dyn MTLTexture>,
        ) -> bool;

        /// The pixel format types supported for the input source.
        ///
        /// Use with kCVPixelBufferPixelFormatTypeKey in the video compositor's sourcePixelBufferAttributes dictionary when implementing AVVideoCompositing.
        #[unsafe(method(sourcePixelFormatTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn sourcePixelFormatTypes() -> Retained<NSArray<NSNumber>>;

        /// The pixel format types supported for the output destination.
        ///
        /// Use with kCVPixelBufferPixelFormatTypeKey in the video compositor's requiredPixelBufferAttributesForRenderContext dictionary when implementing AVVideoCompositing.
        #[unsafe(method(destinationPixelFormatTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn destinationPixelFormatTypes() -> Retained<NSArray<NSNumber>>;

        #[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>;
    );
}