()
| 43 | call(); |
| 44 | |
| 45 | function call() { |
| 46 | console.log('Starting call'); |
| 47 | startTime = window.performance.now(); |
| 48 | const videoTracks = stream.getVideoTracks(); |
| 49 | const audioTracks = stream.getAudioTracks(); |
| 50 | if (videoTracks.length > 0) { |
| 51 | console.log(`Using video device: ${videoTracks[0].label}`); |
| 52 | } |
| 53 | if (audioTracks.length > 0) { |
| 54 | console.log(`Using audio device: ${audioTracks[0].label}`); |
| 55 | } |
| 56 | const servers = null; |
| 57 | pc1 = new RTCPeerConnection(servers); |
| 58 | console.log('Created local peer connection object pc1'); |
| 59 | pc1.onicecandidate = e => onIceCandidate(pc1, e); |
| 60 | pc2 = new RTCPeerConnection(servers); |
| 61 | console.log('Created remote peer connection object pc2'); |
| 62 | pc2.onicecandidate = e => onIceCandidate(pc2, e); |
| 63 | pc1.oniceconnectionstatechange = e => onIceStateChange(pc1, e); |
| 64 | pc2.oniceconnectionstatechange = e => onIceStateChange(pc2, e); |
| 65 | pc2.ontrack = gotRemoteStream; |
| 66 | |
| 67 | stream.getTracks().forEach( |
| 68 | track => { |
| 69 | pc1.addTrack( |
| 70 | track, |
| 71 | stream |
| 72 | ); |
| 73 | } |
| 74 | ); |
| 75 | console.log('Added local stream to pc1'); |
| 76 | |
| 77 | console.log('pc1 createOffer start'); |
| 78 | pc1.createOffer(onCreateOfferSuccess, onCreateSessionDescriptionError); |
| 79 | } |
| 80 | |
| 81 | function onCreateSessionDescriptionError(error) { |
| 82 | console.log(`Failed to create session description: ${error.toString()}`); |
no test coverage detected