screencapturekit/stream/configuration/
advanced.rs

1use super::internal::SCStreamConfiguration;
2
3/// Presenter overlay privacy alert setting (macOS 14.2+)
4///
5/// Controls when the system displays a privacy alert for presenter overlay.
6#[repr(i32)]
7#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
8pub enum SCPresenterOverlayAlertSetting {
9    /// Let the system decide when to show the alert
10    #[default]
11    System = 0,
12    /// Never show the privacy alert
13    Never = 1,
14    /// Always show the privacy alert
15    Always = 2,
16}
17
18impl SCStreamConfiguration {
19    /// Sets whether to ignore shadows for single window capture.
20    ///
21    /// A Boolean value that indicates whether the stream omits the shadow effects
22    /// of the windows it captures.
23    /// Available on macOS 14.0+
24    ///
25    /// Requires the `macos_14_0` feature flag to be enabled.
26    #[cfg(feature = "macos_14_0")]
27    pub fn set_ignores_shadows_single_window(&mut self, ignores_shadows: bool) -> &mut Self {
28        unsafe {
29            crate::ffi::sc_stream_configuration_set_ignores_shadows_single_window(
30                self.as_ptr(),
31                ignores_shadows,
32            );
33        }
34        self
35    }
36
37    /// Sets whether to ignore shadows for single window capture (builder pattern)
38    #[cfg(feature = "macos_14_0")]
39    #[must_use]
40    pub fn with_ignores_shadows_single_window(mut self, ignores_shadows: bool) -> Self {
41        self.set_ignores_shadows_single_window(ignores_shadows);
42        self
43    }
44
45    #[cfg(feature = "macos_14_0")]
46    pub fn ignores_shadows_single_window(&self) -> bool {
47        unsafe {
48            crate::ffi::sc_stream_configuration_get_ignores_shadows_single_window(self.as_ptr())
49        }
50    }
51
52    /// Sets whether captured content should be treated as opaque.
53    ///
54    /// A Boolean value that indicates whether the stream treats the transparency
55    /// of the captured content as opaque.
56    /// Available on macOS 13.0+
57    ///
58    /// Requires the `macos_13_0` feature flag to be enabled.
59    #[cfg(feature = "macos_13_0")]
60    pub fn set_should_be_opaque(&mut self, should_be_opaque: bool) -> &mut Self {
61        unsafe {
62            crate::ffi::sc_stream_configuration_set_should_be_opaque(
63                self.as_ptr(),
64                should_be_opaque,
65            );
66        }
67        self
68    }
69
70    /// Sets whether captured content should be treated as opaque (builder pattern)
71    #[cfg(feature = "macos_13_0")]
72    #[must_use]
73    pub fn with_should_be_opaque(mut self, should_be_opaque: bool) -> Self {
74        self.set_should_be_opaque(should_be_opaque);
75        self
76    }
77
78    #[cfg(feature = "macos_13_0")]
79    pub fn should_be_opaque(&self) -> bool {
80        unsafe { crate::ffi::sc_stream_configuration_get_should_be_opaque(self.as_ptr()) }
81    }
82
83    /// Sets whether to include child windows in capture.
84    ///
85    /// A Boolean value that indicates whether the content includes child windows.
86    /// Available on macOS 14.2+
87    ///
88    /// Requires the `macos_14_2` feature flag to be enabled.
89    #[cfg(feature = "macos_14_2")]
90    pub fn set_includes_child_windows(&mut self, includes_child_windows: bool) -> &mut Self {
91        unsafe {
92            crate::ffi::sc_stream_configuration_set_includes_child_windows(
93                self.as_ptr(),
94                includes_child_windows,
95            );
96        }
97        self
98    }
99
100    /// Sets whether to include child windows (builder pattern)
101    #[cfg(feature = "macos_14_2")]
102    #[must_use]
103    pub fn with_includes_child_windows(mut self, includes_child_windows: bool) -> Self {
104        self.set_includes_child_windows(includes_child_windows);
105        self
106    }
107
108    #[cfg(feature = "macos_14_2")]
109    pub fn includes_child_windows(&self) -> bool {
110        unsafe { crate::ffi::sc_stream_configuration_get_includes_child_windows(self.as_ptr()) }
111    }
112
113    /// Sets the presenter overlay privacy alert setting.
114    ///
115    /// A configuration for the privacy alert that the capture session displays.
116    /// Available on macOS 14.2+
117    ///
118    /// Requires the `macos_14_2` feature flag to be enabled.
119    #[cfg(feature = "macos_14_2")]
120    pub fn set_presenter_overlay_privacy_alert_setting(
121        &mut self,
122        setting: SCPresenterOverlayAlertSetting,
123    ) -> &mut Self {
124        unsafe {
125            crate::ffi::sc_stream_configuration_set_presenter_overlay_privacy_alert_setting(
126                self.as_ptr(),
127                setting as i32,
128            );
129        }
130        self
131    }
132
133    /// Sets the presenter overlay privacy alert setting (builder pattern)
134    #[cfg(feature = "macos_14_2")]
135    #[must_use]
136    pub fn with_presenter_overlay_privacy_alert_setting(
137        mut self,
138        setting: SCPresenterOverlayAlertSetting,
139    ) -> Self {
140        self.set_presenter_overlay_privacy_alert_setting(setting);
141        self
142    }
143
144    #[cfg(feature = "macos_14_2")]
145    pub fn presenter_overlay_privacy_alert_setting(&self) -> SCPresenterOverlayAlertSetting {
146        let value = unsafe {
147            crate::ffi::sc_stream_configuration_get_presenter_overlay_privacy_alert_setting(
148                self.as_ptr(),
149            )
150        };
151        match value {
152            1 => SCPresenterOverlayAlertSetting::Never,
153            2 => SCPresenterOverlayAlertSetting::Always,
154            _ => SCPresenterOverlayAlertSetting::System,
155        }
156    }
157
158    /// Sets whether to ignore shadow display configuration.
159    ///
160    /// Available on macOS 14.0+
161    ///
162    /// Requires the `macos_14_0` feature flag to be enabled.
163    #[cfg(feature = "macos_14_0")]
164    pub fn set_ignores_shadow_display_configuration(&mut self, ignores_shadow: bool) -> &mut Self {
165        unsafe {
166            crate::ffi::sc_stream_configuration_set_ignores_shadow_display_configuration(
167                self.as_ptr(),
168                ignores_shadow,
169            );
170        }
171        self
172    }
173
174    /// Sets whether to ignore shadow display configuration (builder pattern)
175    #[cfg(feature = "macos_14_0")]
176    #[must_use]
177    pub fn with_ignores_shadow_display_configuration(mut self, ignores_shadow: bool) -> Self {
178        self.set_ignores_shadow_display_configuration(ignores_shadow);
179        self
180    }
181
182    #[cfg(feature = "macos_14_0")]
183    pub fn ignores_shadow_display_configuration(&self) -> bool {
184        unsafe {
185            crate::ffi::sc_stream_configuration_get_ignores_shadow_display_configuration(
186                self.as_ptr(),
187            )
188        }
189    }
190}