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

WebRTC

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on.
Avatar for David David
September 25, 2022

 WebRTC

Avatar for David

David

September 25, 2022
Tweet

More Decks by David

Other Decks in Programming

Transcript

  1. WEBRTC GETUSERMEDIA (MEDIASTREAM) var constraints = {audio: true, video: true};

    navigator.getUserMedia(constraints, function(stream) { video.src = window.URL.createObjectURL(stream); }, errorCallback);
  2. WEBRTC PEERCONNECTION alice = new RTCPeerConnection(null, null) alice.add(stream) alice.createOffer().then(offer =>

    { return alice.setLocalDescription(offer) .then( () => { sendOffer(“bob”, offer); }); }).catch(errorHandler);
  3. WEBRTC PEERCONNECTION bob = new RTCPeerConnection(null, null) bob.setRemoteDescriptor(offer) .then(() =>

    { bob.createAnswer().then((answer) => { return bob.setLocalDescription(answer) .then(() => { sendAnswer(“alice”, answer); }); }).catch(errorHandler);