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
25 changes: 0 additions & 25 deletions quest/m1/lite07-idle-oldest.md

This file was deleted.

14 changes: 7 additions & 7 deletions rs/moq-net/src/lite/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10698,7 +10698,7 @@ impl TrackServe {
(None, Sub::Active(active)) if !fills.is_empty() => active.demand.clone(),
(pref, _) => pref,
};
let request = self.wire_request(pref, opening, producer.idle_newest());
let request = self.wire_request(pref, producer.idle_newest().filter(|_| opening));
// The demand's ranges and the fills' groups, widened together until they fit.
let (request, groups) = match ranged {
true => {
Expand Down Expand Up @@ -10865,12 +10865,11 @@ impl TrackServe {
/// What a SUBSCRIBE carries for the demand `pref`: the subscription and its ranges, or
/// `None` when it asks for nothing.
///
/// `opening` when this opens a subscription for a copy whose newest cached group, while
/// idle, is `newest`.
/// `newest` when this opens a subscription for a copy whose newest cached group, while
/// idle, is that group.
fn wire_request(
&self,
pref: Option<Subscription>,
opening: bool,
newest: Option<u64>,
) -> Option<(Subscription, Vec<lite::Range>)> {
// An empty half-open range asks for nothing, and the wire cannot say that: its
Expand All @@ -10890,14 +10889,15 @@ impl TrackServe {
// the subscriber has no start of its own: a quiet track (a catalog) sends
// that group again, which says the cache is current. A lite-07 list keeps
// any range of its own, so only one asking just for the live or oldest group
// counts.
// counts. A copy that cached nothing keeps the subscriber's ranges: no start
// would widen a live viewer's ask to every group from the oldest.
let idle = subscription.start().is_none()
&& (!ranged
|| subscription
.ranges
.iter()
.all(|range| range.end.is_none() && matches!(range.start, Anchor::Oldest | Anchor::Relative(0))));
if opening && idle {
if let Some(newest) = newest.filter(|_| idle) {
subscription = subscription.with_start(newest);
}
wire_ranges(&subscription).map(|ranges| (subscription, ranges))
Expand All @@ -10907,7 +10907,7 @@ impl TrackServe {
/// registered with its copy pending. `None` when it asks for nothing.
fn pipeline(&self, pref: Subscription) -> Result<Option<Pipelined>, Error> {
// A copy not accepted yet caches nothing.
let Some((subscription, ranges)) = self.wire_request(Some(pref.clone()), true, None) else {
let Some((subscription, ranges)) = self.wire_request(Some(pref.clone()), None) else {
return Ok(None);
};
let ranges = match self.subscriber.version.has_ranges() {
Expand Down
48 changes: 48 additions & 0 deletions rs/moq-net/tests/integration/subscribe_ranges.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,54 @@ async fn sparse_ranges_reach_the_publisher_on_lite07() {
}
}

/// A live viewer's fresh lite-07 copy, cached nothing yet, asks its upstream for the live
/// edge, not every group from the oldest, directly or through a relay.
#[kio::test]
async fn a_live_viewer_asks_lite07_upstream_for_the_live_edge() {
let version: Version = "moq-lite-07-wip".parse().unwrap();
for relay in [false, true] {
let publisher = produce_origin(1);
let broadcast = publisher
.route("bcast", moq_net::origin::RouteOptions::hidden())
.unwrap();
let track = broadcast.broadcast().create_track("quiet", timed()).unwrap();
broadcast.announce().unwrap();

let relay_origin = produce_origin(2);
let subscriber = produce_origin(3);
let mut sessions = Vec::new();
if relay {
let mut options = MockConnectOptions::new(version);
options.server_publish = Some(publisher.consume());
options.client_subscribe = Some(relay_origin.clone());
sessions.push(connect_mock(options).await);
}
let mut options = MockConnectOptions::new(version);
options.server_publish = Some(match relay {
true => relay_origin.consume(),
false => publisher.consume(),
});
options.client_subscribe = Some(subscriber.clone());
sessions.push(connect_mock(options).await);

let consumer = subscriber.consume();
let remote = kio::clock::timeout(TIMEOUT, consumer.follow("bcast", None).unwrap().available())
.await
.expect("resolve timeout")
.expect("broadcast resolves")
.unwrap();

let _live = subscribe(&remote, Subscription::default().with_ranges([Range::live()])).await;
kio::clock::timeout(TIMEOUT, crate::support::wanted(track.demand()))
.await
.expect("no subscriber appeared")
.unwrap();
let asked = track.subscription().expect("the publisher holds the demand").ranges;
assert_eq!(asked, [Range::live()], "relay={relay}");
drop((track, sessions, relay_origin, subscriber, broadcast, publisher));
}
}

/// A subscriber from group 4 merged with a live one doesn't floor the shared subscription
/// at 4: the live one still gets group 3.
#[kio::test]
Expand Down