Created
March 27, 2020 19:49
-
-
Save shriyaRam/3aab4c77a62e2a6c3f03f00328b24eb0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function call() { | |
callButton.disabled = true; | |
hangupButton.disabled = false; | |
console.log('Starting call'); | |
startTime = window.performance.now(); | |
const videoTracks = localStream.getVideoTracks(); | |
const audioTracks = localStream.getAudioTracks(); | |
if (videoTracks.length > 0) { | |
console.log(`Using video device: ${videoTracks[0].label}`); | |
} | |
if (audioTracks.length > 0) { | |
console.log(`Using audio device: ${audioTracks[0].label}`); | |
} | |
const configuration = getSelectedSdpSemantics(); | |
console.log('RTCPeerConnection configuration:', configuration); | |
pc1 = new RTCPeerConnection(configuration); | |
console.log('Created local peer connection object pc1'); | |
pc1.addEventListener('icecandidate', e => onIceCandidate(pc1, e)); | |
pc2 = new RTCPeerConnection(configuration); | |
console.log('Created remote peer connection object pc2'); | |
pc2.addEventListener('icecandidate', e => onIceCandidate(pc2, e)); | |
pc1.addEventListener('iceconnectionstatechange', e => onIceStateChange(pc1, e)); | |
pc2.addEventListener('iceconnectionstatechange', e => onIceStateChange(pc2, e)); | |
pc2.addEventListener('track', gotRemoteStream); | |
pc1.addEventListener('track', gotRemoteStream); | |
localStream.getTracks().forEach(track => {pc1.addTrack(track, localStream);pc2.addTrack(track, localStream);}); | |
console.log('Added local stream to pc1'); | |
try { | |
console.log('pc1 createOffer start'); | |
const offer = await pc1.createOffer(offerOptions); | |
await onCreateOfferSuccess(offer); | |
} catch (e) { | |
onCreateSessionDescriptionError(e); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment