objc2_av_kit/generated/
AVCaptureView.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-av-foundation")]
10use objc2_av_foundation::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15/// The inline controls pane for media recording is associated with the view.
16///
17/// The floating controls pane for media recordings is associated with the view.
18///
19/// The inline controls pane for selection capture devices is associated with the view.
20///
21/// The default controls pane is associated with the view.
22///
23/// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avcaptureviewcontrolsstyle?language=objc)
24// NS_ENUM
25#[repr(transparent)]
26#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
27pub struct AVCaptureViewControlsStyle(pub NSInteger);
28impl AVCaptureViewControlsStyle {
29    #[doc(alias = "AVCaptureViewControlsStyleInline")]
30    pub const Inline: Self = Self(0);
31    #[doc(alias = "AVCaptureViewControlsStyleFloating")]
32    pub const Floating: Self = Self(1);
33    #[doc(alias = "AVCaptureViewControlsStyleInlineDeviceSelection")]
34    pub const InlineDeviceSelection: Self = Self(2);
35    #[doc(alias = "AVCaptureViewControlsStyleDefault")]
36    pub const Default: Self = Self(AVCaptureViewControlsStyle::Inline.0);
37}
38
39unsafe impl Encode for AVCaptureViewControlsStyle {
40    const ENCODING: Encoding = NSInteger::ENCODING;
41}
42
43unsafe impl RefEncode for AVCaptureViewControlsStyle {
44    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
45}
46
47extern_class!(
48    /// AVCaptureView is a subclass of NSView that can be used to display standard user interface controls for capturing media data.
49    ///
50    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avcaptureview?language=objc)
51    #[unsafe(super(NSView, NSResponder, NSObject))]
52    #[derive(Debug, PartialEq, Eq, Hash)]
53    #[cfg(feature = "objc2-app-kit")]
54    #[cfg(target_os = "macos")]
55    pub struct AVCaptureView;
56);
57
58#[cfg(feature = "objc2-app-kit")]
59#[cfg(target_os = "macos")]
60unsafe impl NSAccessibility for AVCaptureView {}
61
62#[cfg(feature = "objc2-app-kit")]
63#[cfg(target_os = "macos")]
64unsafe impl NSAccessibilityElementProtocol for AVCaptureView {}
65
66#[cfg(feature = "objc2-app-kit")]
67#[cfg(target_os = "macos")]
68unsafe impl NSAnimatablePropertyContainer for AVCaptureView {}
69
70#[cfg(feature = "objc2-app-kit")]
71#[cfg(target_os = "macos")]
72unsafe impl NSAppearanceCustomization for AVCaptureView {}
73
74#[cfg(feature = "objc2-app-kit")]
75#[cfg(target_os = "macos")]
76unsafe impl NSCoding for AVCaptureView {}
77
78#[cfg(feature = "objc2-app-kit")]
79#[cfg(target_os = "macos")]
80unsafe impl NSDraggingDestination for AVCaptureView {}
81
82#[cfg(feature = "objc2-app-kit")]
83#[cfg(target_os = "macos")]
84unsafe impl NSObjectProtocol for AVCaptureView {}
85
86#[cfg(feature = "objc2-app-kit")]
87#[cfg(target_os = "macos")]
88unsafe impl NSUserInterfaceItemIdentification for AVCaptureView {}
89
90#[cfg(feature = "objc2-app-kit")]
91#[cfg(target_os = "macos")]
92impl AVCaptureView {
93    extern_methods!(
94        #[cfg(feature = "objc2-av-foundation")]
95        /// A capture session represented by this view.
96        ///
97        /// 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.
98        #[unsafe(method(session))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn session(&self) -> Option<Retained<AVCaptureSession>>;
101
102        #[cfg(feature = "objc2-av-foundation")]
103        /// Sets the session represented by this view.
104        ///
105        /// Parameter `session`: The session to be represented.
106        ///
107        /// 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.
108        ///
109        /// 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.
110        ///
111        /// 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.
112        #[unsafe(method(setSession:showVideoPreview:showAudioPreview:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn setSession_showVideoPreview_showAudioPreview(
115            &self,
116            session: Option<&AVCaptureSession>,
117            show_video_preview: bool,
118            show_audio_preview: bool,
119        );
120
121        #[cfg(feature = "objc2-av-foundation")]
122        /// A capture file output used to record media data.
123        ///
124        /// 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.
125        #[unsafe(method(fileOutput))]
126        #[unsafe(method_family = none)]
127        pub unsafe fn fileOutput(&self) -> Option<Retained<AVCaptureFileOutput>>;
128
129        /// The capture view's delegate.
130        ///
131        /// The start recording button will be disabled if the delegate is not set.
132        #[unsafe(method(delegate))]
133        #[unsafe(method_family = none)]
134        pub unsafe fn delegate(
135            &self,
136        ) -> Option<Retained<ProtocolObject<dyn AVCaptureViewDelegate>>>;
137
138        /// This is a [weak property][objc2::topics::weak_property].
139        /// Setter for [`delegate`][Self::delegate].
140        #[unsafe(method(setDelegate:))]
141        #[unsafe(method_family = none)]
142        pub unsafe fn setDelegate(
143            &self,
144            delegate: Option<&ProtocolObject<dyn AVCaptureViewDelegate>>,
145        );
146
147        /// The style of the capture controls pane associated with the view.
148        #[unsafe(method(controlsStyle))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn controlsStyle(&self) -> AVCaptureViewControlsStyle;
151
152        /// Setter for [`controlsStyle`][Self::controlsStyle].
153        #[unsafe(method(setControlsStyle:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn setControlsStyle(&self, controls_style: AVCaptureViewControlsStyle);
156
157        #[cfg(feature = "objc2-av-foundation")]
158        /// A string defining how the video is displayed within the views bounds rect.
159        ///
160        /// Options are AVLayerVideoGravityResize, AVLayerVideoGravityResizeAspect and AVLayerVideoGravityResizeAspectFill. AVLayerVideoGravityResizeAspect is default.
161        #[unsafe(method(videoGravity))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>;
164
165        #[cfg(feature = "objc2-av-foundation")]
166        /// Setter for [`videoGravity`][Self::videoGravity].
167        #[unsafe(method(setVideoGravity:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity);
170    );
171}
172
173/// Methods declared on superclass `NSView`.
174#[cfg(feature = "objc2-app-kit")]
175#[cfg(target_os = "macos")]
176impl AVCaptureView {
177    extern_methods!(
178        #[unsafe(method(initWithFrame:))]
179        #[unsafe(method_family = init)]
180        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
181
182        #[unsafe(method(initWithCoder:))]
183        #[unsafe(method_family = init)]
184        pub unsafe fn initWithCoder(
185            this: Allocated<Self>,
186            coder: &NSCoder,
187        ) -> Option<Retained<Self>>;
188    );
189}
190
191/// Methods declared on superclass `NSResponder`.
192#[cfg(feature = "objc2-app-kit")]
193#[cfg(target_os = "macos")]
194impl AVCaptureView {
195    extern_methods!(
196        #[unsafe(method(init))]
197        #[unsafe(method_family = init)]
198        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
199    );
200}
201
202/// Methods declared on superclass `NSObject`.
203#[cfg(feature = "objc2-app-kit")]
204#[cfg(target_os = "macos")]
205impl AVCaptureView {
206    extern_methods!(
207        #[unsafe(method(new))]
208        #[unsafe(method_family = new)]
209        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
210    );
211}
212
213extern_protocol!(
214    /// Defines an interface for delegates of AVCaptureView.
215    ///
216    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avcaptureviewdelegate?language=objc)
217    pub unsafe trait AVCaptureViewDelegate: NSObjectProtocol {
218        #[cfg(all(feature = "objc2-app-kit", feature = "objc2-av-foundation"))]
219        #[cfg(target_os = "macos")]
220        /// Informs the delegate that a new media recording should be started.
221        ///
222        /// If captureFileOutput is an instance of AVCaptureMovieFileOutput this can be achieved by calling startRecordingToOutputFileURL:recordingDelegate: on the captureFileOutput.
223        #[unsafe(method(captureView:startRecordingToFileOutput:))]
224        #[unsafe(method_family = none)]
225        unsafe fn captureView_startRecordingToFileOutput(
226            &self,
227            capture_view: &AVCaptureView,
228            file_output: &AVCaptureFileOutput,
229        );
230    }
231);