Skip to content

feat(moq-ffi)!: expose Subscription and TrackInfo instead of hardcoding defaults#1763

Merged
kixelated merged 3 commits into
claude/happy-jang-9553c6from
claude/moq-ffi-subscription-trackinfo
Jun 16, 2026
Merged

feat(moq-ffi)!: expose Subscription and TrackInfo instead of hardcoding defaults#1763
kixelated merged 3 commits into
claude/happy-jang-9553c6from
claude/moq-ffi-subscription-trackinfo

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to the accept(None) cleanup: several moq-ffi spots hardcoded a None/default where the underlying moq-net API takes a caller-controllable value, so FFI consumers had no say over delivery or track properties.

  • subscribe_track / subscribe_media / TrackProducer.consume used subscribe(None), dropping the whole Subscription (priority, ordering, staleness, group range).
  • publish_track used create_track(name, None), dropping TrackInfo (priority, cache, compression, ordering, timescale).

This adds two uniffi::Records mirroring moq-net — MoqSubscription and MoqTrackInfo, each with per-field defaults — and threads them as optional args through the four methods.

uniffi 0.31 supports #[uniffi(default)] on record fields but not function arguments, so the FFI args are required Option<_>; each language wrapper supplies the native default.

Bindings

Each wrapper forwards the new optional param so end users aren't broken:

  • py: subscription=None / info=None kwargs; moq.Subscription / moq.TrackInfo re-exported.
  • swift: subscription: Subscription? = nil / info: TrackInfo? = nil; typealiases added.
  • go: *Subscription / *TrackInfo params (nil = defaults); type aliases added.
  • kt: Subscription / TrackInfo typealiases (kt calls the FFI directly).
  • docs: no change — the only examples calling these are Python (which default) and the kt/swift dynamic examples use writeFrame/abort.

Caveat (go)

Go has no constructor defaults, so a partially-built Subscription{Priority: 3} gets Go zero values (e.g. ordered=false) rather than the record defaults. Passing nil uses moq-net's real defaults and is the documented path. Happy to add NewSubscription() / NewTrackInfo() helpers if you'd like construction to match the other languages.

Test plan

  • Rust: 22 moq-ffi tests pass; clippy + fmt clean via nix.
  • Python: full suite (40 tests) passes, including a new one exercising TrackInfo + Subscription end-to-end; ruff + pyright clean.
  • gofmt clean on the go edits. swift/kt updated by inspection (no xcframework/gradle locally).

Stacking

Stacked on #1761 (it reuses the MoqTrackProducer Pending/Active refactor from that PR), so the base is claude/happy-jang-9553c6 and the diff shows only this change. Retarget to dev once #1761 lands.

🤖 Generated with Claude Code

(Written by Claude)

kixelated and others added 3 commits June 16, 2026 10:33
…ng defaults

Like the previous accept(None), several spots hardcoded a None/default where the
underlying moq-net API takes a caller-controllable value, so FFI consumers had no
say over delivery or track properties.

- subscribe_track / subscribe_media / TrackProducer.consume took subscribe(None),
  dropping the whole Subscription (priority, ordering, staleness, group range).
- publish_track took create_track(name, None), dropping TrackInfo (priority, cache,
  compression, ordering, timescale).

Add two uniffi records mirroring moq-net (MoqSubscription, MoqTrackInfo, each with
per-field defaults) and pass them as optional args. uniffi 0.31 supports field
defaults but not function-arg defaults, so the FFI args are required Option<_> and
each language wrapper supplies the native default (None/nil/null).

Wrappers updated to forward the new optional params (py kwargs, swift/`= nil`,
go `*T`, kt typealiases) so end users aren't broken. Go has no constructor
defaults, so a partially-built Subscription/TrackInfo gets Go zero values; pass nil
for moq-net's real defaults.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@kixelated kixelated merged commit e2e55cb into claude/happy-jang-9553c6 Jun 16, 2026
7 checks passed
@kixelated kixelated deleted the claude/moq-ffi-subscription-trackinfo branch June 16, 2026 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant