Expand description
§moq-lite: Media over QUIC Transport
moq-lite is designed for real-time live media delivery with sub-second latency at massive scale.
This is a simplified subset of the official Media over QUIC (MoQ) transport, focusing on the practical features.
§API
The API is built around Producer/Consumer pairs, with the hierarchy:
- Origin: A collection of Broadcasts, produced by one or more Sessions.
- Broadcast: A collection of Tracks, produced by a single publisher.
- Track: A collection of Groups, delivered out-of-order until expired.
- Group: A collection of Frames, delivered in order until cancelled.
- Frame: Chunks of data with an upfront size.
§Compatibility
moq-lite purposely implements a subset of the IETF moq-transport specification.
Many features are unsupported on purpose to keep the API and implementation clean,
rather than pollute them with half-baked features.
That said, the library is forwards-compatible with the full specification and supports moq-transport drafts 14+ via version negotiation. Everything will work perfectly, so long as your application uses the API as defined above.
For example, there’s no concept of “sub-group” in moq-lite. When connecting to
a moq-transport implementation, we use sub-group=0 for all frames and silently
drop any received frames not in sub-group=0. If your application genuinely needs
multiple sub-groups, tell me why and we can figure something out.
§Producers and Consumers
Each level of the hierarchy is split into a Producer / Consumer pair:
- The Producer is the writer: it appends new state (publishes a broadcast, starts a group, writes frames, closes a track).
- The Consumer is a reader: each consumer holds its own independent view of the producer’s state, with its own cursor through the stream.
Both halves are cheaply clonable so you can hand out multiple handles. Cloning a consumer creates another reader (each at its own cursor); cloning a producer gives another writer that contributes to the same shared state. Closing the last producer signals consumers that no more updates are coming.
§Async
This library is async-first, using tokio for async I/O and task management.
Any plain async method should be awaited from inside an active tokio runtime.
Otherwise you risk a panic.
This requirement is being phased out as more methods grow poll_xxx counterparts
built on conducer, so you can drive them from custom executors without a tokio
runtime. You can also call them synchronously, since conducer is built on the
standard std::task::Waker API and any std::task::Waker is a valid driver.
Re-exports§
pub use bytes;
Structs§
- Bandwidth
Consumer - Consumes bandwidth estimates, allowing reads and async change notifications.
- Bandwidth
Producer - Produces bandwidth estimates, notifying consumers when the value changes.
- Bounds
Exceeded - The number is too large to fit in a VarInt (62 bits).
- Broadcast
- A collection of media tracks that can be published and subscribed to.
- Broadcast
Consumer - Subscribe to arbitrary broadcast/tracks.
- Broadcast
Dynamic - Handles on-demand track creation for a broadcast.
- Broadcast
Producer - Manages tracks within a broadcast.
- Client
- A MoQ client session builder.
- Frame
- A chunk of data with an upfront size.
- Frame
Consumer - Used to consume a frame’s worth of data, streaming as bytes arrive.
- Frame
Producer - Writes a frame’s payload in one or more chunks.
- Group
- A group contains a sequence number because they can arrive out of order.
- Group
Consumer - Consume a group, frame-by-frame.
- Group
Producer - Writes frames to a group in order.
- Origin
- A relay origin, identified by a 62-bit varint on the wire.
- Origin
Consumer - Consumes announced broadcasts matching against an optional prefix.
- Origin
List - Bounded list of
Originentries, typically the hop chain of a broadcast. - Origin
Producer - Announces broadcasts to consumers over the network.
- Path
- A broadcast path that provides safe prefix matching operations.
- Path
Prefixes - A deduplicated list of path prefixes.
- Server
- A MoQ server session builder.
- Session
- A MoQ transport session, wrapping a WebTransport connection.
- Time
Overflow - Returned when a
Timescaleoperation would exceed the QUIC VarInt range (2^62 - 1) or overflow during scale conversion or arithmetic. - Timescale
- A timestamp representing the presentation time in a given scale. ex. 1000 for milliseconds.
- TooMany
Origins - Returned when an operation would grow an
OriginListpast its hop-count cap. - Track
- A track is a collection of groups, delivered out-of-order until expired.
- Track
Consumer - A consumer for a track, used to read groups.
- Track
Producer - A producer for a track, used to create new groups.
- Versions
- A set of supported MoQ versions.
Enums§
- Decode
Error - A decode error.
- Encode
Error - An error that occurs during encoding.
- Error
- A list of possible errors that can occur during the session.
- Version
- A MoQ protocol version.
Constants§
- ALPNS
- ALPN strings for supported versions.
Traits§
- AsPath
- A trait for types that can be converted to a
Path.
Type Aliases§
- Origin
Announce - A broadcast path and its associated consumer, or None if closed.
- Path
Owned - An owned version of
Pathwith a'staticlifetime. - Result
- Time
- A timestamp representing the presentation time in milliseconds.