Upgrade to Pro — share decks privately, control downloads, hide ads and more …

WebRTC Everywhere (Beyond the Browser) @ Data Terra Nemo 2015

WebRTC Everywhere (Beyond the Browser) @ Data Terra Nemo 2015

Talk by Feross Aboukhadijeh (that's me!) at Data Terra Nemo 2015 (http://dtn.is).

https://webtorrent.io
https://instant.io
http://feross.org

Feross Aboukhadijeh

May 23, 2015
Tweet

More Decks by Feross Aboukhadijeh

Other Decks in Technology

Transcript

  1. WebRTC Everywhere
    by Feross

    View Slide

  2. WebRTC
    Beyond the Browser

    View Slide

  3. WebTorrent
    4 BitTorrent in the browser
    4 True P2P implementation – not just a proxy
    4 No install – pure JavaScript with WebRTC
    4 Exposes files as node-style streams
    4 Stream into , , VLC, Chromecast,
    Airplay, etc.

    View Slide

  4. var WebTorrent = require('webtorrent')
    var client = new WebTorrent()
    client.add('magnet:...', function (torrent) {
    console.log('Got torrent metadata!', torrent.infoHash)
    torrent.files.forEach(function (file) {
    var video = document.createElement('video')
    document.body.appendChild(video)
    file.createReadStream().pipe(video)
    })
    })

    View Slide

  5. Astro
    Bob Ren
    Daniel Posch
    Feross Aboukhadijeh
    Iván Todorovich
    John Hiesey
    Joseph Dykstra
    Mathias Buus
    Travis Fischer
    many more...

    View Slide

  6. P2P

    View Slide

  7. POWER TO THE PEOPLE

    View Slide

  8. Freedom

    View Slide

  9. True personal computing

    View Slide

  10. WebRTC

    View Slide

  11. WebRTC is a backdoor
    4 Companies just want browser video chat
    4 But they're building P2P into the fabric of the web
    4 Let's use this opportunity!

    View Slide

  12. WebRTC Data Channel

    View Slide

  13. Data Channel Unintended Consequences
    4 Peer-assisted delivery (PeerCDN, Peer5, others)
    4 File transfer (WebTorrent, Sharefest)
    4 Website hosting over torrents
    4 Chat/email/encrypted real-time communications
    4 All future P2P protocols!

    View Slide

  14. WebRTC Whiteboard
    Demo

    View Slide

  15. WebRTC Whiteboard
    whiteboard.webtorrent.io

    View Slide

  16. WebRTC Whiteboard
    whiteboard.webtorrent.io
    github.com/feross/whiteboard

    View Slide

  17. Another unintended consequence...
    WebRTC beyond the
    browser

    View Slide

  18. This is WebRTC Everywhere
    4 WebRTC in web apps (desktop & mobile)
    4 WebRTC in desktop apps
    4 WebRTC in server apps
    4 WebRTC in mobile apps

    View Slide

  19. WebRTC is universal

    View Slide

  20. Only transport that works
    in the browser

    View Slide

  21. You get NAT traversal for free

    View Slide

  22. No cross-origin policy

    View Slide

  23. Mandatory transport
    encryption

    View Slide

  24. Data Channel API is easy!
    var channel = peer.createDataChannel()
    channel.send('hi')
    channel.addEventListener('message', function (event) {
    console.log('got message: ' + event.data)
    })

    View Slide

  25. Where does WebRTC work
    today?

    View Slide

  26. WebRTC support in Web Apps
    4 Google Chrome - supported
    4 Mozilla Firefox - supported
    4 Opera - supported
    4 Microsoft Edge (next IE) - planned
    4 Apple Safari - no comment

    View Slide

  27. WebRTC support in Desktop apps
    4 Electron (atom-shell) - easiest choice!
    4 NW.js (node-webkit) - also super easy!
    4 Google's webrtc.org - compile it into your app
    4 Ericsson's OpenWebRTC - compile it into your app

    View Slide

  28. WebRTC support in Server apps
    4 wrtc package on npm (native dep on webrtc.org)
    4 Google's webrtc.org - compile it into your app
    4 Ericsson's OpenWebRTC - compile it into your app

    View Slide

  29. WebRTC support in Mobile apps
    4 iOS - Google's webrtc.org - compile it into your app
    4 Android - Use Chromium WebView
    4 Or, better: Just use Chrome/Firefox on Android!

    View Slide

  30. Electron is awesome!

    View Slide

  31. Same code in both places
    Demo

    View Slide

  32. friends
    github.com/moose-team/friends

    View Slide

  33. You can run it headless!
    github.com/maxogden/electron-spawn

    View Slide


  34. View Slide

  35. There are challenges, and
    even some deal breakers

    View Slide

  36. WebRTC deal breakers

    View Slide

  37. No "Data Channel only" build
    4 All implementations include media component cruft
    4 Data channel build: code.google.com/p/webrtc/
    issues/detail?id=3892

    View Slide

  38. Not as lightweight as UDP
    4 Even after optimization, it won't ever be

    View Slide

  39. No IE/Safari support yet
    4 Consider using Temasys plugin
    4 Microsoft Edge support coming soon

    View Slide

  40. WebRTC challenges

    View Slide

  41. Offer/answer connection model
    4 IP/UDP/TCP is like calling a phone number
    4 WebRTC is like getting set up on a date

    View Slide

  42. Single points of failure
    remain!

    View Slide

  43. In browser, you need a domain name
    4 Possible solution: Make it work offline!
    4 hyperboot.org
    4 Service Workers

    View Slide

  44. Finding peers
    4 Easiest way is through a central tracker / introducer
    4 signalhub (used by Friends)
    4 bittorrent-tracker (used by WebTorrent)
    4 We need a general purpose WebRTC DHT!
    4 webrtc-explorer by David Dias

    View Slide

  45. STUN
    4 External service that aids in NAT traversal
    4 Lots of services just use Google's public STUN server
    4 You can run your own very cheaply
    4 Possible privacy leak, but unlikely

    View Slide

  46. Privacy leak
    4 Any webpage can query your local IPs
    4 Chrome disables local candidates on proxy/VPN
    4 Tor Browser Bundle disables WebRTC

    View Slide

  47. Streaming is a challenge
    4 No readable backpressure
    4 Writable backpressure is hacky
    4 bufferedAmount
    4 setInteval

    View Slide

  48. Despite challenges, we
    should rally around
    WebRTC

    View Slide

  49. We need more P2P apps

    View Slide

  50. We need more P2P primitives

    View Slide

  51. LET'S MAKE THE MAN
    A BIT HUMBLER

    View Slide

  52. "The sharing economy is
    mainly owned by the 1%"
    @jowyang

    View Slide

  53. simple-peer

    View Slide

  54. View Slide

  55. View Slide

  56. apps that use simple-peer
    4 Friends - P2P chat
    4 ScreenCat - Screen sharing
    4 WebTorrent - browser torrent client
    4 Whiteboard - draw together
    4 Lots of experiments: webrtc-explorer, peernet,
    rtcat, webcat ...

    View Slide

  57. bittorrent-dht

    View Slide

  58. Learn more about WebRTC
    "html5rocks webrtc basics"
    webrtchacks.com
    "simple-peer" on npm

    View Slide

  59. Learn more about
    WebTorrent
    webtorrent.io
    instant.io

    View Slide