Minimal client-server (not p2p) voice chat server?

Is there a crate or tutorial for building a minimal client-server (not p2p) voice chat server? (like a mini-discord)

At a thousand foot view, this is basically having the clients open up udp / webrtc, and the server just routing the packets around. However, googling around, all I'm getting are results on:

  • how do build a discord bot
  • STUN/TURN/ICE servers
  • using existing VOIP software

I tried to figure out how to do something like this a year or so ago, and although I never got very far, I can at least share some crates you might find useful:

1 Like

@gretchenfrage : Thanks for sharing. I've played with cpal a bit, but never used either audiopus or speexdsp-resampler. Any other advice from your experiences ?

Naively, I feel like there should be a way to use webrtc (via rust/wasm32) in the browser to capture audio + convert to webrtc/udp packets, then the rust server "just" needs to decode, remix, encode, and send it back out. Unfortunately, due to some complexity I am unaware of, this becomes a really messy problem and existing solution seems to offload this to VOIP software.

I made a very simple client-server with audiopus, cpal and UdpSocket (client microphone -> server speaker). The hardest part was buffering (avoid buffer overflow or underflow). I used ring-channel between the audiopus and cpal, and a custom channel (like a ring buffer but where reading does not overflow) between audiopus and UdpSocket, and it works well.

1 Like

@tuxmain : Any chance you can MIT/BSD the code?

I can publish it, but only under GNU AGPLv3 :wink:

The project is not ready to be on a Git repo yet, so here is the code.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.