Skip to content

moq-boy: refactor Rust publisher into Session struct#1225

Merged
kixelated merged 3 commits into
mainfrom
moq-boy-rust-refactor
Apr 7, 2026
Merged

moq-boy: refactor Rust publisher into Session struct#1225
kixelated merged 3 commits into
mainfrom
moq-boy-rust-refactor

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Summary

  • Extract Stats/StatsReport to stats.rs and Status/StatusPublisher to status.rs
  • Introduce Session struct to hold shared state (atomics, condvar, video encoder, config), replacing the 12-param run_emulator function
  • Convert monitor functions to async methods on Session (run_track_monitor, run_pause_monitor, wait_for_resume, publish_status)
  • Add configurable --game-prefix and --viewer-prefix CLI args (defaults: anon/boy/game, anon/boy/viewer)
  • Add tracing::warn on video frame drops, safety comments on unsafe casts, and module-level docs on all files
  • Document magic numbers (frame duration, CGB boot register, encoding params) and add pause/resume state diagram

Test plan

  • cargo check -p moq-boy passes
  • just check passes
  • Run just demo boy and verify emulator connects, streams video/audio, accepts viewer input

🤖 Generated with Claude Code

kixelated and others added 2 commits April 6, 2026 17:45
- Extract Stats/StatsReport to stats.rs
- Extract Status/StatusPublisher to status.rs
- Introduce Session struct to hold shared state (atomics, condvar, video encoder, config)
- Convert monitor functions to async methods on Session (run_track_monitor, run_pause_monitor)
- Move wait_for_resume and publish_status to Session methods
- Add configurable --game-prefix and --viewer-prefix CLI args
- Add video bootstrap() method to VideoEncoder
- Add tracing::warn on video frame drops
- Add safety comments on all unsafe pointer casts in audio.rs
- Document magic numbers (frame duration, CGB boot register, CRF, GOP, Opus bitrate)
- Add module-level documentation to all source files
- Add pause/resume state diagram in module docs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The relay URL already includes the root namespace (e.g. /anon), so the
Rust prefix defaults were duplicating it (anon/boy/game → anon/anon/boy/game).
Consolidate game_prefix and viewer_prefix into a single prefix arg
(default: "boy") matching the JS path structure: boy/{name} for game
broadcasts and boy/{name}/viewer for viewer feedback.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@kixelated kixelated enabled auto-merge (squash) April 7, 2026 01:20
@kixelated kixelated disabled auto-merge April 7, 2026 01:24
@kixelated kixelated merged commit 373e6da into main Apr 7, 2026
2 checks passed
@kixelated kixelated deleted the moq-boy-rust-refactor branch April 7, 2026 01:24
@coderabbitai

coderabbitai Bot commented Apr 7, 2026

Copy link
Copy Markdown
Contributor

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b0c0f670-8d86-4e28-b8ed-74db4cfae1ef

📥 Commits

Reviewing files that changed from the base of the PR and between f76acbb and 896a8ba.

📒 Files selected for processing (7)
  • rs/moq-boy/src/audio.rs
  • rs/moq-boy/src/emulator.rs
  • rs/moq-boy/src/input.rs
  • rs/moq-boy/src/main.rs
  • rs/moq-boy/src/stats.rs
  • rs/moq-boy/src/status.rs
  • rs/moq-boy/src/video.rs

Walkthrough

Added module-level documentation for audio, video, and input pipelines; introduced OPUS_BITRATE and clarified audio epoch/PTS behavior with safety comments around i16u8 conversions. Emulator docs added and emulator init now sets CPU register a = 0x11. Introduced new stats and status modules (with Stats, StatsReport, and StatusPublisher). Refactored main into a Session-driven coordination model, added Config.prefix, and moved emulator loop into run_emulator(...). Video encoder: added bootstrap(...) and now logs on dropped frames in try_frame().

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch moq-boy-rust-refactor
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch moq-boy-rust-refactor

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@moq-bot moq-bot Bot mentioned this pull request Apr 4, 2026
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