kixelated / moq-rs

Rust library for Media over QUIC
Apache License 2.0
355 stars 53 forks source link

Media over QUIC

Media over QUIC (MoQ) is a live media delivery protocol utilizing QUIC streams. See quic.video for more information.

This repository contains a few crates:

There's currently no way to view media with this repo; you'll need to use moq-js for that. A hosted version is available at quic.video and accepts the ?host=localhost:4443 query parameter.

Development

Launch a basic cluster, including provisioning certs and deploying root certificates:

make run

Then, visit https://quic.video/publish/?server=localhost:4443.

For more control, use the dev helper scripts.

Usage

moq-relay

moq-relay is a server that forwards subscriptions from publishers to subscribers, caching and deduplicating along the way. It's designed to be run in a datacenter, relaying media across multiple hops to deduplicate and improve QoS. The relays optionally register themselves via the moq-api endpoints, which is used to discover other relays and share broadcasts.

Notable arguments:

This listens for WebTransport connections on UDP https://localhost:4443 by default. You need a client to connect to that address, to both publish and consume media.

moq-pub

A client that publishes a fMP4 stream over MoQ, with a few restrictions.

This client can currently be used in conjuction with either ffmpeg or gstreamer.

ffmpeg

moq-pub can be run as a binary, accepting a stream (from ffmpeg via stdin) and publishing it to the given relay. See dev/pub for the required ffmpeg flags.

gstreamer

moq-pub can also be run as a library, currently used for a gstreamer plugin. This is in a separate repository to avoid gstreamer being a hard requirement. See run for an example pipeline.

moq-transport

A media-agnostic library used by moq-relay and moq-pub to serve the underlying subscriptions. It has caching/deduplication built-in, so your application is oblivious to the number of connections under the hood.

See the published crate and documentation.

moq-clock

moq-clock is a simple client that can publish or subscribe to the current time. It's meant to demonstate that moq-transport can be used for more than just media.

moq-dir

moq-dir is a server that aggregates announcements. It produces tracks based on the prefix, which are subscribable and can be used to discover broadcasts.

For example, if a client announces the broadcast .public.room.12345.alice, then moq-dir will produce the following track:

TRACK namespace=. track=public.room.12345.
OBJECT +alice

Use the --announce <moq-dir-url> flag when running the relay to forward all announcements to the instance.

moq-api

This is a API server that exposes a REST API. It's used by relays to inserts themselves as origins when publishing, and to find the origin when subscribing. It's basically just a thin wrapper around redis that is only needed to run multiple relays in a (simple) cluster.

License

Licensed under either: