8000 GitHub - kixelated/moq: Rust library for Media over QUIC
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

kixelated/moq

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Media over QUIC

License Discord Crates.io npm

Media over QUIC

Media over QUIC (MoQ) is a next-generation live media delivery protocol that provides real-time latency at massive scale. Built on modern web technologies like WebTransport and WebCodecs, MoQ delivers WebRTC-like latency with CDN-like distribution.

Key Features:

  • πŸš€ Real-time latency via QUIC stream priotization and partial reliability.
  • πŸ“ˆ Massive scale via edge caching, fanout, and multi-region clustering.
  • 🌐 Browser support via WebTransport and WebCodecs.
  • πŸ”§ Generic transport for any live data, not just media
  • 🎯 Simple API with both Rust and TypeScript implementations

Note: This project is a fork of the IETF MoQ specification. The focus is narrower, focusing on simplicity and deployability.

Demo

This repository is split into multiple binaries and libraries across different languages. It can get overwhelming, so there's an included demo with some examples.

Note: this demo uses an insecure HTTP fetch intended for local development only. In production, you'll need a proper domain and a matching TLS certificate via LetsEncrypt or similar.

Quick Setup

Requirements:

# Runs a relay, demo media, and the web server
nix shell -c just all

Then visit https://localhost:8080 to see the demo. Note that this uses an insecure HTTP fetch for local development only; in production you'll need a proper domain + TLS certificate.

TIP: If you've installed nix-direnv, then only just all is required.

Full Setup

If you don't like Nix, or just want things install globally, then you can install dependencies manually.

Requirements:

Run it:

# Install some more dependencies
just setup

# Runs a relay, demo media, and the web server
just all

Then visit https://localhost:8080 to see the demo.

Architecture

MoQ is designed as a layered protocol stack.

Rule 1: The CDN MUST NOT know anything about your application, media codecs, or even the available tracks. Everything could be fully E2EE and the CDN wouldn't care. No business logic allowed.

Instead, moq-relay operates on rules encoded in the moq-lite header. These rules are based on video encoding but are generic enough to be used for any live data. The goal is to keep the server as dumb as possible while supporting a wide range of use-cases.

The media logic is split into another protocol called hang. It's pretty simple and only intended to be used by clients or media servers. If you want to do something more custom, then you can always extend it or replace it entirely.

Think of hang as like HLS/DASH, while moq-lite is like HTTP.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Application   β”‚   🏒 Your business logic
β”‚                 β”‚    - authentication, non-media tracks, etc.
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚      hang       β”‚   🎬 Media-specific encoding/streaming
β”‚                 β”‚     - codecs, containers, catalog
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”œ
β”‚    moq-lite     β”‚  🚌 Generic pub/sub transport
β”‚                 β”‚     - broadcasts, tracks, groups, frames
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  WebTransport   β”‚  🌐 Browser-compatible QUIC
β”‚      QUIC       β”‚     - HTTP/3 handshake, multiplexing, etc.
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Libraries

This repository provides both Rust and TypeScript libraries with similar APIs but language-specific optimizations.

Rust

Crate Description Docs
moq-lite The core pub/sub transport protocol. Has built-in concurrency and deduplication. docs.rs
moq-relay A clusterable relay server. This relay performs fan-out connecting multiple clients and servers together.
moq-token An authentication scheme supported by moq-relay. Can be used as a library or as a CLI to authenticate sessions.
moq-native Opinionated helpers to configure a Quinn QUIC endpoint. It's harder than it should be. docs.rs
hang Media-specific encoding/streaming layered on top of moq-lite. Can be used as a library or a CLI. docs.rs
hang-gst A simple gstreamer plugin for publishing or consuming hang broadcasts.
hang-wasm A deprecated web player using WASM. Use the Typescript implementation instead.

TypeScript

Package Description NPM
@kixelated/moq The core pub/sub transport protocol. Has built-in concurrency and deduplication. npm
@kixelated/hang Media-specific encoding/streaming layered on top of moq-lite. Provides both a Javascript API and Web Components. npm
@kixelated/hang-demo Examples using @kixelated/hang.

Protocol

Read the specifications:

Development

# See all available commands
just

# Build everything
just build

# Run tests and linting
just check

# Automatically fix some linting errors
just fix

# Run the demo manually
just relay    # Terminal 1: Start relay server
just pub tos  # Terminal 2: Publish a demo video using ffmpeg
just web      # Terminal 3: Start web server

There are more commands: check out the Justfile, rs/Justfile, and js/Justfile.

License

Licensed under either:

About

Rust library for Media over QUIC

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

 
 
 

Contributors 23

0