diff --git a/.github/workflows/release-gate.yml b/.github/workflows/release-gate.yml index b82aa57386d..ac306a70085 100644 --- a/.github/workflows/release-gate.yml +++ b/.github/workflows/release-gate.yml @@ -252,7 +252,6 @@ jobs: - "rs/moq-congestion/**" - "rs/moq-crypto/**" - "rs/moq-hls/**" - - "rs/moq-ice/**" - "rs/moq-json/**" - "rs/moq-loc/**" - "rs/moq-msf/**" @@ -261,7 +260,6 @@ jobs: - "rs/moq-pattern/**" - "rs/moq-quic/**" - "rs/moq-relay/**" - - "rs/moq-rtc/**" - "rs/moq-rtmp/**" - "rs/moq-rtsp/**" - "rs/moq-shaper/**" @@ -269,6 +267,7 @@ jobs: - "rs/moq-srt/**" - "rs/moq-stats/**" - "rs/moq-tokio/**" + - "rs/moq-webrtc/**" - "rs/qmux/**" - "Cargo.toml" - "Cargo.lock" diff --git a/.oss-scanner/Dockerfile b/.oss-scanner/Dockerfile index 4aa0a34f495..b0a60150b82 100644 --- a/.oss-scanner/Dockerfile +++ b/.oss-scanner/Dockerfile @@ -22,13 +22,14 @@ RUN rustup show active-toolchain || rustup toolchain install \ && curl -LsSf "https://get.nexte.st/$NEXTEST_VERSION/$nextest" | tar zxf - -C "$CARGO_HOME/bin" \ && cargo nextest --version -ARG CRATES="kio hang moq-auth moq-crypto moq-hls moq-ice moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtc moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-cli" +ARG CRATES="kio hang moq-auth moq-crypto moq-hls moq-json moq-loc moq-msf moq-mux moq-net moq-pattern moq-quic moq-relay moq-rtmp moq-rtsp moq-sock moq-srt moq-stats moq-tokio moq-uring moq-webrtc moq-cli" # Path specs, because the lockfile also has published copies of some workspace crates. # io-uring compiles the relay's io_uring QUIC workers (`--runtime-io-uring`), which the default features leave out. +# p2p compiles moq-webrtc's data channel transport and its tests. RUN cargo fetch --locked \ && specs=$(printf -- '-p path+file:///src/rs/%s ' $CRATES) \ - && cargo build --locked $specs --features moq-relay/io-uring --bins \ - && cargo test --locked --no-run $specs --features moq-relay/io-uring + && cargo build --locked $specs --features moq-relay/io-uring,moq-webrtc/p2p --bins \ + && cargo test --locked --no-run $specs --features moq-relay/io-uring,moq-webrtc/p2p ENV CARGO_NET_OFFLINE=true diff --git a/.oss-scanner/threat_model.md b/.oss-scanner/threat_model.md index 3e3c4f9413c..7a42c41537f 100644 --- a/.oss-scanner/threat_model.md +++ b/.oss-scanner/threat_model.md @@ -11,7 +11,7 @@ Treat everything a peer sends as hostile, before and after authentication: - **WebSocket and HTTP** on the relay's `[web]` listeners: the upgrade, the public `/announced`, `/fetch` and `/certificate.sha256` endpoints, and query strings. - **Authorization inputs**: the JWT (`moq-auth`), the SETUP token, the dialed path and query, and the relay's handling of grants (root, publish and subscribe pattern unions, mounts, expiry, revalidation). - **Media payloads**: catalogs (`hang`, `moq-msf`, JSON in `moq-json`) and containers and codecs parsed by `moq-mux` (fMP4, MPEG-TS, FLV, MKV, LOC, and the H.264, H.265, AV1, VP8, VP9, AAC, Opus and FLAC bitstream parsers). A publisher controls these bytes, and the relay or a subscriber may parse them. -- **Ingest gateways**: RTMP (`moq-rtmp`), RTSP (`moq-rtsp`), SRT (`moq-srt`), WebRTC and ICE/STUN (`moq-rtc`, `moq-ice`), and HLS playlists and segments (`moq-hls`). +- **Ingest gateways**: RTMP (`moq-rtmp`), RTSP (`moq-rtsp`), SRT (`moq-srt`), WebRTC, ICE/STUN, and data channels (`moq-webrtc`), and HLS playlists and segments (`moq-hls`). - **Peer relays** in a cluster are authenticated but should not be able to break a node beyond what their grant allows. ## Security properties the relay must hold @@ -34,7 +34,7 @@ Most important, in this order: 1. `rs/moq-relay` and the crates it serves the network with: `rs/moq-net`, `rs/moq-quic`, `rs/moq-tokio`, `rs/moq-uring`, `rs/moq-sock`, `rs/moq-auth`, `rs/moq-pattern`. 2. Authorization: a session publishing, subscribing, or seeing announcements outside its grant, or reaching another root (tenant) through path tricks, revalidation, mounts, or cluster links. 3. `rs/moq-mux` and `rs/hang`: container, codec, and catalog parsing of publisher-controlled bytes. -4. The ingest gateways: `rs/moq-rtmp`, `rs/moq-rtsp`, `rs/moq-srt`, `rs/moq-rtc`, `rs/moq-ice`, `rs/moq-hls`. +4. The ingest gateways: `rs/moq-rtmp`, `rs/moq-rtsp`, `rs/moq-srt`, `rs/moq-webrtc`, `rs/moq-hls`. 5. `rs/moq-crypto`, `rs/moq-cli`, `rs/moq-json`, `rs/moq-stats`, `rs/kio`. `unsafe` is rare and worth reading closely where it appears: `rs/moq-quic`, `rs/moq-net/src/model`, `rs/moq-net/src/util/cell.rs`, `rs/moq-net/src/transport.rs`, and `rs/moq-relay/src/uring.rs`. @@ -45,7 +45,7 @@ Out of scope: `js/` and the other language bindings (`py/`, `swift/`, `kt/`, `go The image is offline, with every crate fetched and `CARGO_NET_OFFLINE` set. The debug build of the in-scope crates, their test binaries, and the `moq-relay` and `moq` binaries are already built in `/src/target/debug`. Debug builds keep overflow checks on. -- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. Add `--features moq-relay/io-uring` for the relay and `moq-uring` so the io\_uring backend's tests run (they skip on a kernel without io\_uring support). Unit tests use the deterministic clock in `kio::clock` rather than wall time, so they are fast and reproducible. +- **Tests**: `cargo nextest run -p path+file:///src/rs/moq-net` (or any in-scope crate; the path spec is needed because the lockfile also has published copies of some crates). Use nextest as CI does: some tests install process-global state and fail under plain `cargo test`. Add `--features moq-relay/io-uring` for the relay and `moq-uring` so the io\_uring backend's tests run (they skip on a kernel without io\_uring support), and `--features moq-webrtc/p2p` for the data channel transport's. Unit tests use the deterministic clock in `kio::clock` rather than wall time, so they are fast and reproducible. - **A relay to attack**: `./target/debug/moq-relay demo/relay/localhost.toml` listens on UDP and TCP `[::]:4443` with a self-signed certificate and anonymous access to every path. The binary is built with io\_uring support; pass `--runtime-io-uring` to serve QUIC from the io\_uring workers in `rs/moq-uring` and `rs/moq-relay/src/uring.rs` instead of tokio. For authorization testing, grant a narrow anonymous pattern with `[auth] public_subscribe` / `public_publish`, or run the reference auth server (`moq auth generate`, `moq auth sign`, `moq auth serve`, then `[auth] url`; see `doc/bin/cli.md`) and try to escape a signed token's root and patterns. `doc/bin/relay/` documents the config, auth, cluster, and HTTP endpoints. - **A client**: `./target/debug/moq --help` publishes, subscribes, fetches, and lists announcements against a relay. `curl http://localhost:4443/announced/` and `curl http://localhost:4443/fetch//` hit the HTTP endpoints. - **Fuzz harnesses**: `rs/moq-net/fuzz` and `rs/moq-quic/fuzz` hold cargo-fuzz targets for the wire codecs and the QUIC state machine. cargo-fuzz and a nightly toolchain are not in the image, but the targets show the parser entry points. diff --git a/Cargo.lock b/Cargo.lock index efa810525e3..720a257ea6e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4493,7 +4493,6 @@ dependencies = [ "moq-json", "moq-mux", "moq-relay", - "moq-rtc", "moq-rtmp", "moq-rtsp", "moq-shaper", @@ -4501,6 +4500,7 @@ dependencies = [ "moq-tokio", "moq-transcode", "moq-video", + "moq-webrtc", "mpeg2ts", "object_store", "percent-encoding", @@ -4653,19 +4653,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "moq-ice" -version = "0.1.0" -dependencies = [ - "kio", - "str0m", - "stun-types", - "thiserror 2.0.21", - "tokio", - "tracing", - "workspace-hack", -] - [[package]] name = "moq-json" version = "0.5.8" @@ -4965,30 +4952,6 @@ dependencies = [ "workspace-hack", ] -[[package]] -name = "moq-rtc" -version = "0.3.12" -dependencies = [ - "aws-lc-rs", - "axum", - "bytes", - "hang", - "kio", - "moq-ice", - "moq-mux", - "moq-net", - "moq-tokio", - "reqwest", - "str0m", - "thiserror 2.0.21", - "tokio", - "tracing", - "tracing-test", - "url", - "uuid", - "workspace-hack", -] - [[package]] name = "moq-rtmp" version = "0.3.11" @@ -5154,14 +5117,12 @@ dependencies = [ "http", "humantime", "humantime-serde", - "if-addrs", "jni", "kio", "libc", "mdns-sd", "moq-congestion", "moq-crypto", - "moq-ice", "moq-net", "moq-quic", "moq-shaper", @@ -5183,8 +5144,6 @@ dependencies = [ "serde", "serde_with", "socket2 0.6.5", - "str0m", - "stun-types", "tempfile", "thiserror 2.0.21", "tikv-jemalloc-ctl", @@ -5347,6 +5306,34 @@ dependencies = [ "zune-jpeg", ] +[[package]] +name = "moq-webrtc" +version = "0.3.12" +dependencies = [ + "aws-lc-rs", + "axum", + "bytes", + "futures", + "hang", + "if-addrs", + "kio", + "mdns-sd", + "moq-mux", + "moq-net", + "moq-tokio", + "qmux 0.7.0", + "reqwest", + "str0m", + "stun-types", + "thiserror 2.0.21", + "tokio", + "tracing", + "tracing-test", + "url", + "uuid", + "workspace-hack", +] + [[package]] name = "mp4-atom" version = "0.17.1" diff --git a/Cargo.toml b/Cargo.toml index 68db74e417a..47691aa4bde 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,6 @@ default-members = [ # "rs/moq-ffi", # requires Python/maturin # "rs/moq-gst", # requires GStreamer "rs/moq-hls", - "rs/moq-ice", "rs/moq-json", "rs/moq-loc", "rs/moq-msf", @@ -32,7 +31,6 @@ default-members = [ "rs/moq-quic", "rs/moq-relay", "rs/moq-room", - "rs/moq-rtc", "rs/moq-rtmp", "rs/moq-rtsp", "rs/moq-shaper", @@ -44,6 +42,7 @@ default-members = [ "rs/moq-uring", "rs/moq-v4l", "rs/moq-video", + "rs/moq-webrtc", "rs/qmux", "rs/test-env", # Maturin runs the workspace's `uniffi-bindgen` binary from the root to @@ -111,7 +110,7 @@ humantime = "2.3" humantime-serde = "1.1.1" hyper = "1.11" hyper-util = { version = "0.1.21", features = ["tokio"] } -# Interface addresses for WebRTC host candidates (moq-tokio's `webrtc` feature). +# Interface addresses for WebRTC host candidates (moq-webrtc's `p2p` feature). if-addrs = "0.15" indexmap = "2.14.2" io-uring = "0.7.15" @@ -121,7 +120,8 @@ kio-macros = { version = "0.1.0", path = "rs/kio/macros" } libc = "0.2" libloading = "0.9" linux-raw-sys = { version = "0.12.1", features = ["ioctl"] } -# DNS-SD advertisement and browsing for LAN peer discovery (moq-tokio's `mdns` feature). +# DNS-SD advertisement and browsing for LAN peer discovery (moq-tokio's `mdns` feature), +# and `.local` candidate resolution (moq-webrtc's `p2p` feature). # `async` awaits the event channel instead of blocking a thread on it. mdns-sd = { version = "0.21", features = ["async"] } moq-archive = { version = "0.0.11", path = "rs/moq-archive" } @@ -131,7 +131,6 @@ moq-congestion = { version = "0.1.0", path = "rs/moq-congestion" } # default-features off: moq-auth takes only the endpoint key and its text codec. moq-crypto = { version = "0.0.11", path = "rs/moq-crypto", default-features = false } moq-hls = { version = "0.5.11", path = "rs/moq-hls", default-features = false } -moq-ice = { version = "0.1.0", path = "rs/moq-ice" } moq-json = { version = "0.5.8", path = "rs/moq-json" } moq-loc = { version = "0.2.19", path = "rs/moq-loc" } moq-msf = { version = "0.5.1", path = "rs/moq-msf" } @@ -145,7 +144,6 @@ moq-pattern = { version = "0.1.2", path = "rs/moq-pattern" } # default-features off so each consumer picks its crypto provider. moq-quic = { version = "0.1.0", path = "rs/moq-quic", default-features = false } moq-relay = { version = "0.17.2", path = "rs/moq-relay", default-features = false } -moq-rtc = { version = "0.3.12", path = "rs/moq-rtc" } moq-rtmp = { version = "0.3.11", path = "rs/moq-rtmp" } moq-rtsp = { version = "0.1.0", path = "rs/moq-rtsp" } moq-sock = { version = "0.2.0", path = "rs/moq-sock" } @@ -176,6 +174,7 @@ moq-vaapi = "0.1.1" # that argument, so moq-ffi and moq-c opt NVIDIA and VAAPI back in (OpenH264 # through their own `openh264` feature, which release builds enable). moq-video = { version = "0.1.10", path = "rs/moq-video", default-features = false } +moq-webrtc = { version = "0.3.12", path = "rs/moq-webrtc" } mp4-atom = "0.17.1" nix = { version = "0.31.3", features = ["net", "socket", "uio"] } num_enum = "0.7" diff --git a/doc/bin/rtc.md b/doc/bin/rtc.md index 2eefff03d92..ef5a047a920 100644 --- a/doc/bin/rtc.md +++ b/doc/bin/rtc.md @@ -44,4 +44,4 @@ player or `export rtc --connect` must reconnect to reach the replacement. `--connect` runs until its session ends. Built on [str0m](https://crates.io/crates/str0m); the library is -[`moq-rtc`](https://docs.rs/moq-rtc). +[`moq-webrtc`](https://github.com/moq-dev/moq/tree/main/rs/moq-webrtc). diff --git a/doc/concept/transport.md b/doc/concept/transport.md index ca9db2176e2..d2cfb7e0327 100644 --- a/doc/concept/transport.md +++ b/doc/concept/transport.md @@ -90,7 +90,7 @@ records, with no datagrams. The application supplies signaling and ICE and keeps ownership of the peer connection; closing the transport closes only its channel. SCTP ordering means one lost packet can hold back every stream. -Native peers can opt into `moq-tokio`'s internal `webrtc` feature, which runs its own ICE agent: +Native peers can use `moq-webrtc`'s `p2p` feature, which runs its own ICE agent: host candidates on every interface, server-reflexive candidates from the STUN servers it is given, and mDNS resolution of a browser's `.local` candidates. The application still carries the offer, answer, and candidates; the offering diff --git a/doc/lib/rs/index.md b/doc/lib/rs/index.md index 0e46fa6ac74..c6da36759f1 100644 --- a/doc/lib/rs/index.md +++ b/doc/lib/rs/index.md @@ -25,10 +25,9 @@ missing required CPU feature before starting transport cryptography. | --- | --- | | [moq-net](/lib/rs/moq-net) | The pub/sub layer: sessions, origins, broadcasts, tracks, groups, frames. Transport-agnostic. | | [moq-pattern](https://docs.rs/moq-pattern) | Path patterns such as `room/**`. Re-exported by moq-net and moq-auth. | -| [moq-tokio](https://docs.rs/moq-tokio) | Connects and listens over QUIC, WebTransport, WebSocket, TCP, or Unix sockets, from config or CLI flags, and runs WebRTC data channels that the caller signals (`webrtc` feature). With default features off, `driver` builds a Tokio QUIC stack, with rind cryptography, without MoQ. | +| [moq-tokio](https://docs.rs/moq-tokio) | Connects and listens over QUIC, WebTransport, WebSocket, TCP, or Unix sockets, from config or CLI flags, and runs MoQ over a qmux session established elsewhere (`qmux` feature). With default features off, `driver` builds a Tokio QUIC stack, with rind cryptography, without MoQ. | | [qmux](https://docs.rs/qmux) | QUIC streams, datagrams, and flow control over TCP, TLS, WebSocket, and Unix sockets, on moq-quic's state machine. | | [moq-sock](https://docs.rs/moq-sock) | Socket binding and CPU pinning for thread-per-core listeners. | -| [moq-ice](https://github.com/moq-dev/moq/tree/main/rs/moq-ice) | Internal infrastructure with no stability promise; the ICE agent behind native WebRTC: drives a str0m connection over UDP, with a STUN client. | | [moq-uring](https://docs.rs/moq-uring) | Experimental Linux io\_uring server for moq-lite. | | [hang](/lib/rs/hang) | The media layer: catalog, containers, ordered frame delivery. | | [moq-mux](/lib/rs/moq-mux) | Import and export fMP4/CMAF, MPEG-TS, Matroska, FLV, and Annex-B. | @@ -44,7 +43,7 @@ missing required CPU feature before starting transport cryptography. | [moq-loc](https://docs.rs/moq-loc), [moq-msf](https://docs.rs/moq-msf) | The IETF LOC container and MSF catalog. | | [moq-stats](https://docs.rs/moq-stats) | Publish and consume relay traffic counters as tracks. | | [kio](/lib/rs/kio) | The async primitives everything polls through, and one clock for time and timers on tokio and a deterministic test simulator. | -| [moq-hls](https://docs.rs/moq-hls), [moq-rtmp](https://docs.rs/moq-rtmp), [moq-srt](https://docs.rs/moq-srt), [moq-rtsp](https://github.com/moq-dev/moq/tree/main/rs/moq-rtsp), [moq-rtc](https://docs.rs/moq-rtc) | The [gateways](/bin/), as libraries you can embed with your own auth. | +| [moq-hls](https://docs.rs/moq-hls), [moq-rtmp](https://docs.rs/moq-rtmp), [moq-srt](https://docs.rs/moq-srt), [moq-rtsp](https://github.com/moq-dev/moq/tree/main/rs/moq-rtsp), [moq-webrtc](https://github.com/moq-dev/moq/tree/main/rs/moq-webrtc) | The [gateways](/bin/), as libraries you can embed with your own auth. moq-webrtc's `p2p` feature also runs MoQ over a data channel with a browser peer, signaled by the caller. | | [moq-ffi](https://docs.rs/moq-ffi), [moq-c](/lib/c/) | The UniFFI core behind the language bindings, and the C ABI. | | [moq-relay](/bin/relay/), [moq-cli](/bin/cli) | The binaries, also usable as crates. | | [web-transport](https://github.com/moq-dev/web-transport) | The WebTransport traits and the browser transport, in a sibling repository. | diff --git a/doc/lib/rs/moq-net.md b/doc/lib/rs/moq-net.md index 5700cdc1509..9463b9087d0 100644 --- a/doc/lib/rs/moq-net.md +++ b/doc/lib/rs/moq-net.md @@ -20,7 +20,7 @@ What you use it for, beyond what the concept page already describes: - **Requests can pin an instance.** `consumer.request(path, Some(instance))` resolves only through a route announcing that [publisher instance](/concept/moq-lite#publisher-instances); `None` takes whichever route wins. The resolved consumer names its instance in `info().instance`, pinned or not. A route serves a random instance minted when it is created and kept across `withdraw()` and `announce()`; set one with `RouteOptions::with_instance(instance, epoch)` only for a publisher that continues its group sequences across restarts and raises the epoch each time. `route.instance()` names it. - **Rank several CDNs.** Dial each with its own subscribe handle, `origin.clone().with_preference(origin::Preference::new(rank))` (higher wins; 0 is neutral and a negative rank demotes), all on one origin. Requests use the preferred link that has a route and fail over to the next; see [multiple CDNs](/concept/moq-lite#multiple-cdns). - **Request one instance, or follow them all.** `consumer.request(path, None)` resolves the instance serving a path now, and fails `Unroutable` only once discovery has synced with no route for it. `consumer.follow(path, None)` hands out each publisher instance serving a path from `available()`: the first once announced, then each one that takes over, `None` once the path goes offline, and whatever serves it next, like JS `follow(path)`. `consumer.announced()` lists paths only as present or absent. A broadcast already resolved stays on the old instance until dropped or its route goes. See [identity and recovery](/concept/identity) to choose between following and holding one instance. -- **Discovery follows what you watch.** A client session asks the relay for announcements only under the prefixes its subscribe origin's readers watch, with `announced()`, `request`, or `follow`, stops asking about a prefix 2s after nothing at or beneath it is watched, and asks again on reconnect. A broadcast resolved through a discovered route keeps its path watched until dropped. `request` owns discovery of its path, so no separate watch is needed. A server session, or a client fed into an origin handle marked `with_link(origin::Link::Peer)` or `Link::Upstream`, asks for everything it may, so a relay discovers everything. An HTTP gateway (the moq-hls `Server`, the moq-rtc WHEP router) watches its whole scope while it lives, so the paths its callers name never open a request each. moq-lite-03/04 sessions, whose announcements mark no initial set, still ask for everything. +- **Discovery follows what you watch.** A client session asks the relay for announcements only under the prefixes its subscribe origin's readers watch, with `announced()`, `request`, or `follow`, stops asking about a prefix 2s after nothing at or beneath it is watched, and asks again on reconnect. A broadcast resolved through a discovered route keeps its path watched until dropped. `request` owns discovery of its path, so no separate watch is needed. A server session, or a client fed into an origin handle marked `with_link(origin::Link::Peer)` or `Link::Upstream`, asks for everything it may, so a relay discovers everything. An HTTP gateway (the moq-hls `Server`, the moq-webrtc WHEP router) watches its whole scope while it lives, so the paths its callers name never open a request each. moq-lite-03/04 sessions, whose announcements mark no initial set, still ask for everything. - **Dial and accept sockets.** `socket::Endpoint::new(&origin, prefix, id)` announces a hidden endpoint at `/.socket/`, used only to route dials. A session speaks one of two protocols, each with its own dial and accept. `accept_tcp()` and `accept_track()` yield an `Incoming` dial to `accept` or `reject` (dropping it rejects). `dial_tcp(peer)` and an accepted `tcp` dial yield a `socket::TcpStream`, a `group::Producer` and `group::Consumer` pair carrying one reliable, ordered byte pipe each way (finish is FIN, abort is RST, and `ready` paces the writer to the reader); `dial_track(peer, info)` and an accepted `track` dial yield a `socket::TrackStream`, this side's `track::Producer` and a `track::Subscriber` of the peer's half, subscribed reliably and in order until the application updates it, one message per group. A dial resolves once the peer accepts, and an accept checks that the claimed dialer really dialed this endpoint, waiting for its endpoint while the dial stays open. Every hop needs moq-lite-07 or moq-transport: while the origin has an older moq-lite client session whose publish half doesn't opt into hidden broadcasts (`with_hidden(true)`), dials and accepts fail with `Unsupported`. A dial to a peer behind such a hop waits, as for a peer not online yet. Session tracks are never announced or listed. See [Sockets](/concept/socket). - **One track per name.** Concurrent subscriptions share one request and producer. The application owns sequence numbers: the broadcast keeps nothing of an ended track, so a producer that replaces it starts at 0. A name always means the same content, so the replacement continues past its predecessor's groups with `create_group` at an explicit sequence. Readers of an aborted track resume onto the replacement when they read through an origin request, whose route always names an instance; otherwise their subscription ends with the error. - **Authored tracks default to a zero `max_age`.** `track::Info::default()` sets `max_age` to `Some(Duration::ZERO)`, the live edge only; a publisher that wants readers to reach history sets a longer bound, or `with_max_age(None)` for no publisher limit. Media tracks from `hang::container::track_info` declare `hang::container::MAX_AGE` (30 seconds). `max_age` is how long a superseded group stays fresh, never the newest group; it frees no bytes, which the cache pool's expiry reclaims. Received metadata keeps absence as no limit, and an origin's `cache_duration` can only cap it lower. diff --git a/doc/setup/upgrade.md b/doc/setup/upgrade.md index 45f07237eeb..48ef35a7a39 100644 --- a/doc/setup/upgrade.md +++ b/doc/setup/upgrade.md @@ -27,13 +27,23 @@ replaces it. - **Binaries:** [moq-relay](https://github.com/moq-dev/moq/blob/main/rs/moq-relay/MIGRATE.md), [moq-cli (`moq`)](https://github.com/moq-dev/moq/blob/main/rs/moq-cli/MIGRATE.md), [moq-gst](https://github.com/moq-dev/moq/blob/main/rs/moq-gst/MIGRATE.md), [obs-moq](https://github.com/moq-dev/moq/blob/main/cpp/obs/MIGRATE.md) - **Bindings:** [moq-ffi (UniFFI)](https://github.com/moq-dev/moq/blob/main/rs/moq-ffi/MIGRATE.md), [moq-c (C)](https://github.com/moq-dev/moq/blob/main/rs/moq-c/MIGRATE.md), [Python](https://github.com/moq-dev/moq/blob/main/py/moq-rs/MIGRATE.md), [Go](https://github.com/moq-dev/moq/blob/main/go/wrapper/MIGRATE.md), [Swift](https://github.com/moq-dev/moq/blob/main/swift/MIGRATE.md), [Kotlin](https://github.com/moq-dev/moq/blob/main/kt/moq/MIGRATE.md), [Dart](https://github.com/moq-dev/moq/blob/main/dart/moq/MIGRATE.md), [C++](https://github.com/moq-dev/moq/blob/main/cpp/moq/MIGRATE.md) -- **Rust:** [hang](https://github.com/moq-dev/moq/blob/main/rs/hang/MIGRATE.md), [kio](https://github.com/moq-dev/moq/blob/main/rs/kio/MIGRATE.md), [kio-macros](https://github.com/moq-dev/moq/blob/main/rs/kio/macros/MIGRATE.md), [moq-archive](https://github.com/moq-dev/moq/blob/main/rs/moq-archive/MIGRATE.md), [moq-audio](https://github.com/moq-dev/moq/blob/main/rs/moq-audio/MIGRATE.md), [moq-auth](https://github.com/moq-dev/moq/blob/main/rs/moq-auth/MIGRATE.md), [moq-boy](https://github.com/moq-dev/moq/blob/main/rs/moq-boy/MIGRATE.md), [moq-crypto](https://github.com/moq-dev/moq/blob/main/rs/moq-crypto/MIGRATE.md), [moq-hls](https://github.com/moq-dev/moq/blob/main/rs/moq-hls/MIGRATE.md), [moq-ice](https://github.com/moq-dev/moq/blob/main/rs/moq-ice/MIGRATE.md), [moq-json](https://github.com/moq-dev/moq/blob/main/rs/moq-json/MIGRATE.md), [moq-loc](https://github.com/moq-dev/moq/blob/main/rs/moq-loc/MIGRATE.md), [moq-msf](https://github.com/moq-dev/moq/blob/main/rs/moq-msf/MIGRATE.md), [moq-mux](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/MIGRATE.md), [moq-net](https://github.com/moq-dev/moq/blob/main/rs/moq-net/MIGRATE.md), [moq-nvenc](https://github.com/moq-dev/moq/blob/main/rs/moq-nvenc/MIGRATE.md), [moq-pattern](https://github.com/moq-dev/moq/blob/main/rs/moq-pattern/MIGRATE.md), [moq-quic](https://github.com/moq-dev/moq/blob/main/rs/moq-quic/MIGRATE.md), [moq-room](https://github.com/moq-dev/moq/blob/main/rs/moq-room/MIGRATE.md), [moq-rtc](https://github.com/moq-dev/moq/blob/main/rs/moq-rtc/MIGRATE.md), [moq-rtmp](https://github.com/moq-dev/moq/blob/main/rs/moq-rtmp/MIGRATE.md), [moq-sock](https://github.com/moq-dev/moq/blob/main/rs/moq-sock/MIGRATE.md), [moq-srt](https://github.com/moq-dev/moq/blob/main/rs/moq-srt/MIGRATE.md), [moq-stats](https://github.com/moq-dev/moq/blob/main/rs/moq-stats/MIGRATE.md), [moq-tokio](https://github.com/moq-dev/moq/blob/main/rs/moq-tokio/MIGRATE.md), [moq-transcode](https://github.com/moq-dev/moq/blob/main/rs/moq-transcode/MIGRATE.md), [moq-uring](https://github.com/moq-dev/moq/blob/main/rs/moq-uring/MIGRATE.md), [moq-v4l](https://github.com/moq-dev/moq/blob/main/rs/moq-v4l/MIGRATE.md), [moq-video](https://github.com/moq-dev/moq/blob/main/rs/moq-video/MIGRATE.md), [qmux](https://github.com/moq-dev/moq/blob/main/rs/qmux/MIGRATE.md) +- **Rust:** [hang](https://github.com/moq-dev/moq/blob/main/rs/hang/MIGRATE.md), [kio](https://github.com/moq-dev/moq/blob/main/rs/kio/MIGRATE.md), [kio-macros](https://github.com/moq-dev/moq/blob/main/rs/kio/macros/MIGRATE.md), [moq-archive](https://github.com/moq-dev/moq/blob/main/rs/moq-archive/MIGRATE.md), [moq-audio](https://github.com/moq-dev/moq/blob/main/rs/moq-audio/MIGRATE.md), [moq-auth](https://github.com/moq-dev/moq/blob/main/rs/moq-auth/MIGRATE.md), [moq-boy](https://github.com/moq-dev/moq/blob/main/rs/moq-boy/MIGRATE.md), [moq-crypto](https://github.com/moq-dev/moq/blob/main/rs/moq-crypto/MIGRATE.md), [moq-hls](https://github.com/moq-dev/moq/blob/main/rs/moq-hls/MIGRATE.md), [moq-json](https://github.com/moq-dev/moq/blob/main/rs/moq-json/MIGRATE.md), [moq-loc](https://github.com/moq-dev/moq/blob/main/rs/moq-loc/MIGRATE.md), [moq-msf](https://github.com/moq-dev/moq/blob/main/rs/moq-msf/MIGRATE.md), [moq-mux](https://github.com/moq-dev/moq/blob/main/rs/moq-mux/MIGRATE.md), [moq-net](https://github.com/moq-dev/moq/blob/main/rs/moq-net/MIGRATE.md), [moq-nvenc](https://github.com/moq-dev/moq/blob/main/rs/moq-nvenc/MIGRATE.md), [moq-pattern](https://github.com/moq-dev/moq/blob/main/rs/moq-pattern/MIGRATE.md), [moq-quic](https://github.com/moq-dev/moq/blob/main/rs/moq-quic/MIGRATE.md), [moq-room](https://github.com/moq-dev/moq/blob/main/rs/moq-room/MIGRATE.md), [moq-rtmp](https://github.com/moq-dev/moq/blob/main/rs/moq-rtmp/MIGRATE.md), [moq-sock](https://github.com/moq-dev/moq/blob/main/rs/moq-sock/MIGRATE.md), [moq-srt](https://github.com/moq-dev/moq/blob/main/rs/moq-srt/MIGRATE.md), [moq-stats](https://github.com/moq-dev/moq/blob/main/rs/moq-stats/MIGRATE.md), [moq-tokio](https://github.com/moq-dev/moq/blob/main/rs/moq-tokio/MIGRATE.md), [moq-transcode](https://github.com/moq-dev/moq/blob/main/rs/moq-transcode/MIGRATE.md), [moq-uring](https://github.com/moq-dev/moq/blob/main/rs/moq-uring/MIGRATE.md), [moq-v4l](https://github.com/moq-dev/moq/blob/main/rs/moq-v4l/MIGRATE.md), [moq-video](https://github.com/moq-dev/moq/blob/main/rs/moq-video/MIGRATE.md), [moq-webrtc (was moq-rtc)](https://github.com/moq-dev/moq/blob/main/rs/moq-webrtc/MIGRATE.md), [qmux](https://github.com/moq-dev/moq/blob/main/rs/qmux/MIGRATE.md) - **JavaScript:** [`@moq/auth`](https://github.com/moq-dev/moq/blob/main/js/auth/MIGRATE.md), [`@moq/boy`](https://github.com/moq-dev/moq/blob/main/js/moq-boy/MIGRATE.md), [`@moq/clock`](https://github.com/moq-dev/moq/blob/main/js/clock/MIGRATE.md), [`@moq/hang`](https://github.com/moq-dev/moq/blob/main/js/hang/MIGRATE.md), [`@moq/json`](https://github.com/moq-dev/moq/blob/main/js/json/MIGRATE.md), [`@moq/loc`](https://github.com/moq-dev/moq/blob/main/js/loc/MIGRATE.md), [`@moq/msf`](https://github.com/moq-dev/moq/blob/main/js/msf/MIGRATE.md), [`@moq/net`](https://github.com/moq-dev/moq/blob/main/js/net/MIGRATE.md), [`@moq/p2p`](https://github.com/moq-dev/moq/blob/main/js/p2p/MIGRATE.md), [`@moq/pattern`](https://github.com/moq-dev/moq/blob/main/js/pattern/MIGRATE.md), [`@moq/publish`](https://github.com/moq-dev/moq/blob/main/js/publish/MIGRATE.md), [`@moq/qmux`](https://github.com/moq-dev/moq/blob/main/js/qmux/MIGRATE.md), [`@moq/room`](https://github.com/moq-dev/moq/blob/main/js/room/MIGRATE.md), [`@moq/signals`](https://github.com/moq-dev/moq/blob/main/js/signals/MIGRATE.md), [`@moq/ui`](https://github.com/moq-dev/moq/blob/main/js/ui/MIGRATE.md), [`@moq/video`](https://github.com/moq-dev/moq/blob/main/js/video/MIGRATE.md), [`@moq/watch`](https://github.com/moq-dev/moq/blob/main/js/watch/MIGRATE.md) ## Unreleased These land with the next breaking release. +- **WebRTC moves to `moq-webrtc`.** The `moq-rtc` crate is renamed + `moq-webrtc`: replace `moq_rtc::` with `moq_webrtc::`. Its last release stays + on crates.io. moq-tokio's `webrtc` feature is gone: enable moq-webrtc's `p2p` + feature and use `moq_webrtc::p2p` instead of `moq_tokio::webrtc`, with + `offerer.connect(&client)` for `client.connect_webrtc(&offerer)` and + `answerer.accept(&listener)` for `listener.accept_webrtc(&answerer)`. The + ICE agent that was `moq-ice`, never published, is a private module of + moq-webrtc. moq-cli's `webrtc` cargo feature is gone: drop it from your + build; `import rtc` and `export rtc` never needed it. Nothing changes on the + wire. - **The default priority byte moves again.** Priorities are signed in every API, -128 to 127 with 0 unset, so nobody has to know that 127 is the middle of a byte. The wire keeps one byte and one urgency on both protocols, so an diff --git a/quest/m0/test-flakes-2/README.md b/quest/m0/test-flakes-2/README.md index 0ac762f0bc8..5b2604a27e7 100644 --- a/quest/m0/test-flakes-2/README.md +++ b/quest/m0/test-flakes-2/README.md @@ -49,7 +49,7 @@ The `rust-swapped -> js` and `rust -> js` browser audio timeouts were a lite-06 catalog group dropped mid-read ending the player's catalog, fixed by [moq-dev/moq#6820](https://github.com/moq-dev/moq/pull/6820). -moq-rtc's session-end test was never load-bound: on the paused clock, dimpl's +moq-webrtc's session-end test was never load-bound: on the paused clock, dimpl's randomly jittered DTLS handshake give-up raced ICE's establishment deadline, fixed by [moq-dev/moq#7379](https://github.com/moq-dev/moq/pull/7379). diff --git a/quest/m1/README.md b/quest/m1/README.md index 4e747bed9cb..7829e2597c6 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -52,7 +52,7 @@ moves what remains of them once their claims merge. - [TS fidelity and recovery](/quest/m1/ts-reliability/README.md) - both modes have explicit profiles, automated validation, loss tests, and a dedicated guide - [WebGPU on Safari](/quest/m1/webgpu-safari.md) - the WebGPU renderer is verified on Safari 26 for macOS and iOS - [Session policy lives in moq-net](/quest/m1/session-policy/README.md) - accept and connect deadlines, admission, window widening and reconnect live once in moq-net; moq-tokio and moq-relay's io_uring path call them -- [Vendor and trim the WebRTC stack](/quest/m1/webrtc-vendor.md) - str0m, dimpl, `is`, and sctp-proto live in moq-webrtc with unused code removed, so moq-rtc can take rind +- [Vendor and trim the WebRTC stack](/quest/m1/webrtc-vendor.md) - str0m, dimpl, `is`, and sctp-proto live in moq-webrtc with unused code removed, so moq-webrtc can take rind - [MoQ on rind](/quest/m1/rind/README.md) - every MoQ crate takes its crypto from rind, a pure-Rust graviola fork, so no build compiles C crypto - [VAAPI encode and decode](/quest/m1/video-vaapi.md) - H.265 encode and decode, pre-generated bindings, and pooled resize surfaces, including the moq-dev/vaapi release that carries them - [A relay forwards an upstream refusal's retry interval](/quest/m1/retry-interval-forward.md) - a forwarded SUBSCRIBE refusal keeps the upstream's retry interval diff --git a/quest/m1/rind/README.md b/quest/m1/rind/README.md index f74c02abd88..0334768c0b3 100644 --- a/quest/m1/rind/README.md +++ b/quest/m1/rind/README.md @@ -65,4 +65,4 @@ The epic's own work, once every child has merged: ## Required -- [moq-rtc on rind](/quest/m1/rind/rtc.md) - str0m and dimpl run DTLS, SRTP, and STUN on rind +- [moq-webrtc on rind](/quest/m1/rind/rtc.md) - str0m and dimpl run DTLS, SRTP, and STUN on rind diff --git a/quest/m1/rind/rtc.md b/quest/m1/rind/rtc.md index 3e694b8b923..f5d49e1844b 100644 --- a/quest/m1/rind/rtc.md +++ b/quest/m1/rind/rtc.md @@ -1,8 +1,8 @@ -# [M] moq-rtc on rind +# [M] moq-webrtc on rind ## Goal -moq-rtc and moq-ice run the vendored str0m and dimpl on rind: +moq-webrtc runs the vendored str0m and dimpl on rind: DTLS 1.2, SRTP (AES-CM-HMAC-SHA1-80 and AEAD AES-128/256-GCM), STUN MESSAGE-INTEGRITY, and DTLS certificates through `rind-rcgen`. Their graphs hold no aws-lc-rs or str0m-aws-lc-rs, and a browser still connects. diff --git a/quest/m1/session-policy/README.md b/quest/m1/session-policy/README.md index b632fb325f9..ab20224de18 100644 --- a/quest/m1/session-policy/README.md +++ b/quest/m1/session-policy/README.md @@ -20,9 +20,8 @@ maintainer asked what that means for io_uring and how much of moq-tokio belongs in moq-net, and decided: - ✅ **Move the policy first**, then give moq-tokio thin handoffs - (`Listener::accept_with`, `Client::connect_with`), which the - [WebRTC rename](/quest/m2/webrtc-rename.md) builds on (#7804 closed - unmerged). + (`Listener::accept_with`, `Client::connect_with`), which moq-webrtc's + data channel transport builds on (#7804 closed unmerged). Not chosen: a moq-tokio handoff now with the move later; moq-webrtc calling moq-net directly with its own policy. - ✅ **Reconnect is in scope**: the reconnect, backoff and GOAWAY candidate diff --git a/quest/m1/webrtc-vendor.md b/quest/m1/webrtc-vendor.md index 7f4abd186d5..6444c1f64bd 100644 --- a/quest/m1/webrtc-vendor.md +++ b/quest/m1/webrtc-vendor.md @@ -8,16 +8,12 @@ moq-webrtc builds str0m, dimpl, `is`, and sctp-proto from private in-tree module Decided 2026-10-30 with the maintainer (planning interview); see the [epic](/quest/m3/webrtc/README.md) for what goes and why. -Milestone: ✅ m1 (moved from m2, maintainer, 2026-11-03). Not chosen: keep it in m2, or send [moq-rtc on rind](/quest/m1/rind/rtc.md) back to m2. m1's [moq-rtc on rind](/quest/m1/rind/rtc.md) requires this, so it sits at the m1 top level. It stays a child of the m3 [WebRTC epic](/quest/m3/webrtc/README.md). +Milestone: ✅ m1 (moved from m2, maintainer, 2026-11-03). Not chosen: keep it in m2, or send [moq-webrtc on rind](/quest/m1/rind/rtc.md) back to m2. m1's [moq-webrtc on rind](/quest/m1/rind/rtc.md) requires this, so it sits at the m1 top level. It stays a child of the m3 [WebRTC epic](/quest/m3/webrtc/README.md). -- Vendor str0m and str0m-proto at the main-branch revision moq-dev/rind's `rind-str0m` targeted (`dc317173`, on dimpl 0.9 with str0m's pluggable crypto provider), with the dimpl, `is`, and sctp-proto versions it depends on (maintainer, 2026-10-31), so [moq-rtc on rind](/quest/m1/rind/rtc.md) can port rind's provider code unchanged. Commit them unchanged first so later diffs show only our changes, then trim. -- Remove: str0m's `bwe/`, leaky pacer, H.266, RED, DTMF, G.7xx and comfort noise, VLA and simulcast layers, RTCP XR and app feedback, stats, `_internal_test_exports`, the crypto backends other than the one rind will replace (keep the provider trait until [moq-rtc on rind](/quest/m1/rind/rtc.md)); dimpl's `dtls13/` and `auto.rs`. Keep upstream's tests for what remains. -- Keep dimpl's typed `TimeoutError::Handshake` through the vendored `dtls.rs`, which str0m flattens into `CryptoError::Other(String)`, and replace moq-ice's text match for it with a typed match if [the typed DTLS timeout](/quest/m3/webrtc/dtls-timeout.md) has landed. +- Vendor str0m and str0m-proto at the main-branch revision moq-dev/rind's `rind-str0m` targeted (`dc317173`, on dimpl 0.9 with str0m's pluggable crypto provider), with the dimpl, `is`, and sctp-proto versions it depends on (maintainer, 2026-10-31), so [moq-webrtc on rind](/quest/m1/rind/rtc.md) can port rind's provider code unchanged. Commit them unchanged first so later diffs show only our changes, then trim. +- Remove: str0m's `bwe/`, leaky pacer, H.266, RED, DTMF, G.7xx and comfort noise, VLA and simulcast layers, RTCP XR and app feedback, stats, `_internal_test_exports`, the crypto backends other than the one rind will replace (keep the provider trait until [moq-webrtc on rind](/quest/m1/rind/rtc.md)); dimpl's `dtls13/` and `auto.rs`. Keep upstream's tests for what remains. +- Keep dimpl's typed `TimeoutError::Handshake` through the vendored `dtls.rs`, which str0m flattens into `CryptoError::Other(String)`, and replace moq-webrtc's ICE module's text match for it with a typed match if [the typed DTLS timeout](/quest/m3/webrtc/dtls-timeout.md) has landed. - Keep the license files and record each upstream version in the module docs. - Drop the crates.io dependencies on str0m and friends from the workspace once nothing uses them. -Public API: none beyond what [rename](/quest/m2/webrtc-rename.md) changed. Wire: unchanged; the same DTLS 1.2 suites and SRTP profiles are offered. - -## Required - -- [Rename moq-rtc to moq-webrtc](/quest/m2/webrtc-rename.md) - the crate the stack is vendored into +Public API: none. Wire: unchanged; the same DTLS 1.2 suites and SRTP profiles are offered. diff --git a/quest/m2/README.md b/quest/m2/README.md index bbcb7530f43..36a4502f68c 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -184,7 +184,6 @@ quests that require them. - [Finalize moq-lite-07](/quest/m2/lite07-finalize.md) - when the maintainer cuts it, lite-07 negotiates as `moq-lite-07` and the next release ships it - [Unbounded groups](/quest/m2/unbounded-groups/README.md) - groups and frames lose their size caps; a group keeps a 32 MB tail, and readers behind it replay through paced flights or refresh - [Session policy lives in moq-net](/quest/m1/session-policy/README.md) - accept and connect deadlines, admission, window widening and reconnect live once in moq-net; moq-tokio and moq-relay's io_uring path call them (held in m1 by an open claim) -- [Rename moq-rtc to moq-webrtc](/quest/m2/webrtc-rename.md) - one published `moq-webrtc` crate holds the gateway, the ICE driver, and the data-channel transport - [MoQ on rind](/quest/m1/rind/README.md) - every MoQ crate takes its crypto from rind, a pure-Rust graviola fork, so no build compiles C crypto (held in m1 by an open claim) - [Cut readiness](/quest/m2/cut-gate/README.md) - the checks the cut needs that break nothing: main no slower than release, vendored fixes ported, and moq-c at parity - [Probe](/quest/m2/probe/README.md) - a session probes up to the bitrate it wants to send or receive, so a stopped simulcast rendition resumes and a viewer up-switches; browser padding is parked in m3 (held in m2 by open claims; moves to m3) diff --git a/quest/m2/webrtc-rename.md b/quest/m2/webrtc-rename.md deleted file mode 100644 index f0504dd4bf3..00000000000 --- a/quest/m2/webrtc-rename.md +++ /dev/null @@ -1,23 +0,0 @@ -# [M] Rename moq-rtc to moq-webrtc - -## Goal - -The published `moq-webrtc` crate holds what `moq-rtc`, `moq-ice`, and moq-tokio's `webrtc` feature hold today: the WHIP/WHEP gateway, the ICE driver, and the native data-channel connect/accept. `moq-rtc` and `moq-ice` are gone from the workspace, and moq-tokio has no `webrtc` feature. - -## Plan - -Decided 2026-10-30 with the maintainer (planning interview); see the [epic](/quest/m3/webrtc/README.md). - -Milestone: ✅ m1 (moved from m2, maintainer, 2026-11-03). Not chosen: keep it in m2, or send [moq-rtc on rind](/quest/m1/rind/rtc.md) back to m2. [Vendor and trim the WebRTC stack](/quest/m1/webrtc-vendor.md) requires this, and m1's rind epic requires the vendoring, so this sits at the m2 top level. It stays a child of the m3 [WebRTC epic](/quest/m3/webrtc/README.md). - -- Move `rs/moq-rtc` to `rs/moq-webrtc` and merge `rs/moq-ice` in as a module. Keep the gateway's `server` feature; add a feature for the data-channel transport so WHIP/WHEP-only builds skip SCTP. -- Move moq-tokio's `webrtc` module (`rs/moq-tokio/src/webrtc.rs`, host gathering, `.local` resolution) into moq-webrtc, built on moq-tokio's public session types. Its connect and accept go through moq-tokio's `connect_with`/`accept_with` handoffs, which run moq-net's session policy over the established data channel. The handoffs take the qmux session and bound only the MoQ handshake from the call; bounding ICE and the channel coming up (moq-tokio's wrappers use the listen and connect timeouts today) moves with the transport, so moq-webrtc needs its own establishment bound. -- Boundary decided 2026-11-04 (maintainer, from [moq-dev/moq#7804](https://github.com/moq-dev/moq/pull/7804)): ✅ move session policy into moq-net first ([Session policy lives in moq-net](/quest/m1/session-policy/README.md)), then this rename uses the thin handoffs. Not chosen: a moq-tokio handoff over today's policy, or moq-webrtc calling moq-net with its own policy. Removing SCTP stays with [Vendor and trim the WebRTC stack](/quest/m1/webrtc-vendor.md). -- Update moq-cli's `rtc` subcommand, the bindings or examples that use the transport, `test/p2p`, and every doc and quest naming the old crates. -- Publishing: the last `moq-rtc`/`moq-ice` releases stay on crates.io; `doc/setup/upgrade.md` says where things moved. Version numbers are the maintainer's. - -Public API: breaking (crate rename; `moq_tokio::webrtc` moves). Wire: none. - -## Related - -- [moq-rtc REMB and TIAS](/rs/moq-rtc/src/server/whip.rs) - #7373 added the capped answer in moq-rtc; carry it through the move diff --git a/quest/m3/README.md b/quest/m3/README.md index 4026818f465..15c76c26f91 100644 --- a/quest/m3/README.md +++ b/quest/m3/README.md @@ -89,7 +89,7 @@ federation) land. - [A moq-transport group head fills its hole in place](/quest/m3/ietf-fill-refill.md) - fills and joining FETCHes write into the tail's group, deleting the `Fill` handoff - [One port](/quest/m3/one-port/README.md) - one UDP port carries QUIC, SRT, and WebRTC media through an embedder hook, and one TCP port carries HTTP, RTMP, and RTMPS - [WebSocket caps](/quest/m3/rate-websocket.md) - paced reads and writes over bounded socket buffers hold WebSocket to the same caps -- [moq-rtc pacing](/quest/m3/rtc-pacing.md) - a capped WHEP viewer never receives more than its cap plus burst, NACK resends included +- [moq-webrtc pacing](/quest/m3/rtc-pacing.md) - a capped WHEP viewer never receives more than its cap plus burst, NACK resends included - [SRT rate handle](/quest/m3/srt-rate-handle.md) - a per-connection cap paces SRT pulls, retransmits included, and closes SRT publishers past it - [One port on the io_uring workers](/quest/m3/uring-demux.md) - `moq-uring`'s workers host the UDP demux, so a ring relay keeps WebRTC media and SRT on its QUIC port - [Synced data playback](/quest/m3/watch-data-sync.md) - js/watch releases JSON and binary payloads on the media playhead, and a slow data track holds media back @@ -142,7 +142,7 @@ federation) land. - [Audio's Latest start reaches back](/quest/m3/audio-latest-reach-back.md) - moq_audio's start covers min plus warmup like other consumers - [moq-lite tails count drops](/quest/m3/lite-tail-drop-count.md) - SUBSCRIBE_DROP accounting replaces the session-tail grace from lite-05 - [Audio track changes are gapless](/quest/m3/gapless-audio-switch.md) - no silence beyond a frame on audio format or rendition changes, enforced by media QA -- [We own our WebRTC stack](/quest/m3/webrtc/README.md) - moq-rtc becomes moq-webrtc with moq-ice, the data-channel transport, and a vendored, trimmed str0m/dimpl/is/sctp-proto +- [We own our WebRTC stack](/quest/m3/webrtc/README.md) - one moq-webrtc crate holds the gateway, its ICE module, the data-channel transport, and a vendored, trimmed str0m/dimpl/is/sctp-proto - [PUBLISH_DONE says why](/quest/m3/publish-done-codes.md) - GOING_AWAY, TOO_FAR_BEHIND, and EXPIRED round-trip as stream codes - [A revoked announce resets instead of FINning](/quest/m3/announce-revoke-reset.md) - a PUBLISH_NAMESPACE revoked after its OK resets with INTERNAL_ERROR, per draft-22 §6.4.2.3 - [moq repair refuses a live recording](/quest/m3/mp4-repair-lock.md) - the recorder's advisory lock keeps `moq repair mp4` off a file still being written diff --git a/quest/m3/audit-compile-time.md b/quest/m3/audit-compile-time.md index 6aab5fa379c..ba9248eda58 100644 --- a/quest/m3/audit-compile-time.md +++ b/quest/m3/audit-compile-time.md @@ -309,7 +309,7 @@ instantiating the whole map. - Explained, no action: aws-lc-sys's build script remains the longest unit in clean builds; the crypto provider stays (m0). usage-rs derive output scales with config fields and is external code. serde visitors per - deserializer are inherent to TOML config. moq-rtmp, moq-srt and moq-rtc + deserializer are inherent to TOML config. moq-rtmp, moq-srt and moq-webrtc entry points generic over `impl Into` instantiate their async bodies in the `moq` bin (20,327 lines with drop glue, 1.8%); a non-generic inner function would move them, but adds code for little. The catalog JSON diff diff --git a/quest/m3/audit-test-coverage.md b/quest/m3/audit-test-coverage.md index ba40fcdcccb..564bc39d7b4 100644 --- a/quest/m3/audit-test-coverage.md +++ b/quest/m3/audit-test-coverage.md @@ -80,6 +80,10 @@ Lines covered / measured: | moq-v4l | 9 / 1457 | moq-video | 6462 / 9988 | | carla bridge (demo) | 923 / 1676 | | | +moq-rtc, moq-ice, and moq-tokio's `webrtc` module have since merged into +moq-webrtc, so its report compares with moq-rtc plus moq-ice, and moq-tokio's +row above still counts the moved module. + | JS package | Lines | Unloaded files | JS package | Lines | Unloaded files | | --- | --- | --- | --- | --- | --- | | common | 200 / 250 | 5 | loc | 127 / 145 | 0 | diff --git a/quest/m3/crates-trusted-publisher.md b/quest/m3/crates-trusted-publisher.md index 8bd29a4fb36..5072291a2b0 100644 --- a/quest/m3/crates-trusted-publisher.md +++ b/quest/m3/crates-trusted-publisher.md @@ -10,7 +10,7 @@ Delete this quest once every crate has one. ## Waiting - Maintainer: after [the cut](/quest/m3/release/cut.md) publishes kio-macros, moq-bench, - moq-c, moq-congestion, moq-crypto, moq-ice, moq-quic, and moq-rtsp by token, add + moq-c, moq-congestion, moq-crypto, moq-quic, moq-rtsp, and moq-webrtc by token, add their trusted publishers the same way. Settings pages need a crates.io login, so check with a `release-rs.yml` run that publishes through OIDC. @@ -36,14 +36,14 @@ such crate here. Decided 2026-11-02 (maintainer, /quest-unblock): the maintainer is adding the publishers now, each with repository `moq-dev/moq`, workflow `release-rs.yml`, and environment -`publish` (the job runs in it). Already on crates.io (31): hang, kio, libmoq, +`publish` (the job runs in it). Already on crates.io (30): hang, kio, libmoq, moq-archive, moq-audio, moq-auth, moq-boy, moq-cli, moq-ffi, moq-gst, moq-hls, moq-json, moq-loc, moq-msf, moq-mux, moq-native, moq-net, moq-nvenc, -moq-pattern, moq-relay, moq-rtc, moq-rtmp, moq-sock, moq-srt, moq-stats, +moq-pattern, moq-relay, moq-rtmp, moq-sock, moq-srt, moq-stats, moq-tokio, moq-transcode, moq-uring, moq-v4l, moq-video, qmux. Not yet published (7), so their first publish needs the token and they get a trusted -publisher after it: kio-macros, moq-c, moq-congestion, moq-crypto, moq-ice, -moq-quic, moq-rtsp. moq-crypto became publishable in +publisher after it: kio-macros, moq-c, moq-congestion, moq-crypto, +moq-quic, moq-rtsp, moq-webrtc. moq-crypto became publishable in [moq-dev/moq#7733](https://github.com/moq-dev/moq/pull/7733). `CARGO_REGISTRY_TOKEN` is revoked only after all of them have one. Settings pages need a crates.io login, so the check is a `release-rs.yml` run publishing through OIDC. diff --git a/quest/m3/one-port/README.md b/quest/m3/one-port/README.md index c3190f00d06..12cbb4bf848 100644 --- a/quest/m3/one-port/README.md +++ b/quest/m3/one-port/README.md @@ -26,7 +26,7 @@ STUN's only consumer is P2P, deferred to m2. SRT is not blocked upstream: sans-io `srt-protocol` directly instead of waiting on a socket abstraction in srt-tokio. -Decided 2026-10-05, from moq.pro's audit: `moq-rtc` taking a fed socket +Decided 2026-10-05, from moq.pro's audit: `moq-webrtc` taking a fed socket ([rtc-feed](/quest/m3/one-port/rtc-feed.md)) joins this line, and [the io_uring demux](/quest/m3/uring-demux.md) is planned beside it, all in m2 rather than m3, since moq.pro's edge cutover and its uring rollout wait on @@ -76,7 +76,7 @@ One OS socket, or one shard of a reuseport group, is read by the QUIC endpoint's own socket, which keeps QUIC in place and copies every other class into that stack's bounded feed, shared by every shard. Sends go straight to the shared socket, so every stack answers from the same address -and port. `moq-rtc`'s `Mux` already demuxes STUN by ufrag +and port. `moq-webrtc`'s `Mux` already demuxes STUN by ufrag internally and takes a fed socket in [WebRTC on the shared socket](/quest/m3/one-port/rtc-feed.md). SRT skips `srt-tokio`, which accepts a `tokio::net::UdpSocket` but no abstraction, and feeds @@ -95,7 +95,7 @@ so the shared port never answers public Binding requests. ## Required -- [WebRTC on the shared socket](/quest/m3/one-port/rtc-feed.md) - `moq-rtc` serves WHIP and WHEP media from the WebRTC hook and pins ICE tuples +- [WebRTC on the shared socket](/quest/m3/one-port/rtc-feed.md) - `moq-webrtc` serves WHIP and WHEP media from the WebRTC hook and pins ICE tuples - [SRT on the shared socket](/quest/m3/one-port/srt-demux.md) - moq-srt drives `srt-protocol` on demuxed packets and the flow table pins its 4-tuples ## Related diff --git a/quest/m3/one-port/rtc-feed.md b/quest/m3/one-port/rtc-feed.md index a6c34505cc3..4cf24bf8699 100644 --- a/quest/m3/one-port/rtc-feed.md +++ b/quest/m3/one-port/rtc-feed.md @@ -2,7 +2,7 @@ ## Goal -`moq-rtc`'s server serves WHIP and WHEP media from a socket it is fed rather +`moq-webrtc`'s server serves WHIP and WHEP media from a socket it is fed rather than one it binds: datagrams arrive from the demux's WebRTC hook, replies go out through the shared socket, ICE candidates advertise the shared address, and every 4-tuple ICE selects is pinned to WebRTC in the demux's flow table. @@ -11,9 +11,9 @@ Binding its own socket keeps working unchanged. ## Plan Decided 2026-10-05: this is upstream's work, reversing the 2026-09-30 -narrowing that left `Mux::feed` to the embedder. `moq-rtc` is an upstream, +narrowing that left `Mux::feed` to the embedder. `moq-webrtc` is an upstream, generic crate, so every embedder of the one-port demux gets WebRTC without -reaching into its internals. A standalone `moq-rtc` quest was rejected: the +reaching into its internals. A standalone `moq-webrtc` quest was rejected: the work only matters beside the demux, so it ships in this line. Decided 2026-10-05: the API is a socket choice in the server config plus a @@ -37,22 +37,22 @@ pub enum Socket { } ``` -Build on `moq-ice` (split out in #5702) rather than beside it. -`moq_ice::Socket { udp, locals, inbound }` already separates the advertised +Build on moq-webrtc's ICE module (split out in #5702) rather than beside it. +moq-webrtc's `ice::Socket { udp, locals, inbound }` already separates the advertised host candidates (`locals`, from `ice_candidates`) from the bound address and takes routed datagrams on its `Inbound` queue, and the server mux -(`rs/moq-rtc/src/server/mux.rs`) already routes its own `recv_from` loop +(`rs/moq-webrtc/src/server/mux.rs`) already routes its own `recv_from` loop into per-session `Inbound`s. What is left is the send side and the mux's -read loop: `moq_ice::Socket`'s `udp: Arc` becomes -`Arc` (`Transmit` lives in `moq-ice`, and `UdpSocket` +read loop: moq-webrtc's `ice::Socket`'s `udp: Arc` becomes +`Arc` (`Transmit` lives in moq-webrtc's ICE module, and `UdpSocket` implements it, so the bound case behaves as today), and a fed mux routes datagrams from the demux hook instead of reading a bound socket. Adapt the sketch above to that: `advertised` is `ice_candidates`, and `recv` feeds the mux's existing router. Address-family mapping follows the real socket, not the advertisement: a dual-stack socket bound to `[::]` may advertise a public IPv4 address, so the `Transmit` impl owns the IPv4-mapped conversion -`moq-ice` applies today. Received and pinned addresses use the same -`moq_ice::canonical` form the demux's flow table keys on, or no pin ever +moq-webrtc's ICE module applies today. Received and pinned addresses use the same +moq-webrtc's `ice::canonical` form the demux's flow table keys on, or no pin ever matches. When ICE selects a pair, the remote address goes out on `pinned`, so the demux routes that tuple to WebRTC before any SRT test (see the @@ -63,7 +63,7 @@ unpin message or idle expiry in the flow table, as SRT's pins have. The demux side has landed: `moq_tokio::quic::demux::WebRtc` (from `Demux::webrtc`, or `moq_relay::Relay::webrtc` for an embedded relay) yields ICE checks and responses, DTLS, and RTP as `Datagram`s whose `remote` is already in -`moq_ice::canonical` form, sends a `Transmit` from the shared port (mapping an +moq-webrtc's `ice::canonical` form, sends a `Transmit` from the shared port (mapping an IPv4 destination for an AF_INET6 socket), and pins a remote with `pin`, which returns a guard that releases the pin on drop. So the fed `Socket` takes a `WebRtc` rather than the channels in the sketch, and the mux holds a `Pin` per diff --git a/quest/m3/rtc-pacing.md b/quest/m3/rtc-pacing.md index 7fe0a8574c2..92206ab8cda 100644 --- a/quest/m3/rtc-pacing.md +++ b/quest/m3/rtc-pacing.md @@ -1,13 +1,13 @@ -# [M] moq-rtc paces WHEP viewers to a cap, NACKs included +# [M] moq-webrtc paces WHEP viewers to a cap, NACKs included ## Goal -An embedder can give a `moq-rtc` WHEP session a bitrate cap, and moq-rtc +An embedder can give a `moq-webrtc` WHEP session a bitrate cap, and moq-webrtc never sends that viewer more media payload than the cap plus a burst, retransmits included. The cap counts payload, unlike the QUIC send cap (`moq_quic::Limits::send_rate`), which counts whole ack-eliciting packets, QUIC overhead included. RTP, SRTP, and UDP overhead sits outside -it: moq-rtc picks the packet sizes, so the overhead per payload byte is +it: moq-webrtc picks the packet sizes, so the overhead per payload byte is fixed, and the viewer can't inflate it. This backs moq.pro's egress caps. @@ -30,7 +30,7 @@ WHEP enforcement needs it and nobody owned it. - NACK resends draw from the same rate-plus-burst bucket as the frame pacer, and a resend with no credit left is skipped, so faking loss only spends the credit the viewer's next group would have used. str0m fulfils NACKs from - its video send buffer (`rs/moq-rtc/src/session.rs`), so charging needs a + its video send buffer (`rs/moq-webrtc/src/session.rs`), so charging needs a hook on that path. Decided 2026-10-30 (maintainer): add it to the vendored str0m ([WebRTC epic](/quest/m3/webrtc/README.md)) rather than upstream. - Decided 2026-10-30 (maintainer): the pacer is moq-congestion's, made public and @@ -56,7 +56,7 @@ WHEP enforcement needs it and nobody owned it. caps, each NACKing every packet for several burst windows, stay under their own cap plus burst. -Public API: a rate handle on moq-rtc's WHEP server. Decided 2026-10-30 +Public API: a rate handle on moq-webrtc's WHEP server. Decided 2026-10-30 (maintainer): `whep::accept` takes the same shape as `whip::accept`, a `whep::Request` struct with `Request::with_rate(rate::Limit)`, replacing its argument list rather than adding a fifth argument. Wire: none. diff --git a/quest/m3/spawn-audit.md b/quest/m3/spawn-audit.md index 9c5396f5a83..d2616809e79 100644 --- a/quest/m3/spawn-audit.md +++ b/quest/m3/spawn-audit.md @@ -35,7 +35,7 @@ As of `main` today the spawning library crates include moq-tokio (connection, server, client), moq-relay (web, shutdown, uring), moq-mux's container consumer, moq-hls's server (its path follower and each -broadcaster's driver), moq-rtmp, moq-rtsp, moq-srt, moq-rtc, moq-transcode, +broadcaster's driver), moq-rtmp, moq-rtsp, moq-srt, moq-webrtc, moq-transcode, moq-video's encode producer, moq-cli's play path, moq-bench, and qmux's transport. Recount with `rg 'tokio::spawn|spawn_local|task::spawn'` outside tests, benches, and binaries before starting. diff --git a/quest/m3/srt-rate-handle.md b/quest/m3/srt-rate-handle.md index 205c2351b58..b359a861551 100644 --- a/quest/m3/srt-rate-handle.md +++ b/quest/m3/srt-rate-handle.md @@ -31,7 +31,7 @@ enforcement needs it and nobody owned it. is released gradually instead of waiting forever or exceeding cap plus burst. Decide drops only before a group starts: past cap plus burst, skip to the next group; dropping 188-byte TS packets would leave partial - frames. As in [moq-rtc pacing](/quest/m3/rtc-pacing.md), a group (or + frames. As in [moq-webrtc pacing](/quest/m3/rtc-pacing.md), a group (or frame) larger than the burst is paced through to its end. Retransmissions draw from the same bucket, and one with no credit left is skipped, which needs the hook `srt-protocol`'s sender exposes when driven @@ -60,5 +60,5 @@ Wire: none. ## Related -- [moq-rtc pacing](/quest/m3/rtc-pacing.md) - the same pacing and retransmit charging on WHEP +- [moq-webrtc pacing](/quest/m3/rtc-pacing.md) - the same pacing and retransmit charging on WHEP - [moq-srt wire source](/quest/m3/wire-stats/srt.md) - per-connection byte counts from the same socket diff --git a/quest/m3/stats/rust.md b/quest/m3/stats/rust.md index d928e61802a..b6389eec934 100644 --- a/quest/m3/stats/rust.md +++ b/quest/m3/stats/rust.md @@ -31,7 +31,7 @@ - Audio capture: `capture::Samples::gap` only flags that buffers were dropped. Counting `skipped` needs the drop size, converted to codec frames. - The gateways build their catalogs in their own crates (`moq-rtmp`, - `moq-srt`, `moq-rtc`, `moq-archive`; `hls` and `rtsp` build theirs in + `moq-srt`, `moq-webrtc`, `moq-archive`; `hls` and `rtsp` build theirs in `rs/moq-cli`), so each needs a way to name the stats track and the echo path before its first catalog, and a reporter to run beside each session's catalog. The report writer lives in `rs/moq-cli/src/report.rs` and reads the diff --git a/quest/m3/uring-demux.md b/quest/m3/uring-demux.md index f156d05cbb6..830c3625c7a 100644 --- a/quest/m3/uring-demux.md +++ b/quest/m3/uring-demux.md @@ -28,10 +28,10 @@ the QUIC endpoint. The classifier, pin table, per-source `Queue`, and listener's socket does inline in its receive; only QUIC continues into the endpoint. Until this lands, `moq_relay::Relay::webrtc` refuses an io_uring relay. The worker is thread-per-core and `!Send`, while the consumers -of the other classes (`moq-rtc`, `moq-srt`) run on +of the other classes (`moq-webrtc`, `moq-srt`) run on tokio, so non-QUIC datagrams cross to them on a `Send` channel, and their replies come back through a remote-send path into the owning worker's ring, -which is what a fed `moq-rtc` takes as its `Transmit` +which is what a fed `moq-webrtc` takes as its `Transmit` ([WebRTC on the shared socket](/quest/m3/one-port/rtc-feed.md)). A flow pinned on one shard keeps landing there because reuseport steers only QUIC by connection ID. diff --git a/quest/m3/webrtc/README.md b/quest/m3/webrtc/README.md index fe056582f6c..77ee17af793 100644 --- a/quest/m3/webrtc/README.md +++ b/quest/m3/webrtc/README.md @@ -2,7 +2,7 @@ ## Goal -All of MoQ's WebRTC lives in one published crate, `moq-webrtc` (today's `moq-rtc` renamed), holding the WHIP/WHEP gateway, the ICE driver from `moq-ice`, the native data-channel transport from `moq-tokio`, and vendored copies of str0m, dimpl, `is`, and sctp-proto. Fixes to the stack land in normal MoQ PRs instead of waiting on upstream, and code MoQ doesn't use is gone. +All of MoQ's WebRTC lives in one published crate, `moq-webrtc`, holding the WHIP/WHEP gateway, the ICE driver, the native data-channel transport (`p2p`), and vendored copies of str0m, dimpl, `is`, and sctp-proto. Fixes to the stack land in normal MoQ PRs instead of waiting on upstream, and code MoQ doesn't use is gone. Non-goals: TURN; DTLS 1.3; replacing a vendored layer before there's a reason to. @@ -11,16 +11,15 @@ Non-goals: TURN; DTLS 1.3; replacing a vendored layer before there's a reason to Decided 2026-10-30 with the maintainer (planning interview), after the str0m workarounds piled up: one `b=` line per SDP media section ([moq-dev/moq#7373](https://github.com/moq-dev/moq/pull/7373)), DTLS retransmits running out before ICE connects ([moq-dev/moq#7379](https://github.com/moq-dev/moq/pull/7379)), no hook to charge or serve NACK resends ([rtc-pacing](/quest/m3/rtc-pacing.md)), and `std::time::Instant` in a `kio::clock` workspace. No upstream reports were approved; vendoring replaces them. - **Vendor, then replace.** Copy the upstream crates in, trim them, and fix them in-tree. Replacing a layer with our own (SDP, RTP/RTCP, SRTP, SCTP) is a later child once a concrete need appears; none is planned yet. -- **One crate.** `moq-ice` merges into it, since its only users are `moq-rtc` and moq-tokio's data-channel transport. moq-tokio's `webrtc` feature moves into `moq-webrtc` as well, which breaks the cycle (`moq-webrtc` depends on moq-tokio; moq-tokio would otherwise need ICE and SCTP). The vendored crates become private modules, not separate published crates, keeping their MIT/Apache-2.0 notices (str0m's `packet/` carries webrtc-rs's Apache notice). +- **One crate.** The ICE driver (once `moq-ice`) and moq-tokio's former `webrtc` data-channel transport live in `moq-webrtc`, which depends on moq-tokio rather than the reverse, so moq-tokio needs no ICE or SCTP. The vendored crates become private modules, not separate published crates, keeping their MIT/Apache-2.0 notices (str0m's `packet/` carries webrtc-rs's Apache notice). - **What goes** (from the 2026-10-30 inventory: we use frame mode, full ICE, and DTLS 1.2, and never enable str0m's BWE, pacer, or stats): GCC bandwidth estimation (8k lines; GCC is ported into `moq-congestion` as `moq_congestion::gcc`), the leaky pacer (replaced by moq-congestion's pacer, made public by [rtc-pacing](/quest/m3/rtc-pacing.md)), H.266, RED, DTMF, G.7xx and comfort noise, VLA and simulcast layers, RTCP XR and app feedback, stats, internal test exports, and dimpl's DTLS 1.3 and version auto-selection. Roughly 17k of str0m's 72k lines and 11k of dimpl's 33k. -- **DTLS 1.2 only.** Every browser negotiates 1.2 today. [moq-rtc on rind](/quest/m1/rind/rtc.md) narrows to 1.2 to match. +- **DTLS 1.2 only.** Every browser negotiates 1.2 today. [moq-webrtc on rind](/quest/m1/rind/rtc.md) narrows to 1.2 to match. - **SCTP stays**, for browser data channels in [P2P](/quest/m4/p2p/README.md), but compiles only with the data-channel feature, so WHIP/WHEP builds carry none of it. Vendored, it can later be simplified or put on moq-congestion. - **Upstream fixes:** after vendoring, nobody merges upstream automatically. Record the vendored upstream versions in the crate docs; the release-cut audit checks the upstream changelogs for security fixes (malformed SRTP/RTCP input, for example) and ports them. -- Docs a change makes stale (crate names, `doc/lib/rs`, `doc/setup/upgrade.md`, other quests naming `moq-rtc` or `moq-ice`) change in the PR that makes them stale. +- Docs a change makes stale (crate names, `doc/lib/rs`, `doc/setup/upgrade.md`, other quests naming a crate or module) change in the PR that makes them stale. ## Required -- [Rename moq-rtc to moq-webrtc](/quest/m2/webrtc-rename.md) - one crate holds the gateway, the ICE driver, and the data-channel transport - [Vendor and trim the stack](/quest/m1/webrtc-vendor.md) - str0m, dimpl, `is`, and sctp-proto live in moq-webrtc with unused code removed - [A typed DTLS handshake timeout error](/quest/m3/webrtc/dtls-timeout.md) - callers match a DTLS handshake timeout by variant, and session end treats it like an ICE timeout - [Several bandwidth lines per media section](/quest/m3/webrtc/sdp-bandwidth.md) - answers carry both `b=TIAS` and `b=AS` without splicing @@ -29,5 +28,5 @@ Decided 2026-10-30 with the maintainer (planning interview), after the str0m wor ## Related -- [moq-rtc paces WHEP viewers](/quest/m3/rtc-pacing.md) - adds the NACK hook and the shared pacer on the vendored stack -- [moq-rtc on rind](/quest/m1/rind/rtc.md) - the vendored DTLS and SRTP take rind's crypto +- [moq-webrtc paces WHEP viewers](/quest/m3/rtc-pacing.md) - adds the NACK hook and the shared pacer on the vendored stack +- [moq-webrtc on rind](/quest/m1/rind/rtc.md) - the vendored DTLS and SRTP take rind's crypto diff --git a/quest/m3/webrtc/dtls-after-ice.md b/quest/m3/webrtc/dtls-after-ice.md index fc634dcaeba..c34b7e56d2e 100644 --- a/quest/m3/webrtc/dtls-after-ice.md +++ b/quest/m3/webrtc/dtls-after-ice.md @@ -6,7 +6,7 @@ DTLS sends its first flight only once ICE has nominated a pair, so a peer whose ## Plan -Decided 2026-10-30 with the maintainer (planning interview). Today DTLS starts before ICE connects and dimpl gives up after 1+2+4+8+16 s with jitter (`dimpl/src/config.rs:90-92`), racing moq-ice's 30 s deadline; [moq-dev/moq#7379](https://github.com/moq-dev/moq/pull/7379) papered over the race by reporting an early DTLS failure as a timeout. Hold DTLS activation (around str0m's `lib.rs:1493`) until nomination, then remove #7379's remapping if nothing else needs it. Test on the paused clock: ICE nominating at 29 s still completes DTLS. Added 2026-10-31 from [moq-dev/moq#7379](https://github.com/moq-dev/moq/pull/7379): also test that a DTLS failure after ICE has connected still reports a DTLS error (`moq_ice::Error::Rtc`, or the [typed handshake timeout](/quest/m3/webrtc/dtls-timeout.md)), not `Timeout` (moq-rtc's `IceTimeout`), so the remapping (or its removal) only ever changes a failure before nomination. +Decided 2026-10-30 with the maintainer (planning interview). Today DTLS starts before ICE connects and dimpl gives up after 1+2+4+8+16 s with jitter (`dimpl/src/config.rs:90-92`), racing moq-webrtc's ICE module's 30 s deadline; [moq-dev/moq#7379](https://github.com/moq-dev/moq/pull/7379) papered over the race by reporting an early DTLS failure as a timeout. Hold DTLS activation (around str0m's `lib.rs:1493`) until nomination, then remove #7379's remapping if nothing else needs it. Test on the paused clock: ICE nominating at 29 s still completes DTLS. Added 2026-10-31 from [moq-dev/moq#7379](https://github.com/moq-dev/moq/pull/7379): also test that a DTLS failure after ICE has connected still reports a DTLS error (moq-webrtc's `ice::Error::Rtc`, or the [typed handshake timeout](/quest/m3/webrtc/dtls-timeout.md)), not `Timeout` (moq-webrtc's `IceTimeout`), so the remapping (or its removal) only ever changes a failure before nomination. Public API: none. Wire: none. diff --git a/quest/m3/webrtc/dtls-timeout.md b/quest/m3/webrtc/dtls-timeout.md index 8a83c145d9e..222a45ec27d 100644 --- a/quest/m3/webrtc/dtls-timeout.md +++ b/quest/m3/webrtc/dtls-timeout.md @@ -3,29 +3,28 @@ ## Goal A DTLS handshake that times out after ICE connects surfaces as its own error -variant in `moq-ice` and `moq-rtc` (or `moq-webrtc`, after the -[rename](/quest/m2/webrtc-rename.md)), so callers match it instead of the text +variant in moq-webrtc's ICE module and gateway, so callers match it instead of the text `rtc error: DTLS error: timeout: handshake` inside `Error::Rtc(String)`. Session-end handling and logging treat it like an ICE timeout: `session::end` logs it at debug as abandoned-session churn, not as a warning. ## Plan -Today `Agent::drain` (`rs/moq-ice/src/agent.rs`) maps any DTLS failure before +Today `Agent::drain` (`rs/moq-webrtc/src/ice/agent.rs`) maps any DTLS failure before ICE connects to `Error::Timeout`, and stringifies everything else. str0m flattens dimpl's typed `Error::Timeout(TimeoutError::Handshake)` into `CryptoError::Other(String)` (`str0m/src/dtls.rs`), so the variant is lost -before moq-ice sees it. +before moq-webrtc's ICE module sees it. -- Classify it once at the str0m boundary in moq-ice, the only place that sees +- Classify it once at the str0m boundary in moq-webrtc's ICE module, the only place that sees str0m's error. Until the [vendored stack](/quest/m1/webrtc-vendor.md) lands, that is a text match there, pinned by a test against the crate's real message. If the vendoring lands first, carry dimpl's variant through the vendored `dtls.rs` typed instead, and add no text match. Otherwise the vendoring quest replaces the match; its plan says so. -- Add the variant to `moq_ice::Error` and `moq_rtc::Error`, named by role (for - example `DtlsTimeout`), and map it in `moq-rtc`'s session loop and moq-tokio's - `webrtc` transport, which also matches `moq_ice::Error`. +- Add the variant to moq-webrtc's `ice::Error` and `moq_webrtc::Error`, named by role (for + example `DtlsTimeout`), and map it in `moq-webrtc`'s session loop and its + `p2p` transport, which also matches moq-webrtc's `ice::Error`. - Decide in the PR whether the variant stays distinct from `IceTimeout` or folds into one establishment-timeout variant, and record why. Distinct is recommended: an ICE timeout means no path, a DTLS timeout means a path that diff --git a/quest/m3/wire-stats/README.md b/quest/m3/wire-stats/README.md index 63d743742bc..038b0c4c03f 100644 --- a/quest/m3/wire-stats/README.md +++ b/quest/m3/wire-stats/README.md @@ -16,7 +16,7 @@ excluded: ACKs, and retransmits. - **WebSocket:** the TCP stream's bytes, which include TLS, WebSocket, and qmux framing and retransmits. -- **Gateways an embedder terminates:** SRT through moq-srt's source. moq-rtc +- **Gateways an embedder terminates:** SRT through moq-srt's source. moq-webrtc exposes none since #6454 removed its unused one; it returns only with an adapter a consumer registers. An embedder terminating RTMP on its own socket registers that socket's `TCP_INFO` counts; moq-rtmp's own `Server` and diff --git a/quest/m4/p2p/native-quic.md b/quest/m4/p2p/native-quic.md index b8baaac4a31..4c856bbd7df 100644 --- a/quest/m4/p2p/native-quic.md +++ b/quest/m4/p2p/native-quic.md @@ -7,7 +7,7 @@ selected by their applications connect directly across a NAT: ICE finds a path through host and server-reflexive candidates, then a `moq-quic` connection runs over the nominated pair, with each side's certificate pinned by the fingerprint the other sent in its offer or answer. A pair with a -browser still uses a data channel (`moq_tokio::webrtc`). +browser still uses a data channel (`moq_webrtc::p2p`). ## Plan @@ -18,12 +18,12 @@ Decided with the maintainer on 2026-10-13: the relay as rendezvous and fallback. - ICE is str0m's standalone sans-IO agent, the `is` crate (0.11, already in the lockfile through str0m; str0m re-exports it as `str0m::ice`). Gather - candidates with `moq_tokio::webrtc`'s host gathering, `.local` resolution, - and the STUN Binding client in `moq-ice`; don't copy them. The first two - are private to the data channel transport today, so move them into - `moq-ice` rather than export them from `moq-tokio`. Decided 2026-10-30 (maintainer): `moq-ice`, - the data-channel transport, and a vendored `is` all move into - `moq-webrtc` ([rename](/quest/m2/webrtc-rename.md)); take them from there. + candidates with `moq_webrtc::p2p`'s host gathering, `.local` resolution, + and the STUN Binding client in moq-webrtc's ICE module; don't copy them. The first two + are private to the data channel transport today, so move them into the + ICE module. Decided 2026-10-30 (maintainer): the ICE driver, the + data-channel transport, and a vendored `is` all live in `moq-webrtc`; + take them from there. - QUIC is `moq-quic`, fed datagrams from the nominated pair. - Authentication: each side generates a self-signed certificate and sends its SHA-256 fingerprint in its offer or answer, as DTLS fingerprints ride diff --git a/rs/justfile b/rs/justfile index 40071ca2224..e0f3c2b130a 100644 --- a/rs/justfile +++ b/rs/justfile @@ -264,7 +264,7 @@ features: run bash sh/local.sh cargo check --locked -p moq-boy --no-default-features # Alone, since the workspace's `kio/sim` dev-dependencies would unify `kio/async` back in. run bash sh/local.sh cargo check --locked --manifest-path rs/moq-auth/Cargo.toml --lib --all-features - run bash sh/local.sh cargo check --locked -p moq-hls -p moq-rtmp -p moq-rtc --no-default-features --all-targets + run bash sh/local.sh cargo check --locked -p moq-hls -p moq-rtmp -p moq-webrtc --no-default-features --all-targets run bash sh/local.sh cargo clippy --locked --workspace {{ no_fuzz }} --all-targets --all-features -- -D warnings run env RUSTDOCFLAGS="-D warnings" bash sh/local.sh cargo doc --locked --workspace {{ no_fuzz }} --all-features --no-deps run bash sh/rs/nextest.sh cargo nextest run --locked --workspace {{ no_fuzz }} --all-targets --all-features diff --git a/rs/moq-cli/Cargo.toml b/rs/moq-cli/Cargo.toml index 740a9d9586b..cd5e84b9ba8 100644 --- a/rs/moq-cli/Cargo.toml +++ b/rs/moq-cli/Cargo.toml @@ -36,8 +36,6 @@ quic = ["moq-tokio/quic"] # congestion-control testing. qlog = ["moq-tokio/qlog"] websocket = ["moq-tokio/websocket"] -# Native WebRTC data channels, for holding sessions with browser peers. -webrtc = ["moq-tokio/webrtc"] # The cloud object stores `export archive` and `import archive` reach (`s3://`, # `gs://`, `az://`), signing through rind and connecting through reqwest. Local # `file://` URLs need none of them. @@ -118,7 +116,6 @@ moq-mux = { workspace = true, features = ["async"] } # Cluster, LAN mesh, and inbound `/.cluster` auth. default-features off so the # CLI's own feature set (quic, cluster-lan) is what selects them. moq-relay = { workspace = true } -moq-rtc = { workspace = true } moq-rtmp = { workspace = true } moq-rtsp = { workspace = true } moq-srt = { workspace = true } @@ -126,6 +123,7 @@ moq-srt = { workspace = true } moq-tokio = { workspace = true, default-features = false, features = ["tcp", "uds", "watch"] } moq-transcode = { workspace = true, optional = true } moq-video = { workspace = true, optional = true } +moq-webrtc = { workspace = true } object_store = { workspace = true, features = ["fs"] } percent-encoding = { workspace = true } pollster = { workspace = true, optional = true } diff --git a/rs/moq-cli/src/rtc.rs b/rs/moq-cli/src/rtc.rs index 9d5a8a8727b..2065dc1f6f3 100644 --- a/rs/moq-cli/src/rtc.rs +++ b/rs/moq-cli/src/rtc.rs @@ -62,7 +62,7 @@ pub async fn listen_import(target: ImportTarget, listen: Listen) -> anyhow::Resu config.max_age = target.max_age; config.bandwidth = target.bandwidth; config.linger = target.linger; - let server = moq_rtc::Server::new(config); + let server = moq_webrtc::Server::new(config); serve(server.publish_router(publisher), "WHIP", listen).await } @@ -74,7 +74,7 @@ pub async fn listen_export(origin: moq_net::origin::Consumer, name: String, list let subscriber = origin .scope("", &scope) .with_context(|| format!("failed to scope origin to broadcast `{name}`"))?; - let server = moq_rtc::Server::new(server_config(&listen)); + let server = moq_webrtc::Server::new(server_config(&listen)); serve(server.subscribe_router(subscriber), "WHEP", listen).await } @@ -105,10 +105,10 @@ pub async fn connect_import(target: ImportTarget, url: Url, instance: moq_net::I tracing::info!(url = %RedactedUrl::new(&url), %name, "WHEP client pulling"); notify_ready(); - let mut config = moq_rtc::client::Config::default(); + let mut config = moq_webrtc::client::Config::default(); config.max_age = target.max_age; config.bandwidth = target.bandwidth; - let client = moq_rtc::Client::new(config); + let client = moq_webrtc::Client::new(config); client.subscribe(url, route.broadcast().clone()).await?; Ok(()) } @@ -128,13 +128,13 @@ pub async fn connect_export(origin: moq_net::origin::Consumer, url: Url, name: S tracing::info!(url = %RedactedUrl::new(&url), %name, "WHIP client pushing"); notify_ready(); - let client = moq_rtc::Client::new(moq_rtc::client::Config::default()); + let client = moq_webrtc::Client::new(moq_webrtc::client::Config::default()); client.publish(url, source).await?; Ok(()) } -fn server_config(listen: &Listen) -> moq_rtc::server::Config { - let mut config = moq_rtc::server::Config::default(); +fn server_config(listen: &Listen) -> moq_webrtc::server::Config { + let mut config = moq_webrtc::server::Config::default(); config.udp_bind = listen.udp_bind; config.ice_candidates.clone_from(&listen.public_addr); config diff --git a/rs/moq-hls/src/lib.rs b/rs/moq-hls/src/lib.rs index 84b384d5879..31fa623e46d 100644 --- a/rs/moq-hls/src/lib.rs +++ b/rs/moq-hls/src/lib.rs @@ -1,7 +1,7 @@ //! HLS / LL-HLS <-> MoQ gateway. //! //! Bridges HLS (and Low-Latency HLS) and [`moq_net`] broadcasts in both -//! directions, mirroring the WHIP/WHEP split in `moq-rtc`: +//! directions, mirroring the WHIP/WHEP split in `moq-webrtc`: //! //! - [`import`] pulls a remote HLS master/media playlist and publishes its CMAF //! segments into MoQ (an HTTP *client* that *publishes*). diff --git a/rs/moq-ice/CHANGELOG.md b/rs/moq-ice/CHANGELOG.md deleted file mode 100644 index 2a718d0b3af..00000000000 --- a/rs/moq-ice/CHANGELOG.md +++ /dev/null @@ -1,12 +0,0 @@ -# Changelog - -All notable changes to this project will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [Unreleased] - -### Added - -- First release: the ICE agent shared by `moq-tokio`'s WebRTC data channel transport and `moq-rtc`'s WHIP/WHEP gateway, with a STUN Binding client and per-peer wire counters. diff --git a/rs/moq-ice/Cargo.toml b/rs/moq-ice/Cargo.toml deleted file mode 100644 index 6b533666d2e..00000000000 --- a/rs/moq-ice/Cargo.toml +++ /dev/null @@ -1,28 +0,0 @@ -[package] -name = "moq-ice" -description = "Media over QUIC - drives a str0m WebRTC connection's ICE over a tokio UDP socket" -authors = ["Luke Curley"] -repository = "https://github.com/moq-dev/moq" -license = "MIT OR Apache-2.0" - -version = "0.1.0" -edition = "2024" -rust-version.workspace = true - -keywords = ["webrtc", "ice", "stun", "str0m", "moq"] -categories = ["network-programming", "multimedia"] - -[dependencies] -kio = { workspace = true, features = ["runtime"] } -str0m = { workspace = true } -stun-types = { workspace = true } -thiserror = { workspace = true } -tokio = { workspace = true, features = ["macros", "net", "rt", "sync"] } -tracing = { workspace = true } - -[dev-dependencies] -tokio = { workspace = true, features = ["macros", "rt-multi-thread", "test-util"] } -workspace-hack = { path = "../workspace-hack" } - -[lints] -workspace = true diff --git a/rs/moq-ice/MIGRATE.md b/rs/moq-ice/MIGRATE.md deleted file mode 100644 index 4be91a0b380..00000000000 --- a/rs/moq-ice/MIGRATE.md +++ /dev/null @@ -1,5 +0,0 @@ -# Migrating moq-ice - -How to update your code for each breaking change, newest first. - -## Unreleased diff --git a/rs/moq-ice/README.md b/rs/moq-ice/README.md deleted file mode 100644 index 5c840fc8a02..00000000000 --- a/rs/moq-ice/README.md +++ /dev/null @@ -1,12 +0,0 @@ -# moq-ice - -Drives a [str0m](https://github.com/algesten/str0m) WebRTC connection over a -tokio UDP socket: the run loop that feeds it datagrams and timeouts, a STUN -Binding client for server-reflexive candidates, and per-peer wire counters. - -str0m is sans-IO and requires every mutation to be followed by draining its -output. `Agent::rtc_mut` hands out a guard that drains when dropped, so callers -can't forget. - -This is internal infrastructure with no API stability promise: `moq-tokio`'s `webrtc` feature -builds MoQ data channels on it, and `moq-rtc` builds its WHIP/WHEP gateway. diff --git a/rs/moq-rtmp/README.md b/rs/moq-rtmp/README.md index 0319ea0d121..e08e391d9e6 100644 --- a/rs/moq-rtmp/README.md +++ b/rs/moq-rtmp/README.md @@ -7,7 +7,7 @@ both directions with [`moq-mux`](../moq-mux): on **publish** it re-wraps a client's messages as FLV tags, demuxes them, and publishes the result into a MoQ origin as ordinary broadcasts; on **play** it subscribes to a broadcast from the origin, muxes it back to FLV, and streams the tags down to the player. It's the -sibling of `moq-srt`, `moq-cli` HLS import/export, and `moq-rtc`'s WHIP/WHEP. Both +sibling of `moq-srt`, `moq-cli` HLS import/export, and `moq-webrtc`'s WHIP/WHEP. Both legacy RTMP (H.264 + AAC) and enhanced RTMP (E-RTMP: HEVC, AV1, VP9, Opus, AC-3) work in each direction, since the codec handling lives in the `moq-mux` FLV demuxer/muxer. Pure Rust: the protocol is provided by `rml_rtmp`, with no librtmp diff --git a/rs/moq-rtmp/src/lib.rs b/rs/moq-rtmp/src/lib.rs index 6a558f11696..bfcc19084fa 100644 --- a/rs/moq-rtmp/src/lib.rs +++ b/rs/moq-rtmp/src/lib.rs @@ -8,7 +8,7 @@ //! its audio/video messages as FLV tags, demux them with [`moq_mux`], and //! publish the result into a [`moq_net::origin::Producer`] as ordinary MoQ //! broadcasts. This is the contribution-ingest analogue of `moq-srt`, -//! `moq-cli import ... hls`, and `moq-rtc`'s WHIP. +//! `moq-cli import ... hls`, and `moq-webrtc`'s WHIP. //! - **Play (egress)**: a client (VLC, ffplay, mpv) pulls //! `rtmp://host//`; we subscribe to that broadcast from a //! [`moq_net::origin::Consumer`], mux it back to FLV with [`moq_mux`], and stream diff --git a/rs/moq-sock/src/demux.rs b/rs/moq-sock/src/demux.rs index 37617b4c9cb..b830be36215 100644 --- a/rs/moq-sock/src/demux.rs +++ b/rs/moq-sock/src/demux.rs @@ -150,7 +150,7 @@ impl Counters { /// Keyed by the remote address alone: the local port is the socket's, and a /// remote address reaching two of a wildcard socket's local addresses is /// treated as one flow. IPv4-mapped addresses are folded to IPv4, as -/// `moq_ice::canonical` does, so a dual-stack socket's pins match. +/// moq-webrtc's ICE agent does, so a dual-stack socket's pins match. #[derive(Clone, Debug, Default)] pub struct Flows(Arc); diff --git a/rs/moq-srt/README.md b/rs/moq-srt/README.md index 0db652251a7..d729b7b4215 100644 --- a/rs/moq-srt/README.md +++ b/rs/moq-srt/README.md @@ -8,7 +8,7 @@ by its stream id `m=` mode: - `m=publish` (the default): ingest. Demux the connection's transport stream with [`moq-mux`](../moq-mux) and publish it into a MoQ origin as an ordinary broadcast. The contribution-ingest analogue of `moq-cli` HLS import and - `moq-rtc`'s WHIP. Once a second it logs the importer's per-stream counters + `moq-webrtc`'s WHIP. Once a second it logs the importer's per-stream counters the way `moq import ts` does, so a PID that goes silent behind a running mux is named. - `m=request`: egress. Re-mux a broadcast from the origin back to MPEG-TS and diff --git a/rs/moq-srt/src/lib.rs b/rs/moq-srt/src/lib.rs index 9fdf3715dca..a5749eb8e9b 100644 --- a/rs/moq-srt/src/lib.rs +++ b/rs/moq-srt/src/lib.rs @@ -6,7 +6,7 @@ //! //! - `m=publish` (the default): demux the MPEG-TS the connection carries with //! [`moq_mux`] and publish it into the origin as an ordinary broadcast. The -//! contribution-ingest analogue of `moq-cli import ... hls` and `moq-rtc`'s WHIP. +//! contribution-ingest analogue of `moq-cli import ... hls` and `moq-webrtc`'s WHIP. //! - `m=request`: re-mux a broadcast from the origin back to MPEG-TS and stream //! it to the caller, so a plain SRT player (VLC, ffmpeg) can watch it. //! diff --git a/rs/moq-tokio/Cargo.toml b/rs/moq-tokio/Cargo.toml index a7abbcc4092..93ff10d314f 100644 --- a/rs/moq-tokio/Cargo.toml +++ b/rs/moq-tokio/Cargo.toml @@ -39,14 +39,15 @@ qlog = ["moq-quic?/qlog"] # LAN peer discovery over mDNS (the `mdns` module). mdns = ["dep:mdns-sd"] jemalloc = ["dep:tikv-jemallocator", "dep:tikv-jemalloc-ctl"] -websocket = ["_transport", "dep:qmux", "watch", "dep:dns-lookup"] +websocket = ["qmux", "watch", "dep:dns-lookup"] # Qmux over TCP: plaintext `tcp://`, and `tls://`. Server-side and client-side. -tcp = ["_transport", "dep:qmux", "dep:dns-lookup", "dep:tokio-rustls"] +tcp = ["qmux", "dep:dns-lookup", "dep:tokio-rustls"] +# MoQ over a qmux session established elsewhere, such as moq-webrtc's data channel: +# `Client::connect_with` and `Listener::accept_with`. Every qmux transport turns it on. +qmux = ["_transport", "dep:qmux"] # Unix-domain-socket qmux transport (`unix://`), unix-only. Adds peer-credential # inspection on accept. Pulls in `tcp` (shares qmux's stream transport). uds = ["tcp", "qmux/uds"] -# Native WebRTC data channels over str0m, with a full ICE agent (the `webrtc` module). -webrtc = ["_transport", "dep:qmux", "dep:moq-ice", "dep:str0m", "dep:if-addrs", "dep:mdns-sd"] # Inside `kio::clock::sim::run`, detached tasks spawn on kio's deterministic simulator, # and with `driver`, `quic::driver::sim` carries datagrams over seeded, impaired # `moq_quic::sim::Link`s with no sockets. Turns on no transport of its own. Hidden from the @@ -63,14 +64,11 @@ hex = { workspace = true } http = { version = "1", optional = true } humantime = { workspace = true } humantime-serde = { workspace = true } -if-addrs = { workspace = true, optional = true } kio = { workspace = true, features = ["async", "runtime"] } mdns-sd = { workspace = true, optional = true } moq-congestion = { workspace = true, optional = true } # rind's rustls provider and the `UnsupportedCpu` error, re-exported as `crypto`. Needs no moq-net. moq-crypto = { workspace = true, features = ["provider"] } -# The ICE agent behind the `webrtc` module. Private, like str0m: neither appears in this crate's API. -moq-ice = { workspace = true, optional = true } moq-net = { workspace = true, optional = true } # The QUIC state machine `quic::driver` drives; rind supplies its cryptography. moq-quic = { workspace = true, optional = true } @@ -89,7 +87,6 @@ rustls-platform-verifier = "0.7" rustls-webpki = { version = "0.103", default-features = false, features = ["std"], optional = true } serde = { version = "1", features = ["derive"] } serde_with = { version = "3", features = ["hex"] } -str0m = { workspace = true, optional = true } thiserror = "2" tikv-jemalloc-ctl = { version = "0.7", optional = true } tikv-jemallocator = { version = "0.7", features = ["profiling", "unprefixed_malloc_on_supported_platforms"], optional = true } @@ -145,8 +142,6 @@ rind-rustls = { workspace = true } # worker tests can prove a stopped group closed its own, and port reservations # that never listen, so a test needn't release a port another test could take. socket2 = { workspace = true, features = ["all"] } -# A fake STUN server for the WebRTC server-reflexive candidate test. -stun-types = { workspace = true } tempfile = "3" # test-util adds tokio::time::pause/auto-advance for the time-dependent tests. tokio = { workspace = true, features = ["test-util"] } diff --git a/rs/moq-tokio/src/client.rs b/rs/moq-tokio/src/client.rs index de61056a724..985ed0d635a 100644 --- a/rs/moq-tokio/src/client.rs +++ b/rs/moq-tokio/src/client.rs @@ -327,7 +327,7 @@ impl Client { /// /// The connect timeout bounds the MoQ handshake from this call. A transport handed /// over cannot be redialed, so there is no reconnect: the session ends with it. - #[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] + #[cfg(feature = "qmux")] pub async fn connect_with(&self, session: qmux::Session) -> crate::Result { let timeout = self.policy.timeout; let connect = connect_session(&self.moq, session); @@ -342,39 +342,6 @@ impl Client { .await } - /// Run a MoQ client session over the data channel an [`crate::webrtc::Offerer`] opened. - /// - /// The connect timeout bounds ICE and the channel coming up, then - /// [`Self::connect_with`] bounds the MoQ handshake. A peer link cannot be redialed, so - /// there is no reconnect: the session ends with the peer connection. - #[cfg(feature = "webrtc")] - pub async fn connect_webrtc(&self, peer: &crate::webrtc::Offerer) -> crate::Result { - let protocol = peer.protocol(); - if !self.versions.alpns().contains(&protocol) { - return Err(crate::webrtc::Error::Protocol(protocol.to_string()).into()); - } - - let establish = async { - let opened = peer.channel().await?; - let session = qmux::Session::connect(opened.channel, opened.config).await?; - Ok::<_, crate::webrtc::Error>(crate::spawn_qmux(session)) - }; - let timeout = self.policy.timeout; - let session = crate::runtime::scope(async move { - match timeout.is_zero() { - true => Ok(establish.await?), - false => kio::clock::timeout(timeout, establish) - .await - .map_err(|_| Error::ConnectTimeout(timeout))? - .map_err(Error::from), - } - }) - .await?; - let session = self.connect_with(session).await?; - tracing::info!(version = %session.version(), transport = %crate::Transport::WebRtc, "connected"); - Ok(session) - } - /// Dial one attempt of a [`Connection`]'s policy and complete the MoQ handshake. /// /// Errors if no transport feature is compiled in. diff --git a/rs/moq-tokio/src/error.rs b/rs/moq-tokio/src/error.rs index 628d0155897..d368f26a22a 100644 --- a/rs/moq-tokio/src/error.rs +++ b/rs/moq-tokio/src/error.rs @@ -255,14 +255,9 @@ pub enum Error { #[error(transparent)] Unix(Arc), - /// The WebRTC data channel transport failed. - #[cfg(feature = "webrtc")] - #[error(transparent)] - WebRtc(Arc), - /// A qmux session refused the limits [`crate::server::Request::with_quic_limits`] set, /// such as a rate cap, which qmux cannot pace. - #[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] + #[cfg(feature = "qmux")] #[error("qmux refused the session limits: {0}")] QmuxLimits(String), } @@ -433,13 +428,6 @@ impl From for Error { } } -#[cfg(feature = "webrtc")] -impl From for Error { - fn from(err: crate::webrtc::Error) -> Self { - Self::WebRtc(Arc::new(err)) - } -} - /// Convenience alias for results produced by this crate. pub type Result = std::result::Result; diff --git a/rs/moq-tokio/src/lib.rs b/rs/moq-tokio/src/lib.rs index 79169664e45..74c4a3ce25e 100644 --- a/rs/moq-tokio/src/lib.rs +++ b/rs/moq-tokio/src/lib.rs @@ -6,7 +6,7 @@ //! - WebSocket (fallback via [web-transport-ws](https://crates.io/crates/web-transport-ws)) //! - TCP via the `tcp://` (plaintext) and `tls://` schemes (qmux; requires `tcp` feature) //! - Unix domain socket via the `unix://` scheme (qmux, peer-credential aware; requires `uds` feature, unix-only) -//! - A WebRTC data channel with a browser peer, signaled by the caller (qmux; requires `webrtc` feature) +//! - A qmux session established elsewhere, such as over a WebRTC data channel (requires `qmux` feature) //! //! With `net`, `client::Client` connects to relays; transport features enable //! `server::Server` for accepting connections. The `mdns` feature finds peers on the local network. @@ -77,19 +77,16 @@ pub mod worker; mod util; #[cfg(feature = "watch")] pub mod watch; -#[cfg(feature = "webrtc")] -#[doc(hidden)] -pub mod webrtc; #[cfg(feature = "websocket")] pub mod websocket; -/// Session settings for every qmux transport (WebSocket, `tcp://`, `tls://`, `unix://`, WebRTC), +/// Session settings for every qmux transport moq-tokio establishes (WebSocket, `tcp://`, `tls://`, `unix://`), /// with `quic`'s windows and stream count. /// /// A qmux session leases receive credit as QUIC does, so it takes the same per-session /// numbers rather than qmux's own defaults. moq-lite holds a stream open per subscription, /// past qmux's default of 100, where a peer's opens would wait on credit forever. -#[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] +#[cfg(any(feature = "websocket", feature = "tcp"))] fn qmux_config(quic: &quic::Resolved) -> qmux::Config { let mut config = qmux::Config::default(); config.limits = quic.limits(); @@ -98,13 +95,13 @@ fn qmux_config(quic: &quic::Resolved) -> qmux::Config { /// [`qmux_config`] at the `[quic]` defaults, for a server's qmux sessions, which widen once /// admitted (see [`server::Request::with_quic_limits`]). -#[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] +#[cfg(any(feature = "websocket", feature = "tcp"))] fn qmux_default() -> qmux::Config { qmux_config(&quic::Resolved::default()) } /// Run a qmux session's driver on the runtime, handing back the session. -#[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] +#[cfg(any(feature = "websocket", feature = "tcp"))] fn spawn_qmux( (session, driver): (qmux::Session, qmux::Driver), ) -> qmux::Session { diff --git a/rs/moq-tokio/src/quic.rs b/rs/moq-tokio/src/quic.rs index 0006d909ab4..4976a826cb0 100644 --- a/rs/moq-tokio/src/quic.rs +++ b/rs/moq-tokio/src/quic.rs @@ -746,9 +746,9 @@ impl Resolved { moq_quic::transport::keep_alive_interval(self.keep_alive, idle_timeout) } - /// The flow-control limits as moq-quic spells them. + /// The flow-control limits as moq-quic and qmux spell them. #[cfg(feature = "_transport")] - pub(crate) fn limits(&self) -> moq_quic::Limits { + pub fn limits(&self) -> moq_quic::Limits { use std::num::NonZeroU64; let mut limits = moq_quic::Limits::default(); diff --git a/rs/moq-tokio/src/server.rs b/rs/moq-tokio/src/server.rs index dd105872cab..a2eb3a8924a 100644 --- a/rs/moq-tokio/src/server.rs +++ b/rs/moq-tokio/src/server.rs @@ -16,8 +16,8 @@ use url::Url; // the stream listeners hand back an already-built `Request`. #[cfg(any(feature = "quic", feature = "websocket"))] use futures::FutureExt; -// The pending handshakes of the transports `Server` accepts itself; WebRTC -// signaling is the caller's, so a WebRTC-only build has none. +// The pending handshakes of the transports `Server` accepts itself; a session +// handed to `accept_with` is established by the caller, so a `qmux`-only build has none. #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] use futures::{ future::BoxFuture, @@ -222,6 +222,7 @@ impl Config { pub struct Server { activity: moq_net::server::Activity, moq: moq_net::Server, + #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] versions: moq_net::Versions, #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] /// Pending handshakes, each isolated: one panicking (`None`) must not end the listener. @@ -431,6 +432,7 @@ impl Server { #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] accept: Default::default(), moq, + #[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] versions, #[cfg(any(feature = "tcp", all(feature = "uds", unix)))] streams, @@ -537,8 +539,8 @@ impl Server { } #[cfg(not(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix))))] - /// Fails, since no compiled transport is one this server listens on (WebRTC - /// sessions arrive through [`Listener::accept_webrtc`]). + /// Fails, since no compiled transport is one this server listens on (a session + /// established elsewhere arrives through `Listener::accept_with`). async fn accept_next(&mut self) -> crate::Result { Err(Error::NoBackend("no listener to accept from")) } @@ -857,7 +859,10 @@ impl Listener { /// accept deadline counts from this call and bounds SETUP, admission, and the reply; /// establishing the session is the caller's to bound. Returns [`Error::Stopped`] once /// the listener is closing. - #[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] + /// + /// To have a drain wait for a session still being established, hold a guard from + /// [`Self::activity`] until this call returns. + #[cfg(feature = "qmux")] pub async fn accept_with( &self, transport: Transport, @@ -871,38 +876,11 @@ impl Listener { crate::runtime::scope(Request::accept_qmux(&server.moq, session, incoming)).await } - /// Read the MoQ SETUP from the data channel the remote peer opened on an - /// [`crate::webrtc::Answerer`], leaving admission to the returned [`Request`]. - /// - /// The handshake timeout bounds ICE and the channel coming up, then - /// [`Self::accept_with`] bounds the MoQ handshake. The channel must carry the - /// answerer's protocol, a MoQ ALPN this server speaks. Returns [`Error::Stopped`] once - /// the listener is closing. - #[cfg(feature = "webrtc")] - pub async fn accept_webrtc(&self, peer: &crate::webrtc::Answerer) -> crate::Result { - use crate::webrtc::Error as WebRtcError; - - // Counted toward the drain while establishing; a drain admits `accept_with`'s own - // guard while this one is held, so the connection is tracked throughout. - let _establishing = self.server.activity.enter().ok_or(Error::Stopped)?; - if !self.server.versions.alpns().contains(&peer.protocol()) { - return Err(WebRtcError::Protocol(peer.protocol().to_string()).into()); - } - let deadline = self.server.moq.deadline(kio::clock::now()); - let establish = async { - let opened = peer.channel().await?; - if opened.protocol != peer.protocol() { - return Err(WebRtcError::Protocol(opened.protocol)); - } - let session = crate::spawn_qmux(qmux::Session::accept(opened.channel, opened.config).await?); - Ok((session, opened.protocol)) - }; - let (session, protocol) = crate::runtime::scope(within(deadline, establish)).await?; - let link = Link { - alpn: Some(protocol), - ..Default::default() - }; - self.accept_with(Transport::WebRtc, session, link).await + /// The accepted connections a drain waits for, including any session a guard from it + /// holds while it is established for [`Self::accept_with`]. + #[cfg(feature = "qmux")] + pub fn activity(&self) -> &moq_net::server::Activity { + &self.server.activity } /// Close every listener and connection, once each QUIC peer has been sent the @@ -1002,13 +980,7 @@ pub(crate) async fn accept_websocket( /// /// Nothing is established yet that could carry a close code, so an expired /// handshake is dropped, which closes its connection. -#[cfg(any( - feature = "quic", - feature = "websocket", - feature = "tcp", - all(feature = "uds", unix), - feature = "webrtc" -))] +#[cfg(any(feature = "quic", feature = "websocket", feature = "tcp", all(feature = "uds", unix)))] pub(crate) async fn within( deadline: Option, handshake: impl Future>, @@ -1388,7 +1360,7 @@ pub(crate) struct Incoming { pub active: moq_net::server::Active, } -#[cfg(any(test, feature = "websocket", feature = "tcp", feature = "webrtc"))] +#[cfg(any(test, feature = "qmux"))] impl Incoming { /// A connection with no facts beyond its transport. pub(crate) fn new( @@ -1419,7 +1391,7 @@ pub(crate) enum Under { Quic(crate::quic::driver::connection::Connection), /// A qmux session: WebSocket, `tcp://`, `tls://`, `unix://`, or one handed over with /// [`Listener::accept_with`]. - #[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] + #[cfg(feature = "qmux")] Qmux(qmux::Session), } @@ -1575,7 +1547,7 @@ impl Request { } /// [`Self::accept`] over a qmux session. - #[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] + #[cfg(feature = "qmux")] pub(crate) async fn accept_qmux( server: &moq_net::Server, session: qmux::Session, @@ -1694,7 +1666,7 @@ impl Request { Under::Opaque => {} #[cfg(feature = "quic")] Under::Quic(quic) => quic.set_limits(limits).expect("validated by with_quic_limits"), - #[cfg(any(feature = "websocket", feature = "tcp", feature = "webrtc"))] + #[cfg(feature = "qmux")] Under::Qmux(qmux) => { if let Err(err) = qmux.set_limits(limits) { self.handshake.close(moq_net::SessionError::Internal.into()); diff --git a/rs/moq-rtc/CHANGELOG.md b/rs/moq-webrtc/CHANGELOG.md similarity index 100% rename from rs/moq-rtc/CHANGELOG.md rename to rs/moq-webrtc/CHANGELOG.md diff --git a/rs/moq-rtc/Cargo.toml b/rs/moq-webrtc/Cargo.toml similarity index 63% rename from rs/moq-rtc/Cargo.toml rename to rs/moq-webrtc/Cargo.toml index 0ea7ca60820..9c935a71060 100644 --- a/rs/moq-rtc/Cargo.toml +++ b/rs/moq-webrtc/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "moq-rtc" -description = "WebRTC (WHIP/WHEP) gateway for Media over QUIC" +name = "moq-webrtc" +description = "Media over QUIC - WebRTC: the WHIP/WHEP gateway and data-channel sessions with browser peers" authors = ["Luke Curley "] repository = "https://github.com/moq-dev/moq" license = "MIT OR Apache-2.0" @@ -18,23 +18,31 @@ default = ["server"] # stack and calls `whip::accept` / `whep::accept` drops them with # `default-features = false`. server = ["dep:axum"] +# MoQ sessions over a WebRTC data channel with a browser peer (the `p2p` module): qmux +# over SCTP, host candidates per interface, and `.local` candidates resolved over mDNS. +p2p = ["dep:if-addrs", "dep:mdns-sd", "dep:qmux", "moq-tokio/qmux"] -# Pure library: the WHIP/WHEP <-> MoQ gateway (axum routers + WHEP/WHIP client). -# The CLI lives in `moq-cli` (the `rtc` subcommand); embedders mount the routers -# / dial with `Client` against their own origin. +# Pure library: the WHIP/WHEP <-> MoQ gateway (axum routers + WHEP/WHIP client), and +# with `p2p`, MoQ sessions over a data channel. The CLI lives in `moq-cli` (the `rtc` +# subcommand); embedders mount the routers / dial with `Client` against their own origin. [dependencies] axum = { workspace = true, optional = true } bytes = { workspace = true } hang = { workspace = true } +if-addrs = { workspace = true, optional = true } # Drives each str0m connection over its UDP socket. kio = { workspace = true, features = ["runtime"] } -moq-ice = { workspace = true } +mdns-sd = { workspace = true, optional = true } moq-mux = { workspace = true, features = ["async"] } moq-net = { workspace = true } -# `RedactedUrl` keeps a dialed URL's query token and userinfo out of the logs. +# `RedactedUrl` keeps a dialed URL's query token and userinfo out of the logs, and with +# `p2p`, `Client::connect_with` and `Listener::accept_with` run MoQ over the data channel. moq-tokio = { workspace = true } +qmux = { workspace = true, optional = true } reqwest = { workspace = true, features = ["rustls"] } str0m = { workspace = true } +# The STUN Binding client the ICE agent runs for server-reflexive candidates. +stun-types = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["full"] } tracing = { workspace = true } @@ -45,6 +53,8 @@ uuid = { version = "1", features = ["v4"] } # Signs the MESSAGE-INTEGRITY on a forged STUN binding request: str0m rejects a # request without one, and its own SHA1 provider is private. aws-lc-rs = { workspace = true } +# `poll!` checks what a data channel peer is still waiting on. +futures = { workspace = true } # The tests host their broadcasts on `origin::spawn`, and dial a session over TCP. moq-tokio = { workspace = true, features = ["net", "tcp"] } tokio = { workspace = true, features = ["test-util"] } diff --git a/rs/moq-rtc/MIGRATE.md b/rs/moq-webrtc/MIGRATE.md similarity index 100% rename from rs/moq-rtc/MIGRATE.md rename to rs/moq-webrtc/MIGRATE.md diff --git a/rs/moq-rtc/clippy.toml b/rs/moq-webrtc/clippy.toml similarity index 100% rename from rs/moq-rtc/clippy.toml rename to rs/moq-webrtc/clippy.toml diff --git a/rs/moq-rtc/src/client/mod.rs b/rs/moq-webrtc/src/client/mod.rs similarity index 100% rename from rs/moq-rtc/src/client/mod.rs rename to rs/moq-webrtc/src/client/mod.rs diff --git a/rs/moq-rtc/src/client/whep.rs b/rs/moq-webrtc/src/client/whep.rs similarity index 100% rename from rs/moq-rtc/src/client/whep.rs rename to rs/moq-webrtc/src/client/whep.rs diff --git a/rs/moq-rtc/src/client/whip.rs b/rs/moq-webrtc/src/client/whip.rs similarity index 100% rename from rs/moq-rtc/src/client/whip.rs rename to rs/moq-webrtc/src/client/whip.rs diff --git a/rs/moq-rtc/src/codec/av1.rs b/rs/moq-webrtc/src/codec/av1.rs similarity index 100% rename from rs/moq-rtc/src/codec/av1.rs rename to rs/moq-webrtc/src/codec/av1.rs diff --git a/rs/moq-rtc/src/codec/bitstream_test.rs b/rs/moq-webrtc/src/codec/bitstream_test.rs similarity index 98% rename from rs/moq-rtc/src/codec/bitstream_test.rs rename to rs/moq-webrtc/src/codec/bitstream_test.rs index 3f1e76df018..17555f7c500 100644 --- a/rs/moq-rtc/src/codec/bitstream_test.rs +++ b/rs/moq-webrtc/src/codec/bitstream_test.rs @@ -3,7 +3,7 @@ //! The H.264 Annex-B -> AVCC conversion is provided by `moq_mux::codec::h264`, //! but the WHIP path depends on the importer parsing the SPS for the catalog //! and accepting Annex-B input via the bridge. These tests guard against -//! regressions in the contract the moq-rtc bridge depends on. +//! regressions in the contract the moq-webrtc bridge depends on. //! //! Inline (rather than under `tests/`) because they exercise the crate-private //! `codec` module directly. @@ -170,7 +170,7 @@ async fn vp9_keyframe_publishes_dimensions_and_starts_group() { // - H.264 with avc3 storage (inline SPS/PPS): passthrough. // - H.264 with avc1 storage: length-prefix -> start-code with SPS+PPS // prefixed on every keyframe (regression in moq-mux already covers this; -// this test confirms moq-rtc's wrapper plumbs through correctly). +// this test confirms moq-webrtc's wrapper plumbs through correctly). #[tokio::test(start_paused = true)] async fn egress_opus_passthrough() { diff --git a/rs/moq-rtc/src/codec/h264.rs b/rs/moq-webrtc/src/codec/h264.rs similarity index 100% rename from rs/moq-rtc/src/codec/h264.rs rename to rs/moq-webrtc/src/codec/h264.rs diff --git a/rs/moq-rtc/src/codec/h265.rs b/rs/moq-webrtc/src/codec/h265.rs similarity index 100% rename from rs/moq-rtc/src/codec/h265.rs rename to rs/moq-webrtc/src/codec/h265.rs diff --git a/rs/moq-rtc/src/codec/mod.rs b/rs/moq-webrtc/src/codec/mod.rs similarity index 100% rename from rs/moq-rtc/src/codec/mod.rs rename to rs/moq-webrtc/src/codec/mod.rs diff --git a/rs/moq-rtc/src/codec/opus.rs b/rs/moq-webrtc/src/codec/opus.rs similarity index 100% rename from rs/moq-rtc/src/codec/opus.rs rename to rs/moq-webrtc/src/codec/opus.rs diff --git a/rs/moq-rtc/src/codec/vp8.rs b/rs/moq-webrtc/src/codec/vp8.rs similarity index 100% rename from rs/moq-rtc/src/codec/vp8.rs rename to rs/moq-webrtc/src/codec/vp8.rs diff --git a/rs/moq-rtc/src/codec/vp9.rs b/rs/moq-webrtc/src/codec/vp9.rs similarity index 100% rename from rs/moq-rtc/src/codec/vp9.rs rename to rs/moq-webrtc/src/codec/vp9.rs diff --git a/rs/moq-rtc/src/egress.rs b/rs/moq-webrtc/src/egress.rs similarity index 100% rename from rs/moq-rtc/src/egress.rs rename to rs/moq-webrtc/src/egress.rs diff --git a/rs/moq-rtc/src/error.rs b/rs/moq-webrtc/src/error.rs similarity index 100% rename from rs/moq-rtc/src/error.rs rename to rs/moq-webrtc/src/error.rs diff --git a/rs/moq-ice/src/agent.rs b/rs/moq-webrtc/src/ice/agent.rs similarity index 95% rename from rs/moq-ice/src/agent.rs rename to rs/moq-webrtc/src/ice/agent.rs index 95a5593e40e..9f12e59db7b 100644 --- a/rs/moq-ice/src/agent.rs +++ b/rs/moq-webrtc/src/ice/agent.rs @@ -12,7 +12,7 @@ use stun_types::message::{BINDING, Message, MessageClass, MessageWriteVec, Trans use stun_types::prelude::*; use tokio::net::UdpSocket; -use crate::{Inbound, Socket, Wire}; +use super::{Inbound, Socket}; /// Backstop deadline for reaching a connected ICE state, covering the one case /// str0m's agent deliberately never times out: a peer that provides no remote @@ -38,7 +38,6 @@ const STUN_LAST_WAIT: u32 = 16; /// Why an [`Agent`] stopped. #[derive(Debug, thiserror::Error)] -#[non_exhaustive] pub enum Error { /// The peer disconnected, str0m closed the connection, or the inbound queue ended. #[error("peer connection closed")] @@ -62,7 +61,6 @@ impl Error { /// What [`Agent::next`] surfaced. #[derive(Debug)] -#[non_exhaustive] #[expect( clippy::large_enum_variant, reason = "moved once per poll; boxing would allocate for every data channel message" @@ -71,6 +69,10 @@ pub enum Event { /// An event from str0m. ICE disconnection is reported as [`Error::Closed`] instead. Rtc(str0m::Event), /// A server-reflexive candidate, already added locally, to signal to the peer. + #[cfg_attr( + not(feature = "p2p"), + allow(dead_code, reason = "only the p2p transport gathers server-reflexive candidates") + )] Candidate(Candidate), /// Every STUN server answered or gave up: no more local candidates follow. Gathered, @@ -150,6 +152,10 @@ impl Agent { /// Ask each STUN server for this socket's public mapping, offering what comes /// back as a server-reflexive candidate. Servers of a family with no host /// candidate are skipped. + #[cfg_attr( + not(feature = "p2p"), + allow(dead_code, reason = "only the p2p transport gathers server-reflexive candidates") + )] pub fn with_stun(mut self, servers: &[SocketAddr]) -> Self { let now = Instant::now(); for &server in servers { @@ -180,6 +186,7 @@ impl Agent { /// Hold off the deadline for ICE to connect until the first [`Agent::rtc_mut`], /// for an offer whose answer has yet to arrive: signaling time is the caller's. + #[cfg_attr(not(feature = "p2p"), allow(dead_code, reason = "only the p2p transport offers"))] pub fn awaiting_answer(mut self) -> Self { self.started = None; self @@ -197,11 +204,6 @@ impl Agent { RtcMut(self) } - /// The counters of the bytes exchanged with the peer. - pub fn wire(&self) -> &Wire { - &self.inbound.wire - } - /// Drive the connection until it surfaces an [`Event`]. /// /// Cancel safe: the connection is always drained between calls, and a datagram @@ -317,7 +319,7 @@ impl Agent { Ok(len) => self.inbound.wire.sent(len), // Changes can keep coming while the socket stays full, so the backlog is // bounded like the inbound queue; ICE, SCTP, and RTP recover the loss. - Err(err) if err.kind() == std::io::ErrorKind::WouldBlock && self.outbox.len() < crate::INBOX => { + Err(err) if err.kind() == std::io::ErrorKind::WouldBlock && self.outbox.len() < crate::ice::INBOX => { self.outbox.push_back((data.to_vec(), dst)) } Err(err) if err.kind() == std::io::ErrorKind::WouldBlock => { @@ -479,7 +481,7 @@ mod tests { let socket = Arc::new(UdpSocket::bind("127.0.0.1:0").await.unwrap()); let peer = UdpSocket::bind("127.0.0.1:0").await.unwrap(); let local = socket.local_addr().unwrap(); - let inbound = crate::reader(socket.clone()); + let inbound = crate::ice::reader(socket.clone()); let wire = inbound.wire.clone(); let socket = Socket::new(socket, vec![local], inbound).unwrap(); let mut agent = Agent::new(Rtc::builder().build(Instant::now().into_std()), socket).unwrap(); @@ -489,13 +491,13 @@ mod tests { agent.send(&[42; 73], peer.local_addr().unwrap()); // UDP refuses an oversized datagram, which is never counted as sent. agent.send(&vec![0; 65_536], peer.local_addr().unwrap()); - assert_eq!(wire.stats(), crate::Stats { tx: 73, rx: 0 }); + assert_eq!(wire.stats(), crate::ice::Stats { tx: 73, rx: 0 }); peer.send_to(&[7; 11], local).await.unwrap(); let (data, _) = agent.inbound.packets.recv().await.unwrap(); assert_eq!(data.len(), 11); drop(agent); - assert_eq!(wire.stats(), crate::Stats { tx: 73, rx: 11 }); + assert_eq!(wire.stats(), crate::ice::Stats { tx: 73, rx: 11 }); } /// An agent on a fresh socket, which tokio reports unwritable until the runtime @@ -505,7 +507,7 @@ mod tests { socket.set_nonblocking(true).unwrap(); let socket = Arc::new(UdpSocket::from_std(socket).unwrap()); let local = socket.local_addr().unwrap(); - let socket = Socket::new(socket.clone(), vec![local], crate::reader(socket)).unwrap(); + let socket = Socket::new(socket.clone(), vec![local], crate::ice::reader(socket)).unwrap(); Agent::new(Rtc::builder().build(Instant::now().into_std()), socket).unwrap() } @@ -513,10 +515,10 @@ mod tests { async fn outbox_is_bounded() { let mut agent = unpolled(); let dst = agent.locals[0]; - for _ in 0..crate::INBOX + 10 { + for _ in 0..crate::ice::INBOX + 10 { agent.send(&[1; 100], dst); } - assert_eq!(agent.outbox.len(), crate::INBOX); + assert_eq!(agent.outbox.len(), crate::ice::INBOX); } #[tokio::test] @@ -559,7 +561,7 @@ mod tests { let socket = Arc::new(UdpSocket::bind("127.0.0.1:0").await.unwrap()); let local = socket.local_addr().unwrap(); - let socket = Socket::new(socket.clone(), vec![local], crate::reader(socket)).unwrap(); + let socket = Socket::new(socket.clone(), vec![local], crate::ice::reader(socket)).unwrap(); // A STUN server that never answers holds the deadline past the handshake's // retransmissions, so DTLS deterministically gives up first. let stun = UdpSocket::bind("127.0.0.1:0").await.unwrap(); diff --git a/rs/moq-ice/src/lib.rs b/rs/moq-webrtc/src/ice/mod.rs similarity index 66% rename from rs/moq-ice/src/lib.rs rename to rs/moq-webrtc/src/ice/mod.rs index 2f8ff9a9e0b..7495d00fabd 100644 --- a/rs/moq-ice/src/lib.rs +++ b/rs/moq-webrtc/src/ice/mod.rs @@ -1,14 +1,12 @@ //! The ICE side of a str0m peer connection: one UDP socket, its candidates, and //! the loop that drives an [`str0m::Rtc`] over it. //! -//! This crate is internal infrastructure with no API stability promise. -//! //! str0m is sans-IO, so [`Agent::next`] alternates between feeding it datagrams //! and timeouts and draining what it produces (transmits, events, the next //! timeout), and runs a STUN Binding client on the same socket so the agent can -//! offer server-reflexive candidates. Shared by `moq-tokio`'s data channel -//! transport and `moq-rtc`'s WHIP/WHEP gateway, which only differ in what they do -//! with the events. +//! offer server-reflexive candidates. Shared by the WHIP/WHEP gateway and the +//! `p2p` data channel transport, which only differ in what they do with +//! the events. //! //! str0m requires every mutation of an `Rtc` to be followed by draining its output //! to a timeout before the next one. The agent owns that cycle: [`Agent::rtc`] is @@ -17,13 +15,13 @@ //! //! A dual-stack socket (`[::]`) reports an IPv4 peer as an IPv4-mapped IPv6 //! address and refuses a send to a real `V4` destination. Neither form leaks past -//! this crate: inbound sources are unmapped by [`canonical`], since ICE pairs +//! this module: inbound sources are unmapped by [`canonical`], since ICE pairs //! candidates by address family, and outbound destinations are mapped back. -#![warn(missing_docs)] - mod agent; mod wire; -pub use agent::{Agent, Error, Event, RtcMut, canonical}; -pub use wire::{INBOX, Inbound, Packet, Socket, Stats, Wire, reader}; +pub(crate) use agent::{Agent, Error, Event, canonical}; +#[cfg(test)] +pub(crate) use wire::Stats; +pub(crate) use wire::{INBOX, Inbound, Packet, Socket, Wire, reader}; diff --git a/rs/moq-ice/src/wire.rs b/rs/moq-webrtc/src/ice/wire.rs similarity index 95% rename from rs/moq-ice/src/wire.rs rename to rs/moq-webrtc/src/ice/wire.rs index 638bcf6c6b5..3f831cc27a3 100644 --- a/rs/moq-ice/src/wire.rs +++ b/rs/moq-webrtc/src/ice/wire.rs @@ -5,7 +5,7 @@ use std::sync::atomic::{AtomicU64, Ordering}; use tokio::net::UdpSocket; use tokio::sync::mpsc; -use crate::canonical; +use super::canonical; /// One inbound UDP datagram and the address it came from. pub type Packet = (Vec, SocketAddr); @@ -15,7 +15,7 @@ pub type Packet = (Vec, SocketAddr); /// and a stalled session must not grow memory without limit. pub const INBOX: usize = 256; -/// The UDP socket an [`crate::Agent`] runs on: where it sends, what it receives, +/// The UDP socket an [`super::Agent`] runs on: where it sends, what it receives, /// and the host candidates it is reachable at. pub struct Socket { /// Sends datagrams, possibly shared by several agents (a demuxed server socket). @@ -45,7 +45,7 @@ impl Socket { } } -/// The datagrams routed to one [`crate::Agent`], and the counters they are tallied in. +/// The datagrams routed to one [`super::Agent`], and the counters they are tallied in. pub struct Inbound { /// Ends once every sender is dropped, which ends the agent. pub packets: mpsc::Receiver, @@ -66,6 +66,7 @@ struct Counters { } /// A snapshot of a [`Wire`]'s counters. +#[cfg(test)] #[derive(Clone, Copy, Debug, Default, PartialEq, Eq)] pub struct Stats { /// Bytes the socket accepted, including ICE, DTLS, and retransmissions. @@ -76,6 +77,7 @@ pub struct Stats { impl Wire { /// Read both counters without consuming them. + #[cfg(test)] pub fn stats(&self) -> Stats { Stats { tx: self.0.tx.load(Ordering::Relaxed), diff --git a/rs/moq-rtc/src/ingest.rs b/rs/moq-webrtc/src/ingest.rs similarity index 100% rename from rs/moq-rtc/src/ingest.rs rename to rs/moq-webrtc/src/ingest.rs diff --git a/rs/moq-rtc/src/lib.rs b/rs/moq-webrtc/src/lib.rs similarity index 98% rename from rs/moq-rtc/src/lib.rs rename to rs/moq-webrtc/src/lib.rs index 94ec1f5c32a..33299853caa 100644 --- a/rs/moq-rtc/src/lib.rs +++ b/rs/moq-webrtc/src/lib.rs @@ -1,6 +1,7 @@ -//! WebRTC ↔ MoQ gateway. +//! WebRTC for MoQ: a WHIP/WHEP gateway, and with the `p2p` feature, MoQ sessions over a +//! data channel with a browser peer (the `p2p` module). //! -//! Bridges WHIP (RFC 9725) and WHEP between WebRTC peers and +//! The 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: //! @@ -39,6 +40,8 @@ #![warn(missing_docs)] pub mod client; +#[cfg(feature = "p2p")] +pub mod p2p; pub mod rate; pub mod server; @@ -49,6 +52,7 @@ pub mod server; mod codec; mod egress; mod error; +mod ice; mod ingest; mod sdp; mod session; diff --git a/rs/moq-tokio/src/webrtc/channel.rs b/rs/moq-webrtc/src/p2p/channel.rs similarity index 100% rename from rs/moq-tokio/src/webrtc/channel.rs rename to rs/moq-webrtc/src/p2p/channel.rs diff --git a/rs/moq-tokio/src/webrtc.rs b/rs/moq-webrtc/src/p2p/mod.rs similarity index 82% rename from rs/moq-tokio/src/webrtc.rs rename to rs/moq-webrtc/src/p2p/mod.rs index 528c4956ddf..8abe06a9072 100644 --- a/rs/moq-tokio/src/webrtc.rs +++ b/rs/moq-webrtc/src/p2p/mod.rs @@ -8,11 +8,13 @@ //! remote peer, and feed its replies back. //! //! The [`Offerer`] opens the data channel, labelled `moq` and carrying the agreed -//! MoQ ALPN as its protocol, and runs the MoQ client over it with -//! [`crate::Client::connect_webrtc`]. The [`Answerer`] adopts that channel and -//! runs the MoQ server with [`crate::Listener::accept_webrtc`]. This matches -//! `@moq/p2p`, where `Transport.connect` creates the channel and -//! `Transport.accept` adopts it. +//! MoQ ALPN as its protocol, and runs a [`moq_tokio::Client`] over it with +//! [`Offerer::connect`]. The [`Answerer`] adopts that channel and hands it to a +//! [`moq_tokio::Listener`] with [`Answerer::accept`]. This matches `@moq/p2p`, +//! where `Transport.connect` creates the channel and `Transport.accept` adopts it. +//! moq-net's session policy runs over the channel as over any other transport. +//! +//! Every entry point must run inside a tokio runtime, like the gateway's. //! //! The channel carries qmux-01, one record per SCTP message, capped at 16 KiB and //! the peer's SCTP message limit. Ordered delivery means one lost chunk stalls @@ -21,6 +23,7 @@ use std::net::{IpAddr, Ipv4Addr, SocketAddr}; use std::str::FromStr; use std::sync::Arc; +use std::time::Duration; use bytes::Bytes; use str0m::Rtc; @@ -58,7 +61,7 @@ const READ_SLACK: u64 = 16 * RECORD_SIZE; /// The connection-level receive window a data channel session grants, the `[quic]` default /// every qmux session takes. -const RECEIVE_WINDOW: u64 = crate::quic::DEFAULT_RECEIVE_WINDOW; +const RECEIVE_WINDOW: u64 = moq_tokio::quic::DEFAULT_RECEIVE_WINDOW; /// The default STUN port (RFC 8489 section 18.10). const STUN_PORT: u16 = 3478; @@ -75,9 +78,9 @@ pub enum Error { #[error("peer connection closed")] Closed, - /// ICE never connected before the establishment deadline, or before the DTLS - /// handshake gave up waiting for it. - #[error("ICE did not connect in time")] + /// The connection and its data channel did not come up within [`Config::timeout`], + /// or ICE gave up first. + #[error("the peer connection did not come up in time")] Timeout, /// The WebRTC stack failed (DTLS, SCTP, or ICE state). @@ -119,29 +122,62 @@ pub enum Error { /// The qmux handshake over the channel failed. #[error("qmux handshake failed: {0}")] Qmux(String), + + /// The MoQ session over the channel failed. + #[error(transparent)] + Session(#[from] moq_tokio::Error), } -crate::error::from_message!(qmux::Error => Qmux); +impl From for Error { + fn from(err: qmux::Error) -> Self { + Self::Qmux(err.to_string()) + } +} impl Error { - /// Adopt the agent's error. Not a `From` impl, which would put moq-ice in this crate's API. - fn ice(err: moq_ice::Error) -> Self { + /// Adopt the agent's error. Not a `From` impl, which would name the private agent in this API. + fn ice(err: crate::ice::Error) -> Self { match err { - moq_ice::Error::Closed => Self::Closed, - moq_ice::Error::Timeout => Self::Timeout, - moq_ice::Error::Rtc(err) => Self::Rtc(err), - err => Self::Rtc(err.to_string()), + crate::ice::Error::Closed => Self::Closed, + crate::ice::Error::Timeout => Self::Timeout, + crate::ice::Error::Rtc(err) => Self::Rtc(err), } } } -/// How an [`Offerer`] or [`Answerer`] gathers its local candidates. -#[derive(Clone, Debug, Default)] +/// The longest [`Config::timeout`] waits by default, matching the ICE agent's own backstop. +const TIMEOUT: Duration = Duration::from_secs(30); + +/// Run `establish` within `timeout`, where zero means no bound. +async fn bounded(timeout: Duration, establish: impl Future>) -> Result { + match timeout.is_zero() { + true => establish.await, + false => kio::clock::timeout(timeout, establish) + .await + .map_err(|_| Error::Timeout)?, + } +} + +/// How an [`Offerer`] or [`Answerer`] gathers its local candidates and bounds its connection. +#[derive(Clone, Debug)] #[non_exhaustive] pub struct Config { /// STUN servers asked for this host's public address. Empty means LAN only: /// host candidates and nothing else. pub stun: Vec, + /// How long [`Offerer::connect`] and [`Answerer::accept`] wait for ICE, DTLS, and the + /// data channel to come up, and qmux to start over it. 30 seconds by default; zero + /// disables the bound. + pub timeout: Duration, +} + +impl Default for Config { + fn default() -> Self { + Self { + stun: Vec::new(), + timeout: TIMEOUT, + } + } } /// A STUN server, written the way an `RTCIceServer` URL names one: `stun:host[:port]`. @@ -249,7 +285,7 @@ text!(Answer); text!(Candidate); /// The offering side of a WebRTC peer connection, which opens the MoQ data channel -/// and runs the MoQ client over it with [`crate::Client::connect_webrtc`]. +/// and runs the MoQ client over it with [`Offerer::connect`]. /// /// A background task drives the connection from creation, so ICE checks and STUN /// replies are answered while signaling is still in progress. It runs until both @@ -258,15 +294,14 @@ text!(Candidate); /// leaves a running session alone. pub struct Offerer { peer: Peer, - /// The MoQ ALPN the channel carries. - protocol: String, + timeout: Duration, } impl Offerer { /// Start a peer connection with a data channel for MoQ `protocol`, the ALPN the /// peers agreed through signaling, returning the offer to send. pub async fn new(config: &Config, protocol: &str) -> Result<(Self, Offer), Error> { - crate::runtime::scope(Self::with_hosts(config, protocol, hosts()?)).await + Self::with_hosts(config, protocol, hosts()?).await } async fn with_hosts(config: &Config, protocol: &str, hosts: Vec) -> Result<(Self, Offer), Error> { @@ -280,7 +315,7 @@ impl Offerer { ordered: true, reliability: Reliability::Reliable, negotiated: None, - protocol: protocol.to_string(), + protocol, }); let (offer, pending) = api.apply().expect("adding a channel is an SDP change"); @@ -289,7 +324,10 @@ impl Offerer { pending: Some(pending), }; let peer = Peer::spawn(config, rtc, socket, role, None).await?; - let offerer = Self { peer, protocol }; + let offerer = Self { + peer, + timeout: config.timeout, + }; Ok((offerer, Offer(offer.to_sdp_string()))) } @@ -324,19 +362,34 @@ impl Offerer { self.peer.add_candidate(candidate).await } - /// The MoQ ALPN this peer's data channel carries. - pub(crate) fn protocol(&self) -> &str { - &self.protocol + /// Run `client`'s MoQ session over the data channel once it opens. + /// + /// [`Config::timeout`] bounds ICE and the channel coming up, then the client's connect + /// timeout bounds the MoQ handshake. A peer link cannot be redialed, so there is no + /// reconnect: the session ends with the peer connection. Only one session may take + /// the channel. + pub async fn connect(&self, client: &moq_tokio::Client) -> Result { + let establish = async { + let opened = self.peer.channel().await?; + let (session, driver) = qmux::Session::connect(opened.channel, opened.config).await?; + tokio::spawn(driver); + Ok::<_, Error>(session) + }; + let session = bounded(self.timeout, establish).await?; + let session = client.connect_with(session).await?; + tracing::info!(version = %session.version(), transport = %moq_tokio::Transport::WebRtc, "connected"); + Ok(session) } /// Wait for the data channel to open, and take it. - pub(crate) async fn channel(&self) -> Result { + #[cfg(test)] + async fn channel(&self) -> Result { self.peer.channel().await } } /// The answering side of a WebRTC peer connection, which adopts the remote peer's -/// MoQ data channel and serves it with [`crate::Listener::accept_webrtc`]. +/// MoQ data channel and serves it with [`Answerer::accept`]. /// /// Like [`Offerer`], a background task drives the connection until both this /// handle and any session over its data channel are gone. @@ -344,13 +397,14 @@ pub struct Answerer { peer: Peer, /// The MoQ ALPN the remote peer's channel must carry. protocol: String, + timeout: Duration, } impl Answerer { /// Start a peer connection for the remote peer's offer and MoQ `protocol`, the /// ALPN the peers agreed through signaling, returning the answer to send. pub async fn new(config: &Config, offer: &Offer, protocol: &str) -> Result<(Self, Answer), Error> { - crate::runtime::scope(Self::with_hosts(config, offer, protocol, hosts()?)).await + Self::with_hosts(config, offer, protocol, hosts()?).await } async fn with_hosts( @@ -373,7 +427,12 @@ impl Answerer { let peer = Peer::spawn(config, rtc, socket, Role::Answerer, Some(max_message)).await?; peer.resolver.add(mdns).await?; - Ok((Self { peer, protocol }, Answer(answer.to_sdp_string()))) + let answerer = Self { + peer, + protocol, + timeout: config.timeout, + }; + Ok((answerer, Answer(answer.to_sdp_string()))) } /// The next local candidate to send the remote peer, or `None` once gathering is done. @@ -395,13 +454,36 @@ impl Answerer { self.peer.add_candidate(candidate).await } - /// The MoQ ALPN the remote peer's data channel must carry. - pub(crate) fn protocol(&self) -> &str { - &self.protocol + /// Read the MoQ SETUP from the data channel the remote peer opens, leaving admission + /// to the returned [`moq_tokio::server::Request`]. + /// + /// [`Config::timeout`] bounds ICE and the channel coming up, then `listener`'s + /// handshake timeout bounds the MoQ handshake. A drain of `listener` waits for the + /// connection meanwhile. The channel must carry the protocol signaling agreed. Only + /// one session may take the channel. + pub async fn accept(&self, listener: &moq_tokio::Listener) -> Result { + // Held until `accept_with` takes its own, so a drain that starts meanwhile waits. + let _establishing = listener.activity().enter().ok_or(moq_tokio::Error::Stopped)?; + let establish = async { + let opened = self.peer.channel().await?; + if opened.protocol != self.protocol { + return Err(Error::Protocol(opened.protocol)); + } + let (session, driver) = qmux::Session::accept(opened.channel, opened.config).await?; + tokio::spawn(driver); + Ok((session, opened.protocol)) + }; + let (session, protocol) = bounded(self.timeout, establish).await?; + let mut link = moq_tokio::server::Link::default(); + link.alpn = Some(protocol); + Ok(listener + .accept_with(moq_tokio::Transport::WebRtc, session, link) + .await?) } /// Wait for the remote peer's data channel to open, and take it. - pub(crate) async fn channel(&self) -> Result { + #[cfg(test)] + async fn channel(&self) -> Result { self.peer.channel().await } } @@ -430,12 +512,12 @@ impl Peer { async fn spawn( config: &Config, rtc: Rtc, - socket: moq_ice::Socket, + socket: crate::ice::Socket, role: Role, max_message: Option, ) -> Result { let stun = resolve_stun(&config.stun).await; - let mut agent = moq_ice::Agent::new(rtc, socket)?.with_stun(&stun); + let mut agent = crate::ice::Agent::new(rtc, socket)?.with_stun(&stun); if let Role::Offerer { .. } = role { // The answer applies through `rtc_mut`, which starts the deadline. agent = agent.awaiting_answer(); @@ -454,7 +536,7 @@ impl Peer { taken: false, }; use tracing::Instrument; - crate::runtime::spawn(crate::panic::isolate(driver.run()).instrument(tracing::Span::current())); + tokio::spawn(moq_tokio::panic::isolate(driver.run()).instrument(tracing::Span::current())); let resolver = Resolver::spawn(commands.clone(), resolver::Mdns); Ok(Self { @@ -492,7 +574,7 @@ impl Peer { } /// A data channel that opened, ready to carry qmux. -pub(crate) struct Opened { +struct Opened { pub channel: channel::Channel, /// The MoQ ALPN the channel carries. pub protocol: String, @@ -503,7 +585,10 @@ pub(crate) struct Opened { /// The qmux session settings for a channel carrying `protocol`, advertising /// `max_record_size`: 16 KiB, capped by the peer's SCTP message limit. fn session_config(protocol: &str, max_record_size: u64) -> qmux::Config { - let mut config = crate::qmux_default(); + // The `[quic]` limits every qmux session takes: moq-lite holds a stream open per + // subscription, past qmux's default stream count. + let mut config = qmux::Config::default(); + config.limits = moq_tokio::quic::Resolved::default().limits(); config.version = qmux::Version::QMux01; config.protocol = qmux::Protocol::Negotiated(protocol.to_string()); config.max_record_size = max_record_size; @@ -516,7 +601,7 @@ fn session_config(protocol: &str, max_record_size: u64) -> qmux::Config { config } -pub(crate) enum Command { +enum Command { Answer(SdpAnswer, u64, oneshot::Sender>), Candidate(str0m::Candidate), Channel(oneshot::Sender>), @@ -545,7 +630,7 @@ struct Open { /// Owns the connection and runs it on its own task. struct Driver { - agent: moq_ice::Agent, + agent: crate::ice::Agent, commands: mpsc::Receiver, /// Dropped once gathering finishes, ending [`Offerer::candidate`] and [`Answerer::candidate`]. candidates: Option>, @@ -669,20 +754,19 @@ impl Driver { } } - fn event(&mut self, event: moq_ice::Event) -> Result<(), Error> { + fn event(&mut self, event: crate::ice::Event) -> Result<(), Error> { let event = match event { - moq_ice::Event::Candidate(candidate) => { + crate::ice::Event::Candidate(candidate) => { if let Some(candidates) = &self.candidates { let _ = candidates.send(Candidate(candidate.to_sdp_string())); } return Ok(()); } - moq_ice::Event::Gathered => { + crate::ice::Event::Gathered => { self.candidates = None; return Ok(()); } - moq_ice::Event::Rtc(event) => event, - _ => return Ok(()), + crate::ice::Event::Rtc(event) => event, }; match event { @@ -837,12 +921,13 @@ fn hosts() -> Result, Error> { /// Bind a dual-stack socket on an ephemeral port, pairing it with each host /// address, and start reading it. -fn bind(hosts: &[IpAddr]) -> Result { - let socket = crate::bind::udp(crate::bind::Udp::new("[::]:0".parse().unwrap())) - .or_else(|_| crate::bind::udp(crate::bind::Udp::new("0.0.0.0:0".parse().unwrap())))?; +fn bind(hosts: &[IpAddr]) -> Result { + use moq_tokio::bind; + let socket = bind::udp(bind::Udp::new("[::]:0".parse().unwrap())) + .or_else(|_| bind::udp(bind::Udp::new("0.0.0.0:0".parse().unwrap())))?; socket.set_nonblocking(true)?; // A `[::]` socket that stayed v6-only can't send to IPv4 candidates. - let ipv4 = socket.local_addr()?.is_ipv4() || crate::bind::udp_is_dual_stack(&socket); + let ipv4 = socket.local_addr()?.is_ipv4() || bind::udp_is_dual_stack(&socket); let socket = UdpSocket::from_std(socket)?; let local = socket.local_addr()?; @@ -855,7 +940,7 @@ fn bind(hosts: &[IpAddr]) -> Result { return Err(Error::NoHost); } let udp = Arc::new(socket); - Ok(moq_ice::Socket::new(udp.clone(), locals, moq_ice::reader(udp))?) + Ok(crate::ice::Socket::new(udp.clone(), locals, crate::ice::reader(udp))?) } /// Look up each STUN server. One that does not resolve is skipped, since a missing diff --git a/rs/moq-tokio/src/webrtc/resolver.rs b/rs/moq-webrtc/src/p2p/resolver.rs similarity index 97% rename from rs/moq-tokio/src/webrtc/resolver.rs rename to rs/moq-webrtc/src/p2p/resolver.rs index 0895365fa88..9f66d307a9b 100644 --- a/rs/moq-tokio/src/webrtc/resolver.rs +++ b/rs/moq-webrtc/src/p2p/resolver.rs @@ -9,7 +9,6 @@ use std::time::Duration; use tokio::sync::mpsc; use super::{Command, Error, candidate_address, with_address}; -use crate::abort::AbortOnDrop; /// How long to wait for a `.local` name to resolve: mdns-sd's first query plus its /// retransmissions at one and two seconds (RFC 6762 section 5.2). @@ -27,7 +26,7 @@ pub(super) trait Lookup: Send + Sync + 'static { /// already sent, and its signaling waits behind its own slow names. pub(super) struct Resolver { batches: mpsc::Sender>, - _task: AbortOnDrop, + task: tokio::task::JoinHandle<()>, } impl Resolver { @@ -35,16 +34,13 @@ impl Resolver { pub fn spawn(commands: mpsc::Sender, lookup: impl Lookup) -> Self { let (batches, rx) = mpsc::channel(1); use tracing::Instrument; - let task = crate::runtime::spawn( + let task = tokio::spawn( async move { - crate::panic::isolate(run(rx, commands, lookup)).await; + moq_tokio::panic::isolate(run(rx, commands, lookup)).await; } .instrument(tracing::Span::current()), ); - Self { - batches, - _task: AbortOnDrop::new(task), - } + Self { batches, task } } /// Queue `.local` candidate lines, waiting while the resolver is behind. @@ -56,6 +52,12 @@ impl Resolver { } } +impl Drop for Resolver { + fn drop(&mut self) { + self.task.abort(); + } +} + async fn run(batches: mpsc::Receiver>, commands: mpsc::Sender, lookup: impl Lookup) { // Once the driver exits no lookup can reach a connection, so stop, and let // signaling see the peer is closed. diff --git a/rs/moq-tokio/src/webrtc/tests.rs b/rs/moq-webrtc/src/p2p/tests.rs similarity index 84% rename from rs/moq-tokio/src/webrtc/tests.rs rename to rs/moq-webrtc/src/p2p/tests.rs index ff488b79f5c..c10cbd3b099 100644 --- a/rs/moq-tokio/src/webrtc/tests.rs +++ b/rs/moq-webrtc/src/p2p/tests.rs @@ -10,12 +10,12 @@ const LOOPBACK: IpAddr = IpAddr::V4(Ipv4Addr::LOCALHOST); /// A protocol both the default client and server speak. fn protocol() -> &'static str { - crate::connect::Config::default().versions().alpns()[0] + moq_tokio::connect::Config::default().versions().alpns()[0] } /// A one-frame broadcast named `test` and the handles that keep it alive. fn broadcast(payload: &[u8]) -> (moq_net::origin::Producer, impl Sized) { - let origin = crate::origin::spawn(); + let origin = moq_tokio::origin::spawn(); let broadcast = origin.route("test", moq_net::origin::RouteOptions::default()).unwrap(); let track = broadcast .broadcast() @@ -34,28 +34,28 @@ fn broadcast(payload: &[u8]) -> (moq_net::origin::Producer, impl Sized) { /// offering one, and read the frame back across the data channel. async fn transfer(offerer: &Offerer, answerer: &Answerer, payload: &[u8]) { let (origin, _keep) = broadcast(payload); - let listener = crate::listen::Config::default() + let listener = moq_tokio::listen::Config::default() .init_streams() .unwrap() .listen() .await .unwrap(); let server = async { - let request = listener.accept_webrtc(answerer).await.unwrap(); - assert_eq!(request.transport(), crate::Transport::WebRtc); - assert_eq!(request.alpn(), Some(answerer.protocol())); + let request = answerer.accept(&listener).await.unwrap(); + assert_eq!(request.transport(), moq_tokio::Transport::WebRtc); + assert_eq!(request.alpn(), Some(answerer.protocol.as_str())); request.with_publisher(&origin).ok().await.unwrap() }; - let subscribed = crate::origin::spawn(); + let subscribed = moq_tokio::origin::spawn(); let consumer = subscribed.consume(); let mut announced = consumer.announced(); - let client = crate::client::Config::default() + let client = moq_tokio::client::Config::default() .init() .unwrap() .with_subscriber(subscribed); let (_server, _client) = kio::clock::timeout(TIMEOUT, async { - tokio::join!(server, async { client.connect_webrtc(offerer).await.unwrap() }) + tokio::join!(server, async { offerer.connect(&client).await.unwrap() }) }) .await .expect("handshake timed out"); @@ -86,6 +86,22 @@ async fn session_over_loopback() { transfer(&offerer, &answerer, b"hello").await; } +/// A zero timeout disables the bound rather than elapsing at once. +#[tokio::test] +async fn zero_timeout_is_unbounded() { + let config = Config { + timeout: Duration::ZERO, + ..Config::default() + }; + let (offerer, offer) = Offerer::with_hosts(&config, protocol(), vec![LOOPBACK]).await.unwrap(); + let (answerer, answer) = Answerer::with_hosts(&config, &offer, protocol(), vec![LOOPBACK]) + .await + .unwrap(); + offerer.accept(&answer).await.unwrap(); + + transfer(&offerer, &answerer, b"hello").await; +} + /// A frame many records long fills the SCTP send window, so the writer has to /// wait for the peer's acknowledgements and resume. #[tokio::test] @@ -202,6 +218,7 @@ async fn server_reflexive_candidate_is_offered_and_selected() { let stun = stun_server().await; let config = Config { stun: vec![format!("stun:{stun}").parse().unwrap()], + ..Default::default() }; let private = IpAddr::V4(Ipv4Addr::new(127, 0, 0, 2)); let (mut offerer, offer) = Offerer::with_hosts(&config, protocol(), vec![private]).await.unwrap(); @@ -231,22 +248,36 @@ async fn server_reflexive_candidate_is_offered_and_selected() { transfer(&offerer, &answerer, b"hello").await; } +/// A channel carrying a protocol that is not MoQ opens, and moq-net's policy refuses it on both sides. #[tokio::test] async fn unsupported_protocol_is_refused() { - let (offerer, _) = Offerer::with_hosts(&Config::default(), "not-moq", vec![LOOPBACK]) + let config = Config::default(); + let (offerer, offer) = Offerer::with_hosts(&config, "not-moq", vec![LOOPBACK]).await.unwrap(); + let (answerer, answer) = Answerer::with_hosts(&config, &offer, "not-moq", vec![LOOPBACK]) .await .unwrap(); - let client = crate::client::Config::default().init().unwrap(); - assert!(matches!( - client.connect_webrtc(&offerer).await, - Err(crate::Error::WebRtc(err)) if matches!(*err, Error::Protocol(_)) - )); + offerer.accept(&answer).await.unwrap(); + + let listener = moq_tokio::listen::Config::default() + .init_streams() + .unwrap() + .listen() + .await + .unwrap(); + let client = moq_tokio::client::Config::default().init().unwrap(); + let (accepted, connected) = kio::clock::timeout(TIMEOUT, async { + tokio::join!(answerer.accept(&listener), offerer.connect(&client)) + }) + .await + .expect("the refusal timed out"); + assert!(accepted.is_err(), "the answerer accepted an unsupported protocol"); + assert!(connected.is_err(), "the offerer connected with an unsupported protocol"); } /// A channel carrying another supported ALPN than the one signaling agreed is refused. #[tokio::test] async fn unsignaled_protocol_is_refused() { - let versions = crate::connect::Config::default().versions(); + let versions = moq_tokio::connect::Config::default().versions(); let [agreed, other, ..] = versions.alpns()[..] else { panic!("expected two supported ALPNs"); }; @@ -257,19 +288,16 @@ async fn unsignaled_protocol_is_refused() { .unwrap(); offerer.accept(&answer).await.unwrap(); - let listener = crate::listen::Config::default() + let listener = moq_tokio::listen::Config::default() .init_streams() .unwrap() .listen() .await .unwrap(); - let accepted = kio::clock::timeout(TIMEOUT, listener.accept_webrtc(&answerer)) + let accepted = kio::clock::timeout(TIMEOUT, answerer.accept(&listener)) .await .expect("the channel did not open"); - assert!(matches!( - accepted, - Err(crate::Error::WebRtc(err)) if matches!(&*err, Error::Protocol(protocol) if protocol == other) - )); + assert!(matches!(accepted, Err(Error::Protocol(protocol)) if protocol == other)); } #[test] @@ -399,16 +427,10 @@ async fn a_drain_waits_for_an_establishing_peer() { .unwrap(); let activity = moq_net::server::Activity::default(); - let listener = crate::server::Config { - activity: activity.clone(), - ..Default::default() - } - .init_streams() - .unwrap() - .listen() - .await - .unwrap(); - let mut accept = std::pin::pin!(listener.accept_webrtc(&answerer)); + let mut config = moq_tokio::server::Config::default(); + config.activity = activity.clone(); + let listener = config.init_streams().unwrap().listen().await.unwrap(); + let mut accept = std::pin::pin!(answerer.accept(&listener)); // The answer is not applied yet, so the channel cannot open. assert!(futures::poll!(accept.as_mut()).is_pending()); let mut closed = std::pin::pin!(activity.close()); @@ -418,11 +440,10 @@ async fn a_drain_waits_for_an_establishing_peer() { ); offerer.accept(&answer).await.unwrap(); - let client = crate::client::Config::default().init().unwrap(); - let (request, session) = - kio::clock::timeout(TIMEOUT, async { tokio::join!(accept, client.connect_webrtc(&offerer)) }) - .await - .expect("handshake timed out"); + let client = moq_tokio::client::Config::default().init().unwrap(); + let (request, session) = kio::clock::timeout(TIMEOUT, async { tokio::join!(accept, offerer.connect(&client)) }) + .await + .expect("handshake timed out"); let request = request.expect("the drain refused an establishing peer"); assert!(futures::poll!(closed.as_mut()).is_pending()); drop((request, session)); diff --git a/rs/moq-rtc/src/rate.rs b/rs/moq-webrtc/src/rate.rs similarity index 98% rename from rs/moq-rtc/src/rate.rs rename to rs/moq-webrtc/src/rate.rs index 2f057e94752..225e81701af 100644 --- a/rs/moq-rtc/src/rate.rs +++ b/rs/moq-webrtc/src/rate.rs @@ -1,7 +1,7 @@ //! Bitrate caps for WHIP ingest. //! //! An embedder hands [`whip::accept`](crate::whip::accept) a [`Limit`] through -//! [`Request::with_rate`](crate::whip::Request::with_rate), and moq-rtc steers the +//! [`Request::with_rate`](crate::whip::Request::with_rate), and moq-webrtc steers the //! publisher's encoder under its [`Cap`]: a `b=TIAS` //! line in the SDP answer, and periodic REMB where the publisher negotiated //! it. WebRTC has no receiver backpressure, so a publisher that ignores both is metered @@ -16,7 +16,7 @@ use kio::clock::Instant; use moq_net::bandwidth::Rate; use tokio::sync::watch; -/// The share of the cap moq-rtc steers the encoder to. +/// The share of the cap moq-webrtc steers the encoder to. /// /// The meter counts every media payload, but the steering lines only bound what the /// browser's video encoder targets: audio rides on top, and encoders overshoot their @@ -27,7 +27,7 @@ const STEER: f64 = 0.9; /// How long the meter remembers the credit it discarded, for frames still assembling. /// /// str0m completes a frame at most its video reordering timeout after the frame's first -/// packet, 2 seconds by default, which moq-rtc keeps; audio waits half that. +/// packet, 2 seconds by default, which moq-webrtc keeps; audio waits half that. const ASSEMBLY: Duration = Duration::from_secs(2); /// A bitrate cap: the sustained rate media may arrive at, and the burst above it. @@ -84,7 +84,7 @@ impl From for Cap { /// Clones share the cap. [`Limit::set`] applies to a running session at once: the /// meter switches to the new cap, and the next REMB goes out immediately, lifting its /// ceiling when the cap is lifted. The SDP answer's TIAS is fixed at the cap set when the -/// offer was accepted, since moq-rtc never renegotiates: a session that starts uncapped +/// offer was accepted, since moq-webrtc never renegotiates: a session that starts uncapped /// steers only through REMB, and raising or lifting a starting cap frees the publisher /// only as far as that TIAS allows. #[derive(Clone)] diff --git a/rs/moq-rtc/src/sdp.rs b/rs/moq-webrtc/src/sdp.rs similarity index 100% rename from rs/moq-rtc/src/sdp.rs rename to rs/moq-webrtc/src/sdp.rs diff --git a/rs/moq-rtc/src/server/mod.rs b/rs/moq-webrtc/src/server/mod.rs similarity index 100% rename from rs/moq-rtc/src/server/mod.rs rename to rs/moq-webrtc/src/server/mod.rs diff --git a/rs/moq-rtc/src/server/mux.rs b/rs/moq-webrtc/src/server/mux.rs similarity index 96% rename from rs/moq-rtc/src/server/mux.rs rename to rs/moq-webrtc/src/server/mux.rs index 78e9ddef366..c602f3a771f 100644 --- a/rs/moq-rtc/src/server/mux.rs +++ b/rs/moq-webrtc/src/server/mux.rs @@ -23,7 +23,7 @@ use std::collections::HashMap; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; -use moq_ice::{Inbound, Packet}; +use crate::ice::{Inbound, Packet}; use str0m::ice::{IceCreds, StunMessage}; use tokio::net::UdpSocket; use tokio::sync::mpsc; @@ -45,7 +45,7 @@ struct Registry { struct Entry { ufrag: String, sender: mpsc::Sender, - wire: moq_ice::Wire, + wire: crate::ice::Wire, } /// The shared media socket plus its demux routing table. @@ -125,8 +125,8 @@ impl Mux { /// [`Registration`] guard the session task must hold for its lifetime. pub(crate) fn register(&self) -> (IceCreds, Inbound, Registration) { let creds = IceCreds::new(); - let (tx, rx) = mpsc::channel(moq_ice::INBOX); - let wire = moq_ice::Wire::default(); + let (tx, rx) = mpsc::channel(crate::ice::INBOX); + let wire = crate::ice::Wire::default(); let entry = Arc::new(Entry { ufrag: creds.ufrag.clone(), sender: tx, @@ -171,8 +171,8 @@ async fn demux(socket: Arc, registry: Arc>) { } }; // A dual-stack bind reports IPv4 peers as `::ffff:a.b.c.d`; unmap before - // this address becomes a registry key or reaches ICE (see `moq_ice::canonical`). - let src = moq_ice::canonical(src); + // this address becomes a registry key or reaches ICE (see `crate::ice::canonical`). + let src = crate::ice::canonical(src); let data = &buf[..len]; // Cached peers need one routing lock; only a new address parses STUN. @@ -255,7 +255,7 @@ mod tests { let address_b = "127.0.0.1:10002".parse().unwrap(); let mut registry = mux.registry.lock().unwrap(); assert!(registry.route(100, address_a, Some("unknown")).is_none()); - for _ in 0..moq_ice::INBOX { + for _ in 0..crate::ice::INBOX { let entry = registry.route(11, address_a, Some(&a.ufrag)).unwrap(); entry.sender.try_send((vec![0; 11], address_a)).unwrap(); } @@ -268,12 +268,12 @@ mod tests { drop(registry); assert_eq!( source_a.stats(), - moq_ice::Stats { + crate::ice::Stats { tx: 0, - rx: 11 * moq_ice::INBOX as u64 + 23 + rx: 11 * crate::ice::INBOX as u64 + 23 } ); - assert_eq!(source_b.stats(), moq_ice::Stats { tx: 0, rx: 37 }); + assert_eq!(source_b.stats(), crate::ice::Stats { tx: 0, rx: 37 }); // Unregister even while an inbox is still held: cached addresses cannot // keep attributing traffic after the peer ends. @@ -305,7 +305,7 @@ mod tests { let mut addresses = Vec::new(); for peer in 0..peers { let (sender, receiver) = mpsc::channel(1); - let wire = moq_ice::Wire::default(); + let wire = crate::ice::Wire::default(); let address = SocketAddr::from(([127, 0, 0, 1], peer as u16 + 1)); let entry = Arc::new(Entry { ufrag: peer.to_string(), diff --git a/rs/moq-rtc/src/server/whep.rs b/rs/moq-webrtc/src/server/whep.rs similarity index 99% rename from rs/moq-rtc/src/server/whep.rs rename to rs/moq-webrtc/src/server/whep.rs index 501939c852b..b4603add445 100644 --- a/rs/moq-rtc/src/server/whep.rs +++ b/rs/moq-webrtc/src/server/whep.rs @@ -165,7 +165,7 @@ pub async fn accept( let answer = rtc.sdp_api().accept_offer(offer).map_err(Error::rtc)?; let resource_id = sdp::new_resource_id(); - let socket = moq_ice::Socket::new(mux.socket(), mux.candidates().to_vec(), inbound)?; + let socket = crate::ice::Socket::new(mux.socket(), mux.candidates().to_vec(), inbound)?; let session = session::Session::egress(rtc, socket, source)?; // Register before returning so a DELETE that races startup still finds the diff --git a/rs/moq-rtc/src/server/whip.rs b/rs/moq-webrtc/src/server/whip.rs similarity index 99% rename from rs/moq-rtc/src/server/whip.rs rename to rs/moq-webrtc/src/server/whip.rs index 9d6341ff336..8ac5ac49820 100644 --- a/rs/moq-rtc/src/server/whip.rs +++ b/rs/moq-webrtc/src/server/whip.rs @@ -189,7 +189,7 @@ pub async fn accept(server: &Server, request: Request<'_>) -> Result { let instance = route.instance(); let resource_id = sdp::new_resource_id(); - let socket = moq_ice::Socket::new(mux.socket(), mux.candidates().to_vec(), inbound)?; + let socket = crate::ice::Socket::new(mux.socket(), mux.candidates().to_vec(), inbound)?; let session = session::Session::ingest(rtc, socket, sink)?.with_rate(&rate); // Register before returning so a DELETE that races the first packet still diff --git a/rs/moq-rtc/src/session.rs b/rs/moq-webrtc/src/session.rs similarity index 96% rename from rs/moq-rtc/src/session.rs rename to rs/moq-webrtc/src/session.rs index 1707b804be2..292c0ce0f1f 100644 --- a/rs/moq-rtc/src/session.rs +++ b/rs/moq-webrtc/src/session.rs @@ -1,6 +1,6 @@ //! str0m session driver shared by every HTTP role / media direction. //! -//! [`moq_ice::Agent`] drives the sans-IO [`str0m::Rtc`] over UDP; +//! [`crate::ice::Agent`] drives the sans-IO [`str0m::Rtc`] over UDP; //! [`Session::run`] feeds it egress writes and handles the media events it surfaces. //! //! The session itself doesn't care whether the [`Rtc`] was populated by @@ -93,7 +93,7 @@ impl MediaFlow { /// `inbound` rather than being read off the socket directly, so several /// sessions can share one socket behind the `crate::server::mux`. pub struct Session { - agent: moq_ice::Agent, + agent: crate::ice::Agent, role: MediaRole, opened_media: HashSet, /// Egress write requests. `Some` only for [`MediaRole::Egress`] @@ -116,10 +116,10 @@ pub struct Session { impl Session { /// Convenience for the ingest case (WHIP server, WHEP client). The socket's - /// `inbound` comes from the server mux, or [`moq_ice::reader`] for a 1:1 client socket. - pub fn ingest(rtc: Rtc, socket: moq_ice::Socket, sink: Box) -> Result { + /// `inbound` comes from the server mux, or [`crate::ice::reader`] for a 1:1 client socket. + pub fn ingest(rtc: Rtc, socket: crate::ice::Socket, sink: Box) -> Result { Ok(Self { - agent: moq_ice::Agent::new(rtc, socket)?, + agent: crate::ice::Agent::new(rtc, socket)?, role: MediaRole::Ingest(sink), opened_media: HashSet::new(), writes_rx: None, @@ -131,12 +131,12 @@ impl Session { } /// Convenience for the egress case (WHEP server, WHIP client). The socket's - /// `inbound` comes from the server mux, or [`moq_ice::reader`] for a 1:1 client socket. - pub fn egress(rtc: Rtc, socket: moq_ice::Socket, mut source: EgressSource) -> Result { + /// `inbound` comes from the server mux, or [`crate::ice::reader`] for a 1:1 client socket. + pub fn egress(rtc: Rtc, socket: crate::ice::Socket, mut source: EgressSource) -> Result { let writes_rx = source.take_writes(); let catalog_end = source.take_catalog_end(); Ok(Self { - agent: moq_ice::Agent::new(rtc, socket)?, + agent: crate::ice::Agent::new(rtc, socket)?, role: MediaRole::Egress(Box::new(source)), opened_media: HashSet::new(), writes_rx: Some(writes_rx), @@ -253,12 +253,12 @@ impl Session { } => self.send_remb(), event = self.agent.next() => match event { - Ok(moq_ice::Event::Rtc(event)) => self.handle_event(event)?, + Ok(crate::ice::Event::Rtc(event)) => self.handle_event(event)?, // No STUN servers are configured, so there is nothing to trickle. Ok(_) => {} - Err(moq_ice::Error::Closed) => return Err(Error::SessionClosed), - Err(moq_ice::Error::Timeout) => return Err(Error::IceTimeout), - Err(err) => return Err(Error::rtc(err)), + Err(crate::ice::Error::Closed) => return Err(Error::SessionClosed), + Err(crate::ice::Error::Timeout) => return Err(Error::IceTimeout), + Err(crate::ice::Error::Rtc(err)) => return Err(Error::Rtc(err)), }, } } @@ -681,16 +681,16 @@ pub fn rtc_with_codecs(codecs: &[str0m::format::Codec]) -> Rtc { } /// Bind an ephemeral UDP socket for a single client session, read by its own -/// [`moq_ice::reader`], with the ICE candidates to advertise. +/// [`crate::ice::reader`], with the ICE candidates to advertise. /// /// The client paths are 1:1 (one socket per dialed session, no demux); the /// server paths share one socket via `crate::server::mux` instead. `advertise` /// IPs are used verbatim (reusing the bound port); empty falls back to the /// bound address, substituting loopback when that address is unspecified. -pub async fn bind_udp(advertise: &[SocketAddr]) -> Result { +pub async fn bind_udp(advertise: &[SocketAddr]) -> Result { let udp = Arc::new(UdpSocket::bind(("0.0.0.0", 0)).await?); let locals = advertised_candidates(advertise, udp.local_addr()?)?; - Ok(moq_ice::Socket::new(udp.clone(), locals, moq_ice::reader(udp))?) + Ok(crate::ice::Socket::new(udp.clone(), locals, crate::ice::reader(udp))?) } /// Pair configured ICE candidates with the bound UDP port and validate them. diff --git a/sh/rs/select.sh b/sh/rs/select.sh index 4ab7bf5e38f..48b47ce4649 100755 --- a/sh/rs/select.sh +++ b/sh/rs/select.sh @@ -201,8 +201,8 @@ case "$action" in features+=(moq-video/capture moq-audio/capture moq-audio/playback) fi if wants moq-cli; then features+=(moq-cli/play moq-cli/openh264); fi - # The WebRTC module's hostile-input tests, such as mDNS backpressure. - if wants moq-tokio; then features+=(moq-tokio/webrtc); fi + # The WebRTC data channel's hostile-input tests, such as mDNS backpressure. + if wants moq-webrtc; then features+=(moq-webrtc/p2p); fi # The relay's io_uring listener, Linux-only. A moq-uring change selects # the relay too, as its dependent. if [[ "$(uname -s)" == Linux ]] && wants moq-relay; then features+=(moq-relay/io-uring); fi diff --git a/sh/rs/select.test.py b/sh/rs/select.test.py index 0f12ee508e5..e3ac50dfa1a 100644 --- a/sh/rs/select.test.py +++ b/sh/rs/select.test.py @@ -73,7 +73,7 @@ def selected(self, *paths, action="lint", github_actions=False): return calls.read_text().splitlines() if calls.exists() else [] def test_nextest_launcher_selects_workspace(self): - features = [*DEVICE_FEATURES.split(), "moq-tokio/webrtc", *(["moq-relay/io-uring"] if LINUX else [])] + features = [*DEVICE_FEATURES.split(), "moq-webrtc/p2p", *(["moq-relay/io-uring"] if LINUX else [])] features += [feature for feature in target_features() if feature not in features] for github_actions in (False, True): for action in ("check", "check-test", "lint", "test"): @@ -156,10 +156,13 @@ def test_device_features_join_the_one_test_build(self): self.assertEqual(len(calls), 1, calls) # The targets' required features follow the device ones. self.assertIn(f" --features {features}", calls[0]) - # moq-tokio's WebRTC module is off by default too. - calls = self.selected("rs/moq-tokio/src/webrtc.rs", action="test") + # moq-webrtc's data channel transport is off by default too. + calls = self.selected("rs/moq-webrtc/src/p2p/mod.rs", action="test") self.assertEqual(len(calls), 1, calls) - self.assertIn(" moq-tokio/webrtc", calls[0]) + self.assertIn(" moq-webrtc/p2p", calls[0]) + # So is a change to qmux, which only that optional feature pulls in. + calls = self.selected("rs/qmux/src/lib.rs", action="test") + self.assertTrue(any(" moq-webrtc/p2p" in call for call in calls), calls) # A dependency of the media crates still runs both their device tests. calls = self.selected("rs/moq-audio/src/lib.rs", action="test") self.assertIn("--package moq-video --package moq-audio", calls[0]) diff --git a/sh/rs/tokio-features.sh b/sh/rs/tokio-features.sh index c4328fb151a..9d9ff69ea14 100755 --- a/sh/rs/tokio-features.sh +++ b/sh/rs/tokio-features.sh @@ -41,7 +41,7 @@ driver_dependencies() { run driver_dependencies # Every isolated permutation, which `just rs features` asks for. if ((all)); then - for feature in net quic tcp uds websocket webrtc; do + for feature in net qmux quic tcp uds websocket; do run cargo clippy --locked -p moq-tokio --no-default-features --features "$feature" -- -D warnings done fi