MCPcopy
hub / github.com/webrtc/samples / call

Function call

src/content/peerconnection/multiple/js/main.js:58–88  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

56}
57
58async 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
90async function negotiate(localPc, remotePc) {
91 localPc.onicecandidate = e => remotePc.addIceCandidate(e.candidate);

Callers

nothing calls this directly

Calls 6

negotiateFunction · 0.85
getAudioTracksMethod · 0.80
getVideoTracksMethod · 0.80
getTracksMethod · 0.80
addTrackMethod · 0.80
gotRemoteStreamFunction · 0.70

Tested by

no test coverage detected