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 session::Session driver and the same per-codec adapters in codec; the per-direction split lives in session::MediaSink (ingest) / egress::EgressSource (egress).

§Embedding

Depend on this crate with default-features = false to embed the gateway in another process: 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. That lean build skips the standalone binary’s deps (axum-server, clap, moq-native, rustls, sd-notify, tower-http), which the server feature (on by default) pulls back in for the moq-rtc binary.

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 is handled by moq-mux’s Avc3 importer: str0m hands us Annex-B (start-code NALs with inline SPS/PPS) and that’s exactly what the importer wants, so no extra transform is needed in the gateway. 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;

Modules§

client
HTTP-client side: dial a remote WHIP/WHEP endpoint over an SDP exchange.
codec
Per-codec bridges between moq-mux and str0m.
egress
Per-broadcast egress source for the RTP-out paths.
ingest
Per-broadcast MediaSink used by every RTP-in flow (server publish / WHIP server, client subscribe / WHEP client).
sdp
SDP plumbing.
server
HTTP-server side: accept WHIP/WHEP offers from remote clients.
session
str0m session driver shared by every HTTP role / media direction.

Enums§

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

Type Aliases§

Result