Skip to main content

Crate moq_rtc

Crate moq_rtc 

Source
Expand description

WebRTC ↔ MoQ gateway.

Bridges WHIP (RFC 9725) and WHEP between WebRTC peers and moq_net broadcasts. The crate is split along two orthogonal axes so all four combinations can land independently:

RTP-in (ingest into MoQ)RTP-out (egress from MoQ)
HTTP serverServer::publish_router (WHIP server)Server::subscribe_router (WHEP server)
HTTP clientClient::subscribe (WHEP client)Client::publish (WHIP client)

The two HTTP-client paths and the two HTTP-server paths share a single internal session driver and the same per-codec adapters; the per-direction split lives in the (crate-private) ingest and egress sources.

§Embedding

Build a Server over your own OriginProducer / OriginConsumer and merge Server::publish_router / Server::subscribe_router into your own axum app, or dial out with Client. A command-line interface is provided by the moq-cli binary, on top of this library.

The bundled routers are unauthenticated: they derive the broadcast name from the request path. To own the HTTP route and authorize requests yourself (resolving the broadcast name from a verified token), skip the routers and call whip::accept (ingest) / whep::accept (egress) from your own handler. Return the Response::answer in your HTTP response, then run Response::run to drive the media session for its lifetime.

§Bitstream gotcha

The WebRTC ↔ MoQ shape conversion for H.264 and H.265 is handled by moq-mux importers: str0m hands us Annex-B (start-code NALs with inline parameter sets) and that’s exactly what the importers want. AV1 uses the shared OBU splitter/importer. Opus, VP8, and VP9 pass through.

Re-exports§

pub use client::Client;
pub use server::Response;
pub use server::Server;
pub use server::whep;
pub use server::whip;
pub use str0m;
pub use axum;
pub use url;

Modules§

client
HTTP-client side: dial a remote WHIP/WHEP endpoint over an SDP exchange.
server
HTTP-server side: accept WHIP/WHEP offers from remote clients.

Enums§

Error
Errors produced by the WebRTC <-> MoQ gateway.

Type Aliases§

Result
Convenience alias for results from the WebRTC <-> MoQ gateway.