2. SOMETHING ABOUT IT
WHAT IS MEDIASOUP?
A WebRTC SFU “Selective Forwarding Unit”
▸Handles the media layer
▸Doesn’t mix audio/video streams
A multi-party video solution for Node.js
▸Not a standalone media server
▸A server-side Node.js module
▸JavaScript ES6 API (core written in C++)
4. TOPOLOGIES
FULL MESH
▸ Each participant sends his audio and
video to all other participants
▸ Each participant receives all the streams
from all other participants
No media server needed
Low latency
Lot of encodings in each participant
High uplink bandwidth required
5. TOPOLOGIES
MCU: MULTIPOINT
CONTROL UNIT▸ Each participant sends his streams to a media server
▸ The server mixes all the streams and composes a
single one
▸ Example: Asterisk meetme
Simple at client side: single audio/video mixed stream
from the server
Interoperability: the server can transcode
Low bandwidth required
CPU expensive decoding/encoding in server side
(high latency)
Non flexible client side applications
6. TOPOLOGIES
SFU: SELECTIVE
FORWARDING UNIT▸ Participant sends his streams to a media server
▸ The media server routes the streams to all other
participants
▸ Each participant receives many streams
High throughput, low latency
Low CPU at server side (no decoding/encoding)
Good uplink bandwidth usage
The client side application can render each
remote video stream as desired
Simulcast/SVC required for real scenarios
8. A MULTI-PARTY FAMILY VIDEOCONFERENCE
Manu
▸At parents’ house
▸Antisystem
▸…but owns an iPhone 6
▸Excellent Wi-Fi connection
Beatriz
▸At home
▸Conservative
▸MacBook Air
▸Excellent Wi-Fi connection
Roberto
▸In the mountains
▸Unknown ideology
▸HTC Desire (2010)
▸Poor 3G connection
9. A MULTI-PARTY FAMILY VIDEOCONFERENCE
THE PROBLEM
▸Roberto has not a good
bandwidth
▸Roberto can not receive HD
video from Manu and
Beatriz
OUGH
!
10. A MULTI-PARTY FAMILY VIDEOCONFERENCE
POSSIBLE SOLUTIONS
1. Drop Roberto from the conference
2. Limit the video quality of Manu and Beatriz
3. …
11. A MULTI-PARTY FAMILY VIDEOCONFERENCE
SOLUTION: SIMULCAST / SVC
▸Manu and Beatriz send
different “quality” video
layers
▸The SFU chooses the
appropriate ones for
Roberto
12. TOPOLOGIES
FULL MESH MCU SFU
Client uplink Very high Low Low
Client downlink Very high Low High
Client CPU usage Very high Low Medium
Server CPU usage - Very high Very low
Latency None High Low
Can transcode - Yes No
Requires simulcast/SVC - - Yes
Flexible video layout Yes No Yes
15. MEDIASOUP IS MINIMALIST
WHAT IS *NOT* MEDIASOUP?
▸It is NOT a standalone server
▸It does NOT have “init” scripts for Debian or CentOS
▸It does NOT have a “config” file
▸It does NOT implement the SIP protocol
▸It does NOT implement ANY signaling protocol
▸It does NOT provide an “admin” web interface
▸It does NOT provide a client SDK
18. $ npm install —save mediasoup
MEDIASOUP & NODE.JS
A NODE.JS MODULE
▸A Node.js module is a dependency/library within a project
▸You create your Node.js based project/application
▸You add mediasoup as a module into it
19. MEDIASOUP & NODE.JS
A PACKAGE.JSON EXAMPLE
{
"name": "my-amazing-multiconference-server-app",
"version": "1.0.0",
"description": "Enterprise conferencing application",
"main": "index.js",
"author": "My Great Company",
"license": "UNLICENSED",
"dependencies": {
"express": "^4.14.0",
"mediasoup": "^1.0.0",
"socket.io": "^1.5.0"
}
}
21. MEDIASOUP
EXPOSES A
JAVASCRIPT
// Load mediasoup module
const mediasoup = require('mediasoup');
// Create a mediasoup Server
let server = mediasoup.Server();
// Options for the mediasoup Room
const roomOptions = {
mediaCodecs: [
{
kind : 'audio',
name : 'audio/opus',
clockRate : 48000
},
{
kind : 'video',
name : 'video/vp8',
clockRate : 90000
}
]
};
// Create a mediasoup Room
server.createRoom(roomOptions)
.then((room) => {
// Got the Room instance
handleRoom(room);
});
22. MEDIASOUP API
LOW LEVEL API
mediasoup exposes a low level API similar to ORTC
// Create a Peer
let peer = room.Peer('alice');
// Create a ICE+DTLS Transport
peer.createTransport(options)
.then((transport) => {
transport.setRemoteDtlsParameters(data);
});
// Create a RtpReceiver to handle audio from the browser
let audioReceiver = peer.RtpReceiver('audio', transport);
// Create a RtpReceiver to handle video from the browser
let videoReceiver = peer.RtpReceiver('video', transport);
23. MEDIASOUP API
HIGH LEVEL API
mediasoup also exposes a high level API similar to WebRTC 1.0
// Create a PeerConnection
let peerconnection = new mediasoup.webrtc.RTCPeerConnection(room, 'alice');
// Set the remote SDP offer
peerconnection.setRemoteDescription(desc)
.then(() => {
return peerconnection.createAnswer();
})
.then((desc) => {
return peerconnection.setLocalDescription(desc);
})
.then(() => {
// Answer the participant request with the SDP answer
request.accept({
sdp: peerconnection.localDescription.sdp
});
});
25. MEDIASOUP API
JUST MEDIA
▸mediasoup does NOT talk the SIP protocol
▸…nor it talks ANY signaling protocol
▸You can use socket.io (for example) to communicate with
browsers/endpoints via WebSocket
▸…or build your own protocol
27. MEDIASOUP ROADMAP
WORKING ON IT…
1.0.0
▸RTCP: process RTCP reports to allow mediasoup diagnose
per peer uplink/downlink issues
▸WebRTC 1.0: more API needed
2.0.0
▸Simulcast & SVC: handle multiple streams/layers from clients
and select which one to route to others
29. THE APPLICATION
ASK YOURSELF
▸ Want to build yet another boring enterprise
conferencing app?
▸ May be a funny social app?
▸ Will you build the app on Node.js?
▸ Browser app? mobile app? native
Android/iOS SDKs?
▸ Do you need interoperability with PSTN?
Really?
32. DEMO APPLICATION
FIRSTSIGHT
“See many people, only talk to one”
Backend
▸Node.js server running mediasoup and websocket modules
▸JS logic to handle media rooms and manage participants
Frontend
▸HTML5 application made with React.js
▸JS logic to handle MediaStream from room participants