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 py/moq-rs/tests/test_testing_clock.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ async def main():

# Group 0 stalls with no frame, so the in-order read waits on it until
# group 1 has been out for max_delay: a native timer is pending.
track.append_group()
_stalled = track.append_group()
later = track.append_group()
later.write_frame(b"later")
later.finish()
Expand Down
1 change: 0 additions & 1 deletion quest/m1/public-model/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ Work owned by this README, after the children land:

## Required

- [One group writer](/quest/m1/public-model/group-writer.md) - `group::Producer` is not `Clone`; the model and sessions hold a crate-private handle that cannot write or finish
- [Public ingest](/quest/m1/public-model/ingest.md) - a custom subscriber writes received groups, frames, starts, and ends into a track through public calls
- [Public serving](/quest/m1/public-model/serve.md) - a custom publisher reads a track's start, cursor, and group expiry for its wire through public calls
- [Public routes and answering](/quest/m1/public-model/answer.md) - a custom relay ingests routes, answers broadcast and track requests on demand, and advertises without echoing a peer's routes back
Expand Down
118 changes: 0 additions & 118 deletions quest/m1/public-model/group-writer.md

This file was deleted.

16 changes: 5 additions & 11 deletions quest/m1/public-model/ingest.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,22 +64,20 @@ Rust items (`rs/moq-net/src/model/`), as they stood at b4eab0db1:
it).
- ✅ Make one open frame per group a compile-time guarantee. Drop public
`Clone` from `group::Producer`; the model and sessions keep a
crate-private duplicate. The chunked writer is owned:
crate-private non-writing handle. The chunked writer is owned:
`group::Producer::create_frame(self, info) -> Result<frame::Producer>`
aborts the group with the error on failure (an oversized frame, a
timestamp mismatch, or a closed group are bugs or protocol errors),
`frame::Producer::finish(self) -> Result<group::Producer>` hands it
back, and `frame.group()` gives read access (demand, info, closed)
while the frame is open. `write_frame(&mut self)` stays for one-shot
frames. The borrowing `create_frame` and `ProducerOwned` go, with the
stale "caller's promise" doc; `FrameOpen` stays only as a backstop for
crate-internal duplicates. `track::Producer` keeps `Clone`: several
stale "caller's promise" doc. `track::Producer` keeps `Clone`: several
writers creating groups is legitimate, and `claim_sequence` already
refuses a duplicate sequence.
- Dropping `Clone` and the crate-private non-writing handle moved to
[One group writer](/quest/m1/public-model/group-writer.md), which
names the handle `group::Handle` and deletes `FrameOpen` (decided
2026-10-18, #5892), so the backstop above goes. This item keeps the
- #6020 dropped `Clone`, added the crate-private non-writing
`group::Handle`, and deleted `FrameOpen` (decided 2026-10-18, #5892),
so the backstop above goes. This item keeps the
public owned chunked writer. Its callers that hold a
`&mut group::Producer` (hang's `Frame::write_to`, moq-mux's LOC and
fMP4 encoders) cannot call a consuming `create_frame(self)`; weigh
Expand Down Expand Up @@ -207,10 +205,6 @@ Tests: each public call gets a mock-time test in its language, and the
built-in subscribers move onto the public calls, so their existing suites
cover the behavior.

## Required

- [One group writer](/quest/m1/public-model/group-writer.md) - the non-Clone writer the owned chunked writer builds on

## Closes

- [#5862](https://github.com/moq-dev/moq/issues/5862) - no way to accept a track::Request with content
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-c/src/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ impl Publish {

/// Finish a raw group. No more frames can be written.
pub fn group_finish(&mut self, group: Id) -> Result<(), Error> {
let group = self.groups.remove(group).ok_or(Error::GroupNotFound)?;
let mut group = self.groups.remove(group).ok_or(Error::GroupNotFound)?;
group.finish()?;
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-e2ee/src/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Producer {
/// # Errors
///
/// A net error if the group is already closed.
pub fn finish(self) -> Result<()> {
pub fn finish(mut self) -> Result<()> {
self.inner.finish()?;
Ok(())
}
Expand Down
21 changes: 19 additions & 2 deletions rs/moq-ffi/src/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,32 @@ impl MoqGroupProducer {
impl MoqGroupProducer {
/// Wait until a consumer has this group.
pub(crate) async fn used(&self) -> Result<(), MoqError> {
let producer = self.inner.lock().unwrap().as_ref().ok_or(MoqError::Closed)?.clone();
Ok(producer.demand().used().await?)
let demand = self.inner.lock().unwrap().as_ref().ok_or(MoqError::Closed)?.demand();
Ok(demand.used().await?)
}
}

#[cfg(test)]
mod metadata_tests {
use super::*;

#[test]
fn dropping_a_group_binding_ends_its_unfinished_group() {
let broadcast = moq_net::broadcast::Info::new().produce();
let track = broadcast.create_track("test", moq_net::track::Info::default()).unwrap();
let group = track.append_group().unwrap();
let mut consumer = group.consume();
let binding = MoqGroupProducer {
sequence: group.sequence,
inner: std::sync::Mutex::new(Some(group)),
};
drop(binding);
assert!(matches!(
consumer.poll_read_frame(&moq_net::kio::Waiter::noop()),
std::task::Poll::Ready(Err(moq_net::Error::Dropped))
));
}

#[test]
fn untimed_info_round_trips_through_the_binding() {
let original = moq_net::track::Info::default();
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-ffi/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1298,7 +1298,7 @@ async fn json_consumer_takes_an_unread_track() {
.subscribe_track("events".into(), None)
.await
.unwrap();
track.append_group().unwrap();
track.append_group().unwrap().finish().unwrap();
tokio::time::timeout(TIMEOUT, read.recv_group())
.await
.expect("timed out waiting for a group")
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-flate/src/stream/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ impl Inner {
// second group, and (with compression) write into it from a window the consumer never
// received. That is exactly the split log ending the track exists to prevent.
let group = match self.group.take() {
Some(group) => group.finish(),
Some(mut group) => group.finish(),
None => Ok(()),
};
let track = self.track.finish();
Expand Down
6 changes: 3 additions & 3 deletions rs/moq-json/src/snapshot/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ struct Track {
impl Track {
/// Finish the open group without opening a replacement.
fn cut(&mut self) -> Result<()> {
if let Some(group) = self.group.take() {
if let Some(mut group) = self.group.take() {
group.finish()?;
}
Ok(())
Expand Down Expand Up @@ -401,7 +401,7 @@ impl Track {
/// Close the open group and write a snapshot as the first frame of a new one.
fn write_snapshot(&mut self, timestamp: Option<moq_net::Timestamp>, payload: bytes::Bytes) -> Result<()> {
// The previous group is complete; no more frames will be appended to it.
if let Some(group) = self.group.take() {
if let Some(mut group) = self.group.take() {
group.finish()?;
}

Expand Down Expand Up @@ -434,7 +434,7 @@ impl Track {
}

fn finish(&mut self) -> Result<()> {
if let Some(group) = self.group.take() {
if let Some(mut group) = self.group.take() {
group.finish()?;
}
self.inner.finish()?;
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-json/src/stream/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl Track {
// second group, and (with compression) write into it from a window the consumer never
// received. That is exactly the split log ending the track exists to prevent.
let group = match self.group.take() {
Some(group) => group.finish(),
Some(mut group) => group.finish(),
None => Ok(()),
};
let track = self.inner.finish();
Expand Down
6 changes: 3 additions & 3 deletions rs/moq-json/src/window/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ impl<T> Inner<T> {
}

fn cut(&mut self) -> Result<()> {
let Some(group) = self.track.group.take() else {
let Some(mut group) = self.track.group.take() else {
return Ok(());
};
// The group closes either way, so reset first: a `finish` error must not leave the encoder
Expand Down Expand Up @@ -205,7 +205,7 @@ impl Track {
/// Close the open group and write the header as the first frame of a new one.
fn write_header(&mut self, timestamp: Option<moq_net::Timestamp>, payload: bytes::Bytes) -> Result<()> {
// The previous group is complete; no more frames will be appended to it.
if let Some(group) = self.group.take() {
if let Some(mut group) = self.group.take() {
group.finish()?;
}

Expand All @@ -232,7 +232,7 @@ impl Track {
}

fn finish(&mut self) -> Result<()> {
if let Some(group) = self.group.take() {
if let Some(mut group) = self.group.take() {
group.finish()?;
}
self.inner.finish()?;
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-mux/src/container/consumer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3710,7 +3710,7 @@ mod tests {
track.subscribe(moq_net::track::Subscription::default().with_max_delay(Duration::from_millis(500)));
let mut consumer = Consumer::new(consumer_track, Container::Legacy(crate::container::Kind::Data));

let group0 = track.create_group(moq_net::group::Info { sequence: 0 }).unwrap();
let mut group0 = track.create_group(moq_net::group::Info { sequence: 0 }).unwrap();
group0.finish().unwrap();

write_group(&mut track, 1, &[ts(30_000)]);
Expand Down
6 changes: 3 additions & 3 deletions rs/moq-mux/src/container/fmp4/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,7 +1012,7 @@ impl<E: crate::catalog::hang::CatalogExt> Import<E> {
let new_segment = track.segment != Some(self.segment);
let start_group = track.group.is_none() || new_segment;
let mut g = if start_group {
if let Some(prev) = track.group.take() {
if let Some(mut prev) = track.group.take() {
prev.finish()?;
if let Some(recorder) = track.recorder.as_mut() {
recorder.finish_group(prev.sequence);
Expand Down Expand Up @@ -1085,7 +1085,7 @@ impl<E: crate::catalog::hang::CatalogExt> Import<E> {
for track in self.tracks.values_mut() {
track.estimator.cut(None);
track.publish_estimate()?;
if let Some(g) = track.group.take() {
if let Some(mut g) = track.group.take() {
g.finish()?;
if let Some(recorder) = track.recorder.as_mut() {
recorder.finish_group(g.sequence);
Expand Down Expand Up @@ -1128,7 +1128,7 @@ impl<E: crate::catalog::hang::CatalogExt> Import<E> {
for track in self.tracks.values_mut() {
track.estimator.cut(None);
track.publish_estimate()?;
if let Some(g) = track.group.take() {
if let Some(mut g) = track.group.take() {
g.finish()?;
if let Some(recorder) = track.recorder.as_mut() {
recorder.finish_group(g.sequence);
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-mux/src/container/mkv/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ impl<E: crate::catalog::hang::CatalogExt> Import<E> {
// No frame follows to anchor the clock, so publish the declared track set now.
self.initial_reservation = None;
for track in self.tracks.values_mut() {
if let Some(g) = track.group.take() {
if let Some(mut g) = track.group.take() {
g.finish()?;
}
track.track.finish()?;
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-mux/src/container/producer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ where
if let Some(group) = self.group.as_mut() {
self.container.finish_group(group, tail_end)?;
}
if let Some(group) = self.group.take() {
if let Some(mut group) = self.group.take() {
group.finish()?;
if let Some(recorder) = self.recorder.as_mut() {
recorder.finish_group(group.sequence);
Expand Down
4 changes: 2 additions & 2 deletions rs/moq-mux/src/container/ts/export_timing_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ impl Live {
} else {
let tick = self.tick;
let keyframe = tick.is_multiple_of(GOP);
if keyframe && let Some(group) = self.group.take() {
if keyframe && let Some(mut group) = self.group.take() {
match std::mem::take(&mut self.stalling) {
true => self.stalled.push(group),
false => group.finish().unwrap(),
Expand Down Expand Up @@ -281,7 +281,7 @@ impl Live {

/// End the broadcast and let every leg render what it holds.
async fn finish(&mut self, legs: &mut [&mut Leg]) {
if let Some(group) = self.group.take() {
if let Some(mut group) = self.group.take() {
group.finish().unwrap();
}
self.stalled.clear();
Expand Down
2 changes: 1 addition & 1 deletion rs/moq-mux/src/container/ts/release_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ fn republish_cut(
}

/// Finish `group`, or abort it as evicted if it is one of the `cut`.
fn end(sequence: u64, group: moq_net::group::Producer, cut: &[u64]) {
fn end(sequence: u64, mut group: moq_net::group::Producer, cut: &[u64]) {
match cut.contains(&sequence) {
true => group.abort(moq_net::Error::Old).unwrap(),
false => group.finish().unwrap(),
Expand Down
Loading