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

Function call

src/content/capture/canvas-pc/js/main.js:45–79  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

43call();
44
45function 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
81function onCreateSessionDescriptionError(error) {
82 console.log(`Failed to create session description: ${error.toString()}`);

Callers 1

main.jsFile · 0.70

Calls 7

getVideoTracksMethod · 0.80
getAudioTracksMethod · 0.80
getTracksMethod · 0.80
addTrackMethod · 0.80
createOfferMethod · 0.80
onIceCandidateFunction · 0.70
onIceStateChangeFunction · 0.70

Tested by

no test coverage detected