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;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-core-media")]
7use objc2_core_media::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12/// These constants specify the type of segment
13///
14/// Indicates segment represent playback of a primary item.
15///
16/// Indicates segment represents playback of an interstitial event.
17///
18/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemsegmenttype?language=objc)
19// NS_ENUM
20#[repr(transparent)]
21#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct AVPlayerItemSegmentType(pub NSInteger);
23impl AVPlayerItemSegmentType {
24    #[doc(alias = "AVPlayerItemSegmentTypePrimary")]
25    pub const Primary: Self = Self(0);
26    #[doc(alias = "AVPlayerItemSegmentTypeInterstitial")]
27    pub const Interstitial: Self = Self(1);
28}
29
30unsafe impl Encode for AVPlayerItemSegmentType {
31    const ENCODING: Encoding = NSInteger::ENCODING;
32}
33
34unsafe impl RefEncode for AVPlayerItemSegmentType {
35    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
36}
37
38extern_class!(
39    /// Representing a segment of time on the integrated timeline. Segments are immutable objects.
40    ///
41    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
42    ///
43    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemsegment?language=objc)
44    #[unsafe(super(NSObject))]
45    #[derive(Debug, PartialEq, Eq, Hash)]
46    pub struct AVPlayerItemSegment;
47);
48
49unsafe impl Send for AVPlayerItemSegment {}
50
51unsafe impl Sync for AVPlayerItemSegment {}
52
53unsafe impl NSObjectProtocol for AVPlayerItemSegment {}
54
55impl AVPlayerItemSegment {
56    extern_methods!(
57        #[unsafe(method(init))]
58        #[unsafe(method_family = init)]
59        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
60
61        #[unsafe(method(new))]
62        #[unsafe(method_family = new)]
63        pub unsafe fn new() -> Retained<Self>;
64
65        /// The type of content this segment represents.
66        #[unsafe(method(segmentType))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn segmentType(&self) -> AVPlayerItemSegmentType;
69
70        #[cfg(feature = "objc2-core-media")]
71        /// The timeMapping for this segment.
72        ///
73        /// 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.
74        #[unsafe(method(timeMapping))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn timeMapping(&self) -> CMTimeMapping;
77
78        /// This property provides a collection of time ranges for the segment if media data is readily available. The ranges provided might be discontinuous.
79        ///
80        /// 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.
81        #[unsafe(method(loadedTimeRanges))]
82        #[unsafe(method_family = none)]
83        pub unsafe fn loadedTimeRanges(&self) -> Retained<NSArray<NSValue>>;
84
85        /// The date this segment starts at.
86        ///
87        /// The date this segment starts at. This value will be nil if the primary item does not contain dates.
88        #[unsafe(method(startDate))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn startDate(&self) -> Option<Retained<NSDate>>;
91
92        #[cfg(feature = "AVPlayerInterstitialEventController")]
93        /// The associated interstitial event for this segment.
94        ///
95        /// The associated interstitial event for this segment. This value will be nil for segments representing playback of the primary itme.
96        #[unsafe(method(interstitialEvent))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn interstitialEvent(&self) -> Option<Retained<AVPlayerInterstitialEvent>>;
99    );
100}
101
102extern_class!(
103    /// AVPlayerItemIntegratedTimelineSnapshot provides an immutable representation of inspectable details from an AVPlayerItemIntegratedTimeline.
104    ///
105    /// An instance of AVPlayerItemIntegratedTimelineSnapshot is an immutable snapshot representation of inspectable details from an AVPlayerItemIntegratedTimeline. As playback progresses,
106    /// AVPlayerItemIntegratedTimelineSnapshot will not reflect the new timeline state. One can request a new snapshot instance from an AVPlayerItemIntegratedTimeline to reflect the latest timeline state.
107    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
108    ///
109    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimelinesnapshot?language=objc)
110    #[unsafe(super(NSObject))]
111    #[derive(Debug, PartialEq, Eq, Hash)]
112    pub struct AVPlayerItemIntegratedTimelineSnapshot;
113);
114
115unsafe impl Send for AVPlayerItemIntegratedTimelineSnapshot {}
116
117unsafe impl Sync for AVPlayerItemIntegratedTimelineSnapshot {}
118
119unsafe impl NSObjectProtocol for AVPlayerItemIntegratedTimelineSnapshot {}
120
121impl AVPlayerItemIntegratedTimelineSnapshot {
122    extern_methods!(
123        #[unsafe(method(init))]
124        #[unsafe(method_family = init)]
125        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
126
127        #[unsafe(method(new))]
128        #[unsafe(method_family = new)]
129        pub unsafe fn new() -> Retained<Self>;
130
131        #[cfg(feature = "objc2-core-media")]
132        /// Returns the duration totaling the primary item and scheduled interstitial events.
133        ///
134        /// 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.
135        /// Before loading the duration of the primary item, the value of this property is kCMTimeInvalid. For livestreams, this value will be kCMTimeIndefinite.
136        #[unsafe(method(duration))]
137        #[unsafe(method_family = none)]
138        pub unsafe fn duration(&self) -> CMTime;
139
140        /// Returns the current AVPlayerItemSegment playback is traversing.
141        #[unsafe(method(currentSegment))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn currentSegment(&self) -> Option<Retained<AVPlayerItemSegment>>;
144
145        /// Returns an array of AVPlayerItemSegment for the snapshot.
146        ///
147        /// Returns an array of AVPlayerItemSegment. The segments are presented in chronological order, contiguous from the previous element, and non-overlapping.
148        #[unsafe(method(segments))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn segments(&self) -> Retained<NSArray<AVPlayerItemSegment>>;
151
152        #[cfg(feature = "objc2-core-media")]
153        /// Returns the current time on the integrated timeline when the snapshot was taken.
154        ///
155        /// Returns the current time on the integrated timeline when the snapshot was taken. CurrentTime will not change as playback progresses.
156        #[unsafe(method(currentTime))]
157        #[unsafe(method_family = none)]
158        pub unsafe fn currentTime(&self) -> CMTime;
159
160        /// Returns the  current date when the snapshot was taken, or nil if playback is not mapped to any date.
161        #[unsafe(method(currentDate))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn currentDate(&self) -> Option<Retained<NSDate>>;
164
165        #[cfg(feature = "objc2-core-media")]
166        /// Provides mapping from time to AVPlayerItemSegment and offset in segment.
167        ///
168        /// Parameter `time`: Time represented in the integrated time domain.
169        ///
170        /// Parameter `timeSegmentOut`: Output parameter for segment.
171        ///
172        /// Parameter `segmentOffsetOut`: Output parameter for offset in segment.
173        ///
174        /// 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.
175        #[unsafe(method(mapTime:toSegment:atSegmentOffset:))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn mapTime_toSegment_atSegmentOffset(
178            &self,
179            time: CMTime,
180            time_segment_out: Option<&mut Retained<AVPlayerItemSegment>>,
181            segment_offset_out: NonNull<CMTime>,
182        );
183    );
184}
185
186extern_class!(
187    /// An AVPlayerItemIntegratedTimeline provides detailed timing information and control for the sequence of playback of a primary AVPlayerItem and scheduled AVPlayerInterstitialEvents.
188    ///
189    /// 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.
190    /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
191    ///
192    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimeline?language=objc)
193    #[unsafe(super(NSObject))]
194    #[derive(Debug, PartialEq, Eq, Hash)]
195    pub struct AVPlayerItemIntegratedTimeline;
196);
197
198unsafe impl Send for AVPlayerItemIntegratedTimeline {}
199
200unsafe impl Sync for AVPlayerItemIntegratedTimeline {}
201
202unsafe impl NSObjectProtocol for AVPlayerItemIntegratedTimeline {}
203
204impl AVPlayerItemIntegratedTimeline {
205    extern_methods!(
206        #[unsafe(method(init))]
207        #[unsafe(method_family = init)]
208        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
209
210        #[unsafe(method(new))]
211        #[unsafe(method_family = new)]
212        pub unsafe fn new() -> Retained<Self>;
213
214        /// This property provides an immutable representation of the timeline state at time of request.
215        ///
216        /// 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.
217        #[unsafe(method(currentSnapshot))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn currentSnapshot(&self) -> Retained<AVPlayerItemIntegratedTimelineSnapshot>;
220
221        #[cfg(feature = "objc2-core-media")]
222        /// Returns the current time on the integrated timeline.
223        ///
224        /// Returns the current time on the integrated timeline. During playback of interstitial events that occupy a single point, currentTime will not change.
225        #[unsafe(method(currentTime))]
226        #[unsafe(method_family = none)]
227        pub unsafe fn currentTime(&self) -> CMTime;
228
229        /// Returns the date of current playback, or nil if playback is not mapped to any date.
230        #[unsafe(method(currentDate))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn currentDate(&self) -> Option<Retained<NSDate>>;
233    );
234}
235
236/// AVPlayerItemIntegratedTimelineControl.
237impl AVPlayerItemIntegratedTimeline {
238    extern_methods!(
239        #[cfg(all(feature = "block2", feature = "objc2-core-media"))]
240        /// Seeks to a particular time in the integrated time domain and invokes the completionHandler
241        ///
242        /// Parameter `time`: Time represented in the integrated time domain.
243        ///
244        /// Parameter `toleranceBefore`: Tolerance before target time allowed to seek to.
245        ///
246        /// Parameter `toleranceAfter`: Tolerance after target time allowed to seek to.
247        ///
248        /// Parameter `completionHandler`: CompletionHandler callback after seek completes. Success will be true if the playhead moved to the new time.
249        ///
250        /// 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.
251        #[unsafe(method(seekToTime:toleranceBefore:toleranceAfter:completionHandler:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn seekToTime_toleranceBefore_toleranceAfter_completionHandler(
254            &self,
255            time: CMTime,
256            tolerance_before: CMTime,
257            tolerance_after: CMTime,
258            completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
259        );
260
261        #[cfg(feature = "block2")]
262        /// Seeks playhead to corresponding date and invokes the completionHandler.
263        ///
264        /// Parameter `date`: The new position for the playhead.
265        ///
266        /// Parameter `completionHandler`: CompletionHandler callback after seek completes. Success will be true if the playhead moved to the new date.
267        ///
268        /// The integrated timeline will seek playhead to the coresponding date.
269        #[unsafe(method(seekToDate:completionHandler:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn seekToDate_completionHandler(
272            &self,
273            date: &NSDate,
274            completion_handler: Option<&block2::Block<dyn Fn(Bool)>>,
275        );
276    );
277}
278
279extern_protocol!(
280    /// Defines protocol for objects returned from timeline observer routines.
281    ///
282    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimelineobserver?language=objc)
283    pub unsafe trait AVPlayerItemIntegratedTimelineObserver: NSObjectProtocol {}
284);
285
286/// AVPlayerItemIntegratedTimelineObserver.
287impl AVPlayerItemIntegratedTimeline {
288    extern_methods!(
289        /// Cancels a previously registered time observer.
290        ///
291        /// Parameter `observer`: An object returned by a previous call to -addPeriodicTimeObserverForInterval or -addBoundaryTimeObserverForSegment.
292        #[unsafe(method(removeTimeObserver:))]
293        #[unsafe(method_family = none)]
294        pub unsafe fn removeTimeObserver(
295            &self,
296            observer: &ProtocolObject<dyn AVPlayerItemIntegratedTimelineObserver>,
297        );
298    );
299}
300
301extern "C" {
302    /// 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.
303    ///
304    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncnotification?language=objc)
305    pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncNotification:
306        &'static NSNotificationName;
307}
308
309extern "C" {
310    /// Indicates the reason for the snapshot out of sync notification.
311    ///
312    /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonkey?language=objc)
313    pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonKey: &'static NSString;
314}
315
316/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreason?language=objc)
317// NS_TYPED_ENUM
318pub type AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason = NSString;
319
320extern "C" {
321    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonsegmentschanged?language=objc)
322    pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonSegmentsChanged:
323        &'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
324}
325
326extern "C" {
327    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasoncurrentsegmentchanged?language=objc)
328    pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonCurrentSegmentChanged:
329        &'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
330}
331
332extern "C" {
333    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonloadedtimerangeschanged?language=objc)
334    pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonLoadedTimeRangesChanged:
335        &'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
336}
337
338/// AVPlayerItemIntegratedTimelineSupport.
339#[cfg(feature = "AVPlayerItem")]
340impl AVPlayerItem {
341    extern_methods!(
342        /// 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.
343        #[unsafe(method(integratedTimeline))]
344        #[unsafe(method_family = none)]
345        pub unsafe fn integratedTimeline(&self) -> Retained<AVPlayerItemIntegratedTimeline>;
346    );
347}