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