我正在使用 JsSip 0.7x api 来制作 webrtc 的客户端。使用 chrome 进行测试。使用网关终止 pstn 上的呼叫。使用 index.html 中的音频元素并在事件“addstream”上添加远程流初始注册邀请等消息交换并收到 200 ok。
日志显示已添加远程流但双方都没有音频,甚至没有响铃。媒体流活动:真,结束:假
有人可以提出可能的问题吗
- index.html <audio id='remoteVideo' 控制 autoplay = "autoplay" > 不支持
-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);