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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
//! 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-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-image")]
use objc2_core_image::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;
#[cfg(feature = "objc2-image-io")]
use objc2_image_io::*;
use crate::*;
/// A block callback for processing frames of a live photo, including the still image
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/photos/phlivephotoframeprocessingblock?language=objc)
#[cfg(all(feature = "block2", feature = "objc2-core-image"))]
pub type PHLivePhotoFrameProcessingBlock = *mut block2::DynBlock<
dyn Fn(NonNull<ProtocolObject<dyn PHLivePhotoFrame>>, NonNull<*mut NSError>) -> *mut CIImage,
>;
/// [Apple's documentation](https://developer.apple.com/documentation/photos/phlivephotoeditingoption?language=objc)
// NS_TYPED_ENUM
pub type PHLivePhotoEditingOption = NSString;
extern_class!(
/// [Apple's documentation](https://developer.apple.com/documentation/photos/phlivephotoeditingcontext?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct PHLivePhotoEditingContext;
);
extern_conformance!(
unsafe impl NSObjectProtocol for PHLivePhotoEditingContext {}
);
impl PHLivePhotoEditingContext {
extern_methods!(
#[cfg(feature = "PHContentEditingInput")]
/// Initializer from the specified live photo input
/// Return nil if the specified input is not for a live photo
#[unsafe(method(initWithLivePhotoEditingInput:))]
#[unsafe(method_family = init)]
pub unsafe fn initWithLivePhotoEditingInput(
this: Allocated<Self>,
live_photo_input: &PHContentEditingInput,
) -> Option<Retained<Self>>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[cfg(feature = "objc2-core-image")]
/// The original full-size image from the input live photo
#[unsafe(method(fullSizeImage))]
#[unsafe(method_family = none)]
pub unsafe fn fullSizeImage(&self) -> Retained<CIImage>;
#[cfg(feature = "objc2-core-media")]
/// The duration of the live photo
#[unsafe(method(duration))]
#[unsafe(method_family = none)]
pub unsafe fn duration(&self) -> CMTime;
#[cfg(feature = "objc2-core-media")]
/// The time of the still image within the live photo
#[unsafe(method(photoTime))]
#[unsafe(method_family = none)]
pub unsafe fn photoTime(&self) -> CMTime;
#[cfg(all(feature = "block2", feature = "objc2-core-image"))]
/// A block that can be set to process each frame of the live photo
/// Note that the context uses a copy of the processor block during processing
///
/// # Safety
///
/// - The returned block's argument 1 must be a valid pointer.
/// - The returned block's argument 2 must be a valid pointer.
#[unsafe(method(frameProcessor))]
#[unsafe(method_family = none)]
pub unsafe fn frameProcessor(&self) -> PHLivePhotoFrameProcessingBlock;
#[cfg(all(feature = "block2", feature = "objc2-core-image"))]
/// Setter for [`frameProcessor`][Self::frameProcessor].
///
/// This is [copied][objc2_foundation::NSCopying::copy] when set.
///
/// # Safety
///
/// `frame_processor` must be a valid pointer or null.
#[unsafe(method(setFrameProcessor:))]
#[unsafe(method_family = none)]
pub unsafe fn setFrameProcessor(&self, frame_processor: PHLivePhotoFrameProcessingBlock);
/// Specify the audio volume of the edited live photo
/// Must be between 0.0 and 1.0
/// Default to 1.0
#[unsafe(method(audioVolume))]
#[unsafe(method_family = none)]
pub unsafe fn audioVolume(&self) -> c_float;
/// Setter for [`audioVolume`][Self::audioVolume].
#[unsafe(method(setAudioVolume:))]
#[unsafe(method_family = none)]
pub unsafe fn setAudioVolume(&self, audio_volume: c_float);
#[cfg(feature = "objc2-image-io")]
#[unsafe(method(orientation))]
#[unsafe(method_family = none)]
pub unsafe fn orientation(&self) -> CGImagePropertyOrientation;
#[cfg(all(
feature = "PHLivePhoto",
feature = "block2",
feature = "objc2-core-foundation"
))]
/// Asynchronously generate a new live photo suitable for playback in a PHLivePhotoView of the specified target size
/// The options dictionary can contain additional options, see below
///
/// # Safety
///
/// `options` generic should be of the correct type.
#[unsafe(method(prepareLivePhotoForPlaybackWithTargetSize:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn prepareLivePhotoForPlaybackWithTargetSize_options_completionHandler(
&self,
target_size: CGSize,
options: Option<&NSDictionary<NSString, AnyObject>>,
handler: &block2::DynBlock<dyn Fn(*mut PHLivePhoto, *mut NSError)>,
);
#[cfg(all(feature = "PHContentEditingOutput", feature = "block2"))]
/// Asynchronously process and save the edited live photo to the specified content editing output
/// Options dictionary should be nil, reserved for future expansion
///
/// # Safety
///
/// `options` generic should be of the correct type.
#[unsafe(method(saveLivePhotoToOutput:options:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn saveLivePhotoToOutput_options_completionHandler(
&self,
output: &PHContentEditingOutput,
options: Option<&NSDictionary<NSString, AnyObject>>,
handler: &block2::DynBlock<dyn Fn(Bool, *mut NSError)>,
);
/// Cancel the current asynchronous operation
/// This is implicitly called whenever prepare or save is called
/// A canceled operation will call its completion handler with an appropriate error code
#[unsafe(method(cancel))]
#[unsafe(method_family = none)]
pub unsafe fn cancel(&self);
);
}
/// Methods declared on superclass `NSObject`.
impl PHLivePhotoEditingContext {
extern_methods!(
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
/// The type of frame in the Live Photo
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/photos/phlivephotoframetype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PHLivePhotoFrameType(pub NSInteger);
impl PHLivePhotoFrameType {
/// Indicates the still image
#[doc(alias = "PHLivePhotoFrameTypePhoto")]
pub const Photo: Self = Self(0);
/// Indicates a video frame
#[doc(alias = "PHLivePhotoFrameTypeVideo")]
pub const Video: Self = Self(1);
}
unsafe impl Encode for PHLivePhotoFrameType {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for PHLivePhotoFrameType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
/// Protocol that describes a single frame of a live photo
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/photos/phlivephotoframe?language=objc)
pub unsafe trait PHLivePhotoFrame {
#[cfg(feature = "objc2-core-image")]
/// Input image for the frame
#[unsafe(method(image))]
#[unsafe(method_family = none)]
unsafe fn image(&self) -> Retained<CIImage>;
#[cfg(feature = "objc2-core-media")]
/// The time of the frame relative to the beginning of the live photo
#[unsafe(method(time))]
#[unsafe(method_family = none)]
unsafe fn time(&self) -> CMTime;
/// The type of frame
#[unsafe(method(type))]
#[unsafe(method_family = none)]
unsafe fn r#type(&self) -> PHLivePhotoFrameType;
#[cfg(feature = "objc2-core-foundation")]
/// The scale of the frame relative to the full-size image
#[unsafe(method(renderScale))]
#[unsafe(method_family = none)]
unsafe fn renderScale(&self) -> CGFloat;
}
);
extern "C" {
/// Indicates whether processing should happen at playback time
/// If set to NO (the default) the live photo will always be rendered before playback
/// If set to YES, the editing context might still choose to render first for performance reasons
/// This option is ignored by the saveLivePhotoToOutput method
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/photos/phlivephotoshouldrenderatplaybacktime?language=objc)
pub static PHLivePhotoShouldRenderAtPlaybackTime: &'static PHLivePhotoEditingOption;
}
extern "C" {
/// The error domain for all Live Photo Editing errors (Deprecated).
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/photos/phlivephotoeditingerrordomain?language=objc)
#[deprecated]
pub static PHLivePhotoEditingErrorDomain: &'static NSString;
}
/// Error code for Live Photo Editing errors (Deprecated)
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/photos/phlivephotoeditingerrorcode?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct PHLivePhotoEditingErrorCode(pub NSInteger);
impl PHLivePhotoEditingErrorCode {
#[doc(alias = "PHLivePhotoEditingErrorCodeUnknown")]
#[deprecated]
pub const Unknown: Self = Self(0);
#[doc(alias = "PHLivePhotoEditingErrorCodeAborted")]
#[deprecated]
pub const Aborted: Self = Self(1);
}
unsafe impl Encode for PHLivePhotoEditingErrorCode {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for PHLivePhotoEditingErrorCode {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}