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")]
60extern_conformance!(
61    unsafe impl NSAccessibility for AVCaptureView {}
62);
63
64#[cfg(feature = "objc2-app-kit")]
65#[cfg(target_os = "macos")]
66extern_conformance!(
67    unsafe impl NSAccessibilityElementProtocol for AVCaptureView {}
68);
69
70#[cfg(feature = "objc2-app-kit")]
71#[cfg(target_os = "macos")]
72extern_conformance!(
73    unsafe impl NSAnimatablePropertyContainer for AVCaptureView {}
74);
75
76#[cfg(feature = "objc2-app-kit")]
77#[cfg(target_os = "macos")]
78extern_conformance!(
79    unsafe impl NSAppearanceCustomization for AVCaptureView {}
80);
81
82#[cfg(feature = "objc2-app-kit")]
83#[cfg(target_os = "macos")]
84extern_conformance!(
85    unsafe impl NSCoding for AVCaptureView {}
86);
87
88#[cfg(feature = "objc2-app-kit")]
89#[cfg(target_os = "macos")]
90extern_conformance!(
91    unsafe impl NSDraggingDestination for AVCaptureView {}
92);
93
94#[cfg(feature = "objc2-app-kit")]
95#[cfg(target_os = "macos")]
96extern_conformance!(
97    unsafe impl NSObjectProtocol for AVCaptureView {}
98);
99
100#[cfg(feature = "objc2-app-kit")]
101#[cfg(target_os = "macos")]
102extern_conformance!(
103    unsafe impl NSUserInterfaceItemIdentification for AVCaptureView {}
104);
105
106#[cfg(feature = "objc2-app-kit")]
107#[cfg(target_os = "macos")]
108impl AVCaptureView {
109    extern_methods!(
110        #[cfg(feature = "objc2-av-foundation")]
111        /// A capture session represented by this view.
112        ///
113        /// 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.
114        #[unsafe(method(session))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn session(&self) -> Option<Retained<AVCaptureSession>>;
117
118        #[cfg(feature = "objc2-av-foundation")]
119        /// Sets the session represented by this view.
120        ///
121        /// Parameter `session`: The session to be represented.
122        ///
123        /// 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.
124        ///
125        /// 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.
126        ///
127        /// 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.
128        #[unsafe(method(setSession:showVideoPreview:showAudioPreview:))]
129        #[unsafe(method_family = none)]
130        pub unsafe fn setSession_showVideoPreview_showAudioPreview(
131            &self,
132            session: Option<&AVCaptureSession>,
133            show_video_preview: bool,
134            show_audio_preview: bool,
135        );
136
137        #[cfg(feature = "objc2-av-foundation")]
138        /// A capture file output used to record media data.
139        ///
140        /// 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.
141        #[unsafe(method(fileOutput))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn fileOutput(&self) -> Option<Retained<AVCaptureFileOutput>>;
144
145        /// The capture view's delegate.
146        ///
147        /// The start recording button will be disabled if the delegate is not set.
148        #[unsafe(method(delegate))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn delegate(
151            &self,
152        ) -> Option<Retained<ProtocolObject<dyn AVCaptureViewDelegate>>>;
153
154        /// Setter for [`delegate`][Self::delegate].
155        ///
156        /// This is a [weak property][objc2::topics::weak_property].
157        #[unsafe(method(setDelegate:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setDelegate(
160            &self,
161            delegate: Option<&ProtocolObject<dyn AVCaptureViewDelegate>>,
162        );
163
164        /// The style of the capture controls pane associated with the view.
165        #[unsafe(method(controlsStyle))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn controlsStyle(&self) -> AVCaptureViewControlsStyle;
168
169        /// Setter for [`controlsStyle`][Self::controlsStyle].
170        #[unsafe(method(setControlsStyle:))]
171        #[unsafe(method_family = none)]
172        pub unsafe fn setControlsStyle(&self, controls_style: AVCaptureViewControlsStyle);
173
174        #[cfg(feature = "objc2-av-foundation")]
175        /// A string defining how the video is displayed within the views bounds rect.
176        ///
177        /// Options are AVLayerVideoGravityResize, AVLayerVideoGravityResizeAspect and AVLayerVideoGravityResizeAspectFill. AVLayerVideoGravityResizeAspect is default.
178        #[unsafe(method(videoGravity))]
179        #[unsafe(method_family = none)]
180        pub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>;
181
182        #[cfg(feature = "objc2-av-foundation")]
183        /// Setter for [`videoGravity`][Self::videoGravity].
184        ///
185        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
186        #[unsafe(method(setVideoGravity:))]
187        #[unsafe(method_family = none)]
188        pub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity);
189    );
190}
191
192/// Methods declared on superclass `NSView`.
193#[cfg(feature = "objc2-app-kit")]
194#[cfg(target_os = "macos")]
195impl AVCaptureView {
196    extern_methods!(
197        #[unsafe(method(initWithFrame:))]
198        #[unsafe(method_family = init)]
199        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
200
201        /// # Safety
202        ///
203        /// `coder` possibly has further requirements.
204        #[unsafe(method(initWithCoder:))]
205        #[unsafe(method_family = init)]
206        pub unsafe fn initWithCoder(
207            this: Allocated<Self>,
208            coder: &NSCoder,
209        ) -> Option<Retained<Self>>;
210    );
211}
212
213/// Methods declared on superclass `NSResponder`.
214#[cfg(feature = "objc2-app-kit")]
215#[cfg(target_os = "macos")]
216impl AVCaptureView {
217    extern_methods!(
218        #[unsafe(method(init))]
219        #[unsafe(method_family = init)]
220        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
221    );
222}
223
224/// Methods declared on superclass `NSObject`.
225#[cfg(feature = "objc2-app-kit")]
226#[cfg(target_os = "macos")]
227impl AVCaptureView {
228    extern_methods!(
229        #[unsafe(method(new))]
230        #[unsafe(method_family = new)]
231        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
232    );
233}
234
235extern_protocol!(
236    /// Defines an interface for delegates of AVCaptureView.
237    ///
238    /// See also [Apple's documentation](https://developer.apple.com/documentation/avkit/avcaptureviewdelegate?language=objc)
239    pub unsafe trait AVCaptureViewDelegate: NSObjectProtocol {
240        #[cfg(all(feature = "objc2-app-kit", feature = "objc2-av-foundation"))]
241        #[cfg(target_os = "macos")]
242        /// Informs the delegate that a new media recording should be started.
243        ///
244        /// If captureFileOutput is an instance of AVCaptureMovieFileOutput this can be achieved by calling startRecordingToOutputFileURL:recordingDelegate: on the captureFileOutput.
245        #[unsafe(method(captureView:startRecordingToFileOutput:))]
246        #[unsafe(method_family = none)]
247        unsafe fn captureView_startRecordingToFileOutput(
248            &self,
249            capture_view: &AVCaptureView,
250            file_output: &AVCaptureFileOutput,
251        );
252    }
253);