SlideShare a Scribd company logo
1 of 47
Download to read offline
WEBRTC + SOCKET.IO
BUILDING A SKYPE-LIKE VIDEO CHAT WITH
NATIVE JAVASCRIPT
/MICHELE DI SALVATORE @MIKDISAL
Javascript Architect @ Objectway
Audio and video communication and peer-to-peer data
sharing through a web application
Native javascript (no plugins)
Open source
appear.in
HOW IS BORN
Global IP Solutions acquired by Google in 2010
Google open sourced the technologies
SUPPORTED BROWSERS AND PLATFORMS
IE AND SAFARI?
freeTemasys Plugin
JAVASCRIPT WEBRTC API
MediaStream
RTCPeerConnection
RTCDataChannel
MEDIASTREAM (AKA GETUSERMEDIA)
Acquiring audio and video
Can contain multiple 'tracks'
var constraints = {
video: {
mandatory: {
minWidth: 640,
minHeight: 360
}
};
function successCallback(stream) {
var video = document.querySelector("video");
video.src = window.URL.createObjectURL(stream);
}
function errorCallback(error) {
console.log("navigator.getUserMedia error: ", error);
}
Constraints controls the contents of the MediaStream
RTCPEERCONNECTION
Communicating audio and video
Signal processing
Codec handling
Peer to peer communication
Security
Bandwidth management
...
RTCDATACHANNEL
Communicating arbitrary data
Same API as WebSockets
Ultra-low latency
Unreliable or reliable
Secure
SIGNALING
Exchanging 'session description' objects
What formats I support, what I want to send
Network information for peer-to-peer setup
Any message mechanism and protocol
JSEP
JavaScript Session Establishment Protocol
RTCSESSIONDESCRIPTION EXAMPLE
v=0
o=- 7614219274584779017 2 IN IP4 127.0.0.1
s=-
t=0 0
a=group:BUNDLE audio video
a=msid-semantic: WMS
m=audio 1 RTP/SAVPF 111 103 104 0 8 107 106 105 13 126
c=IN IP4 0.0.0.0
a=rtcp:1 IN IP4 0.0.0.0
a=ice-ufrag:W2TGCZw2NZHuwlnf
a=ice-pwd:xdQEccP40E+P0L5qTyzDgfmW
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level
a=mid:audio
a=rtcp-mux
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:9c1AHz27dZ9xPI91YNfSlI67/EMkjHHIHORiC
a=rtpmap:111 opus/48000/2
...
P2P IN REAL WORLD
NAT & Firewalls?
STUN SERVER
Gives my public IP address
Simple server, cheap to run
Data flows peer-to-peer
STUN SERVER
TURN SERVER
Fallback for p2p failing
Data via server
Call works everywhere
STUN + TURN SERVERS
ICE
Interactive Connectivity Establishment
A framework to connect peers via UDP, enabling
RTCPeerConnection via STUN and TURN server
WEBRTC SECURITY
On Chrome only via https
Encryption for media and data
Sandboxed
WEBRTC LIBRARIES & CO.
by
by
by
by
...
adapter.js webrtc
rtc-everywhere contra
SimpleWebRTC &Yet
RTCMultiConnection Muaz Khan
RTCMULTICONNECTION
A javascript wrapper library supporting
approximately all possible peer-to-peer
features.
WEBRTC EXPERIMENTS
Tons of open source experiments based on
RTCMultiConnection:
webrtc-experiment.com
WEBSOCKETS
Standardized in 2011
Interactive communication session between browser and
server
Event driven
Sending strings and binary data
WEBSOCKETS BROWSER SUPPORT
All and IE10+
ajax polling as fallback
SOCKET.IO
A popular open source library with client and server
implementations
Server side written in Node and easy to start
var server = require('http').createServer();
var io = require('socket.io')(server);
io.on('connection', function(socket){
socket.on('hi!', function(data){
socket.emit('a-message', {hello: 'world'});
});
socket.on('disconnect', function(){});
});
server.listen(3000);
SOCKET.IO CLIENT
var socket = io.connect('http://localhost:3000/');
socket.on('connect', function () {
socket.emit('hi!');
});
socket.on('a-message', function (data) {
console.log(data.hello);
});
GOAL
A SKYPE LIKE CHAT
MAIN ISSUES
WebRTC architecture like IRC
rooms with shared chat: text, video and data
direct chat: only one to one
room managed by initiator
conversation type can change without agreement: text to
video
IMPLEMENTATION
STEP 1
UserA is logged in and is connected to the socket server
STEP 2
The app sends a "presence" event to other users through
the socket
The server forwards the message only to user's contacts
Each present user replies with the same "presence" event
SOCKET.IO FORWARD ROLE
STEP 3
Each present user replies with the same "presence" event
STEP 4
When a user receives a "presence" event, it automatically
knows that the sender is online
Also the server sends the “presence” event to all, when a
user socket is disconnected
STEP 5
UserA starts a conversation and the app creates the webrtc
connection
STEP 6
UserA sends a message via webrtc
STEP 7
UserB receives a notification
STEP 8
UserB starts writing a message
STEP 9
UserA receives the "is typing" info sent via webrtc
STEP 10
UserA starts a video call sending a request to UserB via
socket
STEP 11
UserB receives the request and accepting starts a video call
via webrtc
STEP 12
The 2 users can video chat via webrtc
Each user can close the video at any time or start a text chat
STEP 13
A user can send text messages also
STEP 14
A user can start an audio chat in the same way as a video
chat
chat
BEHIND THE SCENES
WHERE IS WEBRTC?
Behind this actions
chat messages
video / audio call
"is typing" info
AND THE OTHERS?
via WebSockets
presence
video / audio initialization
all status infos
THAT'S ALL!
THANK YOU ALL
/Michele Di Salvatore @MikDiSal

More Related Content

What's hot

Reverse proxy
Reverse proxyReverse proxy
Reverse proxy
tim4911
 

What's hot (20)

Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
docker installation and basics
docker installation and basicsdocker installation and basics
docker installation and basics
 
test2
test2test2
test2
 
Git interview questions | Edureka
Git interview questions | EdurekaGit interview questions | Edureka
Git interview questions | Edureka
 
A Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things ContainersA Gentle Introduction To Docker And All Things Containers
A Gentle Introduction To Docker And All Things Containers
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Docker Advanced registry usage
Docker Advanced registry usageDocker Advanced registry usage
Docker Advanced registry usage
 
Intro docker
Intro dockerIntro docker
Intro docker
 
Builder pattern
Builder patternBuilder pattern
Builder pattern
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
Reverse proxy
Reverse proxyReverse proxy
Reverse proxy
 
Docker
DockerDocker
Docker
 
Midi technique - présentation docker
Midi technique - présentation dockerMidi technique - présentation docker
Midi technique - présentation docker
 
Docker compose
Docker composeDocker compose
Docker compose
 
HTTP
HTTPHTTP
HTTP
 
Multi Stage Docker Build
Multi Stage Docker Build Multi Stage Docker Build
Multi Stage Docker Build
 
Head first docker
Head first dockerHead first docker
Head first docker
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Docker Container Introduction
Docker Container IntroductionDocker Container Introduction
Docker Container Introduction
 
Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)Go swagger tutorial how to create golang api documentation using go swagger (1)
Go swagger tutorial how to create golang api documentation using go swagger (1)
 

Viewers also liked

Viewers also liked (20)

Team working e team building
Team working e team buildingTeam working e team building
Team working e team building
 
A jQuery for WebRTC
A jQuery for WebRTCA jQuery for WebRTC
A jQuery for WebRTC
 
Server-side WebRTC Infrastructure
Server-side WebRTC InfrastructureServer-side WebRTC Infrastructure
Server-side WebRTC Infrastructure
 
WebRTC with Java
WebRTC with JavaWebRTC with Java
WebRTC with Java
 
To Build or Not to Build Your WebRTC Infrastructure
To Build or Not to Build Your WebRTC InfrastructureTo Build or Not to Build Your WebRTC Infrastructure
To Build or Not to Build Your WebRTC Infrastructure
 
A Practical Guide to WebRTC
A Practical Guide to WebRTCA Practical Guide to WebRTC
A Practical Guide to WebRTC
 
WebRTC on Mobile
WebRTC on MobileWebRTC on Mobile
WebRTC on Mobile
 
Team building
Team buildingTeam building
Team building
 
Il Team Player 20.20 - Le caratteristiche della persona che tutti i Team cercano
Il Team Player 20.20 - Le caratteristiche della persona che tutti i Team cercanoIl Team Player 20.20 - Le caratteristiche della persona che tutti i Team cercano
Il Team Player 20.20 - Le caratteristiche della persona che tutti i Team cercano
 
Formazione e Team building
Formazione e Team buildingFormazione e Team building
Formazione e Team building
 
La gestione del team work
La gestione del team workLa gestione del team work
La gestione del team work
 
Team building
Team buildingTeam building
Team building
 
Baby Steps: A WebRTC Tutorial
Baby Steps: A WebRTC TutorialBaby Steps: A WebRTC Tutorial
Baby Steps: A WebRTC Tutorial
 
Lavorare in team
Lavorare in teamLavorare in team
Lavorare in team
 
Setup ephemeral password for TURN, Learn RTC in less than 200 Lines of code
Setup ephemeral password for TURN, Learn RTC in less than 200 Lines of codeSetup ephemeral password for TURN, Learn RTC in less than 200 Lines of code
Setup ephemeral password for TURN, Learn RTC in less than 200 Lines of code
 
TEAM BUILDING POWERPOINT
TEAM BUILDING POWERPOINTTEAM BUILDING POWERPOINT
TEAM BUILDING POWERPOINT
 
How I built a WebRTC enabled website in 20 minutes!
How I built a WebRTC enabled website in 20 minutes!How I built a WebRTC enabled website in 20 minutes!
How I built a WebRTC enabled website in 20 minutes!
 
Learn node.js by building projects
Learn node.js by building projectsLearn node.js by building projects
Learn node.js by building projects
 
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...
Web rtc, Media stream, Peer connection, Setting up STUN and TURN on Linux and...
 
Socket.IO
Socket.IOSocket.IO
Socket.IO
 

Similar to WebRTC + Socket.io: building a skype-like video chat with native javascript

Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqela
jobandesther
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
Viktor Gamov
 

Similar to WebRTC + Socket.io: building a skype-like video chat with native javascript (20)

Introduction To Webrtc
Introduction To WebrtcIntroduction To Webrtc
Introduction To Webrtc
 
Nodejs and WebSockets
Nodejs and WebSocketsNodejs and WebSockets
Nodejs and WebSockets
 
WebRTC
WebRTCWebRTC
WebRTC
 
Networking and Data Access with Eqela
Networking and Data Access with EqelaNetworking and Data Access with Eqela
Networking and Data Access with Eqela
 
WebRTC: Bring real-time to the web - Barcamp Saigon 2012
WebRTC: Bring real-time to the web - Barcamp Saigon 2012WebRTC: Bring real-time to the web - Barcamp Saigon 2012
WebRTC: Bring real-time to the web - Barcamp Saigon 2012
 
JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013JooinK - DevFest Piemonte 2013
JooinK - DevFest Piemonte 2013
 
WebRTC 101 - How to get started building your first WebRTC application
WebRTC 101 - How to get started building your first WebRTC applicationWebRTC 101 - How to get started building your first WebRTC application
WebRTC 101 - How to get started building your first WebRTC application
 
WebRTC - Brings Real-Time to the Web
WebRTC - Brings Real-Time to the WebWebRTC - Brings Real-Time to the Web
WebRTC - Brings Real-Time to the Web
 
React Native EU 2021 - Creating a VoIP app in React Native - the beginner's g...
React Native EU 2021 - Creating a VoIP app in React Native - the beginner's g...React Native EU 2021 - Creating a VoIP app in React Native - the beginner's g...
React Native EU 2021 - Creating a VoIP app in React Native - the beginner's g...
 
Pushing the Boundaries of Sencha and HTML5′s WebRTC
Pushing the Boundaries of Sencha and HTML5′s WebRTCPushing the Boundaries of Sencha and HTML5′s WebRTC
Pushing the Boundaries of Sencha and HTML5′s WebRTC
 
How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-How to create a real time chat application using socket.io, golang, and vue js-
How to create a real time chat application using socket.io, golang, and vue js-
 
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java DevelopersWebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
WebSockets: The Current State of the Most Valuable HTML5 API for Java Developers
 
DevCon5 (July 2014) - Acision SDK
DevCon5 (July 2014) - Acision SDKDevCon5 (July 2014) - Acision SDK
DevCon5 (July 2014) - Acision SDK
 
Oracle JET and WebSocket
Oracle JET and WebSocketOracle JET and WebSocket
Oracle JET and WebSocket
 
HTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the WebHTML5 WebSocket: The New Network Stack for the Web
HTML5 WebSocket: The New Network Stack for the Web
 
Webrtc in Real world
Webrtc in Real world Webrtc in Real world
Webrtc in Real world
 
Meego Widget Development using Qt WRT @iRajLal
Meego Widget Development using Qt WRT @iRajLalMeego Widget Development using Qt WRT @iRajLal
Meego Widget Development using Qt WRT @iRajLal
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
Node worshop Realtime - Socket.io
Node worshop Realtime - Socket.ioNode worshop Realtime - Socket.io
Node worshop Realtime - Socket.io
 
HTML5 WebWorks
HTML5 WebWorksHTML5 WebWorks
HTML5 WebWorks
 

Recently uploaded

introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
VishalKumarJha10
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
VictorSzoltysek
 

Recently uploaded (20)

Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 

WebRTC + Socket.io: building a skype-like video chat with native javascript