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