SlideShare une entreprise Scribd logo
1  sur  48
Télécharger pour lire hors ligne
Intro to WebRTC and VozDigital 
Iván Mosquera, Senior Software Engineer 
imosquera@tuenti.com | ivan@ivanmosquera.net | @ivmos | @theevnt | @Tuentieng
whoami 
● From Bilbao 
● Enjoying Tuenti since 2010 
● Member of Voice Team 
● @ivmos 
● @TuentiEng
● May 2011 
● “To enable rich, high 
quality, RTC 
applications to be 
developed in the 
browser via simple 
JavaScript APIs and 
HTML5.” 
● Plugin-free 
● Javascript API 
● Native API 
available too
Before WebRTC? 
● Plugins: flash, java, native addons.. 
● Codecs..
Let´s go! 
● We need some theory. 
● APIs: 
○ MediaStream/getUserMedia 
○ RTC PeerConnection 
○ RTC Data channel (remember, not only a/v!)
Client API (JS/wrappers) 
WebRTC C++ API 
Session handling 
Transport 
Video 
Engine 
WebRTC 
Voice 
Engine 
Audio Capture/Render Video Capture Network IO
What WebRTC does not provide... 
Signaling!!! 
● WebRTC solves the media transport 
problem, not the high level signaling one. 
● NAT traversal problem: ICE
Workshop hints 
● https://gist.github.com/ivmos/HASH 
● http://jsfiddle.net/gh/gist/lib/V/HASH
GO GO GO: let´s get media! 
http://jsfiddle. 
net/gh/gist/library/pure/7fb79f59ab1f2a36ff27/ 
Action: check console 
● Audio&Video source with MediaStream API. 
● Chrome snippets (interop) (polyfill) 
● navigator.webkitGetUserMedia
let’s hype a bit 
● You can mix with other Javascript APIs 
○ ASCII camera 
○ Photobooth app 
● We´re not studying it but RtcDataChannel 
API is awesome too 
○ http://www.peer-server.com/ 
○ https://rtccopy.com/ 
○ https://github.com/feross/webtorrent
We have the video, let´s offer it 
http://jsfiddle. 
net/gh/gist/library/pure/8ce6340f8870f6d91f0a/2b1596f312403 
7dedf7ea443413c8a0352599606/ 
Action: check offer SDP 
● pc: RTCPeerConnection 
● Once we have the video, with the pc we 
need to offer it with a description 
● pc.addStream 
● pc.createOffer
RTCSessionDescription 
● pc.setLocalDescription 
(offer) 
● RTCSessionDescription 
● offer, answer.. 
● sdp (1998, RTP, RTSP…) 
● check offer.sdp :) 
● sending that sdp… (no 
signaling defined) 
v=0 
o=- 4420499408415283528 2 IN IP4 127.0.0.1 
s=- 
t=0 0 
a=group:BUNDLE audio video 
a=msid-semantic: WMS 
VNGaWbmub1HsBjaxybQCE91gqOW5RFN3zt2Z 
m=audio 1 RTP/SAVPF 111 103 104 0 8 106 105 13 126 
c=IN IP4 0.0.0.0 
a=rtcp:1 IN IP4 0.0.0.0 
a=ice-ufrag:rTPGidiJq18Xsr2l 
a=ice-pwd:xrvmCOYkTGlIcqNMuCFr9yrf 
a=ice-options:google-ice 
a=fingerprint:sha-256 A0:15:3C:15:22:98:E9:D1:4C:60: 
D0:0D:F7:34:A8:DA:9F:52:E0:D1:D0:16:43:B3:5D:95:EC: 
EB:B4:9C:90:D5 
a=setup:actpass 
a=mid:audio 
a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level 
a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/ 
abs-send-time 
http://jsfiddle. 
net/gh/gist/library/pure/6272bd4f5c626ab7a2bc/68170b303b509d9a17d9c968 
a5447aaee117cbb3/ 
Action: check how we’re “sending” the offer SDP 
http://webrtchacks.com/sdp-anatomy/
Let´s answer it 
http://jsfiddle. 
net/gh/gist/library/pure/7fbe699afc6462f22cd1/a418431770c29a00a252 
d48730e4613500c196df/ 
Actions: 
● Send offer sdp to callee 
● Send answer sdp to caller 
● isCaller flag 
● pc.setRemoteDescription 
● pc.createAnswer 
● pc.setLocalDescription(answer)
… and receiving the answer 
http://jsfiddle.net/gh/gist/library/pure/8d0c1e1bd09fe27761ff/ 
Action: 
● Offer 
● Answer 
● Caller does not know about callee yet 
● Receiving the answer the same way the 
callee received the offer (signaling) 
● pc.setRemoteDescription with type.answer 
● check pc state..
pc state until now, finished? 
http://jsfiddle.net/gh/gist/library/pure/8d0c1e1bd09fe27761ff/ 
Same code, but this time pay attention to the pc state 
● pc.localDescription OK 
● pc.remoteDescription OK 
● pc.onicecandidate ??? 
● pc.onaddstream ???
ICE 
● Purpose 
● Candidate 
● Types: 
http://jsfiddle. 
net/gh/gist/library/pure/0ea6abc8a6f7064895a6/f1086199fbb 
3296a39172ac2119c05e9fd851a29/ 
Action: check refactor 
http://jsfiddle. 
net/gh/gist/library/pure/0ea6abc8a6f7064895a6/1d4a6676e8 
6824353b4b17aabad02031690b28f5/ 
Action: 
● check the candidates 
● check pc.iceGatheringState 
○ local 
○ reflexive/stun 
○ relay/turn 
● pc.onicecandidate 
● pc.iceconnectionstate 
http://jsfiddle. 
net/gh/gist/library/pure/0ea6abc8a6f7064895a6/c9 
d54da712a7d69d44dafa4e1339fea3764ca01a/ 
Action: 
● Check candidates again 
http://jsfiddle. 
net/gh/gist/library/pure/0ea6abc8a6f7064895a6/798c3aba9bf521f5 
08ad31f9d0e93e6d81ccb61f/ 
Actions: do the whole flow again, offer, answer and candidates
no video yet, what´s missing? 
● pc.onaddstream 
http://jsfiddle.net/gh/gist/jquery/1.11.0 
/0ea6abc8a6f7064895a6/05f7404850c1933e07fc4b72faa07841180c320f/ 
Action: try again the whole flow, you should now have video in both tabs 
:) 
https://github.com/ivmos/webrtc-workshop/tree/master/cpJsApp
Recap 
● create pc 
● create offer, pc.setLocalDescription(offer) 
● send offer 
● receive offer 
● pc.setRemoteDescription(offer) 
● pc.createAnswer, pc.setLocalDescr(answer) 
● send answer 
● receive answer 
● pc.setRemoteDescription(answer) 
● ICE!!
Recap: caller 
CREATE PEER 
CONNECTION 
CREATE OFFER 
SEND OFFER 
RECEIVE ANSWER 
SAVE ANSWER 
PROFIT!
Recap: callee 
RECEIVE OFFER 
CREATE PEER 
CONNECTION 
SAVE OFFER 
CREATE ANSWER 
SEND ANSWER 
PROFIT!
BOTH 
SEND ICE 
CANDIDATE 
SEND ICE 
CANDIDATE 
SEND ICE 
CANDIDATE 
SEND ICE 
CANDIDATE 
SEND ICE 
CANDIDATE 
SEND ICE 
CANDIDATE
Server signaling iteration 
● XHR polling example 
● API: 
○ startSession(sid, success) 
○ getParticipants(sid, success) 
○ getMessages(sid, success) 
○ sendOffer(sid, to, offerSdp, success) 
○ sendAnswer(sid, to, answerSdp, success) 
○ sendIceCandidate(sid, to, candSdp, success) 
○ sendTerminate(sid, to, success) 
● MySql backend: 
○ sessions 
○ requests 
Base snippet: 
http://jsfiddle.net/gh/gist/jquery/1.11.0 
/9a93a110efb9cf0ae46f/7d03c3c617753d2029950b05181d557925a 
4a7d4/
1. Use real signaling 
● Instead of copy-paste signaling, use the 
provided API. “s/console.log/Api.*/g” 
● mySid, otherSid hardcoded by now, we still 
assume we’re only working with 2 tabs. 
● Candidates to be sent one by one 
● Api.startSession needed
2. Listen for messages 
● We need to listen for offer, answer and 
candidate type messages 
● setInterval loop
3. adding candidates fix 
● Check pc.remoteDescription before pc. 
addIceCandidate. Enqueue if needed. 
● Do the pc.addIceCandidate after pc. 
setRemoteDescription 
● Not a problem for caller as he starts the 
signaling 
● Profit!
Improvements 
● unharcode otherSid 
○ <select> for to (callee) 
■ getParticipants loop 
● Call button: isCaller and offer 
■ call method 
● unharcode mySid 
○ <input> for sessionId (caller) 
● Add your own video too 
http://jsfiddle.net/gh/gist/jquery/1.11.0/5692b5b7c0fa4d855d2b/ 
https://github.com/ivmos/webrtc-workshop/tree/master/xhrJsApp
Security 
● In our implementation, signaling security 
concerns? 
● In media channel? 
○ WebRTC security
A few links 
● WebRTC 1.0 RFC 
● Understanding why ORTC effort (Iñaki Baz 
interview) 
● JS Lib using SIP signaling: http://jssip.net 
● http://webrtchacks.com/ 
● https://www.webrtc-experiment.com/ (Muaz 
Khan interview) 
● http://corporate.tuenti. 
com/en/dev/blog/Building-a-VoIP-Service-using- 
WebRTC
An inbound & outbound VoIP service 
…using the customer’s GSM number! 
…with no additional data charges! 
…integrated with existing Tuenti chat infrastructure
WebRTC for App2App calls
Multiple resources 
Will he be 
available??
Always Connected Application
Solution Overview
Signaling over XMPP 
● Jingle protocol 
<jingle xmlns='urn:xmpp:jingle:1' 
action='session-initiate' 
initiator='romeo@montague.lit/orchard' 
sid='a73sjjvkla37jfea'> 
<content creator='initiator' name='voice'> 
<description xmlns='urn:xmpp:jingle:apps:rtp:1' media='audio'> 
<payload-type id='96' name='speex' clockrate='16000'/> 
<payload-type id='97' name='speex' clockrate='8000'/> 
<payload-type id='18' name='G729'/> 
<payload-type id='0' name='PCMU' /> 
<payload-type id='103' name='L16' clockrate='16000' channels='2'/> 
<payload-type id='98' name='x-ISAC' clockrate='8000'/> 
</description> 
</content> 
</jingle>
SDP over XMPP in tuenti 
● Tangle protocol 
<tangle xmlns='urn:tuenti:tangle:1' 
action='session-initiate' 
initiator='javierf@tuenti.com' 
sid='a73sjjvkla37jfea'> 
<sdp><![CDATA[SDP]]></sdp> 
</tangle>
VoIP message sequence chart
Tangle multiple resources
We need a SIP stack!
VoIP message sequence chart
SIP message sequence chart
Merging the message sequence charts
Voice Gateway Overview 
Messenger 
xmpp http SIP 
App Chat Server 
Http 
Server 
SIP Servlets Application SIP provider
Questions?

Contenu connexe

Dernier

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvLewisJB
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptMadan Karki
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsSachinPawar510423
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfROCENODodongVILLACER
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringJuanCarlosMorales19600
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)dollysharma2066
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptSAURABHKUMAR892774
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction managementMariconPadriquez1
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptJasonTagapanGulla
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the weldingMuhammadUzairLiaqat
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncssuser2ae721
 

Dernier (20)

Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Work Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvvWork Experience-Dalton Park.pptxfvvvvvvv
Work Experience-Dalton Park.pptxfvvvvvvv
 
Indian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.pptIndian Dairy Industry Present Status and.ppt
Indian Dairy Industry Present Status and.ppt
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
Vishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documentsVishratwadi & Ghorpadi Bridge Tender documents
Vishratwadi & Ghorpadi Bridge Tender documents
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Risk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdfRisk Assessment For Installation of Drainage Pipes.pdf
Risk Assessment For Installation of Drainage Pipes.pdf
 
Piping Basic stress analysis by engineering
Piping Basic stress analysis by engineeringPiping Basic stress analysis by engineering
Piping Basic stress analysis by engineering
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
Call Us ≽ 8377877756 ≼ Call Girls In Shastri Nagar (Delhi)
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
Arduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.pptArduino_CSE ece ppt for working and principal of arduino.ppt
Arduino_CSE ece ppt for working and principal of arduino.ppt
 
computer application and construction management
computer application and construction managementcomputer application and construction management
computer application and construction management
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
Solving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.pptSolving The Right Triangles PowerPoint 2.ppt
Solving The Right Triangles PowerPoint 2.ppt
 
welding defects observed during the welding
welding defects observed during the weldingwelding defects observed during the welding
welding defects observed during the welding
 
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsyncWhy does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
Why does (not) Kafka need fsync: Eliminating tail latency spikes caused by fsync
 

En vedette

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

En vedette (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Intro to WebRTC and VozDigital

  • 1. Intro to WebRTC and VozDigital Iván Mosquera, Senior Software Engineer imosquera@tuenti.com | ivan@ivanmosquera.net | @ivmos | @theevnt | @Tuentieng
  • 2. whoami ● From Bilbao ● Enjoying Tuenti since 2010 ● Member of Voice Team ● @ivmos ● @TuentiEng
  • 3.
  • 4. ● May 2011 ● “To enable rich, high quality, RTC applications to be developed in the browser via simple JavaScript APIs and HTML5.” ● Plugin-free ● Javascript API ● Native API available too
  • 5. Before WebRTC? ● Plugins: flash, java, native addons.. ● Codecs..
  • 6. Let´s go! ● We need some theory. ● APIs: ○ MediaStream/getUserMedia ○ RTC PeerConnection ○ RTC Data channel (remember, not only a/v!)
  • 7.
  • 8. Client API (JS/wrappers) WebRTC C++ API Session handling Transport Video Engine WebRTC Voice Engine Audio Capture/Render Video Capture Network IO
  • 9. What WebRTC does not provide... Signaling!!! ● WebRTC solves the media transport problem, not the high level signaling one. ● NAT traversal problem: ICE
  • 10. Workshop hints ● https://gist.github.com/ivmos/HASH ● http://jsfiddle.net/gh/gist/lib/V/HASH
  • 11. GO GO GO: let´s get media! http://jsfiddle. net/gh/gist/library/pure/7fb79f59ab1f2a36ff27/ Action: check console ● Audio&Video source with MediaStream API. ● Chrome snippets (interop) (polyfill) ● navigator.webkitGetUserMedia
  • 12. let’s hype a bit ● You can mix with other Javascript APIs ○ ASCII camera ○ Photobooth app ● We´re not studying it but RtcDataChannel API is awesome too ○ http://www.peer-server.com/ ○ https://rtccopy.com/ ○ https://github.com/feross/webtorrent
  • 13. We have the video, let´s offer it http://jsfiddle. net/gh/gist/library/pure/8ce6340f8870f6d91f0a/2b1596f312403 7dedf7ea443413c8a0352599606/ Action: check offer SDP ● pc: RTCPeerConnection ● Once we have the video, with the pc we need to offer it with a description ● pc.addStream ● pc.createOffer
  • 14. RTCSessionDescription ● pc.setLocalDescription (offer) ● RTCSessionDescription ● offer, answer.. ● sdp (1998, RTP, RTSP…) ● check offer.sdp :) ● sending that sdp… (no signaling defined) v=0 o=- 4420499408415283528 2 IN IP4 127.0.0.1 s=- t=0 0 a=group:BUNDLE audio video a=msid-semantic: WMS VNGaWbmub1HsBjaxybQCE91gqOW5RFN3zt2Z m=audio 1 RTP/SAVPF 111 103 104 0 8 106 105 13 126 c=IN IP4 0.0.0.0 a=rtcp:1 IN IP4 0.0.0.0 a=ice-ufrag:rTPGidiJq18Xsr2l a=ice-pwd:xrvmCOYkTGlIcqNMuCFr9yrf a=ice-options:google-ice a=fingerprint:sha-256 A0:15:3C:15:22:98:E9:D1:4C:60: D0:0D:F7:34:A8:DA:9F:52:E0:D1:D0:16:43:B3:5D:95:EC: EB:B4:9C:90:D5 a=setup:actpass a=mid:audio a=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level a=extmap:3 http://www.webrtc.org/experiments/rtp-hdrext/ abs-send-time http://jsfiddle. net/gh/gist/library/pure/6272bd4f5c626ab7a2bc/68170b303b509d9a17d9c968 a5447aaee117cbb3/ Action: check how we’re “sending” the offer SDP http://webrtchacks.com/sdp-anatomy/
  • 15. Let´s answer it http://jsfiddle. net/gh/gist/library/pure/7fbe699afc6462f22cd1/a418431770c29a00a252 d48730e4613500c196df/ Actions: ● Send offer sdp to callee ● Send answer sdp to caller ● isCaller flag ● pc.setRemoteDescription ● pc.createAnswer ● pc.setLocalDescription(answer)
  • 16. … and receiving the answer http://jsfiddle.net/gh/gist/library/pure/8d0c1e1bd09fe27761ff/ Action: ● Offer ● Answer ● Caller does not know about callee yet ● Receiving the answer the same way the callee received the offer (signaling) ● pc.setRemoteDescription with type.answer ● check pc state..
  • 17. pc state until now, finished? http://jsfiddle.net/gh/gist/library/pure/8d0c1e1bd09fe27761ff/ Same code, but this time pay attention to the pc state ● pc.localDescription OK ● pc.remoteDescription OK ● pc.onicecandidate ??? ● pc.onaddstream ???
  • 18. ICE ● Purpose ● Candidate ● Types: http://jsfiddle. net/gh/gist/library/pure/0ea6abc8a6f7064895a6/f1086199fbb 3296a39172ac2119c05e9fd851a29/ Action: check refactor http://jsfiddle. net/gh/gist/library/pure/0ea6abc8a6f7064895a6/1d4a6676e8 6824353b4b17aabad02031690b28f5/ Action: ● check the candidates ● check pc.iceGatheringState ○ local ○ reflexive/stun ○ relay/turn ● pc.onicecandidate ● pc.iceconnectionstate http://jsfiddle. net/gh/gist/library/pure/0ea6abc8a6f7064895a6/c9 d54da712a7d69d44dafa4e1339fea3764ca01a/ Action: ● Check candidates again http://jsfiddle. net/gh/gist/library/pure/0ea6abc8a6f7064895a6/798c3aba9bf521f5 08ad31f9d0e93e6d81ccb61f/ Actions: do the whole flow again, offer, answer and candidates
  • 19. no video yet, what´s missing? ● pc.onaddstream http://jsfiddle.net/gh/gist/jquery/1.11.0 /0ea6abc8a6f7064895a6/05f7404850c1933e07fc4b72faa07841180c320f/ Action: try again the whole flow, you should now have video in both tabs :) https://github.com/ivmos/webrtc-workshop/tree/master/cpJsApp
  • 20. Recap ● create pc ● create offer, pc.setLocalDescription(offer) ● send offer ● receive offer ● pc.setRemoteDescription(offer) ● pc.createAnswer, pc.setLocalDescr(answer) ● send answer ● receive answer ● pc.setRemoteDescription(answer) ● ICE!!
  • 21. Recap: caller CREATE PEER CONNECTION CREATE OFFER SEND OFFER RECEIVE ANSWER SAVE ANSWER PROFIT!
  • 22. Recap: callee RECEIVE OFFER CREATE PEER CONNECTION SAVE OFFER CREATE ANSWER SEND ANSWER PROFIT!
  • 23. BOTH SEND ICE CANDIDATE SEND ICE CANDIDATE SEND ICE CANDIDATE SEND ICE CANDIDATE SEND ICE CANDIDATE SEND ICE CANDIDATE
  • 24. Server signaling iteration ● XHR polling example ● API: ○ startSession(sid, success) ○ getParticipants(sid, success) ○ getMessages(sid, success) ○ sendOffer(sid, to, offerSdp, success) ○ sendAnswer(sid, to, answerSdp, success) ○ sendIceCandidate(sid, to, candSdp, success) ○ sendTerminate(sid, to, success) ● MySql backend: ○ sessions ○ requests Base snippet: http://jsfiddle.net/gh/gist/jquery/1.11.0 /9a93a110efb9cf0ae46f/7d03c3c617753d2029950b05181d557925a 4a7d4/
  • 25. 1. Use real signaling ● Instead of copy-paste signaling, use the provided API. “s/console.log/Api.*/g” ● mySid, otherSid hardcoded by now, we still assume we’re only working with 2 tabs. ● Candidates to be sent one by one ● Api.startSession needed
  • 26. 2. Listen for messages ● We need to listen for offer, answer and candidate type messages ● setInterval loop
  • 27. 3. adding candidates fix ● Check pc.remoteDescription before pc. addIceCandidate. Enqueue if needed. ● Do the pc.addIceCandidate after pc. setRemoteDescription ● Not a problem for caller as he starts the signaling ● Profit!
  • 28. Improvements ● unharcode otherSid ○ <select> for to (callee) ■ getParticipants loop ● Call button: isCaller and offer ■ call method ● unharcode mySid ○ <input> for sessionId (caller) ● Add your own video too http://jsfiddle.net/gh/gist/jquery/1.11.0/5692b5b7c0fa4d855d2b/ https://github.com/ivmos/webrtc-workshop/tree/master/xhrJsApp
  • 29. Security ● In our implementation, signaling security concerns? ● In media channel? ○ WebRTC security
  • 30. A few links ● WebRTC 1.0 RFC ● Understanding why ORTC effort (Iñaki Baz interview) ● JS Lib using SIP signaling: http://jssip.net ● http://webrtchacks.com/ ● https://www.webrtc-experiment.com/ (Muaz Khan interview) ● http://corporate.tuenti. com/en/dev/blog/Building-a-VoIP-Service-using- WebRTC
  • 31.
  • 32. An inbound & outbound VoIP service …using the customer’s GSM number! …with no additional data charges! …integrated with existing Tuenti chat infrastructure
  • 34. Multiple resources Will he be available??
  • 36.
  • 38. Signaling over XMPP ● Jingle protocol <jingle xmlns='urn:xmpp:jingle:1' action='session-initiate' initiator='romeo@montague.lit/orchard' sid='a73sjjvkla37jfea'> <content creator='initiator' name='voice'> <description xmlns='urn:xmpp:jingle:apps:rtp:1' media='audio'> <payload-type id='96' name='speex' clockrate='16000'/> <payload-type id='97' name='speex' clockrate='8000'/> <payload-type id='18' name='G729'/> <payload-type id='0' name='PCMU' /> <payload-type id='103' name='L16' clockrate='16000' channels='2'/> <payload-type id='98' name='x-ISAC' clockrate='8000'/> </description> </content> </jingle>
  • 39. SDP over XMPP in tuenti ● Tangle protocol <tangle xmlns='urn:tuenti:tangle:1' action='session-initiate' initiator='javierf@tuenti.com' sid='a73sjjvkla37jfea'> <sdp><![CDATA[SDP]]></sdp> </tangle>
  • 42. We need a SIP stack!
  • 45. Merging the message sequence charts
  • 46. Voice Gateway Overview Messenger xmpp http SIP App Chat Server Http Server SIP Servlets Application SIP provider
  • 47.