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
35 changes: 0 additions & 35 deletions quest/m0/ts-congested-path.md

This file was deleted.

27 changes: 20 additions & 7 deletions rs/moq-mux/src/container/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -486,9 +486,10 @@ impl ExportSource {
}

/// Start at the newest group, the live edge, rather than the oldest one the max delay still
/// reaches. The subscription carries the max delay from the start: under a zero budget every
/// hop drops each group a newer one supersedes, and raising it later cannot recover the
/// groups that follow the edge.
/// reaches. The subscription asks to join at the edge too, whatever the delay's min, so a hop
/// whose protocol carries a join's min spends no path on groups this reader skips. It carries
/// the max delay from the start: under a zero budget every hop drops each group a newer one
/// supersedes, and raising it later cannot recover the groups that follow the edge.
pub fn live(mut self) -> Self {
self.start().live = true;
self
Expand Down Expand Up @@ -699,7 +700,13 @@ impl ExportSource {
let instance = binding.sibling().then(|| broadcast.clone());
let subscription =
moq_net::track::Subscription::default().with_ranges([floor_range(start.floor, self.delay)]);
let subscription = self.delay.subscription(subscription);
// A live start reads from the newest group, so it joins there: history behind the edge
// would only be skipped, after crowding out the newest group on a narrow path.
let delay = match start.live {
true => self.delay.with_min(Duration::ZERO),
false => self.delay,
};
let subscription = delay.subscription(subscription);
let track = match broadcast.track(&self.target.track) {
Ok(track) => track,
Err(_) if instance.as_ref().is_some_and(|i| i.poll_closed(waiter).is_ready()) => return self.end(),
Expand Down Expand Up @@ -1329,7 +1336,9 @@ mod tests {

/// The requested budget must be present on the first SUBSCRIBE, a live start's too. Updating
/// it after SUBSCRIBE_OK cannot recover backlog the publisher already skipped, nor the groups a
/// zero budget drops as superseded before the update lands.
/// zero budget drops as superseded before the update lands. A live start joins at the edge,
/// since it would skip any history behind it, and on a narrow path that history delays the
/// newest group by a group or two.
#[tokio::test]
async fn latency_is_sent_with_the_initial_subscription() {
for live_start in [false, true] {
Expand All @@ -1348,15 +1357,19 @@ mod tests {
let _ = export.poll_read(waiter);
match live.track.subscription() {
Some(subscription) => Poll::Ready(subscription.ranges.iter().find_map(|range| match range.start {
moq_net::track::Start::Live { max, .. } => Some(max),
moq_net::track::Start::Live { min, max } => Some((min, max)),
_ => None,
})),
None => Poll::Pending,
}
})
.await;

assert_eq!(observed, Some(Some(max_delay)), "live start: {live_start}");
let min = match live_start {
true => std::time::Duration::ZERO,
false => max_delay,
};
assert_eq!(observed, Some((Some(min), Some(max_delay))), "live start: {live_start}");
}
}

Expand Down
7 changes: 4 additions & 3 deletions rs/moq-mux/src/container/ts/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1705,8 +1705,8 @@ where
/// video track that dropped one resumes at its next keyframe. A source whose clock runs
/// further off ours than 13818-1 lets the PCR follow fails the export once it has used half
/// the delay, where a brief network stall only drops what it made late. Every track is
/// subscribed with the whole delay as its min and max, so a relay resets a group only once it
/// is that old. The export skips a stalled group once it falls the whole delay behind the
/// subscribed with the whole delay as its max, so a relay resets a group only once it is that
/// old; a live export joins at the edge, and a replay reaches back the whole delay. The export skips a stalled group once it falls the whole delay behind the
/// newest content (see [`Consumer`](crate::container::Consumer)), so a stall shorter than the
/// delay loses nothing, while a group whose tail never arrives makes the start of the next one
/// late.
Expand Down Expand Up @@ -4772,7 +4772,8 @@ fn video_kind(config: &VideoConfig, name: &str) -> Result<Kind> {
}

/// The delay a track subscription states for an export running `delay` behind: all of it, as both
/// bounds, so a relay resets a group only once it is that old.
/// bounds, so a relay resets a group only once it is that old and a replay reaches back that far.
/// A live start joins at the edge whatever the min ([`ExportSource::live`]).
pub(super) fn subscribed(delay: Duration) -> crate::container::Delay {
crate::container::Delay::default().with_min(delay).with_max(delay)
}
Expand Down
52 changes: 32 additions & 20 deletions rs/moq-mux/src/container/ts/export_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10619,28 +10619,40 @@ async fn a_follower_keeps_a_return_awaiting_its_catalog_when_a_stitch_goes() {
assert_eq!(start.elapsed(), follow);
}

/// Each track subscription joins live the whole delay back and states it as its max, so a relay
/// holds a group as long as the export could still play it.
/// Each track subscription states the whole delay as its max, so a relay holds a group as long as
/// the export could still play it. A live export joins at the edge, where it starts reading, so no
/// backlog it would skip crowds out the newest group; a replay reaches back the whole delay.
#[tokio::test(start_paused = true)]
async fn a_subscription_states_the_whole_delay() {
let origin = crate::source::produce_origin();
let (live, mut catalog) = publish_bare(&origin, None);
let mut audio = aac_rendition(&mut live.broadcast().clone(), &mut catalog, "a.aac");
write_aac(&mut audio, 0);
let delay = Duration::from_secs(2);
let mut export = open_export(crate::source::resolved(&origin, "live").await, delay)
.await
.unwrap();
let _ = kio::clock::timeout(Duration::from_secs(1), export.next()).await;
let subscription = audio.track().subscription().unwrap();
assert_eq!(
subscription.ranges,
[moq_net::track::Range::from(moq_net::track::Start::Live {
min: Some(delay),
max: Some(delay),
})]
);
drop((live, catalog));
for replay in [false, true] {
let origin = crate::source::produce_origin();
let (live, mut catalog) = publish_bare(&origin, None);
let mut audio = aac_rendition(&mut live.broadcast().clone(), &mut catalog, "a.aac");
write_aac(&mut audio, 0);
let delay = Duration::from_secs(2);
let export = open_export(crate::source::resolved(&origin, "live").await, delay)
.await
.unwrap();
let mut export = match replay {
true => export.with_replay(),
false => export,
};
let _ = kio::clock::timeout(Duration::from_secs(1), export.next()).await;
let subscription = audio.track().subscription().unwrap();
let min = match replay {
true => delay,
false => Duration::ZERO,
};
assert_eq!(
subscription.ranges,
[moq_net::track::Range::from(moq_net::track::Start::Live {
min: Some(min),
max: Some(delay),
})],
"replay: {replay}"
);
drop((live, catalog));
}
}

/// A program that ends while stitching, then returns after the unresolved replacement goes,
Expand Down