objc2_video_toolbox/generated/
VTPixelRotationSession.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#[cfg(feature = "objc2-core-video")]
11use objc2_core_video::*;
12
13use crate::*;
14
15/// A reference to a Video Toolbox Pixel Rotation Session.
16///
17/// A pixel rotation session supports the rotating of images from source CVPixelBuffers to
18/// destination CVPixelBuffers.  The session reference is a reference-counted CF object.
19/// To create an image rotation session, call VTPixelRotationSessionCreate;
20/// then you can optionally configure the session using VTSessionSetProperty;
21/// then to transfer pixels, call VTPixelRotationSessionRotateImage.
22/// When you are done with the session, you should call CFRelease to tear it down
23/// and release your object reference.
24///
25/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vtpixelrotationsession?language=objc)
26#[doc(alias = "VTPixelRotationSessionRef")]
27#[repr(C)]
28pub struct VTPixelRotationSession {
29    inner: [u8; 0],
30    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
31}
32
33cf_type!(
34    unsafe impl VTPixelRotationSession {}
35);
36#[cfg(feature = "objc2")]
37cf_objc2_type!(
38    unsafe impl RefEncode<"OpaqueVTPixelRotationSession"> for VTPixelRotationSession {}
39);
40
41impl VTPixelRotationSession {
42    /// Creates a session for rotating images between CVPixelBuffers.
43    ///
44    /// Parameter `allocator`: An allocator for the session.  Pass NULL to use the default allocator.
45    ///
46    /// Parameter `pixelRotationSessionOut`: Points to a variable to receive the new pixel rotation session.
47    ///
48    /// # Safety
49    ///
50    /// `pixel_rotation_session_out` must be a valid pointer.
51    #[doc(alias = "VTPixelRotationSessionCreate")]
52    #[inline]
53    pub unsafe fn create(
54        allocator: Option<&CFAllocator>,
55        pixel_rotation_session_out: NonNull<*mut VTPixelRotationSession>,
56    ) -> OSStatus {
57        extern "C-unwind" {
58            fn VTPixelRotationSessionCreate(
59                allocator: Option<&CFAllocator>,
60                pixel_rotation_session_out: NonNull<*mut VTPixelRotationSession>,
61            ) -> OSStatus;
62        }
63        unsafe { VTPixelRotationSessionCreate(allocator, pixel_rotation_session_out) }
64    }
65
66    /// Tears down a pixel rotation session.
67    ///
68    /// When you are done with an image rotation session you created, call VTPixelRotationSessionInvalidate
69    /// to tear it down and then CFRelease to release your object reference.
70    /// When an pixel rotation session's retain count reaches zero, it is automatically invalidated, but
71    /// since sessions may be retained by multiple parties, it can be hard to predict when this will happen.
72    /// Calling VTPixelRotationSessionInvalidate ensures a deterministic, orderly teardown.
73    #[doc(alias = "VTPixelRotationSessionInvalidate")]
74    #[inline]
75    pub unsafe fn invalidate(&self) {
76        extern "C-unwind" {
77            fn VTPixelRotationSessionInvalidate(session: &VTPixelRotationSession);
78        }
79        unsafe { VTPixelRotationSessionInvalidate(self) }
80    }
81}
82
83unsafe impl ConcreteType for VTPixelRotationSession {
84    /// Returns the CFTypeID for pixel rotation sessions.
85    #[doc(alias = "VTPixelRotationSessionGetTypeID")]
86    #[inline]
87    fn type_id() -> CFTypeID {
88        extern "C-unwind" {
89            fn VTPixelRotationSessionGetTypeID() -> CFTypeID;
90        }
91        unsafe { VTPixelRotationSessionGetTypeID() }
92    }
93}
94
95impl VTPixelRotationSession {
96    /// Rotates a pixel buffer.
97    ///
98    /// Rotates sourceBuffer and places the output in destinationBuffer.
99    /// For 90 and 270 degree rotations, the width and height of destinationBuffer must be the inverse
100    /// of sourceBuffer.
101    /// For 180 degree rotations, the width and height of destinationBuffer and sourceBuffer must match.
102    /// By default, all existing attachments on destinationBuffer are removed and new attachments
103    /// are set describing the transferred image.  Unrecognised attachments on sourceBuffer will
104    /// be propagated to destinationBuffer.
105    /// Some properties may modify this behaviour; see VTPixelRotationProperties.h for more details.
106    ///
107    /// Parameter `session`: The pixel rotation session.
108    ///
109    /// Parameter `sourceBuffer`: The source buffer.
110    ///
111    /// Parameter `destinationBuffer`: The destination buffer.
112    ///
113    /// Returns: If the transfer was successful, noErr; otherwise an error code, such as kVTPixelRotationNotSupportedErr.
114    #[doc(alias = "VTPixelRotationSessionRotateImage")]
115    #[cfg(feature = "objc2-core-video")]
116    #[inline]
117    pub unsafe fn rotate_image(
118        &self,
119        source_buffer: &CVPixelBuffer,
120        destination_buffer: &CVPixelBuffer,
121    ) -> OSStatus {
122        extern "C-unwind" {
123            fn VTPixelRotationSessionRotateImage(
124                session: &VTPixelRotationSession,
125                source_buffer: &CVPixelBuffer,
126                destination_buffer: &CVPixelBuffer,
127            ) -> OSStatus;
128        }
129        unsafe { VTPixelRotationSessionRotateImage(self, source_buffer, destination_buffer) }
130    }
131}
132
133extern "C-unwind" {
134    #[deprecated = "renamed to `VTPixelRotationSession::create`"]
135    pub fn VTPixelRotationSessionCreate(
136        allocator: Option<&CFAllocator>,
137        pixel_rotation_session_out: NonNull<*mut VTPixelRotationSession>,
138    ) -> OSStatus;
139}
140
141extern "C-unwind" {
142    #[deprecated = "renamed to `VTPixelRotationSession::invalidate`"]
143    pub fn VTPixelRotationSessionInvalidate(session: &VTPixelRotationSession);
144}
145
146extern "C-unwind" {
147    #[cfg(feature = "objc2-core-video")]
148    #[deprecated = "renamed to `VTPixelRotationSession::rotate_image`"]
149    pub fn VTPixelRotationSessionRotateImage(
150        session: &VTPixelRotationSession,
151        source_buffer: &CVPixelBuffer,
152        destination_buffer: &CVPixelBuffer,
153    ) -> OSStatus;
154}