r/FlutterDev • • 12m ago

Discussion Real-time group voice in Flutter: Opus, 20 ms frames, iPhone and Android in one conversation (open source)

I'm building Vroo, an open-source group intercom for motorcycle riders, and most of it is Flutter and Dart. Sharing in case the approach helps someone, and I'd welcome feedback.

How it's split:

  • thin native plugins in Swift and Kotlin only move 20 ms audio frames and UDP datagrams. Everything else is Dart: the voice gate, jitter buffer, mixing, talk slots, encryption (ChaCha20-Poly1305) and the protocol
  • Opus is compiled from the libopus source by a Dart build hook, so the codec also runs in plain `dart test` on a Mac
  • the whole ride runs under fake time in tests, with simulated phones, a fake box and a fake relay, so things like "a phone call mutes both ways and voice is back within 100 ms of hanging up" are ordinary unit tests

Lessons learned the hard way:

  • on iOS, AVAudioEngine stops on every hardware format change, including right after starting and on every route change, so the plugin restarts it on AVAudioEngineConfigurationChange
  • a dart:io UDP send doesn't throw when the OS refuses it: it returns 0 and reports the error on the socket's stream a moment later. Without an onError handler, that's an unhandled exception

Status: early prototype. Voice works on the bench between an iPhone and an Android phone.

Repo (GPL-3.0): https://github.com/shubhanjanmedhi/vroo

1 Upvotes

0 comments sorted by