objc2_av_foundation/generated/AVPlayerItemOutput.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-foundation")]
9use objc2_core_foundation::*;
10#[cfg(feature = "objc2-core-media")]
11use objc2_core_media::*;
12#[cfg(feature = "objc2-core-video")]
13use objc2_core_video::*;
14use objc2_foundation::*;
15
16use crate::*;
17
18extern_class!(
19 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemoutput?language=objc)
20 #[unsafe(super(NSObject))]
21 #[derive(Debug, PartialEq, Eq, Hash)]
22 pub struct AVPlayerItemOutput;
23);
24
25unsafe impl Send for AVPlayerItemOutput {}
26
27unsafe impl Sync for AVPlayerItemOutput {}
28
29extern_conformance!(
30 unsafe impl NSObjectProtocol for AVPlayerItemOutput {}
31);
32
33impl AVPlayerItemOutput {
34 extern_methods!(
35 #[cfg(all(feature = "objc2-core-foundation", feature = "objc2-core-media"))]
36 /// Convert a host time, expressed in seconds, to item time.
37 ///
38 /// Converts a host time value (for example a CADisplayLink timestamp, or the value returned by CACurrentMediaTime()) to the equivalent time on the item's timebase.
39 ///
40 /// Note: The Core Animation CADisplayLink timestamp property expresses the most recent, or previous, screen refresh time. You need to increment this timestamp by the CADisplayLink's duration property to find the next appropriate item time.
41 ///
42 /// Parameter `hostTimeInSeconds`: The timestamp value to convert to item time.
43 ///
44 /// Returns: The equivalent item time.
45 #[unsafe(method(itemTimeForHostTime:))]
46 #[unsafe(method_family = none)]
47 pub unsafe fn itemTimeForHostTime(&self, host_time_in_seconds: CFTimeInterval) -> CMTime;
48
49 #[cfg(feature = "objc2-core-media")]
50 /// Convenience method to convert a Mach host time to item time.
51 ///
52 /// Converts Mach host time to the equivalent time on the item's timebase.
53 /// mach_absolute_time() returns time awake since boot in system-specific rational units that can be queried by calling mach_timebase_info().
54 ///
55 /// Parameter `machAbsoluteTime`: The Mach host time to convert to item time.
56 ///
57 /// Returns: The equivalent item time.
58 #[unsafe(method(itemTimeForMachAbsoluteTime:))]
59 #[unsafe(method_family = none)]
60 pub unsafe fn itemTimeForMachAbsoluteTime(&self, mach_absolute_time: i64) -> CMTime;
61
62 #[cfg(all(feature = "objc2-core-media", feature = "objc2-core-video"))]
63 /// Convenience method to convert a CoreVideo timestamp to the equivalent time on the item's timebase.
64 ///
65 /// Note: A CVDisplayLink provides a parameter inOutputTimestamp that expresses a future screen refresh time. You can use this value directly to find the next appropriate item time.
66 /// Use `itemTimeForHostTime` if you were using this method previously to find the item time and have to switch over due to CVDisplayLink deprecation.
67 ///
68 /// Parameter `timestamp`: The CoreVideo timestamp value to convert to item time.
69 ///
70 /// Returns: The equivalent item time.
71 #[unsafe(method(itemTimeForCVTimeStamp:))]
72 #[unsafe(method_family = none)]
73 pub unsafe fn itemTimeForCVTimeStamp(&self, timestamp: CVTimeStamp) -> CMTime;
74
75 /// Indicates whether the output, when added to an AVPlayerItem, will be used in addition to normal rendering of media data by the player or instead of normal rendering.
76 ///
77 /// The default value is NO, indicating that the output will be used in addition to normal rendering. If you want to render the media data provided by the output yourself instead of allowing it to be rendered as in normally would be by AVPlayer, set suppressesPlayerRendering to YES.
78 ///
79 /// Whenever any output is added to an AVPlayerItem that has suppressesPlayerRendering set to YES, the media data supplied to the output will not be rendered by AVPlayer. Other media data associated with the item but not provided to such an output is not affected. For example, if an output of class AVPlayerItemVideoOutput with a value of YES for suppressesPlayerRendering is added to an AVPlayerItem, video media for that item will not be rendered by the AVPlayer, while audio media, subtitle media, and other kinds of media, if present, will be rendered.
80 ///
81 /// This property is not atomic.
82 ///
83 /// # Safety
84 ///
85 /// This might not be thread-safe.
86 #[unsafe(method(suppressesPlayerRendering))]
87 #[unsafe(method_family = none)]
88 pub unsafe fn suppressesPlayerRendering(&self) -> bool;
89
90 /// Setter for [`suppressesPlayerRendering`][Self::suppressesPlayerRendering].
91 ///
92 /// # Safety
93 ///
94 /// This might not be thread-safe.
95 #[unsafe(method(setSuppressesPlayerRendering:))]
96 #[unsafe(method_family = none)]
97 pub unsafe fn setSuppressesPlayerRendering(&self, suppresses_player_rendering: bool);
98 );
99}
100
101/// Methods declared on superclass `NSObject`.
102impl AVPlayerItemOutput {
103 extern_methods!(
104 #[unsafe(method(init))]
105 #[unsafe(method_family = init)]
106 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
107
108 #[unsafe(method(new))]
109 #[unsafe(method_family = new)]
110 pub unsafe fn new() -> Retained<Self>;
111 );
112}
113
114extern_class!(
115 /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemvideooutput?language=objc)
116 #[unsafe(super(AVPlayerItemOutput, NSObject))]
117 #[derive(Debug, PartialEq, Eq, Hash)]
118 pub struct AVPlayerItemVideoOutput;
119);
120
121unsafe impl Send for AVPlayerItemVideoOutput {}
122
123unsafe impl Sync for AVPlayerItemVideoOutput {}
124
125extern_conformance!(
126 unsafe impl NSObjectProtocol for AVPlayerItemVideoOutput {}
127);
128
129impl AVPlayerItemVideoOutput {
130 extern_methods!(
131 /// Returns an instance of AVPlayerItemVideoOutput, initialized with the specified pixel buffer attributes, for video image output.
132 ///
133 /// Parameter `pixelBufferAttributes`: The client requirements for output CVPixelBuffers, expressed using the constants in
134 /// <CoreVideo
135 /// /CVPixelBuffer.h>.
136 ///
137 /// Returns: An instance of AVPlayerItemVideoOutput.
138 ///
139 /// # Safety
140 ///
141 /// `pixel_buffer_attributes` generic should be of the correct type.
142 #[unsafe(method(initWithPixelBufferAttributes:))]
143 #[unsafe(method_family = init)]
144 pub unsafe fn initWithPixelBufferAttributes(
145 this: Allocated<Self>,
146 pixel_buffer_attributes: Option<&NSDictionary<NSString, AnyObject>>,
147 ) -> Retained<Self>;
148
149 /// Returns an instance of AVPlayerItemVideoOutput, initialized with the specified output settings, for video image output.
150 ///
151 /// Parameter `outputSettings`: The client requirements for output CVPixelBuffers, expressed using the constants in AVVideoSettings.h.
152 ///
153 /// For uncompressed video output, start with kCVPixelBuffer* keys in
154 /// <CoreVideo
155 /// /CVPixelBuffer.h>.
156 ///
157 /// In addition to the keys in CVPixelBuffer.h, uncompressed video settings dictionaries may also contain the following keys:
158 ///
159 /// AVVideoAllowWideColorKey
160 ///
161 ///
162 /// Returns: An instance of AVPlayerItemVideoOutput.
163 ///
164 /// This method throws an exception for any of the following reasons:
165 /// - the output settings dictionary is empty
166 /// - the settings will yield compressed output
167 /// - the settings do not honor the requirements listed above for outputSettings
168 ///
169 /// # Safety
170 ///
171 /// `output_settings` generic should be of the correct type.
172 #[unsafe(method(initWithOutputSettings:))]
173 #[unsafe(method_family = init)]
174 pub unsafe fn initWithOutputSettings(
175 this: Allocated<Self>,
176 output_settings: Option<&NSDictionary<NSString, AnyObject>>,
177 ) -> Retained<Self>;
178
179 #[cfg(feature = "objc2-core-media")]
180 /// Query if any new video output is available for an item time.
181 ///
182 /// This method returns YES if there is available video output, appropriate for display, at the specified item time not marked as acquired. If you require multiple objects to acquire video output from the same AVPlayerItem, you should instantiate more than one AVPlayerItemVideoOutput and add each via addOutput:. Each AVPlayerItemVideoOutput maintains a separate record of client acquisition.
183 ///
184 /// Parameter `itemTime`: The item time to query.
185 ///
186 /// Returns: A BOOL indicating if there is newer output.
187 #[unsafe(method(hasNewPixelBufferForItemTime:))]
188 #[unsafe(method_family = none)]
189 pub unsafe fn hasNewPixelBufferForItemTime(&self, item_time: CMTime) -> bool;
190
191 #[cfg(all(feature = "objc2-core-media", feature = "objc2-core-video"))]
192 /// Retrieves an image that is appropriate for display at the specified item time, and marks the image as acquired.
193 ///
194 /// The client is responsible for calling CVBufferRelease on the returned CVPixelBuffer when finished with it.
195 ///
196 /// Typically you would call this method in response to a CADisplayLink delegate invocation and if hasNewPixelBufferForItemTime: also returns YES.
197 ///
198 /// The buffer reference retrieved from copyPixelBufferForItemTime:itemTimeForDisplay: may itself be NULL. A reference to a NULL pixel buffer communicates that nothing should be displayed for the supplied item time.
199 ///
200 /// Parameter `itemTime`: A CMTime that expresses a desired item time.
201 ///
202 /// Parameter `itemTimeForDisplay`: A CMTime pointer whose value will contain the true display deadline for the copied pixel buffer. Can be NULL.
203 ///
204 /// # Safety
205 ///
206 /// `out_item_time_for_display` must be a valid pointer or null.
207 #[unsafe(method(copyPixelBufferForItemTime:itemTimeForDisplay:))]
208 #[unsafe(method_family = copy)]
209 pub unsafe fn copyPixelBufferForItemTime_itemTimeForDisplay(
210 &self,
211 item_time: CMTime,
212 out_item_time_for_display: *mut CMTime,
213 ) -> Option<Retained<CVPixelBuffer>>;
214
215 #[cfg(feature = "dispatch2")]
216 /// Sets the receiver's delegate and a dispatch queue on which the delegate will be called.
217 ///
218 /// Parameter `delegate`: An object conforming to AVPlayerItemOutputPullDelegate protocol.
219 ///
220 /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be called.
221 ///
222 /// # Safety
223 ///
224 /// `delegate_queue` possibly has additional threading requirements.
225 #[unsafe(method(setDelegate:queue:))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn setDelegate_queue(
228 &self,
229 delegate: Option<&ProtocolObject<dyn AVPlayerItemOutputPullDelegate>>,
230 delegate_queue: Option<&DispatchQueue>,
231 );
232
233 /// Informs the receiver that the AVPlayerItemVideoOutput client is entering a quiescent state.
234 ///
235 /// Parameter `interval`: A wall clock time interval.
236 ///
237 /// Message this method before you suspend your use of a CADisplayLink. The interval you provide will be used to message your delegate, in advance, that it should resume the display link. If the interval you provide is large, effectively requesting wakeup earlier than the AVPlayerItemVideoOutput is prepared to act, the delegate will be invoked as soon as possible. Do not use this method to force a delegate invocation for each sample.
238 #[unsafe(method(requestNotificationOfMediaDataChangeWithAdvanceInterval:))]
239 #[unsafe(method_family = none)]
240 pub unsafe fn requestNotificationOfMediaDataChangeWithAdvanceInterval(
241 &self,
242 interval: NSTimeInterval,
243 );
244
245 /// The receiver's delegate.
246 #[unsafe(method(delegate))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn delegate(
249 &self,
250 ) -> Option<Retained<ProtocolObject<dyn AVPlayerItemOutputPullDelegate>>>;
251
252 #[cfg(feature = "dispatch2")]
253 /// The dispatch queue where the delegate is messaged.
254 ///
255 /// This property is not atomic.
256 ///
257 /// # Safety
258 ///
259 /// This might not be thread-safe.
260 #[unsafe(method(delegateQueue))]
261 #[unsafe(method_family = none)]
262 pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;
263 );
264}
265
266/// Methods declared on superclass `NSObject`.
267impl AVPlayerItemVideoOutput {
268 extern_methods!(
269 #[unsafe(method(init))]
270 #[unsafe(method_family = init)]
271 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
272
273 #[unsafe(method(new))]
274 #[unsafe(method_family = new)]
275 pub unsafe fn new() -> Retained<Self>;
276 );
277}
278
279extern_protocol!(
280 /// Defines common delegate methods for objects participating in AVPlayerItemOutput pull sample output acquisition.
281 ///
282 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
283 ///
284 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemoutputpulldelegate?language=objc)
285 pub unsafe trait AVPlayerItemOutputPullDelegate: NSObjectProtocol + Send + Sync {
286 /// A method invoked once, prior to a new sample, if the AVPlayerItemOutput sender was previously messaged requestNotificationOfMediaDataChangeWithAdvanceInterval:.
287 ///
288 /// This method is invoked once after the sender is messaged requestNotificationOfMediaDataChangeWithAdvanceInterval:.
289 #[optional]
290 #[unsafe(method(outputMediaDataWillChange:))]
291 #[unsafe(method_family = none)]
292 unsafe fn outputMediaDataWillChange(&self, sender: &AVPlayerItemOutput);
293
294 /// A method invoked when the output is commencing a new sequence.
295 ///
296 /// This method is invoked after any seeking and change in playback direction. If you are maintaining any queued future samples, copied previously, you may want to discard these after receiving this message.
297 #[optional]
298 #[unsafe(method(outputSequenceWasFlushed:))]
299 #[unsafe(method_family = none)]
300 unsafe fn outputSequenceWasFlushed(&self, output: &AVPlayerItemOutput);
301 }
302);
303
304extern_class!(
305 /// A subclass of AVPlayerItemOutput that can vend media with a legible characteristic as NSAttributedStrings.
306 ///
307 /// An instance of AVPlayerItemLegibleOutput is typically initialized using the -init method.
308 ///
309 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
310 ///
311 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutput?language=objc)
312 #[unsafe(super(AVPlayerItemOutput, NSObject))]
313 #[derive(Debug, PartialEq, Eq, Hash)]
314 pub struct AVPlayerItemLegibleOutput;
315);
316
317unsafe impl Send for AVPlayerItemLegibleOutput {}
318
319unsafe impl Sync for AVPlayerItemLegibleOutput {}
320
321extern_conformance!(
322 unsafe impl NSObjectProtocol for AVPlayerItemLegibleOutput {}
323);
324
325impl AVPlayerItemLegibleOutput {
326 extern_methods!(
327 #[cfg(feature = "dispatch2")]
328 /// Sets the receiver's delegate and a dispatch queue on which the delegate will be called.
329 ///
330 /// Parameter `delegate`: An object conforming to AVPlayerItemLegibleOutputPushDelegate protocol.
331 ///
332 /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be called.
333 ///
334 /// The delegate is held using a zeroing-weak reference, so it is safe to deallocate the delegate while the receiver still has a reference to it.
335 ///
336 /// # Safety
337 ///
338 /// `delegate_queue` possibly has additional threading requirements.
339 #[unsafe(method(setDelegate:queue:))]
340 #[unsafe(method_family = none)]
341 pub unsafe fn setDelegate_queue(
342 &self,
343 delegate: Option<&ProtocolObject<dyn AVPlayerItemLegibleOutputPushDelegate>>,
344 delegate_queue: Option<&DispatchQueue>,
345 );
346
347 /// The receiver's delegate.
348 ///
349 /// The delegate is held using a zeroing-weak reference, so this property will have a value of nil after a delegate that was previously set has been deallocated. This property is not key-value observable.
350 ///
351 /// This property is not atomic.
352 ///
353 /// # Safety
354 ///
355 /// This might not be thread-safe.
356 #[unsafe(method(delegate))]
357 #[unsafe(method_family = none)]
358 pub unsafe fn delegate(
359 &self,
360 ) -> Option<Retained<ProtocolObject<dyn AVPlayerItemLegibleOutputPushDelegate>>>;
361
362 #[cfg(feature = "dispatch2")]
363 /// The dispatch queue where the delegate is messaged.
364 ///
365 /// This property is not key-value observable.
366 ///
367 /// This property is not atomic.
368 ///
369 /// # Safety
370 ///
371 /// This might not be thread-safe.
372 #[unsafe(method(delegateQueue))]
373 #[unsafe(method_family = none)]
374 pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;
375
376 /// Permits advance invocation of the associated delegate, if any.
377 ///
378 /// If it is possible, an AVPlayerItemLegibleOutput will message its delegate advanceIntervalForDelegateInvocation seconds earlier than otherwise. If the value you provide is large, effectively requesting provision of samples earlier than the AVPlayerItemLegibleOutput is prepared to act on them, the delegate will be invoked as soon as possible.
379 ///
380 /// This property is not atomic.
381 ///
382 /// # Safety
383 ///
384 /// This might not be thread-safe.
385 #[unsafe(method(advanceIntervalForDelegateInvocation))]
386 #[unsafe(method_family = none)]
387 pub unsafe fn advanceIntervalForDelegateInvocation(&self) -> NSTimeInterval;
388
389 /// Setter for [`advanceIntervalForDelegateInvocation`][Self::advanceIntervalForDelegateInvocation].
390 ///
391 /// # Safety
392 ///
393 /// This might not be thread-safe.
394 #[unsafe(method(setAdvanceIntervalForDelegateInvocation:))]
395 #[unsafe(method_family = none)]
396 pub unsafe fn setAdvanceIntervalForDelegateInvocation(
397 &self,
398 advance_interval_for_delegate_invocation: NSTimeInterval,
399 );
400 );
401}
402
403/// Methods declared on superclass `NSObject`.
404impl AVPlayerItemLegibleOutput {
405 extern_methods!(
406 #[unsafe(method(init))]
407 #[unsafe(method_family = init)]
408 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
409
410 #[unsafe(method(new))]
411 #[unsafe(method_family = new)]
412 pub unsafe fn new() -> Retained<Self>;
413 );
414}
415
416/// AVPlayerItemLegibleOutput_NativeRepresentation.
417impl AVPlayerItemLegibleOutput {
418 extern_methods!(
419 /// Returns an instance of AVPlayerItemLegibleOutput with filtering enabled for AVPlayerItemLegibleOutputPushDelegate's legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:.
420 ///
421 /// Parameter `subtypes`: NSArray of NSNumber FourCC codes, e.g.
422 /// @
423 /// [ [NSNumber numberWithUnsignedInt:'tx3g'] ]
424 ///
425 /// Returns: An instance of AVPlayerItemLegibleOutput.
426 ///
427 /// Add media subtype FourCC number objects to the subtypes array to elect to receive that type as a CMSampleBuffer instead of an NSAttributedString. Initializing an AVPlayerItemLegibleOutput using the -init method is equivalent to calling -initWithMediaSubtypesForNativeRepresentation: with an empty array, which means that all legible data, regardless of media subtype, will be delivered using NSAttributedString in a common format.
428 ///
429 /// If a media subtype for which there is no legible data in the current player item is included in the media subtypes array, no error will occur. AVPlayerItemLegibleOutput will not vend closed caption data as CMSampleBuffers, so it is an error to include 'c608' in the media subtypes array.
430 ///
431 /// This method throws an exception if any media subtype is kCMClosedCaptionFormatType_CEA608 (native representation is not available for media subtype).
432 #[unsafe(method(initWithMediaSubtypesForNativeRepresentation:))]
433 #[unsafe(method_family = init)]
434 pub unsafe fn initWithMediaSubtypesForNativeRepresentation(
435 this: Allocated<Self>,
436 subtypes: &NSArray<NSNumber>,
437 ) -> Retained<Self>;
438 );
439}
440
441/// The type of a text styling resolution.
442///
443/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutputtextstylingresolution?language=objc)
444// NS_TYPED_ENUM
445pub type AVPlayerItemLegibleOutputTextStylingResolution = NSString;
446
447extern "C" {
448 /// Specify this level of text styling resolution to receive attributed strings from an AVPlayerItemLegibleOutput that include the same level of styling information that AVFoundation would use itself to render text within an AVPlayerLayer. The text styling will accommodate user-level Media Accessibility settings.
449 ///
450 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutputtextstylingresolutiondefault?language=objc)
451 pub static AVPlayerItemLegibleOutputTextStylingResolutionDefault:
452 &'static AVPlayerItemLegibleOutputTextStylingResolution;
453}
454
455extern "C" {
456 /// Specify this level of text styling resolution to receive only the styling present in the source media and the styling provided via AVPlayerItem.textStyleRules.
457 ///
458 /// This level of resolution excludes styling provided by the user-level Media Accessibility settings. You would typically use it if you wish to override the styling specified in source media. If you do this, you are strongly encouraged to allow your custom styling in turn to be overriden by user preferences for text styling that are available as Media Accessibility settings.
459 ///
460 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutputtextstylingresolutionsourceandrulesonly?language=objc)
461 pub static AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly:
462 &'static AVPlayerItemLegibleOutputTextStylingResolution;
463}
464
465/// AVPlayerItemLegibleOutput_TextStylingResolution.
466impl AVPlayerItemLegibleOutput {
467 extern_methods!(
468 /// A string identifier indicating the degree of text styling to be applied to attributed strings vended by the receiver
469 ///
470 /// Valid values are AVPlayerItemLegibleOutputTextStylingResolutionDefault and AVPlayerItemLegibleOutputTextStylingResolutionSourceAndRulesOnly. An NSInvalidArgumentException is raised if this property is set to any other value. The default value is AVPlayerItemLegibleOutputTextStylingResolutionDefault, which indicates that attributed strings vended by the receiver will include the same level of styling information that would be used if AVFoundation were rendering the text via AVPlayerLayer.
471 ///
472 /// This property is not atomic.
473 ///
474 /// # Safety
475 ///
476 /// This might not be thread-safe.
477 #[unsafe(method(textStylingResolution))]
478 #[unsafe(method_family = none)]
479 pub unsafe fn textStylingResolution(
480 &self,
481 ) -> Retained<AVPlayerItemLegibleOutputTextStylingResolution>;
482
483 /// Setter for [`textStylingResolution`][Self::textStylingResolution].
484 ///
485 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
486 ///
487 /// # Safety
488 ///
489 /// This might not be thread-safe.
490 #[unsafe(method(setTextStylingResolution:))]
491 #[unsafe(method_family = none)]
492 pub unsafe fn setTextStylingResolution(
493 &self,
494 text_styling_resolution: &AVPlayerItemLegibleOutputTextStylingResolution,
495 );
496 );
497}
498
499extern_protocol!(
500 /// Extends AVPlayerItemOutputPushDelegate to provide additional methods specific to attributed string output.
501 ///
502 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
503 ///
504 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemlegibleoutputpushdelegate?language=objc)
505 pub unsafe trait AVPlayerItemLegibleOutputPushDelegate:
506 AVPlayerItemOutputPushDelegate + Send + Sync
507 {
508 #[cfg(feature = "objc2-core-media")]
509 /// A delegate callback that delivers new textual samples.
510 ///
511 /// Parameter `output`: The AVPlayerItemLegibleOutput source.
512 ///
513 /// Parameter `strings`: An NSArray of NSAttributedString, each containing both the run of text and descriptive markup.
514 ///
515 /// Parameter `nativeSamples`: An NSArray of CMSampleBuffer objects, for media subtypes included in the array passed in to -initWithMediaSubtypesForNativeRepresentation:
516 ///
517 /// Parameter `itemTime`: The item time at which the strings should be presented.
518 ///
519 /// For each media subtype in the array passed in to -initWithMediaSubtypesForNativeRepresentation:, the delegate will receive sample buffers carrying data in its native format via the nativeSamples parameter, if there is media data of that subtype in the media resource. For all other media subtypes present in the media resource, the delegate will receive attributed strings in a common format via the strings parameter. See
520 /// <CoreMedia
521 /// /CMTextMarkup.h> for the string attributes that are used in the attributed strings.
522 ///
523 /// # Safety
524 ///
525 /// `native_samples` generic should be of the correct type.
526 #[optional]
527 #[unsafe(method(legibleOutput:didOutputAttributedStrings:nativeSampleBuffers:forItemTime:))]
528 #[unsafe(method_family = none)]
529 unsafe fn legibleOutput_didOutputAttributedStrings_nativeSampleBuffers_forItemTime(
530 &self,
531 output: &AVPlayerItemLegibleOutput,
532 strings: &NSArray<NSAttributedString>,
533 native_samples: &NSArray,
534 item_time: CMTime,
535 );
536 }
537);
538
539extern_protocol!(
540 /// Defines common delegate methods for objects participating in AVPlayerItemOutput push sample output acquisition.
541 ///
542 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
543 ///
544 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemoutputpushdelegate?language=objc)
545 pub unsafe trait AVPlayerItemOutputPushDelegate: NSObjectProtocol + Send + Sync {
546 /// A method invoked when the output is commencing a new sequence of media data.
547 ///
548 /// This method is invoked after any seeking and change in playback direction. If you are maintaining any queued future media data, received previously, you may want to discard these after receiving this message.
549 #[optional]
550 #[unsafe(method(outputSequenceWasFlushed:))]
551 #[unsafe(method_family = none)]
552 unsafe fn outputSequenceWasFlushed(&self, output: &AVPlayerItemOutput);
553 }
554);
555
556extern_class!(
557 /// A subclass of AVPlayerItemOutput that vends collections of metadata items carried in metadata tracks.
558 ///
559 ///
560 /// Setting the value of suppressesPlayerRendering on an instance of AVPlayerItemMetadataOutput has no effect.
561 ///
562 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
563 ///
564 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemmetadataoutput?language=objc)
565 #[unsafe(super(AVPlayerItemOutput, NSObject))]
566 #[derive(Debug, PartialEq, Eq, Hash)]
567 pub struct AVPlayerItemMetadataOutput;
568);
569
570unsafe impl Send for AVPlayerItemMetadataOutput {}
571
572unsafe impl Sync for AVPlayerItemMetadataOutput {}
573
574extern_conformance!(
575 unsafe impl NSObjectProtocol for AVPlayerItemMetadataOutput {}
576);
577
578impl AVPlayerItemMetadataOutput {
579 extern_methods!(
580 /// Creates an instance of AVPlayerItemMetadataOutput.
581 ///
582 /// Parameter `identifiers`: A array of metadata identifiers indicating the metadata items that the output should provide.
583 ///
584 /// See AVMetadataIdentifiers.h for publicly defined metadata identifiers. Pass nil to receive all of the timed metadata from all enabled AVPlayerItemTracks that carry timed metadata.
585 #[unsafe(method(initWithIdentifiers:))]
586 #[unsafe(method_family = init)]
587 pub unsafe fn initWithIdentifiers(
588 this: Allocated<Self>,
589 identifiers: Option<&NSArray<NSString>>,
590 ) -> Retained<Self>;
591
592 #[cfg(feature = "dispatch2")]
593 /// Sets the receiver's delegate and a dispatch queue on which the delegate will be called.
594 ///
595 /// Parameter `delegate`: An object conforming to AVPlayerItemMetadataOutputPushDelegate protocol.
596 ///
597 /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be called.
598 ///
599 /// # Safety
600 ///
601 /// `delegate_queue` possibly has additional threading requirements.
602 #[unsafe(method(setDelegate:queue:))]
603 #[unsafe(method_family = none)]
604 pub unsafe fn setDelegate_queue(
605 &self,
606 delegate: Option<&ProtocolObject<dyn AVPlayerItemMetadataOutputPushDelegate>>,
607 delegate_queue: Option<&DispatchQueue>,
608 );
609
610 /// The receiver's delegate.
611 ///
612 /// The delegate is held using a zeroing-weak reference, so this property will have a value of nil after a delegate that was previously set has been deallocated. This property is not key-value observable.
613 ///
614 /// This property is not atomic.
615 ///
616 /// # Safety
617 ///
618 /// This might not be thread-safe.
619 #[unsafe(method(delegate))]
620 #[unsafe(method_family = none)]
621 pub unsafe fn delegate(
622 &self,
623 ) -> Option<Retained<ProtocolObject<dyn AVPlayerItemMetadataOutputPushDelegate>>>;
624
625 #[cfg(feature = "dispatch2")]
626 /// The dispatch queue on which messages are sent to the delegate.
627 ///
628 /// This property is not key-value observable.
629 ///
630 /// This property is not atomic.
631 ///
632 /// # Safety
633 ///
634 /// This might not be thread-safe.
635 #[unsafe(method(delegateQueue))]
636 #[unsafe(method_family = none)]
637 pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;
638
639 /// Permits advance invocation of the associated delegate, if any.
640 ///
641 /// If it is possible, an AVPlayerItemMetadataOutput will message its delegate advanceIntervalForDelegateInvocation seconds earlier than otherwise. If the value you provide is large, effectively requesting provision of samples earlier than the AVPlayerItemMetadataOutput is prepared to act on them, the delegate will be invoked as soon as possible.
642 ///
643 /// This property is not atomic.
644 ///
645 /// # Safety
646 ///
647 /// This might not be thread-safe.
648 #[unsafe(method(advanceIntervalForDelegateInvocation))]
649 #[unsafe(method_family = none)]
650 pub unsafe fn advanceIntervalForDelegateInvocation(&self) -> NSTimeInterval;
651
652 /// Setter for [`advanceIntervalForDelegateInvocation`][Self::advanceIntervalForDelegateInvocation].
653 ///
654 /// # Safety
655 ///
656 /// This might not be thread-safe.
657 #[unsafe(method(setAdvanceIntervalForDelegateInvocation:))]
658 #[unsafe(method_family = none)]
659 pub unsafe fn setAdvanceIntervalForDelegateInvocation(
660 &self,
661 advance_interval_for_delegate_invocation: NSTimeInterval,
662 );
663 );
664}
665
666/// Methods declared on superclass `NSObject`.
667impl AVPlayerItemMetadataOutput {
668 extern_methods!(
669 #[unsafe(method(init))]
670 #[unsafe(method_family = init)]
671 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
672
673 #[unsafe(method(new))]
674 #[unsafe(method_family = new)]
675 pub unsafe fn new() -> Retained<Self>;
676 );
677}
678
679extern_protocol!(
680 /// Extends AVPlayerItemOutputPushDelegate to provide additional methods specific to metadata output.
681 ///
682 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemmetadataoutputpushdelegate?language=objc)
683 pub unsafe trait AVPlayerItemMetadataOutputPushDelegate:
684 AVPlayerItemOutputPushDelegate + Send + Sync
685 {
686 #[cfg(all(feature = "AVPlayerItemTrack", feature = "AVTimedMetadataGroup"))]
687 /// A delegate callback that delivers a new collection of metadata items.
688 ///
689 /// Parameter `output`: The AVPlayerItemMetadataOutput source.
690 ///
691 /// Parameter `groups`: An NSArray of AVTimedMetadataGroups that may contain metadata items with requested identifiers, according to the format descriptions associated with the underlying tracks.
692 ///
693 /// Parameter `track`: An instance of AVPlayerItemTrack that indicates the source of the metadata items in the group.
694 ///
695 /// Each group provided in a single invocation of this method will have timing that does not overlap with any other group in the array.
696 /// Note that for some timed metadata formats carried by HTTP live streaming, the timeRange of each group must be reported as kCMTimeIndefinite, because its duration will be unknown until the next metadata group in the stream arrives. In these cases, the groups parameter will always contain a single group.
697 /// Groups are typically packaged into arrays for delivery to your delegate according to the chunking or interleaving of the underlying metadata data.
698 /// Note that if the item carries multiple metadata tracks containing metadata with the same metadata identifiers, this method can be invoked for each one separately, each with reference to the associated AVPlayerItemTrack.
699 /// Note that the associated AVPlayerItemTrack parameter can be nil which implies that the metadata describes the asset as a whole, not just a single track of the asset.
700 #[optional]
701 #[unsafe(method(metadataOutput:didOutputTimedMetadataGroups:fromPlayerItemTrack:))]
702 #[unsafe(method_family = none)]
703 unsafe fn metadataOutput_didOutputTimedMetadataGroups_fromPlayerItemTrack(
704 &self,
705 output: &AVPlayerItemMetadataOutput,
706 groups: &NSArray<AVTimedMetadataGroup>,
707 track: Option<&AVPlayerItemTrack>,
708 );
709 }
710);
711
712extern_class!(
713 /// A subclass of AVPlayerItemOutput that can vend media with a legible characteristic as rendered CVPixelBufferRefs.
714 ///
715 /// An instance of AVPlayerItemRenderedLegibleOutput is initialized using the -init method.
716 ///
717 /// Subclasses of this type that are used from Swift must fulfill the requirements of a Sendable type.
718 ///
719 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemrenderedlegibleoutput?language=objc)
720 #[unsafe(super(AVPlayerItemOutput, NSObject))]
721 #[derive(Debug, PartialEq, Eq, Hash)]
722 pub struct AVPlayerItemRenderedLegibleOutput;
723);
724
725unsafe impl Send for AVPlayerItemRenderedLegibleOutput {}
726
727unsafe impl Sync for AVPlayerItemRenderedLegibleOutput {}
728
729extern_conformance!(
730 unsafe impl NSObjectProtocol for AVPlayerItemRenderedLegibleOutput {}
731);
732
733impl AVPlayerItemRenderedLegibleOutput {
734 extern_methods!(
735 #[unsafe(method(init))]
736 #[unsafe(method_family = init)]
737 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
738
739 #[unsafe(method(new))]
740 #[unsafe(method_family = new)]
741 pub unsafe fn new() -> Retained<Self>;
742
743 #[cfg(feature = "objc2-core-foundation")]
744 /// Creates an instance of AVPlayerItemRenderedLegibleOutput.
745 ///
746 /// Parameter `videoDisplaySize`: CGSize for the video display area
747 ///
748 /// This is the only available initializer for AVPlayerItemRenderedLegibleOutput. The client can also choose to reset videoDisplaySize after initialization or during playback. Initializing and resetting videoDisplaySize with a zero height or width will result in an exception being thrown.
749 #[unsafe(method(initWithVideoDisplaySize:))]
750 #[unsafe(method_family = init)]
751 pub unsafe fn initWithVideoDisplaySize(
752 this: Allocated<Self>,
753 video_display_size: CGSize,
754 ) -> Retained<Self>;
755
756 #[cfg(feature = "dispatch2")]
757 /// Sets the receiver's delegate and a dispatch queue on which the delegate will be called.
758 ///
759 /// Parameter `delegate`: An object conforming to AVPlayerItemRenderedLegibleOutputPushDelegate protocol.
760 ///
761 /// Parameter `delegateQueue`: A dispatch queue on which all delegate methods will be called.
762 ///
763 /// The delegate is held using a zeroing-weak reference, so it is safe to deallocate the delegate while the receiver still has a reference to it.
764 ///
765 /// # Safety
766 ///
767 /// `delegate_queue` possibly has additional threading requirements.
768 #[unsafe(method(setDelegate:queue:))]
769 #[unsafe(method_family = none)]
770 pub unsafe fn setDelegate_queue(
771 &self,
772 delegate: Option<&ProtocolObject<dyn AVPlayerItemRenderedLegibleOutputPushDelegate>>,
773 delegate_queue: Option<&DispatchQueue>,
774 );
775
776 /// The receiver's delegate.
777 ///
778 /// The delegate is held using a zeroing-weak reference, so this property will have a value of nil after a delegate that was previously set has been deallocated. This property is not key-value observable.
779 ///
780 /// This property is not atomic.
781 ///
782 /// # Safety
783 ///
784 /// This might not be thread-safe.
785 #[unsafe(method(delegate))]
786 #[unsafe(method_family = none)]
787 pub unsafe fn delegate(
788 &self,
789 ) -> Option<Retained<ProtocolObject<dyn AVPlayerItemRenderedLegibleOutputPushDelegate>>>;
790
791 #[cfg(feature = "dispatch2")]
792 /// The dispatch queue where the delegate is messaged.
793 ///
794 /// This property is not key-value observable.
795 ///
796 /// This property is not atomic.
797 ///
798 /// # Safety
799 ///
800 /// This might not be thread-safe.
801 #[unsafe(method(delegateQueue))]
802 #[unsafe(method_family = none)]
803 pub unsafe fn delegateQueue(&self) -> Option<Retained<DispatchQueue>>;
804
805 /// Permits advance invocation of the associated delegate, if any.
806 ///
807 /// If it is possible, an AVPlayerItemRenderedLegibleOutput will message its delegate advanceIntervalForDelegateInvocation seconds earlier than otherwise. If the value you provide is large, effectively requesting provision of samples earlier than the AVPlayerItemRenderedLegibleOutput is prepared to act on them, the delegate will be invoked as soon as possible.
808 ///
809 /// This property is not atomic.
810 ///
811 /// # Safety
812 ///
813 /// This might not be thread-safe.
814 #[unsafe(method(advanceIntervalForDelegateInvocation))]
815 #[unsafe(method_family = none)]
816 pub unsafe fn advanceIntervalForDelegateInvocation(&self) -> NSTimeInterval;
817
818 /// Setter for [`advanceIntervalForDelegateInvocation`][Self::advanceIntervalForDelegateInvocation].
819 ///
820 /// # Safety
821 ///
822 /// This might not be thread-safe.
823 #[unsafe(method(setAdvanceIntervalForDelegateInvocation:))]
824 #[unsafe(method_family = none)]
825 pub unsafe fn setAdvanceIntervalForDelegateInvocation(
826 &self,
827 advance_interval_for_delegate_invocation: NSTimeInterval,
828 );
829
830 #[cfg(feature = "objc2-core-foundation")]
831 /// Permits rendering of pixel buffers according to the set width and height
832 ///
833 /// The client is expected to set videodisplay size during init and may also set it again during playback. The pixel buffers will be rendered according to the set width and height of display area. If this property is set during the presentation time of a vended caption image, a new caption image rendered according to new videoDisplaySize, will be vended out. Setting this property with a zero height or width will result in an exception being thrown and it is client's responsibility to handle it using appropriate catch block.
834 ///
835 /// This property is not atomic.
836 ///
837 /// # Safety
838 ///
839 /// This might not be thread-safe.
840 #[unsafe(method(videoDisplaySize))]
841 #[unsafe(method_family = none)]
842 pub unsafe fn videoDisplaySize(&self) -> CGSize;
843
844 #[cfg(feature = "objc2-core-foundation")]
845 /// Setter for [`videoDisplaySize`][Self::videoDisplaySize].
846 ///
847 /// # Safety
848 ///
849 /// This might not be thread-safe.
850 #[unsafe(method(setVideoDisplaySize:))]
851 #[unsafe(method_family = none)]
852 pub unsafe fn setVideoDisplaySize(&self, video_display_size: CGSize);
853 );
854}
855
856extern_protocol!(
857 /// Extends AVPlayerItemOutputPushDelegate to provide additional methods specific to pixel buffers output.
858 ///
859 /// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avplayeritemrenderedlegibleoutputpushdelegate?language=objc)
860 pub unsafe trait AVPlayerItemRenderedLegibleOutputPushDelegate:
861 AVPlayerItemOutputPushDelegate
862 {
863 #[cfg(all(feature = "AVRenderedCaptionImage", feature = "objc2-core-media"))]
864 /// A delegate callback that delivers new rendered caption images
865 ///
866 /// Parameter `output`: The AVPlayerItemRenderedLegibleOutput source.
867 ///
868 /// Parameter `captionImages`: An NSArray of AVRenderedCaptionImage(s), consisting of a CVPixelBufferRef and its associated position (in pixels) relative to the video frame
869 ///
870 /// Parameter `itemTime`: The item time at which the caption images should be presented.
871 #[optional]
872 #[unsafe(method(renderedLegibleOutput:didOutputRenderedCaptionImages:forItemTime:))]
873 #[unsafe(method_family = none)]
874 unsafe fn renderedLegibleOutput_didOutputRenderedCaptionImages_forItemTime(
875 &self,
876 output: &AVPlayerItemRenderedLegibleOutput,
877 caption_images: &NSArray<AVRenderedCaptionImage>,
878 item_time: CMTime,
879 );
880 }
881);