Skip to content

Instantly share code, notes, and snippets.

@shriyaRam
Created March 27, 2020 20:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shriyaRam/b5f3a2b8f06369c5450a68ab11b10d12 to your computer and use it in GitHub Desktop.
Save shriyaRam/b5f3a2b8f06369c5450a68ab11b10d12 to your computer and use it in GitHub Desktop.
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');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment