objc2_av_foundation/generated/
AVExternalSyncDevice.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::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// Connection state of an external sync device
13///
14/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avexternalsyncdevicestatus?language=objc)
15// NS_ENUM
16#[repr(transparent)]
17#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub struct AVExternalSyncDeviceStatus(pub NSInteger);
19impl AVExternalSyncDeviceStatus {
20    /// Indicates that external sync signal is not connected, or has transitioned to a state that is not recoverable.
21    #[doc(alias = "AVExternalSyncDeviceStatusUnavailable")]
22    pub const Unavailable: Self = Self(0);
23    /// Indicates that a device supporting external sync is connected, but calibration has not started.
24    #[doc(alias = "AVExternalSyncDeviceStatusReady")]
25    pub const Ready: Self = Self(1);
26    /// Indicates that the external sync signal is connected and that the AVExternalSyncDevice object is calibrating to follow.
27    #[doc(alias = "AVExternalSyncDeviceStatusCalibrating")]
28    pub const Calibrating: Self = Self(2);
29    /// Indicates that the ``AVExternalSyncDevice`` object is running and that the clock property on ``AVExternalSyncDevice`` is calibrated to the external sync signal.
30    #[doc(alias = "AVExternalSyncDeviceStatusActiveSync")]
31    pub const ActiveSync: Self = Self(3);
32    /// Indicates that the AVExternalSyncDevice was calibrated to follow the external sync, but the sync signal has been lost. The camera will continue to match the last signal it received, but sync is not guaranteed.
33    #[doc(alias = "AVExternalSyncDeviceStatusFreeRunSync")]
34    pub const FreeRunSync: Self = Self(4);
35}
36
37unsafe impl Encode for AVExternalSyncDeviceStatus {
38    const ENCODING: Encoding = NSInteger::ENCODING;
39}
40
41unsafe impl RefEncode for AVExternalSyncDeviceStatus {
42    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
43}
44
45extern_class!(
46    /// An external sync device connected to a host device that can be used to drive the timing of an internal component, such as a camera sensor.
47    ///
48    /// Each instance of ``AVExternalSyncDevice`` corresponds to a physical external device that can drive an internal component, like a camera readout. You cannot create instances of ``AVExternalSyncDevice``. Instead, you obtain an array of all currently available external sync devices using ``AVExternalSyncDeviceDiscoverySession``.
49    ///
50    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avexternalsyncdevice?language=objc)
51    #[unsafe(super(NSObject))]
52    #[derive(Debug, PartialEq, Eq, Hash)]
53    pub struct AVExternalSyncDevice;
54);
55
56extern_conformance!(
57    unsafe impl NSObjectProtocol for AVExternalSyncDevice {}
58);
59
60impl AVExternalSyncDevice {
61    extern_methods!(
62        #[unsafe(method(init))]
63        #[unsafe(method_family = init)]
64        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
65
66        #[unsafe(method(new))]
67        #[unsafe(method_family = new)]
68        pub unsafe fn new() -> Retained<Self>;
69
70        /// The status of the externally connected device.
71        ///
72        /// Use this property to query the current connection status of the external sync device. This property is key-value observable.
73        #[unsafe(method(status))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn status(&self) -> AVExternalSyncDeviceStatus;
76
77        #[cfg(feature = "objc2-core-media")]
78        /// A clock representing the source of time from the external sync device.
79        ///
80        /// This property returns `NULL` until the ``status`` reaches ``AVExternalSyncDeviceStatusActiveSync``.
81        #[unsafe(method(clock))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn clock(&self) -> Option<Retained<CMClock>>;
84
85        #[cfg(feature = "objc2-core-media")]
86        /// Delay to wait before starting the frame capture.
87        ///
88        /// An external sync is generally used to configure multiple devices in the real world. A display and a camera may receive a signal at the same time, but that does not mean the refresh of the display and camera are aligned in a way that does not cause tearing in the recording. The signal compensation delay can be used to offset the readout of a camera on an intra-frame scale.
89        ///
90        /// - Important: You should always set this property to a value less than the frame duration at which the camera is operating.
91        #[unsafe(method(signalCompensationDelay))]
92        #[unsafe(method_family = none)]
93        pub unsafe fn signalCompensationDelay(&self) -> CMTime;
94
95        #[cfg(feature = "objc2-core-media")]
96        /// Setter for [`signalCompensationDelay`][Self::signalCompensationDelay].
97        #[unsafe(method(setSignalCompensationDelay:))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn setSignalCompensationDelay(&self, signal_compensation_delay: CMTime);
100
101        /// A unique identifier for an external sync device.
102        ///
103        /// Use this property to select a specific external sync device.
104        #[unsafe(method(uuid))]
105        #[unsafe(method_family = none)]
106        pub unsafe fn uuid(&self) -> Retained<NSUUID>;
107
108        /// The USB vendor identifier associated with the external sync device.
109        ///
110        /// This `UInt32` value is provided by the hardware vendor, and returns 0 if not available.
111        #[unsafe(method(vendorID))]
112        #[unsafe(method_family = none)]
113        pub unsafe fn vendorID(&self) -> u32;
114
115        /// The USB product identifier associated with the external sync device.
116        ///
117        /// This `UInt32` value comes from the hardware vendor, and returns 0 if not available. Use this value in conjunction with the ``vendorID`` to determine a specific product.
118        #[unsafe(method(productID))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn productID(&self) -> u32;
121    );
122}
123
124extern_class!(
125    /// A means of discovering and monitoring connection / disconnection of external sync devices to the host.
126    ///
127    /// ``AVExternalSyncDeviceDiscoverySession`` is a singleton that lists the external sync devices connected to the host. The client is expected to key-value observe the ``AVExternalSyncDeviceDiscoverySession/devices`` property for changes to the external sync devices list.
128    ///
129    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avexternalsyncdevicediscoverysession?language=objc)
130    #[unsafe(super(NSObject))]
131    #[derive(Debug, PartialEq, Eq, Hash)]
132    pub struct AVExternalSyncDeviceDiscoverySession;
133);
134
135extern_conformance!(
136    unsafe impl NSObjectProtocol for AVExternalSyncDeviceDiscoverySession {}
137);
138
139impl AVExternalSyncDeviceDiscoverySession {
140    extern_methods!(
141        #[unsafe(method(init))]
142        #[unsafe(method_family = init)]
143        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
144
145        #[unsafe(method(new))]
146        #[unsafe(method_family = new)]
147        pub unsafe fn new() -> Retained<Self>;
148
149        /// The singleton instance of the external sync source device discovery session.
150        ///
151        /// Access the one and only external sync device discovery session on this host device using this method. ``sharedSession`` returns `nil` if the host device doesn't support external sync devices.
152        #[unsafe(method(sharedSession))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn sharedSession() -> Option<Retained<AVExternalSyncDeviceDiscoverySession>>;
155
156        /// Whether external sync devices are supported by this device.
157        ///
158        /// A value of `true` indicates that external sync devices are supported while `false` indicates they are not.
159        #[unsafe(method(isSupported))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn isSupported() -> bool;
162
163        /// An array of external sync devices connected to this host.
164        ///
165        /// The list is updated when external sync devices are connected to the host and they remain in the list until they become unavailable. This property is key-value observable.
166        #[unsafe(method(devices))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn devices(&self) -> Retained<NSArray<AVExternalSyncDevice>>;
169    );
170}
171
172extern_protocol!(
173    /// Defines an interface for delegates of ``AVCaptureDeviceInput`` to respond to events that occur when connecting, calibrating, and disconnecting external sync devices.
174    ///
175    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avexternalsyncdevicedelegate?language=objc)
176    pub unsafe trait AVExternalSyncDeviceDelegate: NSObjectProtocol {
177        /// Informs your delegate when the external sync device status has changed.
178        #[optional]
179        #[unsafe(method(externalSyncDeviceStatusDidChange:))]
180        #[unsafe(method_family = none)]
181        unsafe fn externalSyncDeviceStatusDidChange(&self, device: &AVExternalSyncDevice);
182
183        #[optional]
184        #[unsafe(method(externalSyncDevice:failedWithError:))]
185        #[unsafe(method_family = none)]
186        unsafe fn externalSyncDevice_failedWithError(
187            &self,
188            device: &AVExternalSyncDevice,
189            error: Option<&NSError>,
190        );
191    }
192);