I am using sip.js (version 0.13.7)
for making a voice call.
I get media stream & attaching it as follows:
let mediaStream
getMedia() {
if (navigator.getUserMedia) {
navigator.getUserMedia(
{ audio: true, video: false },
function(stream) {
mediaStream = stream
},
function(err) {
console.log('error in getUserMedia: ' + err.name)
}
)
} else {
console.log('getUserMedia not supported')
}
}
handleInvite(session) {
handleMedia(session)
session.accept(mediaStream)
}
handleMedia(session) {
session.on('trackAdded', function() {
var remoteStream = new MediaStream()
var pc = session.sessionDescriptionHandler.peerConnection
pc.getReceivers().forEach(receiver => {
remoteStream.addTrack(receiver.track)
})
incomingAudioEl.srcObject = remoteStream
incomingAudioEl.play()
})
}
It is working well for single call, but I am not able to make multiple simultaneous call, event if I try to call handleInvite()
with new session, there is no audio & only first call is audible.
There is no good documentation about how to do this on sip.js website & many solutions availble online are previous incompatible versions.
When I search for "sip.js multiple calls" on Google, first result comes is https://sipjs.com/guides/reuse-mediastreams/, which is a non existing page.
Note: I was able to make two simultaneous using older sip version, i.e. 0.7.0, but not with the latest.