pub struct SCStreamConfiguration(/* private fields */);Expand description
Opaque wrapper around SCStreamConfiguration
Configuration for a screen capture stream, including dimensions, pixel format, audio settings, and other capture parameters.
§Examples
use screencapturekit::stream::configuration::SCStreamConfiguration;
let config = SCStreamConfiguration::new()
.with_width(1920)
.with_height(1080);Implementations§
Source§impl SCStreamConfiguration
impl SCStreamConfiguration
Sourcepub fn set_ignores_shadows_single_window(
&mut self,
ignores_shadows: bool,
) -> SCResult<&mut Self>
pub fn set_ignores_shadows_single_window( &mut self, ignores_shadows: bool, ) -> SCResult<&mut Self>
Sets whether to ignore shadows for single window capture.
A Boolean value that indicates whether the stream omits the shadow effects of the windows it captures. Available on macOS 14.0+
Requires the macos_14_0 feature flag to be enabled.
Sourcepub fn with_ignores_shadows_single_window(
self,
ignores_shadows: bool,
) -> SCResult<Self>
pub fn with_ignores_shadows_single_window( self, ignores_shadows: bool, ) -> SCResult<Self>
Sets whether to ignore shadows for single window capture (builder pattern)
Sourcepub fn ignores_shadows_single_window(&self) -> bool
pub fn ignores_shadows_single_window(&self) -> bool
Get whether shadows are ignored for single-window capture (macOS 14.0+).
Sourcepub fn set_should_be_opaque(
&mut self,
should_be_opaque: bool,
) -> SCResult<&mut Self>
pub fn set_should_be_opaque( &mut self, should_be_opaque: bool, ) -> SCResult<&mut Self>
Sets whether captured content should be treated as opaque.
A Boolean value that indicates whether the stream treats the transparency of the captured content as opaque.
Available on macOS 14.0+ (SCStreamConfiguration.shouldBeOpaque is
annotated API_AVAILABLE(macos(14.0))), so this requires the
macos_14_0 feature flag. On older systems it returns
SCError::FeatureNotAvailable.
Sourcepub fn with_should_be_opaque(self, should_be_opaque: bool) -> SCResult<Self>
pub fn with_should_be_opaque(self, should_be_opaque: bool) -> SCResult<Self>
Sets whether captured content should be treated as opaque (builder pattern)
Sourcepub fn should_be_opaque(&self) -> bool
pub fn should_be_opaque(&self) -> bool
Get whether captured content is treated as opaque (macOS 14.0+).
Sourcepub fn set_includes_child_windows(
&mut self,
includes_child_windows: bool,
) -> SCResult<&mut Self>
pub fn set_includes_child_windows( &mut self, includes_child_windows: bool, ) -> SCResult<&mut Self>
Sets whether to include child windows in capture.
A Boolean value that indicates whether the content includes child windows. Available on macOS 14.2+
Requires the macos_14_2 feature flag to be enabled.
Sourcepub fn with_includes_child_windows(
self,
includes_child_windows: bool,
) -> SCResult<Self>
pub fn with_includes_child_windows( self, includes_child_windows: bool, ) -> SCResult<Self>
Sets whether to include child windows (builder pattern)
Sourcepub fn includes_child_windows(&self) -> bool
pub fn includes_child_windows(&self) -> bool
Get whether child windows are included (macOS 14.2+).
Sourcepub fn set_presenter_overlay_privacy_alert_setting(
&mut self,
setting: SCPresenterOverlayAlertSetting,
) -> SCResult<&mut Self>
pub fn set_presenter_overlay_privacy_alert_setting( &mut self, setting: SCPresenterOverlayAlertSetting, ) -> SCResult<&mut Self>
Sets the presenter overlay privacy alert setting.
A configuration for the privacy alert that the capture session displays.
Available on macOS 14.0+ — presenterOverlayPrivacyAlertSetting is
annotated API_AVAILABLE(macos(14.0)), not 14.2 as this binding
previously assumed — so it only needs the macos_14_0 feature flag.
Sourcepub fn with_presenter_overlay_privacy_alert_setting(
self,
setting: SCPresenterOverlayAlertSetting,
) -> SCResult<Self>
pub fn with_presenter_overlay_privacy_alert_setting( self, setting: SCPresenterOverlayAlertSetting, ) -> SCResult<Self>
Sets the presenter overlay privacy alert setting (builder pattern, macOS 14.0+)
Sourcepub fn presenter_overlay_privacy_alert_setting(
&self,
) -> SCResult<SCPresenterOverlayAlertSetting>
pub fn presenter_overlay_privacy_alert_setting( &self, ) -> SCResult<SCPresenterOverlayAlertSetting>
Get the presenter overlay privacy alert setting (macOS 14.0+).
Sourcepub fn set_ignores_shadow_display_configuration(
&mut self,
ignores_shadow: bool,
) -> SCResult<&mut Self>
pub fn set_ignores_shadow_display_configuration( &mut self, ignores_shadow: bool, ) -> SCResult<&mut Self>
Sets whether to ignore shadow display configuration.
Available on macOS 14.0+
Requires the macos_14_0 feature flag to be enabled.
Sourcepub fn with_ignores_shadow_display_configuration(
self,
ignores_shadow: bool,
) -> SCResult<Self>
pub fn with_ignores_shadow_display_configuration( self, ignores_shadow: bool, ) -> SCResult<Self>
Sets whether to ignore shadow display configuration (builder pattern)
Sourcepub fn ignores_shadow_display_configuration(&self) -> bool
pub fn ignores_shadow_display_configuration(&self) -> bool
Get whether the shadow display configuration is ignored (macOS 14.0+).
Source§impl SCStreamConfiguration
impl SCStreamConfiguration
Sourcepub fn set_captures_audio(&mut self, captures_audio: bool) -> &mut Self
pub fn set_captures_audio(&mut self, captures_audio: bool) -> &mut Self
Enable or disable audio capture
§Examples
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::default();
config.set_captures_audio(true);
assert!(config.captures_audio());Sourcepub fn with_captures_audio(self, captures_audio: bool) -> Self
pub fn with_captures_audio(self, captures_audio: bool) -> Self
Enable or disable audio capture (builder pattern)
Sourcepub fn captures_audio(&self) -> bool
pub fn captures_audio(&self) -> bool
Check if audio capture is enabled
Sourcepub fn set_sample_rate(&mut self, sample_rate: impl Into<i32>) -> &mut Self
pub fn set_sample_rate(&mut self, sample_rate: impl Into<i32>) -> &mut Self
Set the audio sample rate
Accepts either an AudioSampleRate enum or a raw i32 Hz value.
§Supported Values
ScreenCaptureKit supports: 8000, 16000, 24000, 48000 Hz.
Other values will default to 48000 Hz.
§Examples
use screencapturekit::prelude::*;
use screencapturekit::stream::configuration::audio::AudioSampleRate;
// Using the enum (recommended)
let config = SCStreamConfiguration::new()
.with_sample_rate(AudioSampleRate::Rate48000);
// Using raw value (still works)
let config = SCStreamConfiguration::new()
.with_sample_rate(48000);Sourcepub fn with_sample_rate(self, sample_rate: impl Into<i32>) -> Self
pub fn with_sample_rate(self, sample_rate: impl Into<i32>) -> Self
Set the audio sample rate (builder pattern)
Sourcepub fn sample_rate(&self) -> i32
pub fn sample_rate(&self) -> i32
Get the configured audio sample rate in Hz
Sourcepub fn audio_sample_rate(&self) -> Option<AudioSampleRate>
pub fn audio_sample_rate(&self) -> Option<AudioSampleRate>
Get the configured audio sample rate as an enum
Returns None if the current sample rate is not a supported value.
Sourcepub fn set_channel_count(&mut self, channel_count: impl Into<i32>) -> &mut Self
pub fn set_channel_count(&mut self, channel_count: impl Into<i32>) -> &mut Self
Set the number of audio channels
Accepts either an AudioChannelCount enum or a raw i32 value.
§Supported Values
ScreenCaptureKit supports: 1 (mono), 2 (stereo).
Other values will default to stereo.
§Examples
use screencapturekit::prelude::*;
use screencapturekit::stream::configuration::audio::AudioChannelCount;
// Using the enum (recommended)
let config = SCStreamConfiguration::new()
.with_channel_count(AudioChannelCount::Stereo);
// Using raw value (still works)
let config = SCStreamConfiguration::new()
.with_channel_count(2);Sourcepub fn with_channel_count(self, channel_count: impl Into<i32>) -> Self
pub fn with_channel_count(self, channel_count: impl Into<i32>) -> Self
Set the number of audio channels (builder pattern)
Sourcepub fn channel_count(&self) -> i32
pub fn channel_count(&self) -> i32
Get the configured channel count
Sourcepub fn audio_channel_count(&self) -> Option<AudioChannelCount>
pub fn audio_channel_count(&self) -> Option<AudioChannelCount>
Get the configured channel count as an enum
Returns None if the current channel count is not a supported value.
Sourcepub fn set_captures_microphone(
&mut self,
captures_microphone: bool,
) -> SCResult<&mut Self>
pub fn set_captures_microphone( &mut self, captures_microphone: bool, ) -> SCResult<&mut Self>
Enable microphone capture (macOS 15.0+)
When set to true, the stream will capture audio from the microphone
in addition to system/application audio (if captures_audio is also enabled).
Note: Requires NSMicrophoneUsageDescription in your app’s Info.plist
for microphone access permission.
§Availability
macOS 15.0+. On earlier versions it returns
SCError::FeatureNotAvailable.
§Example
use screencapturekit::prelude::*;
let config = SCStreamConfiguration::new()
.with_captures_audio(true) // System audio
.with_captures_microphone(true) // Microphone audio (macOS 15.0+)
.expect("macOS 15.0 or later")
.with_sample_rate(48000)
.with_channel_count(2);Sourcepub fn with_captures_microphone(
self,
captures_microphone: bool,
) -> SCResult<Self>
pub fn with_captures_microphone( self, captures_microphone: bool, ) -> SCResult<Self>
Enable microphone capture (builder pattern)
Sourcepub fn captures_microphone(&self) -> bool
pub fn captures_microphone(&self) -> bool
Get whether microphone capture is enabled (macOS 15.0+).
Sourcepub fn set_excludes_current_process_audio(
&mut self,
excludes: bool,
) -> &mut Self
pub fn set_excludes_current_process_audio( &mut self, excludes: bool, ) -> &mut Self
Exclude current process audio from capture.
When set to true, the stream will not capture audio from the current
process, preventing feedback loops in recording applications.
§Example
use screencapturekit::prelude::*;
let config = SCStreamConfiguration::new()
.with_captures_audio(true)
.with_excludes_current_process_audio(true); // Prevent feedbackSourcepub fn with_excludes_current_process_audio(self, excludes: bool) -> Self
pub fn with_excludes_current_process_audio(self, excludes: bool) -> Self
Exclude current process audio (builder pattern)
Sourcepub fn excludes_current_process_audio(&self) -> bool
pub fn excludes_current_process_audio(&self) -> bool
Get whether current process audio is excluded from capture.
Sourcepub fn set_microphone_capture_device_id(
&mut self,
device_id: &str,
) -> SCResult<&mut Self>
pub fn set_microphone_capture_device_id( &mut self, device_id: &str, ) -> SCResult<&mut Self>
Set microphone capture device ID (macOS 15.0+).
Specifies which microphone device to capture from.
§Availability
macOS 15.0+.
§Errors
Returns SCError::InvalidConfiguration — leaving the configuration
unchanged — if device_id contains an interior NUL byte, and
SCError::FeatureNotAvailable before macOS 15.0.
§Example
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::new()
.with_captures_microphone(true)
.expect("macOS 15.0 or later");
config
.set_microphone_capture_device_id("AppleHDAEngineInput:1B,0,1,0:1")
.expect("device ID has no NUL byte");Sourcepub fn with_microphone_capture_device_id(
self,
device_id: &str,
) -> SCResult<Self>
pub fn with_microphone_capture_device_id( self, device_id: &str, ) -> SCResult<Self>
Set microphone capture device ID (builder pattern)
Sourcepub fn clear_microphone_capture_device_id(&mut self) -> SCResult<&mut Self>
pub fn clear_microphone_capture_device_id(&mut self) -> SCResult<&mut Self>
Clear microphone capture device ID, reverting to default system microphone
Sourcepub fn microphone_capture_device_id(&self) -> Option<String>
pub fn microphone_capture_device_id(&self) -> Option<String>
Get microphone capture device ID (macOS 15.0+).
Source§impl SCStreamConfiguration
impl SCStreamConfiguration
Sourcepub fn set_shows_cursor(&mut self, shows_cursor: bool) -> &mut Self
pub fn set_shows_cursor(&mut self, shows_cursor: bool) -> &mut Self
Show or hide the cursor in captured frames
§Examples
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::default();
config.set_shows_cursor(true);
assert!(config.shows_cursor());Sourcepub fn with_shows_cursor(self, shows_cursor: bool) -> Self
pub fn with_shows_cursor(self, shows_cursor: bool) -> Self
Show or hide the cursor (builder pattern)
Sourcepub fn shows_cursor(&self) -> bool
pub fn shows_cursor(&self) -> bool
Check if cursor is shown in capture
Sourcepub fn set_shows_mouse_clicks(
&mut self,
shows_mouse_clicks: bool,
) -> SCResult<&mut Self>
pub fn set_shows_mouse_clicks( &mut self, shows_mouse_clicks: bool, ) -> SCResult<&mut Self>
Show mouse click indicators (macOS 15.0+)
When enabled, draws a circle around the cursor when clicked. This helps viewers track mouse activity in recordings.
§Availability
macOS 15.0+. On earlier versions it returns
SCError::FeatureNotAvailable.
§Examples
use screencapturekit::prelude::*;
let config = SCStreamConfiguration::new()
.with_shows_cursor(true)
.with_shows_mouse_clicks(true)
.expect("macOS 15.0 or later");Sourcepub fn with_shows_mouse_clicks(self, shows_mouse_clicks: bool) -> SCResult<Self>
pub fn with_shows_mouse_clicks(self, shows_mouse_clicks: bool) -> SCResult<Self>
Show mouse click indicators (builder pattern)
Sourcepub fn shows_mouse_clicks(&self) -> bool
pub fn shows_mouse_clicks(&self) -> bool
Check if mouse click indicators are shown (macOS 15.0+)
Sourcepub fn set_captures_shadows_only(
&mut self,
captures_shadows_only: bool,
) -> SCResult<&mut Self>
pub fn set_captures_shadows_only( &mut self, captures_shadows_only: bool, ) -> SCResult<&mut Self>
Capture only window shadows (macOS 14.0+)
When set to true, the stream captures only the shadows of windows,
not the actual window content. This is useful for creating transparency
or blur effects in compositing applications.
§Availability
macOS 14.0+. On earlier versions it returns
SCError::FeatureNotAvailable.
§Examples
use screencapturekit::prelude::*;
let config = SCStreamConfiguration::new()
.with_width(1920)
.with_height(1080)
.with_captures_shadows_only(true)
.expect("macOS 14.0 or later");Sourcepub fn with_captures_shadows_only(
self,
captures_shadows_only: bool,
) -> SCResult<Self>
pub fn with_captures_shadows_only( self, captures_shadows_only: bool, ) -> SCResult<Self>
Capture only window shadows (builder pattern)
Sourcepub fn captures_shadows_only(&self) -> bool
pub fn captures_shadows_only(&self) -> bool
Get whether only window shadows are captured (macOS 14.0+).
Sourcepub fn set_ignores_shadows_display(
&mut self,
ignores_shadows: bool,
) -> SCResult<&mut Self>
pub fn set_ignores_shadows_display( &mut self, ignores_shadows: bool, ) -> SCResult<&mut Self>
Ignore shadows for display capture (macOS 14.0+)
When set to true, window shadows are excluded from display capture.
§Availability
macOS 14.0+. On earlier versions it returns
SCError::FeatureNotAvailable.
Sourcepub fn with_ignores_shadows_display(
self,
ignores_shadows: bool,
) -> SCResult<Self>
pub fn with_ignores_shadows_display( self, ignores_shadows: bool, ) -> SCResult<Self>
Ignore shadows for display capture (builder pattern)
Sourcepub fn ignores_shadows_display(&self) -> bool
pub fn ignores_shadows_display(&self) -> bool
Check if shadows are ignored for display capture (macOS 14.0+)
Sourcepub fn set_ignore_global_clip_display(
&mut self,
ignore: bool,
) -> SCResult<&mut Self>
pub fn set_ignore_global_clip_display( &mut self, ignore: bool, ) -> SCResult<&mut Self>
Ignore global clip for display capture (macOS 14.0+)
When set to true, the global clip region is ignored for display capture.
§Availability
macOS 14.0+. On earlier versions it returns
SCError::FeatureNotAvailable.
Sourcepub fn with_ignore_global_clip_display(self, ignore: bool) -> SCResult<Self>
pub fn with_ignore_global_clip_display(self, ignore: bool) -> SCResult<Self>
Ignore global clip for display capture (builder pattern)
Sourcepub fn ignore_global_clip_display(&self) -> bool
pub fn ignore_global_clip_display(&self) -> bool
Check if global clip is ignored for display capture (macOS 14.0+)
Sourcepub fn set_ignore_global_clip_single_window(
&mut self,
ignore: bool,
) -> SCResult<&mut Self>
pub fn set_ignore_global_clip_single_window( &mut self, ignore: bool, ) -> SCResult<&mut Self>
Ignore global clip for single window capture (macOS 14.0+)
When set to true, the global clip region is ignored for single window capture.
§Availability
macOS 14.0+. On earlier versions it returns
SCError::FeatureNotAvailable.
Sourcepub fn with_ignore_global_clip_single_window(
self,
ignore: bool,
) -> SCResult<Self>
pub fn with_ignore_global_clip_single_window( self, ignore: bool, ) -> SCResult<Self>
Ignore global clip for single window capture (builder pattern)
Sourcepub fn ignore_global_clip_single_window(&self) -> bool
pub fn ignore_global_clip_single_window(&self) -> bool
Check if global clip is ignored for single window capture (macOS 14.0+)
Source§impl SCStreamConfiguration
impl SCStreamConfiguration
Sourcepub fn set_queue_depth(&mut self, queue_depth: u32) -> &mut Self
pub fn set_queue_depth(&mut self, queue_depth: u32) -> &mut Self
Set the queue depth for frame buffering.
ScreenCaptureKit documents a valid range of
MIN_QUEUE_DEPTH to MAX_QUEUE_DEPTH (3–8). Values outside that
range are clamped rather than forwarded: SCStream rejects an
out-of-range depth when capture starts, and it does so with a generic
SCStreamErrorFailedToStart, which is far harder to diagnose than a
silently clamped buffer count. Read the value back with
queue_depth to see what was applied.
Larger depths absorb more downstream jitter at the cost of latency and memory (each slot holds a full frame); smaller depths minimise latency but drop frames sooner when the consumer stalls.
Sourcepub fn with_queue_depth(self, queue_depth: u32) -> Self
pub fn with_queue_depth(self, queue_depth: u32) -> Self
Set the queue depth (builder pattern)
See set_queue_depth for the clamping rules.
Sourcepub fn queue_depth(&self) -> u32
pub fn queue_depth(&self) -> u32
Get the configured queue depth.
Sourcepub fn set_minimum_frame_interval(&mut self, cm_time: &CMTime) -> &mut Self
pub fn set_minimum_frame_interval(&mut self, cm_time: &CMTime) -> &mut Self
Set the minimum frame interval
Sourcepub fn with_minimum_frame_interval(self, cm_time: &CMTime) -> Self
pub fn with_minimum_frame_interval(self, cm_time: &CMTime) -> Self
Set the minimum frame interval (builder pattern)
pub fn minimum_frame_interval(&self) -> CMTime
Sourcepub fn fps(&self) -> u32
pub fn fps(&self) -> u32
Get the target frame rate in frames per second
Converts the minimum frame interval (CMTime) to FPS.
Returns 0 if the frame interval is zero or invalid (i.e. the stream is
uncapped — see set_fps).
Sourcepub fn set_fps(&mut self, fps: u32) -> &mut Self
pub fn set_fps(&mut self, fps: u32) -> &mut Self
Set the target frame rate in frames per second
This is a convenience method that creates the appropriate CMTime for the given FPS.
For example, 60 FPS creates a frame interval of 1/60 second.
§Arguments
fps- Target frames per second (e.g., 30, 60, 120)
Passing 0 sets the interval to kCMTimeZero (0/1), which is
ScreenCaptureKit’s “no minimum interval — deliver frames as fast as
the source produces them” value. The naive 1/0 this used to build was
a zero-timescale CMTime: still flagged valid, but degenerate, so
CMTimeGetSeconds divides by zero and the stream’s frame pacing is
undefined.
§Examples
use screencapturekit::stream::configuration::SCStreamConfiguration;
let config = SCStreamConfiguration::new()
.with_fps(60);Sourcepub fn with_fps(self, fps: u32) -> Self
pub fn with_fps(self, fps: u32) -> Self
Set the target frame rate (builder pattern)
See set_fps for details.
Sourcepub fn set_capture_resolution_type(
&mut self,
resolution_type: SCCaptureResolutionType,
) -> SCResult<&mut Self>
pub fn set_capture_resolution_type( &mut self, resolution_type: SCCaptureResolutionType, ) -> SCResult<&mut Self>
Set the capture resolution type (macOS 14.0+)
Controls how the capture resolution is determined.
§Arguments
resolution_type- The resolution strategy to use
§Examples
use screencapturekit::stream::configuration::{SCStreamConfiguration, SCCaptureResolutionType};
let config = SCStreamConfiguration::new()
.with_capture_resolution_type(SCCaptureResolutionType::Best)
.expect("macOS 14.0 or later");Sourcepub fn with_capture_resolution_type(
self,
resolution_type: SCCaptureResolutionType,
) -> SCResult<Self>
pub fn with_capture_resolution_type( self, resolution_type: SCCaptureResolutionType, ) -> SCResult<Self>
Set the capture resolution type (builder pattern, macOS 14.0+)
Sourcepub fn capture_resolution_type(&self) -> SCResult<SCCaptureResolutionType>
pub fn capture_resolution_type(&self) -> SCResult<SCCaptureResolutionType>
Get the capture resolution type (macOS 14.0+)
Source§impl SCStreamConfiguration
impl SCStreamConfiguration
Sourcepub fn set_pixel_format(&mut self, pixel_format: PixelFormat) -> &mut Self
pub fn set_pixel_format(&mut self, pixel_format: PixelFormat) -> &mut Self
Set the pixel format for captured frames
Streams created via Self::new / Self::default are pinned to
PixelFormat::BGRA at construction time, so calling this method is
only required when you want a non-BGRA format (e.g. YUV 420v for
video encoding, or l10r for HDR). Apple’s runtime default for
SCStreamConfiguration() varies by macOS release — see
PixelFormat::BGRA for context.
§Examples
use screencapturekit::stream::configuration::{SCStreamConfiguration, PixelFormat};
let mut config = SCStreamConfiguration::default();
config.set_pixel_format(PixelFormat::BGRA);Sourcepub fn with_pixel_format(self, pixel_format: PixelFormat) -> Self
pub fn with_pixel_format(self, pixel_format: PixelFormat) -> Self
Set the pixel format (builder pattern)
Sourcepub fn pixel_format(&self) -> PixelFormat
pub fn pixel_format(&self) -> PixelFormat
Get the current pixel format
Sourcepub fn set_background_color_rgba(
&mut self,
r: f32,
g: f32,
b: f32,
a: f32,
) -> &mut Self
pub fn set_background_color_rgba( &mut self, r: f32, g: f32, b: f32, a: f32, ) -> &mut Self
Set the background color for captured content with an explicit alpha value.
Available on macOS 13.0+
Sourcepub fn set_background_color(&mut self, r: f32, g: f32, b: f32) -> &mut Self
pub fn set_background_color(&mut self, r: f32, g: f32, b: f32) -> &mut Self
Set the background color for captured content.
This convenience overload uses an opaque alpha channel (1.0).
Sourcepub fn with_background_color_rgba(self, r: f32, g: f32, b: f32, a: f32) -> Self
pub fn with_background_color_rgba(self, r: f32, g: f32, b: f32, a: f32) -> Self
Set the background color with an explicit alpha value (builder pattern).
Sourcepub fn with_background_color(self, r: f32, g: f32, b: f32) -> Self
pub fn with_background_color(self, r: f32, g: f32, b: f32) -> Self
Set the background color (builder pattern).
This convenience overload uses an opaque alpha channel (1.0).
Sourcepub fn background_color(&self) -> Option<(f32, f32, f32, f32)>
pub fn background_color(&self) -> Option<(f32, f32, f32, f32)>
Get the current background color, if it was set through this wrapper.
Sourcepub fn set_color_space_name(
&mut self,
name: &str,
) -> Result<&mut Self, InteriorNulError>
pub fn set_color_space_name( &mut self, name: &str, ) -> Result<&mut Self, InteriorNulError>
Set the color space name for captured content.
Available on macOS 13.0+. Use the color_space constants for the
values ScreenCaptureKit recognises.
§Errors
Returns InteriorNulError — leaving the configuration unchanged — if
name contains an interior NUL byte.
Sourcepub fn with_color_space_name(self, name: &str) -> Result<Self, InteriorNulError>
pub fn with_color_space_name(self, name: &str) -> Result<Self, InteriorNulError>
Set the color space name (builder pattern).
Sourcepub fn color_space_name(&self) -> Option<String>
pub fn color_space_name(&self) -> Option<String>
Get the color space name for captured content.
Sourcepub fn set_color_matrix(
&mut self,
matrix: &str,
) -> Result<&mut Self, InteriorNulError>
pub fn set_color_matrix( &mut self, matrix: &str, ) -> Result<&mut Self, InteriorNulError>
Set the YCbCr color matrix for captured content.
Available on macOS 13.0+. matrix must be one of the color_matrix
constants — despite the free-form &str signature the property is a
closed set of kCGDisplayStreamYCbCrMatrix_* identifiers, and any
other string is ignored by the system without an error. The setting
only affects YCbCr pixel formats and is inert for BGRA capture.
§Errors
Returns InteriorNulError — leaving the configuration unchanged — if
matrix contains an interior NUL byte.
Sourcepub fn color_matrix(&self) -> Option<String>
pub fn color_matrix(&self) -> Option<String>
Get the color matrix for captured content.
Returns the color matrix as a string, or None if not set.
Sourcepub fn with_color_matrix(self, matrix: &str) -> Result<Self, InteriorNulError>
pub fn with_color_matrix(self, matrix: &str) -> Result<Self, InteriorNulError>
Set the color matrix (builder pattern)
Source§impl SCStreamConfiguration
impl SCStreamConfiguration
Sourcepub fn set_width(&mut self, width: u32) -> &mut Self
pub fn set_width(&mut self, width: u32) -> &mut Self
Set the output width in pixels
The width determines the width of captured frames.
§Examples
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::default();
config.set_width(1920);
assert_eq!(config.width(), 1920);Sourcepub fn with_width(self, width: u32) -> Self
pub fn with_width(self, width: u32) -> Self
Set the output width in pixels (builder pattern)
§Examples
use screencapturekit::prelude::*;
let config = SCStreamConfiguration::new()
.with_width(1920)
.with_height(1080);Sourcepub fn width(&self) -> u32
pub fn width(&self) -> u32
Get the configured output width in pixels
§Examples
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::default();
config.set_width(1920);
assert_eq!(config.width(), 1920);Sourcepub fn set_height(&mut self, height: u32) -> &mut Self
pub fn set_height(&mut self, height: u32) -> &mut Self
Set the output height in pixels
The height determines the height of captured frames.
§Examples
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::default();
config.set_height(1080);
assert_eq!(config.height(), 1080);Sourcepub fn with_height(self, height: u32) -> Self
pub fn with_height(self, height: u32) -> Self
Set the output height in pixels (builder pattern)
§Examples
use screencapturekit::prelude::*;
let config = SCStreamConfiguration::new()
.with_width(1920)
.with_height(1080);Sourcepub fn height(&self) -> u32
pub fn height(&self) -> u32
Get the configured output height in pixels
§Examples
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::default();
config.set_height(1080);
assert_eq!(config.height(), 1080);Sourcepub fn set_scales_to_fit(&mut self, scales_to_fit: bool) -> &mut Self
pub fn set_scales_to_fit(&mut self, scales_to_fit: bool) -> &mut Self
Enable or disable scaling to fit the output dimensions
When enabled, the source content will be scaled to fit within the configured width and height, potentially changing aspect ratio.
§Examples
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::default();
config.set_scales_to_fit(true);
assert!(config.scales_to_fit());Sourcepub fn with_scales_to_fit(self, scales_to_fit: bool) -> Self
pub fn with_scales_to_fit(self, scales_to_fit: bool) -> Self
Enable or disable scaling to fit (builder pattern)
Sourcepub fn scales_to_fit(&self) -> bool
pub fn scales_to_fit(&self) -> bool
Check if scaling to fit is enabled
Sourcepub fn set_source_rect(&mut self, source_rect: CGRect) -> &mut Self
pub fn set_source_rect(&mut self, source_rect: CGRect) -> &mut Self
Set the source rectangle to capture
Defines which portion of the source content to capture. Coordinates are relative to the source content’s coordinate system.
§Examples
use screencapturekit::prelude::*;
use screencapturekit::cg::CGRect;
// Capture only top-left quarter of screen
let rect = CGRect::new(0.0, 0.0, 960.0, 540.0);
let mut config = SCStreamConfiguration::default();
config.set_source_rect(rect);Sourcepub fn with_source_rect(self, source_rect: CGRect) -> Self
pub fn with_source_rect(self, source_rect: CGRect) -> Self
Set the source rectangle (builder pattern)
Sourcepub fn source_rect(&self) -> CGRect
pub fn source_rect(&self) -> CGRect
Get the configured source rectangle
Sourcepub fn set_destination_rect(&mut self, destination_rect: CGRect) -> &mut Self
pub fn set_destination_rect(&mut self, destination_rect: CGRect) -> &mut Self
Set the destination rectangle for captured content
Defines where the captured content will be placed in the output frame. Useful for picture-in-picture or multi-source compositions.
§Examples
use screencapturekit::prelude::*;
use screencapturekit::cg::CGRect;
// Place captured content in top-left corner
let rect = CGRect::new(0.0, 0.0, 640.0, 480.0);
let mut config = SCStreamConfiguration::default();
config.set_destination_rect(rect);Sourcepub fn with_destination_rect(self, destination_rect: CGRect) -> Self
pub fn with_destination_rect(self, destination_rect: CGRect) -> Self
Set the destination rectangle (builder pattern)
Sourcepub fn destination_rect(&self) -> CGRect
pub fn destination_rect(&self) -> CGRect
Get the configured destination rectangle
Sourcepub fn set_preserves_aspect_ratio(
&mut self,
preserves_aspect_ratio: bool,
) -> SCResult<&mut Self>
pub fn set_preserves_aspect_ratio( &mut self, preserves_aspect_ratio: bool, ) -> SCResult<&mut Self>
Preserve aspect ratio when scaling
When enabled, the content will be scaled while maintaining its original aspect ratio, potentially adding letterboxing or pillarboxing.
Note: This property requires macOS 14.0+. On older versions, the setter
returns SCError::FeatureNotAvailable and the getter returns false.
§Examples
use screencapturekit::prelude::*;
let mut config = SCStreamConfiguration::default();
config
.set_preserves_aspect_ratio(true)
.expect("macOS 14.0 or later");
// Returns true on macOS 14.0+, false on older versions
let _ = config.preserves_aspect_ratio();Sourcepub fn with_preserves_aspect_ratio(
self,
preserves_aspect_ratio: bool,
) -> SCResult<Self>
pub fn with_preserves_aspect_ratio( self, preserves_aspect_ratio: bool, ) -> SCResult<Self>
Preserve aspect ratio when scaling (builder pattern)
Sourcepub fn preserves_aspect_ratio(&self) -> bool
pub fn preserves_aspect_ratio(&self) -> bool
Check if aspect ratio preservation is enabled
Source§impl SCStreamConfiguration
impl SCStreamConfiguration
Sourcepub fn set_stream_name(&mut self, name: Option<&str>) -> SCResult<&mut Self>
pub fn set_stream_name(&mut self, name: Option<&str>) -> SCResult<&mut Self>
Set the stream name for identification
Assigns a name to the stream that can be used for debugging and identification purposes. The name appears in system logs and debugging tools.
Available on macOS 14.0+.
§Errors
Returns SCError::InvalidConfiguration — leaving the configuration
unchanged — if name contains an interior NUL byte, and
SCError::FeatureNotAvailable before macOS 14.0.
§Examples
use screencapturekit::prelude::*;
let config = SCStreamConfiguration::new()
.with_stream_name(Some("MyApp-MainCapture"))
.expect("stream name has no NUL byte");Sourcepub fn with_stream_name(self, name: Option<&str>) -> SCResult<Self>
pub fn with_stream_name(self, name: Option<&str>) -> SCResult<Self>
Set the stream name (builder pattern)
Sourcepub fn stream_name(&self) -> Option<String>
pub fn stream_name(&self) -> Option<String>
Get the configured stream name
Returns the name assigned to this stream, if any.
Sourcepub fn set_capture_dynamic_range(
&mut self,
dynamic_range: SCCaptureDynamicRange,
) -> SCResult<&mut Self>
pub fn set_capture_dynamic_range( &mut self, dynamic_range: SCCaptureDynamicRange, ) -> SCResult<&mut Self>
Set the dynamic range mode for capture (macOS 15.0+)
Controls whether to capture in SDR or HDR mode and how HDR content should be tone-mapped for display.
§Availability
macOS 15.0+. Requires the macos_15_0 feature flag to be enabled.
§Modes
SDR: Standard dynamic range capture (default)HDRLocalDisplay: HDR with tone mapping optimized for the local displayHDRCanonicalDisplay: HDR with canonical tone mapping for portability
§Examples
use screencapturekit::prelude::*;
use screencapturekit::stream::configuration::stream_properties::SCCaptureDynamicRange;
let config = SCStreamConfiguration::new()
.with_width(1920)
.with_height(1080)
.with_capture_dynamic_range(SCCaptureDynamicRange::HDRLocalDisplay)
.expect("macOS 15.0 or later");Sourcepub fn with_capture_dynamic_range(
self,
dynamic_range: SCCaptureDynamicRange,
) -> SCResult<Self>
pub fn with_capture_dynamic_range( self, dynamic_range: SCCaptureDynamicRange, ) -> SCResult<Self>
Set the dynamic range mode (builder pattern)
Sourcepub fn capture_dynamic_range(&self) -> SCResult<SCCaptureDynamicRange>
pub fn capture_dynamic_range(&self) -> SCResult<SCCaptureDynamicRange>
Get the configured dynamic range mode (macOS 15.0+)
Returns the current HDR capture mode setting.
Requires the macos_15_0 feature flag to be enabled.
Source§impl SCStreamConfiguration
impl SCStreamConfiguration
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new stream configuration with default values
This is equivalent to SCStreamConfiguration::default().
§Examples
use screencapturekit::prelude::*;
let config = SCStreamConfiguration::new()
.with_width(1920)
.with_height(1080);Sourcepub fn from_preset(preset: SCStreamConfigurationPreset) -> SCResult<Self>
pub fn from_preset(preset: SCStreamConfigurationPreset) -> SCResult<Self>
Create a configuration from a preset (macOS 15.0+)
Presets provide optimized default values for specific use cases, particularly for HDR capture.
§Examples
use screencapturekit::stream::configuration::{SCStreamConfiguration, SCStreamConfigurationPreset};
let config = SCStreamConfiguration::from_preset(SCStreamConfigurationPreset::CaptureHDRStreamLocalDisplay)
.expect("macOS 15.0 or later");