WebRTC

Peer-to-peer real-time communication for audio, video, and data. Build video conferencing, voice calls, and low-latency data channels directly in your Delphi applications.

What is WebRTC?

WebRTC (Web Real-Time Communication) enables direct peer-to-peer connections between devices for streaming audio, video, and arbitrary data.

Direct Peer-to-Peer Communication

WebRTC eliminates the need for media servers by establishing direct connections between peers. Using STUN and TURN servers for NAT traversal and ICE for connectivity checks, WebRTC finds the optimal path between two endpoints. sgcWebSockets provides a complete WebRTC stack including signaling, peer connection management, SDP negotiation, and data channels — all from native Delphi code.

  • No media server required for peer-to-peer connections
  • Low-latency audio, video, and data streaming
  • Built-in encryption for all media streams
  • Works behind NATs and firewalls with ICE/STUN/TURN
PEER A PEER B STUN/TURN

WebRTC Features

A complete WebRTC stack for native Delphi applications.

STUN/TURN/ICE

Full NAT traversal support with STUN for address discovery, TURN for relay fallback, and ICE for optimal connectivity path selection.

RTCPeerConnection

Manage peer connections with full lifecycle support: creation, offer/answer negotiation, ICE candidate exchange, and graceful teardown.

Data Channels

Exchange arbitrary data between peers with configurable reliability, ordering, and priority. Perfect for chat, file transfer, and gaming.

SDP Offer/Answer

Session Description Protocol negotiation for establishing media sessions. Automatic codec negotiation and capability matching.

Audio/Video Streams

Stream audio and video between peers with support for multiple tracks, codec negotiation, and adaptive bitrate control.

Screen Sharing

Share screen content with remote peers for presentations, remote support, and collaborative work sessions.

WebRTC Use Cases

Real-time communication scenarios powered by WebRTC.

Video Conferencing

Build multi-party video conferencing applications with low latency and high-quality audio and video streams.

Voice Calls

Implement VoIP calling with crystal-clear audio, echo cancellation, and noise suppression built into the protocol.

Peer-to-Peer File Sharing

Transfer files directly between peers without server intermediaries, ensuring privacy and reducing bandwidth costs.

Real-Time Gaming

Build multiplayer games with ultra-low-latency data channels for game state synchronization and voice chat.

Live Streaming

Stream live audio and video content to audiences with minimal delay compared to traditional streaming protocols.

Delphi WebRTC Example

Set up a peer connection and exchange data in native Delphi code.

uses
  sgcWebRTC_Client, sgcP2P_Client, sgcSTUN_Classes;

var
  P2PClient: TsgcP2PClient;

procedure TForm1.FormCreate(Sender: TObject);
begin
  P2PClient := TsgcP2PClient.Create(nil);

  // Configure STUN server for NAT traversal
  P2PClient.STUNServer.Host := 'stun.l.google.com';
  P2PClient.STUNServer.Port := 19302;

  // Configure TURN server as relay fallback
  P2PClient.TURNServer.Host := 'turn.example.com';
  P2PClient.TURNServer.Port := 3478;
  P2PClient.TURNServer.Username := 'user';
  P2PClient.TURNServer.Password := 'password';

  // Set up event handlers
  P2PClient.OnP2PConnect := OnP2PConnect;
  P2PClient.OnP2PMessage := OnP2PMessage;
  P2PClient.OnP2PDisconnect := OnP2PDisconnect;
end;

procedure TForm1.ButtonConnectClick(Sender: TObject);
begin
  // Connect to signaling server and create peer connection
  P2PClient.Host := 'signaling.example.com';
  P2PClient.Port := 443;
  P2PClient.Connect;
end;

procedure TForm1.OnP2PConnect(Sender: TObject;
  aPeerId: string);
begin
  // Peer connected, send a data channel message
  P2PClient.SendMessage(aPeerId, 'Hello from Delphi!');
end;

procedure TForm1.OnP2PMessage(Sender: TObject;
  aPeerId, aMessage: string);
begin
  Memo1.Lines.Add('Peer ' + aPeerId + ': ' + aMessage);
end;

Documentation & Demos

Deep-link to the component reference, grab the ready-to-run demo project, and download the trial.

Ready to Get Started with WebRTC?

Download the free trial and start building peer-to-peer communication in minutes.