objc2_av_foundation/generated/AVPlayerItemIntegratedTimeline.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5#[cfg(feature = "dispatch2")]
6use dispatch2::*;
7use objc2::__framework_prelude::*;
8#[cfg(feature = "objc2-core-media")]
9use objc2_core_media::*;
10use objc2_foundation::*;
11
12use crate::*;
13
14/// These constants specify the type of segment
15///
16/// Indicates segment represent playback of a primary item.
17///
18/// Indicates segment represents playback of an interstitial event.
19///
20/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemsegmenttype?language=objc)
21// NS_ENUM
22#[repr(transparent)]
23#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
24pub struct AVPlayerItemSegmentType(pub NSInteger);
25impl AVPlayerItemSegmentType {
26 #[doc(alias = "AVPlayerItemSegmentTypePrimary")]
27 pub const Primary: Self = Self(0);
28 #[doc(alias = "AVPlayerItemSegmentTypeInterstitial")]
29 pub const Interstitial: Self = Self(1);
30}
31
32unsafe impl Encode for AVPlayerItemSegmentType {
33 const ENCODING: Encoding = NSInteger::ENCODING;
34}
35
36unsafe impl RefEncode for AVPlayerItemSegmentType {
37 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
38}
39
40extern_class!(
41 /// Representing a segment of time on the integrated timeline. Segments are immutable objects.
42 ///
43 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
44 ///
45 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemsegment?language=objc)
46 #[unsafe(super(NSObject))]
47 #[derive(Debug, PartialEq, Eq, Hash)]
48 pub struct AVPlayerItemSegment;
49);
50
51unsafe impl Send for AVPlayerItemSegment {}
52
53unsafe impl Sync for AVPlayerItemSegment {}
54
55extern_conformance!(
56 unsafe impl NSObjectProtocol for AVPlayerItemSegment {}
57);
58
59impl AVPlayerItemSegment {
60 extern_methods!(
61 #[unsafe(method(init))]
62 #[unsafe(method_family = init)]
63 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
64
65 #[unsafe(method(new))]
66 #[unsafe(method_family = new)]
67 pub unsafe fn new() -> Retained<Self>;
68
69 /// The type of content this segment represents.
70 ///
71 /// This property is not atomic.
72 ///
73 /// # Safety
74 ///
75 /// This might not be thread-safe.
76 #[unsafe(method(segmentType))]
77 #[unsafe(method_family = none)]
78 pub unsafe fn segmentType(&self) -> AVPlayerItemSegmentType;
79
80 #[cfg(feature = "objc2-core-media")]
81 /// The timeMapping for this segment.
82 ///
83 /// The timeMapping source timeRange represents the start and duration in the segment source's timeline (ie: primary item timeline or interstitial event). The target timeRange represents the start point and duration in the integrated timeline. For interstitial events which occupy a single point, the target's duration will be kCMTimeZero.
84 ///
85 /// This property is not atomic.
86 ///
87 /// # Safety
88 ///
89 /// This might not be thread-safe.
90 #[unsafe(method(timeMapping))]
91 #[unsafe(method_family = none)]
92 pub unsafe fn timeMapping(&self) -> CMTimeMapping;
93
94 /// This property provides a collection of time ranges for the segment if media data is readily available. The ranges provided might be discontinuous.
95 ///
96 /// Returns an NSArray of NSValues containing CMTimeRanges. Loaded time ranges will be within the timeMapping's target timeRange. Loaded time ranges will be empty for interstitial events that occupy a single point in time.
97 #[unsafe(method(loadedTimeRanges))]
98 #[unsafe(method_family = none)]
99 pub unsafe fn loadedTimeRanges(&self) -> Retained<NSArray<NSValue>>;
100
101 /// The date this segment starts at.
102 ///
103 /// The date this segment starts at. This value will be nil if the primary item does not contain dates.
104 ///
105 /// This property is not atomic.
106 ///
107 /// # Safety
108 ///
109 /// This might not be thread-safe.
110 #[unsafe(method(startDate))]
111 #[unsafe(method_family = none)]
112 pub unsafe fn startDate(&self) -> Option<Retained<NSDate>>;
113
114 #[cfg(feature = "AVPlayerInterstitialEventController")]
115 /// The associated interstitial event for this segment.
116 ///
117 /// The associated interstitial event for this segment. This value will be nil for segments representing playback of the primary itme.
118 ///
119 /// This property is not atomic.
120 ///
121 /// # Safety
122 ///
123 /// This might not be thread-safe.
124 #[unsafe(method(interstitialEvent))]
125 #[unsafe(method_family = none)]
126 pub unsafe fn interstitialEvent(&self) -> Option<Retained<AVPlayerInterstitialEvent>>;
127 );
128}
129
130extern_class!(
131 /// AVPlayerItemIntegratedTimelineSnapshot provides an immutable representation of inspectable details from an AVPlayerItemIntegratedTimeline.
132 ///
133 /// An instance of AVPlayerItemIntegratedTimelineSnapshot is an immutable snapshot representation of inspectable details from an AVPlayerItemIntegratedTimeline. As playback progresses,
134 /// AVPlayerItemIntegratedTimelineSnapshot will not reflect the new timeline state. One can request a new snapshot instance from an AVPlayerItemIntegratedTimeline to reflect the latest timeline state.
135 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
136 ///
137 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimelinesnapshot?language=objc)
138 #[unsafe(super(NSObject))]
139 #[derive(Debug, PartialEq, Eq, Hash)]
140 pub struct AVPlayerItemIntegratedTimelineSnapshot;
141);
142
143unsafe impl Send for AVPlayerItemIntegratedTimelineSnapshot {}
144
145unsafe impl Sync for AVPlayerItemIntegratedTimelineSnapshot {}
146
147extern_conformance!(
148 unsafe impl NSObjectProtocol for AVPlayerItemIntegratedTimelineSnapshot {}
149);
150
151impl AVPlayerItemIntegratedTimelineSnapshot {
152 extern_methods!(
153 #[unsafe(method(init))]
154 #[unsafe(method_family = init)]
155 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
156
157 #[unsafe(method(new))]
158 #[unsafe(method_family = new)]
159 pub unsafe fn new() -> Retained<Self>;
160
161 #[cfg(feature = "objc2-core-media")]
162 /// Returns the duration totaling the primary item and scheduled interstitial events.
163 ///
164 /// This property returns the duration totaling the primary item and scheduled interstitial events and taking into account the interstitial event's playoutLimit and resumption offset.
165 /// Before loading the duration of the primary item, the value of this property is kCMTimeInvalid. For livestreams, this value will be kCMTimeIndefinite.
166 ///
167 /// This property is not atomic.
168 ///
169 /// # Safety
170 ///
171 /// This might not be thread-safe.
172 #[unsafe(method(duration))]
173 #[unsafe(method_family = none)]
174 pub unsafe fn duration(&self) -> CMTime;
175
176 /// Returns the current AVPlayerItemSegment playback is traversing.
177 #[unsafe(method(currentSegment))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn currentSegment(&self) -> Option<Retained<AVPlayerItemSegment>>;
180
181 /// Returns an array of AVPlayerItemSegment for the snapshot.
182 ///
183 /// Returns an array of AVPlayerItemSegment. The segments are presented in chronological order, contiguous from the previous element, and non-overlapping.
184 #[unsafe(method(segments))]
185 #[unsafe(method_family = none)]
186 pub unsafe fn segments(&self) -> Retained<NSArray<AVPlayerItemSegment>>;
187
188 #[cfg(feature = "objc2-core-media")]
189 /// Returns the current time on the integrated timeline when the snapshot was taken.
190 ///
191 /// Returns the current time on the integrated timeline when the snapshot was taken. CurrentTime will not change as playback progresses.
192 #[unsafe(method(currentTime))]
193 #[unsafe(method_family = none)]
194 pub unsafe fn currentTime(&self) -> CMTime;
195
196 /// Returns the current date when the snapshot was taken, or nil if playback is not mapped to any date.
197 #[unsafe(method(currentDate))]
198 #[unsafe(method_family = none)]
199 pub unsafe fn currentDate(&self) -> Option<Retained<NSDate>>;
200
201 #[cfg(feature = "objc2-core-media")]
202 /// Provides mapping from time to AVPlayerItemSegment and offset in segment.
203 ///
204 /// Parameter `time`: Time represented in the integrated time domain.
205 ///
206 /// Parameter `timeSegmentOut`: Output parameter for segment.
207 ///
208 /// Parameter `segmentOffsetOut`: Output parameter for offset in segment.
209 ///
210 /// Provides mapping from time to segment and offset in the segment's timeMapping target. For time that correlates to the start of multiple segments, this will return the first one.
211 ///
212 /// # Safety
213 ///
214 /// `segment_offset_out` must be a valid pointer.
215 #[unsafe(method(mapTime:toSegment:atSegmentOffset:))]
216 #[unsafe(method_family = none)]
217 pub unsafe fn mapTime_toSegment_atSegmentOffset(
218 &self,
219 time: CMTime,
220 time_segment_out: Option<&mut Retained<AVPlayerItemSegment>>,
221 segment_offset_out: NonNull<CMTime>,
222 );
223 );
224}
225
226extern_class!(
227 /// An AVPlayerItemIntegratedTimeline provides detailed timing information and control for the sequence of playback of a primary AVPlayerItem and scheduled AVPlayerInterstitialEvents.
228 ///
229 /// An object that models the timeline and sequence of playback of primary AVPlayerItem and scheduled AVPlayerInterstitialEvents. The timeline models all regions expected to be traversed during playback. Notably portions of the primary item may not be presented when exiting an interstitial event with a positive resumption offset.
230 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
231 ///
232 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimeline?language=objc)
233 #[unsafe(super(NSObject))]
234 #[derive(Debug, PartialEq, Eq, Hash)]
235 pub struct AVPlayerItemIntegratedTimeline;
236);
237
238unsafe impl Send for AVPlayerItemIntegratedTimeline {}
239
240unsafe impl Sync for AVPlayerItemIntegratedTimeline {}
241
242extern_conformance!(
243 unsafe impl NSObjectProtocol for AVPlayerItemIntegratedTimeline {}
244);
245
246impl AVPlayerItemIntegratedTimeline {
247 extern_methods!(
248 #[unsafe(method(init))]
249 #[unsafe(method_family = init)]
250 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
251
252 #[unsafe(method(new))]
253 #[unsafe(method_family = new)]
254 pub unsafe fn new() -> Retained<Self>;
255
256 /// This property provides an immutable representation of the timeline state at time of request.
257 ///
258 /// Returns an immutable representation of the timeline state at time of request. A timeline snapshot provides accessors for obtaining inspectable details of the timeline. Because a snapshot is immutable, the snapshot's properties will not update as playback continues.
259 #[unsafe(method(currentSnapshot))]
260 #[unsafe(method_family = none)]
261 pub unsafe fn currentSnapshot(&self) -> Retained<AVPlayerItemIntegratedTimelineSnapshot>;
262
263 #[cfg(feature = "objc2-core-media")]
264 /// Returns the current time on the integrated timeline.
265 ///
266 /// Returns the current time on the integrated timeline. During playback of interstitial events that occupy a single point, currentTime will not change.
267 #[unsafe(method(currentTime))]
268 #[unsafe(method_family = none)]
269 pub unsafe fn currentTime(&self) -> CMTime;
270
271 /// Returns the date of current playback, or nil if playback is not mapped to any date.
272 #[unsafe(method(currentDate))]
273 #[unsafe(method_family = none)]
274 pub unsafe fn currentDate(&self) -> Option<Retained<NSDate>>;
275 );
276}
277
278/// AVPlayerItemIntegratedTimelineControl.
279impl AVPlayerItemIntegratedTimeline {
280 extern_methods!(
281 #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
282 /// Seeks to a particular time in the integrated time domain and invokes the completionHandler
283 ///
284 /// Parameter `time`: Time represented in the integrated time domain.
285 ///
286 /// Parameter `toleranceBefore`: Tolerance before target time allowed to seek to.
287 ///
288 /// Parameter `toleranceAfter`: Tolerance after target time allowed to seek to.
289 ///
290 /// Parameter `completionHandler`: CompletionHandler callback after seek completes. Success will be true if the playhead moved to the new time.
291 ///
292 /// The integrated timeline seeks to the the range of [time-beforeTolerance, time+afterTolerance] will be attributed to a segment and AVPlayerItem that falls in that range. You can request sample accurate seeking by passing a time value of kCMTimeZero for both toleranceBefore and toleranceAfter.
293 ///
294 /// # Safety
295 ///
296 /// `completion_handler` block must be sendable.
297 #[unsafe(method(seekToTime:toleranceBefore:toleranceAfter:completionHandler:))]
298 #[unsafe(method_family = none)]
299 pub unsafe fn seekToTime_toleranceBefore_toleranceAfter_completionHandler(
300 &self,
301 time: CMTime,
302 tolerance_before: CMTime,
303 tolerance_after: CMTime,
304 completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
305 );
306
307 #[cfg(feature = "block2")]
308 /// Seeks playhead to corresponding date and invokes the completionHandler.
309 ///
310 /// Parameter `date`: The new position for the playhead.
311 ///
312 /// Parameter `completionHandler`: CompletionHandler callback after seek completes. Success will be true if the playhead moved to the new date.
313 ///
314 /// The integrated timeline will seek playhead to the coresponding date.
315 ///
316 /// # Safety
317 ///
318 /// `completion_handler` block must be sendable.
319 #[unsafe(method(seekToDate:completionHandler:))]
320 #[unsafe(method_family = none)]
321 pub unsafe fn seekToDate_completionHandler(
322 &self,
323 date: &NSDate,
324 completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
325 );
326 );
327}
328
329extern_protocol!(
330 /// Defines protocol for objects returned from timeline observer routines.
331 ///
332 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimelineobserver?language=objc)
333 pub unsafe trait AVPlayerItemIntegratedTimelineObserver: NSObjectProtocol {}
334);
335
336/// AVPlayerItemIntegratedTimelineObserver.
337impl AVPlayerItemIntegratedTimeline {
338 extern_methods!(
339 #[cfg(all(
340 feature = "block2",
341 feature = "dispatch2",
342 feature = "objc2-core-media"
343 ))]
344 /// Requests invocation of a block during playback to report changing time.
345 ///
346 /// Parameter `interval`: The interval of invocation of the block during normal playback, according to progress of the current time in the integrated timeline.
347 ///
348 /// Parameter `queue`: The serial queue onto which block should be enqueued. If you pass NULL, the main queue (obtained using dispatch_get_main_queue()) will be used. Passing a concurrent queue to this method will result in undefined behavior.
349 ///
350 /// Parameter `block`: The block to be invoked periodically.
351 ///
352 /// Returns: An object conforming to the AVPlayerItemIntegratedTimelineObserver protocol. You must retain this returned value as long as you want the time observer to be invoked by the timeline. The block is invoked periodically at the interval specified, interpreted according to the integrated timeline. The block is also invoked across AVPlayerItemSegment and AVPlayerItem boundaries, whenever time jumps, and whenever playback starts or stops. Each call to -addPeriodicTimeObserverForInterval:queue:usingBlock: should be paired with a corresponding call to -removeTimeObserver:. Releasing the observer object without a call to -removeTimeObserver: will result in undefined behavior
353 ///
354 /// # Safety
355 ///
356 /// - `queue` possibly has additional threading requirements.
357 /// - `block` block must be sendable.
358 #[unsafe(method(addPeriodicTimeObserverForInterval:queue:usingBlock:))]
359 #[unsafe(method_family = none)]
360 pub unsafe fn addPeriodicTimeObserverForInterval_queue_usingBlock(
361 &self,
362 interval: CMTime,
363 queue: Option<&DispatchQueue>,
364 block: &block2::DynBlock<dyn Fn(CMTime)>,
365 ) -> Retained<ProtocolObject<dyn AVPlayerItemIntegratedTimelineObserver>>;
366
367 #[cfg(all(feature = "block2", feature = "dispatch2"))]
368 /// Requests invocation of a block when an offset in a segment is traversed during playback.
369 ///
370 /// Parameter `segment`: AVPlayerItemSegment to monitor playback traversal of.
371 ///
372 /// Parameter `offsetsIntoSegment`: Offsets in the segment for which the observer requests notification, supplied as an array of NSValues carrying CMTimes.
373 ///
374 /// Parameter `queue`: The serial queue onto which block should be enqueued. If you pass NULL, the main queue (obtained using dispatch_get_main_queue()) will be used. Passing a concurrent queue to this method will result in undefined behavior.
375 ///
376 /// Parameter `block`: The block to be invoked when the offset is crossed during playback of a segment.
377 ///
378 /// Returns: An object conforming to the AVPlayerItemIntegratedTimelineObserver protocol. You must retain this returned value as long as you want the time observer to be invoked by the timeline. Pass this object to -removeTimeObserver: to cancel time observation. One can also configure single point segments with segmentTimes to trigger during traversal of the segment's playback. As the timeline duration and segments change, the installed time observer will be automatically adjusted to fire at the desired offset in the segment. A segment that is removed from the timeline will trigger the invocation of the block immediately with success set as false.
379 /// Each call to -addBoundaryTimeObserverForSegment:segment:offsetsInSegment:queue:usingBlock: should be paired with a corresponding call to -removeTimeObserver:. Releasing the observer object without a call to -removeTimeObserver: will result in undefined behavior
380 ///
381 /// # Safety
382 ///
383 /// - `offsets_into_segment` generic should be of the correct type.
384 /// - `queue` possibly has additional threading requirements.
385 /// - `block` block must be sendable.
386 #[unsafe(method(addBoundaryTimeObserverForSegment:offsetsIntoSegment:queue:usingBlock:))]
387 #[unsafe(method_family = none)]
388 pub unsafe fn addBoundaryTimeObserverForSegment_offsetsIntoSegment_queue_usingBlock(
389 &self,
390 segment: &AVPlayerItemSegment,
391 offsets_into_segment: &NSArray,
392 queue: Option<&DispatchQueue>,
393 block: &block2::DynBlock<dyn Fn(Bool)>,
394 ) -> Retained<ProtocolObject<dyn AVPlayerItemIntegratedTimelineObserver>>;
395
396 /// Cancels a previously registered time observer.
397 ///
398 /// Parameter `observer`: An object returned by a previous call to -addPeriodicTimeObserverForInterval or -addBoundaryTimeObserverForSegment.
399 #[unsafe(method(removeTimeObserver:))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn removeTimeObserver(
402 &self,
403 observer: &ProtocolObject<dyn AVPlayerItemIntegratedTimelineObserver>,
404 );
405 );
406}
407
408extern "C" {
409 /// A notification which is posted when the snapshot objects provided by this timeline would be out of sync with the current timeline state. See keys below.
410 ///
411 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncnotification?language=objc)
412 pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncNotification:
413 &'static NSNotificationName;
414}
415
416extern "C" {
417 /// Indicates the reason for the snapshot out of sync notification.
418 ///
419 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonkey?language=objc)
420 pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonKey: &'static NSString;
421}
422
423/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreason?language=objc)
424// NS_TYPED_ENUM
425pub type AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason = NSString;
426
427extern "C" {
428 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonsegmentschanged?language=objc)
429 pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonSegmentsChanged:
430 &'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
431}
432
433extern "C" {
434 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasoncurrentsegmentchanged?language=objc)
435 pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonCurrentSegmentChanged:
436 &'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
437}
438
439extern "C" {
440 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonloadedtimerangeschanged?language=objc)
441 pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonLoadedTimeRangesChanged:
442 &'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
443}
444
445/// AVPlayerItemIntegratedTimelineSupport.
446#[cfg(feature = "AVPlayerItem")]
447impl AVPlayerItem {
448 extern_methods!(
449 /// Obtain an instance of AVPlayerItemIntegratedTimeline representing the timing and control of playback of the item with its scheduled AVPlayerInterstitialEvents. This value will return nil for AVPlayerItems in an interstitial player.
450 #[unsafe(method(integratedTimeline))]
451 #[unsafe(method_family = none)]
452 pub unsafe fn integratedTimeline(&self) -> Retained<AVPlayerItemIntegratedTimeline>;
453 );
454}