()
| 56 | } |
| 57 | |
| 58 | async function call() { |
| 59 | callButton.disabled = true; |
| 60 | hangupButton.disabled = false; |
| 61 | console.log('Starting calls'); |
| 62 | const audioTracks = localStream.getAudioTracks(); |
| 63 | const videoTracks = localStream.getVideoTracks(); |
| 64 | if (audioTracks.length > 0) { |
| 65 | console.log(`Using audio device: ${audioTracks[0].label}`); |
| 66 | } |
| 67 | if (videoTracks.length > 0) { |
| 68 | console.log(`Using video device: ${videoTracks[0].label}`); |
| 69 | } |
| 70 | // Create an RTCPeerConnection via the polyfill. |
| 71 | pc1Local = new RTCPeerConnection(); |
| 72 | pc1Remote = new RTCPeerConnection(); |
| 73 | pc1Remote.ontrack = e => gotRemoteStream(e, video2); |
| 74 | console.log('pc1: created local and remote peer connection objects'); |
| 75 | |
| 76 | pc2Local = new RTCPeerConnection(); |
| 77 | pc2Remote = new RTCPeerConnection(); |
| 78 | pc2Remote.ontrack = e => gotRemoteStream(e, video3); |
| 79 | console.log('pc2: created local and remote peer connection objects'); |
| 80 | localStream.getTracks().forEach(track => { |
| 81 | pc1Local.addTrack(track, localStream); |
| 82 | pc2Local.addTrack(track, localStream); |
| 83 | }); |
| 84 | await Promise.all([ |
| 85 | negotiate(pc1Local, pc1Remote), |
| 86 | negotiate(pc2Local, pc2Remote), |
| 87 | ]); |
| 88 | } |
| 89 | |
| 90 | async function negotiate(localPc, remotePc) { |
| 91 | localPc.onicecandidate = e => remotePc.addIceCandidate(e.candidate); |
nothing calls this directly
no test coverage detected