Henrik pc = new RTCPeerConnection() Henrik’s Mom Step #2 You, and your mother both create a peer connection object pc = new RTCPeerConnection() Saturday, June 22, 13
Step #3 getUserMedia var localVideo = document.getElementById(‘local’); navigator.getUserMedia( { video: true, audio: true }, function (stream) { peerConnection.addStream(stream); attachMediaStream(localVideoEl, stream); }, function () { console.log("failed to get local media"); } ); Saturday, June 22, 13
Henrik // establish socket.io connection conn = io.connect(“http://sigserver.com”); // identify yourself to the server conn.emit(“id”, “henrik”); Henrik’s Mom Step #4 Signaling Server Signaling Server Saturday, June 22, 13
// create a new peer connection var pc = new RTCPeerConnection(); // tell our browser to describe our session pc.createOffer(function (sessionDescription) { // send it through our socket.io connection conn.emit(“message”, { to: “mom”, type: “offer”, body: sessionDescription }); }); Step #5 Send offer to mom Saturday, June 22, 13
// socket.io handler for incoming message conn.on(“message”, function (msg) { if (msg.type === “answer”) { var desc = new RTCSessionDescription(msg.payload); pc.setRemoteDescription(desc); } }); Step #7 Process mom’s reply Saturday, June 22, 13
Step #7.1 process the ice messages // socket.io handler for incoming message conn.on(“message”, function (msg) { if (msg.type === “ice”) { var candidate = new RTCIceCandidate({ sdpMLineIndex: message.payload.label, candidate: message.payload.candidate }); pc.addIceCandidate(candidate); } }); Saturday, June 22, 13