screencapturekit/stream/configuration/mod.rs
1mod internal;
2
3pub mod advanced;
4pub mod audio;
5pub mod captured_elements;
6pub mod captured_frames;
7pub mod colors;
8pub mod dimensions;
9pub mod pixel_format;
10pub mod stream_properties;
11
12pub use advanced::SCPresenterOverlayAlertSetting;
13pub use audio::{AudioChannelCount, AudioSampleRate};
14pub use internal::SCStreamConfiguration;
15pub use pixel_format::PixelFormat;
16pub use stream_properties::SCCaptureDynamicRange;
17
18/// Capture resolution type for stream configuration (macOS 14.0+)
19///
20/// Controls how the capture resolution is determined relative to the source content.
21#[repr(i32)]
22#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
23#[cfg(feature = "macos_14_0")]
24pub enum SCCaptureResolutionType {
25 /// Automatically determines the best resolution
26 #[default]
27 Automatic = 0,
28 /// Uses the best available resolution (highest quality)
29 Best = 1,
30 /// Uses the nominal resolution of the display
31 Nominal = 2,
32}
33
34#[cfg(feature = "macos_14_0")]
35impl std::fmt::Display for SCCaptureResolutionType {
36 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
37 match self {
38 Self::Automatic => write!(f, "Automatic"),
39 Self::Best => write!(f, "Best"),
40 Self::Nominal => write!(f, "Nominal"),
41 }
42 }
43}
44
45impl Default for SCStreamConfiguration {
46 fn default() -> Self {
47 Self::internal_init()
48 }
49}
50
51/// Preset for creating stream configurations (macOS 15.0+)
52///
53/// Use these presets to create configurations optimized for specific use cases,
54/// particularly HDR capture scenarios.
55#[repr(i32)]
56#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
57#[cfg(feature = "macos_15_0")]
58pub enum SCStreamConfigurationPreset {
59 /// HDR stream optimized for local display
60 CaptureHDRStreamLocalDisplay = 0,
61 /// HDR stream optimized for canonical display
62 CaptureHDRStreamCanonicalDisplay = 1,
63 /// HDR screenshot optimized for local display
64 CaptureHDRScreenshotLocalDisplay = 2,
65 /// HDR screenshot optimized for canonical display
66 CaptureHDRScreenshotCanonicalDisplay = 3,
67 /// HDR recording optimized for HDR10, preserving SDR range during playback
68 ///
69 /// This preset sets values for `captureDynamicRange`, `pixelFormat`, and `colorSpace`
70 /// intended for a stream recording in HDR10, optimized for rendering on the
71 /// canonical HDR display. It also adds HDR10 metadata to the video recording
72 /// that is designed to preserve the SDR range during video playback.
73 CaptureHDRRecordingPreservedSDRHDR10 = 4,
74}
75
76impl SCStreamConfiguration {
77 /// Create a new stream configuration with default values
78 ///
79 /// This is equivalent to `SCStreamConfiguration::default()`.
80 ///
81 /// # Examples
82 ///
83 /// ```
84 /// use screencapturekit::prelude::*;
85 ///
86 /// let config = SCStreamConfiguration::new()
87 /// .with_width(1920)
88 /// .with_height(1080);
89 /// ```
90 #[must_use]
91 pub fn new() -> Self {
92 Self::default()
93 }
94
95 /// Create a configuration from a preset (macOS 15.0+)
96 ///
97 /// Presets provide optimized default values for specific use cases,
98 /// particularly for HDR capture.
99 ///
100 /// # Examples
101 ///
102 /// ```no_run
103 /// use screencapturekit::stream::configuration::{SCStreamConfiguration, SCStreamConfigurationPreset};
104 ///
105 /// let config = SCStreamConfiguration::from_preset(SCStreamConfigurationPreset::CaptureHDRStreamLocalDisplay);
106 /// ```
107 #[cfg(feature = "macos_15_0")]
108 #[must_use]
109 pub fn from_preset(preset: SCStreamConfigurationPreset) -> Self {
110 unsafe {
111 let ptr = crate::ffi::sc_stream_configuration_create_with_preset(preset as i32);
112 Self::from_ptr(ptr)
113 }
114 }
115
116 #[cfg(feature = "macos_15_0")]
117 pub(crate) unsafe fn from_ptr(ptr: *const std::ffi::c_void) -> Self {
118 Self(ptr)
119 }
120}