| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 'use strict'; | 5 'use strict'; |
| 6 | 6 |
| 7 const DESKTOP_MEDIA = ['screen', 'window', 'tab', 'audio']; | 7 const DESKTOP_MEDIA = ['screen', 'window', 'tab', 'audio']; |
| 8 | 8 |
| 9 var pending_request_id = null; | 9 var pending_request_id = null; |
| 10 var pc1 = null; | 10 var pc1 = null; |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 console.log('navigator.webkitGetUserMedia() errot: ', error); | 53 console.log('navigator.webkitGetUserMedia() errot: ', error); |
| 54 } | 54 } |
| 55 | 55 |
| 56 // Capture video/audio of media and initialize RTC communication. | 56 // Capture video/audio of media and initialize RTC communication. |
| 57 function gotStream(stream) { | 57 function gotStream(stream) { |
| 58 console.log('Received local stream', stream); | 58 console.log('Received local stream', stream); |
| 59 var video = document.querySelector('video'); | 59 var video = document.querySelector('video'); |
| 60 video.src = URL.createObjectURL(stream); | 60 video.src = URL.createObjectURL(stream); |
| 61 stream.onended = function() { console.log('Ended'); }; | 61 stream.onended = function() { console.log('Ended'); }; |
| 62 | 62 |
| 63 var servers = null; | 63 pc1 = new RTCPeerConnection(); |
| 64 pc1 = new webkitRTCPeerConnection(servers); | |
| 65 pc1.onicecandidate = function(event) { | 64 pc1.onicecandidate = function(event) { |
| 66 onIceCandidate(pc1, event); | 65 onIceCandidate(pc1, event); |
| 67 }; | 66 }; |
| 68 pc2 = new webkitRTCPeerConnection(servers); | 67 pc2 = new RTCPeerConnection(); |
| 69 pc2.onicecandidate = function(event) { | 68 pc2.onicecandidate = function(event) { |
| 70 onIceCandidate(pc2, event); | 69 onIceCandidate(pc2, event); |
| 71 }; | 70 }; |
| 72 pc1.oniceconnectionstatechange = function(event) { | 71 pc1.oniceconnectionstatechange = function(event) { |
| 73 onIceStateChange(pc1, event); | 72 onIceStateChange(pc1, event); |
| 74 }; | 73 }; |
| 75 pc2.oniceconnectionstatechange = function(event) { | 74 pc2.oniceconnectionstatechange = function(event) { |
| 76 onIceStateChange(pc2, event); | 75 onIceStateChange(pc2, event); |
| 77 }; | 76 }; |
| 78 pc2.onaddstream = gotRemoteStream; | 77 pc2.onaddstream = gotRemoteStream; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 var remotePC = (pc === pc1) ? pc2 : pc1; | 112 var remotePC = (pc === pc1) ? pc2 : pc1; |
| 114 remotePC.addIceCandidate(new RTCIceCandidate(event.candidate)); | 113 remotePC.addIceCandidate(new RTCIceCandidate(event.candidate)); |
| 115 } | 114 } |
| 116 } | 115 } |
| 117 | 116 |
| 118 function onIceStateChange(pc, event) { | 117 function onIceStateChange(pc, event) { |
| 119 if (pc) { | 118 if (pc) { |
| 120 console.log('ICE state change event: ', event); | 119 console.log('ICE state change event: ', event); |
| 121 } | 120 } |
| 122 } | 121 } |
| OLD | NEW |