diff --git a/quest/m2/README.md b/quest/m2/README.md index d4de0062915..19b24ca7d95 100644 --- a/quest/m2/README.md +++ b/quest/m2/README.md @@ -229,7 +229,6 @@ lite-07; bitrate enforcement is not part of this release. - [Clean ALSA playback onset](/quest/m2/audio-alsa-onset.md) - no onset restarts or clicks over PulseAudio - [Interop audit](/quest/m2/audit-interop.md) - our interop runner entries match what we ship, and every red interop cell with a moq.dev side is fixed, reported, or noted as down or unsupported - [The HLS server follows each path once](/quest/m2/hls-follow-once.md) - `Following` reports synced absence, so moq-hls resolves with one follow -- [moq-gst playback shares one session context](/quest/m2/gst-session-context.md) - the playback helpers take one context instead of six arguments - [moq-bench pins the instances it measures](/quest/m2/bench-epoch-pin.md) - pooled requests pin their announced epoch, so a takeover is not counted as the same broadcast - [The memory bench finishes at 1 MiB frames](/quest/m2/memory-bench-hang.md) - the allocation mode's park at `size=1048576` is root-caused and fixed - [Audio's Latest start reaches back](/quest/m2/audio-latest-reach-back.md) - moq_audio's start covers min plus warmup like other consumers diff --git a/quest/m2/gst-session-context.md b/quest/m2/gst-session-context.md deleted file mode 100644 index d4699d7fa95..00000000000 --- a/quest/m2/gst-session-context.md +++ /dev/null @@ -1,17 +0,0 @@ -# [S] moq-gst playback shares one session context - -## Goal - -moq-gst's playback helpers take one session context instead of passing six -arguments of session plumbing to each other. - -## Plan - -Suggested by [moq-dev/moq#7084](https://github.com/moq-dev/moq/pull/7084). -The prerequisite pad-actor refactor landed in -[moq-dev/moq#7368](https://github.com/moq-dev/moq/pull/7368), reshaping the -same code. - -Decided 2026-10-30 (maintainer, /quest-plan of the 2026-10-30 /quest-complete follow-ups): ✅ new m2 quest, after moqsrc-pad-actor / fold into it / drop. - -Public API: none. Wire: none. diff --git a/rs/moq-gst/src/source/imp.rs b/rs/moq-gst/src/source/imp.rs index 51023cf9340..70110b5a57c 100644 --- a/rs/moq-gst/src/source/imp.rs +++ b/rs/moq-gst/src/source/imp.rs @@ -136,15 +136,9 @@ impl SessionController { let task_connection = connection.clone(); let task_element = element.clone(); Ok(Self::spawn(client, connection, element, move |shutdown| async move { - run_session( - &task_connection, - origin, - settings.broadcast, - settings.max_delay, - task_element, - shutdown, - ) - .await + Session::new(task_element, shutdown, settings.max_delay) + .run(&task_connection, &origin, &settings.broadcast) + .await })) } @@ -775,119 +769,224 @@ impl PadActor { } } -async fn run_session( - connection: &moq_tokio::Connection, - origin: moq_net::origin::Consumer, - broadcast: String, - max_delay: Duration, +/// What a session shares with every run, follower, and reader it starts, handed down as one +/// context rather than argument by argument. +#[derive(Clone)] +struct Session { element: glib::WeakRef, - mut shutdown: watch::Receiver, -) -> Result<()> { - // Stop closes the connection only after the session ends, so the dial races shutdown here. - tokio::select! { - established = moq_net::kio::wait(|waiter| connection.poll_established(waiter)) => established?, - _ = shutdown.changed() => return Ok(()), + /// How far a group may trail the live edge before a reader skips it. + max_delay: Duration, + /// Outlive every run, so a pipeline linked by name (`s.video_0 ! ...`) keeps flowing across a + /// restart. + pads: Pads, + /// Set by [`SessionController::stop`] before it flushes the pads. + shutdown: watch::Receiver, +} + +impl Session { + /// A session for `element`, with no pads yet. + fn new(element: glib::WeakRef, shutdown: watch::Receiver, max_delay: Duration) -> Self { + Self { + element, + max_delay, + pads: Pads::default(), + shutdown, + } } - // A temporary disconnect keeps the origin alive; only a terminal failure closes the loop. - let lost = async { - match connection.closed().await { - Ok(()) => anyhow::anyhow!("connection closed"), - Err(err) => anyhow::Error::from(err).context("connection closed"), + /// Wait for the dial, then follow `path` until the connection is lost for good or `shutdown` + /// fires. + async fn run( + &self, + connection: &moq_tokio::Connection, + origin: &moq_net::origin::Consumer, + path: &str, + ) -> Result<()> { + // Stop closes the connection only after the session ends, so the dial races shutdown here. + let mut shutdown = self.shutdown.clone(); + tokio::select! { + established = moq_net::kio::wait(|waiter| connection.poll_established(waiter)) => established?, + _ = shutdown.changed() => return Ok(()), } - }; - follow_path(&origin, &broadcast, max_delay, element, shutdown, lost).await -} -/// Follow the path's announcements for the whole session: play on a start, switch to the new -/// broadcast on a restart, and hold the pads from an end until the next start. Returns once -/// `shutdown` fires, `lost` resolves, or the origin closes. Every track is read with `max_delay`. -async fn follow_path( - origin: &moq_net::origin::Consumer, - path: &str, - max_delay: Duration, - element: glib::WeakRef, - mut shutdown: watch::Receiver, - lost: impl Future, -) -> Result<()> { - use moq_mux::follow::{Event, Instances}; - - let mut follow = Instances::new(origin, path, None)?; - let pads = Pads::default(); - let mut runs = tokio::task::JoinSet::new(); - // Cancels the latest run. - let mut latest: Option> = None; - let mut lost = std::pin::pin!(lost); - - tracing::info!(%path, "waiting for broadcast to be announced"); - let result = loop { - let broadcast = tokio::select! { - _ = shutdown.changed() => break Ok(()), - err = &mut lost => break Err(err), - event = follow.next() => match event { - Ok(Event::Start(broadcast)) => { - tracing::info!(%path, epoch = broadcast.info().epoch.as_ref().map(tracing::field::display), "online"); - Some(broadcast) + // A temporary disconnect keeps the origin alive; only a terminal failure closes the loop. + let lost = async { + match connection.closed().await { + Ok(()) => anyhow::anyhow!("connection closed"), + Err(err) => anyhow::Error::from(err).context("connection closed"), + } + }; + self.follow_path(origin, path, lost).await + } + + /// Follow the path's announcements for the whole session: play on a start, switch to the new + /// broadcast on a restart, and hold the pads from an end until the next start. Returns once + /// `shutdown` fires, `lost` resolves, or the origin closes, after releasing the pads. + async fn follow_path( + &self, + origin: &moq_net::origin::Consumer, + path: &str, + lost: impl Future, + ) -> Result<()> { + use moq_mux::follow::{Event, Instances}; + + let mut follow = Instances::new(origin, path, None)?; + let mut shutdown = self.shutdown.clone(); + let mut runs = tokio::task::JoinSet::new(); + // Cancels the latest run. + let mut latest: Option> = None; + let mut lost = std::pin::pin!(lost); + + tracing::info!(%path, "waiting for broadcast to be announced"); + let result = loop { + let broadcast = tokio::select! { + _ = shutdown.changed() => break Ok(()), + err = &mut lost => break Err(err), + event = follow.next() => match event { + Ok(Event::Start(broadcast)) => { + tracing::info!(%path, epoch = broadcast.info().epoch.as_ref().map(tracing::field::display), "online"); + Some(broadcast) + } + Ok(Event::End) => { + tracing::info!(%path, "offline, holding pads until it returns"); + None + } + Err(moq_mux::Error::Moq(moq_net::Error::Closed)) => break Ok(()), + Err(err) => break Err(anyhow::Error::from(err).context("broadcast refused")), + }, + joined = runs.join_next(), if !runs.is_empty() => match joined.expect("guarded by is_empty") { + Ok(Ok(())) => None, + Ok(Err(err)) => break Err(err), + Err(err) => break Err(anyhow::Error::from(err).context("run panicked")), + }, + }; + + if let Some(broadcast) = broadcast { + // Cut over at once: the old run's readers hand their pads back without waiting for their + // subscriptions to end. + if let Some(cancel) = latest.take() { + let _ = cancel.send(true); } - Ok(Event::End) => { - tracing::info!(%path, "offline, holding pads until it returns"); - None + latest = Some(self.play(&mut runs, moq_mux::Source::new(origin.clone(), broadcast))); + } + }; + + if let Some(cancel) = latest.take() { + let _ = cancel.send(true); + } + while runs.join_next().await.is_some() {} + // A stop removes the pads; anything else ends the stream downstream first. + let eos = !*shutdown.borrow(); + self.pads.release(eos).await; + result + } + + /// Start the instance handed out by the follower until it ends or is replaced, returning its + /// cancel handle. + fn play(&self, runs: &mut tokio::task::JoinSet>, source: moq_mux::Source) -> watch::Sender { + let (cancel, mut cancelled) = watch::channel(false); + let session = self.clone(); + runs.spawn_on( + STREAMING.scope(self.element.clone(), async move { + session.follow_catalog(source, &mut cancelled).await + }), + RUNTIME.handle(), + ); + cancel + } + + /// Follow one broadcast's catalog, with one [`Follower`] per broadcast its renditions reference. + /// Returns once the catalog closes and the last follower drains, or `cancel` fires. The pads stay + /// with the session, except those of renditions the catalog retired. + async fn follow_catalog(&self, source: moq_mux::Source, cancel: &mut watch::Receiver) -> Result<()> { + let broadcast = source.broadcast(); + let catalog_track = broadcast.track(hang::catalog::Catalog::DEFAULT_NAME)?; + // A publisher that never answers would otherwise hold the run until it is cancelled. + let catalog_track = tokio::select! { + track = catalog_track.subscribe(hang::catalog::Catalog::default_subscription()) => match track { + Ok(track) => track, + Err(err) if source_lost(&err) => { + tracing::warn!(%err, "catalog unavailable, holding pads"); + return Ok(()); } - Err(moq_mux::Error::Moq(moq_net::Error::Closed)) => break Ok(()), - Err(err) => break Err(anyhow::Error::from(err).context("broadcast refused")), - }, - joined = runs.join_next(), if !runs.is_empty() => match joined.expect("guarded by is_empty") { - Ok(Ok(())) => None, - Ok(Err(err)) => break Err(err), - Err(err) => break Err(anyhow::Error::from(err).context("run panicked")), + Err(err) => return Err(anyhow::Error::from(err).context("catalog refused")), }, + _ = cancel.changed() => return Ok(()), + }; + let mut catalog_consumer = moq_mux::catalog::hang::Consumer::new(catalog_track); + + // Follow the catalog for the whole run and reconcile against every update, rather than + // building the renditions once from the first frame. This covers reactive publishers (the + // browser via @moq/hang) that announce an empty catalog before their encoder configures, then + // add renditions a beat later, as well as renditions appearing, disappearing, or changing + // codec/resolution mid-stream. + let (stop, stopped) = watch::channel(false); + let playback = Playback { + session: self.clone(), + broadcast: broadcast.clone(), + timeline: Arc::default(), + stop: stopped, }; + let mut followers: HashMap = HashMap::new(); + // Woken when a follower runs out of renditions, so the run can let it go without waiting for + // another catalog update. + let emptied = Arc::new(tokio::sync::Notify::new()); + // The followers, and the retirements of pads the catalog no longer lists. + let mut tasks = tokio::task::JoinSet::new(); + let mut catalog_closed = false; + let mut result = Ok(()); - if let Some(broadcast) = broadcast { - // Cut over at once: the old run's readers hand their pads back without waiting for their - // subscriptions to end. - if let Some(cancel) = latest.take() { - let _ = cancel.send(true); + loop { + if catalog_closed && tasks.is_empty() { + break; + } + + tokio::select! { + biased; + // Ended by a restart, or the session ending. + _ = cancel.changed() => break, + _ = tasks.join_next(), if !tasks.is_empty() => {} + _ = emptied.notified() => followers.retain(|_, follower| !follower.plan.is_closed() && !follower.idle()), + // The guard stops us polling a closed catalog track (which would spin the loop + // returning None) while the followers drain. + next = catalog_consumer.next(), if !catalog_closed => match next { + Ok(Some(catalog)) => reconcile(&catalog, &source, &playback, &mut followers, &mut tasks, &emptied, cancel), + // Catalog track closed. Don't stop the followers: let each reader reach its natural + // end, and just stop reconciling while they drain. + // + // That includes a reader still resolving its subscription, which is + // indistinguishable here from one that has simply not been polled yet: a final + // snapshot naming a track the publisher does serve arrives this way, and stopping on + // "not live yet" would drop it. Whether a rendition will ever be served is the + // publisher's to answer, and ending the broadcast is where it does: every name it + // never served resolves with an error, which fails that reader's subscribe and ends + // it. + Ok(None) => catalog_closed = true, + Err(err) if catalog_lost(&err) => { + tracing::warn!(%err, "catalog lost, holding pads"); + catalog_closed = true; + } + Err(err) => { + result = Err(err.into()); + break; + } + }, + } + + if catalog_closed { + for (_, follower) in followers.drain() { + follower.plan.send_modify(|plan| plan.closed = true); + } } - latest = Some(play( - &mut runs, - moq_mux::Source::new(origin.clone(), broadcast), - max_delay, - &pads, - &element, - &shutdown, - )); } - }; - if let Some(cancel) = latest.take() { - let _ = cancel.send(true); - } - while runs.join_next().await.is_some() {} - // A stop removes the pads; anything else ends the stream downstream first. - let eos = !*shutdown.borrow(); - pads.release(eos).await; - result -} + // Stop every follower, then wait for each to hand its pads back. On the clean catalog-closed + // exit the tasks already drained, so this is a no-op. + let _ = stop.send(true); + while tasks.join_next().await.is_some() {} -/// Start the instance handed out by the follower until it ends or is replaced, returning its cancel handle. -fn play( - runs: &mut tokio::task::JoinSet>, - source: moq_mux::Source, - max_delay: Duration, - pads: &Pads, - element: &glib::WeakRef, - shutdown: &watch::Receiver, -) -> watch::Sender { - let (cancel, mut cancelled) = watch::channel(false); - let (pads, task_element, shutdown) = (pads.clone(), element.clone(), shutdown.clone()); - runs.spawn_on( - STREAMING.scope(element.clone(), async move { - follow_catalog(source, max_delay, &pads, task_element, &shutdown, &mut cancelled).await - }), - RUNTIME.handle(), - ); - cancel + result + } } /// Whether a failure is the source going away (its session closing, or its route going), which @@ -918,109 +1017,6 @@ fn catalog_lost(err: &moq_mux::Error) -> bool { } } -/// Follow one broadcast's catalog, with one [`Follower`] per broadcast its renditions reference. -/// Returns once the catalog closes and the last follower drains, or `cancel` fires. The pads stay -/// with the session, except those of renditions the catalog retired. -async fn follow_catalog( - source: moq_mux::Source, - max_delay: Duration, - pads: &Pads, - element: glib::WeakRef, - shutdown: &watch::Receiver, - cancel: &mut watch::Receiver, -) -> Result<()> { - let broadcast = source.broadcast(); - let catalog_track = broadcast.track(hang::catalog::Catalog::DEFAULT_NAME)?; - // A publisher that never answers would otherwise hold the run until it is cancelled. - let catalog_track = tokio::select! { - track = catalog_track.subscribe(hang::catalog::Catalog::default_subscription()) => match track { - Ok(track) => track, - Err(err) if source_lost(&err) => { - tracing::warn!(%err, "catalog unavailable, holding pads"); - return Ok(()); - } - Err(err) => return Err(anyhow::Error::from(err).context("catalog refused")), - }, - _ = cancel.changed() => return Ok(()), - }; - let mut catalog_consumer = moq_mux::catalog::hang::Consumer::new(catalog_track); - - // Follow the catalog for the whole run and reconcile against every update, rather than - // building the renditions once from the first frame. This covers reactive publishers (the - // browser via @moq/hang) that announce an empty catalog before their encoder configures, then - // add renditions a beat later, as well as renditions appearing, disappearing, or changing - // codec/resolution mid-stream. - let (stop, stopped) = watch::channel(false); - let playback = Playback { - element, - broadcast: broadcast.clone(), - max_delay, - pads: pads.clone(), - timeline: Arc::default(), - shutdown: shutdown.clone(), - stop: stopped, - }; - let mut followers: HashMap = HashMap::new(); - // Woken when a follower runs out of renditions, so the run can let it go without waiting for - // another catalog update. - let emptied = Arc::new(tokio::sync::Notify::new()); - // The followers, and the retirements of pads the catalog no longer lists. - let mut tasks = tokio::task::JoinSet::new(); - let mut catalog_closed = false; - let mut result = Ok(()); - - loop { - if catalog_closed && tasks.is_empty() { - break; - } - - tokio::select! { - biased; - // Ended by a restart, or the session ending. - _ = cancel.changed() => break, - _ = tasks.join_next(), if !tasks.is_empty() => {} - _ = emptied.notified() => followers.retain(|_, follower| !follower.plan.is_closed() && !follower.idle()), - // The guard stops us polling a closed catalog track (which would spin the loop - // returning None) while the followers drain. - next = catalog_consumer.next(), if !catalog_closed => match next { - Ok(Some(catalog)) => reconcile(&catalog, &source, &playback, &mut followers, &mut tasks, &emptied, cancel), - // Catalog track closed. Don't stop the followers: let each reader reach its natural - // end, and just stop reconciling while they drain. - // - // That includes a reader still resolving its subscription, which is - // indistinguishable here from one that has simply not been polled yet: a final - // snapshot naming a track the publisher does serve arrives this way, and stopping on - // "not live yet" would drop it. Whether a rendition will ever be served is the - // publisher's to answer, and ending the broadcast is where it does: every name it - // never served resolves with an error, which fails that reader's subscribe and ends - // it. - Ok(None) => catalog_closed = true, - Err(err) if catalog_lost(&err) => { - tracing::warn!(%err, "catalog lost, holding pads"); - catalog_closed = true; - } - Err(err) => { - result = Err(err.into()); - break; - } - }, - } - - if catalog_closed { - for (_, follower) in followers.drain() { - follower.plan.send_modify(|plan| plan.closed = true); - } - } - } - - // Stop every follower, then wait for each to hand its pads back. On the clean catalog-closed - // exit the tasks already drained, so this is a no-op. - let _ = stop.send(true); - while tasks.join_next().await.is_some() {} - - result -} - /// Bring the run in line with `catalog`: list its renditions on the pads, retiring the pads of /// those it dropped, and hand each referenced broadcast's follower the renditions that read it. /// @@ -1117,7 +1113,7 @@ fn reconcile( .cloned() .chain(disabled.iter().map(|(rendition, _)| rendition.clone())) .collect(); - playback.pads.list(listed, cancel); + playback.session.pads.list(listed, cancel); let mut plans: HashMap = HashMap::new(); for (rendition, shape) in desired { @@ -1179,7 +1175,7 @@ fn reconcile( } .run(instances, plan); tasks.spawn_on( - STREAMING.scope(playback.element.clone(), follower_task), + STREAMING.scope(playback.session.element.clone(), follower_task), RUNTIME.handle(), ); followers.insert( @@ -1211,20 +1207,15 @@ impl Followed { } } -/// What one broadcast run shares with every follower and reader it starts. Pads survive a -/// broadcast switch; its timing does not. +/// What one broadcast run shares with every follower and reader it starts. The session survives a +/// broadcast switch; the run's timing does not. #[derive(Clone)] struct Playback { - element: glib::WeakRef, + session: Session, /// The catalog's broadcast. A sibling outlives its closed catalog until it ends. broadcast: moq_net::broadcast::Consumer, - /// How far a group may trail the live edge before a reader skips it. - max_delay: Duration, - pads: Pads, /// Shared by the catalog's own renditions and the first instance of each sibling. timeline: Arc, - /// The session's shutdown, which [`SessionController::stop`] sets before it flushes the pads. - shutdown: watch::Receiver, /// Set once the run ends, stopping every follower. stop: watch::Receiver, } @@ -1400,7 +1391,7 @@ impl Follower { /// Bring the renditions in line with `wanted`, stopping each one reshaped or gone, and return /// those added or reshaped. [`Self::play`] starts the rest. fn apply(&mut self, mut wanted: HashMap) -> HashSet { - let pads = &self.playback.pads; + let pads = &self.playback.session.pads; let mut fresh = HashSet::new(); self.renditions .retain(|rendition, entry| match wanted.remove(rendition) { @@ -1499,7 +1490,7 @@ impl Follower { .map(|(serial, _)| *serial) .chain(self.current.as_ref().map(|current| current.serial)) .collect(); - let pads = &self.playback.pads; + let pads = &self.playback.session.pads; self.finished .retain(|rendition, serial| pads.is_listed(rendition) && serials.contains(&serial)); } @@ -1551,7 +1542,7 @@ impl Follower { }; let (rendition, id) = (rendition.clone(), self.next_id); self.readers.spawn_on( - STREAMING.scope(self.playback.element.clone(), async move { + STREAMING.scope(self.playback.session.element.clone(), async move { let exit = reader.run().await; (rendition, id, exit) }), @@ -1574,7 +1565,7 @@ impl Follower { if entry.draining { self.renditions.remove(&rendition); } else if let Exit::Unlisted = exit - && self.playback.pads.is_listed(&rendition) + && self.playback.session.pads.is_listed(&rendition) { // Delisted and listed again while it went to claim its pad, which the plan coalesced. self.play(); @@ -1631,13 +1622,12 @@ impl Reader { live, mut cancel, } = self; - let Playback { + let Session { element, max_delay, pads, shutdown, - .. - } = playback; + } = playback.session; let (kind, name) = (rendition.0, &rendition.1); // An instance that already played this track to its end on the pad would replay its last @@ -2289,10 +2279,7 @@ mod session_tests { use hang::catalog::{AudioCodec, AudioConfig, Container, H264, VideoCodec, VideoConfig}; use tokio::sync::watch; - use super::{ - DEFAULT_MAX_DELAY, NEXT_VIDEO_PAD_ID, Pads, ResolvedSettings, SessionController, TrackKind, follow_catalog, - follow_path, - }; + use super::{DEFAULT_MAX_DELAY, NEXT_VIDEO_PAD_ID, Pads, ResolvedSettings, Session, SessionController, TrackKind}; /// The pad-id counters are process-global, so a test reading one has to be the only test /// allocating while it runs. `cargo test` shares a process across tests (nextest doesn't), @@ -2329,15 +2316,9 @@ mod session_tests { let stopping = shutdown.clone(); let (origin, _driver) = moq_net::origin::Producer::new(Default::default()); let source = moq_mux::Source::new(origin.consume(), broadcast); - follow_catalog( - source, - DEFAULT_MAX_DELAY, - &Pads::default(), - element, - &stopping, - &mut shutdown, - ) - .await + Session::new(element, stopping, DEFAULT_MAX_DELAY) + .follow_catalog(source, &mut shutdown) + .await }) } @@ -2370,12 +2351,9 @@ mod session_tests { let source = moq_mux::Source::new(origin.consume(), broadcast.consume()); let (_stop, stopped) = watch::channel(false); let playback = super::Playback { - element: element.downgrade(), + session: Session::new(element.downgrade(), stopped.clone(), DEFAULT_MAX_DELAY), broadcast: broadcast.consume(), - max_delay: DEFAULT_MAX_DELAY, - pads: Pads::default(), timeline: Arc::default(), - shutdown: stopped.clone(), stop: stopped.clone(), }; let (plan, received) = watch::channel(super::Plan::default()); @@ -2540,9 +2518,14 @@ mod session_tests { let weak = element.downgrade(); let pads = pads.clone(); let source = moq_mux::Source::new(origin().consume(), broadcast.consume()); - let task = super::RUNTIME.spawn(async move { - follow_catalog(source, DEFAULT_MAX_DELAY, &pads, weak, &shutdown, &mut cancelled).await - }); + let session = Session { + max_delay: DEFAULT_MAX_DELAY, + element: weak, + pads, + shutdown, + }; + let task = + super::RUNTIME.spawn(async move { session.follow_catalog(source, &mut cancelled).await }); let first = usize::from(audio_first); let other = 1 - first; let mut write = |index: usize, seconds: u64| { @@ -2638,15 +2621,9 @@ mod session_tests { let consumer = origin.consume(); let weak = element.downgrade(); let following = super::RUNTIME.spawn(async move { - follow_path( - &consumer, - "room/catalog", - DEFAULT_MAX_DELAY, - weak, - shutdown, - std::future::pending(), - ) - .await + Session::new(weak, shutdown, DEFAULT_MAX_DELAY) + .follow_path(&consumer, "room/catalog", std::future::pending()) + .await }); let (path, request) = super::RUNTIME.block_on(async { tokio::select! { @@ -2774,7 +2751,9 @@ mod session_tests { let source = moq_mux::Source::new(origin().consume(), broadcast.consume()); let session = super::RUNTIME.spawn(async move { let stopping = cancelled.clone(); - follow_catalog(source, max_delay, &Pads::default(), weak, &stopping, &mut cancelled).await + Session::new(weak, stopping, max_delay) + .follow_catalog(source, &mut cancelled) + .await }); let request = await_request(&mut dynamic); @@ -3279,9 +3258,13 @@ mod session_tests { let pads = pads.clone(); let weak = element.downgrade(); let source = moq_mux::Source::new(origin().consume(), broadcast.consume()); - super::RUNTIME.spawn(async move { - follow_catalog(source, DEFAULT_MAX_DELAY, &pads, weak, &shutdown, &mut cancelled).await - }) + let session = Session { + max_delay: DEFAULT_MAX_DELAY, + element: weak, + pads, + shutdown, + }; + super::RUNTIME.spawn(async move { session.follow_catalog(source, &mut cancelled).await }) }; let pad = super::RUNTIME.block_on(adds.recv()).unwrap(); assert!(pad.starts_with("video_"), "{pad} was added first"); @@ -3442,15 +3425,9 @@ mod session_tests { connection.clone(), element.downgrade(), move |shutdown| async move { - follow_path( - &origin, - "room", - DEFAULT_MAX_DELAY, - weak, - shutdown, - std::future::pending(), - ) - .await + Session::new(weak, shutdown, DEFAULT_MAX_DELAY) + .follow_path(&origin, "room", std::future::pending()) + .await }, ); (session, connection) @@ -3646,12 +3623,14 @@ mod session_tests { let instance = publisher.broadcast.consume(); let reader = super::Reader { playback: super::Playback { - element: element.downgrade(), + session: Session { + max_delay: DEFAULT_MAX_DELAY, + element: element.downgrade(), + pads, + shutdown, + }, broadcast: instance.clone(), - max_delay: DEFAULT_MAX_DELAY, - pads, timeline: Arc::default(), - shutdown, stop, }, rendition, @@ -3831,15 +3810,9 @@ mod session_tests { let (shutdown, stopping) = watch::channel(false); let (origin, weak) = (origin.consume(), element.downgrade()); let task = super::RUNTIME.spawn(async move { - follow_path( - &origin, - "room", - DEFAULT_MAX_DELAY, - weak, - stopping, - std::future::pending(), - ) - .await + Session::new(weak, stopping, DEFAULT_MAX_DELAY) + .follow_path(&origin, "room", std::future::pending()) + .await }); (shutdown, task) } @@ -4141,15 +4114,9 @@ mod session_tests { let weak = element.downgrade(); let source = moq_mux::Source::new(origin.consume(), room.broadcast.consume()); super::RUNTIME.spawn(async move { - follow_catalog( - source, - DEFAULT_MAX_DELAY, - &Pads::default(), - weak, - &shutdown, - &mut cancelled, - ) - .await + Session::new(weak, shutdown, DEFAULT_MAX_DELAY) + .follow_catalog(source, &mut cancelled) + .await }) };