objc2-av-kit 0.3.2

Bindings to the AVKit 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-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-av-foundation")]
use objc2_av_foundation::*;
use objc2_foundation::*;

use crate::*;

/// The inline controls pane for media recording is associated with the view.
///
/// The floating controls pane for media recordings is associated with the view.
///
/// The inline controls pane for selection capture devices is associated with the view.
///
/// The default controls pane is associated with the view.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avcaptureviewcontrolsstyle?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVCaptureViewControlsStyle(pub NSInteger);
impl AVCaptureViewControlsStyle {
    #[doc(alias = "AVCaptureViewControlsStyleInline")]
    pub const Inline: Self = Self(0);
    #[doc(alias = "AVCaptureViewControlsStyleFloating")]
    pub const Floating: Self = Self(1);
    #[doc(alias = "AVCaptureViewControlsStyleInlineDeviceSelection")]
    pub const InlineDeviceSelection: Self = Self(2);
    #[doc(alias = "AVCaptureViewControlsStyleDefault")]
    pub const Default: Self = Self(AVCaptureViewControlsStyle::Inline.0);
}

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

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

extern_class!(
    /// AVCaptureView is a subclass of NSView that can be used to display standard user interface controls for capturing media data.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avcaptureview?language=objc)
    #[unsafe(super(NSView, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(feature = "objc2-app-kit")]
    #[cfg(target_os = "macos")]
    pub struct AVCaptureView;
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAccessibility for AVCaptureView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAccessibilityElementProtocol for AVCaptureView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAnimatablePropertyContainer for AVCaptureView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSAppearanceCustomization for AVCaptureView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSCoding for AVCaptureView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSDraggingDestination for AVCaptureView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSObjectProtocol for AVCaptureView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSUserInterfaceItemIdentification for AVCaptureView {}
);

#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl AVCaptureView {
    extern_methods!(
        #[cfg(feature = "objc2-av-foundation")]
        /// A capture session represented by this view.
        ///
        /// Modifying the capture session will impact its visual representation in the view. The default value is a session configured for movie file recordings of audio and video media data. Use -setSession:showVideoPreview:showAudioPreview: to change the value of this property.
        #[unsafe(method(session))]
        #[unsafe(method_family = none)]
        pub unsafe fn session(&self) -> Option<Retained<AVCaptureSession>>;

        #[cfg(feature = "objc2-av-foundation")]
        /// Sets the session represented by this view.
        ///
        /// Parameter `session`: The session to be represented.
        ///
        /// Parameter `showVideoPreview`: Whether or not video preview should be shown. If YES, capture inputs for video media data will be added, removed, or modified depending on device availability and user selection.
        ///
        /// Parameter `showAudioPreview`: Whether or not audio preview should be shown. If YES, capture inputs for audio media data will be added, removed, or modified depending on device availability and user selection.
        ///
        /// The view must either show audio preview or video preview or both. Furthermore, the view may modify the capture session, for example, to access media data for preview or when the user select a new capture source. Only the default session is started and stopped automatically. The provided session must be manually started and stopped.
        #[unsafe(method(setSession:showVideoPreview:showAudioPreview:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setSession_showVideoPreview_showAudioPreview(
            &self,
            session: Option<&AVCaptureSession>,
            show_video_preview: bool,
            show_audio_preview: bool,
        );

        #[cfg(feature = "objc2-av-foundation")]
        /// A capture file output used to record media data.
        ///
        /// The value of this property is the first instance of AVCaptureFileOutput contained in the session's outputs array or nil if no such instance is found. In the latter case the capture view's start recording button will be disabled. However, the controls for choosing input sources may still be enabled.
        #[unsafe(method(fileOutput))]
        #[unsafe(method_family = none)]
        pub unsafe fn fileOutput(&self) -> Option<Retained<AVCaptureFileOutput>>;

        /// The capture view's delegate.
        ///
        /// The start recording button will be disabled if the delegate is not set.
        #[unsafe(method(delegate))]
        #[unsafe(method_family = none)]
        pub unsafe fn delegate(
            &self,
        ) -> Option<Retained<ProtocolObject<dyn AVCaptureViewDelegate>>>;

        /// Setter for [`delegate`][Self::delegate].
        ///
        /// This is a [weak property][objc2::topics::weak_property].
        #[unsafe(method(setDelegate:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setDelegate(
            &self,
            delegate: Option<&ProtocolObject<dyn AVCaptureViewDelegate>>,
        );

        /// The style of the capture controls pane associated with the view.
        #[unsafe(method(controlsStyle))]
        #[unsafe(method_family = none)]
        pub unsafe fn controlsStyle(&self) -> AVCaptureViewControlsStyle;

        /// Setter for [`controlsStyle`][Self::controlsStyle].
        #[unsafe(method(setControlsStyle:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setControlsStyle(&self, controls_style: AVCaptureViewControlsStyle);

        #[cfg(feature = "objc2-av-foundation")]
        /// A string defining how the video is displayed within the views bounds rect.
        ///
        /// Options are AVLayerVideoGravityResize, AVLayerVideoGravityResizeAspect and AVLayerVideoGravityResizeAspectFill. AVLayerVideoGravityResizeAspect is default.
        #[unsafe(method(videoGravity))]
        #[unsafe(method_family = none)]
        pub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>;

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

/// Methods declared on superclass `NSView`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl AVCaptureView {
    extern_methods!(
        #[unsafe(method(initWithFrame:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;

        /// # Safety
        ///
        /// `coder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            coder: &NSCoder,
        ) -> Option<Retained<Self>>;
    );
}

/// Methods declared on superclass `NSResponder`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl AVCaptureView {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
impl AVCaptureView {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

extern_protocol!(
    /// Defines an interface for delegates of AVCaptureView.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avcaptureviewdelegate?language=objc)
    pub unsafe trait AVCaptureViewDelegate: NSObjectProtocol {
        #[cfg(all(feature = "objc2-app-kit", feature = "objc2-av-foundation"))]
        #[cfg(target_os = "macos")]
        /// Informs the delegate that a new media recording should be started.
        ///
        /// If captureFileOutput is an instance of AVCaptureMovieFileOutput this can be achieved by calling startRecordingToOutputFileURL:recordingDelegate: on the captureFileOutput.
        #[unsafe(method(captureView:startRecordingToFileOutput:))]
        #[unsafe(method_family = none)]
        unsafe fn captureView_startRecordingToFileOutput(
            &self,
            capture_view: &AVCaptureView,
            file_output: &AVCaptureFileOutput,
        );
    }
);