我正在尝试将sip.js 0.11与FreeSwitch 1.6一起使用,但是在建立呼叫(接受)时它没有音频。进行保留时,音频将起作用。经过测试:Chrome 70和电子3。
APP代码:
USERAGENT
userAgent = new SIP.UA({
uri: user+'@'+url,
transportOptions: {
wsServers: ['wss://' + url],
},
authorizationUser: user,
password: password,
register : true,
});
userAgent.start()
拨打电话
var sessionDescriptionHandlerOptions = {
constraints: {
audio: true,
video: false
}
}
var session = userAgent.invite('sip:'+number+'@freeswitch_server',
sessionDescriptionHandlerOptions);
ATTACH_MEDIA
session.on('trackAdded', function() {
var pc = session.sessionDescriptionHandler.peerConnection;
var remoteStream = new MediaStream();
pc.getReceivers().forEach(function(receiver) {
remoteStream.addTrack(receiver.track);
});
remoteAudio.srcObject = remoteStream;
remoteAudio.play();
var localStream = new MediaStream();
pc.getSenders().forEach(function(sender) {
localStream.addTrack(sender.track);
});
localAudio.srcObject = localStream;
localAudio.play();
});
HTML
<video id="remoteAudio"></video>
<video id="localAudio" muted="muted"></video>
非常感谢!