nile.js
A tool for scalable peer-to-peer video streaming using WebTorrent.
NOTE: This project is no longer being actively maintained
Why WebTorrent?
By using the collective power of WebTorrent, video streams get progressively stronger as more peers contribute to a torrent. With torrents, it is also possible for users to access previous parts of a stream unlike traditional WebRTC video streaming.
About
Server
This is the plug-and-play middleware that receives the torrent link from the broadcasting client and sets up the proper Socket.io connections for the viewing clients.
Broadcaster
This is the client component that records video from a device's camera, saving it to generated torrent files, and sending those torrents' magnet link out to the viewing clients.
Viewer
This is the client which views what the Broadcaster is recording. It receives a torrent magnet link and renders the video from that torrent to an injected video tag using WebTorrent.
Usage
Server
Nile.js utilizes Express middleware and socket.io to receive torrent information, broadcast it to as many clients it can comfortably handle who will then send it out to the rest of the clients.
To use it, require nileServer from our package and pass in the Node Server instance you're using. In Express, you can get this instance by calling app.listen.
You'll also need to pass in the number of WebSockets the server has to maintain. Let's use 10 for now.
Here's how you would use it in your server:
const server = app.listen(8000);
const socketLimit = 10;
const nileServer = require('nile.js/nileServer')(server, 10);
Now add the nile.js middleware w/ app.use:
app.use('/', nileServer);
Note that this middleware will use a "magnet" route to accept POST requests with the magnet link from the Broadcaster.
Client
Broadcaster
If using a file bundler e.g. (webpack), you may import the module.
import { Broadcaster } from 'nile.js'