Thanks for the reply.
var phone;
var session;
if (configuration.uri && configuration.password) {
JsSIP.debug.enable('JsSIP:*'); // more detailed debug output
phone = new JsSIP.UA(configuration);
phone.on('registrationFailed', function (ev) {
alert(`SIP Registering with UserName: ${sipUserName} Password: ${sipUserPassword} on SIP server failed with error: ` + ev.cause);
configuration.uri = null;
configuration.password = null;
updateUI();
});
phone.on('newRTCSession', function (ev) {
var newSession = ev.session;
if (session) { // hangup any existing call
session.terminate();
}
session = newSession;
var completeSession = function () {
session = null;
updateUI();
};
session.on('ended', completeSession);
session.on('failed', completeSession);
session.on('accepted', updateUI);
session.on('confirmed', function () {
var localStream = session.connection.getLocalStreams()[0];
var dtmfSender = session.connection.createDTMFSender(localStream.getAudioTracks()[0])
session.sendDTMF = function (tone) {
dtmfSender.insertDTMF(tone);
};
updateUI();
});
session.on('peerconnection', (e) => {
console.log('peerconnection', e);
let logError = '';
const peerconnection = e.peerconnection;
peerconnection.onaddstream = function (e) {
console.log('addstream', e);
// set remote audio stream (to listen to remote audio)
remoteAudio.srcObject = e.stream;
remoteAudio.play();
};
var remoteStream = new MediaStream();
console.log(peerconnection.getReceivers());
peerconnection.getReceivers().forEach(function (receiver) {
console.log(receiver);
remoteStream.addTrack(receiver.track);
});
});
if (session.direction === 'incoming') {
//incomingCallAudio.play();
if ($('#dndSwitch').is(':checked') == false) {
document.getElementById('incommingCallAudio').play();
}
} else {
console.log('con', session.connection)
session.connection.addEventListener('addstream', function (e) {
//incomingCallAudio.pause();
remoteAudio.srcObject = e.stream;
if ($('#dndSwitch').is(':checked') == false) {
document.getElementById('incommingCallAudio').pause();
}
});
}
updateUI();
});
phone.start();
}
This code is working fine on audio call with 2 persons.
From last 2 weeks, we tried many ways but didn't work and we are stuck on it.
Thanks in advance.