sew-call-client
sew-call-client is the native voice engine for Sew, a self-hosted team chat server: it joins a Sew voice call from a desktop app, with end-to-end encrypted audio, TURN relay and reconnects.
Sew is a self-hosted chat and calls server from Alakazam Labs. A company runs it on its own Linux server for channels, threads, direct messages and voice and video calls; people reach it from a browser or from apps built on its client API. This crate is Sew's native call client: a desktop or phone app links it to join a Sew call from its own process, with the media encrypted end to end between the people in the call. You need a Sew server to use it.
Two labels appear in these docs:
- K2 is Alakazam Labs' platform, which can host Sew.
kessel-audioandkessel-video, the audio and video pipelines this crate uses, are K2's crates (MIT OR Apache-2.0, on crates.io). Nothing here needs K2: the crate works against any Sew server. - Sew version ("Sew 0.9.0") is a version of the Sew server. Next to a feature, it is the first server version that has it. In the CHANGELOG's headings, it is the server version that release of this crate is tested against.
Everything below the user interface for one call:
- signalling against Sew's media server over the LiveKit client protocol (through
sew-lk-compat), with resume, full reconnect inside a 20 s window, and a re-join through the host'sJoinProviderafter that; - transport on str0m, with TURN over UDP, TCP and TLS, relay-only when the call asks for it, and the platform's TLS trust;
- end-to-end encryption that cannot be turned off: MLS call keys (
sew-e2ee) over the call credential and the call socket, the mandatory checks on every publication and subscription, and the device key store (device). Remote frames are decrypted and verified before the audio pipeline sees them; nothing is ever sent unencrypted; - mute and deafen, the participant list, speaking levels, and the call credential's renewal;
- the call-stats beacon: when Sew's join answer carries its terms, one anonymous sample per
window (played and concealed audio, packet loss, jitter, the longest gap, the path) to Sew,
and the same numbers for the host (
Call::stats,CallEvent::Stats; thestatsmodule says how each is derived); - with the
audiofeatures, the bridge to thekessel-audioaudio pipeline (capture, processing, Opus, playout on the system's devices).
The host keeps the user's sign-in: it implements JoinProvider, which asks Sew for the join
answer and hands it over. No token needs to reach a web view.
Not affiliated with or endorsed by LiveKit.
- Source: https://github.com/Alakazam-211/sew-crates (read-only: it is generated from Sew's repository at each release, so pull requests are not merged there)
- API documentation: https://docs.rs/sew-call-client
- Issues: https://github.com/Alakazam-211/sew-crates/issues/new/choose,
with the
sew-call-clientform, which labels the issuecrate:sew-call-client - Security problems: report them privately, as SECURITY.md says.
- MSRV: Rust 1.95.
Features
Which cargo features build where. Every iOS and Android build needs mobile (or
rust-crypto); the crate refuses to compile for a phone without it.
| Feature | Linux | macOS | Windows | iOS | Android |
|---|---|---|---|---|---|
audio (default) |
yes (ALSA development files) | yes | yes | yes (OS voice processing) | yes (OS voice processing) |
audio-core |
yes | yes | yes | yes | yes |
builtin-ring-provider (default) |
yes | yes | yes | yes | yes |
rust-crypto |
yes | yes | yes | yes (required) | yes (required) |
mobile |
not used | not used | not used | yes (required) | yes (required) |
keyring-store |
yes (Secret Service) | yes (Keychain) | yes (Credential Manager) | no | no |
dfn3 |
yes | yes | yes | yes | yes |
noise-bench |
debug builds | debug builds | debug builds | debug builds | debug builds |
noise-probe |
measurement builds | measurement builds | measurement builds | measurement builds | measurement builds |
video-core |
yes | yes | yes | yes | yes |
video |
yes (VP8 only; screens need the xdg portal or libpipewire) | yes | yes | yes | yes |
testing |
tests only | tests only | tests only | tests only | tests only |
sim-software-key |
no | no | no | simulator only | x86 emulator only |
What each one does:
audio(default): thekessel-audiobridge on the system's audio devices (cpal: CoreAudio, WASAPI, ALSA; Linux builds need ALSA's development files).audio-core: the bridge onkessel-audio's null device only, with no system libraries.keyring-store(off by default): the device key in the OS credential store (macOS Keychain, Windows Credential Manager, the Linux Secret Service). Without it, or a store of your own (ClientConfig::with_device_key_store), the key is a 0600 file under the data directory.rust-crypto: the call's DTLS/SRTP in pure Rust (dimpl's RustCrypto backend and RustCrypto ciphers) and the E2EE frame cipher on RustCrypto, instead of aws-lc-rs;CRYPTO_BACKENDsays which one a build has.mobile: what an iOS or Android build needs:rust-crypto(aws-lc-rs is never built for phones, and the crate refuses to compile there without it) and, withaudiooraudio-core,kessel-audio's phone backend. Withaudioon a phone,platform_audio_configis the OS's own voice processing (iOS's VoiceProcessingIO unit, Android's AAudio with the voice-communication preset) with the OS's echo cancellation and noise suppression on; desktop keeps cpal (AUDIO_BACKENDsays which). On Android callsew_call_client::android_init(env, context)before the first join (the platform TLS verifier needs the JVM), and add rustls-platform-verifier's Kotlin component to the app.- Noise removal (with
audio-core, desktop):AudioBridge::start_with_noisehands kessel-audio's capture hook asew-noisestage (RNNoise, between echo cancellation and gain control; kessel-audio's own noise suppression is then off), in the mode aNoiseRemovalControlholds (NoiseRemoval::OfforStandard, the default).setchanges it mid-call without a click;stateandsubscribegive{mode, active, reason}, wherereasonisbudgetorfaultwhen kessel-audio stopped the stage, orunavailablewhere no stage runs (phones).platform_audio_configsets Standard on desktop. - Noise removal Off on phones (
mobile): the OS's voice processing is off too and the microphone is captured raw (iOS: the plain RemoteIO unit; Android: the unprocessed source where the device has it, else the voice recognition source), with kessel-audio's echo cancellation and gain control and no noise suppression. A call that starts in Off opens raw;setduring a call switches the live call's capture both ways, with a short pause of the microphone. The state'sphone_mode(os,raw),phone_mode_switches,phone_mode_gap_msandphone_mode_reason(switch_failed) follow it. On Android, passAudioManager.PROPERTY_SUPPORT_AUDIO_SOURCE_UNPROCESSEDtoNoiseRemovalControl::set_android_unprocessed_supported, and read kessel-audio's events throughAudioBridge::eventsso a failed switch shows at once. dfn3(off by default): Standard runs DeepFilterNet3's low-latency model (by Hendrik Schröter and the DeepFilterNet authors; MIT OR Apache-2.0), with RNNoise beside it as its automatic step-down, on desktop and, after the OS's voice processing, on phones. The app ships the weights as a resource (DFN3_WEIGHTS_FILE, with their NOTICE and licence texts) and gives their path toNoiseRemovalControl::set_dfn3_weights, which only checks the file's pinned sha256; the model is loaded off the audio thread when a call first needs it (that call starts on RNNoise, on phones the OS's voice processing alone, withmodel_reason: loading, and steps up without a click), and released afterset_dfn3_idle_unload's time with no call (DFN3_IDLE_UNLOADby default;preload_dfn3loads it at once). Without usable weights Standard stays RNNoise (on phones, the OS's voice processing alone). The state then also says whichmodelruns, why it is RNNoise (model_reason) and how often the call's stage stepped down (step_downs), with the stage's timing for a call's log (step_down_reason,last_step_down_ms_ago,slowest_block_us,blocks_over_budget,in_grace,dfn3_state,retry_in_ms,grace_step_downs,slowest_block_cpu_us,p99_block_us,p99_block_cpu_us, and kessel-audio'scapture_stage_strikes,capture_stage_bypassed,capture_stage_p99_us,capture_stage_grace,capture_stage_grace_blocks,capture_stage_grace_over_budget,capture_stage_last_transient,capture_stage_clock,capture_stage_max_wall_us,capture_stage_preempted_over_budget,capture_stage_starved, and how the OS schedules the processing thread the stage runs on,capture_stage_dsp_scheduling:workgroup,time_constraint,qos,noneorown_workgroup; the thread asks for real-time scheduling on macOS and iOS). The call's start and its busy moments (the session activating, a route change, a device switch, a camera starting, and the app's lifecycle throughNoiseRemovalControl::app_scene_changed) open a grace window in which the stage keeps the model through the load, and kessel-audio holds its own timing rule for the stage back for as long. Which files to ship and where: tauri-plugin-sew-voice's README, "Shipping DeepFilterNet3 in your app".noise-bench(debug builds only, never indefault):noise_bench::run, the stage on the device's microphone for a while, reported as JSON.noise-probe(measurement builds only, never indefault; turns ondfn3):NoiseRemovalControl::arm_probehas the next call's stage record what each block cost, which core the processing thread was on and what DeepFilterNet3 ran, beside two fixed calibration loops on that thread;probe_reportgives it as JSON, andnoise_probe::referenceruns the same loops on a thread of the app's. On macOS and iOS the app gives the function that reads the thread's core number (the system call needsunsafe, which this crate has none of); tauri-plugin-sew-voice's probe usespthread_cpu_number_np, so a probe build of it needs iOS 14.2 or macOS 11 or later.video-coreandvideo(off by default):kessel-video, K2's cameras, screen capture and video codecs, without (video-core) or with (video) the system's devices, OS codecs and its pure-Rust VP8. With either, calls receive video: the remote camera and screen tracks (CallEvent::VideoAdded,VideoChanged,VideoRemoved,Participant::cameraandscreen), each disabled at the media server until the host opens a sink for it (Call::video_sink), then decrypted, verified encoded VP8 and H.264 frames throughCall::video_frames.VideoCaptureopens cameras and screens (the OS picker, the screen list with PNG thumbnails) and runs the pre-join camera preview;VideoBridgepublishes the camera and screens opened through it (one opener holds the camera), with the in-call self-view (VideoBridge::self_view).VideoCapture::camera_taphands the camera's raw frames, as captured and before any encoder, to a native self-view (on macOS and iOS the camera'sCVPixelBuffer; upright, never mirrored, with the camera's facing). A build without them negotiates no video at all.builtin-ring-provider(default): TLS falls back to rustls's ring provider when you pass no provider and install no process default (see "TLS crypto provider" below). Without it, that case is refused withno_crypto_provider.testing: test-only helpers. Never in a release build. Withvideo-coreas well,FixtureBackendreplays pre-encoded VP8 and H.264 simulcast streams.sim-software-key(off; iOS simulator and x86 Android emulator builds only, refused elsewhere):SimSoftwareKey, a software stand-in for the hardware device key.
TLS crypto provider
Every TLS connection the engine makes (signalling, TURN over TLS, Sew's API and the key routes) uses one rustls crypto provider, chosen in this order:
- yours, from
ClientConfig::with_crypto_provider(Arc<rustls::crypto::CryptoProvider>)(sew_call_client::rustlsis the rustls the engine uses); - else the process default, if your app installed one with
CryptoProvider::install_default; - else ring, the built-in (feature
builtin-ring-provider, on by default). With that feature off and neither of the above, TLS setup fails withno_crypto_provider(a join answersCallError::Setupnaming it); the engine never picks whatever crypto happens to be linked.
The choice is logged at info, once per change: tls provider: <name> (caller | process default | built-in). It covers TLS only; the call's DTLS and SRTP keep their own backend.
Usage
The crate is on crates.io, and so is every crate it depends on: the Sew crates (sew-proto,
sew-lkproto, sew-lk-compat, sew-e2ee, sew-mls-crypto, sew-noise), Alakazam Labs' fork
of str0m and K2's kessel-audio and kessel-video. A dependency line is all it needs. It
needs a Sew server to join calls on (see the
sew-crates README).
[]
= "0.9.4"
An app also needs, for its JoinProvider and to run a call:
# The engine runs on Tokio: call `CallClient::join` from inside a Tokio runtime.
= { = "1", = ["rt-multi-thread", "macros"] }
# `JoinAnswer::from_json` takes Sew's client API base as a `url::Url`.
= "2"
# Only for the example provider below, which calls Sew over HTTP with reqwest. Any HTTP
# client works: the provider only has to return the body of Sew's join answer.
= { = "0.12", = false, = ["json", "rustls-tls"] }
= "1"
The engine's WebRTC stack is sew-str0m, Alakazam Labs' fork of str0m 0.25 (library name
str0m), which carries Sew's fixes (among them one to the bandwidth estimate at the start of a
call). This release uses sew-str0m 0.25.6 from crates.io.
Your app implements JoinProvider: it asks Sew for the join answer with the app's own
session and returns it. A minimal one, and a call through it (the same code is compiled as the
JoinProvider documentation's example):
use PathBuf;
use Arc;
use ;
/// The app's sign-in, kept in Rust: Sew's client API base and the app's session token.
async
CallClient::with_mls or CallClient::new
Both build the engine; they differ in who builds the call keys.
CallClient::with_mls(config)is the one to use in an app. It builds Sew's MLS call keys (e2ee::MlsKeys) from the config: the device key whereClientConfigsays (a 0600 file by default, your store withClientConfig::with_device_key_store, a hardware key withClientConfig::with_hardware_device_key) and the platform the device enrols as.CallClient::new(config, keys)takes anye2ee::E2eeProvideryou built. Use it when you configureMlsKeysyourself, for example to set the device name Sew shows in the person's device list (MlsKeys::with_label), or in tests with thetestingfeature'sStaticKeys. There is no provider that turns encryption off.
use PathBuf;
use Arc;
use MlsKeys;
use ;
let data_dir = from;
let config = new;
// What an app needs: Sew's MLS call keys, from the config.
let _client = with_mls;
// The same keys built by hand, with the device name Sew shows.
let keys = new
.with_platform
.with_label;
let _client = new;
Recording consent (Sew 0.7.3)
A recorded call never records this device without the person's yes, and no answer is never a
yes: the engine feeds the call keys the recording state Sew sends (the join answer, the call
socket's own recording_updated, Sew's answer to a consent), and the keys release this
device's key to the recorder only while Sew says granted.
- A join that Sew refuses
409 recording_consent_required(your provider returnsProviderError::ConsentRequired;ProviderError::from_sew_errorreads Sew's error body) comes back held:CallState::ConsentRequired { recording_id, notice_version }, no media and no keys, the notice inCall::recording().call.consent(granted, notice_version)joins again with the answer asJoinRequest::recording_notice(forward it as the voice join'srecording_notice);leave()gives up. - In a call,
Call::recording()andCallEvent::Recordingare the call's recording as Sew says it;call.consent(..)andcall.withdraw_consent()("Stop recording me") go through your provider'sJoinProvider::consentwith the person's own session (ConsentAnswer::pathandbodyare Sew's route and body). The defaultconsentsends nothing (consent_unsupported): the person stays unrecorded. - Record and Stop (Sew 0.9.0):
call.start_recording()andcall.stop_recording()go through your provider'sJoinProvider::recordingwith the person's own session (RecordingRequest::pathandbodyare Sew's route and body); Sew's refusals come back as given. Record is the starter's own consent, nobody else's. The defaultrecordingsends nothing (recording_unsupported).CallRecording::triggersays what started a recording andCallRecording::requiredwhether the room requires it (Stop is then refusedrecording_requiredwhile two or more people are in the room).CallRecording::started_byandCallRecording::started_atsay who started it and when, by Sew's clock: count the running time fromstarted_at, so someone who joins a call already being recorded sees the real time (Nonewhile a held join into an auto-record room waits).CallRecording::audio_keep_dayssays how many days Sew keeps the audio (0: deleted once the transcript is final), also after the person answered the notice; a held join into an auto-record room takes it from the notice. Participant::recordermarks the recorder in the roster.
Network changes (phones)
Call call.network_changed() from your path monitor (NWPathMonitor on iOS,
ConnectivityManager.NetworkCallback on Android) when the default network changes. The engine
resumes at once on a fresh TURN allocation over the new network and restarts ICE, instead of
waiting for the old connections to time out; the state is reconnecting until it's done.
Calling it again for the same change does no harm.
The phone's audio session
Keep one AudioSession for the app, start each call's audio with
AudioBridge::start_with_session(&call, platform_audio_config(input, output), &session), and
report the OS's audio session to it with session.event(SessionEvent::…): Activated and
Deactivated (CallKit's didActivate / didDeactivate), Suspend and Resume (an
interruption), RouteChanged. On iOS the audio starts deferred: the microphone and the speaker
open only once the session is active. Deactivated and Suspend pause I/O without ending the
call; Resume restarts it; RouteChanged re-reads the device. What the app said before a call
(an early Activated, a Suspend) applies when its audio starts. The engine never configures
or activates AVAudioSession or the Android audio mode: that stays the app's job. On desktop
the events change nothing.
How the processing thread is scheduled
kessel-audio runs its capture processing, the noise removal stage included, on one thread.
NoiseRemovalControl::set_dsp_sched sets what that thread asks the OS for. Only macOS and
iOS act on it; on other platforms the setting is kept and has no effect.
use ;
noise.set_dsp_sched?;
The modes (CaptureDspSchedMode):
Workgroup, the default: the thread asks for the OS's real-time policy, and on iOS it also joins the audio unit's own workgroup while the phone's audio unit runs. This is what a call does when nothing is set.TimeConstraintOnly: asks for the real-time policy with the figures you give, and no workgroup.None: no request. The thread keeps the OS's default scheduling.OwnWorkgroup: asks for the real-time policy, and a work interval of the thread's own in place of the audio unit's workgroup. Each block of audio is one interval, due a set time after it starts (the interval deadline).
CaptureDspSched::new(mode) starts from the pipeline's default figures;
with_time_constraint_us and with_interval_deadline_us change them. Figures the pipeline
would refuse are refused when you set them, and nothing changes.
- It does nothing until you call it: a call behaves as before.
- It applies from the next call. The pipeline reads the setting once, as a call's audio starts, so a call under way keeps what it started with.
set_dsp_sched(None)goes back to the default.- Nothing is stored: keep the choice with the app's settings and set it again at start.
What a call asked for and what it got are in its noise removal state (NoiseRemovalState),
beside capture_stage_dsp_scheduling, which says what the OS granted. Each field is absent
while unset:
capture_stage_dsp_sched_requested: the mode asked for;capture_stage_dsp_sched_effective: the mode the thread runs in (unsupportedon a platform without these calls);capture_stage_dsp_sched_fallback: why the two differ, when the OS refused part of the request and the thread fell back toworkgroup;capture_stage_dsp_period_us,capture_stage_dsp_computation_us,capture_stage_dsp_constraint_us: the time-constraint figures asked for;capture_stage_dsp_interval_deadline_us: the interval deadline, inown_workgroup;capture_stage_dsp_intervals: how many work intervals the thread has finished.
Signing out
client.forget_server(install_id) deletes the devices of one Sew install that the data
directory holds (each key from its store, a hardware key through HardwareDeviceKey::delete,
then the record and the pins) and answers the removed DeviceKeyIds; it is refused with
DeviceError::InCall during a call. client.known_device_keys() lists every key the data
directory holds a record of (device::forget_install and device::known_device_keys take a
VaultConfig or a directory directly).
For a Tauri 2 app, tauri-plugin-sew-voice wraps
this engine in Tauri commands and events (its README lists them).
Licence
MIT OR Apache-2.0, at your option. See LICENSE-MIT, LICENSE-APACHE and NOTICE.
This crate holds no LiveKit-derived code. It depends on sew-lk-compat and sew-lkproto
(Apache-2.0), which hold code ported from or generated from LiveKit, and, through sew-e2ee, on
sew-mls-crypto, which holds code derived from OpenMLS (MIT); their NOTICE files must travel
with any binary that includes this crate.
Copyright 2026 Alakazam Labs.