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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
//! 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::*;
/// Video Toolbox HDR Metadata Generation Session
///
///
/// This file defines the public API for the VTHDRPerFrameMetadataGenerationSession.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vthdrperframemetadatagenerationhdrformattype?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type VTHDRPerFrameMetadataGenerationHDRFormatType = CFString;
extern "C" {
/// Specifies that DolbyVision data should be generated and attached for each pixel buffer.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvthdrperframemetadatagenerationhdrformattype_dolbyvision?language=objc)
pub static kVTHDRPerFrameMetadataGenerationHDRFormatType_DolbyVision:
&'static VTHDRPerFrameMetadataGenerationHDRFormatType;
}
extern "C" {
/// Specifies an array of HDR formats that should be generated.
///
/// This key represents a CFArrayRef. Only one key is supported ( kVTHDRPerFrameMetadataGenerationHDRFormatType_DolbyVision ).
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/kvthdrperframemetadatagenerationoptionskey_hdrformats?language=objc)
pub static kVTHDRPerFrameMetadataGenerationOptionsKey_HDRFormats: &'static CFString;
}
/// A mechanism for generating HDR Per Frame Metadata and attaching that metadata to a CVPixelBuffer and the backing IOSurface.
///
/// VTHDRPerFrameMetadataGenerationSessionRef is a CF type, so call CFRelease to release your object reference.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/videotoolbox/vthdrperframemetadatagenerationsession?language=objc)
#[doc(alias = "VTHDRPerFrameMetadataGenerationSessionRef")]
#[repr(C)]
pub struct VTHDRPerFrameMetadataGenerationSession {
inner: [u8; 0],
_p: UnsafeCell<PhantomData<(*const UnsafeCell<()>, PhantomPinned)>>,
}
cf_type!(
unsafe impl VTHDRPerFrameMetadataGenerationSession {}
);
#[cfg(feature = "objc2")]
cf_objc2_type!(
unsafe impl RefEncode<"OpaqueVTHDRPerFrameMetadataGenerationSession">
for VTHDRPerFrameMetadataGenerationSession
{
}
);
unsafe impl ConcreteType for VTHDRPerFrameMetadataGenerationSession {
#[doc(alias = "VTHDRPerFrameMetadataGenerationSessionGetTypeID")]
#[inline]
fn type_id() -> CFTypeID {
extern "C-unwind" {
fn VTHDRPerFrameMetadataGenerationSessionGetTypeID() -> CFTypeID;
}
unsafe { VTHDRPerFrameMetadataGenerationSessionGetTypeID() }
}
}
impl VTHDRPerFrameMetadataGenerationSession {
/// Creates a VTHDRPerFrameMetadataGenerationSession object.
///
/// The returned VTHDRPerFrameMetadataGenerationSession object may be used to perform HDR Per Frame Metadata Generation
/// Call CFRelease to release your object reference.
///
/// Parameter `framesPerSecond`: Value must be greater than 0.0
///
/// Parameter `options`: CFDictionary may contain the key kVTHDRPerFrameMetadataGenerationOptionsHDRFormatsKey.
///
/// # Safety
///
/// - `options` generics must be of the correct type.
/// - `hdr_per_frame_metadata_generation_session_out` must be a valid pointer.
#[doc(alias = "VTHDRPerFrameMetadataGenerationSessionCreate")]
#[inline]
pub unsafe fn create(
allocator: Option<&CFAllocator>,
frames_per_second: c_float,
options: Option<&CFDictionary>,
hdr_per_frame_metadata_generation_session_out: NonNull<
*mut VTHDRPerFrameMetadataGenerationSession,
>,
) -> OSStatus {
extern "C-unwind" {
fn VTHDRPerFrameMetadataGenerationSessionCreate(
allocator: Option<&CFAllocator>,
frames_per_second: c_float,
options: Option<&CFDictionary>,
hdr_per_frame_metadata_generation_session_out: NonNull<
*mut VTHDRPerFrameMetadataGenerationSession,
>,
) -> OSStatus;
}
unsafe {
VTHDRPerFrameMetadataGenerationSessionCreate(
allocator,
frames_per_second,
options,
hdr_per_frame_metadata_generation_session_out,
)
}
}
/// Attaches the Per Frame Metadata to the CVPixelBuffer and the backing IOSurface
///
/// Call this to analyze and attach HDR Metadata. This call will change CVPixelBuffer attachments and backing IOSurface attachments.
///
/// Parameter `hdrPerFrameMetadataGenerationSession`:
/// Parameter `pixelBuffer`:
/// 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
/// from a night scene to a daytime scene, set this to true.
#[doc(alias = "VTHDRPerFrameMetadataGenerationSessionAttachMetadata")]
#[cfg(feature = "objc2-core-video")]
#[inline]
pub unsafe fn attach_metadata(
&self,
pixel_buffer: &CVPixelBuffer,
scene_change: bool,
) -> OSStatus {
extern "C-unwind" {
fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
pixel_buffer: &CVPixelBuffer,
scene_change: Boolean,
) -> OSStatus;
}
unsafe {
VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
self,
pixel_buffer,
scene_change as _,
)
}
}
}
extern "C-unwind" {
#[deprecated = "renamed to `VTHDRPerFrameMetadataGenerationSession::create`"]
pub fn VTHDRPerFrameMetadataGenerationSessionCreate(
allocator: Option<&CFAllocator>,
frames_per_second: c_float,
options: Option<&CFDictionary>,
hdr_per_frame_metadata_generation_session_out: NonNull<
*mut VTHDRPerFrameMetadataGenerationSession,
>,
) -> OSStatus;
}
#[cfg(feature = "objc2-core-video")]
#[deprecated = "renamed to `VTHDRPerFrameMetadataGenerationSession::attach_metadata`"]
#[inline]
pub unsafe extern "C-unwind" fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
pixel_buffer: &CVPixelBuffer,
scene_change: bool,
) -> OSStatus {
extern "C-unwind" {
fn VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
hdr_per_frame_metadata_generation_session: &VTHDRPerFrameMetadataGenerationSession,
pixel_buffer: &CVPixelBuffer,
scene_change: Boolean,
) -> OSStatus;
}
unsafe {
VTHDRPerFrameMetadataGenerationSessionAttachMetadata(
hdr_per_frame_metadata_generation_session,
pixel_buffer,
scene_change as _,
)
}
}