How irdkwmnsb/webrtc-grabber works
Main Components
• Grabber: A stand-alone Electron-based application (in packages/grabber) that runs on the contestants’ PCs. It performs screen (and webcam) capture and initiates a connection via a configured signaling URL.
• Signaling Server: Built primarily from the code in packages/relay (specifically, the cmd/signalling module and associated internal packages). It is a stateful server (originally described as an “express http server” with Socket.io endpoints) responsible for managing peer registration, delivering ICE configuration details (with TURN server info), and coordinating connection setup between Grabbers and viewers.
• TURN Server: Implemented in packages/go-turn, this lightweight Go-based TURN server is deployed to handle NAT traversal by relaying multimedia packets between peers when direct connections are not possible.
File Structure and Build Artifacts
• The top-level directories such as “packages” (with sub-directories for grabber, go-turn, relay, and player-common) indicate a modular design with separate responsibilities.
• The “debian” and “rpm” directories include packaging scripts for different Linux distributions—illustrating that deployment artifacts have been customized per target platform.
• Workflow files in “.github/workflows” suggest CI/CD pipelines for building and releasing each component.
• In the “packages/relay” directory, assets (HTML files and JavaScript code) support the browser-based video streaming interface (“players”), in addition to the signaling server functionality.
Component Relationships and Data Flow
• Grabber → Signaling Server: The Grabber application initiates a connection to the signaling server by pinging it at an interval defined in its configuration file (e.g., every 3 seconds). It also receives a “peerConfig” (including ICE server details) from the signaling server.
• Signaling Server → TURN Server: The signaling server supplies TURN configuration (including TURN server URL, username, and credential) in the ICE configuration to enable NAT traversal. In cases where direct peer-to-peer communication is not feasible, TURN relays audio/video packets.
• Optional Connections: Viewers (or “players”, which may leverage code under packages/player-common and assets from packages/relay/asset) connect to the signaling server to obtain the list of active Grabbers and to establish connections.
Architectural Patterns and Principles
• Modularity: Each major function (capture, signaling, TURN) is separated into its own module with dedicated configuration and build instructions.
• Microservices / Component-based: Although deployed as separate binaries or Docker containers (see docker-compose.yml and Dockerfiles), the components interact through clear, well-defined protocols (HTTP/WebSocket for signaling; TURN for media relay).
• NAT/Network Traversal: The use of a TURN server is central to handling network restrictions, and the configuration files make it evident that ICE-based connection strategies are applied.
• Build and Deployment: The use of CI/CD workflows in GitHub Actions and packaging scripts for both Debian and RPM platforms signifies a deployment plan that caters for various environments.
a. A layout that separates the system into “Client” and “Server/Infrastructure” layers.
b. On the client side:
– Place “Grabber (Screen & Webcam Capture)” with a note “Electron application – configured via packages/grabber/config.json”.
– Add the “Viewer/Player” component (if applicable) represented by assets served for browser-based streams.
c. In the server/infrastructure layer:
– From “Grabber” to “Signaling Server”: label it “Connection initiation, pings, and ICE negotiation”.
– From “Signaling Server” back to “Grabber”: label it “Peer config with ICE / TURN details”.
e. Optionally, add an “Infrastructure/Deployment” note indicating the CI/CD pipelines (GitHub workflows, Docker Compose) and packaging aspects (debian, rpm).