From 8f7e8efc981cf68a3067fb3421fdfbbf6f6275ab Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期二, 23 八月 2022 11:48:31 +0800 Subject: [PATCH] 合并主线 --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 40 ++++++ src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 5 web_src/src/components/dialog/devicePlayer.vue | 143 +++++++++++++---------- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java | 17 +- src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java | 7 - src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java | 4 src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java | 11 + sql/update.sql | 99 ---------------- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java | 9 src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 6 - src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java | 3 11 files changed, 149 insertions(+), 195 deletions(-) diff --git a/sql/update.sql b/sql/update.sql index c04cd92..e69de29 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -1,99 +0,0 @@ -alter table parent_platform - add startOfflinePush int default 0 null; - -alter table parent_platform - add administrativeDivision varchar(50) not null; - -alter table parent_platform - add catalogGroup int default 1 null; - -alter table device - add audioChannelForReceive VARCHAR(50) null; - -alter table device - add audioChannelForSend VARCHAR(50) null; - -alter table stream_push - add serverId varchar(50) not null; - -alter table device - add geoCoordSys varchar(50) not null; -alter table device - add treeType varchar(50) not null; -update device set device.geoCoordSys='WGS84'; -update device set device.treeType='CivilCode'; - -alter table device_channel - add longitudeGcj02 double default null; -alter table device_channel - add latitudeGcj02 double default null; -alter table device_channel - add longitudeWgs84 double default null; -alter table device_channel - add latitudeWgs84 double default null; -alter table device_channel - add businessGroupId varchar(50) default null; -alter table device_channel - add gpsTime varchar(50) default null; - - -alter table device_mobile_position - change cnLng longitudeGcj02 double default null; -alter table device_mobile_position - change cnLat latitudeGcj02 double default null; -alter table device_mobile_position - add longitudeWgs84 double default null; -alter table device_mobile_position - add latitudeWgs84 double default null; -alter table device_mobile_position - drop geodeticSystem; -alter table device_mobile_position - add createTime varchar(50) default null; - -alter table device_alarm - add createTime varchar(50) default null; - -alter table gb_stream - change createStamp createTime varchar(50) default null; - -alter table parent_platform - add createTime varchar(50) default null; -alter table parent_platform - add updateTime varchar(50) default null; - -alter table stream_proxy - add updateTime varchar(50) default null; - -alter table stream_push - add pushTime varchar(50) default null; -alter table stream_push - add status int DEFAULT NULL; -alter table stream_push - add updateTime varchar(50) default null; -alter table stream_push - add pushIng int DEFAULT NULL; -alter table stream_push - change createStamp createTime varchar(50) default null; - -alter table gb_stream - drop column status; - -alter table user - add pushKey varchar(50) default null; -update user set pushKey='453df297a57a5a7438934sda801fc3' where id=1; - -alter table parent_platform - add treeType varchar(50) not null; -update parent_platform set parent_platform.treeType='BusinessGroup'; -alter table parent_platform drop shareAllLiveStream; - -alter table platform_catalog - add civilCode varchar(50) default null; -alter table platform_catalog - add businessGroupId varchar(50) default null; - -/********************* ADD ***************************/ -alter table stream_push - add self int DEFAULT NULL; - - diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index bf6146a..154071e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -10,6 +10,7 @@ import gov.nist.javax.sip.stack.SIPDialog; import javax.sip.Dialog; +import javax.sip.InvalidArgumentException; import javax.sip.SipException; import java.text.ParseException; @@ -127,7 +128,7 @@ */ void streamByeCmd(String deviceId, String channelId, String stream, String callId, SipSubscribe.Event okEvent); void streamByeCmd(String deviceId, String channelId, String stream, String callId); - void streamByeCmd(SIPDialog dialog, SIPRequest request, SipSubscribe.Event okEvent) throws SipException, ParseException; + void streamByeCmd(SIPDialog dialog, String channelId, SIPRequest request, SipSubscribe.Event okEvent) throws SipException, ParseException, InvalidArgumentException; /** * 鍥炴斁鏆傚仠 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 6bf85db..811637a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -676,6 +676,46 @@ streamByeCmd(deviceId, channelId, stream, callId, null); } + @Override + public void streamByeCmd(SIPDialog dialog, String channelId, SIPRequest request, SipSubscribe.Event okEvent) throws SipException, ParseException, InvalidArgumentException { + Request byeRequest = dialog.createRequest(Request.BYE); + SipURI byeURI = (SipURI) byeRequest.getRequestURI(); + byeURI.setHost(request.getRemoteAddress().getHostAddress()); + byeURI.setPort(request.getRemotePort()); + byeURI.setUser(channelId); + ViaHeader viaHeader = (ViaHeader) byeRequest.getHeader(ViaHeader.NAME); + String protocol = viaHeader.getTransport().toUpperCase(); + viaHeader.setRPort(); + // 澧炲姞Contact header + Address concatAddress = sipFactory.createAddressFactory().createAddress(sipFactory.createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp()+":"+sipConfig.getPort())); + byeRequest.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); + List<String> agentParam = new ArrayList<>(); + agentParam.add("wvp-pro"); + // TODO 娣诲姞鐗堟湰淇℃伅浠ュ強鏃ユ湡 + UserAgentHeader userAgentHeader = null; + try { + userAgentHeader = sipFactory.createHeaderFactory().createUserAgentHeader(agentParam); + } catch (ParseException e) { + throw new RuntimeException(e); + } + byeRequest.addHeader(userAgentHeader); + ClientTransaction clientTransaction = null; + if("TCP".equals(protocol)) { + clientTransaction = tcpSipProvider.getNewClientTransaction(byeRequest); + } else if("UDP".equals(protocol)) { + clientTransaction = udpSipProvider.getNewClientTransaction(byeRequest); + } + + CallIdHeader callIdHeader = (CallIdHeader) byeRequest.getHeader(CallIdHeader.NAME); + if (okEvent != null) { + sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), okEvent); + } + CSeqHeader cSeqHeader = (CSeqHeader)byeRequest.getHeader(CSeqHeader.NAME); + cSeqHeader.setSeqNumber(redisCatchStorage.getCSEQ()); + dialog.sendRequest(clientTransaction); + + } + /** * 瑙嗛娴佸仠姝� */ diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java index c35f21b..6eb4bc9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java @@ -26,10 +26,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import javax.sip.Dialog; -import javax.sip.DialogState; -import javax.sip.RequestEvent; -import javax.sip.SipException; +import javax.sip.*; import javax.sip.address.SipURI; import javax.sip.header.CallIdHeader; import javax.sip.header.FromHeader; @@ -151,11 +148,13 @@ if (sendRtpItem.isOnlyAudio()) { // 璇煶瀵硅 try { - cmder.streamByeCmd((SIPDialog) evt.getDialog(), (SIPRequest) evt.getRequest(), null); + cmder.streamByeCmd((SIPDialog) evt.getDialog(), sendRtpItem.getChannelId(), (SIPRequest) evt.getRequest(), null); } catch (SipException e) { throw new RuntimeException(e); } catch (ParseException e) { throw new RuntimeException(e); + } catch (InvalidArgumentException e) { + throw new RuntimeException(e); } } else { // 鍚戜笂绾у钩鍙� diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 3a49f44..867fcab 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -90,12 +90,6 @@ @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IStreamProxyService streamProxyService; - - @Autowired private EventPublisher publisher; /** @@ -288,6 +282,7 @@ return (MediaServerItem)RedisUtil.get(key); } + @Override public MediaServerItem getDefaultMediaServer() { 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 4d167f0..8beff77 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 @@ -25,11 +25,7 @@ private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorage storager; - - @Autowired private IMediaServerService mediaServerService; - @Autowired private MediaConfig mediaConfig; 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 0e9b3d1..1ced19b 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 @@ -4,6 +4,7 @@ import java.math.RoundingMode; import java.util.*; +import javax.sip.InvalidArgumentException; import javax.sip.ResponseEvent; import com.genersoft.iot.vmp.gb28181.bean.*; @@ -745,7 +746,7 @@ zlmresTfulUtils.closeStreams(mediaInfo, sendRtpItem.getApp(), sendRtpItem.getStreamId()); } if (audioBroadcastCatch.getStatus() == AudioBroadcastCatchStatus.Ok) { - cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getRequest(), null); + cmder.streamByeCmd(audioBroadcastCatch.getDialog(), audioBroadcastCatch.getChannelId(), audioBroadcastCatch.getRequest(), null); } audioBroadcastManager.del(deviceId, channelId); @@ -753,6 +754,8 @@ throw new RuntimeException(e); } catch (ParseException e) { throw new RuntimeException(e); + } catch (InvalidArgumentException e) { + throw new RuntimeException(e); } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 8fabbda..8ab2712 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -77,12 +77,6 @@ private PlatformGbStreamMapper platformGbStreamMapper; @Autowired - private EventPublisher eventPublisher; - - @Autowired - private ParentPlatformMapper parentPlatformMapper; - - @Autowired private IGbStreamService gbStreamService; @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index dcd89b3..2fcc9c2 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -197,9 +197,11 @@ @Operation(summary = "璇煶骞挎挱鍛戒护") @Parameter(name = "deviceId", description = "璁惧鍥芥爣缂栧彿", required = true) - @GetMapping("/broadcast/{deviceId}") - @PostMapping("/broadcast/{deviceId}") - public DeferredResult<WVPResult<AudioBroadcastResult>> broadcastApi(@PathVariable String deviceId) { + @Parameter(name = "deviceId", description = "閫氶亾鍥芥爣缂栧彿", required = true) + @Parameter(name = "timeout", description = "鎺ㄦ祦瓒呮椂鏃堕棿(绉�)", required = true) + @GetMapping("/broadcast/{deviceId}/{channelId}") + @PostMapping("/broadcast/{deviceId}/{channelId}") + public DeferredResult<WVPResult<AudioBroadcastResult>> broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout) { if (logger.isDebugEnabled()) { logger.debug("璇煶骞挎挱API璋冪敤"); } @@ -258,13 +260,10 @@ return result; } - @Operation(summary = "鑾峰彇鎵�鏈夌殑ssrc") - @ApiOperation("鍋滄璇煶骞挎挱") - @ApiImplicitParams({ - @ApiImplicitParam(name = "deviceId", value = "璁惧Id", dataTypeClass = String.class), - @ApiImplicitParam(name = "channelId", value = "閫氶亾Id", dataTypeClass = String.class), - }) + @Operation(summary = "鍋滄璇煶骞挎挱") + @Parameter(name = "deviceId", description = "璁惧Id", required = true) + @Parameter(name = "channelId", description = "閫氶亾Id", required = true) @GetMapping("/broadcast/stop/{deviceId}/{channelId}") @PostMapping("/broadcast/stop/{deviceId}/{channelId}") public WVPResult<String> stopBroadcastA(@PathVariable String deviceId, @PathVariable String channelId) { diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index 2b44dd7..7e40720 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -199,4 +199,15 @@ } } } + + @PostMapping("/userInfo") + @Operation(summary = "绠$悊鍛樹慨鏀规櫘閫氱敤鎴峰瘑鐮�") + public LoginUser getUserInfo() { + // 鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛id + LoginUser userInfo = SecurityUtils.getUserInfo(); + if (userInfo == null) { + throw new ControllerException(ErrorCode.ERROR100); + } + return userInfo; + } } diff --git a/web_src/src/components/dialog/devicePlayer.vue b/web_src/src/components/dialog/devicePlayer.vue index 85f83f8..0cba21f 100644 --- a/web_src/src/components/dialog/devicePlayer.vue +++ b/web_src/src/components/dialog/devicePlayer.vue @@ -871,76 +871,91 @@ } }, startBroadcast(url){ - // 鑾峰彇鎺ㄦ祦閴存潈KEY - console.log(this.$loginUser) - console.log(this.$loginUser.pushKey) - url += "&sign=" + crypto.createHash('md5').update(this.$loginUser.pushKey, "utf8").digest('hex') - console.log("寮�濮嬭闊冲璁诧細 " + url) - this.broadcastRtc = new ZLMRTCClient.Endpoint({ - debug: true, // 鏄惁鎵撳嵃鏃ュ織 - zlmsdpUrl: url, //娴佸湴鍧� - simulecast: false, - useCamera: false, - audioEnable: true, - videoEnable: false, - recvOnly: false, - }) + // 鑾峰彇鎺ㄦ祦閴存潈Key + this.$axios({ + method: 'post', + url: '/api/user/userInfo', + }).then( (res)=> { + if (res.data.code !== 0) { + this.$message({ + showClose: true, + message: "鑾峰彇鎺ㄦ祦閴存潈Key澶辫触", + type: "error", + }); + }else { + let pushKey = res.data.data.pushKey; + // 鑾峰彇鎺ㄦ祦閴存潈KEY + url += "&sign=" + crypto.createHash('md5').update(pushKey, "utf8").digest('hex') + 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", "鑾峰彇鍒颁簡鏈湴娴�") - // }); + // 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('涓嶆敮鎸亀ebrtc',e) - this.$message({ - showClose: true, - message: '涓嶆敮鎸亀ebrtc, 鏃犳硶杩涜璇煶瀵硅', - type: 'error' - }); - }); + this.broadcastRtc.on(ZLMRTCClient.Events.WEBRTC_NOT_SUPPORT,(e)=>{// 鑾峰彇鍒颁簡鏈湴娴� + console.error('涓嶆敮鎸亀ebrtc',e) + this.$message({ + showClose: true, + message: '涓嶆敮鎸亀ebrtc, 鏃犳硶杩涜璇煶瀵硅', + 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_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 === "connecting") { - this.broadcastStatus = 0; - }else if (e === "connected") { - this.broadcastStatus = 1; - }else if (e === "disconnected") { - this.broadcastStatus = -1; + 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 === "connecting") { + this.broadcastStatus = 0; + }else if (e === "connected") { + this.broadcastStatus = 1; + }else if (e === "disconnected") { + 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' + }); + }); } }); - this.broadcastRtc.on(ZLMRTCClient.Events.CAPTURE_STREAM_FAILED,(e)=>{// offer anwser 浜ゆ崲澶辫触 - console.log('鎹曡幏娴佸け璐�',e) - this.$message({ - showClose: true, - message: '鎹曡幏娴佸け璐�' + e, - type: 'error' - }); - }); + + }, stopBroadcast(){ this.broadcastStatus = -2; -- Gitblit v1.8.0