类型:开发
描述:
This commit is contained in:
48
package-lock.json
generated
48
package-lock.json
generated
@@ -13,6 +13,7 @@
|
|||||||
"echarts-wordcloud": "^2.0.0",
|
"echarts-wordcloud": "^2.0.0",
|
||||||
"element-plus": "^2.9.0",
|
"element-plus": "^2.9.0",
|
||||||
"hls.js": "^1.5.18",
|
"hls.js": "^1.5.18",
|
||||||
|
"jssip": "^3.10.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pinia": "^2.2.6",
|
"pinia": "^2.2.6",
|
||||||
"pinia-plugin-persistedstate": "^4.2.0",
|
"pinia-plugin-persistedstate": "^4.2.0",
|
||||||
@@ -1880,6 +1881,15 @@
|
|||||||
"url": "https://github.com/sponsors/sindresorhus"
|
"url": "https://github.com/sponsors/sindresorhus"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/debug": {
|
||||||
|
"version": "4.1.12",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@types/debug/-/debug-4.1.12.tgz",
|
||||||
|
"integrity": "sha512-vIChWdVG3LG1SMxEvI/AK+FWJthlrqlTu7fbrlywTkkaONwk/UAGaULXRlf8vkzFBLVm0zkMdCquhL5aOjhXPQ==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/ms": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@types/eslint": {
|
"node_modules/@types/eslint": {
|
||||||
"version": "9.6.1",
|
"version": "9.6.1",
|
||||||
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz",
|
"resolved": "https://registry.npmjs.org/@types/eslint/-/eslint-9.6.1.tgz",
|
||||||
@@ -1910,6 +1920,12 @@
|
|||||||
"integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==",
|
"integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/events": {
|
||||||
|
"version": "3.0.3",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@types/events/-/events-3.0.3.tgz",
|
||||||
|
"integrity": "sha512-trOc4AAUThEz9hapPtSd7wf5tiQKvTtu5b371UxXdTuqzIh0ArcRspRP0i0Viu+LXstIQ1z96t1nsPxT9ol01g==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/json-schema": {
|
"node_modules/@types/json-schema": {
|
||||||
"version": "7.0.15",
|
"version": "7.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||||
@@ -1932,6 +1948,12 @@
|
|||||||
"@types/lodash": "*"
|
"@types/lodash": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/@types/ms": {
|
||||||
|
"version": "2.1.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/@types/ms/-/ms-2.1.0.tgz",
|
||||||
|
"integrity": "sha512-GsCCIZDE/p3i96vtEqx+7dBUGXrc7zeSK3wwPHIaRThS+9OhWIXRqzs4d6k1SVU8g91DrNRWxWUGhp5KXQb2VA==",
|
||||||
|
"license": "MIT"
|
||||||
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "22.13.10",
|
"version": "22.13.10",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.10.tgz",
|
||||||
@@ -2897,7 +2919,6 @@
|
|||||||
"version": "4.4.0",
|
"version": "4.4.0",
|
||||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
|
"resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz",
|
||||||
"integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
|
"integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ms": "^2.1.3"
|
"ms": "^2.1.3"
|
||||||
@@ -3309,9 +3330,7 @@
|
|||||||
"version": "3.3.0",
|
"version": "3.3.0",
|
||||||
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
|
"resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz",
|
||||||
"integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
|
"integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"peer": true,
|
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=0.8.x"
|
"node": ">=0.8.x"
|
||||||
}
|
}
|
||||||
@@ -3996,6 +4015,19 @@
|
|||||||
"graceful-fs": "^4.1.6"
|
"graceful-fs": "^4.1.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/jssip": {
|
||||||
|
"version": "3.10.1",
|
||||||
|
"resolved": "https://registry.npmmirror.com/jssip/-/jssip-3.10.1.tgz",
|
||||||
|
"integrity": "sha512-V82JW6fZF02VInHMKgTO9oEXbkZwqezGj9SNaQPh+btriC16FfSPsRBnD+i9IhU9C86JA9le6Z8AZirYnbKi2g==",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@types/debug": "^4.1.7",
|
||||||
|
"@types/events": "^3.0.0",
|
||||||
|
"debug": "^4.3.1",
|
||||||
|
"events": "^3.3.0",
|
||||||
|
"sdp-transform": "^2.14.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/kind-of": {
|
"node_modules/kind-of": {
|
||||||
"version": "6.0.3",
|
"version": "6.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
|
||||||
@@ -4253,7 +4285,6 @@
|
|||||||
"version": "2.1.3",
|
"version": "2.1.3",
|
||||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||||
"dev": true,
|
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/nanoid": {
|
"node_modules/nanoid": {
|
||||||
@@ -4868,6 +4899,15 @@
|
|||||||
"integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==",
|
"integrity": "sha512-6FtHJEvt+pVMIB9IBY+IcCJ6Z5f1iQnytgyfKMhDKgmzYG+TeH/wx1y3l27rshSbLiSanrR9ffZDrEsmjlQF2g==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
|
"node_modules/sdp-transform": {
|
||||||
|
"version": "2.15.0",
|
||||||
|
"resolved": "https://registry.npmmirror.com/sdp-transform/-/sdp-transform-2.15.0.tgz",
|
||||||
|
"integrity": "sha512-KrOH82c/W+GYQ0LHqtr3caRpM3ITglq3ljGUIb8LTki7ByacJZ9z+piSGiwZDsRyhQbYBOBJgr2k6X4BZXi3Kw==",
|
||||||
|
"license": "MIT",
|
||||||
|
"bin": {
|
||||||
|
"sdp-verify": "checker.js"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "6.3.1",
|
"version": "6.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz",
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
"echarts-wordcloud": "^2.0.0",
|
"echarts-wordcloud": "^2.0.0",
|
||||||
"element-plus": "^2.9.0",
|
"element-plus": "^2.9.0",
|
||||||
"hls.js": "^1.5.18",
|
"hls.js": "^1.5.18",
|
||||||
|
"jssip": "^3.10.1",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pinia": "^2.2.6",
|
"pinia": "^2.2.6",
|
||||||
"pinia-plugin-persistedstate": "^4.2.0",
|
"pinia-plugin-persistedstate": "^4.2.0",
|
||||||
|
|||||||
1
src/assets/com/jssip.js
Normal file
1
src/assets/com/jssip.js
Normal file
File diff suppressed because one or more lines are too long
592
src/assets/com/webrtc.js
Normal file
592
src/assets/com/webrtc.js
Normal file
@@ -0,0 +1,592 @@
|
|||||||
|
import JsSIP from 'jssip';
|
||||||
|
export default class MyWebrtc {
|
||||||
|
constructor() {
|
||||||
|
var MediaStreamTrack = null;
|
||||||
|
var peerconnection = null;
|
||||||
|
var outgoingSession = null;
|
||||||
|
var incomingSession = null;
|
||||||
|
var currentSession = null;
|
||||||
|
var getJsSipgetIp = null; //存取全局IP
|
||||||
|
var getJsSipPhoneNumber = null; //存取全局号码
|
||||||
|
var getJsSipgetPassWord = null; //存取全局密码
|
||||||
|
var getstatus1 = null;
|
||||||
|
var getstatus2 = null;
|
||||||
|
var globalRegisteState = '未注册';//注册状态
|
||||||
|
var globalCallPhoneStates = "未通话";//通话状态
|
||||||
|
var judgeIsVoice = "";//判断是语音拨打还是视频拨打
|
||||||
|
var Datas = null;
|
||||||
|
var useVideo = true;
|
||||||
|
var selfViewWap = document.getElementById('selfViewWap');
|
||||||
|
URL = window.URL || window.webkitURL;
|
||||||
|
var localStream = null;
|
||||||
|
var userAgent = null;
|
||||||
|
var autoAnswerFlag = false;//是否自动接听
|
||||||
|
var holdFlag = false;
|
||||||
|
|
||||||
|
var session;
|
||||||
|
var incomingCallAudio = new window.Audio('./static/incoming-call-ringtone.wav');
|
||||||
|
var ringbackAudio = new window.Audio('./static/ringbacktone.wav');
|
||||||
|
incomingCallAudio.loop = true;
|
||||||
|
ringbackAudio.loop = true;
|
||||||
|
var remoteAudio = new window.Audio();
|
||||||
|
remoteAudio.autoplay = true;
|
||||||
|
|
||||||
|
var meVideo;
|
||||||
|
var youVideo;
|
||||||
|
|
||||||
|
var constraints = {
|
||||||
|
audio: true,
|
||||||
|
video: false
|
||||||
|
};
|
||||||
|
|
||||||
|
if(useVideo){
|
||||||
|
constraints = {
|
||||||
|
audio: true,
|
||||||
|
video: true
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//jssip实例初始化
|
||||||
|
this.jssipAgent = function(JsSipPhoneNumber, JsSipgetIp, JsSipgetPort, JsSipgetPassWord, remoteVideo, Registerstate, Callstate) {
|
||||||
|
getJsSipPhoneNumber = JsSipPhoneNumber;
|
||||||
|
getJsSipgetIp = JsSipgetIp;
|
||||||
|
getJsSipgetPassWord = JsSipgetPassWord;
|
||||||
|
getstatus1 = Registerstate;
|
||||||
|
getstatus2 = Callstate;
|
||||||
|
var phoneNumber = JsSipPhoneNumber + "@";
|
||||||
|
var getIp = JsSipgetIp;
|
||||||
|
getJsSipgetIp = JsSipgetIp;
|
||||||
|
// var lastPort = ":5060"
|
||||||
|
//var sip_uri_ = (phoneNumber + getIp + lastPort).toString();
|
||||||
|
var sip_uri_ = ("sip:"+phoneNumber + getIp).toString();
|
||||||
|
console.log(sip_uri_);
|
||||||
|
// var ws_uri_ = "ws://10.0.11.120:5066";
|
||||||
|
var _Ws = "ws://";
|
||||||
|
var _WsPort = ":"+JsSipgetPort;
|
||||||
|
var ws_uri_ = (_Ws + getIp + _WsPort).toString();
|
||||||
|
console.log(ws_uri_);
|
||||||
|
//var sip_password_ = document.getElementById('JsSipgetPassWord').value;
|
||||||
|
var sip_password_ = JsSipgetPassWord;
|
||||||
|
// var sip_password_ = "1234";
|
||||||
|
JsSIP.C.SESSION_EXPIRES=120,JsSIP.C.MIN_SESSION_EXPIRES=120;
|
||||||
|
var socket = new JsSIP.WebSocketInterface(ws_uri_);
|
||||||
|
var configuration = {
|
||||||
|
sockets: [socket],
|
||||||
|
uri: sip_uri_,
|
||||||
|
register: true,
|
||||||
|
password: sip_password_,
|
||||||
|
contact_uri: sip_uri_ + ';transport=wss',
|
||||||
|
ws_servers: ws_uri_
|
||||||
|
//session_timers: false
|
||||||
|
};
|
||||||
|
|
||||||
|
userAgent = new JsSIP.UA(configuration);
|
||||||
|
incomingCallAudio.play();
|
||||||
|
incomingCallAudio.pause();
|
||||||
|
ringbackAudio.play();
|
||||||
|
ringbackAudio.pause();
|
||||||
|
|
||||||
|
userAgent.on('registered', function(data) {
|
||||||
|
//console.log(data);
|
||||||
|
console.info("registered: ", data.response.status_code, ",", data.response.reason_phrase);
|
||||||
|
});
|
||||||
|
//未注册
|
||||||
|
userAgent.on('unregistered', function(e) {
|
||||||
|
console.log("未注册", e);
|
||||||
|
});
|
||||||
|
userAgent.on('registrationFailed', function(data) {
|
||||||
|
console.log("registrationFailed, ", data);
|
||||||
|
});
|
||||||
|
//1.在注册到期之前发射几秒钟。如果应用程序没有为这个事件设置任何监听器,JsSIP将像往常一样重新注册。
|
||||||
|
userAgent.on('registrationExpiring', function() {
|
||||||
|
|
||||||
|
//过期之后将自动重新注册
|
||||||
|
console.warn("registrationExpiring");
|
||||||
|
//重新注册
|
||||||
|
userAgent.register();
|
||||||
|
//jssipAgent(JsSipPhoneNumber,JsSipgetIp,JsSipgetPassWord,remoteVideo,status1,status2);
|
||||||
|
});
|
||||||
|
//为传入或传出的会话/呼叫
|
||||||
|
userAgent.on('newRTCSession', function(data) {
|
||||||
|
console.info('onNewRTCSession: ', data);
|
||||||
|
if(data.originator == 'remote') { //incoming call
|
||||||
|
|
||||||
|
if(globalCallPhoneStates == "连接中" || globalCallPhoneStates == "通话中" || globalCallPhoneStates.indexOf("来电")>-1){
|
||||||
|
var options2 = {
|
||||||
|
all: false,
|
||||||
|
'status_code':486
|
||||||
|
};
|
||||||
|
data.session.terminate(options2);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
autoAnswerFlag = document.getElementById('autoAnswerFlag').checked;
|
||||||
|
console.info("incomingSession, answer the call");
|
||||||
|
incomingSession = data.session;
|
||||||
|
Datas = data.session;
|
||||||
|
var incomingNum = data.request.headers.From[0].raw;
|
||||||
|
if(incomingNum.indexOf("sip:")>0){
|
||||||
|
incomingNum = incomingNum.substring(incomingNum.indexOf("sip:")+4);
|
||||||
|
incomingNum = incomingNum.substring(0,incomingNum.indexOf("@"));
|
||||||
|
}
|
||||||
|
|
||||||
|
globalCallPhoneStates = incomingNum+"来电";
|
||||||
|
|
||||||
|
if(useVideo){
|
||||||
|
initVideo();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(autoAnswerFlag){//自动接听
|
||||||
|
incomingCallAudio.pause();
|
||||||
|
|
||||||
|
if(useVideo){
|
||||||
|
Datas.answer({
|
||||||
|
'mediaConstraints': {
|
||||||
|
'audio': true,
|
||||||
|
"video": true
|
||||||
|
},
|
||||||
|
'mediaStream': null
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
Datas.answer({
|
||||||
|
'mediaConstraints': {
|
||||||
|
'audio': true,
|
||||||
|
"video": false
|
||||||
|
},
|
||||||
|
'mediaStream': null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
getstatus2.innerText = "通话中";
|
||||||
|
globalCallPhoneStates = "通话中";
|
||||||
|
|
||||||
|
Datas.connection.ontrack = getRemoteStream;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
peerconnection = data.session.connection;
|
||||||
|
peerconnection.ontrack = getRemoteStream;
|
||||||
|
|
||||||
|
if(useVideo){
|
||||||
|
initVideo();
|
||||||
|
}
|
||||||
|
|
||||||
|
//peerconnection.addEventListener('addstream', function(ev) {
|
||||||
|
// ringbackAudio.pause();
|
||||||
|
// console.info('onaddstream from remote - ', ev);
|
||||||
|
// remoteAudio.srcObject = ev.stream;
|
||||||
|
//});
|
||||||
|
|
||||||
|
console.info("outgoingSession");
|
||||||
|
outgoingSession = data.session;
|
||||||
|
outgoingSession.on('connecting', function(data) {
|
||||||
|
//通话状态
|
||||||
|
// Callstate.innerText = "连接中";
|
||||||
|
// globalCallPhoneStates = "连接中";
|
||||||
|
console.info('onConnecting - ', data.request);
|
||||||
|
currentSession = outgoingSession;
|
||||||
|
outgoingSession = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
//远程挂断事件
|
||||||
|
data.session.on("ended", function(data) {
|
||||||
|
|
||||||
|
console.log("call end", data);
|
||||||
|
//通话状态
|
||||||
|
var call_id = "";
|
||||||
|
if(data.message!=null && data.message.call_id!=null){
|
||||||
|
call_id = data.message.call_id;
|
||||||
|
}else if(currentSession!=null && currentSession._request.call_id!=null){
|
||||||
|
call_id = currentSession._request.call_id;
|
||||||
|
}
|
||||||
|
doEvent("hangup_event",'',call_id);
|
||||||
|
//Callstate.innerText = "已挂断";
|
||||||
|
globalCallPhoneStates = "已挂断";
|
||||||
|
|
||||||
|
clearVideo();
|
||||||
|
currentSession = null;
|
||||||
|
});
|
||||||
|
data.session.on('accepted', function(data) {
|
||||||
|
console.info('onAccepted - ', data);
|
||||||
|
var call_id = "";
|
||||||
|
if(data!=null && data.request!=null && data.request.call_id!=null){
|
||||||
|
call_id = data.request.call_id;
|
||||||
|
}else if(data!=null && data.response!=null && data.response.call_id!=null){
|
||||||
|
call_id = data.response.call_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(data.originator == 'remote' && currentSession == null) {
|
||||||
|
currentSession = incomingSession;
|
||||||
|
incomingSession = null;
|
||||||
|
// console.info("setCurrentSession - ", currentSession);
|
||||||
|
// //通话状态
|
||||||
|
// doEvent("answer_event",'',call_id);
|
||||||
|
//getstatus2.innerText = "通话中 00:00";
|
||||||
|
globalCallPhoneStates = "通话中 00:00";
|
||||||
|
}else if(currentSession != null){
|
||||||
|
// doEvent("answer_event",'',call_id);
|
||||||
|
//getstatus2.innerText = "通话中 00:00";
|
||||||
|
globalCallPhoneStates = "通话中";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
data.session.on('confirmed', function(data) {
|
||||||
|
console.info('onConfirmed - ', data);
|
||||||
|
|
||||||
|
if(data.originator == 'remote' && currentSession == null) {
|
||||||
|
currentSession = incomingSession;
|
||||||
|
incomingSession = null;
|
||||||
|
console.info("setCurrentSession - ", currentSession);
|
||||||
|
//通话状态
|
||||||
|
// doEvent("answer_event",'',data.ack.call_id);
|
||||||
|
//getstatus2.innerText = "通话中";
|
||||||
|
globalCallPhoneStates = "通话中";
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
data.session.on('sdp', function(data) {
|
||||||
|
console.info('onSDP, type - ', data.type, ' sdp - ', data.sdp);
|
||||||
|
if(data.type=="answer" && currentSession != null){
|
||||||
|
var holdOption = currentSession.isOnHold();
|
||||||
|
if(holdOption.local){
|
||||||
|
holdFlag = true;
|
||||||
|
doEvent("hold_event",'',data.request.call_id);
|
||||||
|
}else if(holdFlag){;
|
||||||
|
holdFlag = false;
|
||||||
|
doEvent("unhold_event",'',data.request.call_id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
var changeSDP="";
|
||||||
|
var snsArr = data.sdp.split(/[(\r\n)\r\n]+/);
|
||||||
|
var videoCodec = false;
|
||||||
|
var rtpmap = false;
|
||||||
|
snsArr.forEach((item,index)=>{
|
||||||
|
console.info("index[",index,"]",snsArr[index]);
|
||||||
|
var str = snsArr[index];
|
||||||
|
if(str.indexOf("m=video ")>-1){
|
||||||
|
videoCodec = true;
|
||||||
|
}
|
||||||
|
if(videoCodec){
|
||||||
|
if(str.indexOf("a=rtpmap:")>-1){
|
||||||
|
rtpmap = true;
|
||||||
|
}
|
||||||
|
if(str.indexOf("m=video ")>-1 && str.indexOf("UDP/TLS/RTP/SAVPF")>-1){
|
||||||
|
str = str.substring(0,str.indexOf("UDP/TLS/RTP/SAVPF"))+" UDP/TLS/RTP/SAVPF 102";
|
||||||
|
changeSDP=changeSDP+str+'\n';
|
||||||
|
}else if(rtpmap){
|
||||||
|
if(str.indexOf("a=rtpmap:102 H264/90000")>-1 || str.indexOf("a=fmtp:102 ")>-1
|
||||||
|
|| str.indexOf("a=ssrc")>-1 || str.indexOf("a=rtcp-fb:102 ")>-1){
|
||||||
|
changeSDP=changeSDP+str+'\n';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
changeSDP=changeSDP+str+'\n';
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
changeSDP=changeSDP+str+'\n';
|
||||||
|
}
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
|
//data.sdp = changeSDP;
|
||||||
|
//console.info('onSDP, changed sdp - ', data.sdp);
|
||||||
|
//data.sdp = data.sdp.replace('UDP/TLS/RTP/SAVPF', 'RTP/SAVPF');
|
||||||
|
//console.info('onSDP, changed sdp - ', data.sdp);
|
||||||
|
});
|
||||||
|
data.session.on('progress', function(data) {
|
||||||
|
console.info('onProgress - ', data.originator);
|
||||||
|
if(data.originator == 'remote') {
|
||||||
|
console.info('onProgress, response - ', data.response);
|
||||||
|
if(data.response!=null && data.response.status_code!=null && data.response.status_code=='183'){
|
||||||
|
ringbackAudio.pause();
|
||||||
|
}
|
||||||
|
//通话状态
|
||||||
|
//status2.innerText = "通话中";
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
data.session.on('peerconnection', function(data) {
|
||||||
|
console.info('onPeerconnection - ', data.peerconnection);
|
||||||
|
console.log(data);
|
||||||
|
data.peerconnection.ontrack = getRemoteStream;
|
||||||
|
|
||||||
|
//data.peerconnection.onaddstream = function(ev) {
|
||||||
|
// ringbackAudio.pause();
|
||||||
|
// console.info('onaddstream from remote - ', ev);
|
||||||
|
// remoteAudio.srcObject = ev.stream;
|
||||||
|
//};
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
data.session.on('addstream', function(e){
|
||||||
|
console.info('on addstream - ');
|
||||||
|
incomingCallAudio.pause();
|
||||||
|
remoteAudio.src = e.stream;
|
||||||
|
});
|
||||||
|
|
||||||
|
data.session.on('failed', function(e){
|
||||||
|
console.info('on failed - ');
|
||||||
|
var call_id = "";
|
||||||
|
if(incomingSession!=null && incomingSession._requst!=null){
|
||||||
|
call_id = incomingSession._requst.call_id;
|
||||||
|
}
|
||||||
|
// doEvent("hangup_event",'',call_id);
|
||||||
|
// globalCallPhoneStates = "未通话";
|
||||||
|
|
||||||
|
if(incomingSession!=null){
|
||||||
|
incomingCallAudio.pause();
|
||||||
|
incomingSession = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
clearVideo();
|
||||||
|
currentSession = null;
|
||||||
|
});
|
||||||
|
|
||||||
|
if(data.session.direction === 'incoming'){
|
||||||
|
console.log('incoming - ',data.session);
|
||||||
|
autoAnswerFlag = document.getElementById('autoAnswerFlag').checked;
|
||||||
|
if(!autoAnswerFlag){
|
||||||
|
incomingCallAudio.play();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
console.info("call register");
|
||||||
|
userAgent.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register callbacks to desired call events
|
||||||
|
var eventHandlers = {
|
||||||
|
'progress': function(e) {
|
||||||
|
// ringbackAudio.play();
|
||||||
|
console.log('call is in progress');
|
||||||
|
// getstatus2.innerText = "连接中";
|
||||||
|
// globalCallPhoneStates = "连接中";
|
||||||
|
},
|
||||||
|
'failed': function(e) {
|
||||||
|
console.log('call failed: ', e);
|
||||||
|
ringbackAudio.pause();
|
||||||
|
if(e.cause == "Busy") {
|
||||||
|
console.error("用户正忙");
|
||||||
|
// getstatus2.innerText = "用户正忙";
|
||||||
|
// globalCallPhoneStates = "用户正忙";
|
||||||
|
} else {
|
||||||
|
console.error("拨打失败");
|
||||||
|
//通话状态
|
||||||
|
// getstatus2.innerText = "拨打失败";
|
||||||
|
// globalCallPhoneStates = "拨打失败";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
clearVideo();
|
||||||
|
},
|
||||||
|
'ended': function(e) {
|
||||||
|
//隐藏本地视频区域
|
||||||
|
//selfViewWap.style.display = "none";
|
||||||
|
console.log('call ended : ', e);
|
||||||
|
//通话状态
|
||||||
|
getstatus2.innerText = "已挂断";
|
||||||
|
globalCallPhoneStates = "已挂断";
|
||||||
|
|
||||||
|
clearVideo();
|
||||||
|
currentSession = null;
|
||||||
|
},
|
||||||
|
|
||||||
|
'confirmed': function(e) {
|
||||||
|
ringbackAudio.pause();
|
||||||
|
console.log('call confirmed');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//语音拨打
|
||||||
|
this.JsSip_VoiceCall = function(callPhone,isVoice) {
|
||||||
|
console.log("isVoice",isVoice);
|
||||||
|
judgeIsVoice = isVoice;//判断是语音拨打还是视频拨打
|
||||||
|
//var sip_phone_number_ ="sip:1000@10.0.11.120:5060";
|
||||||
|
var sip = "sip:";
|
||||||
|
var getIp = getJsSipgetIp;
|
||||||
|
var sip_phone_number_ = (sip + callPhone + "@" + getIp).toString();
|
||||||
|
console.log(sip_phone_number_);
|
||||||
|
|
||||||
|
var options = {
|
||||||
|
'eventHandlers': eventHandlers,
|
||||||
|
'mediaConstraints': constraints,
|
||||||
|
'mediaStream': null
|
||||||
|
};
|
||||||
|
|
||||||
|
outgoingSession = userAgent.call(sip_phone_number_, options);
|
||||||
|
}
|
||||||
|
//接听
|
||||||
|
this.VoiceAnsWter = function() {
|
||||||
|
incomingCallAudio.pause();
|
||||||
|
if(useVideo){
|
||||||
|
Datas.answer({
|
||||||
|
'mediaConstraints': {
|
||||||
|
'audio': true,
|
||||||
|
"video": true
|
||||||
|
},
|
||||||
|
'mediaStream': null
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
Datas.answer({
|
||||||
|
'mediaConstraints': {
|
||||||
|
'audio': true,
|
||||||
|
"video": false
|
||||||
|
},
|
||||||
|
'mediaStream': null
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//getstatus2.innerText = "通话中";
|
||||||
|
//globalCallPhoneStates = "通话中";
|
||||||
|
}
|
||||||
|
|
||||||
|
//发送DTMF
|
||||||
|
this.VoiceSendDTMF = function(dtmf) {
|
||||||
|
if(incomingSession!=null){
|
||||||
|
incomingSession.sendDTMF(dtmf);
|
||||||
|
}else{
|
||||||
|
currentSession.sendDTMF(dtmf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//通话保持
|
||||||
|
this.VoiceHold = function() {
|
||||||
|
//var hOptions = {
|
||||||
|
// 'useUpdate': true,
|
||||||
|
// 'mediaStream': null
|
||||||
|
//};
|
||||||
|
if(incomingSession!=null){
|
||||||
|
incomingSession.hold();
|
||||||
|
}else{
|
||||||
|
currentSession.hold();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//解除保持
|
||||||
|
this.VoiceUnHold = function() {
|
||||||
|
if(incomingSession!=null){
|
||||||
|
incomingSession.unhold();
|
||||||
|
}else{
|
||||||
|
currentSession.unhold();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//挂断
|
||||||
|
this.JsSip_hangUpPhone = function() {
|
||||||
|
|
||||||
|
//关闭本地摄像头
|
||||||
|
//this.closeLocalCapature();
|
||||||
|
//userAgent.stop();//保存当前的注册状态并在正常注销并终止活动会话(如果有)后断开与信令服务器的连接。
|
||||||
|
var options = {
|
||||||
|
all: false,
|
||||||
|
'status_code':486
|
||||||
|
};
|
||||||
|
|
||||||
|
if(incomingSession!=null){
|
||||||
|
incomingCallAudio.pause();
|
||||||
|
incomingSession.terminate(options);
|
||||||
|
}else{
|
||||||
|
userAgent.terminateSessions(options); //终止当前对话
|
||||||
|
}
|
||||||
|
//通话状态
|
||||||
|
//getstatus2.innerText = "已挂断";
|
||||||
|
//globalCallPhoneStates = "已挂断";
|
||||||
|
//当挂断电话要重新调用注册接口
|
||||||
|
//this.jssipAgent(getJsSipPhoneNumber,getJsSipgetIp,getJsSipgetPassWord,getRemoteVideo,getstatus1,getstatus2);
|
||||||
|
}
|
||||||
|
|
||||||
|
//注销
|
||||||
|
this.JsSip_clearRegested = function() {
|
||||||
|
var options = {
|
||||||
|
all: true
|
||||||
|
};
|
||||||
|
userAgent.unregister(options);
|
||||||
|
//userAgent.stop();//保存当前的注册状态并在正常注销并终止活动会话(如果有)后断开与信令服务器的连接。
|
||||||
|
}
|
||||||
|
//注册状态
|
||||||
|
this.getRegisterState = function () {
|
||||||
|
return globalRegisteState;
|
||||||
|
}
|
||||||
|
//通话状态
|
||||||
|
this.callPoneState = function(){
|
||||||
|
return globalCallPhoneStates;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取远程媒体流
|
||||||
|
function getRemoteStream(e) {
|
||||||
|
ringbackAudio.pause();
|
||||||
|
console.log('getRemoteStream - ', e.track, e.streams[0]);
|
||||||
|
//remoteAudio.srcObject = e.streams[0];
|
||||||
|
|
||||||
|
if(useVideo){
|
||||||
|
console.log(e.streams[0])
|
||||||
|
// youVideo.srcObject = e.streams[0];
|
||||||
|
// document.body.addEventListener('click', function () {
|
||||||
|
// meVideo.play();
|
||||||
|
// });
|
||||||
|
// 等到视频流准备好了
|
||||||
|
// var interval = setInterval(function () {
|
||||||
|
// if (!meVideo.videoWidth) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// //stage.appendChild(videoView);
|
||||||
|
// clearInterval(interval);
|
||||||
|
// }, 1000 / 50);
|
||||||
|
}else{
|
||||||
|
// remoteAudio.srcObject = e.streams[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//初始化视频
|
||||||
|
function initVideo(){
|
||||||
|
// meVideo = document.getElementById('meVideo');
|
||||||
|
// meVideo.setAttribute('autoplay', '');
|
||||||
|
// meVideo.setAttribute('playsinline', '');
|
||||||
|
// meVideo.style.width = '212px';
|
||||||
|
//
|
||||||
|
// youVideo = document.getElementById('youVideo');
|
||||||
|
// youVideo.setAttribute('autoplay', '');
|
||||||
|
// youVideo.setAttribute('playsinline', '');
|
||||||
|
// youVideo.style.width = '531px';
|
||||||
|
|
||||||
|
navigator.mediaDevices.getUserMedia({
|
||||||
|
audio: false,
|
||||||
|
video:{
|
||||||
|
faceMode: 'user'
|
||||||
|
}
|
||||||
|
}).then(function success(stream) {
|
||||||
|
console.log(stream)
|
||||||
|
// meVideo.srcObject = stream;
|
||||||
|
// document.body.addEventListener('click', function () {
|
||||||
|
// meVideo.play();
|
||||||
|
// });
|
||||||
|
// // 等到视频流准备好了
|
||||||
|
// var interval = setInterval(function () {
|
||||||
|
// if (!meVideo.videoWidth) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// //stage.appendChild(videoView);
|
||||||
|
// clearInterval(interval);
|
||||||
|
// }, 1000 / 50);
|
||||||
|
}).catch(function (error) {
|
||||||
|
alert(error.message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//释放视频资源
|
||||||
|
function clearVideo(){
|
||||||
|
if(useVideo && meVideo!=null && meVideo.srcObject!=null){
|
||||||
|
meVideo.pause();
|
||||||
|
if(meVideo.srcObject.getTracks()[0]!=null){
|
||||||
|
meVideo.srcObject.getTracks()[0].stop();
|
||||||
|
}
|
||||||
|
if(meVideo.srcObject.getTracks()[1]!=null){
|
||||||
|
meVideo.srcObject.getTracks()[1].stop();
|
||||||
|
}
|
||||||
|
meVideo.srcObject = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
src/assets/images/tel-icon.png
Normal file
BIN
src/assets/images/tel-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.3 KiB |
BIN
src/assets/images/voice-icon.png
Normal file
BIN
src/assets/images/voice-icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.3 KiB |
@@ -57,7 +57,9 @@
|
|||||||
<div>{{ item.postName }}</div>
|
<div>{{ item.postName }}</div>
|
||||||
<div>{{ item.phoneNumber }}</div>
|
<div>{{ item.phoneNumber }}</div>
|
||||||
<div>
|
<div>
|
||||||
<img class="sp-ico" src="@/assets/images/sp-icom.png" />
|
<img @click="doCallTel(item)" class="tel-ico" src="@/assets/images/tel-icon.png" />
|
||||||
|
<img @click="doCallVoice(item)" class="voice-ico" src="@/assets/images/voice-icon.png" />
|
||||||
|
<img @click="doCallVideo(item)" class="sp-ico" src="@/assets/images/sp-icom.png" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -72,14 +74,27 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
<el-dialog v-model="dialogComVideo">
|
||||||
|
<div class="videoPrefecture_video" id="videoPrefecture">
|
||||||
|
<video id="youVideo" class="oneVideo"></video>
|
||||||
|
<video id="meVideo" class="twoVideo"></video>
|
||||||
|
<!-- <span class="glyphicon glyphicon-volume-down"></span>-->
|
||||||
|
<!-- <span class="glyphicon glyphicon-off"></span>-->
|
||||||
|
</div>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { getComDeptsApi, getComDeptUsersApi, getComRecordApi } from '@/api/common'
|
import { getComDeptsApi, getComDeptUsersApi, getComRecordApi } from '@/api/common'
|
||||||
|
import {useWebSocket} from "@/hooks/socket.js";
|
||||||
|
import {mode, proSocketBaseUrl, socketBaseUrl} from "@/utils/config.js";
|
||||||
|
import MyWebrtc from '@/assets/com/webrtc.js';
|
||||||
let deptsList = ref([])
|
let deptsList = ref([])
|
||||||
let dialogTableVisible = ref(false)
|
let dialogTableVisible = ref(false)
|
||||||
let dialogTableVisible2 = ref(false)
|
let dialogTableVisible2 = ref(false)
|
||||||
|
let dialogComVideo = ref(false)
|
||||||
|
const webrtcInstance = new MyWebrtc();
|
||||||
const getComDepts = async () => {
|
const getComDepts = async () => {
|
||||||
let res = await getComDeptsApi()
|
let res = await getComDeptsApi()
|
||||||
deptsList.value = res.data
|
deptsList.value = res.data
|
||||||
@@ -95,16 +110,31 @@
|
|||||||
dialogTableVisible2.value = true
|
dialogTableVisible2.value = true
|
||||||
// location.href="http://192.168.0.2:81/";
|
// location.href="http://192.168.0.2:81/";
|
||||||
}
|
}
|
||||||
|
const doCallTel = (item) => {
|
||||||
|
webrtcInstance.JsSip_VoiceCall('15123854798',true);
|
||||||
|
dialogComVideo.value=true;
|
||||||
|
}
|
||||||
|
const doCallVoice = (item) => {
|
||||||
|
webrtcInstance.JsSip_VoiceCall('854798',false);
|
||||||
|
dialogComVideo.value=true;
|
||||||
|
}
|
||||||
|
const doCallVideo = (item) => {
|
||||||
|
webrtcInstance.JsSip_VoiceCall('854798',true);
|
||||||
|
dialogComVideo.value=true;
|
||||||
|
}
|
||||||
const handleDepsUser = async (id, item) => {
|
const handleDepsUser = async (id, item) => {
|
||||||
gridTitle.value = item.name
|
gridTitle.value = item.name
|
||||||
dialogTableVisible.value = true
|
dialogTableVisible.value = true
|
||||||
let res = await getComDeptUsersApi({ id })
|
let res = await getComDeptUsersApi({ id })
|
||||||
gridData.value = res.data
|
gridData.value = res.data
|
||||||
}
|
}
|
||||||
|
const comRegister = () => {
|
||||||
|
webrtcInstance.jssipAgent('101','192.168.77.8','7066','Admin246246246',null,null,null);
|
||||||
|
}
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
getComDepts()
|
getComDepts()
|
||||||
getComRecord()
|
getComRecord()
|
||||||
|
comRegister();
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -124,8 +154,19 @@
|
|||||||
color: #fff;
|
color: #fff;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
.tel-ico {
|
||||||
|
width: vw(30);
|
||||||
|
cursor: pointer;
|
||||||
|
margin-right: vw(20);
|
||||||
|
}
|
||||||
|
.voice-ico{
|
||||||
|
width: vw(35);
|
||||||
|
cursor: pointer;
|
||||||
|
margin-right: vw(20);
|
||||||
|
}
|
||||||
.sp-ico {
|
.sp-ico {
|
||||||
width: vw(40);
|
width: vw(40);
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
.item-name {
|
.item-name {
|
||||||
width: 90%;
|
width: 90%;
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ export const useHomeStore = defineStore('home', () => {
|
|||||||
// 景区信息数据
|
// 景区信息数据
|
||||||
let scenicData = ref({
|
let scenicData = ref({
|
||||||
scenicSpot: [
|
scenicSpot: [
|
||||||
{ value: 0, name: '全县景区数量' },
|
{ value: 24, name: '全县景区数量' },
|
||||||
{ value: 0, name: '核心景区数' },
|
{ value: 5, name: '4A及以上景区总数' },
|
||||||
{ value: 0, name: '低感景区总数' }
|
{ value: 3, name: '核心景区总数' }
|
||||||
],
|
],
|
||||||
data: [
|
data: [
|
||||||
{ name: '预定今日票:', value: 0 },
|
{ name: '预定今日票:', value: 0 },
|
||||||
|
|||||||
Reference in New Issue
Block a user