()
| 180 | } |
| 181 | |
| 182 | async function call() { |
| 183 | callButton.disabled = true; |
| 184 | hangupButton.disabled = false; |
| 185 | console.log('Starting call'); |
| 186 | startTime = window.performance.now(); |
| 187 | const videoTracks = localStream.getVideoTracks(); |
| 188 | const audioTracks = localStream.getAudioTracks(); |
| 189 | if (videoTracks.length > 0) { |
| 190 | console.log(`Using video device: ${videoTracks[0].label}`); |
| 191 | } |
| 192 | if (audioTracks.length > 0) { |
| 193 | console.log(`Using audio device: ${audioTracks[0].label}`); |
| 194 | } |
| 195 | const configuration = {}; |
| 196 | console.log('RTCPeerConnection configuration:', configuration); |
| 197 | pc1 = new RTCPeerConnection(configuration); |
| 198 | console.log('Created local peer connection object pc1'); |
| 199 | pc1.addEventListener('icecandidate', e => onIceCandidate(pc1, e)); |
| 200 | pc2 = new RTCPeerConnection(configuration); |
| 201 | console.log('Created remote peer connection object pc2'); |
| 202 | pc2.addEventListener('icecandidate', e => onIceCandidate(pc2, e)); |
| 203 | pc2.addEventListener('track', gotRemoteStream); |
| 204 | const mode = scalabilityMode.value; |
| 205 | localStream.getTracks().forEach((track) =>{ |
| 206 | if (track.kind == 'video' && mode) { |
| 207 | pc1.addTransceiver(track, { |
| 208 | streams: [localStream], |
| 209 | sendEncodings: [ |
| 210 | {scalabilityMode: mode} |
| 211 | ] |
| 212 | }); |
| 213 | } else { |
| 214 | pc1.addTrack(track, localStream); |
| 215 | } |
| 216 | }); |
| 217 | console.log('Added local stream to pc1'); |
| 218 | codecPreferences.disabled = true; |
| 219 | scalabilityMode.disabled = true; |
| 220 | |
| 221 | try { |
| 222 | console.log('pc1 createOffer start'); |
| 223 | const offer = await pc1.createOffer(offerOptions); |
| 224 | await onCreateOfferSuccess(offer); |
| 225 | } catch (e) { |
| 226 | onCreateSessionDescriptionError(e); |
| 227 | } |
| 228 | } |
| 229 | |
| 230 | function onCreateSessionDescriptionError(error) { |
| 231 | console.log(`Failed to create session description: ${error.toString()}`); |
nothing calls this directly
no test coverage detected