← All posts

Voice and video without WebRTC

In September I wrote about removing the signaling server from WebRTC, and I promised a post about the second library that came out of Presence, our video-call tool for Moss. That post ended on a question: what do you do when WebRTC cannot connect at all? This is the answer. Today we published version 0.2.2 of @lightningrodlabs/signals-media.

The library sends voice and low-rate video between peers over any message channel. It uses no WebRTC, no ICE, and no TURN relay server. You bring the channel: Holochain signals, a WebSocket, or anything that moves a string to a peer. The library does the rest, from the microphone and camera on one side to the speaker and screen on the other.

I'm pretty happy with how well it works. The voice is Opus, the codec WebRTC uses, at 24 kbps and 48 kHz, so a voice sounds the way it does on any good call. The video is what we call a filmstrip: small JPEG frames, from 192 pixels at 6 frames per second up to 384 pixels at 15 frames per second. A WebRTC call commonly sends 720 pixels at 30 frames per second, so this is not HD video. It is enough to see who is talking and how they react, and it fits through a channel that was built for messages.

Why you would want this

There are two cases. The first is a platform with no WebRTC at all. Linux apps built with Tauri run on WebKitGTK, and the stock build of WebKitGTK leaves WebRTC out. RTCPeerConnection does not exist there. A call on that platform needs some other way to carry the media, and this library is one.

The second case is a platform that has WebRTC, with two peers who cannot open a direct path to each other. The usual answer is a TURN server, which someone has to run and pay for. But a peer-to-peer app already has a channel that reaches the other peer, because the setup messages got through. You can send the media over that channel and run no relay server. Your app decides this per peer, and it can switch a peer back when a direct path appears.

What changed since the first version

Version 0.1.0 was a straight extraction from Presence. Then in November we worked through real calls over poor connections, and Presence learned a lot. The 0.2 releases carry those lessons back into the library:

  • Voice survives reordering. A message channel does not deliver in order. The old receiver dropped every frame that arrived after a later one, and in our field logs that was about 15% of frames. The receiver now waits up to 120 ms for a late frame.
  • Senders listen to receivers. Each receiver reports back what arrived and how late. A sender holds back when a peer falls behind, so a slow peer gets fresh audio and not a growing backlog.
  • Video sets its own rate. It starts at 6 frames per second and 192 pixels, and it rises to 15 frames per second and 384 pixels when the path can carry that. It drops video first when the path degrades, so voice keeps going.
  • A camera that never delivers a frame no longer hangs the app. Some cameras do this on WebKitGTK. The call to start the camera now gives up after five seconds and reports the failure. Voice is not affected.
  • Mute follows the microphone you are using now. If your app swaps the audio track, for a new device or a mix, the library judges mute by the new track. It also stops sending when a microphone ends, where before it sent silence.
  • There is a complete Holochain example for Holochain 0.7.1 direct signals, with the zome half included.

With 0.2.2, Presence itself runs on the package. We deleted the copies of this code that Presence kept, so the library you install is the code our own calls use. That round found the microphone fixes above.

We ran it on real hardware. On a Linux laptop under WebKitGTK, two instances held a room with video at about 6 frames per second each way and no voice loss. The Chromium tests run on every change. Android, macOS, iOS and Windows are configured, and we did not run them yet. The changelog lists every change, the breaking ones first, and the cameras that WebKitGTK cannot read.

Hand it to your agent

Getting this working has been lots back and forth with a coding agent, and there are many many gotchas. So the package now ships an agent skill. This one includes the steps to embed the library, the setup that Tauri on Linux needs, and a table of the quiet failures with the cause of each.

To use the skill install the package, then copy the skill into your agent's skills directory. For Claude Code in a project, that is:

npm install @lightningrodlabs/signals-media
mkdir -p .claude/skills
cp -r node_modules/@lightningrodlabs/signals-media/skills/signals-media .claude/skills/

Then ask for what you want, for example "add voice and video to this app with signals-media npm package, over our existing WebSocket". The skill points the agent at the guide, the API reference and the two example hosts, which all ship inside the package. The agent reads the documents for the version you installed, not whatever it remembers.

You can read the skill yourself, and it is a good one-page summary for humans too. The longer path is the developer guide.

Gaps

The package has no echo cancellation beyond what the browser gives you, and it does not repair lost packets. Every send goes to the whole set of peers you name. Under Holochain that makes the experience least-common-denominator: one signal carries the same media to everyone, so the sender has to back off to the slowest channel in the room. One peer on a poor connection lowers the video for all. And it does not replace WebRTC where WebRTC connects directly: a direct path carries far better video. Use this where there is no WebRTC, or where the alternative is a relay server you would have to run.

If you build something with it, or your agent does, please tell us how it went.

← All posts