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#[repr(C)]
47pub struct VTHDRPerFrameMetadataGenerationSession {
48    inner: [u8; 0],
49    _p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
50}
51
52cf_type!(
53    unsafe impl VTHDRPerFrameMetadataGenerationSession {}
54);
55#[cfg(feature = "objc2")]
56cf_objc2_type!(
57    unsafe impl RefEncode<"OpaqueVTHDRPerFrameMetadataGenerationSession">
58        for VTHDRPerFrameMetadataGenerationSession
59    {
60    }
61);
62
63unsafe impl ConcreteType for VTHDRPerFrameMetadataGenerationSession {
64    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionGetTypeID")]
65    #[inline]
66    fn type_id() -> CFTypeID {
67        extern "C-unwind" {
68            fn VTHDRPerFrameMetadataGenerationSessionGetTypeID() -> CFTypeID;
69        }
70        unsafe { VTHDRPerFrameMetadataGenerationSessionGetTypeID() }
71    }
72}
73
74impl VTHDRPerFrameMetadataGenerationSession {
75    /// Creates a VTHDRPerFrameMetadataGenerationSession object.
76    ///
77    /// The returned VTHDRPerFrameMetadataGenerationSession object may be used to perform HDR Per Frame Metadata Generation
78    /// Call CFRelease to release your object reference.
79    ///
80    /// Parameter `framesPerSecond`: Value must be greater than 0.0
81    ///
82    /// Parameter `options`: CFDictionary may contain the key kVTHDRPerFrameMetadataGenerationOptionsHDRFormatsKey.
83    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionCreate")]
84    #[inline]
85    pub unsafe fn create(
86        allocator: Option<&CFAllocator>,
87        frames_per_second: c_float,
88        options: Option<&CFDictionary>,
89        hdr_per_frame_metadata_generation_session_out: NonNull<
90            *mut VTHDRPerFrameMetadataGenerationSession,
91        >,
92    ) -> OSStatus {
93        extern "C-unwind" {
94            fn VTHDRPerFrameMetadataGenerationSessionCreate(
95                allocator: Option<&CFAllocator>,
96                frames_per_second: c_float,
97                options: Option<&CFDictionary>,
98                hdr_per_frame_metadata_generation_session_out: NonNull<
99                    *mut VTHDRPerFrameMetadataGenerationSession,
100                >,
101            ) -> OSStatus;
102        }
103        unsafe {
104            VTHDRPerFrameMetadataGenerationSessionCreate(
105                allocator,
106                frames_per_second,
107                options,
108                hdr_per_frame_metadata_generation_session_out,
109            )
110        }
111    }
112
113    /// Attaches the Per Frame Metadata to the CVPixelBuffer and the backing IOSurface
114    ///
115    /// Call this to analyze and attach HDR Metadata. This call will change CVPixelBuffer attachments and backing IOSurface attachments.
116    ///
117    /// Parameter `hdrPerFrameMetadataGenerationSession`:
118    /// Parameter `pixelBuffer`:
119    /// 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
120    /// from a night scene to a daytime scene, set this to true.
121    #[doc(alias = "VTHDRPerFrameMetadataGenerationSessionAttachMetadata")]
122    #[cfg(feature = "objc2-core-video")]
123    #[inline]
124    pub unsafe fn attach_metadata(
125        self: &VTHDRPerFrameMetadataGenerationSession,
126        pixel_buffer: &CVPixelBuffer,
127        scene_change: bool,
128    ) -> OSStatus {
129        extern "C-unwind" {
130            fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
131                hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
132                pixel_buffer: &CVPixelBuffer,
133                scene_change: Boolean,
134            ) -> OSStatus;
135        }
136        unsafe {
137            VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
138                self,
139                pixel_buffer,
140                scene_change as _,
141            )
142        }
143    }
144}
145
146extern "C-unwind" {
147    #[deprecated = "renamed to `VTHDRPerFrameMetadataGenerationSession::create`"]
148    pub fn VTHDRPerFrameMetadataGenerationSessionCreate(
149        allocator: Option<&CFAllocator>,
150        frames_per_second: c_float,
151        options: Option<&CFDictionary>,
152        hdr_per_frame_metadata_generation_session_out: NonNull<
153            *mut VTHDRPerFrameMetadataGenerationSession,
154        >,
155    ) -> OSStatus;
156}
157
158#[cfg(feature = "objc2-core-video")]
159#[deprecated = "renamed to `VTHDRPerFrameMetadataGenerationSession::attach_metadata`"]
160#[inline]
161pub unsafe extern "C-unwind" fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
162    hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
163    pixel_buffer: &CVPixelBuffer,
164    scene_change: bool,
165) -> OSStatus {
166    extern "C-unwind" {
167        fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
168            hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
169            pixel_buffer: &CVPixelBuffer,
170            scene_change: Boolean,
171        ) -> OSStatus;
172    }
173    unsafe {
174        VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
175            hdr_per_frame_metadata_generation_session,
176            pixel_buffer,
177            scene_change as _,
178        )
179    }
180}