moq-lite
A Rust implementation of the Media over QUIC transport.
This crate provides the core networking layer, implementing the moq-lite specification. Live media is built on top of this layer using something like hang.
- Broadcasts: Discoverable collections of tracks.
- Tracks: Named streams of data, split into groups.
- Groups: A sequential collection of frames, usually starting with a keyframe.
- Frame: A timed chunk of data.
Example - Chat track
// Optional: Use moq_native to make a QUIC client.
let config = default; // See documentation
let client = new;
// For local development, use: http://localhost:4443/anon
// The "anon" path is usually configured to bypass authentication; be careful!
let url = parse.unwrap;
// Establish a WebTransport/QUIC connection.
let connection = client.connect.await?;
// Perform the MoQ handshake.
let mut session = connect.await?;
// Create a broadcast.
// A broadcast is a collection of tracks, but in this example there's just one.
let broadcast = new;
// Create a track that we'll insert into the broadcast.
// A track is a series of groups representing a live stream.
let track = broadcast.create;
// Create a group.
// Each group is independent and the newest group(s) will be prioritized.
let group = track.append;
// Write frames to the group.
// Each frame is dependent on the previous frame, so older frames are prioritized.
group.append;
group.append;
// Finally, publish the broadcast to the session.
// You can provide a broadcast path which gets appended to the URL.
session.publish;
// NOTE: You can create multiple consumer instances of any `XxxProducer`
// Each which will receive a (ref-counted) copy of the data.
let _broadcast = broadcast.consume;
let _track = track.consume;
let _group = group.consume;