diff --git a/quest/m1/README.md b/quest/m1/README.md index 50e3d328e92..9c1bcb67321 100644 --- a/quest/m1/README.md +++ b/quest/m1/README.md @@ -40,7 +40,6 @@ transport, benchmark tooling); worktrees isolate commits, not semantics. - [Optional max age](/quest/m1/ietf-max-age.md) - max age is optional, set only by the publisher, and crosses moq-transport as MAX_CACHE_DURATION - [IETF announce count](/quest/m1/ietf-announce-count.md) - an opt-in moq-transport extension carries the replay count, so IETF announce consumers go live without a timer - [kio waiter overflow](/quest/m1/kio-waiter-lost.md) - a retained `Waiter` past 8 lists stops adding a duplicate entry to lists it already recorded -- [moqsink keyframe latch](/quest/m1/moqsink-keyframe-latch.md) - a header-only buffer after a break no longer permanently invalidates a moqsink video pad - [Capture re-anchor](/quest/m1/capture-reanchor.md) - a repeating or restarting device clock never rewinds native capture during a fast backlog drain - [Splice edge cases](/quest/m1/splice-edges.md) - an unstamped successor, a pruned segment's boundary group, and a warm head during a takeover are each handled correctly - [Track tail hardening](/quest/m1/track-tail-hardening.md) - Rust and JS wait out a track's tail by the same rules, with the known hang, count, truncation, grace, and memory holes closed diff --git a/quest/m1/moqsink-keyframe-latch.md b/quest/m1/moqsink-keyframe-latch.md deleted file mode 100644 index d86c1e638ab..00000000000 --- a/quest/m1/moqsink-keyframe-latch.md +++ /dev/null @@ -1,23 +0,0 @@ -# [XS] moqsink waits for a published keyframe after a break - -## Goal - -A video pad in `moqsink` survives a pause or segment break whose first buffer -carries only codec headers. Today `Media::write` in -`rs/moq-gst/src/sink/pad.rs` clears its `keyframe` latch after any successful -decode. A header-only buffer decodes without emitting a frame, clears the -latch, and the next delta frame hits `MissingKeyframe` outside the guarded -arm, which permanently invalidates the pad -([#4239](https://github.com/moq-dev/moq/pull/4239)). - -## Plan - -Keep the latch set until the importer actually publishes a keyframe, not -until the first buffer parses. That needs `import::Track::decode` to say -whether it emitted a frame, or a comparable signal; prefer reusing what the -importer already knows over inferring it in the pad. - -Regression test beside `video_pause_drops_deltas_until_the_next_keyframe`: a -break followed by a header-only buffer (SPS/PPS alone for H.264), then a -delta, then a keyframe. The delta drops and the keyframe publishes; the pad -stays valid. diff --git a/rs/moq-gst/src/sink/pad.rs b/rs/moq-gst/src/sink/pad.rs index dcbc84bec90..f9b68dd37bc 100644 --- a/rs/moq-gst/src/sink/pad.rs +++ b/rs/moq-gst/src/sink/pad.rs @@ -52,7 +52,9 @@ struct Media { /// Apply a timeline break before the next valid frame, using the normal write error path. discontinuity: bool, /// A video break closed the group, and a pause resumes mid-GOP, so deltas drop until a keyframe - /// opens the next one. + /// opens the next one. Stays set once armed: a successful decode may publish nothing (a + /// header-only buffer), and a delta only misses its keyframe while no group is open, which for + /// video means after a break. keyframe: bool, } @@ -69,7 +71,6 @@ impl Media { Err(moq_mux::Error::MissingKeyframe(_)) if self.keyframe => return Ok(false), result => result?, } - self.keyframe = false; // One group (one QUIC stream) per audio packet, so the relay forwards it without waiting for // the next. if self.audio { @@ -1758,6 +1759,32 @@ mod tests { assert_eq!(push(&mut pad, delta, 166), PushOutcome::Published); } + // A header-only buffer after a break publishes no frame, so no group opens and the deltas that + // follow must still drop rather than invalidate the pad. + #[test] + fn video_header_only_buffer_keeps_waiting_for_the_keyframe() { + gst::init().unwrap(); + let (broadcast, catalog) = producers(); + let mut pad = Pad::new(); + pad.observe_caps(&broadcast, &catalog, producer_options(&h264_caps(), Some("video"))); + pad.observe_segment(time_segment()); + // The SPS and PPS of the keyframe AU, without its IDR slice. + let keyframe = h264_keyframe_au(); + let headers = keyframe.slice(..keyframe.len() - 9); + let delta = Bytes::from_static(&[0, 0, 0, 1, 0x61, 0xe0, 0x12, 0x34]); + let now = Instant::now(); + let push = |pad: &mut Pad, data: Bytes, pts: u64| { + pad.push_buffer(data, Some(gst::ClockTime::from_mseconds(pts)), None, None, now) + .unwrap() + }; + assert_eq!(push(&mut pad, keyframe.clone(), 0), PushOutcome::Published); + pad.discontinuity(); + assert_eq!(push(&mut pad, headers, 33), PushOutcome::Published); + assert_eq!(push(&mut pad, delta.clone(), 66), PushOutcome::Dropped); + assert_eq!(push(&mut pad, keyframe, 100), PushOutcome::Published); + assert_eq!(push(&mut pad, delta, 133), PushOutcome::Published); + } + // Text and opaque tracks carry no codec jitter, so asking them to measure one is a mistake to report // rather than a setting to ignore. #[test]