Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/bin/relay/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ relay.with_web(web).run().await?;
- To serve a session from any other moq-net transport, such as the in-memory
one in tests, enable the `test-support` feature, read its SETUP with `moq_net::Server::accept_request` and pass
`Accepted::new(handshake, transport)` to `Connection::new`. The client must
send its path in the SETUP.
send its path in the SETUP. The server's accept timeout (`moq_net::Server::with_timeout`)
bounds admission and, on moq-lite 01/02, the SETUP reply too.
- To decide admissions yourself, leave `[auth]` empty and answer
`relay.admissions()`; see [Authentication](/bin/relay/auth#in-process).
- To serve WebRTC media (WHIP, WHEP) on the QUIC port, take `relay.webrtc()`:
Expand Down
2 changes: 1 addition & 1 deletion doc/lib/rs/moq-net.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ What you use it for, beyond what the concept page already describes:
- **End content by finishing tracks.** A broadcast has no finished state. When the input ends, finish each track; the broadcast stays announced and keeps serving them until you close it or drop its route. How long to keep it up for late readers is yours to decide: `moq_mux::Linger` holds a hang broadcast for a fixed window.
- **Demand says whether anyone is watching.** `demand()` on a track, group, or broadcast says whether a subscriber is attached. First-party capture does not wait for it: video encodes while enabled and audio keeps raw PCM to encode when someone listens, so a late subscription's `delay.max` or a FETCH finds the recent past. Demand gates bandwidth reservations, transcode rungs, and on-demand video where a publisher opts in, which saves the encode but leaves nothing from before the first subscriber. Holding a broadcast or track consumer is not demand: a track consumer requests nothing until it queries, subscribes, or fetches, and those count until dropped. A shared fetch stays up until its last reader leaves. Demand rolls up: a frame being read keeps its group wanted, a group a subscription or fetch handed out keeps its track wanted until read to its end, and any wanted track keeps its broadcast wanted.
- **Use the model without a runtime.** By default `moq-net` is its `poll_*` APIs and origin driver with caller-supplied time. The `async` feature adds their async wrappers, `time::run`, and both wire sessions.
- **You drive the session, or `moq-tokio` does.** `connect` and `accept` return a session plus a driver that never reads the clock itself. `moq_net::time::run` polls it on tokio. `moq-tokio` hides that. A custom transport implements `moq_net::transport::poll`, and `moq_net::transport::memory::pair` links two sessions in one process with no sockets, for tests or in-process links.
- **You drive the session, or `moq-tokio` does.** `connect` and `accept` return a session plus a driver that never reads the clock itself. `moq_net::time::run` polls it on tokio. `moq-tokio` hides that. A custom transport implements `moq_net::transport::poll`, and `moq_net::transport::memory::pair` links two sessions in one process with no sockets, for tests or in-process links. `Server` bounds each accept with one deadline (10 s by default, `with_timeout`) across SETUP, your admission decision (`Handshake::expired`), and moq-lite 01/02's SETUP reply, and opens a receive window the transport held back once you admit (`with_receive_window`).
- **Reconnect policy comes with it.** With the `async` feature, `moq_net::Reconnect` decides which of a peer's addresses to dial, how long each dial and handshake may take, when to back off and give up, and how to follow a GOAWAY, without doing I/O: you dial each `Attempt` it asks for and report back. `moq-tokio`'s `Connection` runs it, so a client on another runtime gets the same policy rather than a copy.
- **A session bounds what its peer can hold.** Each request holds a stream, so the transport's stream credit bounds subscriptions and FETCHes. `session::Limits` (via `Client::with_limits` and `Server::with_limits`) bounds the announcements per session. The default suits a relay mesh, so lower it for untrusted peers. Past it, the session closes with `TOO_MANY_REQUESTS`. Peer-declared lengths are capped before they are buffered.
- **Authorization is in band.** On moq-lite 07 (`moq-lite-07-wip`, opt-in) and on moq-transport draft-18+ with the [MoQ Auth extension](/draft/moq-auth), `session.auth()` presents tokens without reconnecting and watches the grant the peer sent back. `add(token)` resolves with the token and how the peer took it: `Answer::Granted` on its AUTH stream, or `Answer::Requests` on moq-transport without AUTH, where only a request that names it carries it. A handle passed to `Client::with_auth` outlives each session, so its tokens, and the routes naming them, carry across your own reconnects. A server verifies tokens itself by taking `handshake.requests()` before `ok()`. `authorize(&grant)` narrows or widens a live session on any version: what falls outside resets with `Unauthorized` and the session stays up. A client that publishes outside its grant closes the session, naming the path.
Expand Down
5 changes: 2 additions & 3 deletions quest/m1/session-policy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ in moq-net, and decided:
until io_uring dials.
- ✅ **Fold** the m2 relay-serve-path quest into
[the io_uring path](/quest/m1/session-policy/uring.md) and the
poll-first server-machines quest into
[accept policy](/quest/m1/session-policy/accept.md).
poll-first server-machines quest into accept policy, which landed in
[moq-dev/moq#8003](https://github.com/moq-dev/moq/pull/8003).
- ✅ **Break moq-net's public API in m1**, before the cut, with MIGRATE notes.
Not chosen: additive APIs beside the old ones.

Expand Down Expand Up @@ -65,6 +65,5 @@ Research (2026-11-04, `origin/main` at e6be13d5f8):

## Required

- [Accept policy in moq-net](/quest/m1/session-policy/accept.md) - one accept deadline, admission bound and window widening for every transport
- [The io_uring relay path uses moq-net's policy](/quest/m1/session-policy/uring.md) - deletes `uring.rs`'s copy
- [moq-tokio becomes a thin shell](/quest/m1/session-policy/tokio-handoff.md) - sockets, TLS, accept loops and spawning, plus the transport handoffs WebRTC needs
40 changes: 0 additions & 40 deletions quest/m1/session-policy/accept.md

This file was deleted.

6 changes: 1 addition & 5 deletions quest/m1/session-policy/tokio-handoff.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ moq-net rather than a copy of the policy.

- The handoff's signature (transport plus link metadata in, request or session
out) is fixed by this quest and does not change if policy moves further.
- Delete moq-tokio's now-unused `Deadline`, `Backoff` and the like, and its
- Delete moq-tokio's now-unused `Backoff` and the like (the accept `Deadline` already went), and its
per-transport `Request` construction that moq-net now owns. Bounding the
transport handshake (`within`) stays here, since moq-net has no session yet
at that point.
Expand All @@ -34,7 +34,3 @@ moq-net rather than a copy of the policy.

Public API: moq-tokio adds `accept_with` and `connect_with` and drops internals
it re-exported, with MIGRATE notes. Wire: none.

## Required

- [Accept policy in moq-net](/quest/m1/session-policy/accept.md) - the accept policy the handoff runs
4 changes: 0 additions & 4 deletions quest/m1/session-policy/uring.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ see it for the decisions and research.

Public API: none. Wire: none.

## Required

- [Accept policy in moq-net](/quest/m1/session-policy/accept.md) - the shared policy this path calls

## Related

- [io_uring relay package](/quest/m3/relay-io-uring-package.md) - ships the path this unifies
18 changes: 14 additions & 4 deletions rs/moq-net/src/lite/test_transport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,8 +618,8 @@ pub struct SinkSession {
stats: Arc<Mutex<SinkStats>>,
/// Set by [`Self::with_probe`].
probe: Option<crate::transport::Probe>,
/// Set by [`Self::with_receive_window`].
receive_window: Option<crate::transport::ReceiveWindow>,
/// Set by [`Self::with_receive_window`], and widened by `set_limits`.
receive_window: Arc<Mutex<Option<crate::transport::ReceiveWindow>>>,
}

impl SinkSession {
Expand Down Expand Up @@ -651,7 +651,7 @@ impl SinkSession {

/// Report `window` as the receive windows in force.
pub fn with_receive_window(mut self, window: crate::transport::ReceiveWindow) -> Self {
self.receive_window = Some(window);
self.receive_window = Arc::new(Mutex::new(Some(window)));
self
}

Expand Down Expand Up @@ -831,7 +831,17 @@ impl poll::Session for SinkSession {
}

fn receive_window(&self) -> Option<crate::transport::ReceiveWindow> {
self.receive_window
*self.receive_window.lock().unwrap()
}

/// Set the connection window, on a transport that reports one.
fn set_limits(&self, limits: crate::transport::Limits) -> Result<(), crate::transport::LimitsError> {
let mut window = self.receive_window.lock().unwrap();
let (Some(window), Some(connection)) = (window.as_mut(), limits.receive_window) else {
return Err(crate::transport::LimitsError::Unsupported);
};
window.connection = connection.get();
Ok(())
}
}

Expand Down
Loading
Loading