Skip to content

poc: SWITCH relay implementation (moq-transport PR #1378)#287

Draft
gwendalsimon wants to merge 3 commits intoopenmoq:mainfrom
gwendalsimon:feat/switch-poc
Draft

poc: SWITCH relay implementation (moq-transport PR #1378)#287
gwendalsimon wants to merge 3 commits intoopenmoq:mainfrom
gwendalsimon:feat/switch-poc

Conversation

@gwendalsimon
Copy link
Copy Markdown

@gwendalsimon gwendalsimon commented May 5, 2026

  • Add MoqxSession: thin MoQRelaySession subclass that dispatches onSwitch() to MoqxRelay and exposes publishForSwitch() + writeCatchupToHandle() — both require protected MoQSession access
  • Wire MoqxRelayServer::createSession() to produce MoqxSession instances and call setRelay() immediately after construction
  • Add SwitchTypes.h: SwitchTransition struct + kSwitchTransitionParamKey
  • Add GroupStartObserver.h: lightweight TrackConsumer that fires a callback on each beginSubgroup() for G_switch detection
  • Add SwitchHandler: full relay-side state machine (VALIDATE → SUBSCRIBE_TARGET → OBSERVE_GSWITCH → CUT_OLD → CATCHUP+LIVE) including pre-population of availableTarget from forwarder.largest(), inline FETCH catch-up via writeCatchupToHandle(), and Phase 2 drain loop
  • Add MoqxRelay::handleSwitch(), getForwarder(), getOrSubscribeForwarder(), getSubscriptionHandle(), cache() to complete the relay glue
  • Add moqx_switch_handler_test placeholder target to test/CMakeLists.txt
  • Build not yet verified — requires cmake 3.25+ and system deps: run: sudo deps/moxygen/standalone/install-system-deps.sh

This change is Reviewable

* Add MoqxSession: thin MoQRelaySession subclass that dispatches
  onSwitch() to MoqxRelay and exposes publishForSwitch() +
  writeCatchupToHandle() — both require protected MoQSession access
* Wire MoqxRelayServer::createSession() to produce MoqxSession
  instances and call setRelay() immediately after construction
* Add SwitchTypes.h: SwitchTransition struct + kSwitchTransitionParamKey
* Add GroupStartObserver.h: lightweight TrackConsumer that fires a
  callback on each beginSubgroup() for G_switch detection
* Add SwitchHandler: full relay-side state machine
  (VALIDATE → SUBSCRIBE_TARGET → OBSERVE_GSWITCH → CUT_OLD → CATCHUP+LIVE)
  including pre-population of availableTarget from forwarder.largest(),
  inline FETCH catch-up via writeCatchupToHandle(), and Phase 2 drain loop
* Add MoqxRelay::handleSwitch(), getForwarder(), getOrSubscribeForwarder(),
  getSubscriptionHandle(), cache() to complete the relay glue
* Add moqx_switch_handler_test placeholder target to test/CMakeLists.txt
* Build not yet verified — requires cmake 3.25+ and system deps:
  run: sudo deps/moxygen/standalone/install-system-deps.sh

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gwendalsimon
Copy link
Copy Markdown
Author

gwendalsimon commented May 5, 2026

The moxygen changes are now browsable at: https://github.com/gwendalsimon/moxygen/tree/feat/switch-poc

The moqx implementation is self-contained in this branch. The moxygen submodule carries local-only changes that would need to land in moxygen before this can be merged. Here is what those changes are:

  1. MoQTypes.h — SWITCH frame type (0x1B per moq-transport PR #1378), Switch struct, and 4 new PublishDoneStatusCode values (DOES_NOT_EXIST, TIMEOUT, NOT_SUPPORTED, EXCESSIVE_LOAD)
  2. MoQFramer.h/cpp — parseSwitch() to decode the SWITCH wire format
  3. MoQCodec.h/cpp — onSwitch() virtual callback in ControlCallback, SWITCH allowed on the control stream, dispatch in
    parseFrame()
  4. MoQSession.h/cpp — two additions:
    - getBidiStreamConfig() made virtual + a PUBLISH case so relay-initiated PUBLISH bidi streams are accepted by
    moxygen-based subscribers without PROTOCOL_VIOLATION
    - registerPublishConsumerForSwitch() protected factory — registers TrackPublisherImpl in pubTracks_ and
    pendingRequests_ before the PUBLISH frame hits the wire (needed to avoid a PUBLISH_OK race)
  5. relay/MoQCache.h — getObject() public accessor for catch-up delivery from the cache

@gwendalsimon gwendalsimon marked this pull request as draft May 5, 2026 08:28
gwendalsimon and others added 2 commits May 5, 2026 12:01
Picks up fix(switch): assign SWITCH = 0x1F per moq-transport PR #1378

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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