refactor(moq-net): broadcasts own tracks own groups own frames via inherited Arc<Info>#1900
Merged
Conversation
…herited Arc<Info> Make the model a strict ownership chain: a child is born only from its parent's `create_*`, and each level inherits its parent's `Arc<Info>` so properties (notably the track timescale) are inherited rather than passed piecemeal. Ownership: - `TrackProducer::new` and `TrackRequest::new` are now `pub(crate)`. The public ways to mint a track are `BroadcastProducer::create_track` / `reserve_track`, or a dynamic `TrackRequest`. - `BroadcastProducer::insert_track` is removed. The one production user (the IETF PUBLISH path) now announces the broadcast first, then `create_track`s the track from it, undoing the announce on the error paths. - Standalone `BroadcastInfo::produce()` is kept (origin-owned broadcasts are still a follow-up, like `Arc<OriginInfo>`). Inherited Arc chain: - `BroadcastProducer`/`Consumer`/`Dynamic` hold `Arc<BroadcastInfo>`, threaded into each track (`TrackProducer::broadcast()`). - `TrackState` holds `Option<Arc<TrackInfo>>`; each group inherits a shared `Arc<TrackInfo>` (replacing the copied-out `Option<Timescale>`), and `GroupProducer::timescale()` reads through it. - `GroupProducer`/`Consumer` hold `Arc<GroupInfo>`, threaded into each frame (`FrameProducer::group()`). Rename `Group` -> `GroupInfo` and `Frame` -> `FrameInfo` to match the existing `BroadcastInfo`/`TrackInfo` convention (the wire `lite::Group`/`ietf::Group` are unchanged). Breaking change, targets `dev`. js/net mirror + doc/concept are a follow-up. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
… Arc These three info structs are small all-scalar values, so an Arc is overkill: make them `Copy` and inherit them by value down the chain. Only `BroadcastInfo` (which holds an `OriginList` Vec) stays behind an `Arc`. The info accessors (`TrackSubscriber::info`, `FrameProducer::group`, the Group Deref, etc.) still hand out `&T` references, so the internal storage can move back to `Arc<T>` later without a breaking change. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the moq-net model a strict ownership chain: a child is born only from its parent's
create_*, and each level inherits its parent'sArc<Info>so properties (notably the track timescale) are inherited rather than passed piecemeal.Ownership: children are born only from parents
TrackProducer::newandTrackRequest::neware nowpub(crate). The only public ways to mint a track areBroadcastProducer::create_track/reserve_track, or a dynamicTrackRequest.BroadcastProducer::insert_trackis removed. Its one production user, the IETFPUBLISHpath inietf/subscriber.rs, nowstart_announces the broadcast first and thencreate_tracks the track from it (so the track is genuinely born from its broadcast), undoing the announce on the error paths.BroadcastInfo::produce()is kept, as agreed. Origin-owned broadcasts (Arc<OriginInfo>) remain a deliberate follow-up.Inherited
Arc<Info>chainBroadcastProducer/BroadcastConsumer/BroadcastDynamicholdArc<BroadcastInfo>, threaded into every track viacreate_track/reserve_track/TrackRequest::accept. Exposed asTrackProducer::broadcast().TrackStateholdsOption<Arc<TrackInfo>>; each group inherits a sharedArc<TrackInfo>clone (replacing the copied-outOption<Timescale>), andGroupProducer::timescale()reads through it.GroupProducer/GroupConsumerholdArc<GroupInfo>, threaded into every frame. Exposed asFrameProducer::group().Rename
Group→GroupInfoandFrame→FrameInfo, matching the existingBroadcastInfo/TrackInfoconvention. The wire typeslite::Group/ietf::Groupare unchanged.Cascade
The only breakage anywhere in the workspace was test-site callers of the now-private constructors (moq-mux ×3 files, moq-json, moq-native test) and qualified
moq_net::Group/Framerefs (moq-mux, hang). No production code outside moq-net needed changes. Test sites were migrated tocreate_track(via a throwaway broadcast helper) and the renamed types.Public API changes (breaking, targets
dev)Grouprenamed toGroupInfo;Framerenamed toFrameInfo.TrackProducer::new,TrackRequest::newdemoted topub(crate).BroadcastProducer::insert_trackremoved.BroadcastProducer/Consumer/Dynamicnow carryArc<BroadcastInfo>;GroupProducer/ConsumercarryArc<GroupInfo>;FrameProducercarriesArc<GroupInfo>.TrackProducer::broadcast(),FrameProducer::group().Testing
cargo test -p moq-net→ 398 lib + 4 doctests pass.moq-mux/moq-json/hang/moq-relaylibs pass.cargo build --workspace --all-targets,clippy, andcargo fmt --check(nix toolchain) all clean.Cross-package sync (follow-up)
js/netmirror (broadcast.ts/track.ts/group.ts) anddoc/conceptare not in this PR; they're the tracked follow-up.Arc<OriginInfo>(origins owning broadcasts) intentionally deferred.🤖 Generated with Claude Code
(Written by Claude)