docs.rs failed to build zero-latency-video-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
zero-latency-video
A high-performance, ultra-low-latency video streaming library for macOS, written in Rust.
Designed for real-time interactive streaming use cases (such as Remote Desktop, Cloud Gaming, and VR/AR streaming to Apple Vision Pro or Meta Quest) targeting a glass-to-glass latency of < 20ms on local networks.
Features
- Zero-Copy Capture: Leverages macOS native ScreenCaptureKit to capture the screen directly into shared hardware buffers (
IOSurface/CVPixelBuffer), avoiding costly CPU-RAM copies. - Hardware Acceleration: Uses macOS VideoToolbox for hardware-accelerated H.264 video compression.
- Ultra-Low Latency Rate Control: Configures
EnableLowLatencyRateControl(macOS 12.3+) and disables frame reordering (no B-frames) for zero-buffer real-time encoding. - Lock-free Pipeline: Utilizes
flumelock-free bounded channels to bridge synchronous C encoding callbacks and asynchronous Tokio network tasks seamlessly. - Flexible Backends ("Swap-Ready"): Includes standard WebRTC transport (multi-client isolation, automatic keyframe requests, client state detection) and a raw vector-I/O UDP transport.
Prerequisites
- Operating System: macOS 12.3 or higher.
- Compiler: Xcode Command Line Tools (Clang & Swift compiler) and Rust 1.70+.
- Permissions: Screen Recording permission must be granted to the executable or terminal running the project on macOS.
Installation
Add this to your Cargo.toml dependencies:
[]
= "0.1.0"
= { = "1.0", = ["derive"] }
Quick Start
Here is a basic example setting up a ScreenCaptureKit capture stream encoded with VideoToolbox and broadcasted over WebRTC:
use MacVideoEncoder;
use SCScreenSource;
use WebRTCStreamer;
use ;
async
Swapping Backends
The library is designed to make swapping transport layers extremely simple. To swap from WebRTC to raw UDP streaming (ideal for custom VR clients):
- let mut streamer = WebRTCStreamer::new();
- streamer.connect(cfg).await?;
+ use zero_latency_video::raw_udp_streamer::RawUdpStreamer;
+ let mut streamer = RawUdpStreamer::new();
+ let udp_cfg = StreamConfig {
+ target_addr: "192.168.1.50:5000".to_string(), // Client IP and port
+ ..cfg
+ };
+ streamer.connect(udp_cfg).await?;
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE)
- MIT license (LICENSE-MIT)
at your option.