pub struct AsyncSCStream { /* private fields */ }Expand description
Async wrapper for SCStream with integrated frame iteration
Provides async methods for stream lifecycle and frame iteration. Executor-agnostic - works with any async runtime.
§Examples
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::builder().display(display).exclude_windows(&[]).build();
let mut config = SCStreamConfiguration::default();
config.set_width(1920);
config.set_height(1080);
let stream = AsyncSCStream::new(&filter, &config, 30, SCStreamOutputType::Screen);
stream.start_capture()?;
// Process frames asynchronously
while let Some(frame) = stream.next().await {
println!("Got frame!");
}Implementations§
Source§impl AsyncSCStream
impl AsyncSCStream
Sourcepub fn new(
filter: &SCContentFilter,
config: &SCStreamConfiguration,
buffer_capacity: usize,
output_type: SCStreamOutputType,
) -> Self
pub fn new( filter: &SCContentFilter, config: &SCStreamConfiguration, buffer_capacity: usize, output_type: SCStreamOutputType, ) -> Self
Create a new async stream
§Arguments
filter- Content filter specifying what to captureconfig- Stream configurationbuffer_capacity- Max frames to buffer (oldest dropped when full)output_type- Type of output (Screen, Audio, Microphone)
Sourcepub fn next(&self) -> NextSample<'_> ⓘ
pub fn next(&self) -> NextSample<'_> ⓘ
Get the next sample buffer asynchronously
Returns None when the stream is closed.
Sourcepub fn try_next(&self) -> Option<CMSampleBuffer>
pub fn try_next(&self) -> Option<CMSampleBuffer>
Try to get a sample without waiting
Sourcepub fn buffered_count(&self) -> usize
pub fn buffered_count(&self) -> usize
Get the number of buffered samples
Sourcepub fn clear_buffer(&self)
pub fn clear_buffer(&self)
Clear all buffered samples
Sourcepub fn start_capture(&self) -> Result<(), SCError>
pub fn start_capture(&self) -> Result<(), SCError>
Start capture (synchronous - returns immediately)
§Errors
Returns an error if capture fails to start.
Sourcepub fn stop_capture(&self) -> Result<(), SCError>
pub fn stop_capture(&self) -> Result<(), SCError>
Sourcepub fn update_configuration(
&self,
config: &SCStreamConfiguration,
) -> Result<(), SCError>
pub fn update_configuration( &self, config: &SCStreamConfiguration, ) -> Result<(), SCError>
Sourcepub fn update_content_filter(
&self,
filter: &SCContentFilter,
) -> Result<(), SCError>
pub fn update_content_filter( &self, filter: &SCContentFilter, ) -> Result<(), SCError>
Auto Trait Implementations§
impl Freeze for AsyncSCStream
impl RefUnwindSafe for AsyncSCStream
impl Send for AsyncSCStream
impl Sync for AsyncSCStream
impl Unpin for AsyncSCStream
impl UnwindSafe for AsyncSCStream
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more