While streaming audio is great, live video is even more gratifying. Using the WebRTC protocol, we can stream video in addition to audio and simply pipe it into an HTML video element instead of an audio element.
In this recipe, we will create a peer-to-peer connection where we can allow two users to chat using live video.
To stream live video with Socket.IO, follow these steps:
server.jsfile. This file will be responsible for managing sockets as they join or leave. It will also be responsible for allowing the sockets to connect to one another to initiate a WebRTC session:
var express = require('express'), app = express(), http = require('http'), socketIO = require('socket.io'), fs = require('fs'), ...