关于linphone手机端开发参考基于linphone android sdk 的voip语音、视频通话 教程一、注册_Java_lilin的专栏-CSDN博客
配置帮助群:261074724
呼叫系统参考https://item.taobao.com/item.htm?id=653611115230
sipjs 官网SIP Signaling JavaScript Library for WebRTC Developers | SIP.js
参考官网说明 写法如下:
<body>
<div id="id_msg"></div>
<input id="id_to" value="10000"/>
<button οnclick="call()">call</button>
<button οnclick="gua()">gua</button>
<br/>
<video id="remoteVideo" style="width:200px;height:400px;"></video>
<video id="localVideo" muted="muted"></video>
<script src="sip-0.13.6.min.js"></script>
<script src="vconsole.min.js"></script>
<script type="text/javascript">
var vConsole = new VConsole();
var config = {
// Replace this IP address with your FreeSWITCH IP address
uri: '10001@xx:9060',
// Replace this IP address with your FreeSWITCH IP address
// and replace the port with your FreeSWITCH ws port
transportOptions: {
wsServers: ['wss://xx:7443']
},
// FreeSWITCH Default Username
authorizationUser: '10001',
// FreeSWITCH Default Password
password: 'test1'
};
var userAgent = new SIP.UA(config);
var remoteVideo = document.getElementById('remoteVideo');
var localVideo = document.getElementById('localVideo');
var sipsession = null;
userAgent.on('registered', function () {
document.getElementById('id_msg').innerText="ok";
});
userAgent.on('invite', function(session) {
var url = session.remoteIdentity.uri.toString()+"--->call";
var isaccept = confirm(url);
if(isaccept)
{
//接受来电
session.accept({
sessionDescriptionHandlerOptions: {
constraints: {
audio: true,
video: true
}
}
});
sipsession = session;
session.on('accepted', function() {//
// We need to check the peer connection to determine which track was added
var pc = session.sessionDescriptionHandler.peerConnection;
console.log(pc);
console.log(pc.getLocalStreams());
// Gets remote tracks
var remoteStream = new MediaStream();
pc.getReceivers().forEach(function(receiver) {
remoteStream.addTrack(receiver.track);
});
remoteVideo.srcObject = remoteStream;
remoteVideo.play();
if(pc.getSenders() ){
var localStream = new MediaStream();
pc.getSenders().forEach(function(sender) {
localStream.addTrack(sender.track);
});
localVideo.srcObject = localStream;
localVideo.play();
}
});
}
else
{
//拒绝来电
session.reject();
}
} );
function gua(){
sipsession.terminate();
}
function call( ){
var to =document.getElementById('id_to').value;
sipsession = userAgent.invite(to+'@xx:7443',{
sessionDescriptionHandlerOptions: {
constraints: {
audio: true, video: true
}
}
});
sipsession.on('accepted', function() {
// We need to check the peer connection to determine which track was added
var pc = sipsession.sessionDescriptionHandler.peerConnection;
// Gets remote tracks
var remoteStream = new MediaStream();
pc.getReceivers().forEach(function(receiver) {
remoteStream.addTrack(receiver.track);261074724
});
remoteVideo.srcObject = remoteStream;
remoteVideo.play();
// Gets local tracks
if(pc.getSenders() ){
var localStream = new MediaStream();
pc.getSenders().forEach(function(sender) {
localStream.addTrack(sender.track);
});
localVideo.srcObject = localStream;
localVideo.play();
}
});
}
</script>
</body>
................
测试结果如下
局域网 | 外网(nat ok) | 音视频 | linphone | 正常接听 | |
pc浏览器 | 支持 | 支持 | 支持 | 支持 | ok |
手机浏览器 | 支持 | 支持 | 支持 | 支持 | ok |
微信网页 | 支持 | 支持 | 支持 | 支持 | ok |
手机端须改动一点地方 可以加群讨论:261074724
测试挺好的这个
/
jssip 官网JsSIP - the Javascript SIP library
页面参考
WebRTC + JsSIP + freeSWITCH一对一视频聊天_安晓辉生涯——聚焦程序员的职业规划与成长-CSDN博客_freeswitch webrtc
经个人测试 jssip 在内网效果很好
在外网配置turn后呼叫有点慢 接通好像有点问题
和linphone集成的交流群 :261074724