From ecc8e23e1dcd42c4f2101eb15c30b5bb43afc301 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Sat, 26 Nov 2022 00:06:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=81=8A=E5=A4=A9=E5=8A=9F?= =?UTF-8?q?=E8=83=BD-=E5=BC=80=E5=8F=91=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/chat/ChatPrivateVideo.vue | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/im-ui/src/components/chat/ChatPrivateVideo.vue b/im-ui/src/components/chat/ChatPrivateVideo.vue index d704e04..a9a1810 100644 --- a/im-ui/src/components/chat/ChatPrivateVideo.vue +++ b/im-ui/src/components/chat/ChatPrivateVideo.vue @@ -48,16 +48,17 @@ state: 'NOT_CONNECTED', candidates: [], configuration: { - iceServers: [{ + iceServers: [ + { urls: 'stun:stun.l.google.com:19302' }, { - urls: 'turn:www.boxim.online:3478', + urls: 'turn:8.134.92.70:3478', credential: 'admin123', username: 'admin' }, { - urls: 'stun:www.boxim.online:3478' + urls: 'stun:8.134.92.70:3478' } ] } @@ -126,23 +127,15 @@ console.log("onaddstream") this.$refs.friendVideo.srcObject = e.streams[0]; }; - this.peerConnection.onicegatheringstatechange = (event) => { - if (this.peerConnection.iceGatheringState == 'complete') { - this.candidates.forEach((candidate) => { - this.sendCandidate(candidate); - }) - } - } - this.peerConnection.onicecandidate = (event) => { if (event.candidate) { - // if (this.state == 'CONNECTED') { - // // 已连接,直接发送 - // this.sendCandidate(event.candidate); - // } else { - // 未连接,缓存起来,连接后再发送 - this.candidates.push(event.candidate) - //} + if (this.state == 'CONNECTED') { + // 已连接,直接发送 + this.sendCandidate(event.candidate); + } else { + // 未连接,缓存起来,连接后再发送 + this.candidates.push(event.candidate) + } } } if (stream) { @@ -165,9 +158,9 @@ // 状态为连接中 this.state = 'CONNECTED'; // 发送candidate - // this.candidates.forEach((candidate) => { - // this.sendCandidate(candidate); - // }) + this.candidates.forEach((candidate) => { + this.sendCandidate(candidate); + }) } if (msg.type == this.$enums.MESSAGE_TYPE.RTC_REJECT) { this.$message.error("对方拒绝了您的视频请求");