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
6 changes: 5 additions & 1 deletion doc/bin/gstreamer.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,11 @@ Audio packets share groups of at least 20 ms while forwarding as they arrive.
Each `sink_%u` request pad is one track. Pad properties: `track` names it
(default: after the codec), `container=loc` publishes it as
[LOC](/concept/standard#loc) instead of the legacy hang container, and
`track-status`/`track-error` report its lifecycle. Element properties:
`track-status`/`track-error` report its lifecycle. Caps that only change what
the bitstream already carries (a video resolution) keep the track live. A run
never publishes a track name it ended again: new codec config, a pad requested
again, or a stream resumed after EOS publishes as `<track>/<n>`, which `track`
reads back. Element properties:
`url`, `broadcast`, `linger`, `connect-version`, `tls-disable-verify`, `quic-idle-timeout`, `quic-keylog`,
`quic-keep-alive`, and read-only `status`, `connected`, `moq-version`, and
`estimated-send-rate`, `estimated-recv-rate`, `connection-stats`, and
Expand Down
5 changes: 4 additions & 1 deletion js/net/src/ietf/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,10 @@ export const PublishDoneStatus = {
UPDATE_FAILED: 0x8,
} as const;

/** Whether a PUBLISH_DONE status ends the track cleanly rather than aborting it. */
/**
* Whether a PUBLISH_DONE status ends the subscription cleanly, so its data streams in flight still
* drain, rather than aborting it. Only TRACK_ENDED also ends the track.
*/
export function publishDoneClean(statusCode: number, version: IetfVersion): boolean {
if (statusCode === PublishDoneStatus.TRACK_ENDED) return true;
if (statusCode !== PublishDoneStatus.SUBSCRIPTION_ENDED) return false;
Expand Down
5 changes: 5 additions & 0 deletions js/net/src/ietf/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,11 @@ export class Subscriber {
const { tail, track } = subscription;
const complete = () => count > 0n && BigInt(tail.streams) >= count;
await tail.settle(complete, track.closed);
// SUBSCRIPTION_ENDED ends just this subscription, so the copy fails rather than declare an
// end the track may run past: a later reader subscribes afresh, and its groups continue.
if (done.statusCode !== PublishDoneStatus.TRACK_ENDED) {
throw new Error(`publish done: subscription ended reason=${done.reasonPhrase}`);
}
}

/**
Expand Down
16 changes: 16 additions & 0 deletions js/net/src/ietf/tail.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const ALIAS = 9n;
const TRACK_ENDED = 0x2;
const INTERNAL_ERROR = 0x0;
const UNAUTHORIZED = 0x1;
const SUBSCRIPTION_ENDED = 0x3;

// A plain subgroup stream: no extensions, no subgroup id, end of group on FIN.
const FLAGS: GroupFlags = {
Expand Down Expand Up @@ -162,6 +163,21 @@ test("a PUBLISH_DONE with an error status aborts the track", async () => {
expect(await reader.closed).toBeInstanceOf(Error);
});

// SUBSCRIPTION_ENDED ends only the subscription: a later one continues the track past these
// groups, so the copy delivers what was in flight and then fails rather than declare an end.
test("a SUBSCRIPTION_ENDED PUBLISH_DONE drains, then aborts the track", async () => {
const { subscriber, reader, done } = await subscribed();
const group = groupStream(subscriber, 0);
group.write(object("0.0"));
group.finish();
await group.handled;
await done(SUBSCRIPTION_ENDED, 1n);

expect(await readAll(await reader.recvGroup())).toEqual(["0.0"]);
expect(await reader.closed).toBeInstanceOf(Error);
expect(reader.end()).toBeUndefined();
});

test("an UNAUTHORIZED PUBLISH_DONE reads as the revocation a moq-lite peer sends", async () => {
const { reader, done } = await subscribed();
await done(UNAUTHORIZED, 0n);
Expand Down
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ divergences, under one epic; its redesign proposals went to m2.
- [Empty segments refused](/quest/m1/empty-segments.md) - `room//cam` fails loud instead of naming `room/cam`
- [In-band auth](/quest/m1/auth/README.md) - a session tells its peer what it may publish and subscribe to, unions tokens presented in band, and fails loud on an out-of-scope publish
- [Cluster routing](/quest/m1/cluster-routing/README.md) - prove shared routing contracts, implement per-origin routes, and connect outbound local clusters
- [No reused track names](/quest/m1/name-reuse.md) - no first-party publisher re-creates a finished track under its old name
- [Routing guide](/quest/m1/routing-guide.md) - concepts and practical outbound federation setup
- [Generated C bindings](/quest/m1/c/README.md) - C generated from moq-ffi ships as `moq-c` 0.8.0 and replaces the hand-written libmoq
- [Exact timestamps in every binding](/quest/m1/binding-timestamps.md) - bindings carry `{value, scale}` timestamps instead of lossy microseconds
Expand Down
18 changes: 0 additions & 18 deletions quest/m1/name-reuse.md

This file was deleted.

22 changes: 13 additions & 9 deletions rs/moq-gst/src/sink/imp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use gst::prelude::*;
use gst::subclass::prelude::*;
use hang::moq_net;

use super::pad::{CapsOutcome, ProducerOptions, PushOutcome, caps_supported};
use super::pad::{CapsOutcome, Names, ProducerOptions, PushOutcome, caps_supported};
use super::request_pad::{MoqSinkPad, Notifications, PadLifecycle};
use super::session::{
CAT, Completion, CompletionHandle, ConnectionStatus, RUNTIME, ResolvedSettings, Session, SessionRegistration,
Expand Down Expand Up @@ -70,6 +70,8 @@ struct State {
broadcast: moq_net::origin::Publication,
catalog: Option<moq_mux::catalog::Producer>,
wall: std::sync::Arc<super::wall::Wall>,
/// The configured track names this run ended, which it never publishes again.
names: Names,
/// How long a clean end keeps the finished broadcast up before its EOS.
linger: Duration,
/// Whether the finished broadcast closed, so the EOS it owes may go out.
Expand Down Expand Up @@ -435,7 +437,7 @@ impl ElementImpl for MoqSink {
if let Some(state) = control.live.as_ref()
&& let Some(catalog) = state.catalog.as_ref()
{
pad.lifecycle().media.reserve(catalog, state.wall.clone());
pad.lifecycle().media.reserve(catalog, state.wall.clone(), &state.names);
}
control.admissions.insert(pad.clone());
}
Expand Down Expand Up @@ -582,6 +584,7 @@ impl MoqSink {
broadcast,
catalog: Some(catalog),
wall,
names: Names::default(),
linger,
drained: false,
lingering: None,
Expand All @@ -598,7 +601,7 @@ impl MoqSink {
let changes = lifecycle.reset();
lifecycle.completion = Some(completion.clone());
if !lifecycle.releasing {
lifecycle.media.reserve(catalog, wall.clone());
lifecycle.media.reserve(catalog, wall.clone(), &state.names);
}
changes
};
Expand Down Expand Up @@ -885,7 +888,7 @@ impl MoqSink {
if !lifecycle.releasing {
lifecycle.ended = false;
if let Some(catalog) = &state.catalog {
lifecycle.media.reserve(catalog, state.wall.clone());
lifecycle.media.reserve(catalog, state.wall.clone(), &state.names);
}
}
}
Expand All @@ -911,7 +914,7 @@ impl MoqSink {
lifecycle.media.flush();
let catalog = state.catalog.as_ref();
if let Some(catalog) = catalog {
lifecycle.media.reserve(catalog, state.wall.clone());
lifecycle.media.reserve(catalog, state.wall.clone(), &state.names);
}
let caps = lifecycle.media.resumable_caps();
caps.zip(catalog).and_then(|(caps, catalog)| {
Expand Down Expand Up @@ -1206,7 +1209,7 @@ fn observe_caps(
lifecycle: &mut PadLifecycle,
caps: &gst::Caps,
) -> (Option<Notifications>, bool) {
lifecycle.media.reserve(catalog, state.wall.clone());
lifecycle.media.reserve(catalog, state.wall.clone(), &state.names);
let requested = lifecycle.requested().map(str::to_owned);
let mut options = ProducerOptions::new(caps).with_container(lifecycle.container().into());
if let Some(track) = requested.as_deref() {
Expand Down Expand Up @@ -1596,7 +1599,8 @@ mod tests {
assert!(completion_of(&run.0).is_open());
}

// GStreamer keeps CAPS sticky across a flush, so a resumed pad gets no new CAPS event.
// GStreamer keeps CAPS sticky across a flush, so a resumed pad gets no new CAPS event. EOS ended its
// track, so the resumed one takes a fresh name.
#[test]
fn an_unresolved_pad_resumed_after_eos_publishes_without_new_caps() {
use futures::FutureExt;
Expand Down Expand Up @@ -1626,7 +1630,7 @@ mod tests {
let std::task::Poll::Ready(Ok(Some(next))) = next_catalog(&mut catalog) else {
panic!("the resumed pad must publish its rendition ({resume})")
};
assert!(next.video.renditions.contains_key("video"), "{resume}");
assert!(next.video.renditions.contains_key("video/1"), "{resume}");
let broadcast = run
.0
.imp()
Expand All @@ -1639,7 +1643,7 @@ mod tests {
.broadcast
.consume();
let mut track = broadcast
.track("video")
.track("video/1")
.expect("the resumed track is published")
.subscribe(None)
.now_or_never()
Expand Down
Loading
Loading