From 07956b48df476002e3cfd9b01be9e9fb92590ca9 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 1 Jul 2022 18:26:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=95=8C=E9=9D=A2=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/impl/InviteRequestProcessor.java | 6 +- .../iot/vmp/service/IMediaService.java | 1 + .../vmp/service/impl/MediaServiceImpl.java | 8 +- .../iot/vmp/service/impl/PlayServiceImpl.java | 3 - .../vmanager/bean/AudioBroadcastResult.java | 13 +- src/main/resources/8042900_www.wvp-pro.cn.jks | Bin 0 -> 5676 bytes .../src/components/dialog/devicePlayer.vue | 116 ++++++++++++++++++ 7 files changed, 135 insertions(+), 12 deletions(-) create mode 100644 src/main/resources/8042900_www.wvp-pro.cn.jks diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 6c04c20f..04982c39 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -28,6 +28,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.IMediaServerService; +import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IPlayService; import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; @@ -103,6 +104,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @Autowired private IMediaServerService mediaServerService; + @Autowired + private IMediaService mediaService; + @Autowired private ZLMRESTfulUtils zlmresTfulUtils; @@ -1016,7 +1020,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult(); audioBroadcastResult.setApp(app); audioBroadcastResult.setStream(stream); - audioBroadcastResult.setMediaServerItem(new MediaServerItemLite(mediaServerItem)); + audioBroadcastResult.setStreamInfo(mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, stream, null, null, false)); audioBroadcastResult.setCodec("G.711"); wvpResult.setData(audioBroadcastResult); RequestMessage requestMessage = new RequestMessage(); diff --git a/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java b/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java index 8c05b85f..3eee6c7e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java @@ -41,4 +41,5 @@ public interface IMediaService { * @return */ StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr); + StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, boolean isPlay); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java index 2c084a55..a3d2a385 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java @@ -74,6 +74,11 @@ public class MediaServiceImpl implements IMediaService { @Override public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr) { + return getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr, true); + } + + @Override + public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, boolean isPlay) { StreamInfo streamInfoResult = new StreamInfo(); streamInfoResult.setStream(stream); streamInfoResult.setApp(app); @@ -107,11 +112,10 @@ public class MediaServiceImpl implements IMediaService { streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream)); streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream)); streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream)); - streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream)); + streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=%s", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream, isPlay?"play":"push")); } streamInfoResult.setTracks(tracks); return streamInfoResult; } - } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 6422cfc7..d945bfc9 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -190,10 +190,7 @@ public class PlayServiceImpl implements IPlayService { redisCatchStorage.stopPlay(streamInfo); storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); streamInfo = null; - } - - } if (streamInfo == null) { String streamId = null; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/AudioBroadcastResult.java b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/AudioBroadcastResult.java index a722ae89..64bc243f 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/bean/AudioBroadcastResult.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/bean/AudioBroadcastResult.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.vmanager.bean; +import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite; @@ -8,9 +9,9 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite; */ public class AudioBroadcastResult { /** - * 推流的媒体节点信息 + * 推流的各个方式流地址 */ - private MediaServerItemLite mediaServerItem; + private StreamInfo streamInfo; /** * 编码格式 @@ -28,12 +29,12 @@ public class AudioBroadcastResult { private String stream; - public MediaServerItemLite getMediaServerItem() { - return mediaServerItem; + public StreamInfo getStreamInfo() { + return streamInfo; } - public void setMediaServerItem(MediaServerItemLite mediaServerItem) { - this.mediaServerItem = mediaServerItem; + public void setStreamInfo(StreamInfo streamInfo) { + this.streamInfo = streamInfo; } public String getCodec() { diff --git a/src/main/resources/8042900_www.wvp-pro.cn.jks b/src/main/resources/8042900_www.wvp-pro.cn.jks new file mode 100644 index 0000000000000000000000000000000000000000..3e5120652595d9e6480232fc0d0329a02552548d GIT binary patch literal 5676 zcmeH~c{Ei2|HtpWvskiZi6RWy8rz*2ONcCE$&#HW%9bsRZ4fFElcj|s5+aJ2_@E-Y zWQodBSwfO1TlJBWweL*Zr_bm7e&_o;=XcKcpKo){Ju|QSe$DH3&%Lkvd_3RlbL(>e z06^al5MXik@p2B5^L7gZ05GcR#Q8}8KtXUcavkPCv&x`BB#4E$KoA8Wqmk41j94k& zv2Xg#jJ<`29+SwykuoKMmYQ>ic(&f0DVsq%oRD$bMr@l6X)|>_%(q$MhONJkl_nfh z7`Az*1v{cWVq(~7y3hAs6|?6)n*w0m!c_#MZp%fo28$1-UzEcO4?aEqL%yteHR_HGJtdv8>F z&BJ!%gb0-?M^RykG-8TWRJEM0GRfxrOmp|XlO*4VIXT;W6K7nE4-(#u*Of1MxAMu` zaqVHxe;L_j7O$IHtsfG9!$QbKDJCFDLsGlwPmI+z3!rQNt_~m9EmrU->t@qtuy(l8h+wn{V+q^l2ON!@WTk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O6B-(8GPqnD#Ed z`#yP!=uvU@)!p$^I){KHt=SLCKKFpNbD7xtfAlDGq}bpCSEXp$dIOVcjg=||8>@@HyU*4&1sj}_l$bePC*5k)|x^o#g^0a%60=>Px# literal 0 HcmV?d00001 diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue index 9c254c9b..5c40c31f 100644 --- a/web_src/src/components/dialog/devicePlayer.vue +++ b/web_src/src/components/dialog/devicePlayer.vue @@ -276,6 +276,17 @@ + +
+ +

+ 点击开始对讲 + 等待接通中... + 请说话 +

+ +
+
@@ -359,6 +370,8 @@ export default { recordStartTime: 0, showTimeText: "00:00:00", streamInfo: null, + broadcastRtc: null, + broadcastStatus: -1, // -1 默认状态 0 等待接通 1 接通成功 }; }, methods: { @@ -804,8 +817,111 @@ export default { }, 600) }); }, + getBroadcastStatus() { + if (this.broadcastStatus == -1) { + return "primary" + } + if (this.broadcastStatus == 0) { + return "warning" + } + if (this.broadcastStatus == 1) { + return "danger" + } + }, + broadcastStatusClick() { + if (this.broadcastStatus == -1) { + // 默认状态, 开始 + // 发起语音对讲 + this.$axios({ + method: 'get', + url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30" + }).then( (res)=> { + if (res.data.code == 0) { + let streamInfo = res.data.data.streamInfo; + this.startBroadcast(streamInfo.rtc) + }else { + this.$message({ + showClose: true, + message: res.data.msg, + type: "error", + }); + } + }); + }else if (this.broadcastStatus === 1) { + this.broadcastRtc.close() + this.broadcastRtc = null; + this.broadcastStatus = -1; + } + }, + startBroadcast(url){ + console.log("开始语音对讲: " + url) + this.broadcastRtc = new ZLMRTCClient.Endpoint({ + debug: true, // 是否打印日志 + zlmsdpUrl: url, //流地址 + simulecast: false, + useCamera: false, + audioEnable: true, + videoEnable: false, + recvOnly: false, + }) + // webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS,(e)=>{//获取到了远端流,可以播放 + // console.error('播放成功',e.streams) + // this.broadcastStatus = 1; + // }); + // + // webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_LOCAL_STREAM,(s)=>{// 获取到了本地流 + // this.broadcastStatus = 1; + // // document.getElementById('selfVideo').srcObject=s; + // // this.eventcallbacK("LOCAL STREAM", "获取到了本地流") + // }); + + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_NOT_SUPPORT,(e)=>{// 获取到了本地流 + console.error('不支持webrtc',e) + this.$message({ + showClose: true, + message: '不支持webrtc, 无法进行语音对讲', + type: 'error' + }); + }); + + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,(e)=>{// ICE 协商出错 + console.error('ICE 协商出错') + this.$message({ + showClose: true, + message: 'ICE 协商出错', + type: 'error' + }); + }); + + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,(e)=>{// offer anwser 交换失败 + console.error('offer anwser 交换失败',e) + this.$message({ + showClose: true, + message: 'offer anwser 交换失败' + e, + type: 'error' + }); + }); + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,(e)=>{// offer anwser 交换失败 + console.log('状态改变',e) + if (e === "failed") { + this.broadcastStatus = -1; + }else if (e === "connecting") { + this.broadcastStatus = 0; + }else{ + this.broadcastStatus = 1; + } + }); + this.broadcastRtc.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,(e)=>{// offer anwser 交换失败 + console.log('捕获流失败',e) + this.$message({ + showClose: true, + message: '捕获流失败' + e, + type: 'error' + }); + }); + } } };