English | 简体中文 | 📖 Online Docs
A minimal WebRTC demo project built with Go, providing a WebSocket signaling server and browser-based demo for peer-to-peer audio/video communication. From 1-on-1 calls to multi-party Mesh rooms, covering core WebRTC capabilities for learning and practice.
| Feature | Description |
|---|---|
| WebSocket Signaling | Gorilla WebSocket for Offer/Answer/ICE Candidate relay within rooms, with heartbeat keep-alive |
| Media Controls | Mute/unmute, camera on/off, screen sharing (getDisplayMedia) |
| DataChannel | Peer-to-peer text chat without server relay |
| Local Recording | MediaRecorder captures audio/video streams, exports .webm for download |
| Multi-party Mesh | Room member list broadcast, multi-PeerConnection management, grid video layout |
| Security | Origin validation whitelist, room/client limits, auto-reconnection |
| Docker | Multi-stage Dockerfile, Go compilation + static frontend packaging |
┌──────────────────────────────────────────────────────┐
│ Browser A │
│ ┌──────────┐ ┌──────────┐ ┌────────────────┐ │
│ │ HTML UI │──→│ app.js │──→│ getUserMedia │ │
│ └──────────┘ └────┬─────┘ └──────┬─────────┘ │
└───────────────────────┼─────────────────┼────────────┘
│ WebSocket │ WebRTC P2P
┌──────▼──────┐ │
│ Go Server │ │
│ ┌──────────┐│ │
│ │Signal Hub││ │
│ └──────────┘│ │
└──────┬──────┘ │
│ WebSocket │
┌───────────────────────┼─────────────────┼────────────┐
│ Browser B │ │ │
│ ┌──────────┐ ┌────▼─────┐ ┌──────▼─────────┐ │
│ │ HTML UI │──→│ app.js │──→│ getUserMedia │ │
│ └──────────┘ └──────────┘ └────────────────┘ │
└──────────────────────────────────────────────────────┘
- Signaling: Browser → WebSocket
/ws→ Signal Hub (Offer/Answer/ICE relay) → Browser - Media: Browser ←→ WebRTC P2P audio/video / DataChannel ←→ Browser
git clone https://github.com/LessUp/webrtc.git
cd webrtc
go mod tidy
go run ./cmd/serverOpen two browser tabs at http://localhost:8080, enter the same room name, click a member's ID, then click Call.
docker build -t webrtc .
docker run --rm -p 8080:8080 webrtc| Variable | Description | Default |
|---|---|---|
ADDR |
HTTP listen address | :8080 |
WS_ALLOWED_ORIGINS |
Comma-separated allowed origins; set to * for all |
localhost |
webrtc/
├── cmd/server/ # HTTP + WebSocket entry point
│ └── main.go # Server startup, graceful shutdown, origin config
├── internal/signal/ # Signaling logic
│ ├── hub.go # Room management, message relay, client lifecycle
│ ├── hub_test.go # Unit tests
│ └── message.go # Message type definitions
├── web/ # Browser frontend
│ ├── index.html # UI
│ ├── app.js # WebRTC & signaling logic (Mesh multi-party)
│ └── styles.css # Responsive styles (light/dark theme)
├── docs/ # Technical documentation
│ ├── guide.md # Architecture, frontend, media, recording
│ └── signaling.md # Signaling protocol deep dive
├── .github/workflows/ # CI/CD
│ ├── ci.yml # Go build + test + lint
│ └── pages.yml # GitHub Pages deployment
├── changelog/ # Change logs
├── Dockerfile # Multi-stage build
├── .golangci.yml # Linter configuration
└── go.mod # Go module definition
| Category | Technology |
|---|---|
| Backend | Go 1.22+, net/http, Gorilla WebSocket |
| Frontend | HTML5 + Vanilla JavaScript + CSS3 |
| Media | WebRTC (getUserMedia, RTCPeerConnection, DataChannel, MediaRecorder) |
| Container | Docker (multi-stage build) |
| CI/CD | GitHub Actions (golangci-lint + multi-version test + GitHub Pages) |
- Technical Guide — Architecture, frontend, media, recording
- Signaling Deep Dive — Signaling & room management details
- Roadmap — Development plan & progress tracking
- Contributing — Development workflow & code standards
- 1-on-1 call with status display, error handling, heartbeat
- Mute/camera/screen sharing, DataChannel chat, local recording
- Room member list, auto-call prompt, multi-party Mesh
- Docker multi-stage build & deployment
- TURN support (coturn)
- HTTPS/WSS reverse proxy
- Multi-party calls via SFU