objc2_video_toolbox/generated/VTPixelTransferSession.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;
7use objc2_core_foundation::*;
8#[cfg(feature = "objc2-core-video")]
9use objc2_core_video::*;
10
11use crate::*;
12
13/// A reference to a Video Toolbox Pixel Transfer Session.
14///
15/// A pixel transfer session supports the copying and/or conversion of
16/// images from source CVPixelBuffers to destination CVPixelBuffers.
17/// The session reference is a reference-counted CF object.
18/// To create a pixel transfer session, call VTPixelTransferSessionCreate;
19/// then you can optionally configure the session using VTSessionSetProperty;
20/// then to transfer pixels, call VTPixelTransferSessionTransferImage.
21/// When you are done with the session, you should call VTPixelTransferSessionInvalidate
22/// to tear it down and CFRelease to release your object reference.
23///
24/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtpixeltransfersession?language=objc)
25#[repr(C)]
26pub struct VTPixelTransferSession {
27 inner: [u8; 0],
28 _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
29}
30
31cf_type!(
32 #[encoding_name = "OpaqueVTPixelTransferSession"]
33 unsafe impl VTPixelTransferSession {}
34);
35
36extern "C-unwind" {
37 /// Creates a session for transferring images between CVPixelBuffers.
38 ///
39 /// The function creates a session for transferring images between CVPixelBuffers.
40 ///
41 /// Parameter `allocator`: An allocator for the session. Pass NULL to use the default allocator.
42 ///
43 /// Parameter `pixelTransferSessionOut`: Points to a variable to receive the new pixel transfer session.
44 pub fn VTPixelTransferSessionCreate(
45 allocator: Option<&CFAllocator>,
46 pixel_transfer_session_out: NonNull<*mut VTPixelTransferSession>,
47 ) -> OSStatus;
48}
49
50extern "C-unwind" {
51 /// Tears down a pixel transfer session.
52 ///
53 /// When you are done with a pixel transfer session you created, call VTPixelTransferSessionInvalidate
54 /// to tear it down and then CFRelease to release your object reference.
55 /// When a pixel transfer session's retain count reaches zero, it is automatically invalidated, but
56 /// since sessions may be retained by multiple parties, it can be hard to predict when this will happen.
57 /// Calling VTPixelTransferSessionInvalidate ensures a deterministic, orderly teardown.
58 pub fn VTPixelTransferSessionInvalidate(session: &VTPixelTransferSession);
59}
60
61unsafe impl ConcreteType for VTPixelTransferSession {
62 /// Returns the CFTypeID for pixel transfer sessions.
63 #[doc(alias = "VTPixelTransferSessionGetTypeID")]
64 #[inline]
65 fn type_id() -> CFTypeID {
66 extern "C-unwind" {
67 fn VTPixelTransferSessionGetTypeID() -> CFTypeID;
68 }
69 unsafe { VTPixelTransferSessionGetTypeID() }
70 }
71}
72
73extern "C-unwind" {
74 /// Copies and/or converts an image from one pixel buffer to another.
75 ///
76 /// By default, the full width and height of sourceBuffer are scaled to the full
77 /// width and height of destinationBuffer.
78 /// By default, all existing attachments on destinationBuffer are removed and new attachments
79 /// are set describing the transferred image. Unrecognised attachments on sourceBuffer will
80 /// be propagated to destinationBuffer.
81 /// Some properties will modify this behaviour; see VTPixelTransferProperties.h for more details.
82 ///
83 /// Parameter `session`: The pixel transfer session.
84 ///
85 /// Parameter `sourceBuffer`: The source buffer.
86 ///
87 /// Parameter `destinationBuffer`: The destination buffer.
88 ///
89 /// Returns: If the transfer was successful, noErr; otherwise an error code, such as kVTPixelTransferNotSupportedErr.
90 #[cfg(feature = "objc2-core-video")]
91 pub fn VTPixelTransferSessionTransferImage(
92 session: &VTPixelTransferSession,
93 source_buffer: &CVPixelBuffer,
94 destination_buffer: &CVPixelBuffer,
95 ) -> OSStatus;
96}