SpawnDev.RTC
Cross-platform WebRTC for .NET: browser and desktop from a single API.
SpawnDev.RTC provides one WebRTC interface that works in Blazor WebAssembly (native browser WebRTC via SpawnJS) and on desktop .NET (a bundled SipSorcery fork with browser-interoperable DTLS/SRTP). Peer connections, data channels, media tracks and signaling code are written once. SpawnDev.RTC.Server hosts a WebTorrent-protocol tracker and an embedded STUN/TURN server.
Runs on
Blazor WebAssembly (browser)Desktop .NET (Windows, Linux, macOS)
Highlights
- Browser-style API that mirrors the W3C WebRTC specification; data channels, audio, video, media streams and tracks.
- Desktop peers connect to Chrome, Firefox, Edge and other browser peers (browser-proven DTLS/SRTP) with no native dependencies.
- Zero-copy JS interop in WASM: send and receive ArrayBuffer, TypedArray and Blob without copying to .NET.
- WebTorrent-compatible signaling (SpawnDev.RTC.Signaling) works with public trackers such as wss://tracker.openwebtorrent.com.
- Self-hostable signaling server and an RFC 5766 TURN server as an ASP.NET Core IHostedService (SpawnDev.RTC.Server), with ephemeral HMAC credentials.
- PerfectNegotiator helper for glare-free renegotiation, simulcast offers, and desktop audio/video bridges from SpawnDev.MultiMedia (Opus audio, Windows MediaFoundation H.264 video).
// Same code works on both browser and desktop
var config = new RTCPeerConnectionConfig
{
IceServers = new[] { new RTCIceServerConfig { Urls = "stun:stun.l.google.com:19302" } }
};
using var pc = RTCPeerConnectionFactory.Create(config);
// Create a data channel
var channel = pc.CreateDataChannel("myChannel");
channel.OnOpen += () => channel.Send("Hello from .NET!");
channel.OnStringMessage += (data) => Console.WriteLine($"Received: {data}");
// Create and send offer
var offer = await pc.CreateOffer();
await pc.SetLocalDescription(offer);
// ... send offer.Sdp to remote peer via your signaling serverInstall
dotnet add package SpawnDev.RTCdotnet add package SpawnDev.RTC.ServerBuilding on SpawnDev.RTC?
Private tickets, response targets and a direct line to the engineer who wrote it.