screencapturekit/lib.rs
1//! # ScreenCaptureKit-rs
2//!
3//! Rust bindings for macOS `ScreenCaptureKit` framework.
4//!
5//! This crate provides safe, idiomatic Rust bindings for capturing screen content,
6//! windows, and applications on macOS 12.3+.
7//!
8//! ## Features
9//!
10//! - Screen and window capture
11//! - Audio capture
12//! - Real-time frame processing
13//! - Configurable capture settings
14//! - Zero external dependencies (uses custom Swift bridge)
15//!
16//! ## Quick Start
17//!
18//! ```rust,no_run
19//! use screencapturekit::prelude::*;
20//!
21//! // Get shareable content
22//! let content = SCShareableContent::get()?;
23//! let display = &content.displays()[0];
24//!
25//! // Create filter and configuration
26//! let filter = SCContentFilter::builder()
27//! .display(display)
28//! .exclude_windows(&[])
29//! .build();
30//! let mut config = SCStreamConfiguration::default();
31//! config.set_width(1920);
32//! config.set_height(1080);
33//!
34//! // Create and start stream
35//! let mut stream = SCStream::new(&filter, &config);
36//! stream.start_capture()?;
37//! # Ok::<(), screencapturekit::error::SCError>(())
38//! ```
39//!
40//! ## Module Organization
41//!
42//! - [`cm`] - Core Media types (`CMSampleBuffer`, `CMTime`, etc.)
43//! - [`cg`] - Core Graphics types (`CGRect`, `CGSize`, etc.)
44//! - [`stream`] - Stream configuration and management
45//! - [`shareable_content`] - Display and window information
46//! - [`output`] - Frame buffer and pixel access
47//! - [`error`] - Error types
48//! - [`utils`] - Utility functions
49
50#![warn(clippy::all, clippy::pedantic, clippy::nursery, clippy::cargo)]
51#![allow(clippy::must_use_candidate)]
52#![allow(clippy::missing_const_for_fn)]
53
54pub mod cg;
55pub mod cm;
56#[cfg(feature = "macos_14_0")]
57pub mod content_sharing_picker;
58pub mod dispatch_queue;
59pub mod error;
60pub mod ffi;
61pub mod output;
62#[cfg(feature = "macos_15_0")]
63pub mod recording_output;
64pub mod screenshot_manager;
65pub mod shareable_content;
66pub mod stream;
67pub mod utils;
68
69#[cfg(feature = "async")]
70pub mod async_api;
71
72// Re-export commonly used types
73pub use cm::{
74 codec_types, media_types, AudioBuffer, AudioBufferList, CMFormatDescription, CMSampleBuffer,
75 CMSampleTimingInfo, CMTime, CVPixelBuffer, CVPixelBufferPool, IOSurface, SCFrameStatus,
76};
77pub use utils::four_char_code::FourCharCode;
78
79/// Prelude module for convenient imports
80///
81/// Import everything you need with:
82/// ```rust
83/// use screencapturekit::prelude::*;
84/// ```
85pub mod prelude {
86 pub use crate::cm::{CMSampleBuffer, CMTime};
87 pub use crate::dispatch_queue::{DispatchQoS, DispatchQueue};
88 pub use crate::error::{SCError, SCResult};
89 pub use crate::shareable_content::{
90 SCDisplay, SCRunningApplication, SCShareableContent, SCWindow,
91 };
92 pub use crate::stream::{
93 configuration::{PixelFormat, SCStreamConfiguration},
94 content_filter::SCContentFilter,
95 delegate_trait::SCStreamDelegateTrait,
96 output_trait::SCStreamOutputTrait,
97 output_type::SCStreamOutputType,
98 sc_stream::SCStream,
99 ErrorHandler,
100 };
101}