Skip to main content

Crate moq_lite

Crate moq_lite 

Source
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§

BandwidthConsumer
Consumes bandwidth estimates, allowing reads and async change notifications.
BandwidthProducer
Produces bandwidth estimates, notifying consumers when the value changes.
BoundsExceeded
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.
BroadcastConsumer
Subscribe to arbitrary broadcast/tracks.
BroadcastDynamic
Handles on-demand track creation for a broadcast.
BroadcastProducer
Manages tracks within a broadcast.
Client
A MoQ client session builder.
Frame
A chunk of data with an upfront size.
FrameConsumer
Used to consume a frame’s worth of data, streaming as bytes arrive.
FrameProducer
Writes a frame’s payload in one or more chunks.
Group
A group contains a sequence number because they can arrive out of order.
GroupConsumer
Consume a group, frame-by-frame.
GroupProducer
Writes frames to a group in order.
Origin
A relay origin, identified by a 62-bit varint on the wire.
OriginConsumer
Consumes announced broadcasts matching against an optional prefix.
OriginList
Bounded list of Origin entries, typically the hop chain of a broadcast.
OriginProducer
Announces broadcasts to consumers over the network.
Path
A broadcast path that provides safe prefix matching operations.
PathPrefixes
A deduplicated list of path prefixes.
Server
A MoQ server session builder.
Session
A MoQ transport session, wrapping a WebTransport connection.
TimeOverflow
Returned when a Timescale operation 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.
TooManyOrigins
Returned when an operation would grow an OriginList past its hop-count cap.
Track
A track is a collection of groups, delivered out-of-order until expired.
TrackConsumer
A consumer for a track, used to read groups.
TrackProducer
A producer for a track, used to create new groups.
Versions
A set of supported MoQ versions.

Enums§

DecodeError
A decode error.
EncodeError
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§

OriginAnnounce
A broadcast path and its associated consumer, or None if closed.
PathOwned
An owned version of Path with a 'static lifetime.
Result
Time
A timestamp representing the presentation time in milliseconds.