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