Safe Rust bindings for the librist library, implementing the RIST (Reliable Internet Stream Transport) protocol for professional video streaming.
- Safe abstractions over the librist C API
- Builder pattern for easy configuration
- Callback support with Rust closures
- Async support (optional, via
async-tokiofeature) - Thread-safe sender and receiver contexts
- Cross-platform - Linux, macOS, Windows
Add to your Cargo.toml:
[dependencies]
librist = "0.1"- Rust 1.85+
- Meson and Ninja (for building librist from source)
- C compiler (gcc, clang, or MSVC)
On Ubuntu/Debian:
sudo apt-get install meson ninja-build pkg-configOn macOS:
brew install meson ninja pkg-configuse librist::{RistSender, Profile};
fn main() -> librist::Result<()> {
// Create a sender
let sender = RistSender::builder()
.profile(Profile::Main)
.build()?;
// Add destination peer
sender.add_peer("rist://192.168.1.100:5000")?;
// Start the sender
sender.start()?;
// Send data
let data = vec![0u8; 1316]; // MPEG-TS packet
sender.send(&data)?;
Ok(())
}use librist::{RistReceiver, Profile};
fn main() -> librist::Result<()> {
// Create a receiver
let receiver = RistReceiver::builder()
.profile(Profile::Main)
.build()?;
// Listen on port 5000 (note the @ prefix)
receiver.add_peer("rist://@:5000")?;
// Start the receiver
receiver.start()?;
// Receive data
loop {
match receiver.recv(1000) {
Ok(block) => {
println!("Received {} bytes", block.payload().len());
}
Err(librist::Error::Timeout) => continue,
Err(e) => return Err(e),
}
}
}RIST URLs follow the format:
rist://[user:pass@]host:port[?options]
For listener mode (receiver), prefix with @:
rist://@:5000
| Option | Description |
|---|---|
bandwidth=<kbps> |
Maximum recovery bandwidth |
buffer=<ms> |
Buffer size in milliseconds |
secret=<key> |
Encryption secret |
aes-type=<128|256> |
AES key size |
weight=<n> |
Bonding weight (0 = duplicate) |
cname=<name> |
RTCP canonical name |
async-tokio- Async support via Tokio runtimeserde- Serialization support for config/statstracing- Integration with the tracing ecosystem
bundled(default) - Build librist from sourcesystem- Use system-installed libriststatic- Static linkingmbedtls- Enable mbedTLS encryption
Run the example sender:
cargo run --example sender -- rist://127.0.0.1:5000Run the example receiver:
cargo run --example receiver -- rist://@:5000The library is split into two crates:
- librist-sys - Raw FFI bindings generated with bindgen
- librist - Safe, idiomatic Rust wrapper
See the plans/ directory for detailed design documents.
MIT License - see LICENSE for details.
Contributions are welcome! Please see the design documents in plans/ for architecture details.
- librist - The underlying C library
- Video Services Forum - RIST protocol specification