Expand description
Async API for ScreenCaptureKit
This module provides async versions of operations when the async feature is enabled.
The async API is executor-agnostic and works with any async runtime (Tokio, async-std, smol, etc.).
§Available Types
| Type | Description |
|---|---|
AsyncSCShareableContent | Async content queries |
AsyncSCStream | Async stream with frame iteration |
AsyncSCScreenshotManager | Async screenshot capture (macOS 14.0+) |
AsyncSCContentSharingPicker | Async content picker UI (macOS 14.0+) |
AsyncSCRecordingOutput | Async recording with events (macOS 15.0+) |
§Runtime Agnostic Design
This async API uses only std types and works with any async runtime:
- Uses callback-based Swift FFI for true async operations
- Uses
std::sync::{Arc, Mutex}for synchronization - Uses
std::task::{Poll, Waker}for async primitives - Uses
std::future::Futuretrait
§Examples
§Basic Async Content Query
use screencapturekit::async_api::AsyncSCShareableContent;
let content = AsyncSCShareableContent::get().await?;
println!("Found {} displays", content.displays().len());
println!("Found {} windows", content.windows().len());§Async Stream with Frame Iteration
use screencapturekit::async_api::{AsyncSCShareableContent, AsyncSCStream};
use screencapturekit::stream::configuration::SCStreamConfiguration;
use screencapturekit::stream::content_filter::SCContentFilter;
use screencapturekit::stream::output_type::SCStreamOutputType;
let content = AsyncSCShareableContent::get().await?;
let display = &content.displays()[0];
let filter = SCContentFilter::create().with_display(display).with_excluding_windows(&[]).build();
let config = SCStreamConfiguration::new().with_width(1920).with_height(1080);
let stream = AsyncSCStream::new(&filter, &config, 30, SCStreamOutputType::Screen);
stream.start_capture()?;
// Process frames asynchronously
for _ in 0..100 {
if let Some(frame) = stream.next().await {
println!("Got frame at {:?}", frame.presentation_timestamp());
}
}
stream.stop_capture()?;Structs§
- Async
Picker Filter Future - Future for async picker returning filter only
- Async
Picker Future - Future for async picker with full result
- AsyncSC
Content Sharing Picker - Async wrapper for
SCContentSharingPicker(macOS 14.0+) - AsyncSC
Recording Output - Async wrapper for
SCRecordingOutputwith event stream (macOS 15.0+) - AsyncSC
Screenshot Manager - Async wrapper for
SCScreenshotManager - AsyncSC
Shareable Content - Async wrapper for
SCShareableContent - AsyncSC
Shareable Content Options - Options for async shareable content retrieval
- AsyncSC
Stream - Async wrapper for
SCStreamwith integrated frame iteration - Async
Screenshot Future - Future for async screenshot capture
- Async
Shareable Content Future - Future for async shareable content retrieval
- Next
Recording Event - Future for getting the next recording event
- Next
Sample - Future for getting the next sample buffer
Enums§
- Recording
Event - Recording lifecycle event