Commit 07956b48df476002e3cfd9b01be9e9fb92590ca9

Authored by 648540858
1 parent 1d1f1748

添加界面优化接口

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; @@ -28,6 +28,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
28 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite; 28 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
29 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; 29 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
30 import com.genersoft.iot.vmp.service.IMediaServerService; 30 import com.genersoft.iot.vmp.service.IMediaServerService;
  31 +import com.genersoft.iot.vmp.service.IMediaService;
31 import com.genersoft.iot.vmp.service.IPlayService; 32 import com.genersoft.iot.vmp.service.IPlayService;
32 import com.genersoft.iot.vmp.service.IStreamPushService; 33 import com.genersoft.iot.vmp.service.IStreamPushService;
33 import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; 34 import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
@@ -103,6 +104,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -103,6 +104,9 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
103 @Autowired 104 @Autowired
104 private IMediaServerService mediaServerService; 105 private IMediaServerService mediaServerService;
105 106
  107 + @Autowired
  108 + private IMediaService mediaService;
  109 +
106 @Autowired 110 @Autowired
107 private ZLMRESTfulUtils zlmresTfulUtils; 111 private ZLMRESTfulUtils zlmresTfulUtils;
108 112
@@ -1016,7 +1020,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -1016,7 +1020,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
1016 AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult(); 1020 AudioBroadcastResult audioBroadcastResult = new AudioBroadcastResult();
1017 audioBroadcastResult.setApp(app); 1021 audioBroadcastResult.setApp(app);
1018 audioBroadcastResult.setStream(stream); 1022 audioBroadcastResult.setStream(stream);
1019 - audioBroadcastResult.setMediaServerItem(new MediaServerItemLite(mediaServerItem)); 1023 + audioBroadcastResult.setStreamInfo(mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, stream, null, null, false));
1020 audioBroadcastResult.setCodec("G.711"); 1024 audioBroadcastResult.setCodec("G.711");
1021 wvpResult.setData(audioBroadcastResult); 1025 wvpResult.setData(audioBroadcastResult);
1022 RequestMessage requestMessage = new RequestMessage(); 1026 RequestMessage requestMessage = new RequestMessage();
src/main/java/com/genersoft/iot/vmp/service/IMediaService.java
@@ -41,4 +41,5 @@ public interface IMediaService { @@ -41,4 +41,5 @@ public interface IMediaService {
41 * @return 41 * @return
42 */ 42 */
43 StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr); 43 StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr);
  44 + StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, boolean isPlay);
44 } 45 }
src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java
@@ -74,6 +74,11 @@ public class MediaServiceImpl implements IMediaService { @@ -74,6 +74,11 @@ public class MediaServiceImpl implements IMediaService {
74 74
75 @Override 75 @Override
76 public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr) { 76 public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr) {
  77 + return getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr, true);
  78 + }
  79 +
  80 + @Override
  81 + public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, boolean isPlay) {
77 StreamInfo streamInfoResult = new StreamInfo(); 82 StreamInfo streamInfoResult = new StreamInfo();
78 streamInfoResult.setStream(stream); 83 streamInfoResult.setStream(stream);
79 streamInfoResult.setApp(app); 84 streamInfoResult.setApp(app);
@@ -107,11 +112,10 @@ public class MediaServiceImpl implements IMediaService { @@ -107,11 +112,10 @@ public class MediaServiceImpl implements IMediaService {
107 streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream)); 112 streamInfoResult.setHttps_ts(String.format("https://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
108 streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream)); 113 streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
109 streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream)); 114 streamInfoResult.setWss_ts(String.format("wss://%s:%s/%s/%s.live.ts", addr, mediaInfo.getHttpSSlPort(), app, stream));
110 - streamInfoResult.setRtc(String.format("https://%s:%s/index/api/webrtc?app=%s&stream=%s&type=play", mediaInfo.getStreamIp(), mediaInfo.getHttpSSlPort(), app, stream)); 115 + 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"));
111 } 116 }
112 117
113 streamInfoResult.setTracks(tracks); 118 streamInfoResult.setTracks(tracks);
114 return streamInfoResult; 119 return streamInfoResult;
115 } 120 }
116 -  
117 } 121 }
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -190,10 +190,7 @@ public class PlayServiceImpl implements IPlayService { @@ -190,10 +190,7 @@ public class PlayServiceImpl implements IPlayService {
190 redisCatchStorage.stopPlay(streamInfo); 190 redisCatchStorage.stopPlay(streamInfo);
191 storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); 191 storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
192 streamInfo = null; 192 streamInfo = null;
193 -  
194 } 193 }
195 -  
196 -  
197 } 194 }
198 if (streamInfo == null) { 195 if (streamInfo == null) {
199 String streamId = null; 196 String streamId = null;
src/main/java/com/genersoft/iot/vmp/vmanager/bean/AudioBroadcastResult.java
1 package com.genersoft.iot.vmp.vmanager.bean; 1 package com.genersoft.iot.vmp.vmanager.bean;
2 2
  3 +import com.genersoft.iot.vmp.common.StreamInfo;
3 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 4 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
4 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite; 5 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
5 6
@@ -8,9 +9,9 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite; @@ -8,9 +9,9 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItemLite;
8 */ 9 */
9 public class AudioBroadcastResult { 10 public class AudioBroadcastResult {
10 /** 11 /**
11 - * 推流的媒体节点信息 12 + * 推流的各个方式流地址
12 */ 13 */
13 - private MediaServerItemLite mediaServerItem; 14 + private StreamInfo streamInfo;
14 15
15 /** 16 /**
16 * 编码格式 17 * 编码格式
@@ -28,12 +29,12 @@ public class AudioBroadcastResult { @@ -28,12 +29,12 @@ public class AudioBroadcastResult {
28 private String stream; 29 private String stream;
29 30
30 31
31 - public MediaServerItemLite getMediaServerItem() {  
32 - return mediaServerItem; 32 + public StreamInfo getStreamInfo() {
  33 + return streamInfo;
33 } 34 }
34 35
35 - public void setMediaServerItem(MediaServerItemLite mediaServerItem) {  
36 - this.mediaServerItem = mediaServerItem; 36 + public void setStreamInfo(StreamInfo streamInfo) {
  37 + this.streamInfo = streamInfo;
37 } 38 }
38 39
39 public String getCodec() { 40 public String getCodec() {
src/main/resources/8042900_www.wvp-pro.cn.jks 0 → 100644
No preview for this file type
web_src/src/components/dialog/devicePlayer.vue
@@ -276,6 +276,17 @@ @@ -276,6 +276,17 @@
276 </div> 276 </div>
277 277
278 </el-tab-pane> 278 </el-tab-pane>
  279 + <el-tab-pane label="语音对讲" name="broadcast" >
  280 + <div class="trank" style="text-align: center;">
  281 + <el-button @click="broadcastStatusClick()" :type="getBroadcastStatus()" circle icon="el-icon-microphone" style="font-size: 32px; padding: 24px;margin-top: 24px;"/>
  282 + <p>
  283 + <span v-if="broadcastStatus === -1">点击开始对讲</span>
  284 + <span v-if="broadcastStatus === 0">等待接通中...</span>
  285 + <span v-if="broadcastStatus === 1">请说话</span>
  286 + </p>
  287 +
  288 + </div>
  289 + </el-tab-pane>
279 290
280 </el-tabs> 291 </el-tabs>
281 </div> 292 </div>
@@ -359,6 +370,8 @@ export default { @@ -359,6 +370,8 @@ export default {
359 recordStartTime: 0, 370 recordStartTime: 0,
360 showTimeText: "00:00:00", 371 showTimeText: "00:00:00",
361 streamInfo: null, 372 streamInfo: null,
  373 + broadcastRtc: null,
  374 + broadcastStatus: -1, // -1 默认状态 0 等待接通 1 接通成功
362 }; 375 };
363 }, 376 },
364 methods: { 377 methods: {
@@ -804,8 +817,111 @@ export default { @@ -804,8 +817,111 @@ export default {
804 }, 600) 817 }, 600)
805 }); 818 });
806 }, 819 },
  820 + getBroadcastStatus() {
  821 + if (this.broadcastStatus == -1) {
  822 + return "primary"
  823 + }
  824 + if (this.broadcastStatus == 0) {
  825 + return "warning"
  826 + }
  827 + if (this.broadcastStatus == 1) {
  828 + return "danger"
  829 + }
  830 +
  831 + },
  832 + broadcastStatusClick() {
  833 + if (this.broadcastStatus == -1) {
  834 + // 默认状态, 开始
  835 + // 发起语音对讲
  836 + this.$axios({
  837 + method: 'get',
  838 + url: '/api/play/broadcast/' + this.deviceId + '/' + this.channelId + "?timeout=30"
  839 + }).then( (res)=> {
  840 + if (res.data.code == 0) {
  841 + let streamInfo = res.data.data.streamInfo;
  842 + this.startBroadcast(streamInfo.rtc)
  843 + }else {
  844 + this.$message({
  845 + showClose: true,
  846 + message: res.data.msg,
  847 + type: "error",
  848 + });
  849 + }
  850 + });
  851 + }else if (this.broadcastStatus === 1) {
  852 + this.broadcastRtc.close()
  853 + this.broadcastRtc = null;
  854 + this.broadcastStatus = -1;
  855 + }
  856 + },
  857 + startBroadcast(url){
  858 + console.log("开始语音对讲: " + url)
  859 + this.broadcastRtc = new ZLMRTCClient.Endpoint({
  860 + debug: true, // 是否打印日志
  861 + zlmsdpUrl: url, //流地址
  862 + simulecast: false,
  863 + useCamera: false,
  864 + audioEnable: true,
  865 + videoEnable: false,
  866 + recvOnly: false,
  867 + })
  868 +
  869 + // webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_REMOTE_STREAMS,(e)=>{//获取到了远端流,可以播放
  870 + // console.error('播放成功',e.streams)
  871 + // this.broadcastStatus = 1;
  872 + // });
  873 + //
  874 + // webrtcPlayer.on(ZLMRTCClient.Events.WEBRTC_ON_LOCAL_STREAM,(s)=>{// 获取到了本地流
  875 + // this.broadcastStatus = 1;
  876 + // // document.getElementById('selfVideo').srcObject=s;
  877 + // // this.eventcallbacK("LOCAL STREAM", "获取到了本地流")
  878 + // });
  879 +
  880 + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_NOT_SUPPORT,(e)=>{// 获取到了本地流
  881 + console.error('不支持webrtc',e)
  882 + this.$message({
  883 + showClose: true,
  884 + message: '不支持webrtc, 无法进行语音对讲',
  885 + type: 'error'
  886 + });
  887 + });
807 888
  889 + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ICE_CANDIDATE_ERROR,(e)=>{// ICE 协商出错
  890 + console.error('ICE 协商出错')
  891 + this.$message({
  892 + showClose: true,
  893 + message: 'ICE 协商出错',
  894 + type: 'error'
  895 + });
  896 + });
808 897
  898 + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_OFFER_ANWSER_EXCHANGE_FAILED,(e)=>{// offer anwser 交换失败
  899 + console.error('offer anwser 交换失败',e)
  900 + this.$message({
  901 + showClose: true,
  902 + message: 'offer anwser 交换失败' + e,
  903 + type: 'error'
  904 + });
  905 + });
  906 + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_ON_CONNECTION_STATE_CHANGE,(e)=>{// offer anwser 交换失败
  907 + console.log('状态改变',e)
  908 + if (e === "failed") {
  909 + this.broadcastStatus = -1;
  910 + }else if (e === "connecting") {
  911 + this.broadcastStatus = 0;
  912 + }else{
  913 + this.broadcastStatus = 1;
  914 + }
  915 + });
  916 + this.broadcastRtc.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,(e)=>{// offer anwser 交换失败
  917 + console.log('捕获流失败',e)
  918 + this.$message({
  919 + showClose: true,
  920 + message: '捕获流失败' + e,
  921 + type: 'error'
  922 + });
  923 + });
  924 + }
809 } 925 }
810 }; 926 };
811 </script> 927 </script>