diff --git a/sql/update.sql b/sql/update.sql index c04cd926..e69de29b 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 bf6146a2..154071e4 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.message.SIPRequest; 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 @@ public interface ISIPCommander { */ 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 6bf85db3..811637ad 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 @@ public class SIPCommander implements ISIPCommander { 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 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 c35f21b6..6eb4bc95 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.InitializingBean; 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 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In 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 3a49f441..867fcab0 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 @@ -89,12 +89,6 @@ public class MediaServerServiceImpl implements IMediaServerService { private ZLMRTPServerFactory zlmrtpServerFactory; - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IStreamProxyService streamProxyService; - @Autowired private EventPublisher publisher; @@ -288,6 +282,7 @@ public class MediaServerServiceImpl implements IMediaServerService { 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 4d167f04..8beff779 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 @@ -24,13 +24,9 @@ public class MediaServiceImpl implements IMediaService { @Autowired 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 0e9b3d17..1ced19b2 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.BigDecimal; 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 @@ public class PlayServiceImpl implements IPlayService { 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 @@ public class PlayServiceImpl implements IPlayService { 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 8fabbda6..8ab27126 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 @@ -76,12 +76,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @Autowired private PlatformGbStreamMapper platformGbStreamMapper; - @Autowired - private EventPublisher eventPublisher; - - @Autowired - private ParentPlatformMapper parentPlatformMapper; - @Autowired private IGbStreamService gbStreamService; 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 dcd89b3d..2fcc9c22 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 @@ public class PlayController { @Operation(summary = "语音广播命令") @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @GetMapping("/broadcast/{deviceId}") - @PostMapping("/broadcast/{deviceId}") - public DeferredResult> 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> broadcastApi(@PathVariable String deviceId, @PathVariable String channelId, Integer timeout) { if (logger.isDebugEnabled()) { logger.debug("语音广播API调用"); } @@ -258,13 +260,10 @@ public class PlayController { 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 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 2b44dd77..7e40720a 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 @@ public class UserController { } } } + + @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 85f83f8d..0cba21f1 100644 --- a/web_src/src/components/dialog/devicePlayer.vue +++ b/web_src/src/components/dialog/devicePlayer.vue @@ -871,76 +871,91 @@ export default { } }, 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('不支持webrtc',e) - this.$message({ - showClose: true, - message: '不支持webrtc, 无法进行语音对讲', - type: 'error' - }); - }); + 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_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;