objc2_av_foundation/generated/
AVCaptureExternalDisplayConfigurator.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-core-media")]
7use objc2_core_media::*;
8#[cfg(feature = "objc2-quartz-core")]
9#[cfg(not(target_os = "watchos"))]
10use objc2_quartz_core::*;
11
12use crate::*;
13
14extern_class!(
15    /// A class you use to specify a configuration to your external display configurator.
16    ///
17    /// Using an ``AVCaptureExternalDisplayConfiguration``, you direct your ``AVCaptureExternalDisplayConfigurator`` how to configure an external display to match your device's active video format.
18    ///
19    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureexternaldisplayconfiguration?language=objc)
20    #[unsafe(super(NSObject))]
21    #[derive(Debug, PartialEq, Eq, Hash)]
22    pub struct AVCaptureExternalDisplayConfiguration;
23);
24
25extern_conformance!(
26    unsafe impl NSObjectProtocol for AVCaptureExternalDisplayConfiguration {}
27);
28
29impl AVCaptureExternalDisplayConfiguration {
30    extern_methods!(
31        /// A property indicating whether the frame rate of the external display should be configured to match the camera's frame rate.
32        ///
33        /// If you want to configure your ``AVCaptureVideoPreviewLayer`` to match its source ``AVCaptureDevice/activeVideoMinFrameDuration``, set ``shouldMatchFrameRate`` to `true`. The default value is `false`.
34        #[unsafe(method(shouldMatchFrameRate))]
35        #[unsafe(method_family = none)]
36        pub unsafe fn shouldMatchFrameRate(&self) -> bool;
37
38        /// Setter for [`shouldMatchFrameRate`][Self::shouldMatchFrameRate].
39        #[unsafe(method(setShouldMatchFrameRate:))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn setShouldMatchFrameRate(&self, should_match_frame_rate: bool);
42
43        /// A property indicating whether the color space of the configurator's preview layer should be preserved on the output display by avoiding color space conversions.
44        ///
45        /// Set ``bypassColorSpaceConversion`` to `true` if you would like the configurator's  ``AVCaptureVideoPreviewLayer`` color space preserved on the output display. This is accomplished by setting the working color space to match the color space of the external display. The color properties of the ``CALayer`` remain untouched. The default value is `false`.
46        #[unsafe(method(bypassColorSpaceConversion))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn bypassColorSpaceConversion(&self) -> bool;
49
50        /// Setter for [`bypassColorSpaceConversion`][Self::bypassColorSpaceConversion].
51        #[unsafe(method(setBypassColorSpaceConversion:))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn setBypassColorSpaceConversion(&self, bypass_color_space_conversion: bool);
54
55        #[cfg(feature = "objc2-core-media")]
56        /// Your preferred external display resolution.
57        ///
58        /// Use ``preferredResolution`` to set your desired resolution of the external display. When left at the default value of { 0, 0 },  the native resolution of the external display is used.
59        #[unsafe(method(preferredResolution))]
60        #[unsafe(method_family = none)]
61        pub unsafe fn preferredResolution(&self) -> CMVideoDimensions;
62
63        #[cfg(feature = "objc2-core-media")]
64        /// Setter for [`preferredResolution`][Self::preferredResolution].
65        #[unsafe(method(setPreferredResolution:))]
66        #[unsafe(method_family = none)]
67        pub unsafe fn setPreferredResolution(&self, preferred_resolution: CMVideoDimensions);
68    );
69}
70
71/// Methods declared on superclass `NSObject`.
72impl AVCaptureExternalDisplayConfiguration {
73    extern_methods!(
74        #[unsafe(method(init))]
75        #[unsafe(method_family = init)]
76        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
77
78        #[unsafe(method(new))]
79        #[unsafe(method_family = new)]
80        pub unsafe fn new() -> Retained<Self>;
81    );
82}
83
84extern_class!(
85    /// A configurator class allowing you to configure properties of an external display to match the camera's active video format.
86    ///
87    /// An ``AVCaptureExternalDisplayConfigurator`` allows you to configure a connected external display to output a clean feed using a ``CALayer``. Using the configurator, you can opt into automatic adjustment of the external display’s color space and / or frame rate to match your device’s capture configuration. These adjustments are only applied to the external display, not to the device.
88    ///
89    /// - Note: Not all displays support the same configuration options as the device’s capture formats. Your adjustments to the external display are applied with utmost effort to accurately represent the capture device. When your capture device's ``AVCaptureDevice/activeFormat`` is unavailable on the external display, the configurator automatically chooses the closest available format.
90    ///
91    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avcaptureexternaldisplayconfigurator?language=objc)
92    #[unsafe(super(NSObject))]
93    #[derive(Debug, PartialEq, Eq, Hash)]
94    pub struct AVCaptureExternalDisplayConfigurator;
95);
96
97extern_conformance!(
98    unsafe impl NSObjectProtocol for AVCaptureExternalDisplayConfigurator {}
99);
100
101impl AVCaptureExternalDisplayConfigurator {
102    extern_methods!(
103        #[unsafe(method(init))]
104        #[unsafe(method_family = init)]
105        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
106
107        #[unsafe(method(new))]
108        #[unsafe(method_family = new)]
109        pub unsafe fn new() -> Retained<Self>;
110
111        #[cfg(all(feature = "AVCaptureDevice", feature = "objc2-quartz-core"))]
112        #[cfg(not(target_os = "watchos"))]
113        /// An external display configurator instance that attempts to synchronize the preview layer configuration with the device capture configuration.
114        ///
115        /// - Parameter device: The device for which to monitor the configuration.
116        /// - Parameter previewLayer: The layer that is being used on an external display for displaying the camera preview.
117        /// - Parameter configuration: A configuration specifying which aspects of the camera's active format to monitor and configure on the external display.
118        /// - Returns: an ``AVCaptureExternalDisplayConfigurator`` instance.
119        ///
120        /// An ``AVCaptureExternalDisplayConfigurator`` is only applicable to external displays. It determines which properties to configure on the external display based on your provided configuration (see ``AVCaptureExternalDisplayConfiguration``). The configurator observes changes to your camera''s configuration, and when changes are observed, it modifies the external display's properties to match.
121        ///
122        /// If multiple configurators are linked to the same external display ,the last one created becomes the active configurator for the external display (see ``active``).
123        ///
124        /// - Important: An `NSInvalidArgumentException` is thrown if any of the ``AVCaptureExternalDisplayConfiguration`` options are not supported.
125        #[unsafe(method(initWithDevice:previewLayer:configuration:))]
126        #[unsafe(method_family = init)]
127        pub unsafe fn initWithDevice_previewLayer_configuration(
128            this: Allocated<Self>,
129            device: &AVCaptureDevice,
130            preview_layer: &CALayer,
131            configuration: &AVCaptureExternalDisplayConfiguration,
132        ) -> Retained<Self>;
133
134        #[cfg(feature = "AVCaptureDevice")]
135        /// The device for which the coordinator configures the preview layer.
136        ///
137        /// The value of this property is the ``AVCaptureDevice`` instance you provided when instantiating the configurator. ``AVCaptureExternalDisplayConfigurator`` holds a weak reference to the device. If the device is released, this property returns `nil`.
138        #[unsafe(method(device))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn device(&self) -> Option<Retained<AVCaptureDevice>>;
141
142        #[cfg(feature = "objc2-quartz-core")]
143        #[cfg(not(target_os = "watchos"))]
144        /// The layer for which the configurator adjusts display properties to match the device's state.
145        ///
146        /// The value of this property is the ``CALayer`` instance that you provided when instantiating the configurator. You may specify either an ``AVCaptureVideoPreviewLayer`` or another ``CALayer`` instance that displays a camera's video preview. ``AVCaptureExternalDisplayConfigurator``holds a weak reference to the layer. If the layer is released, this property returns `nil`.
147        #[unsafe(method(previewLayer))]
148        #[unsafe(method_family = none)]
149        pub unsafe fn previewLayer(&self) -> Option<Retained<CALayer>>;
150
151        /// This property tells you whether the configurator is actively configuring the external display.
152        ///
153        /// When this property returns `true`, the external display is successfully configured to match the device. If it returns`false`, the configurator is not making any configuration changes to the external display. If another ``AVCaptureExternalDisplayConfigurator`` instance takes over the configuration of the external display, this property returns `false`.
154        #[unsafe(method(isActive))]
155        #[unsafe(method_family = none)]
156        pub unsafe fn isActive(&self) -> bool;
157
158        /// Forces the external display configurator to asynchronously stop configuring the external display.
159        ///
160        /// Call ``stop`` to force the ``AVCaptureExternalDisplayConfigurator`` to asynchronously stop configuring the external display. Once stopped, the ``active`` property changes to `false` and the ``activeExternalDisplayFrameRate`` becomes 0.
161        #[unsafe(method(stop))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn stop(&self);
164
165        /// The currently configured frame rate on the external display that's displaying the preview layer.
166        ///
167        /// Observe this property to determine if the configured frame rate matches the max frame rate (``AVCaptureDevice/activeVideoMinFrameDuration``) of the device. When the ``active`` property becomes `false`, this property changes to 0.
168        #[unsafe(method(activeExternalDisplayFrameRate))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn activeExternalDisplayFrameRate(&self) -> c_double;
171
172        /// Whether the external display supports matching frame rate to a capture device.
173        ///
174        /// If `true`, you may instantiate a configurator with a configuration specifying ``AVCaptureExternalDisplayConfiguration/shouldMatchFrameRate`` set to `true`.
175        #[unsafe(method(isMatchingFrameRateSupported))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn isMatchingFrameRateSupported() -> bool;
178
179        /// Whether the external display supports bypassing color space conversion.
180        ///
181        /// If `true`, you may instantiate a configurator with a configuration specifying ``AVCaptureExternalDisplayConfiguration/bypassColorSpaceConversion`` set to `true`.
182        #[unsafe(method(isBypassingColorSpaceConversionSupported))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn isBypassingColorSpaceConversionSupported() -> bool;
185
186        /// Whether the external display supports configuration to your preferred resolution.
187        ///
188        /// If `true`, you may instantiate a configurator with a configuration specifying ``AVCaptureExternalDisplayConfiguration/preferredResolution`` set to `true`.
189        #[unsafe(method(isPreferredResolutionSupported))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn isPreferredResolutionSupported() -> bool;
192    );
193}