Skip to content

refactor(gst): moqsrc playback helpers share one session context - #7558

Merged
moq-bot[bot] merged 5 commits into
mainfrom
quest/m2/gst-session-context
Nov 2, 2026
Merged

moq-bot[bot] merged 5 commits into
mainfrom
quest/m2/gst-session-context

Conversation

@kixelated

@kixelated kixelated commented Nov 1, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m2/gst-session-context.md and removes its milestone link.

Problem

moqsrc's playback helpers passed session plumbing to each other as separate arguments: run_session, follow_path, play, and follow_catalog each took the element, the pads, and the shutdown receiver (five arguments apiece), and Playback copied the same three fields again. Any new session-wide setting, such as the max-delay in moq-dev/moq#7084, has to be threaded through every one of them.

Approach

  • Add a private Session { element, pads, shutdown } context, built once per session by Session::new.
  • run (was run_session), follow_path, play, and follow_catalog are now Session methods. Each takes only what varies per call: the connection, origin, and path, the run's source, and its cancel handle.
  • Playback holds the Session plus the run's own broadcast, timeline, and stop, so followers and readers reach session state through playback.session.
  • Tests build a Session directly where they share pads across runs, and use Session::new otherwise.

A whitespace-insensitive diff is about half the size of the plain diff: most of the plain diff is the helper bodies indenting into impl Session.

Choices made without asking

  • Session holds only the state every level shared (element, pads, shutdown). The origin and the connection stay arguments: only run and follow_path use them, and the follow_catalog tests build their sources from origins of their own.
  • The helpers became methods rather than free functions that take &Session. The methods read better, but the move costs indentation churn.
  • Play still copies element and shutdown instead of holding a Session. Holding one would give each queued play a strong reference to the pad table, which PadActor deliberately reaches only weakly.
  • source_lost and catalog_lost moved below impl Session, so all of Session's methods sit in one block.

Impact

  • Public API: none. Wire: none. Behavior: none. Each clone of the shutdown receiver starts from the same seen version that the receiver passed down before this change had.

Coordination

moq-dev/moq#7084 (m1, moqsrc max-delay) already conflicts with main after moq-dev/moq#7368. Whichever PR lands second resolves the conflict. On top of this PR, max_delay becomes a Session field read in Reader::run, with no new arguments.

Validation

  • quest gate nix develop -c just ci origin/main passed, including 225/225 moq-gst tests and clippy.
  • quest check --base origin/main passed.

Follow-ups

None.

Review

mechanical fix by codex / Codex: Merged base and mechanically preserved configurable max-delay through the PR session context; passed cargo fmt -p moq-gst -- --check, cargo build -p moq-gst --locked, and cargo test -p moq-gst --locked with local GStreamer pkg-config/library paths configured. (head f8a7021)

  • Round 1: quest review --base origin/main, Codex, gpt-6.1-sol, medium effort, head a90236242c7a4ac686045d43dec11a9a2f6b11b1. 0 findings.

(Written by Claude Opus 5.5)

🤖 Generated with Claude Code

kixelated and others added 3 commits November 1, 2026 04:43
The session's element, pads, and shutdown travel together as a Session,
and run, follow_path, play, and follow_catalog are its methods, instead
of each helper taking them as separate arguments. A run's Playback holds
the Session plus its own broadcast, timeline, and stop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title moq-gst playback shares one session context refactor(gst): moqsrc playback helpers share one session context Nov 1, 2026
@kixelated
kixelated marked this pull request as ready for review November 1, 2026 12:49
@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 34f55f9d-1738-48bd-8f43-7d030684b07d
Commits

Reviewing files that changed from the base of the PR and between 21d6da9 and f8a7021.

Files selected for processing: 3
  • quest/m2/README.md
  • quest/m2/gst-session-context.md
  • rs/moq-gst/src/source/imp.rs
Files with no reviewable changes: 2
  • quest/m2/README.md
  • quest/m2/gst-session-context.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 2 remain after this review.

Walkthrough

Playback state now resides in a shared Session across broadcast runs. Session handles connection and shutdown, path announcements, catalog updates, and pad release. Playback, follower, and reader code now access session state through Session. Tests use the updated session methods. The related quest note and plan entry were removed.

Merge Risk: Minimal · up to f8a70

This is an internal refactor of playback helpers into a shared session context, with no stated public API or behavior change. No concrete merge-blocking risk was identified.

Pre-merge checks: Passed 5
Check name Status Explanation
Title check Passed The title clearly and concisely identifies the main change: refactoring moqsrc playback helpers to share a session context.
Description check Passed The description is directly related to the changeset and explains the session refactor, design choices, impact, and validation results.
Docstring Coverage Passed Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 84.62% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 13 functions across 1 files.

Finishing Touches
Simplify code
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Some tools did not complete. Review the errors below.

Clippy (1.99.0)

Clippy execution failed

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review by review (OpenAI)

Reviewed commit: a902362

No actionable bugs found. A private Session is a sensible simplification of the repeated plumbing: pad ownership remains session-wide while timelines and cancellation remain run-specific. Keeping Play's fields separate preserves the pad actor's weak ownership rather than introducing a reference cycle. The inspected shutdown, restart, and pad-release paths retain their behavior; no public API or wire change.

Verification: static inspection of the refactor, callers, ownership/cancellation paths, and updated test setup only. I did not run builds, GStreamer tests, or independently reproduce the reported gate results.

(Written by OpenAI)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • New Session context: a private, cloneable Session { element, pads, shutdown } (rs/moq-gst/src/source/imp.rs:748) built once by Session::new, which creates a fresh Pads::default() and holds the state every run, follower, and reader shares.
  • run_session becomes Session::run: takes &self plus only the connection, origin, and path (:769), preserving the dial-vs-shutdown race and the lost future.
  • follow_path, play, follow_catalog become methods: each drops the repeated pads/element/shutdown arguments (:795, :856, :871); follow_path now releases self.pads, and play clones the whole session for the spawned run.
  • Playback nests Session: replaces its three shared fields with one session (:1183) and migrates every access site (reconcile, Follower, Reader::run).
  • Tests and quest cleanup: tests use Session::new where pads are per-run and direct Session { .. } literals where pads are shared; the finished quest doc and its README entry are removed.

I verified the behavior-preserving claims: each Session clone of the shutdown receiver starts from the same seen version the moved receiver carried before (the Session field is never polled), Pads lifetime and refcounts are unchanged by creating it one frame earlier in Session::new, Play still holds element/shutdown directly rather than a Session, and no stale free-function call sites remain. The unrelated run_session/follow_catalog symbols in the hang/tokio examples and moq-rtc are different functions.

Technical details
# Behavior equivalence check

## Notes
- `run` and `follow_path` clone `self.shutdown` before polling; the `Session.shutdown`
  field itself is never polled, so every downstream clone sees the same version the
  original moved receiver carried (the poll that resolves only happens when shutdown
  fires, which breaks the loop).
- `Play.shutdown` is consumed only as `*play.shutdown.borrow()` in
  `PadActor::play` (`rs/moq-gst/src/source/imp.rs:703`); `watch` version state is
  irrelevant there.
- Original `follow_path` created `Pads::default()` locally; `Session::new` now creates
  it. The session is constructed immediately before `run`, so no other holder observes
  a different `Pads`. Early `run` returns drop an empty `Pads` (no `Drop` on `Pads`,
  only `PadTable`), so no release is skipped.
- No remaining callers of `follow_path`/`follow_catalog`/`run_session` free functions
  inside `rs/moq-gst`.

## Required outcome
- None; no change requested.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@kixelated
kixelated enabled auto-merge (squash) November 1, 2026 17:23
@moq-bot
moq-bot Bot disabled auto-merge November 2, 2026 03:15
@moq-bot
moq-bot Bot enabled auto-merge (squash) November 2, 2026 03:15

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Merged base main into the branch: the merge brought in the max-delay feature main now carries, and the branch folded that argument into the new session context instead of re-threading it as a parameter.
  • max_delay moved onto Session: added the field and a Session::new parameter, then populated it from settings.max_delay and read it in Reader::run through playback.session for Subscription::default().with_max_delay(max_delay).
  • Test coverage for the new plumbing: added a_rendition_subscribes_with_the_session_max_delay, and updated the refactor's test setup to pass DEFAULT_MAX_DELAY and build Session directly where pads are shared.

Behavior is unchanged from main: git diff --merge-base main shows only the refactor plus the max_delay field move, with main's property/Settings/DEFAULT_MAX_DELAY machinery untouched, so the merge dropped nothing. run_session has no remaining references in rs/moq-gst, and the Play.shutdown/Pads-lifetime equivalence points from the prior review still hold. I verified statically; pkg-config for GStreamer is unavailable in this environment, so I did not compile moq-gst locally.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@moq-bot
moq-bot Bot merged commit d1a4382 into main Nov 2, 2026
1 check passed
@moq-bot
moq-bot Bot deleted the quest/m2/gst-session-context branch November 2, 2026 03:49
kixelated added a commit that referenced this pull request Nov 2, 2026
Main's rational timestamps (#6946) replace the Dart durations export
beside the retired epoch export. Main's moq-c epoch validation (#7246)
has nothing to validate on an instance, which is any non-empty text: its
malformed-epoch cases are dropped, and the instance parse keeps its
MOQ_ERROR_INVALID_CONFIG mapping in one helper. Main's new relay-hops C
test and resume-history bench are ported onto instances, and moqsrc's
refactored session (#7558) logs the instance escaped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant