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

WebRTC (概要から中の仕組みまで)

WebRTC (概要から中の仕組みまで)

High Performance Browser Networking 輪読会の資料です。

Yosuke Furukawa

October 08, 2014
Tweet

More Decks by Yosuke Furukawa

Other Decks in Programming

Transcript

  1. getUserMedia <video autoplay></video> <script> navigator.getUserMedia = ( navigator.getUserMedia || navigator.webkitGetUserMedia

    || navigator.mozGetUserMedia || navigator.msGetUserMedia); var constraints = { audio: true, video: true } navigator.getUserMedia(constraints, gotStream, logError); function gotStream(stream) { var video = document.querySelector('video'); video.src = window.URL.createObjectURL(stream); video.play(); } function logError(error) { console.log(error); } </script>
  2. RTCPeerConnection API 1. SDP (P2PωΰγΤʔτ࣌ͷσʔλϑΥʔϚοτ) 2. ICE protocol (NATΛ௒͑ͯP2P઀ଓཱ֬ҡ࣋͢ΔͨΊ) -

    STUN - TURN 3. DTLS (௨৴҉߸Խ) 4. SRTP, SCTP (ετϦʔϜଟॏԽɺ᫔᫓੍ޚɺϑϩʔ੍ޚ)
  3. RTCPeerConnection API - RTCPeerConnectionͷͨΊͷAPIࣗମ͸γϯϓϧɹ ͨͩதͰ΍ͬͯΔ͜ͱ͸ ෳࡶ  /"5τϥόʔαϧΛߦ͏*$&ϫʔ Ϋϑϩʔ؅ཧ 

    ϐΞؒͷࣗಈΩʔϓΞϥΠϒ  ϩʔΧϧετϦʔϜͷมԽه࿥  ϦϞʔτετϦʔϜͷมԽه࿥  ετϦʔϜ࠶ωΰγΤʔγϣϯ  ΦϑΝʔੜ੒ɺΞϯαʔडྖ"1*  ݱࡏͷঢ়ଶϦΫΤετ"1*
  4. RTCPeerConnection API 1. SDP (P2PωΰγΤʔτ࣌ͷσʔλϑΥʔϚοτ) 2. ICE protocol (NATΛ௒͑ͯP2P઀ଓཱ֬ҡ࣋͢ΔͨΊ) -

    STUN - TURN 3. DTLS (௨৴҉߸Խ) 4. SRTP, SCTP (ετϦʔϜଟॏԽɺ᫔᫓੍ޚɺϑϩʔ੍ޚ)
  5. SDP

  6. RTCPeerConnection API 1. SDP (P2PωΰγΤʔτ࣌ͷσʔλϑΥʔϚοτ) 2. ICE protocol (NATΛ௒͑ͯP2P઀ଓཱ֬ҡ࣋͢ΔͨΊ) -

    STUN - TURN 3. DTLS (௨৴҉߸Խ) 4. SRTP, SCTP (ετϦʔϜଟॏԽɺ᫔᫓੍ޚɺϑϩʔ੍ޚ)
  7. ICE

  8. RTCPeerConnection API 1. SDP (P2PωΰγΤʔτ࣌ͷσʔλϑΥʔϚοτ) 2. ICE protocol (NATΛ௒͑ͯP2P઀ଓཱ֬ҡ࣋͢ΔͨΊ) -

    STUN - TURN 3. DTLS (௨৴҉߸Խ) 4. SRTP, SCTP (ετϦʔϜଟॏԽɺ᫔᫓੍ޚɺϑϩʔ੍ޚ)
  9. RTCPeerConnection API 1. SDP (P2PωΰγΤʔτ࣌ͷσʔλϑΥʔϚοτ) 2. ICE protocol (NATΛ௒͑ͯP2P઀ଓཱ֬ҡ࣋͢ΔͨΊ) -

    STUN - TURN 3. DTLS (௨৴҉߸Խ) 4. SRTP, SCTP (ετϦʔϜଟॏԽɺ᫔᫓੍ޚɺϑϩʔ੍ޚ)
  10. Μ?

  11. DataChannel var peerConnection = new RTCPeerConnection(); ! var dataChannel =

    peerConnection.createDataChannel("myLabel", dataChannelOptions); ! dataChannel.onopen = function () { dataChannel.send("Hello World!"); }; ! dataChannel.onclose = function () { console.log("The Data Channel is Closed"); }; ! dataChannel.onerror = function (error) { console.log("Data Channel Error:", error); }; ! dataChannel.onmessage = function (event) { console.log("Got Data Channel Message:", event.data); }; !
  12. WebSocket var webSocket = new WebSocket(‘ws://echo.websocket.org/'); ! ! webSocket.onopen =

    function(){ console.log("Connection Opened"); } webSocket.onclose = function(){ console.log("Connection Closed"); } webSocket.onerror = function(evt){ console.log("The following error occurred: " + evt.data); } webSocket.onmessage = function(evt){ console.log("The following data was received:" + evt.data); }
  13. WebSocket var webSocket = new WebSocket(‘ws://echo.websocket.org/'); ! ! webSocket.onopen =

    function(){ console.log("Connection Opened"); } webSocket.onclose = function(){ console.log("Connection Closed"); } webSocket.onerror = function(evt){ console.log("The following error occurred: " + evt.data); } webSocket.onmessage = function(evt){ console.log("The following data was received:" + evt.data); } ΫϦιπ
  14. 456/ /"5 /"5 563/ 4JHOBMJOH4FSWFS /"5Λ௒͑ΔͨΊͷ456/ 563/ɻ *$&"HFOUͰ੾Γ෼͚ΔɺՄೳͩͬ ͨΒΛ5SJDLMF*$&Λ࢖͏ɻ 84

    44&౳ͷ௿ϨΠςϯγͷαʔόʔΛ ࡞Δɻ઀ଓཱ֬ޙ͸%BUB$IBOOFM্Ͱͷ γάφϦϯάΛߦ͏ࣄΛߟྀ͢Δɻ ͪΌΜͱଳҬ෯ʹ஫ҙ͢Δɻ σʔλ͸ͳΔ΂͘খ͘͢͞Δɻ ద੾ͳϝσΟΞ੍ݶΛઃ͚Δɻ %BUB$IBOOFMͷόοϑΝσʔλ͸؂ࢹ͓͖ͯ͠ɺωοτϫʔΫϦϯΫͷঢ়گ ʹదԠͤ͞Δɻ ෦෼త৴པੑͷ͋Δ഑৴ͳΒ࠶ૹΧ΢ϯτͱλΠϜΞ΢τΛద੾ʹઃఆ͢Δɻ
  15. 456/ /"5 /"5 563/ 4JHOBMJOH4FSWFS /"5Λ௒͑ΔͨΊͷ456/ 563/ɻ *$&"HFOUͰ੾Γ෼͚ΔɺՄೳͩͬ ͨΒΛ5SJDLMF*$&Λ࢖͏ɻ 84

    44&౳ͷ௿ϨΠςϯγͷαʔόʔΛ ࡞Δɻ઀ଓཱ֬ޙ͸%BUB$IBOOFM্Ͱͷ γάφϦϯάΛߦ͏ࣄΛߟྀ͢Δɻ ͪΌΜͱଳҬ෯ʹ஫ҙ͢Δɻ σʔλ͸ͳΔ΂͘খ͘͢͞Δɻ ద੾ͳϝσΟΞ੍ݶΛઃ͚Δɻ %BUB$IBOOFMͷόοϑΝσʔλ͸؂ࢹ͓͖ͯ͠ɺωοτϫʔΫϦϯΫͷঢ়گ ʹదԠͤ͞Δɻ ෦෼త৴པੑͷ͋Δ഑৴ͳΒ࠶ૹΧ΢ϯτͱλΠϜΞ΢τΛద੾ʹઃఆ͢Δɻ )BQQZ8FC35$-*'&
  16. ࢀߟจݙ http://www.amazon.co.jp/hpbn/dp/4873116767 ! http://www.html5rocks.com/en/tutorials/webrtc/infrastructure/ ! http://www.html5rocks.com/ja/tutorials/webrtc/datachannels/ ! http://simpl.info/rtcdatachannel/ ! http://www.slideshare.net/iwashi86/20140801-web-rtcmeetup3r3

    ! https://docs.google.com/presentation/d/ 1MkvmX6Gvb1cRATdwF4RFBtol8NgdnblwlwikDnFhT10/present#slide=id.p ! http://html5experts.jp/mganeko/5554/ ! http://iwashi.co/2014/05/13/trickleice/ !