diff --git a/quest/m1/README.md b/quest/m1/README.md index a9ed35f1c1f..679c84b2f44 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -176,7 +176,6 @@ per-frame CPU growth since #5926. - [Interop coverage](/quest/m1/interop-coverage/README.md) - the riskiest moq-transport features moq-net exposes get cross-implementation tests over drafts 18 and 22 - [Calibrate the paired nightly benchmarks](/quest/m1/bench-ci.md) - A/A and deliberately slowed Nightly runs set the paired comparison's threshold, so its regression alerts can be trusted - [The shared pacer holds its rate under 2 Mbit/s](/quest/m1/pacer-low-rate.md) - a rate-paced controller stops sending up to twice its pacing rate at low rates, landed with a BBR3 retune that keeps the probe budgets -- [A reconfigure keeps the published jitter and delay floor](/quest/m1/catalog-jitter-floor.md) - `Rendition::set` floors unsupplied jitter and delay at the catalog's values, so a same-codec reconfigure after a jitter rise no longer aborts TS import - [HLS and DASH segment conformance](/quest/m1/hls-conformance.md) - nightly ffprobe checks that advertised timing, sync flags, and bytes match the media served - [Unbounded groups](/quest/m1/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 - [A follower is told when the serving epochless route leaves](/quest/m1/epochless-leave-restart.md) - wire-level tests pin the restart a follower gets when the serving epochless route is withdrawn or dies while another remains diff --git a/quest/m1/catalog-jitter-floor.md b/quest/m1/catalog-jitter-floor.md deleted file mode 100644 index 1979c48bab2..00000000000 --- a/quest/m1/catalog-jitter-floor.md +++ /dev/null @@ -1,44 +0,0 @@ -# [S] A reconfigure keeps the published jitter and delay floor - -## Goal - -Re-setting an already-published rendition, such as an H.264 or H.265 -same-codec resolution change, never lowers the jitter or delay its catalog -already advertises for a field the new config leaves unset. The reconfigure -publishes with the higher of the two, as a measurement does, instead of -failing with `JitterDecreased` and aborting the TS import. - -## Plan - -Decided 2026-10-31 (maintainer, the /quest-complete requeue session), found -by the sessions of [moq-dev/moq#7436](https://github.com/moq-dev/moq/pull/7436) -and [moq-dev/moq#7387](https://github.com/moq-dev/moq/pull/7387). Planned -here in m1 as its own [S] rather than fixed inside #7436 (no test there needs -it) or dropped: it blocks the conformance test in #7387 once that fixture is -repaired. - -`Rendition::set` (`rs/moq-mux/src/catalog/tracks.rs:655`) resolves the new -config from what it supplies plus the last measurement (`Self::resolved`), -then `check_decrease` refuses anything below the catalog's current jitter or -delay. `Rendition::estimate` (`:711`) already floors its result at the -published values (`resolved.jitter.max(published.jitter)`, `:725-726`). -After a measurement raises jitter mid-run, a reconfigure that supplies no -jitter resolves to the lower detected value and fails. Floor the unsupplied -jitter and delay in `set` at the catalog's published values the same way, so -`check_decrease` still refuses only a value the caller explicitly lowers. - -`published_text_jitter_never_decreases` (`:1078`) expects a `None` re-set -after a supplied 100 ms to fail; with the floor it publishes 100 ms. Keep -the explicit-lower case failing and update the `None` case to the floor. - -Regression test: a unit test in `tracks.rs` that publishes a video config, -raises its jitter with `estimate`, then `set`s a config with new dimensions -and no jitter, and asserts it succeeds with the raised jitter still -published. - -Public API: none. Wire: none. - -## Related - -- [HLS and DASH segment conformance](/quest/m1/hls-conformance.md) - the conformance test this unblocks -- [HLS export follows a resolution change](/quest/m1/hls-reinit-same-codec.md) - the same-codec reconfigure that hits it diff --git a/quest/m1/hls-conformance.md b/quest/m1/hls-conformance.md index ca4c6426ff2..221a0b866a8 100644 --- a/quest/m1/hls-conformance.md +++ b/quest/m1/hls-conformance.md @@ -41,7 +41,6 @@ own quest below. ## Required - [HLS export follows a resolution change](/quest/m1/hls-reinit-same-codec.md) - the conformance test's same-codec switch fails until it lands -- [A reconfigure keeps the published jitter and delay floor](/quest/m1/catalog-jitter-floor.md) - the conformance test's TS import aborts with `JitterDecreased` at its reconfigure until it lands ## Related diff --git a/rs/moq-mux/src/catalog/tracks.rs b/rs/moq-mux/src/catalog/tracks.rs index 3ae2363e3d8..f45658282d7 100644 --- a/rs/moq-mux/src/catalog/tracks.rs +++ b/rs/moq-mux/src/catalog/tracks.rs @@ -652,10 +652,20 @@ impl> Rendition { /// the rendition existed (a dirty start or a B-frame reorder). Only the authoritative ones reach /// the MSF catalog. A caller who wants to pre-empt detection sets the field on the config, or (for /// a config an importer builds out of the bitstream) hands the importer a hint like [`VideoHint`]. + /// Unset jitter and delay keep the published floor across reconfiguration. pub(crate) fn set(&mut self, mut config: C) -> crate::Result<()> { let supplied = config.estimate(); - let resolved = Self::resolved(&supplied, &self.detected); - self.check_decrease(&resolved)?; + let mut resolved = Self::resolved(&supplied, &self.detected); + if self.present { + let published = self.config()?.estimate(); + if supplied.jitter.is_none() { + resolved.jitter = resolved.jitter.max(published.jitter); + } + if supplied.delay.is_none() { + resolved.delay = resolved.delay.max(published.delay); + } + Self::check_decrease(&published, &resolved)?; + } config.set_estimate(resolved.clone()); { let mut guard = self.catalog.modify()?; @@ -758,11 +768,7 @@ impl> Rendition { } /// Refuse a config that lowers the jitter or delay already advertised to subscribers. - fn check_decrease(&self, next: &Estimate) -> crate::Result<()> { - if !self.present { - return Ok(()); - } - let previous = self.config()?.estimate(); + fn check_decrease(previous: &Estimate, next: &Estimate) -> crate::Result<()> { if next.jitter < previous.jitter { return Err(crate::Error::JitterDecreased); } @@ -808,7 +814,7 @@ impl> Rendition { if !self.present { return Err(crate::Error::NotPublished); } - self.check_decrease(&config.estimate())?; + Self::check_decrease(&self.config()?.estimate(), &config.estimate())?; let mut guard = self.catalog.modify()?; let mut next = (*guard).clone(); config.insert(&mut next, &self.name); @@ -1008,6 +1014,53 @@ mod tests { ); } + #[test] + fn reconfigure_floors_only_unsupplied_fields() { + let ms = Duration::from_millis; + for supplied_jitter in [false, true] { + for supplied_delay in [false, true] { + let (_broadcast, catalog, mut rendition) = video_track(); + rendition.set(config(None, None)).unwrap(); + rendition + .estimate(Estimate::default().with_jitter(ms(100)).with_delay(ms(200))) + .unwrap(); + // The most recent reading can be below what was already advertised. + rendition + .estimate(Estimate::default().with_jitter(ms(50)).with_delay(ms(100))) + .unwrap(); + let mut next = config(Some(500_000), supplied_jitter.then_some(ms(150))); + next.delay = supplied_delay.then_some(ms(250)); + next.coded_width = Some(1920); + next.coded_height = Some(1080); + next.framerate = Some(30.0); + rendition.set(next.clone()).unwrap(); + let expected_jitter = Some(ms(if supplied_jitter { 150 } else { 100 })); + let expected_delay = Some(ms(if supplied_delay { 250 } else { 200 })); + next.jitter = expected_jitter; + next.delay = expected_delay; + assert_eq!(catalog.snapshot().video.renditions["v"], next); + + // A floor does not turn an unsupplied field into a supplied hint. + rendition + .estimate(Estimate::default().with_jitter(ms(300)).with_delay(ms(400))) + .unwrap(); + let current = rendition.config().unwrap(); + assert_eq!( + current.jitter, + if supplied_jitter { + expected_jitter + } else { + Some(ms(300)) + } + ); + assert_eq!( + current.delay, + if supplied_delay { expected_delay } else { Some(ms(400)) } + ); + } + } + } + #[test] fn published_delay_never_decreases() { let (_broadcast, catalog, mut rendition) = video_track(); @@ -1017,16 +1070,17 @@ mod tests { config }; rendition.set(delayed(Some(Duration::from_millis(200)))).unwrap(); + assert!(matches!( + rendition.set(delayed(Some(Duration::from_millis(100)))), + Err(crate::Error::DelayDecreased) + )); for smaller in [Some(Duration::from_millis(100)), None] { - assert!(matches!( - rendition.set(delayed(smaller)), - Err(crate::Error::DelayDecreased) - )); assert!(matches!( rendition.replace(delayed(smaller)), Err(crate::Error::DelayDecreased) )); } + rendition.set(delayed(None)).unwrap(); assert_eq!( catalog.snapshot().video.renditions["v"].delay, Some(Duration::from_millis(200)) @@ -1088,12 +1142,11 @@ mod tests { config }; rendition.set(text(Some(Duration::from_millis(100)))).unwrap(); - for smaller in [Some(Duration::from_millis(50)), None] { - assert!(matches!( - rendition.set(text(smaller)), - Err(crate::Error::JitterDecreased) - )); - } + assert!(matches!( + rendition.set(text(Some(Duration::from_millis(50)))), + Err(crate::Error::JitterDecreased) + )); + rendition.set(text(None)).unwrap(); assert_eq!( catalog.snapshot().text.renditions["t"].jitter, Some(Duration::from_millis(100)) diff --git a/rs/moq-mux/src/container/producer.rs b/rs/moq-mux/src/container/producer.rs index e7465ce816a..c3f11190b59 100644 --- a/rs/moq-mux/src/container/producer.rs +++ b/rs/moq-mux/src/container/producer.rs @@ -314,6 +314,8 @@ where } /// Publish or replace this track's catalog config. + /// + /// Unset jitter and delay keep their published floor; explicitly lowering either is refused. pub fn set(&mut self, config: R) -> crate::Result<()> { self.rendition.as_mut().ok_or(crate::Error::NotPublished)?.set(config) } @@ -1081,6 +1083,61 @@ mod tests { assert_eq!(renditions["slow"].jitter, None, "a constant trail is not jitter"); } + #[test] + fn reconfigure_keeps_floors_until_the_track_identity_changes() { + let ms = std::time::Duration::from_millis; + for codec in ["avc3.42c01e", "hev1.1.6.L93.B0"] { + let (_broadcast, catalog, mut tracks) = renditions(&["fast", "slow"]); + let slow = &mut tracks[1]; + // Start a new identity, as an importer does when it resolves its codec. + let mut config = hang::catalog::VideoConfig::new(codec.parse::().unwrap()); + config.coded_width = Some(640); + config.coded_height = Some(360); + slow.reconfigure(config.clone()).unwrap(); + let name = slow.name().to_string(); + tracks[0].write(frame(240_000, true)).unwrap(); + tracks[1].reorder(Timestamp::from_millis(100).unwrap()); + tracks[1].write(frame(40_000, true)).unwrap(); + tracks[1].cut(None).unwrap(); + let measured = catalog.snapshot().video.renditions[&name].clone(); + assert_eq!((measured.jitter, measured.delay), (Some(ms(100)), Some(ms(200)))); + + // Match an external catalog edit, such as the HLS conformance fixture's raise. + let mut edit = tracks[1].modify().unwrap(); + edit.jitter = Some(ms(300)); + edit.delay = Some(ms(400)); + edit.commit().unwrap(); + config.coded_width = Some(1280); + config.coded_height = Some(720); + tracks[1].reconfigure(config.clone()).unwrap(); + assert_eq!(tracks[1].name(), name); + let current = catalog.snapshot().video.renditions[&name].clone(); + assert_eq!((current.coded_width, current.coded_height), (Some(1280), Some(720))); + assert_eq!((current.jitter, current.delay), (Some(ms(300)), Some(ms(400)))); + + for (jitter, delay) in [(Some(ms(250)), None), (None, Some(ms(350)))] { + let mut lower = config.clone(); + lower.jitter = jitter; + lower.delay = delay; + let err = tracks[1].reconfigure(lower).unwrap_err(); + assert!(matches!( + (jitter, err), + (Some(_), crate::Error::JitterDecreased) | (None, crate::Error::DelayDecreased) + )); + assert_eq!(catalog.snapshot().video.renditions[&name], current); + } + + // A new identity owns a new floor, even when it supplies lower values. + config.codec = hang::catalog::VideoCodec::VP8; + config.jitter = Some(ms(20)); + config.delay = Some(ms(30)); + tracks[1].reconfigure(config).unwrap(); + assert_ne!(tracks[1].name(), name); + let current = catalog.snapshot().video.renditions[tracks[1].name()].clone(); + assert_eq!((current.jitter, current.delay), (Some(ms(20)), Some(ms(30)))); + } + } + /// History caught up behind the live edge is not a late write: only what follows it measures delay. #[test] fn history_measures_no_delay() {