objc2-screen-capture-kit 0.3.2

Bindings to the ScreenCaptureKit 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-media")]
use objc2_core_media::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// SCRecordingOutputConfiguration
    ///
    /// SCRecordingOutputConfiguration is an object that encapsulates the configuration for recording.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/screcordingoutputconfiguration?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SCRecordingOutputConfiguration;
);

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

impl SCRecordingOutputConfiguration {
    extern_methods!(
        /// Specifies output URL to save the recording.
        #[unsafe(method(outputURL))]
        #[unsafe(method_family = none)]
        pub unsafe fn outputURL(&self) -> Retained<NSURL>;

        /// Setter for [`outputURL`][Self::outputURL].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setOutputURL:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setOutputURL(&self, output_url: &NSURL);

        #[cfg(feature = "objc2-av-foundation")]
        /// Specifies video codec for the recording output, default is AVVideoCodecTypeH264, supported values can be obtained using availableVideoCodecTypes
        #[unsafe(method(videoCodecType))]
        #[unsafe(method_family = none)]
        pub unsafe fn videoCodecType(&self) -> Retained<AVVideoCodecType>;

        #[cfg(feature = "objc2-av-foundation")]
        /// Setter for [`videoCodecType`][Self::videoCodecType].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setVideoCodecType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setVideoCodecType(&self, video_codec_type: &AVVideoCodecType);

        #[cfg(feature = "objc2-av-foundation")]
        /// Specifies file type for the recording output, default is AVFileTypeMPEG4, supported values can be obtained using availableOutputFileTypes
        #[unsafe(method(outputFileType))]
        #[unsafe(method_family = none)]
        pub unsafe fn outputFileType(&self) -> Retained<AVFileType>;

        #[cfg(feature = "objc2-av-foundation")]
        /// Setter for [`outputFileType`][Self::outputFileType].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setOutputFileType:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setOutputFileType(&self, output_file_type: &AVFileType);

        #[cfg(feature = "objc2-av-foundation")]
        /// Returns an array of supported video codec formats that can be specified in SCRecordingOutputConfiguration for videoCodecType
        #[unsafe(method(availableVideoCodecTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn availableVideoCodecTypes(&self) -> Retained<NSArray<AVVideoCodecType>>;

        #[cfg(feature = "objc2-av-foundation")]
        /// Returns an array of supported file types that can be specified in SCRecordingOutputConfiguration for outputFileType
        /// Provides the file types AVCaptureAudioFileOutput can write.
        #[unsafe(method(availableOutputFileTypes))]
        #[unsafe(method_family = none)]
        pub unsafe fn availableOutputFileTypes(&self) -> Retained<NSArray<AVFileType>>;
    );
}

/// Methods declared on superclass `NSObject`.
impl SCRecordingOutputConfiguration {
    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_protocol!(
    /// Defines an interface for delegates of SCRecordingOutput to respond to events that occur in the process of recording to file.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/screcordingoutputdelegate?language=objc)
    pub unsafe trait SCRecordingOutputDelegate: NSObjectProtocol {
        /// recordingOutputDidStartRecording:
        ///
        /// Parameter `recordingOutput`: the SCRecordingOutput object
        ///
        /// notifies the delegate that recording has succesfully started.
        #[optional]
        #[unsafe(method(recordingOutputDidStartRecording:))]
        #[unsafe(method_family = none)]
        unsafe fn recordingOutputDidStartRecording(&self, recording_output: &SCRecordingOutput);

        /// recordingOutput:didFailWithError:
        ///
        /// Parameter `recordingOutput`: the SCRecordingOutput object
        ///
        /// Parameter `error`: error describing why the recording failed.
        ///
        /// notifies the delegate that recording has failed with error associated.
        #[optional]
        #[unsafe(method(recordingOutput:didFailWithError:))]
        #[unsafe(method_family = none)]
        unsafe fn recordingOutput_didFailWithError(
            &self,
            recording_output: &SCRecordingOutput,
            error: &NSError,
        );

        /// recordingOutputDidFinishRecording:
        ///
        /// notifies the delegate that recording has finished successfully.
        #[optional]
        #[unsafe(method(recordingOutputDidFinishRecording:))]
        #[unsafe(method_family = none)]
        unsafe fn recordingOutputDidFinishRecording(&self, recording_output: &SCRecordingOutput);
    }
);

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/screencapturekit/screcordingoutput?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct SCRecordingOutput;
);

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

impl SCRecordingOutput {
    extern_methods!(
        #[cfg(feature = "objc2-core-media")]
        /// Indicates current duration of recording to the output file.
        #[unsafe(method(recordedDuration))]
        #[unsafe(method_family = none)]
        pub unsafe fn recordedDuration(&self) -> CMTime;

        /// Indicates current size, in bytes, of the data recorded to the output file.
        #[unsafe(method(recordedFileSize))]
        #[unsafe(method_family = none)]
        pub unsafe fn recordedFileSize(&self) -> NSInteger;

        /// initialize SCRecordingOutput object with SCRecordingOutputConfiguration and SCRecordingOutputDelegate
        ///
        /// Parameter `recordingOutputConfiguration`: the requested recording configuration to be applied to the SCRecordingOutput
        ///
        /// Parameter `delegate`: object conforming SCRecordingOutputDelegate protocol. Clients must specify a delegate so that they can be notified about recording event.
        ///
        /// Client can create a SCRecordingOutput with this initializer and add to SCStream to record all captured media into one recording file given output url specified in recordingOutputConfig. The recording will be using H264 and file format is MPEG-4.
        #[unsafe(method(initWithConfiguration:delegate:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithConfiguration_delegate(
            this: Allocated<Self>,
            recording_output_configuration: &SCRecordingOutputConfiguration,
            delegate: &ProtocolObject<dyn SCRecordingOutputDelegate>,
        ) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
impl SCRecordingOutput {
    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>;
    );
}