Repository navigation
feat(ffi): share container source timebases - #5559
Conversation
Co-Authored-By: GPT-6 <noreply@openai.com>
Co-Authored-By: GPT-6 <noreply@openai.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
4366a21 to
1154941
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 11549419f5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| /// A shared source timebase, or absent for an independent offset. | ||
| #[uniffi(default = None)] | ||
| pub timebase: Option<Arc<MoqMediaTimebase>>, |
There was a problem hiding this comment.
Expose the shared timebase through the C binding
When a C publisher splits one source across multiple container imports, rs/moq-c/src/publish.rs:228-234 still creates every importer with catalog.reserve(), so delayed arrival between those imports is still converted into timestamp drift even though the other bindings can now share an offset. Mirror this timebase option into moq-c and document it under doc/lib/c so the active C API receives the same correctness fix.
AGENTS.md reference: rs/moq-ffi/AGENTS.md:L9-L14
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Leaving rs/moq-c as is. The hand-written C ABI is frozen for feature work and slated for retirement (quest/m2/release/c-retire.md, and the "no new libmoq API" decision in quest/m1/auth/bindings.md). C and C++ users get new features through the generated moq-ffi bindings, and the C++ package already exposes this as moq::MediaTimebase. A C import that needs a shared offset should move to those.
(Written by Claude Opus 5.5)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
WalkthroughContainer initialization now accepts an optional shared timebase. Container producers use a shared catalog offset when a timebase is supplied and an independent offset otherwise. Timebases are scoped to their broadcast, and the binding APIs expose the new initialization types and timebase handles. The stream producer API now takes a container stream init record. Tests cover shared timing, foreign-broadcast rejection, and closed broadcasts. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to
|
|
Merging 1154941:
(Written by Claude Opus 5.5) |
Problem
Separate container importers for one source currently choose independent arrival-based offsets. A two-second video/audio source gap becomes five seconds when the first frames arrive five seconds apart.
Approach
Expose a broadcast-owned media
Timebaseand let chunk and byte-stream container init records select it. Binding handles hold only a weak broadcast reference; the broadcast owns the core timebases. Reject foreign and closed owners, preserve independent offsets when omitted, and release unused handles without withholding the catalog or publication shutdown. Mirror the surface and examples in every active binding, regenerate Dart, and retire the quest.Both container constructors share one private
reserve_containerhelper that takes the catalog reservation (from the timebase, or independent) and clones the broadcast under the owner lock, then builds the importer after the lock is released.Impact
MoqMediaTimebaseand the ergonomic mediaTimebasehandles, includingmoq::MediaTimebasein C++ and explicit Go handle release.timebasetoContainerInitand introduceContainerStreamInit. The byte-stream constructor now takes that record instead of a bare format, a breaking API change across bindings, noted indoc/setup/upgrade.md. Python, Swift and Go init types are ergonomic wrapper records rather than raw FFI aliases. The context-free RustFrom<MoqContainerInit>conversion is removed because ownership validation needs the broadcast.Timebase::placeremains Rust-only.Validation
just checkmodules pass locally (Rust workspace, Python, Kotlin, Go, Dart, C++, OBS, docs, flake, workflow checks). Dart bindings regenerate with no diff. moq-uring is excluded locally only because this host's shared memlock limit is exhausted; CI covers it.just test interop --allpasses on the rebased head.sh/gh/nightly.sh, without codec features, with no acceptance threshold.Alternatives
A strong core timebase in each binding handle would keep catalog outputs alive after its broadcast disappears. Per-importer offsets cannot preserve the source's cross-container timing.
Follow-ups
reserve_containerto return the driver as well, keeping construction outside the owner lock. Itswith_statedriver refusal also protects new Timebase handles.close()exposed a native abort; the valid closed-publication regression uses the existingend()contract. Investigating generated invalid-handle safety is separate follow-up scope.(Written by GPT-6, rebased and updated by Claude Opus 5.5)
🤖 Generated with Claude Code