A side project I started in 2019 to learn WebRTC properly. You open a room, share a screen (or several), and the video goes directly between the browsers in that room rather than through a media server, so the server's only job is introducing people to each other.
How it works
- Signalling server: a small Node.js and Socket.io service over HTTPS. It tracks who is in each room and relays WebRTC offers and answers between peers. No video passes through it.
- Mesh topology: when someone joins a room, each existing member opens a direct peer connection to them with
simple-peer, so every viewer gets every stream first-hand. - Screen capture: streams come from the browser's
getDisplayMediaAPI. In 2021 I added support for one person sharing several streams at the same time. - Chat and recording: a chat panel sits next to the streams, and RecordRTC lets you save a stream locally.
What I learned
A full mesh keeps hosting costs close to nothing, but each extra person adds an upload for everyone else, so it suits small rooms. The fiddly part was the connection lifecycle: people joining mid-stream, leaving without warning, and Angular's change detection not noticing streams and messages that arrive from outside it.
Built with Angular 11, TypeScript, simple-peer, RecordRTC, Node.js and Socket.io. The source is private.