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
2 changes: 1 addition & 1 deletion doc/lib/c/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ and `target/include/moq.h`.
- **Encoded video metadata.** `moq_video_init.hint` is a zero-initialized `moq_video_hint` with `has_*` flags for coded dimensions, bitrate (bits per second), frame rate, and latency preference. Hints seed a video codec track's catalog; detected dimensions take precedence.
- **Client config.** A zeroed `moq_client_config` means the defaults for every knob, which is what lets a new one be appended without disturbing callers. Fields cover protocol (`versions`), TLS (`tls_fingerprints`, `tls_roots`, `tls_cert`/`_key`, `tls_host_name`), transport (`bind`, `connect_timeout_us`, the Happy Eyeballs delays, `websocket_enabled`/`_delay_us`), and tuning (reconnect backoff, `quic_*`). Every duration is in microseconds. A knob whose default isn't zero carries a `has_*` flag, so setting `backoff_timeout_us = 0` needs `has_backoff_timeout = true` to mean "retry forever" rather than "use the default". `moq_client_defaults()` reports what a NULL config dials with.
- **Server.** `moq_server_listen` binds before it returns (a bad address or certificate fails there) and hands each incoming session to `on_request` as a request handle. Read `moq_session_request_path` and `_query` to route and authenticate, then `moq_session_request_accept` (a session handle, with origins like `moq_session_connect`) or `moq_session_request_reject` with an HTTP-style code (401 and 403 become the protocol's unauthorized close). An accepted session reports `1` once SETUP completes and never reconnects. `moq_server_addr` reports an ephemeral port and `moq_server_fingerprints` the hashes a client pins for a `tls_generate` certificate. `moq_server_close` stops listening; its terminal callback fires once the sockets are released.
- **Demand.** A watcher on a published track (`moq_publish_track_demand`, `moq_publish_media_demand`, `moq_encode_video_demand`, `moq_encode_audio_demand`) calls `on_demand` with `MOQ_DEMAND_USED` or `MOQ_DEMAND_UNUSED` right away and again on every change, so an encoder on a battery-powered device runs only while someone is watching. The first call is the current state, so a track that went unused before the watcher existed still reports it. `moq_publish_demand_cancel` stops it; the terminal callback still fires. A container has no single demand and is refused. Demand follows the last real subscriber: an origin that served the track drops its source copy on the unused edge and keeps only the finished groups it already cached warm for 30 seconds, so the cache linger does not delay the unused edge.
- **Demand.** A watcher on a published track (`moq_publish_track_demand`, `moq_publish_media_demand`, `moq_encode_video_demand`, `moq_encode_audio_demand`) calls `on_demand` with `MOQ_DEMAND_USED` or `MOQ_DEMAND_UNUSED` right away and again on every change, so an encoder on a battery-powered device runs only while someone is watching. The first call is the current state, so a track that went unused before the watcher existed still reports it. `moq_publish_demand_cancel` stops it; the terminal callback still fires. A container has no single demand and is refused. Demand follows the last real subscriber: an origin that served the track drops its source copy on the unused edge, so a cache linger never delays it. Only a relay keeps what it already delivered warm for 30 seconds, and a returning subscriber is served that cache only once the publisher confirms it is still current.
- **Requests.** `moq_publish_dynamic` serves subscriptions to tracks the broadcast never declared: each arrives as a request handle, read its name with `moq_track_request_name`, then `moq_track_request_accept` (a raw track handle), `moq_track_request_video` / `_audio` (the media handle `moq_publish_video` / `_audio` return), or `moq_track_request_abort` with an application code the subscriber sees. Without a live handler an unknown name is refused. `moq_publish_track_dynamic` does the same for fetches of groups a track no longer has cached, delivered as `moq_group_request_*` (`sequence`, `priority`, `frame_start`); `moq_group_request_accept` starts the producer at `frame_start` so written frames keep their group indices. Register it with `moq_track_request_dynamic` before accepting a track that was itself requested by a fetch, so that pending group survives the transition. Both handlers stop with `moq_publish_dynamic_cancel`.
- **Everything the bindings can do** ([list](/lib/#what-every-binding-can-do)): media publish and consume with the catalog managed for you, raw pixels and PCM with the codec inside (`moq_encode_video`, `moq_encode_audio`, and the `moq_decode_*` mirrors), raw tracks with timestamps and datagrams, JSON and binary data tracks (snapshot or stream, each advertised in the catalog for as long as it lives), group fetch, catalog sections, shared video properties, and stalled hints. The three advertising operations are `moq_origin_create_broadcast` (unannounced producer, invisible to everyone), `moq_publish_announce` / `moq_publish_unannounce` (exact-path advertisement), and `moq_origin_dynamic` (a claim over a path prefix and everything beneath it; `""` for everything). A route is a capability, not an inventory. `moq_origin_announced` takes a literal prefix and an optional relative pattern filter; `moq_announce_update.prefix` stays relative to the origin, while `captures` reports what each wildcard matched when `has_captures` is true. Paths with a `.`-prefixed segment below the prefix are [hidden](/concept/moq-lite#hidden-broadcasts); name the dot segment in `prefix` to list them.

Expand Down
15 changes: 13 additions & 2 deletions rs/moq-net/src/lite/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2777,8 +2777,13 @@ impl<S: crate::transport::poll::Session> TrackServe<S> {
// The floor tracks the requested start until this subscription's own
// SUBSCRIBE_START refines it: the peer never serves below the request, a
// previous subscription's declaration must not outlive its demand, and
// live-edge demand (None) starts with no floor at all.
let _ = producer.start_at(subscription.start.map(|start| start.group));
// live-edge demand (None) starts with no floor at all. Lite-06+ only resolves
// the start with its SUBSCRIBE_START, so until then the floor is just a request.
let floor = subscription.start.map(|start| start.group);
let _ = match self.subscriber.version.resolves_start() {
true => producer.request_start(floor),
false => producer.start_at(floor),
};

tracing::info!(id, broadcast = %self.subscriber.log_path(&self.path), track = %self.name, "subscribe started");

Expand Down Expand Up @@ -3200,6 +3205,12 @@ impl<S: crate::transport::poll::Session> ServeLoop<S> {
// request's own fetch gate, and a cache-miss fetch queued while TRACK_INFO
// was in flight would be drained as NotFound in the gap.
let dynamic = request.dynamic();
// Lite-06+ resolves each subscription's start from its budget, so the floor
// the SUBSCRIBE asks for is not where delivery begins until SUBSCRIBE_START says.
let request = match serve.subscriber.version.resolves_start() {
true => request.resolving_start(),
false => request,
};
let serving = request.accept(info);
Self {
serving,
Expand Down
10 changes: 9 additions & 1 deletion rs/moq-net/src/model/front.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ pub(super) enum Action {
/// Drop the source copy of `track` but keep the delivered groups spliced,
/// so resume stays seamless while nobody reads.
Park { track: Arc<str> },
/// Drop the delivered groups of `track` too: the linger expired unread.
/// Drop the source copy of `track` and every delivered group: the linger expired
/// unread, or the source is local and keeps its own cache.
Release { track: Arc<str> },
/// The logical track completed.
Finish { track: Arc<str> },
Expand Down Expand Up @@ -587,6 +588,13 @@ impl Front {
};
track.used = false;
match track.state {
// A local source keeps its own cache, so a warm copy would only be a staler
// duplicate of it: drop the copy outright, and a returning reader re-splices
// the source and reads its cache against the real live edge.
TrackState::Spliced { .. } if self.identity == Identity::Local => {
track.state = TrackState::Idle;
actions.push(Action::Release { track: name });
}
// Drop the copy so the source goes idle at once; the delivered
// groups stay spliced for the linger.
TrackState::Spliced { .. } => {
Expand Down
Loading
Loading