When using SIP.js in Node.js, mobile apps, or other platforms, you can define a custom
Session Description Handler using the UA’s sessionDescriptionHandlerFactory configuration parameter.
The API documentation seems quite up to date. The "Guides" section on the other hand is very much out of date, it still reflects the 0.7.x API concerning media handling:
https://sipjs.com/guides/make-call/
I'm of two minds as to how to update this. The "easiest" option (as in: fewer lines of documentation) would be to replace this by documentation on how to use the SIP.Simple API, but if we do that there will be absolutely no documentation on how to get the full SIP.UA to make calls.
Jeremy
example config object:
var config = {
userAgentString: 'SIP.js/0.9.*',
traceSip: true,
register: true,
uri: "websi...@your-sip.domain.org",
password: "examplepassword",
hackViaTcp: true,
rel100: SIP.C.supported.SUPPORTED,
wsServers: "wss://your-wsSip-server:443",
sessionDescriptionHandlerFactoryOptions:{
peerConnectionOptions: {
rtcConfiguration:{
iceServers:
[
{ urls:"stun:stun.l.google.com:19302" },
{
urls:"turn:turn-ip:443?transport=tcp",
username:"turnuser",
credential:"turnpass"
}
]
}
}
}
}
//create Uaser Agent object and register
ua = new SIP.UA(config)
ua.on('connected', function () {
ua.register()
})
// Send invite
session = ua.invite(uri, {
sessionDescriptionHandlerOptions: {
constraints: {
audio: true,
video: video
}
}
});
and later you have to listen to addStream from sessionDescriptionHandler wich is not available at once after session init but later:
session.on('progress', function () {
session.sessionDescriptionHandler.on('addStream', function () {
var pc = session.sessionDescriptionHandler.peerConnection
var remoteStream = new MediaStream()
pc.getReceivers().forEach(function(receiver) {
var track = receiver.track
if (track) {
remoteStream.addTrack(track)
}
})
video.srcObject = remoteStream // video is your html-video element for viewing remote stream
video.autoplay = true
})
})
Stefan
I am new to SIP.JS and had gotten a bit lost using various examples from different versions of the API. However, using the above I have managed to get outbound calls working with Asterisk and a WEBRTC client using SIPJS 0.9.2 and audio going both ways.
I am now trying to sort out inbound calls through the same Asterisk setup to the same webrtc client. The call is set up but I get no audio either way. I know it is related to the SessionDescriptionHandler setup as well - is there any example that would show how to set up the sessiondescriptionhandler for an inbound call.
Thanks in advance.
John.
Hi John, any updates concerning this topic? I have the similar question.
Secondly, in Firefox Quantum 61.0b4 (64-bit) I have to prepare media and attach it to the DOM elements. I brought the code here https://pastebin.com/YRpwNYmc, as you can see this code completely the same as here https://sipjs.com/guides/attach-media/ and in this case, I have one way audio (from the remote peer sound goes to the browser well but in opposite way, it doesn't working).
And code which I have shown above absolutely doesn't affect chrome functionality (it works)
How I have to set up media sources properly in different browsers.
My journey with WebRTC/SIPJS and Asterisk is described in this post as well.
https://groups.google.com/forum/#!topic/sip_js/W_ZTmpIeTbQ
In the end my big problem was an issue with Asterisk and how it decided which of the two endpoints was ICE-CONTROLLING/CONTROLLED. I wrote up what I found on this as well.
If any of this is relevant to you - let me know and I will try to help.
Best Regards,
John