Module cm

Module cm 

Source
Expand description

Core Media types and wrappers

This module provides Rust wrappers for Core Media framework types used in screen capture operations.

§Main Types

  • CMSampleBuffer - Container for media samples (audio/video frames)
  • CMTime - Time value with rational timescale for precise timing
  • IOSurface - Hardware-accelerated surface for zero-copy GPU access
  • CMBlockBuffer - Block of contiguous data (audio/compressed video)
  • AudioBuffer - Audio data buffer with sample data
  • AudioBufferList - Collection of audio buffers for multi-channel audio
  • SCFrameStatus - Status of a captured frame (complete, idle, dropped, etc.)

§Example

use screencapturekit::cm::{CMSampleBuffer, CMTime, SCFrameStatus};

fn process_frame(sample: CMSampleBuffer) {
    // Check frame status
    if sample.frame_status() == Some(SCFrameStatus::Complete) {
        // Get timestamp
        let pts = sample.presentation_timestamp();
        println!("Frame at {:?}", pts);

        // Access pixel buffer for CPU processing
        if let Some(pixel_buffer) = sample.image_buffer() {
            // Access IOSurface for GPU processing
            if let Some(surface) = pixel_buffer.io_surface() {
                println!("Surface: {}x{}", surface.width(), surface.height());
            }
        }
    }
}

Re-exports§

pub use iosurface::IOSurface;
pub use iosurface::IOSurfaceLockGuard;
pub use iosurface::IOSurfaceLockOptions;
pub use iosurface::PlaneProperties;

Modules§

codec_types
Common codec type constants
ffi
Raw FFI bindings for Core Media types.
iosurface
IOSurface - Hardware-accelerated surface
media_types
Common media type constants

Structs§

AudioBuffer
Raw audio buffer containing sample data
AudioBufferList
List of audio buffers from an audio sample
AudioBufferListIter
Iterator over audio buffers in an AudioBufferList
AudioBufferListRaw
List of audio buffers from an audio sample
AudioBufferRef
Reference to an audio buffer with convenience methods
CMBlockBuffer
Block buffer containing contiguous media data
CMClock
CMClock wrapper for synchronization clock
CMFormatDescription
CMSampleBuffer
Opaque handle to CMSampleBuffer
CMSampleTimingInfo
Sample timing information
CMTime
CMTime representation matching Core Media’s CMTime

Enums§

SCFrameStatus
Frame status for captured screen content