Webrtc Client, использующий Jssip - Нет звука в обоих направлениях, используя Free switch и chrome
Я использую JsSip 0.7x API для создания клиентской части webrtc. Использовал хром для тестирования. Завершение вызова на PSTN с использованием шлюза. Использование аудиоэлемента в index.html и добавление удаленного потока по событию "addstream". Начальный регистр Приглашение и т. Д. Обмен сообщениями и получение 200 ok
Журнал показывает, что удаленный поток был добавлен, но нет звука с обеих сторон, даже не звонит. медиапоток активен: истина
Может кто-нибудь предложить возможные проблемы
- index.html
-testjssip.js
var localStream, remoteStream = null;
var remoteVideo = document.getElementById('remoteVideo');
var ua, session = null;
var eventHandlers;
var configuration = {
'ws_servers': '******',
'uri': '******',
'password': '*****'
};
// Register callbacks to desired call events
eventHandlers = {
'peerconnection': function (e) {
console.trace("fired for outgoing calls but before sdp generation in peerconnection ");
},
'connecting': function (e) {
},
'progress': function (e) {
console.trace('call is in progress', e);
},
'failed': function (e) {
console.trace('call failed with cause: ', e);
},
'ended': function (e) {
console.trace('call ended with cause: ', e);
},
'confirmed': function (e) {
},
'accepted': function (e) {
console.trace(" call accepted ");
},
'addstream': function (e) {
if(session.connection.getRemoteStreams().length > 0)
{
console.trace('remote stream added ' +e.stream.getAudioTracks().length);
console.trace('remote stream added ' + e.stream.getTracks());
remoteVideo = JsSIP.rtcninja.attachMediaStream(remoteVideo,e.stream);
}
}
};
var options = {
'eventHandlers': eventHandlers,
'extraHeaders': ['X-Foo: foo', 'X-Bar: bar'],
'mediaConstraints': {'audio': true, 'video':false},
'rtcOfferConstraints' : {'offerToReceiveAudio' : true } ,
mandatory: [{
OfferToReceiveAudio: true,
OfferToReceiveVideo: false
},{'DtlsSrtpKeyAgreement': true} ]
};
init();
function init() {
console.trace("intializing user agent");
ua = new JsSIP.UA(configuration);
ua.start();
console.trace("is registered : " + ua.isRegistered());
uaEventHandling();
}
;
function uaEventHandling() {
//events of UA class with their callbacks
ua.on('registered', function (e) {
console.trace("registered", e);
});
ua.on('unregistered', function (e) {
console.trace("ua has been unregistered periodic registeration fails or ua.unregister()", e);
});
ua.on('registrationFailed', function (e) {
console.trace("register failed", e);
});
ua.on('connected', function (e) {
console.trace("connected to websocket");
});
ua.on('disconnected', function (e) {
console.trace("disconnected");
ua.stop();
});
ua.on('newRTCSession', function (e) {
console.trace('new rtc session created - incoming or outgoing call');
session = e.session;
if (e.originator === 'local') {
console.trace(e.request + ' outgoing session');
}
else {
console.trace(e.request + ' incoming session answering a call');
e.session.answer(options);
}
});
ua.on('newMessage', function (e) {
if (e.originator === 'local')
console.trace(' outgoing MESSAGE request ', e);
else
console.trace(' incoming MESSAGE request ', e);
});
};
ua.call('sip:********', options);
0 ответов
Я только что решил ту же проблему. Чтобы добавить поток к аудио элементу, я нашел решение:
var phone = new JsSIP.UA(config);
var session = phone.call(contact, options);
if (session) {
session.connection.addEventListener(''addstream', (e) => {
var audio = document.createElement('audio');
audio.srcObject = e.stream;
audio.play();
});
}
Я не смог бы отблагодарить вас достаточно. Я несколько дней ломал голову, что за история с односторонним звуком. Я чувствовал, что должно быть что-то не так, что JsSIP нигде не спрашивает, где играть? Ниже код, который я добавил:
//This untouched, only so you can easily locate where to add the code:
key: "_createRTCConnection",
value: function _createRTCConnection(pcConfig, rtcConstraints) {
var _this12 = this;
this._connection = new RTCPeerConnection(pcConfig, rtcConstraints);
/*THIS IS MINE*/
this._connection.onaddstream = function(e) {
var oA = document.getElementById("audio_remote")
oA.srcObject = e.stream;
oA.play()}
/*THIS IS MINE*/
Чтобы ответить на ваш вопрос, вы должны добавить это после ответа или посылки вызова. Этот пример предназначен для ответа на входящий звонок:
sipSession.answer({
mediaConstraints: {audio: true, video: false}
});
sipSession.connection.onaddstream = (e) => {
var audio:any = document.getElementById('audio_remote');
audio.srcObject = e.stream;
audio.play();
};