objc2_video_toolbox/generated/
VTHDRPerFrameMetadataGenerationSession.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/// Video Toolbox HDR Metadata Generation Session
16///
17///
18/// This file defines the public API for the VTHDRPerFrameMetadataGenerationSession.
19///
20/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vthdrperframemetadatagenerationhdrformattype?language=objc)
21// NS_TYPED_EXTENSIBLE_ENUM
22pub type VTHDRPerFrameMetadataGenerationHDRFormatType = CFString;
23
24extern "C" {
25    /// Specifies that DolbyVision data should be generated and attached for each pixel buffer.
26    ///
27    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvthdrperframemetadatagenerationhdrformattype_dolbyvision?language=objc)
28    pub static kVTHDRPerFrameMetadataGenerationHDRFormatType_DolbyVision:
29        &'static VTHDRPerFrameMetadataGenerationHDRFormatType;
30}
31
32extern "C" {
33    /// Specifies an array of HDR formats that should be generated.
34    ///
35    /// This key represents a CFArrayRef. Only one key is supported ( kVTHDRPerFrameMetadataGenerationHDRFormatType_DolbyVision ).
36    ///
37    /// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvthdrperframemetadatagenerationoptionskey_hdrformats?language=objc)
38    pub static kVTHDRPerFrameMetadataGenerationOptionsKey_HDRFormats: &'static CFString;
39}
40
41/// A mechanism for generating HDR Per Frame Metadata and attaching that metadata to a CVPixelBuffer and the backing IOSurface.
42///
43/// VTHDRPerFrameMetadataGenerationSessionRef is a CF type, so call CFRelease to release your object reference.
44///
45/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vthdrperframemetadatagenerationsession?language=objc)
46#[doc(alias = "VTHDRPerFrameMetadataGenerationSessionRef")]
47#[repr(C)]
48pub struct VTHDRPerFrameMetadataGenerationSession {
49    inner: [u8; 0],
50    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
51}
52
53cf_type!(
54    unsafe impl VTHDRPerFrameMetadataGenerationSession {}
55);
56#[cfg(feature = "objc2")]
57cf_objc2_type!(
58    unsafe impl RefEncode<"OpaqueVTHDRPerFrameMetadataGenerationSession">
59        for VTHDRPerFrameMetadataGenerationSession
60    {
61    }
62);
63
64unsafe impl ConcreteType for VTHDRPerFrameMetadataGenerationSession {
65    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionGetTypeID")]
66    #[inline]
67    fn type_id() -> CFTypeID {
68        extern "C-unwind" {
69            fn VTHDRPerFrameMetadataGenerationSessionGetTypeID() -> CFTypeID;
70        }
71        unsafe { VTHDRPerFrameMetadataGenerationSessionGetTypeID() }
72    }
73}
74
75impl VTHDRPerFrameMetadataGenerationSession {
76    /// Creates a VTHDRPerFrameMetadataGenerationSession object.
77    ///
78    /// The returned VTHDRPerFrameMetadataGenerationSession object may be used to perform HDR Per Frame Metadata Generation
79    /// Call CFRelease to release your object reference.
80    ///
81    /// Parameter `framesPerSecond`: Value must be greater than 0.0
82    ///
83    /// Parameter `options`: CFDictionary may contain the key kVTHDRPerFrameMetadataGenerationOptionsHDRFormatsKey.
84    ///
85    /// # Safety
86    ///
87    /// - `options` generics must be of the correct type.
88    /// - `hdr_per_frame_metadata_generation_session_out` must be a valid pointer.
89    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionCreate")]
90    #[inline]
91    pub unsafe fn create(
92        allocator: Option<&CFAllocator>,
93        frames_per_second: c_float,
94        options: Option<&CFDictionary>,
95        hdr_per_frame_metadata_generation_session_out: NonNull<
96            *mut VTHDRPerFrameMetadataGenerationSession,
97        >,
98    ) -> OSStatus {
99        extern "C-unwind" {
100            fn VTHDRPerFrameMetadataGenerationSessionCreate(
101                allocator: Option<&CFAllocator>,
102                frames_per_second: c_float,
103                options: Option<&CFDictionary>,
104                hdr_per_frame_metadata_generation_session_out: NonNull<
105                    *mut VTHDRPerFrameMetadataGenerationSession,
106                >,
107            ) -> OSStatus;
108        }
109        unsafe {
110            VTHDRPerFrameMetadataGenerationSessionCreate(
111                allocator,
112                frames_per_second,
113                options,
114                hdr_per_frame_metadata_generation_session_out,
115            )
116        }
117    }
118
119    /// Attaches the Per Frame Metadata to the CVPixelBuffer and the backing IOSurface
120    ///
121    /// Call this to analyze and attach HDR Metadata. This call will change CVPixelBuffer attachments and backing IOSurface attachments.
122    ///
123    /// Parameter `hdrPerFrameMetadataGenerationSession`:
124    /// Parameter `pixelBuffer`:
125    /// Parameter `sceneChange`: If this frame changes significantly in brightness from the previous frame, for example going from an indoor scene to an outdoor scene or
126    /// from a night scene to a daytime scene, set this to true.
127    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionAttachMetadata")]
128    #[cfg(feature = "objc2-core-video")]
129    #[inline]
130    pub unsafe fn attach_metadata(
131        &self,
132        pixel_buffer: &CVPixelBuffer,
133        scene_change: bool,
134    ) -> OSStatus {
135        extern "C-unwind" {
136            fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
137                hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
138                pixel_buffer: &CVPixelBuffer,
139                scene_change: Boolean,
140            ) -> OSStatus;
141        }
142        unsafe {
143            VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
144                self,
145                pixel_buffer,
146                scene_change as _,
147            )
148        }
149    }
150}
151
152extern "C-unwind" {
153    #[deprecated = "renamed to `VTHDRPerFrameMetadataGenerationSession::create`"]
154    pub fn VTHDRPerFrameMetadataGenerationSessionCreate(
155        allocator: Option<&CFAllocator>,
156        frames_per_second: c_float,
157        options: Option<&CFDictionary>,
158        hdr_per_frame_metadata_generation_session_out: NonNull<
159            *mut VTHDRPerFrameMetadataGenerationSession,
160        >,
161    ) -> OSStatus;
162}
163
164#[cfg(feature = "objc2-core-video")]
165#[deprecated = "renamed to `VTHDRPerFrameMetadataGenerationSession::attach_metadata`"]
166#[inline]
167pub unsafe extern "C-unwind" fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
168    hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
169    pixel_buffer: &CVPixelBuffer,
170    scene_change: bool,
171) -> OSStatus {
172    extern "C-unwind" {
173        fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
174            hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
175            pixel_buffer: &CVPixelBuffer,
176            scene_change: Boolean,
177        ) -> OSStatus;
178    }
179    unsafe {
180        VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
181            hdr_per_frame_metadata_generation_session,
182            pixel_buffer,
183            scene_change as _,
184        )
185    }
186}