objc2_core_video/generated/CVBuffer.rs
1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::cell::UnsafeCell;
4use core::ffi::*;
5use core::marker::{PhantomData, PhantomPinned};
6use core::ptr::NonNull;
7#[cfg(feature = "objc2")]
8use objc2::__framework_prelude::*;
9use objc2_core_foundation::*;
10
11use crate::*;
12
13extern "C" {
14 /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvbufferpropagatedattachmentskey?language=objc)
15 pub static kCVBufferPropagatedAttachmentsKey: &'static CFString;
16}
17
18extern "C" {
19 /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvbuffernonpropagatedattachmentskey?language=objc)
20 pub static kCVBufferNonPropagatedAttachmentsKey: &'static CFString;
21}
22
23extern "C" {
24 /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvbuffermovietimekey?language=objc)
25 pub static kCVBufferMovieTimeKey: &'static CFString;
26}
27
28extern "C" {
29 /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvbuffertimevaluekey?language=objc)
30 pub static kCVBufferTimeValueKey: &'static CFString;
31}
32
33extern "C" {
34 /// [Apple's documentation](https://developer.apple.com/documentation/corevideo/kcvbuffertimescalekey?language=objc)
35 pub static kCVBufferTimeScaleKey: &'static CFString;
36}
37
38/// [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvattachmentmode?language=objc)
39// NS_ENUM
40#[repr(transparent)]
41#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct CVAttachmentMode(pub u32);
43impl CVAttachmentMode {
44 #[doc(alias = "kCVAttachmentMode_ShouldNotPropagate")]
45 pub const ShouldNotPropagate: Self = Self(0);
46 #[doc(alias = "kCVAttachmentMode_ShouldPropagate")]
47 pub const ShouldPropagate: Self = Self(1);
48}
49
50#[cfg(feature = "objc2")]
51unsafe impl Encode for CVAttachmentMode {
52 const ENCODING: Encoding = u32::ENCODING;
53}
54
55#[cfg(feature = "objc2")]
56unsafe impl RefEncode for CVAttachmentMode {
57 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
58}
59
60/// Base type for all CoreVideo buffers
61///
62/// See also [Apple's documentation](https://developer.apple.com/documentation/corevideo/cvbuffer?language=objc)
63#[repr(C)]
64pub struct CVBuffer {
65 inner: [u8; 0],
66 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
67}
68
69cf_type!(
70 #[encoding_name = "__CVBuffer"]
71 unsafe impl CVBuffer {}
72);
73
74extern "C-unwind" {
75 /// Sets or adds a attachment of a CVBuffer object
76 ///
77 /// You can attach any CF object to a CVBuffer object to store additional information. CVBufferGetAttachment stores an attachement identified by a key. If the key doesn't exist, the attachment will be added. If the key does exist, the existing attachment will be replaced. In bouth cases the retain count of the attachment will be incremented. The value can be any CFType but nil has no defined behavior.
78 ///
79 /// Parameter `buffer`: Target CVBuffer object.
80 ///
81 /// Parameter `key`: Key in form of a CFString identifying the desired attachment.
82 ///
83 /// Parameter `value`: Attachment in form af a CF object.
84 ///
85 /// Parameter `attachmentMode`: Specifies which attachment mode is desired for this attachment. A particular attachment key may only exist in
86 /// a single mode at a time.
87 pub fn CVBufferSetAttachment(
88 buffer: &CVBuffer,
89 key: &CFString,
90 value: &CFType,
91 attachment_mode: CVAttachmentMode,
92 );
93}
94
95/// Returns a specific attachment of a CVBuffer object
96///
97/// You can attach any CF object to a CVBuffer object to store additional information. CVBufferGetAttachment retrieves an attachement identified by a key.
98///
99/// Parameter `buffer`: Target CVBuffer object.
100///
101/// Parameter `key`: Key in form of a CFString identifying the desired attachment.
102///
103/// Parameter `attachmentMode`: Returns the mode of the attachment, if desired. May be NULL.
104///
105/// Returns: If found the attachment object
106#[deprecated]
107#[inline]
108pub unsafe extern "C-unwind" fn CVBufferGetAttachment(
109 buffer: &CVBuffer,
110 key: &CFString,
111 attachment_mode: *mut CVAttachmentMode,
112) -> Option<CFRetained<CFType>> {
113 extern "C-unwind" {
114 fn CVBufferGetAttachment(
115 buffer: &CVBuffer,
116 key: &CFString,
117 attachment_mode: *mut CVAttachmentMode,
118 ) -> Option<NonNull<CFType>>;
119 }
120 let ret = unsafe { CVBufferGetAttachment(buffer, key, attachment_mode) };
121 ret.map(|ret| unsafe { CFRetained::retain(ret) })
122}
123
124extern "C-unwind" {
125 /// Removes a specific attachment of a CVBuffer object
126 ///
127 /// CVBufferRemoveAttachment removes an attachement identified by a key. If found the attachement is removed and the retain count decremented.
128 ///
129 /// Parameter `buffer`: Target CVBuffer object.
130 ///
131 /// Parameter `key`: Key in form of a CFString identifying the desired attachment.
132 pub fn CVBufferRemoveAttachment(buffer: &CVBuffer, key: &CFString);
133}
134
135extern "C-unwind" {
136 /// Removes all attachments of a CVBuffer object
137 ///
138 /// While CVBufferRemoveAttachment removes a specific attachement identified by a key CVBufferRemoveAllAttachments removes all attachments of a buffer and decrements their retain counts.
139 ///
140 /// Parameter `buffer`: Target CVBuffer object.
141 pub fn CVBufferRemoveAllAttachments(buffer: &CVBuffer);
142}
143
144/// Returns all attachments of a CVBuffer object
145///
146/// CVBufferGetAttachments is a convenience call that returns all attachments with their corresponding keys in a CFDictionary.
147///
148/// Parameter `buffer`: Target CVBuffer object.
149///
150/// Returns: A CFDictionary with all buffer attachments identified by there keys. If no attachment is present, the dictionary is empty. Returns NULL
151/// for invalid attachment mode.
152#[deprecated]
153#[inline]
154pub unsafe extern "C-unwind" fn CVBufferGetAttachments(
155 buffer: &CVBuffer,
156 attachment_mode: CVAttachmentMode,
157) -> Option<CFRetained<CFDictionary>> {
158 extern "C-unwind" {
159 fn CVBufferGetAttachments(
160 buffer: &CVBuffer,
161 attachment_mode: CVAttachmentMode,
162 ) -> Option<NonNull<CFDictionary>>;
163 }
164 let ret = unsafe { CVBufferGetAttachments(buffer, attachment_mode) };
165 ret.map(|ret| unsafe { CFRetained::retain(ret) })
166}
167
168extern "C-unwind" {
169 /// Sets a set of attachments for a CVBuffer
170 ///
171 /// CVBufferSetAttachments is a convenience call that in turn calls CVBufferSetAttachment for each key and value in the given dictionary. All key value pairs must be in the root level of the dictionary.
172 ///
173 /// Parameter `buffer`: Target CVBuffer object.
174 pub fn CVBufferSetAttachments(
175 buffer: &CVBuffer,
176 the_attachments: &CFDictionary,
177 attachment_mode: CVAttachmentMode,
178 );
179}
180
181extern "C-unwind" {
182 /// Copy all propagatable attachments from one buffer to another.
183 ///
184 /// CVBufferPropagateAttachments is a convenience call that copies all attachments with a mode of kCVAttachmentMode_ShouldPropagate from one
185 /// buffer to another.
186 ///
187 /// Parameter `sourceBuffer`: CVBuffer to copy attachments from.
188 ///
189 /// Parameter `destinationBuffer`: CVBuffer to copy attachments to.
190 pub fn CVBufferPropagateAttachments(source_buffer: &CVBuffer, destination_buffer: &CVBuffer);
191}
192
193/// Returns a copy of all attachments of a CVBuffer object. It is the caller’s responsibility to release the returned dictionary.
194///
195/// CVBufferCopyAttachments is a convenience call that returns a copy of all attachments with their corresponding keys in a CFDictionary.
196///
197/// Parameter `buffer`: Target CVBuffer object.
198///
199/// Returns: A CFDictionary with all buffer attachments identified by their keys. If no attachment is present or invalid attachment mode, returns NULL
200#[inline]
201pub unsafe extern "C-unwind" fn CVBufferCopyAttachments(
202 buffer: &CVBuffer,
203 attachment_mode: CVAttachmentMode,
204) -> Option<CFRetained<CFDictionary>> {
205 extern "C-unwind" {
206 fn CVBufferCopyAttachments(
207 buffer: &CVBuffer,
208 attachment_mode: CVAttachmentMode,
209 ) -> Option<NonNull<CFDictionary>>;
210 }
211 let ret = unsafe { CVBufferCopyAttachments(buffer, attachment_mode) };
212 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
213}
214
215/// Returns a retained specific attachment of a CVBuffer object. It is the caller’s responsibility to release the returned value.
216///
217/// You can attach any CF object to a CVBuffer object to store additional information. CVBufferCopyAttachment retrieves a retained attachment identified by a key.
218///
219/// Parameter `buffer`: Target CVBuffer object.
220///
221/// Parameter `key`: Key in form of a CFString identifying the desired attachment.
222///
223/// Parameter `attachmentMode`: Returns the mode of the attachment, if desired. May be NULL.
224///
225/// Returns: If found the attachment object, return the value; otherwize, return NULL.
226#[inline]
227pub unsafe extern "C-unwind" fn CVBufferCopyAttachment(
228 buffer: &CVBuffer,
229 key: &CFString,
230 attachment_mode: *mut CVAttachmentMode,
231) -> Option<CFRetained<CFType>> {
232 extern "C-unwind" {
233 fn CVBufferCopyAttachment(
234 buffer: &CVBuffer,
235 key: &CFString,
236 attachment_mode: *mut CVAttachmentMode,
237 ) -> Option<NonNull<CFType>>;
238 }
239 let ret = unsafe { CVBufferCopyAttachment(buffer, key, attachment_mode) };
240 ret.map(|ret| unsafe { CFRetained::from_raw(ret) })
241}
242
243/// Returns true if an attachment with the passed key is present on a CVBuffer object.
244///
245/// Parameter `buffer`: Target CVBuffer object.
246///
247/// Parameter `key`: Key in form of a CFString identifying the desired attachment.
248///
249/// Returns: True if an attachment with this key is present, otherwise false.
250#[inline]
251pub unsafe extern "C-unwind" fn CVBufferHasAttachment(buffer: &CVBuffer, key: &CFString) -> bool {
252 extern "C-unwind" {
253 fn CVBufferHasAttachment(buffer: &CVBuffer, key: &CFString) -> Boolean;
254 }
255 let ret = unsafe { CVBufferHasAttachment(buffer, key) };
256 ret != 0
257}