()
| 144 | } |
| 145 | |
| 146 | function createPeerConnection() { |
| 147 | connectButton.disabled = true; |
| 148 | hangupButton.disabled = false; |
| 149 | |
| 150 | bytesPrev = 0; |
| 151 | timestampPrev = 0; |
| 152 | pc1 = new RTCPeerConnection(null); |
| 153 | pc2 = new RTCPeerConnection(null); |
| 154 | localStream.getTracks().forEach(track => pc1.addTrack(track, localStream)); |
| 155 | console.log('pc1 creating offer'); |
| 156 | pc1.onnegotiationneeded = () => console.log('Negotiation needed - pc1'); |
| 157 | pc2.onnegotiationneeded = () => console.log('Negotiation needed - pc2'); |
| 158 | pc1.onicecandidate = e => { |
| 159 | console.log('Candidate pc1'); |
| 160 | pc2 |
| 161 | .addIceCandidate(e.candidate) |
| 162 | .then(onAddIceCandidateSuccess, onAddIceCandidateError); |
| 163 | }; |
| 164 | pc2.onicecandidate = e => { |
| 165 | console.log('Candidate pc2'); |
| 166 | pc1 |
| 167 | .addIceCandidate(e.candidate) |
| 168 | .then(onAddIceCandidateSuccess, onAddIceCandidateError); |
| 169 | }; |
| 170 | pc2.ontrack = e => { |
| 171 | if (remoteVideo.srcObject !== e.streams[0]) { |
| 172 | console.log('pc2 got stream'); |
| 173 | remoteVideo.srcObject = e.streams[0]; |
| 174 | } |
| 175 | }; |
| 176 | pc1.createOffer().then( |
| 177 | desc => { |
| 178 | console.log('pc1 offering'); |
| 179 | pc1.setLocalDescription(desc); |
| 180 | pc2.setRemoteDescription(desc); |
| 181 | pc2.createAnswer().then( |
| 182 | desc2 => { |
| 183 | console.log('pc2 answering'); |
| 184 | pc2.setLocalDescription(desc2); |
| 185 | pc1.setRemoteDescription(desc2); |
| 186 | }, |
| 187 | err => console.log(err) |
| 188 | ); |
| 189 | }, |
| 190 | err => console.log(err) |
| 191 | ); |
| 192 | } |
| 193 | |
| 194 | function onAddIceCandidateSuccess() { |
| 195 | console.log('AddIceCandidate success.'); |
nothing calls this directly
no test coverage detected