//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
#[cfg(feature = "dispatch2")]
use dispatch2::*;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-media")]
use objc2_core_media::*;
use objc2_foundation::*;
use crate::*;
/// These constants specify the type of segment
///
/// Indicates segment represent playback of a primary item.
///
/// Indicates segment represents playback of an interstitial event.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemsegmenttype?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct AVPlayerItemSegmentType(pub NSInteger);
impl AVPlayerItemSegmentType {
#[doc(alias = "AVPlayerItemSegmentTypePrimary")]
pub const Primary: Self = Self(0);
#[doc(alias = "AVPlayerItemSegmentTypeInterstitial")]
pub const Interstitial: Self = Self(1);
}
unsafe impl Encode for AVPlayerItemSegmentType {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for AVPlayerItemSegmentType {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_class!(
/// Representing a segment of time on the integrated timeline. Segments are immutable objects.
///
/// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemsegment?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVPlayerItemSegment;
);
unsafe impl Send for AVPlayerItemSegment {}
unsafe impl Sync for AVPlayerItemSegment {}
extern_conformance!(
unsafe impl NSObjectProtocol for AVPlayerItemSegment {}
);
impl AVPlayerItemSegment {
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 type of content this segment represents.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(segmentType))]
#[unsafe(method_family = none)]
pub unsafe fn segmentType(&self) -> AVPlayerItemSegmentType;
#[cfg(feature = "objc2-core-media")]
/// The timeMapping for this segment.
///
/// 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.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(timeMapping))]
#[unsafe(method_family = none)]
pub unsafe fn timeMapping(&self) -> CMTimeMapping;
/// This property provides a collection of time ranges for the segment if media data is readily available. The ranges provided might be discontinuous.
///
/// 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.
#[unsafe(method(loadedTimeRanges))]
#[unsafe(method_family = none)]
pub unsafe fn loadedTimeRanges(&self) -> Retained<NSArray<NSValue>>;
/// The date this segment starts at.
///
/// The date this segment starts at. This value will be nil if the primary item does not contain dates.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(startDate))]
#[unsafe(method_family = none)]
pub unsafe fn startDate(&self) -> Option<Retained<NSDate>>;
#[cfg(feature = "AVPlayerInterstitialEventController")]
/// The associated interstitial event for this segment.
///
/// The associated interstitial event for this segment. This value will be nil for segments representing playback of the primary itme.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(interstitialEvent))]
#[unsafe(method_family = none)]
pub unsafe fn interstitialEvent(&self) -> Option<Retained<AVPlayerInterstitialEvent>>;
);
}
extern_class!(
/// AVPlayerItemIntegratedTimelineSnapshot provides an immutable representation of inspectable details from an AVPlayerItemIntegratedTimeline.
///
/// An instance of AVPlayerItemIntegratedTimelineSnapshot is an immutable snapshot representation of inspectable details from an AVPlayerItemIntegratedTimeline. As playback progresses,
/// AVPlayerItemIntegratedTimelineSnapshot will not reflect the new timeline state. One can request a new snapshot instance from an AVPlayerItemIntegratedTimeline to reflect the latest timeline state.
/// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimelinesnapshot?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVPlayerItemIntegratedTimelineSnapshot;
);
unsafe impl Send for AVPlayerItemIntegratedTimelineSnapshot {}
unsafe impl Sync for AVPlayerItemIntegratedTimelineSnapshot {}
extern_conformance!(
unsafe impl NSObjectProtocol for AVPlayerItemIntegratedTimelineSnapshot {}
);
impl AVPlayerItemIntegratedTimelineSnapshot {
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>;
#[cfg(feature = "objc2-core-media")]
/// Returns the duration totaling the primary item and scheduled interstitial events.
///
/// 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.
/// Before loading the duration of the primary item, the value of this property is kCMTimeInvalid. For livestreams, this value will be kCMTimeIndefinite.
///
/// This property is not atomic.
///
/// # Safety
///
/// This might not be thread-safe.
#[unsafe(method(duration))]
#[unsafe(method_family = none)]
pub unsafe fn duration(&self) -> CMTime;
/// Returns the current AVPlayerItemSegment playback is traversing.
#[unsafe(method(currentSegment))]
#[unsafe(method_family = none)]
pub unsafe fn currentSegment(&self) -> Option<Retained<AVPlayerItemSegment>>;
/// Returns an array of AVPlayerItemSegment for the snapshot.
///
/// Returns an array of AVPlayerItemSegment. The segments are presented in chronological order, contiguous from the previous element, and non-overlapping.
#[unsafe(method(segments))]
#[unsafe(method_family = none)]
pub unsafe fn segments(&self) -> Retained<NSArray<AVPlayerItemSegment>>;
#[cfg(feature = "objc2-core-media")]
/// Returns the current time on the integrated timeline when the snapshot was taken.
///
/// Returns the current time on the integrated timeline when the snapshot was taken. CurrentTime will not change as playback progresses.
#[unsafe(method(currentTime))]
#[unsafe(method_family = none)]
pub unsafe fn currentTime(&self) -> CMTime;
/// Returns the current date when the snapshot was taken, or nil if playback is not mapped to any date.
#[unsafe(method(currentDate))]
#[unsafe(method_family = none)]
pub unsafe fn currentDate(&self) -> Option<Retained<NSDate>>;
#[cfg(feature = "objc2-core-media")]
/// Provides mapping from time to AVPlayerItemSegment and offset in segment.
///
/// Parameter `time`: Time represented in the integrated time domain.
///
/// Parameter `timeSegmentOut`: Output parameter for segment.
///
/// Parameter `segmentOffsetOut`: Output parameter for offset in segment.
///
/// 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.
///
/// # Safety
///
/// `segment_offset_out` must be a valid pointer.
#[unsafe(method(mapTime:toSegment:atSegmentOffset:))]
#[unsafe(method_family = none)]
pub unsafe fn mapTime_toSegment_atSegmentOffset(
&self,
time: CMTime,
time_segment_out: Option<&mut Retained<AVPlayerItemSegment>>,
segment_offset_out: NonNull<CMTime>,
);
);
}
extern_class!(
/// An AVPlayerItemIntegratedTimeline provides detailed timing information and control for the sequence of playback of a primary AVPlayerItem and scheduled AVPlayerInterstitialEvents.
///
/// 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.
/// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimeline?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct AVPlayerItemIntegratedTimeline;
);
unsafe impl Send for AVPlayerItemIntegratedTimeline {}
unsafe impl Sync for AVPlayerItemIntegratedTimeline {}
extern_conformance!(
unsafe impl NSObjectProtocol for AVPlayerItemIntegratedTimeline {}
);
impl AVPlayerItemIntegratedTimeline {
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>;
/// This property provides an immutable representation of the timeline state at time of request.
///
/// 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.
#[unsafe(method(currentSnapshot))]
#[unsafe(method_family = none)]
pub unsafe fn currentSnapshot(&self) -> Retained<AVPlayerItemIntegratedTimelineSnapshot>;
#[cfg(feature = "objc2-core-media")]
/// Returns the current time on the integrated timeline.
///
/// Returns the current time on the integrated timeline. During playback of interstitial events that occupy a single point, currentTime will not change.
#[unsafe(method(currentTime))]
#[unsafe(method_family = none)]
pub unsafe fn currentTime(&self) -> CMTime;
/// Returns the date of current playback, or nil if playback is not mapped to any date.
#[unsafe(method(currentDate))]
#[unsafe(method_family = none)]
pub unsafe fn currentDate(&self) -> Option<Retained<NSDate>>;
);
}
/// AVPlayerItemIntegratedTimelineControl.
impl AVPlayerItemIntegratedTimeline {
extern_methods!(
#[cfg(all(feature = "block2", feature = "objc2-core-media"))]
/// Seeks to a particular time in the integrated time domain and invokes the completionHandler
///
/// Parameter `time`: Time represented in the integrated time domain.
///
/// Parameter `toleranceBefore`: Tolerance before target time allowed to seek to.
///
/// Parameter `toleranceAfter`: Tolerance after target time allowed to seek to.
///
/// Parameter `completionHandler`: CompletionHandler callback after seek completes. Success will be true if the playhead moved to the new time.
///
/// 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.
///
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(seekToTime:toleranceBefore:toleranceAfter:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn seekToTime_toleranceBefore_toleranceAfter_completionHandler(
&self,
time: CMTime,
tolerance_before: CMTime,
tolerance_after: CMTime,
completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
);
#[cfg(feature = "block2")]
/// Seeks playhead to corresponding date and invokes the completionHandler.
///
/// Parameter `date`: The new position for the playhead.
///
/// Parameter `completionHandler`: CompletionHandler callback after seek completes. Success will be true if the playhead moved to the new date.
///
/// The integrated timeline will seek playhead to the coresponding date.
///
/// # Safety
///
/// `completion_handler` block must be sendable.
#[unsafe(method(seekToDate:completionHandler:))]
#[unsafe(method_family = none)]
pub unsafe fn seekToDate_completionHandler(
&self,
date: &NSDate,
completion_handler: Option<&block2::DynBlock<dyn Fn(Bool)>>,
);
);
}
extern_protocol!(
/// Defines protocol for objects returned from timeline observer routines.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemintegratedtimelineobserver?language=objc)
pub unsafe trait AVPlayerItemIntegratedTimelineObserver: NSObjectProtocol {}
);
/// AVPlayerItemIntegratedTimelineObserver.
impl AVPlayerItemIntegratedTimeline {
extern_methods!(
#[cfg(all(
feature = "block2",
feature = "dispatch2",
feature = "objc2-core-media"
))]
/// Requests invocation of a block during playback to report changing time.
///
/// Parameter `interval`: The interval of invocation of the block during normal playback, according to progress of the current time in the integrated timeline.
///
/// 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.
///
/// Parameter `block`: The block to be invoked periodically.
///
/// 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
///
/// # Safety
///
/// - `queue` possibly has additional threading requirements.
/// - `block` block must be sendable.
#[unsafe(method(addPeriodicTimeObserverForInterval:queue:usingBlock:))]
#[unsafe(method_family = none)]
pub unsafe fn addPeriodicTimeObserverForInterval_queue_usingBlock(
&self,
interval: CMTime,
queue: Option<&DispatchQueue>,
block: &block2::DynBlock<dyn Fn(CMTime)>,
) -> Retained<ProtocolObject<dyn AVPlayerItemIntegratedTimelineObserver>>;
#[cfg(all(feature = "block2", feature = "dispatch2"))]
/// Requests invocation of a block when an offset in a segment is traversed during playback.
///
/// Parameter `segment`: AVPlayerItemSegment to monitor playback traversal of.
///
/// Parameter `offsetsIntoSegment`: Offsets in the segment for which the observer requests notification, supplied as an array of NSValues carrying CMTimes.
///
/// 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.
///
/// Parameter `block`: The block to be invoked when the offset is crossed during playback of a segment.
///
/// 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.
/// 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
///
/// # Safety
///
/// - `offsets_into_segment` generic should be of the correct type.
/// - `queue` possibly has additional threading requirements.
/// - `block` block must be sendable.
#[unsafe(method(addBoundaryTimeObserverForSegment:offsetsIntoSegment:queue:usingBlock:))]
#[unsafe(method_family = none)]
pub unsafe fn addBoundaryTimeObserverForSegment_offsetsIntoSegment_queue_usingBlock(
&self,
segment: &AVPlayerItemSegment,
offsets_into_segment: &NSArray,
queue: Option<&DispatchQueue>,
block: &block2::DynBlock<dyn Fn(Bool)>,
) -> Retained<ProtocolObject<dyn AVPlayerItemIntegratedTimelineObserver>>;
/// Cancels a previously registered time observer.
///
/// Parameter `observer`: An object returned by a previous call to -addPeriodicTimeObserverForInterval or -addBoundaryTimeObserverForSegment.
#[unsafe(method(removeTimeObserver:))]
#[unsafe(method_family = none)]
pub unsafe fn removeTimeObserver(
&self,
observer: &ProtocolObject<dyn AVPlayerItemIntegratedTimelineObserver>,
);
);
}
extern "C" {
/// 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.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncnotification?language=objc)
pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncNotification:
&'static NSNotificationName;
}
extern "C" {
/// Indicates the reason for the snapshot out of sync notification.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonkey?language=objc)
pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonKey: &'static NSString;
}
/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreason?language=objc)
// NS_TYPED_ENUM
pub type AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason = NSString;
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonsegmentschanged?language=objc)
pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonSegmentsChanged:
&'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasoncurrentsegmentchanged?language=objc)
pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonCurrentSegmentChanged:
&'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
}
extern "C" {
/// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayerintegratedtimelinesnapshotsoutofsyncreasonloadedtimerangeschanged?language=objc)
pub static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReasonLoadedTimeRangesChanged:
&'static AVPlayerIntegratedTimelineSnapshotsOutOfSyncReason;
}
/// AVPlayerItemIntegratedTimelineSupport.
#[cfg(feature = "AVPlayerItem")]
impl AVPlayerItem {
extern_methods!(
/// 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.
#[unsafe(method(integratedTimeline))]
#[unsafe(method_family = none)]
pub unsafe fn integratedTimeline(&self) -> Retained<AVPlayerItemIntegratedTimeline>;
);
}