Skip to content

Voice in Zaun is a mesh of WebRTC connections, one per other participant (up to 10 per channel). Every audio frame is end-to-end encrypted on top of WebRTC’s own encryption: each sender seals its Opus frames with SFrame (RFC 9605) under a key that reaches the others only wrapped with X-Wing (a post-quantum hybrid) and signed with its member key. Keys change whenever someone joins or leaves. The host relays signalling and keys and never hears audio.

use std::time::Duration;
use zaun_client::VoiceEvent;
let voice = community.channel_by_name("lounge").expect("a voice channel").join()?;
voice.send_audio(&opus_frame); // one 20 ms Opus frame
if let Some(VoiceEvent::Audio { member, frame }) = voice.next_event(Duration::from_millis(100)) {
play(member, &frame);
}

Rust uses str0m and reaches the host’s TURN relay over UDP, TCP or TLS (turns:, TLS 1.3 with the post-quantum X25519MLKEM768 key exchange only). Your app encodes and plays Opus, or uses the built-in AudioPlayer below.

AudioPlayer plays resources into every voice session subscribed to it, on absolute 20 ms deadlines so the stream keeps real time.

use zaun_client::{AudioPlayer, AudioPlayerEvent, AudioResource};
let voice = community.channel_by_name("music").expect("a voice channel").join()?;
let player = AudioPlayer::new()?;
voice.subscribe(&player);
player.play(AudioResource::ogg_file("intro.opus")?); // no transcoding
player.enqueue(AudioResource::ffmpeg_file("song.flac", Default::default())?); // anything ffmpeg reads
for event in player.events() {
if let AudioPlayerEvent::TrackEnd { .. } = event {
// pick the next song
}
}

A player with nobody able to hear it (no subscriber, or everyone muted) pauses itself, and resumes when someone can hear it again.

Media goes only through the host’s TURN relay unless both the host and your app allow a direct connection (allow_direct / allowDirect), since a direct connection shows your IP address to the other participants. Each member’s key is pinned the first time the client sees it; if a host later lists another key for that member, the participant is skipped with a KeyChanged event, and member.fingerprint() gives people something to compare out of band.