1 unstable release
new 0.1.0 | May 22, 2025 |
---|
#12 in Multimedia
25KB
202 lines
Media over QUIC (MoQ) is a live (media) delivery protocol utilizing QUIC. It utilizes new browser technologies such as WebTransport and WebCodecs to provide WebRTC-like functionality. Despite the focus on media, the transport is generic and designed to scale to enormous viewership via clustered relay servers (aka a CDN). See quic.video for more information.
Note: this project is a fork of the IETF specification. The principles are the same but the implementation is exponentially simpler given a narrower focus (and no politics).
Quick Start
Too many words, here's a quick start:
Requirements:
just setup
just all
Layers
Now that those with ADHD have left, let's talk about the layers. Unlike WebRTC, MoQ is purposely split into multiple layers to allow for maximum flexibility. For more information, see the blog.
- QUIC: The network layer, providing a semi-reliable transport over UDP.
- WebTransport: QUIC but with a HTTP/3 handshake for browser compatibility.
- moq-lite: A pub/sub protocol used to serve "broadcasts", "tracks", "groups", and "frames".
- hang: Media-specific encoding based on the WebCodecs API. It's designed primarily for real-time conferencing.
- application: Any stuff you want to build on top of moq/hang.
If you're curious about the underlying protocols, check out the specification.
If you want to argue about anything, participate in the IETF or bad-mouth @kixelated
on Discord.
Environments
Originally, this repository was called moq-rs
with the aim of targetting all platforms.
The reality is that the moq
and hang
are relatively simple while everything else is platform specific.
For example, a MoQ web player MUST use browser APIs for networking, encoding, decoding, rendering, capture, etc. The low level hardware and syscalls otherwise necessary are not exposed to the application (Javascript and WASM alike). You can use wasm-bindgen and web-sys shims, and you can see an example in hang-wasm, but it's a lot of boilerplate and type juggling.
Instead, this repository is split based on the language and environment:
- rs: Rust libraries for native platforms. (and WASM)
- js: Typescript libraries for web only. (not node)
Unfortunately, this means that there are two implementations of moq
and hang
.
They have a similar API but of course there are language differences.
Rust (Native)
- moq: The underlying pub/sub protocol providing real-time latency and scale. This is a simplified fork of the IETF moq-transport draft called
moq-lite
. - moq-relay: A server that forwards content from publishers to any interested subscribers. It can optionally be clustered, allowing N servers to transfer between themselves.
- moq-clock: A dumb clock client/server just to prove MoQ can be used for more than media.
- moq-native: Helpers to configure QUIC on native platforms.
- hang: Media-specific components built on top of MoQ.
- hang-cli: A CLI for publishing and subscribing to media.
- hang-gst: A gstreamer plugin for publishing and subscribing to media.
- hang-wasm: A web client written in Rust and using WASM. (unmaintained)
- web-transport: A Rust implementation of the WebTransport API powered by Quinn.
The hang-wasm crate is currently unmaintained and depends on some other unmaintained crates that I've made. Notably:
- web-transport-wasm: A wrapper around the WebTransport API.
- web-codecs: A wrapper around the WebCodecs API.
- web-streams: A wrapper around the WebStreams API.
- You get the idea; it's all wrappers.
Typescript (Web)
- moq: The underlying pub/sub protocol providing real-time latency and scale. Available as @kixelated/moq
- hang: Media-specific components built on top of MoQ. Can be embedded on a web page via a WebComponent. Available as @kixelated/hang
Check out the demo for an example of how to use the library.
Documentation is sparse as the API is still a work in progress.
The provided Web Components (Watch
and Publish
) are unlikely to change dramatically.
Usage
Requirements
Development
Setup
We use just
to simplify the development process.
Check out the Justfile or run just
to see the available commands.
Install any other required tools:
just setup
Building
# Run the relay, a demo movie, and web server:
just all
# Or run each individually in separate terminals:
just relay
just pub bbb
just web
Then, visit https://localhost:8080 to watch the simple demo.
There are a lot more commands; check out the Justfile and individual README files.
Contributing
When you're ready to submit a PR, make sure the tests pass or face the wrath of CI:
just check
just test
# Optional: Automatically fix easy lint issues.
just fix
License
Licensed under either:
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
Dependencies
~32–56MB
~1M SLoC