objc2_av_foundation/generated/
AVQueuedSampleBufferRendering.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::*;
10
11use crate::*;
12
13/// These constants are the possible status values for queued sample buffer renderers.
14///
15/// Indicates that the receiver is in a fresh state without any sample buffers enqueued on it.
16///
17/// Indicates at least one sample buffer has been enqueued on the receiver.
18///
19/// Indicates that the receiver cannot currently enqueue or render sample buffers because of an error.
20///
21/// See also [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avqueuedsamplebufferrenderingstatus?language=objc)
22// NS_ENUM
23#[repr(transparent)]
24#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
25pub struct AVQueuedSampleBufferRenderingStatus(pub NSInteger);
26impl AVQueuedSampleBufferRenderingStatus {
27    #[doc(alias = "AVQueuedSampleBufferRenderingStatusUnknown")]
28    pub const Unknown: Self = Self(0);
29    #[doc(alias = "AVQueuedSampleBufferRenderingStatusRendering")]
30    pub const Rendering: Self = Self(1);
31    #[doc(alias = "AVQueuedSampleBufferRenderingStatusFailed")]
32    pub const Failed: Self = Self(2);
33}
34
35unsafe impl Encode for AVQueuedSampleBufferRenderingStatus {
36    const ENCODING: Encoding = NSInteger::ENCODING;
37}
38
39unsafe impl RefEncode for AVQueuedSampleBufferRenderingStatus {
40    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
41}
42
43extern_protocol!(
44    /// [Apple's documentation](https://developer.apple.com/documentation/avfoundation/avqueuedsamplebufferrendering?language=objc)
45    pub unsafe trait AVQueuedSampleBufferRendering: NSObjectProtocol {
46        #[cfg(feature = "objc2-core-media")]
47        /// The renderer's timebase, which governs how time stamps are interpreted.
48        ///
49        /// The timebase is used to interpret time stamps.
50        ///
51        /// The timebase is read-only.  Use the AVSampleBufferRenderSynchronizer to set the rate or time.
52        #[unsafe(method(timebase))]
53        #[unsafe(method_family = none)]
54        unsafe fn timebase(&self) -> Retained<CMTimebase>;
55
56        #[cfg(feature = "objc2-core-media")]
57        /// Sends a sample buffer in order to render its contents.
58        ///
59        /// Video-specific notes:
60        ///
61        /// If sampleBuffer has the kCMSampleAttachmentKey_DoNotDisplay attachment set to kCFBooleanTrue, the frame will be decoded but not displayed.  Otherwise, if sampleBuffer has the kCMSampleAttachmentKey_DisplayImmediately attachment set to kCFBooleanTrue, the decoded image will be displayed as soon as possible, replacing all previously enqueued images regardless of their timestamps.  Otherwise, the decoded image will be displayed at sampleBuffer's output presentation timestamp, as interpreted by the timebase.
62        ///
63        /// To schedule the removal of previous images at a specific timestamp, enqueue a marker sample buffer containing no samples, with the kCMSampleBufferAttachmentKey_EmptyMedia attachment set to kCFBooleanTrue.
64        ///
65        /// IMPORTANT NOTE: attachments with the kCMSampleAttachmentKey_ prefix must be set via CMSampleBufferGetSampleAttachmentsArray and CFDictionarySetValue.  Attachments with the kCMSampleBufferAttachmentKey_ prefix must be set via CMSetAttachment.
66        ///
67        /// The combination of either a non-NULL controlTimebase or an AVSampleBufferRenderSynchronizer with the use of kCMSampleAttachmentKey_DisplayImmediately as an attachment to the CMSampleBuffers that are enqueued for display is not recommended.
68        #[unsafe(method(enqueueSampleBuffer:))]
69        #[unsafe(method_family = none)]
70        unsafe fn enqueueSampleBuffer(&self, sample_buffer: &CMSampleBuffer);
71
72        /// Instructs the receiver to discard pending enqueued sample buffers.
73        ///
74        /// Additional sample buffers can be appended after -flush.
75        ///
76        /// Video-specific notes:
77        ///
78        /// It is not possible to determine which sample buffers have been decoded, so the next frame passed to enqueueSampleBuffer: should be an IDR frame (also known as a key frame or sync sample).
79        #[unsafe(method(flush))]
80        #[unsafe(method_family = none)]
81        unsafe fn flush(&self);
82
83        /// Indicates the readiness of the receiver to accept more sample buffers.
84        ///
85        /// An object conforming to AVQueuedSampleBufferRendering keeps track of the occupancy levels of its internal queues for the benefit of clients that enqueue sample buffers from non-real-time sources -- i.e., clients that can supply sample buffers faster than they are consumed, and so need to decide when to hold back.
86        ///
87        /// Clients enqueueing sample buffers from non-real-time sources may hold off from generating or obtaining more sample buffers to enqueue when the value of readyForMoreMediaData is NO.
88        ///
89        /// It is safe to call enqueueSampleBuffer: when readyForMoreMediaData is NO, but it is a bad idea to enqueue sample buffers without bound.
90        ///
91        /// To help with control of the non-real-time supply of sample buffers, such clients can use -requestMediaDataWhenReadyOnQueue:usingBlock in order to specify a block that the receiver should invoke whenever it's ready for sample buffers to be appended.
92        ///
93        /// The value of readyForMoreMediaData will often change from NO to YES asynchronously, as previously supplied sample buffers are decoded and rendered.
94        ///
95        /// This property is not key value observable.
96        #[unsafe(method(isReadyForMoreMediaData))]
97        #[unsafe(method_family = none)]
98        unsafe fn isReadyForMoreMediaData(&self) -> bool;
99
100        #[cfg(all(feature = "block2", feature = "dispatch2"))]
101        /// Instructs the target to invoke a client-supplied block repeatedly, at its convenience, in order to gather sample buffers for playback.
102        ///
103        /// The block should enqueue sample buffers to the receiver either until the receiver's readyForMoreMediaData property becomes NO or until there is no more data to supply. When the receiver has decoded enough of the media data it has received that it becomes ready for more media data again, it will invoke the block again in order to obtain more.
104        ///
105        /// If this method is called multiple times, only the last call is effective. Call stopRequestingMediaData to cancel this request.
106        ///
107        /// Each call to requestMediaDataWhenReadyOnQueue:usingBlock: should be paired with a corresponding call to stopRequestingMediaData:. Releasing the AVQueuedSampleBufferRendering object without a call to stopRequestingMediaData will result in undefined behavior.
108        ///
109        /// # Safety
110        ///
111        /// - `queue` possibly has additional threading requirements.
112        /// - `block` block must be sendable.
113        #[unsafe(method(requestMediaDataWhenReadyOnQueue:usingBlock:))]
114        #[unsafe(method_family = none)]
115        unsafe fn requestMediaDataWhenReadyOnQueue_usingBlock(
116            &self,
117            queue: &DispatchQueue,
118            block: &block2::DynBlock<dyn Fn()>,
119        );
120
121        /// Cancels any current requestMediaDataWhenReadyOnQueue:usingBlock: call.
122        ///
123        /// This method may be called from outside the block or from within the block.
124        #[unsafe(method(stopRequestingMediaData))]
125        #[unsafe(method_family = none)]
126        unsafe fn stopRequestingMediaData(&self);
127
128        /// Indicates whether the enqueued media data meets the renderer's preroll level.
129        ///
130        /// Clients should fetch the value of this property to learn if the renderer has had enough media data enqueued to start playback reliably. Starting playback when this property is NO may prevent smooth playback following an immediate start.
131        #[unsafe(method(hasSufficientMediaDataForReliablePlaybackStart))]
132        #[unsafe(method_family = none)]
133        unsafe fn hasSufficientMediaDataForReliablePlaybackStart(&self) -> bool;
134    }
135);