Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

29 Commits

Repository files navigation

🎬 LiveStream — Multi-Camera WebRTC Streaming App

A real-time, multi-camera live streaming application built with WebRTC and Socket.IO. A Director manages multiple camera feeds, selects which one is broadcast, and Viewers watch the selected stream live in their browser.


How It Works

Cameraman(s) → Director (selects feed) → Viewers
  • Each Cameraman joins a room and streams their camera via WebRTC peer connection to the Director.
  • The Director sees all camera feeds simultaneously and clicks one to select it as the active broadcast.
  • Viewers connect to the room and receive whichever feed the Director has selected. When the Director switches cameras, viewers are automatically redirected to the new feed.

Pages

index.html — Viewer

The main watch page. Displays a live room list in the sidebar and streams the active camera feed in the main player.

  • Connects to the server and fetches available rooms automatically
  • Animated TV-noise canvas shown when no stream is active
  • Auto-refreshes room list every 15 seconds
  • Includes a link to join any room as a cameraman

director.html — Director Control Panel

The broadcast control interface. Auto-generates a room code on load.

  • Displays all connected camera feeds in a responsive grid
  • Click any feed to select it as the active stream for viewers
  • Shows live counts of connected cameramen and viewers
  • Auto-switches to another camera if the active one disconnects

cameraman.html — Cameraman

The mobile-friendly camera interface. Reads the room code from the URL (?code=XXXXXX).

  • Streams at up to 1080p with a 1:1 aspect ratio preview
  • Supports switching between front/back cameras on mobile
  • Mute/unmute audio toggle
  • Wake lock prevents the screen from sleeping during a stream

Project Structure

public/
├── index.html # Viewer page
├── index.css # Viewer styles
├── index.js # Viewer logic (WebRTC + Socket.IO)
├── director.html # Director control panel
├── director.css # Director styles
├── director.js # Director logic (WebRTC + Socket.IO)
├── cameraman.html # Cameraman page
├── cameraman.css # Cameraman styles
└── cameraman.js # Cameraman logic (WebRTC + Socket.IO)

A Node.js server (not included here) is required to serve the files and handle Socket.IO signaling.


WebRTC & Signaling

All peer connections use the following ICE server configuration:

  • STUN:stun.l.google.com:19302, stun1.l.google.com:19302
  • TURN:openrelay.metered.ca (ports 80, 443, 443/TCP)

Signaling flow

EventDirectionDescription
create-roomClient → ServerDirector creates a room
join-roomClient → ServerCameraman or viewer joins a room
cameraman-joinedServer → DirectorNotifies director of a new camera
offerDirector → Cameraman / Viewer → CameramanWebRTC offer
answerCameraman → Director / Cameraman → ViewerWebRTC answer
ice-candidateBoth directionsICE candidate exchange
select-cameramanDirector → ServerDirector picks active camera
stream-startedServer → ViewersTells viewers which camera to connect to
cameraman-leftServer → DirectorCamera disconnected
viewer-joined/leftServer → DirectorViewer count updates
get-room-listViewer → ServerRequest active rooms
room-listServer → ViewerList of active rooms with metadata

Usage

1. Start a broadcast (Director)

Open /director.html — a room code is generated automatically and displayed on screen.

2. Add cameras (Cameraman)

Open /cameraman.html?code=XXXXXX on any device (phone, tablet, laptop) with the room code. Grant camera/microphone permissions and tap Start Camera.

3. Watch the stream (Viewer)

Open /index.html, find the room in the sidebar, and click it to start watching. The stream switches automatically when the director selects a different camera.


Features

  • Multi-camera support — unlimited cameramen per room
  • Instant camera switching — director switches feeds with one click; viewers follow automatically
  • Mobile-first cameraman UI — front/back camera toggle, wake lock, 1:1 crop preview
  • Resilient connections — automatic reconnection with exponential backoff, TURN fallback
  • Live room discovery — viewers see all active rooms without needing a room code
  • Real-time stats — director sees connected cameraman and viewer counts live

About

LiveStream — Multi-Camera WebRTC Streaming App

Resources

Stars

0 stars

Watchers

1 watching

Forks

Contributors

Languages