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