Get started with jssip CDN
Stable version
Copied!
How to start using jssip CDN
// Include the JSSIP library using the CDN link
const script = document.createElement('script');
script.src = 'https://cdn.cdnhub.io/jssip/3.10.1/jssip.min.js';
document.head.appendChild(script);
// Wait for the library to load
window.onJSSIPReady = () => {
const localVideo = document.createElement('video');
localVideo.autoplay = true;
localVideo.muted = true;
document.body.appendChild(localVideo);
const remoteVideo = document.createElement('video');
document.body.appendChild(remoteVideo);
const localPeerConnection = new RTCPeerConnection();
localPeerConnection.onicecandidate = (event) => {
if (event.candidate) {
console.log('Sending ice candidate:', event.candidate);
remotePeerConnection.addIceCandidate(event.candidate);
}
};
localPeerConnection.onaddstream = (event) => {
localVideo.srcObject = event.stream;
};
const remotePeerConnection = new RTCPeerConnection();
remotePeerConnection.onicecandidate = (event) => {
if (event.candidate) {
console.log('Sending ice candidate:', event.candidate);
localPeerConnection.addIceCandidate(event.candidate);
}
};
remotePeerConnection.onaddstream = (event) => {
remoteVideo.srcObject = event.stream;
};
// Create offer and set local description
localPeerConnection.createOffer()
.then((offer) => {
return localPeerConnection.setLocalDescription(offer);
})
.then(() => {
// Set remote description from the provided remote description
const remoteDescription = new RTCSessionDescription({ sdp: 'your_remote_sdp_here' });
return remotePeerConnection.setRemoteDescription(remoteDescription);
})
.then(() => {
// Create answer and set local description
return remotePeerConnection.createAnswer();
})
.then((answer) => {
return remotePeerConnection.setLocalDescription(answer);
})
.then(() => {
// ICE candidates from remote peer
localPeerConnection.onicecandidate = (event) => {
if (event.candidate) {
console.log('Received ice candidate:', event.candidate);
remotePeerConnection.addIceCandidate(event.candidate);
}
};
// Signaling server to exchange offers and answers
// Replace this with your signaling server implementation
const signalingServer = new WebSocket('wss://your_signaling_server_url');
signalingServer.onopen = () => {
console.log('Signaling server connected');
signalingServer.send(JSON.stringify({
type: 'offer',
sdp: localPeerConnection.localDescription,
}));
};
signalingServer.onmessage = (event) => {
const message = JSON.parse(event.data);
switch (message.type) {
case 'answer':
remotePeerConnection.setRemoteDescription(new RTCSessionDescription(message.sdp));
break;
case 'ice':
remotePeerConnection.addIceCandidate(new RTCIceCandidate(message.candidate));
break;
}
};
signalingServer.onclose = () => {
console.log('Signaling server disconnected');
};
})
.catch((error) => {
console.error('Error:', error);
});
};
All versions
0.3.0
0.4.4
0.5.0
0.6.0
0.6.1
0.6.10
0.6.11
0.6.12
0.6.13
0.6.14
0.6.15
0.6.16
0.6.17
0.6.18
0.6.19
0.6.2
0.6.20
0.6.21
0.6.22
0.6.23
0.6.24
0.6.25
0.6.26
0.6.27
0.6.28
0.6.29
0.6.3
0.6.30
0.6.31
0.6.32
0.6.33
0.6.34
0.6.4
0.6.5
0.6.6
0.6.7
0.6.8
0.6.9
0.7.0
0.7.1
0.7.10
0.7.11
0.7.12
0.7.13
0.7.14
0.7.15
0.7.16
0.7.17
0.7.18
0.7.19
0.7.2
0.7.20
0.7.21
0.7.22
0.7.23
0.7.3
0.7.4
0.7.5
0.7.6
0.7.7
0.7.8
0.7.9
1.0.0
1.0.1
2.0.0
2.0.1
2.0.2
2.0.3
2.0.4
2.0.5
2.0.6
3.0.0
3.0.1
3.0.10
3.0.11
3.0.12
3.0.13
3.0.14
3.0.15
3.0.16
3.0.17
3.0.18
3.0.19
3.0.2
3.0.20
3.0.21
3.0.22
3.0.23
3.0.24
3.0.25
3.0.26
3.0.27
3.0.28
3.0.3
3.0.4
3.0.5
3.0.6
3.0.7
3.0.8
3.0.9
3.1.0
3.1.1
3.1.2
3.1.3
3.1.4
3.10.0
*** 3.10.1
3.2.0
3.2.1
3.2.10
3.2.11
3.2.12
3.2.13
3.2.14
3.2.15
3.2.16
3.2.17
3.2.2
3.2.3
3.2.4
3.2.5
3.2.6
3.2.7
3.2.8
3.2.9
3.3.0
3.3.1
3.3.10
3.3.11
3.3.2
3.3.3
3.3.4
3.3.5
3.3.6
3.3.7
3.3.8
3.3.9
3.4.0
3.4.1
3.4.2
3.4.3
3.4.4
3.4.5
3.4.6
3.5.0
3.5.1
3.5.10
3.5.11
3.5.2
3.5.3
3.5.4
3.5.5
3.5.6
3.5.7
3.5.8
3.5.9
3.6.0
3.6.1
3.6.2
3.6.3
3.7.0
3.7.1
3.7.10
3.7.11
3.7.2
3.7.3
3.7.4
3.7.5
3.7.6
3.7.7
3.7.8
3.7.9
3.8.0
3.8.1
3.8.2
3.9.0
3.9.1
3.9.2
3.9.3
3.9.4