styx-capture

Crates.iostyx-capture
lib.rsstyx-capture
version0.1.0
created_at2026-01-19 11:58:49.164136+00
updated_at2026-01-19 11:58:49.164136+00
descriptionCapture descriptors and zero-copy capture trait for Styx.
homepagehttps://github.com/sozo/Styx
repositoryhttps://github.com/sozo/Styx
max_upload_size
id2054420
size22,420
Mathias (SoZ0)

documentation

https://docs.rs/styx-capture

README

styx-capture

Capture descriptors/config validation and the CaptureSource trait for zero-copy frame producers. Includes helpers for building frames from buffer pools and a simple virtual backend for tests.

Documentation

Install

[dependencies]
styx-capture = "0.1.0"

Key types

  • Mode / ModeId: advertised capture modes (FourCc + resolution + intervals).
  • CaptureDescriptor: modes + control metadata for a device/source.
  • CaptureConfig: user-selected mode/interval/controls with validation.
  • CaptureSource: trait yielding FrameLease frames (sync-first).

Building descriptors

modes_from_formats converts a list of MediaFormat values into modes, or build them manually:

use styx_capture::prelude::*;

let mode = Mode {
    id: ModeId(0),
    format: MediaFormat::new(FourCc::new(*b"RG24"), Resolution::new(640, 480).unwrap(), ColorSpace::Srgb),
    intervals: smallvec::smallvec![],
    interval_stepwise: None,
};
let descriptor = CaptureDescriptor { modes: vec![mode], controls: Vec::new() };
let cfg = CaptureConfig { mode: ModeId(0), interval: None, controls: vec![] };
cfg.validate(&descriptor).unwrap();

Virtual capture

virtual_backend::VirtualCapture emits patterned frames from a pool:

use styx_capture::prelude::*;

let pool = BufferPool::with_limits(4, 1 << 20, 8);
let mode = modes_from_formats([MediaFormat::new(FourCc::new(*b"RG24"), Resolution::new(320, 180).unwrap(), ColorSpace::Srgb)])[0].clone();
let cap = virtual_backend::VirtualCapture::new(mode.clone(), pool, 3);
let frame = cap.next_frame().unwrap();
assert_eq!(frame.meta().format.code, FourCc::new(*b"RG24"));

Frame helpers

build_frame_from_pool constructs a single-plane frame with the correct layout/stride for a given FourCc/resolution, returning a pooled FrameLease ready for downstream codecs or pipelines.

Commit count: 0

cargo fmt