screencapturekit/stream/configuration/
advanced.rs

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