| Crates.io | styx-capture |
| lib.rs | styx-capture |
| version | 0.1.0 |
| created_at | 2026-01-19 11:58:49.164136+00 |
| updated_at | 2026-01-19 11:58:49.164136+00 |
| description | Capture descriptors and zero-copy capture trait for Styx. |
| homepage | https://github.com/sozo/Styx |
| repository | https://github.com/sozo/Styx |
| max_upload_size | |
| id | 2054420 |
| size | 22,420 |
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.
[dependencies]
styx-capture = "0.1.0"
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).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_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"));
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.