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 #[cfg(feature = "macos_26_0")]
74 CaptureHDRRecordingPreservedSDRHDR10 = 4,
75}
76
77impl SCStreamConfiguration {
78 /// Create a new stream configuration with default values
79 ///
80 /// This is equivalent to `SCStreamConfiguration::default()`.
81 ///
82 /// # Examples
83 ///
84 /// ```
85 /// use screencapturekit::prelude::*;
86 ///
87 /// let config = SCStreamConfiguration::new()
88 /// .with_width(1920)
89 /// .with_height(1080);
90 /// ```
91 #[must_use]
92 pub fn new() -> Self {
93 Self::default()
94 }
95
96 /// Create a configuration from a preset (macOS 15.0+)
97 ///
98 /// Presets provide optimized default values for specific use cases,
99 /// particularly for HDR capture.
100 ///
101 /// # Examples
102 ///
103 /// ```no_run
104 /// use screencapturekit::stream::configuration::{SCStreamConfiguration, SCStreamConfigurationPreset};
105 ///
106 /// let config = SCStreamConfiguration::from_preset(SCStreamConfigurationPreset::CaptureHDRStreamLocalDisplay);
107 /// ```
108 #[cfg(feature = "macos_15_0")]
109 #[must_use]
110 pub fn from_preset(preset: SCStreamConfigurationPreset) -> Self {
111 unsafe {
112 let ptr = crate::ffi::sc_stream_configuration_create_with_preset(preset as i32);
113 Self::from_ptr(ptr)
114 }
115 }
116
117 #[cfg(feature = "macos_15_0")]
118 pub(crate) unsafe fn from_ptr(ptr: *const std::ffi::c_void) -> Self {
119 Self(ptr)
120 }
121}