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
49 changes: 0 additions & 49 deletions quest/m1/2815-lift-adaptive-stage-refusal.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,5 @@ Branch from dev.

## Related

- [#2815](/quest/m1/2815-lift-adaptive-stage-refusal.md) - two capture stages sharing one allocator
- [#2709](/quest/m1/2709-per-broadcast-bandwidth-estimates-and-reservation.md) - the same allocator mirrored in js/net
- [Ladder](/quest/m2/ladder/README.md) - a transcode ladder dividing the same estimate
1 change: 0 additions & 1 deletion quest/m1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ quest here and merged main into dev.
- [#2709](/quest/m1/2709-per-broadcast-bandwidth-estimates-and-reservation.md) - js/net mirrors the send-side bandwidth allocator so each publisher encodes against its own share
- [Binding rate control](/quest/m1/binding-rate-control.md) - the bindings mirror the allocator and reservation, so a non-Rust publisher follows its bandwidth share
- [#2859](/quest/m1/2859-passthrough-imports-reserve-no-bandwidth-so-a-co-resident.md) - passthrough imports claim their peak-hold catalog bitrate on the allocator so a co-resident encoder targets what is left
- [#2815](/quest/m1/2815-lift-adaptive-stage-refusal.md) - moq-cli accepts several adaptive import stages on one connection now that the allocator divides the estimate
- [HLS 404](/quest/m1/hls-cache-miss-codes.md) - a relay miss and a disconnected publisher answer 404 over moq-lite; IETF upstreams stay 500
- [HLS sibling restart](/quest/m1/hls-sibling-epoch-identity.md) - a replaced sibling publisher restarts its rendition instead of serving stale rows
- [A/V clock](/quest/m1/plan-av-clock.md) - the audio playhead drives Sync.reference while audio plays, through per-track sync handles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ the dev merge.

## Related

- [#2815](/quest/m1/2815-lift-adaptive-stage-refusal.md) - two capture stages sharing one allocator
- [#2859](/quest/m1/2859-passthrough-imports-reserve-no-bandwidth-so-a-co-resident.md) - reserve-only usage for passthrough tracks
- [Binding rate control](/quest/m1/binding-rate-control.md) - the bindings consume the same `moq_mux::rate::Control`
- [#2709](/quest/m1/2709-per-broadcast-bandwidth-estimates-and-reservation.md) - the JS twin
99 changes: 5 additions & 94 deletions rs/moq-cli/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,28 +259,6 @@ impl Invocation {
);
}

// Rate control assumes it owns the uplink: the encoder targets a fraction of the
// connection's estimate, leaving room for its own audio and transport overhead but
// not for a second publisher. Anything else importing over the same connection
// spends what that encoder already claimed, so refuse rather than congest the link
// the estimate exists to protect. Exports only receive, so they don't count, and
// only an outbound client has an estimate at all.
let imports = self
.stages
.iter()
.filter(|stage| matches!(stage, Command::Import(_)))
.count();
let adaptive = self
.stages
.iter()
.any(|stage| matches!(stage, Command::Import(import) if import.source.uses_bandwidth()));
anyhow::ensure!(
self.moq.client.url.is_none() || !adaptive || imports == 1,
"a stage that encodes to fit the connection's bandwidth estimate assumes it's the only \
publisher on that connection, but this runs {imports} import stages; run them as separate \
processes, or publish over --listen, which has no estimate"
);

Ok(())
}
}
Expand Down Expand Up @@ -682,18 +660,6 @@ impl ImportSource {
_ => return None,
})
}
/// Whether this source encodes to fit the connection's bandwidth estimate.
///
/// Rate control is per-encoder while the estimate is per-connection, so each such
/// source assumes it's the only one on the uplink. Only the video encoder reads
/// the estimate, so an audio-only capture doesn't count.
pub fn uses_bandwidth(&self) -> bool {
match self {
#[cfg(feature = "capture")]
Self::Capture(capture) => !capture.no_video,
_ => false,
}
}
}

// ------------------------------------------------------------------ export
Expand Down Expand Up @@ -1141,8 +1107,7 @@ mod tests {
assert_eq!(err.kind(), ParseErrorKind::UnknownArgument);
}

/// Stages that never read the estimate can share a connection freely, so the guard
/// must not reject them.
/// Passthrough imports share a connection; they never read the estimate.
#[test]
fn imports_without_rate_control_can_share_a_connection() {
let cli = Invocation::try_parse_from([
Expand All @@ -1168,78 +1133,24 @@ mod tests {
assert!(cli.validate().is_ok());
}

/// An encoder that follows the estimate targets most of it, so a second publisher
/// on the same connection spends what it already claimed. Exports only receive, and
/// a `--listen` publisher has no estimate to oversubscribe.
/// Two encoding stages share the connection's allocator, so they may run
/// together rather than each targeting the whole estimate.
#[cfg(feature = "capture")]
#[test]
fn an_adaptive_capture_must_be_the_only_import() {
let client: &[&str] = &["--connect", "http://relay"];
let server: &[&str] = &["--listen", "[::]:4443"];

let cases: [(&[&str], &[&str], bool); 3] = [
// Two video captures follow the same estimate.
(client, &["import", "capture"], false),
// A fixed-rate import spends the same uplink from outside the budget.
(client, &["import", "rtmp", "--listen", "127.0.0.1:1935"], false),
// No outbound client, so there's no estimate to oversubscribe.
(server, &["import", "capture"], true),
];

for (side, second, ok) in cases {
let argv = [&["moq"][..], side, &["import", "capture", "--"], second].concat();
let cli = Invocation::try_parse_from(argv.clone()).unwrap();
assert_eq!(cli.validate().is_ok(), ok, "{argv:?}");
}

// An audio-only capture never reads the estimate, so it may share the connection.
fn two_encoding_stages_may_share_a_connection() {
let cli = Invocation::try_parse_from([
"moq",
"--connect",
"http://relay",
"import",
"capture",
"--no-video",
"--",
"import",
"rtmp",
"--listen",
"127.0.0.1:1935",
])
.unwrap();
assert!(cli.validate().is_ok());

// Exports only receive, so they don't compete for the uplink.
let cli = Invocation::try_parse_from([
"moq",
"--connect",
"http://relay",
"import",
"capture",
"--",
"export",
"--broadcast",
"other.hang",
"fmp4",
])
.unwrap();
assert!(cli.validate().is_ok());
}

/// Only the video encoder reads the connection's bandwidth estimate, so an
/// audio-only capture doesn't compete for it and isn't counted against the
/// one-adaptive-stage limit.
#[cfg(feature = "capture")]
#[test]
fn audio_only_capture_is_not_bandwidth_adaptive() {
for (args, adaptive) in [(vec!["capture"], true), (vec!["capture", "--no-video"], false)] {
let argv = [vec!["moq", "--connect", "http://relay", "import"], args].concat();
let cli = Invocation::try_parse_from(argv).unwrap();
let Command::Import(import) = &cli.stages[0] else {
panic!("expected import")
};
assert_eq!(import.source.uses_bandwidth(), adaptive);
}
assert!(cli.validate().is_ok());
Comment thread
kixelated marked this conversation as resolved.
Resolved
}

#[test]
Expand Down
Loading