From 827075d4b699cdd4577ef9dfce082c226f64800c Mon Sep 17 00:00:00 2001 From: iteaj Date: Fri, 30 May 2025 09:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4wvp=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- iboot-tos/pom.xml | 3 +- iboot-tos/wvp-GB28181-pro/README.MD | 2 - iboot-tos/wvp-GB28181-pro/pom.xml | 146 - .../iot/vmp/GbsWvpAutoConfiguration.java | 26 - .../iot/vmp/common/ApiSaveConstant.java | 198 - .../genersoft/iot/vmp/common/CivilCodePo.java | 42 - .../iot/vmp/common/CommonCallback.java | 5 - .../iot/vmp/common/CommonGbChannel.java | 191 - .../iot/vmp/common/GeneralCallback.java | 5 - .../genersoft/iot/vmp/common/InviteInfo.java | 144 - .../iot/vmp/common/InviteSessionStatus.java | 11 - .../iot/vmp/common/InviteSessionType.java | 7 - .../genersoft/iot/vmp/common/StreamInfo.java | 609 ---- .../genersoft/iot/vmp/common/StreamURL.java | 84 - .../iot/vmp/common/SystemAllInfo.java | 54 - .../genersoft/iot/vmp/common/VersionPo.java | 149 - .../iot/vmp/common/VideoManagerConstants.java | 168 - .../vmp/common/enums/DeviceControlType.java | 77 - .../iot/vmp/conf/CivilCodeFileConf.java | 104 - .../genersoft/iot/vmp/conf/DynamicTask.java | 158 - .../genersoft/iot/vmp/conf/MediaConfig.java | 326 -- .../iot/vmp/conf/ProxyServletConfig.java | 303 -- .../iot/vmp/conf/ScheduleConfig.java | 30 - .../com/genersoft/iot/vmp/conf/SipConfig.java | 110 - .../iot/vmp/conf/SipPlatformRunner.java | 72 - .../iot/vmp/conf/ThreadPoolTaskConfig.java | 70 - .../genersoft/iot/vmp/conf/UserSetting.java | 318 -- .../genersoft/iot/vmp/conf/WVPTimerTask.java | 33 - .../conf/exception/ControllerException.java | 37 - .../SsrcTransactionNotFoundException.java | 49 - .../vmp/conf/redis/RedisMsgListenConfig.java | 76 - .../genersoft/iot/vmp/gb28181/SipLayer.java | 141 - .../DigestServerAuthenticationHelper.java | 241 -- .../vmp/gb28181/bean/AlarmChannelMessage.java | 57 - .../iot/vmp/gb28181/bean/BaiduPoint.java | 24 - .../iot/vmp/gb28181/bean/CatalogData.java | 81 - .../iot/vmp/gb28181/bean/ChannelIdType.java | 23 - .../iot/vmp/gb28181/bean/CmdType.java | 8 - .../iot/vmp/gb28181/bean/Device.java | 480 --- .../iot/vmp/gb28181/bean/DeviceAlarm.java | 212 -- .../vmp/gb28181/bean/DeviceAlarmMethod.java | 54 - .../iot/vmp/gb28181/bean/DeviceChannel.java | 563 --- .../gb28181/bean/DeviceChannelInPlatform.java | 23 - .../vmp/gb28181/bean/DeviceNotFoundEvent.java | 27 - .../iot/vmp/gb28181/bean/DragZoomRequest.java | 143 - .../vmp/gb28181/bean/GBStringMsgParser.java | 457 --- .../iot/vmp/gb28181/bean/Gb28181Sdp.java | 46 - .../iot/vmp/gb28181/bean/GbSipDate.java | 149 - .../iot/vmp/gb28181/bean/GbStream.java | 135 - .../bean/GbStringMsgParserFactory.java | 22 - .../vmp/gb28181/bean/HandlerCatchData.java | 44 - .../vmp/gb28181/bean/HomePositionRequest.java | 94 - .../genersoft/iot/vmp/gb28181/bean/Host.java | 35 - .../gb28181/bean/InviteStreamCallback.java | 5 - .../vmp/gb28181/bean/InviteStreamInfo.java | 61 - .../vmp/gb28181/bean/InviteStreamType.java | 8 - .../iot/vmp/gb28181/bean/MobilePosition.java | 220 -- .../iot/vmp/gb28181/bean/ParentPlatform.java | 452 --- .../vmp/gb28181/bean/ParentPlatformCatch.java | 68 - .../iot/vmp/gb28181/bean/PlatformCatalog.java | 122 - .../vmp/gb28181/bean/PlatformGbStream.java | 44 - .../vmp/gb28181/bean/PlatformRegister.java | 15 - .../vmp/gb28181/bean/PresetQuerySipReq.java | 28 - .../iot/vmp/gb28181/bean/RecordInfo.java | 102 - .../iot/vmp/gb28181/bean/RecordItem.java | 144 - .../vmp/gb28181/bean/RemoteAddressInfo.java | 27 - .../iot/vmp/gb28181/bean/SDPInfo.java | 14 - .../iot/vmp/gb28181/bean/SendRtpItem.java | 295 -- .../iot/vmp/gb28181/bean/SipMsgInfo.java | 56 - .../vmp/gb28181/bean/SipTransactionInfo.java | 54 - .../iot/vmp/gb28181/bean/SsrcTransaction.java | 81 - .../iot/vmp/gb28181/bean/SubscribeHolder.java | 110 - .../iot/vmp/gb28181/bean/SubscribeInfo.java | 141 - .../iot/vmp/gb28181/bean/SyncStatus.java | 51 - .../vmp/gb28181/conf/DefaultProperties.java | 63 - .../vmp/gb28181/conf/ServerLoggerImpl.java | 91 - .../iot/vmp/gb28181/conf/StackLoggerImpl.java | 109 - .../iot/vmp/gb28181/event/EventPublisher.java | 118 - .../iot/vmp/gb28181/event/SipSubscribe.java | 180 - .../vmp/gb28181/event/alarm/AlarmEvent.java | 31 - .../event/alarm/AlarmEventListener.java | 70 - .../event/device/RequestTimeoutEvent.java | 25 - .../event/device/RequestTimeoutEventImpl.java | 39 - .../gb28181/event/record/RecordEndEvent.java | 32 - .../event/record/RecordEndEventListener.java | 67 - .../event/subscribe/catalog/CatalogEvent.java | 85 - .../subscribe/catalog/CatalogEventLister.java | 200 - .../vmp/gb28181/session/CatalogDataCatch.java | 146 - .../vmp/gb28181/session/RecordDataCatch.java | 92 - .../iot/vmp/gb28181/session/SSRCFactory.java | 125 - .../session/VideoStreamSessionManager.java | 150 - .../iot/vmp/gb28181/task/ISubscribeTask.java | 10 - .../iot/vmp/gb28181/task/SipRunner.java | 132 - .../task/impl/CatalogSubscribeTask.java | 105 - .../MobilePositionSubscribeHandlerTask.java | 44 - .../impl/MobilePositionSubscribeTask.java | 103 - .../transmit/ISIPProcessorObserver.java | 7 - .../transmit/SIPProcessorObserver.java | 205 -- .../iot/vmp/gb28181/transmit/SIPSender.java | 132 - .../callback/DeferredResultHolder.java | 160 - .../transmit/callback/RequestMessage.java | 39 - .../gb28181/transmit/cmd/ISIPCommander.java | 364 -- .../cmd/ISIPCommanderForPlatform.java | 128 - .../cmd/SIPRequestHeaderPlarformProvider.java | 316 -- .../cmd/SIPRequestHeaderProvider.java | 351 -- .../transmit/cmd/impl/SIPCommander.java | 1429 -------- .../cmd/impl/SIPCommanderFroPlatform.java | 831 ----- .../event/request/ISIPRequestProcessor.java | 14 - .../request/SIPRequestProcessorParent.java | 223 -- .../request/impl/AckRequestProcessor.java | 187 - .../request/impl/ByeRequestProcessor.java | 184 - .../request/impl/CancelRequestProcessor.java | 40 - .../request/impl/InviteRequestProcessor.java | 987 ----- .../NotifyRequestForCatalogProcessor.java | 311 -- .../request/impl/NotifyRequestProcessor.java | 397 -- .../impl/RegisterRequestProcessor.java | 238 -- .../impl/SubscribeRequestProcessor.java | 203 -- .../impl/info/InfoRequestProcessor.java | 149 - .../request/impl/message/IMessageHandler.java | 23 - .../impl/message/MessageHandlerAbstract.java | 53 - .../impl/message/MessageRequestProcessor.java | 142 - .../control/ControlMessageHandler.java | 27 - .../cmd/DeviceControlQueryMessageHandler.java | 358 -- .../message/notify/NotifyMessageHandler.java | 26 - .../notify/cmd/AlarmNotifyMessageHandler.java | 284 -- .../cmd/KeepaliveNotifyMessageHandler.java | 125 - .../cmd/MediaStatusNotifyMessageHandler.java | 136 - .../MobilePositionNotifyMessageHandler.java | 172 - .../message/query/QueryMessageHandler.java | 25 - .../query/cmd/AlarmQueryMessageHandler.java | 68 - .../query/cmd/CatalogQueryMessageHandler.java | 130 - .../cmd/DeviceInfoQueryMessageHandler.java | 85 - .../cmd/DeviceStatusQueryMessageHandler.java | 85 - .../cmd/RecordInfoQueryMessageHandler.java | 146 - .../response/ResponseMessageHandler.java | 25 - .../cmd/AlarmResponseMessageHandler.java | 58 - .../cmd/BroadcastResponseMessageHandler.java | 73 - .../cmd/CatalogResponseMessageHandler.java | 195 - .../ConfigDownloadResponseMessageHandler.java | 79 - .../DeviceConfigResponseMessageHandler.java | 58 - .../DeviceControlResponseMessageHandler.java | 71 - .../cmd/DeviceInfoResponseMessageHandler.java | 107 - .../DeviceStatusResponseMessageHandler.java | 89 - .../MobilePositionResponseMessageHandler.java | 173 - .../PresetQueryResponseMessageHandler.java | 120 - .../cmd/RecordInfoResponseMessageHandler.java | 182 - .../event/response/ISIPResponseProcessor.java | 15 - .../SIPResponseProcessorAbstract.java | 8 - .../response/impl/ByeResponseProcessor.java | 48 - .../impl/CancelResponseProcessor.java | 47 - .../impl/InviteResponseProcessor.java | 96 - .../impl/RegisterResponseProcessor.java | 113 - .../event/timeout/ITimeoutProcessor.java | 7 - .../timeout/impl/TimeoutProcessorImpl.java | 46 - .../iot/vmp/gb28181/utils/Coordtransform.java | 126 - .../iot/vmp/gb28181/utils/MessageElement.java | 17 - .../iot/vmp/gb28181/utils/NumericUtil.java | 46 - .../iot/vmp/gb28181/utils/SipUtils.java | 266 -- .../iot/vmp/gb28181/utils/XmlUtil.java | 647 ---- .../vmp/media/rtvs/RTVSGatewayController.java | 32 - .../iot/vmp/media/zlm/AssistRESTfulUtils.java | 170 - .../iot/vmp/media/zlm/SendRtpPortManager.java | 135 - .../vmp/media/zlm/ZLMHttpHookListener.java | 797 ---- .../vmp/media/zlm/ZLMMediaListManager.java | 145 - .../iot/vmp/media/zlm/ZLMRESTfulUtils.java | 401 -- .../iot/vmp/media/zlm/ZLMRunner.java | 173 - .../iot/vmp/media/zlm/ZLMServerConfig.java | 1214 ------- .../iot/vmp/media/zlm/ZLMServerFactory.java | 315 -- .../vmp/media/zlm/ZlmHttpHookSubscribe.java | 159 - .../vmp/media/zlm/dto/ChannelOnlineEvent.java | 11 - .../media/zlm/dto/HookSubscribeFactory.java | 44 - .../dto/HookSubscribeForRtpServerTimeout.java | 44 - .../dto/HookSubscribeForServerStarted.java | 44 - .../zlm/dto/HookSubscribeForStreamChange.java | 44 - .../iot/vmp/media/zlm/dto/HookType.java | 26 - .../iot/vmp/media/zlm/dto/IHookSubscribe.java | 36 - .../vmp/media/zlm/dto/MediaServerItem.java | 367 -- .../media/zlm/dto/ServerKeepaliveData.java | 4 - .../media/zlm/dto/StreamAuthorityInfo.java | 117 - .../vmp/media/zlm/dto/StreamProxyItem.java | 203 -- .../iot/vmp/media/zlm/dto/StreamPushItem.java | 273 -- .../iot/vmp/media/zlm/dto/ZLMRunInfo.java | 33 - .../iot/vmp/media/zlm/dto/hook/HookParam.java | 17 - .../vmp/media/zlm/dto/hook/HookResult.java | 40 - .../zlm/dto/hook/HookResultForOnPublish.java | 73 - .../media/zlm/dto/hook/OnPlayHookParam.java | 95 - .../zlm/dto/hook/OnPublishHookParam.java | 95 - .../dto/hook/OnRtpServerTimeoutHookParam.java | 64 - .../dto/hook/OnSendRtpStoppedHookParam.java | 35 - .../dto/hook/OnServerKeepaliveHookParam.java | 27 - .../dto/hook/OnStreamChangedHookParam.java | 508 --- .../dto/hook/OnStreamNoneReaderHookParam.java | 51 - .../dto/hook/OnStreamNotFoundHookParam.java | 95 - .../vmp/media/zlm/dto/hook/OriginType.java | 23 - .../vmp/media/zlm/event/ZLMEventAbstract.java | 25 - .../vmp/media/zlm/event/ZLMOfflineEvent.java | 11 - .../vmp/media/zlm/event/ZLMOnlineEvent.java | 11 - .../zlm/event/ZLMStatusEventListener.java | 59 - .../iot/vmp/service/IDeviceAlarmService.java | 35 - .../vmp/service/IDeviceChannelService.java | 105 - .../iot/vmp/service/IDeviceService.java | 190 - .../iot/vmp/service/IGbStreamService.java | 82 - .../iot/vmp/service/IInviteStreamService.java | 86 - .../iot/vmp/service/IMediaServerService.java | 109 - .../iot/vmp/service/IMediaService.java | 44 - .../vmp/service/IPlatformChannelService.java | 29 - .../iot/vmp/service/IPlatformService.java | 60 - .../iot/vmp/service/IPlayService.java | 48 - .../iot/vmp/service/IStreamProxyService.java | 116 - .../iot/vmp/service/IStreamPushService.java | 120 - .../iot/vmp/service/bean/ErrorCallback.java | 6 - .../iot/vmp/service/bean/GPSMsgInfo.java | 106 - .../iot/vmp/service/bean/InviteErrorCode.java | 37 - .../service/bean/InviteTimeOutCallback.java | 6 - .../iot/vmp/service/bean/MediaServerLoad.java | 50 - .../service/bean/MessageForPushChannel.java | 142 - .../bean/MessageForPushChannelResponse.java | 71 - .../vmp/service/bean/PlayBackCallback.java | 7 - .../iot/vmp/service/bean/PlayBackResult.java | 69 - .../PushStreamStatusChangeFromRedisDto.java | 41 - .../service/bean/RequestPushStreamMsg.java | 170 - .../vmp/service/bean/RequestSendItemMsg.java | 188 - .../vmp/service/bean/ResponseSendItemMsg.java | 31 - .../iot/vmp/service/bean/SSRCInfo.java | 42 - .../service/bean/StreamPushItemFromRedis.java | 34 - .../iot/vmp/service/bean/ThirdPartyGB.java | 23 - .../iot/vmp/service/bean/WvpRedisMsg.java | 116 - .../iot/vmp/service/bean/WvpRedisMsgCmd.java | 12 - .../service/impl/DeviceAlarmServiceImpl.java | 36 - .../impl/DeviceChannelServiceImpl.java | 294 -- .../vmp/service/impl/DeviceServiceImpl.java | 650 ---- .../vmp/service/impl/GbStreamServiceImpl.java | 291 -- .../service/impl/InviteStreamServiceImpl.java | 267 -- .../service/impl/MediaServerServiceImpl.java | 863 ----- .../vmp/service/impl/MediaServiceImpl.java | 113 - .../impl/PlatformChannelServiceImpl.java | 177 - .../vmp/service/impl/PlatformServiceImpl.java | 423 --- .../iot/vmp/service/impl/PlayServiceImpl.java | 1011 ------ .../service/impl/StreamProxyServiceImpl.java | 580 --- .../service/impl/StreamPushServiceImpl.java | 546 --- .../redisMsg/RedisAlarmMsgListener.java | 150 - .../redisMsg/RedisCloseStreamMsgListener.java | 59 - .../redisMsg/RedisGbPlayMsgListener.java | 421 --- .../service/redisMsg/RedisGpsMsgListener.java | 78 - .../RedisPushStreamCloseResponseListener.java | 120 - .../RedisPushStreamResponseListener.java | 76 - .../RedisPushStreamStatusListMsgListener.java | 105 - .../RedisPushStreamStatusMsgListener.java | 107 - .../redisMsg/RedisStreamMsgListener.java | 92 - .../iot/vmp/storager/IRedisCatchStorage.java | 201 - .../vmp/storager/IVideoManagerStorage.java | 370 -- .../vmp/storager/dao/DeviceAlarmMapper.java | 20 - .../vmp/storager/dao/DeviceChannelMapper.java | 82 - .../iot/vmp/storager/dao/DeviceMapper.java | 21 - .../dao/DeviceMobilePositionMapper.java | 10 - .../iot/vmp/storager/dao/GbStreamMapper.java | 50 - .../storager/dao/MediaServerItemMapper.java | 11 - .../storager/dao/ParentPlatformMapper.java | 34 - .../storager/dao/PlatformCatalogMapper.java | 31 - .../storager/dao/PlatformChannelMapper.java | 50 - .../storager/dao/PlatformGbStreamMapper.java | 39 - .../vmp/storager/dao/StreamProxyMapper.java | 35 - .../vmp/storager/dao/StreamPushMapper.java | 53 - .../storager/dao/dto/ChannelSourceInfo.java | 22 - .../dao/dto/PlatformRegisterInfo.java | 41 - .../iot/vmp/storager/dao/dto/RecordInfo.java | 133 - .../storager/impl/RedisCatchStorageImpl.java | 579 --- .../impl/VideoManagerStorageImpl.java | 1066 ------ .../vmp/task/StreamProxyScheduledTask.java | 72 - .../iot/vmp/utils/Coordtransform.java | 126 - .../com/genersoft/iot/vmp/utils/DateUtil.java | 120 - .../com/genersoft/iot/vmp/utils/GitUtil.java | 58 - .../com/genersoft/iot/vmp/utils/GpsUtil.java | 41 - .../com/genersoft/iot/vmp/utils/JsonUtil.java | 34 - .../iot/vmp/utils/SpringBeanFactory.java | 50 - .../com/genersoft/iot/vmp/utils/UJson.java | 150 - .../utils/redis/FastJsonRedisSerializer.java | 45 - .../iot/vmp/utils/redis/RedisUtil.java | 47 - .../iot/vmp/vmanager/bean/BaseTree.java | 87 - .../vmp/vmanager/bean/BatchGBStreamParam.java | 23 - .../vmp/vmanager/bean/DeferredResultEx.java | 31 - .../vmanager/bean/DeferredResultFilter.java | 6 - .../iot/vmp/vmanager/bean/ErrorCode.java | 30 - .../vmp/vmanager/bean/OtherPsSendInfo.java | 137 - .../vmp/vmanager/bean/OtherRtpSendInfo.java | 166 - .../iot/vmp/vmanager/bean/PageInfo.java | 99 - .../iot/vmp/vmanager/bean/PlayTypeEnum.java | 23 - .../iot/vmp/vmanager/bean/RecordFile.java | 53 - .../vmp/vmanager/bean/ResourceBaseInfo.java | 30 - .../iot/vmp/vmanager/bean/ResourceInfo.java | 41 - .../iot/vmp/vmanager/bean/SnapPath.java | 50 - .../iot/vmp/vmanager/bean/StreamContent.java | 414 --- .../vmp/vmanager/bean/SystemConfigInfo.java | 46 - .../iot/vmp/vmanager/bean/WVPResult.java | 75 - .../cloudRecord/CloudRecordController.java | 145 - .../MobilePositionController.java | 177 - .../gb28181/alarm/AlarmController.java | 151 - .../vmanager/gb28181/device/DeviceConfig.java | 156 - .../gb28181/device/DeviceControl.java | 401 -- .../device/GbsDeviceManagerController.java | 509 --- .../gb28181/gbStream/GbStreamController.java | 110 - .../gb28181/gbStream/bean/GbStreamParam.java | 54 - .../gb28181/media/MediaController.java | 118 - .../gb28181/platform/PlatformController.java | 553 --- .../gb28181/platform/bean/ChannelReduce.java | 146 - .../platform/bean/UpdateChannelParam.java | 57 - .../vmanager/gb28181/play/PlayController.java | 392 -- .../gb28181/play/bean/PlayResult.java | 39 - .../gb28181/playback/PlaybackController.java | 226 -- .../vmanager/gb28181/ptz/PtzController.java | 179 - .../gb28181/record/GBRecordController.java | 207 -- .../vmanager/gb28181/sse/SseController.java | 55 - .../iot/vmp/vmanager/ps/PsController.java | 322 -- .../iot/vmp/vmanager/rtp/RtpController.java | 379 -- .../vmp/vmanager/server/ServerController.java | 248 -- .../streamProxy/StreamProxyController.java | 182 - .../streamPush/StreamPushController.java | 272 -- .../vmp/web/gb28181/ApiControlController.java | 155 - .../vmp/web/gb28181/ApiDeviceController.java | 241 -- .../vmp/web/gb28181/ApiStreamController.java | 250 -- .../web/gb28181/dto/DeviceChannelExtend.java | 555 --- .../src/main/resources/application-docker.yml | 79 - .../src/main/resources/application-wvp.yml | 170 - .../src/main/resources/civilCode.csv | 3220 ----------------- .../src/main/resources/logback-wvp.xml | 73 - .../mapper/wvp/DeviceAlarmMapper.xml | 43 - .../mapper/wvp/DeviceChannelMapper.xml | 285 -- .../resources/mapper/wvp/DeviceMapper.xml | 75 - .../mapper/wvp/DeviceMobilePositionMapper.xml | 27 - .../resources/mapper/wvp/GbStreamMapper.xml | 107 - .../mapper/wvp/MediaServerItemMapper.xml | 51 - .../mapper/wvp/ParentPlatformMapper.xml | 64 - .../mapper/wvp/PlatformCatalogMapper.xml | 59 - .../mapper/wvp/PlatformChannelMapper.xml | 112 - .../mapper/wvp/PlatformStreamMapper.xml | 81 - .../mapper/wvp/StreamProxyMapper.xml | 81 - .../resources/mapper/wvp/StreamPushMapper.xml | 141 - 337 files changed, 1 insertion(+), 52771 deletions(-) delete mode 100644 iboot-tos/wvp-GB28181-pro/README.MD delete mode 100644 iboot-tos/wvp-GB28181-pro/pom.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/GbsWvpAutoConfiguration.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/ApiSaveConstant.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CivilCodePo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CommonCallback.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CommonGbChannel.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/GeneralCallback.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteSessionStatus.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteSessionType.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/StreamURL.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/VersionPo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/enums/DeviceControlType.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/exception/ControllerException.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisMsgListenConfig.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/BaiduPoint.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ChannelIdType.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CmdType.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannelInPlatform.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceNotFoundEvent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DragZoomRequest.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GBStringMsgParser.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Gb28181Sdp.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbSipDate.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStringMsgParserFactory.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/HandlerCatchData.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/HomePositionRequest.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Host.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamCallback.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformRegister.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordItem.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RemoteAddressInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SDPInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipMsgInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipTransactionInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SyncStatus.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/ServerLoggerImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/SSRCFactory.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/ISIPProcessorObserver.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/ISIPRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/CancelRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/IMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/ControlMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/NotifyMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/QueryMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/ResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/ISIPResponseProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/SIPResponseProcessorAbstract.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/ByeResponseProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/CancelResponseProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/ITimeoutProcessor.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/impl/TimeoutProcessorImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/Coordtransform.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/MessageElement.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/rtvs/RTVSGatewayController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerFactory.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForRtpServerTimeout.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForServerStarted.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamChange.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookType.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/IHookSubscribe.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaServerItem.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ServerKeepaliveData.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamAuthorityInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ZLMRunInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookResult.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookResultForOnPublish.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPlayHookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPublishHookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRtpServerTimeoutHookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnSendRtpStoppedHookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnServerKeepaliveHookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamChangedHookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNoneReaderHookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNotFoundHookParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OriginType.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMEventAbstract.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOfflineEvent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOnlineEvent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceAlarmService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ErrorCallback.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/GPSMsgInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/InviteErrorCode.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/InviteTimeOutCallback.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MediaServerLoad.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannelResponse.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackCallback.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackResult.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PushStreamStatusChangeFromRedisDto.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/RequestPushStreamMsg.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/RequestSendItemMsg.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ResponseSendItemMsg.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/SSRCInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/StreamPushItemFromRedis.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ThirdPartyGB.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/WvpRedisMsg.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/WvpRedisMsgCmd.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisCloseStreamMsgListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamCloseResponseListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMobilePositionMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerItemMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/ChannelSourceInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/PlatformRegisterInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/RecordInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/task/StreamProxyScheduledTask.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/Coordtransform.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/GpsUtil.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/JsonUtil.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/UJson.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/redis/FastJsonRedisSerializer.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/BaseTree.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/BatchGBStreamParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultEx.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultFilter.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ErrorCode.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/OtherPsSendInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/OtherRtpSendInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PlayTypeEnum.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/RecordFile.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaseInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/SnapPath.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamContent.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/SystemConfigInfo.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/GbsDeviceManagerController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/bean/PlayResult.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/sse/SseController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/ps/PsController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/rtp/RtpController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/application-docker.yml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/application-wvp.yml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/civilCode.csv delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/logback-wvp.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceAlarmMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceChannelMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceMobilePositionMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/GbStreamMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/MediaServerItemMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/ParentPlatformMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformCatalogMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformChannelMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformStreamMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/StreamProxyMapper.xml delete mode 100644 iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/StreamPushMapper.xml diff --git a/iboot-tos/pom.xml b/iboot-tos/pom.xml index 9d057836..88761193 100644 --- a/iboot-tos/pom.xml +++ b/iboot-tos/pom.xml @@ -11,8 +11,7 @@ pom - - wvp-GB28181-pro + iboot:tos diff --git a/iboot-tos/wvp-GB28181-pro/README.MD b/iboot-tos/wvp-GB28181-pro/README.MD deleted file mode 100644 index ce6d1547..00000000 --- a/iboot-tos/wvp-GB28181-pro/README.MD +++ /dev/null @@ -1,2 +0,0 @@ -* 同步时间[2023/12/13] -* gb28181项目是基于[wvp-GB28181-pro]修改而来. 感谢开源作者[https://gitee.com/pan648540858/wvp-GB28181-pro] diff --git a/iboot-tos/wvp-GB28181-pro/pom.xml b/iboot-tos/wvp-GB28181-pro/pom.xml deleted file mode 100644 index 1e5ec4b6..00000000 --- a/iboot-tos/wvp-GB28181-pro/pom.xml +++ /dev/null @@ -1,146 +0,0 @@ - - - - com.iteaj - ${reversion} - iboot-tos - - - 4.0.0 - wvp-GB28181-pro - - gb28181项目是基于[wvp-GB28181-pro]修改而来. 感谢开源作者[https://gitee.com/pan648540858/wvp-GB28181-pro] - - - - - org.slf4j - log4j-over-slf4j - - - - org.springframework.boot - spring-boot-starter-data-redis - - - org.springframework.boot - spring-boot-starter-web - - - true - org.springframework.boot - spring-boot-configuration-processor - - - - - org.springdoc - springdoc-openapi-ui - 1.6.10 - - - - - javax.validation - validation-api - - - - - org.springframework.boot - spring-boot-starter-aop - - - - - javax.sip - jain-sip-ri - 1.3.0-91 - - - - - org.dom4j - dom4j - 2.1.3 - - - - com.google.guava - guava - 20.0 - - - - - com.alibaba.fastjson2 - fastjson2 - 2.0.17 - - - com.alibaba.fastjson2 - fastjson2-extension - 2.0.17 - - - - - com.squareup.okhttp3 - okhttp - 4.10.0 - - - - - com.squareup.okhttp3 - logging-interceptor - 4.10.0 - - - - - io.github.rburgst - okhttp-digest - 2.7 - - - - - - - - - - - - org.bitbucket.b_c - jose4j - 0.9.3 - - - - - org.mitre.dsmiley.httpproxy - smiley-http-proxy-servlet - 1.12.1 - - - - - - - - - - - - - com.google.guava - guava - 31.1-jre - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/GbsWvpAutoConfiguration.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/GbsWvpAutoConfiguration.java deleted file mode 100644 index a27cbfac..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/GbsWvpAutoConfiguration.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.genersoft.iot.vmp; - -import com.genersoft.iot.vmp.conf.MediaConfig; -import com.iteaj.framework.security.OrderFilterChainDefinition; -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.context.properties.EnableConfigurationProperties; -import org.springframework.boot.web.servlet.ServletComponentScan; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.core.annotation.Order; - -@ComponentScan({"com.genersoft.iot.vmp"}) -@ServletComponentScan("com.genersoft.iot.vmp.conf") -@MapperScan("com.genersoft.iot.vmp.storager.dao") -@EnableConfigurationProperties(MediaConfig.class) -public class GbsWvpAutoConfiguration { - - /** - * @return - */ - @Bean - @Order(value = 18) - public OrderFilterChainDefinition gbsFilterChainDefinition() { - return new OrderFilterChainDefinition().addAnon("/gbs/zlm/hook/**"); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/ApiSaveConstant.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/ApiSaveConstant.java deleted file mode 100644 index ed1c2b9b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/ApiSaveConstant.java +++ /dev/null @@ -1,198 +0,0 @@ -package com.genersoft.iot.vmp.common; - -/** - * 为API重命名, 方便向数据库记录数据的时候展示 - * @author lin - */ -public class ApiSaveConstant { - - public static String getVal(String key) { - String[] keyItemArray = key.split("/"); - if (keyItemArray.length <= 1 || !"api".equals(keyItemArray[1])) { - return null; - } - if (keyItemArray.length >= 4) { - switch (keyItemArray[2]) { - case "alarm": - if ("delete".equals(keyItemArray[3])) { - return "删除报警"; - } - break; - case "device": - switch (keyItemArray[3]) { - case "config": - if (keyItemArray.length >= 5 && "basicParam".equals(keyItemArray[4])) { - return "[设备配置] 基本配置设置命令"; - } - break; - case "control": - switch (keyItemArray[4]) { - case "teleboot": - return "[设备控制] 远程启动"; - case "record": - return "[设备控制] 录像控制"; - case "guard": - return "[设备控制] 布防/撤防命令"; - case "reset_alarm": - return "[设备控制] 报警复位"; - case "i_frame": - return "[设备控制] 强制关键帧"; - case "home_position": - return "[设备控制] 看守位控制"; - default: - return ""; - } - case "query": - if (keyItemArray.length <= 5) { - return null; - } - switch (keyItemArray[4]) { - case "devices": - if (keyItemArray.length < 7) { - return null; - } - switch (keyItemArray[6]) { - case "sync": - return "[设备查询] 同步设备通道"; - case "delete": - return "[设备查询] 移除设备"; - default: - return ""; - } - case "channel": - return "[设备查询] 更新通道信息"; - case "transport": - return "[设备查询] 修改数据流传输模式"; - default: - return ""; - } - default: - return ""; - } - - break; - case "gbStream": - switch (keyItemArray[3]) { - case "del": - return "移除通道与国标的关联"; - case "add": - return "添加通道与国标的关联"; - default: - return ""; - } - case "media": - break; - case "position": - if ("subscribe".equals(keyItemArray[3])) { - return "订阅位置信息"; - } - break; - case "platform": - switch (keyItemArray[3]) { - case "save": - return "添加上级平台"; - case "delete": - return "移除上级平台"; - case "update_channel_for_gb": - return "向上级平台添加国标通道"; - case "del_channel_for_gb": - return "从上级平台移除国标通道"; - default: - return ""; - } - case "platform_gb_stream": - break; - case "play": - switch (keyItemArray[3]) { - case "start": - return "开始点播"; - case "stop": - return "停止点播"; - case "convert": - return "转码"; - case "convertStop": - return "结束转码"; - case "broadcast": - return "语音广播"; - default: - return ""; - } - case "download": - switch (keyItemArray[3]) { - case "start": - return "开始历史媒体下载"; - case "stop": - return "停止历史媒体下载"; - default: - return ""; - } - case "playback": - switch (keyItemArray[3]) { - case "start": - return "开始视频回放"; - case "stop": - return "停止视频回放"; - default: - return ""; - } - case "ptz": - switch (keyItemArray[3]) { - case "control": - return "云台控制"; - case "front_end_command": - return "通用前端控制命令"; - default: - return ""; - } - case "gb_record": - break; - case "onvif": - break; - case "server": - if ("restart".equals(keyItemArray[3])) { - return "重启流媒体服务"; - } - break; - case "proxy": - switch (keyItemArray[3]) { - case "save": - return "保存代理"; - case "del": - return "移除代理"; - case "start": - return "启用代理"; - case "stop": - return "停用代理"; - default: - return ""; - } - case "push": - switch (keyItemArray[3]) { - case "save_to_gb": - return "将推流添加到国标"; - case "remove_form_gb": - return "将推流移出到国标"; - default: - return ""; - } - case "user": - switch (keyItemArray[3]) { - case "login": - return "登录"; - case "changePassword": - return "修改密码"; - case "add": - return "添加用户"; - case "delete": - return "删除用户"; - default: - return ""; - } - default: - return ""; - } - } - return null; - } -} - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CivilCodePo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CivilCodePo.java deleted file mode 100644 index 452c12ef..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CivilCodePo.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.genersoft.iot.vmp.common; - -public class CivilCodePo { - - private String code; - - private String name; - - private String parentCode; - - public static CivilCodePo getInstance(String[] infoArray) { - CivilCodePo civilCodePo = new CivilCodePo(); - civilCodePo.setCode(infoArray[0]); - civilCodePo.setName(infoArray[1]); - civilCodePo.setParentCode(infoArray[2]); - return civilCodePo; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getParentCode() { - return parentCode; - } - - public void setParentCode(String parentCode) { - this.parentCode = parentCode; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CommonCallback.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CommonCallback.java deleted file mode 100644 index 819fe0dd..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CommonCallback.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.genersoft.iot.vmp.common; - -public interface CommonCallback{ - public void run(T t); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CommonGbChannel.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CommonGbChannel.java deleted file mode 100644 index b289a14a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/CommonGbChannel.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.genersoft.iot.vmp.common; - -import io.swagger.v3.oas.annotations.media.Schema; - -public class CommonGbChannel { - - /** - * 国标字段:归属 - */ - @Schema(description = "归属") - private String owner; - - /** - * 国标字段:行政区划 - */ - @Schema(description = "行政区划") - private String civilCode; - - /** - * 国标字段:安装地址 - */ - @Schema(description = "安装地址") - private String address; - - /** - * 国标字段:经度 - */ - @Schema(description = "经度") - private Double longitude; - - /** - * 国标字段:纬度 - */ - @Schema(description = "纬度") - private Double latitude; - - /** - * 国标字段:摄像机类型: - * 1-球机; - * 2-半球; - * 3-固定枪机; - * 4-遥控枪机 - */ - @Schema(description = "摄像机类型") - private Integer ptzType; - - /** - * 国标字段:摄像机位置类型扩展。 - * 1-省际检查站、 - * 2-党政机关、 - * 3-车站码头、 - * 4-中心广场、 - * 5-体育场馆、 - * 6-商业中心、 - * 7-宗教场所、 - * 8-校园周边、 - * 9-治安复杂区域、 - * 10-交通干线 - */ - @Schema(description = "摄像机位置类型扩展") - private Integer positionType; - - /** - * 国标字段:安装位置室外、室内属性 - * 1-室外、 - * 2-室内 - */ - @Schema(description = "安装位置室外、室内属性") - private Integer roomType; - - /** - * 国标字段:用途 - * 1-治安、 - * 2-交通、 - * 3-重点、 - */ - @Schema(description = "用途") - private Integer useType; - - /** - * 国标字段:补光属性 - * 1-无补光、 - * 2-红外补光、 - * 3-白光补光 - */ - @Schema(description = "补光属性") - private Integer supplyLightType; - - /** - * 摄像机监视方位属性。 - * 1-东、 - * 2-西、 - * 3-南、 - * 4-北、 - * 5-东南、 - * 6-东北、 - * 7-西南、 - * 8-西北 - * - */ - @Schema(description = "方位") - private Integer directionType; - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getCivilCode() { - return civilCode; - } - - public void setCivilCode(String civilCode) { - this.civilCode = civilCode; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public Double getLongitude() { - return longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - public Double getLatitude() { - return latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - - public Integer getPtzType() { - return ptzType; - } - - public void setPtzType(Integer ptzType) { - this.ptzType = ptzType; - } - - public Integer getPositionType() { - return positionType; - } - - public void setPositionType(Integer positionType) { - this.positionType = positionType; - } - - public Integer getRoomType() { - return roomType; - } - - public void setRoomType(Integer roomType) { - this.roomType = roomType; - } - - public Integer getUseType() { - return useType; - } - - public void setUseType(Integer useType) { - this.useType = useType; - } - - public Integer getSupplyLightType() { - return supplyLightType; - } - - public void setSupplyLightType(Integer supplyLightType) { - this.supplyLightType = supplyLightType; - } - - public Integer getDirectionType() { - return directionType; - } - - public void setDirectionType(Integer directionType) { - this.directionType = directionType; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/GeneralCallback.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/GeneralCallback.java deleted file mode 100644 index df07fac5..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/GeneralCallback.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.genersoft.iot.vmp.common; - -public interface GeneralCallback{ - void run(int code, String msg, T data); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteInfo.java deleted file mode 100644 index dabdb4f0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteInfo.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.genersoft.iot.vmp.common; - -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * 记录每次发送invite消息的状态 - */ -public class InviteInfo { - - private String deviceId; - - private String channelId; - - private String stream; - - private SSRCInfo ssrcInfo; - - private String receiveIp; - - private Integer receivePort; - - private String streamMode; - - private InviteSessionType type; - - private InviteSessionStatus status; - - private StreamInfo streamInfo; - - - public static InviteInfo getInviteInfo(String deviceId, String channelId, String stream, SSRCInfo ssrcInfo, - String receiveIp, Integer receivePort, String streamMode, - InviteSessionType type, InviteSessionStatus status) { - InviteInfo inviteInfo = new InviteInfo(); - inviteInfo.setDeviceId(deviceId); - inviteInfo.setChannelId(channelId); - inviteInfo.setStream(stream); - inviteInfo.setSsrcInfo(ssrcInfo); - inviteInfo.setReceiveIp(receiveIp); - inviteInfo.setReceivePort(receivePort); - inviteInfo.setStreamMode(streamMode); - inviteInfo.setType(type); - inviteInfo.setStatus(status); - return inviteInfo; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public InviteSessionType getType() { - return type; - } - - public void setType(InviteSessionType type) { - this.type = type; - } - - public InviteSessionStatus getStatus() { - return status; - } - - public void setStatus(InviteSessionStatus status) { - this.status = status; - } - - public StreamInfo getStreamInfo() { - return streamInfo; - } - - public void setStreamInfo(StreamInfo streamInfo) { - this.streamInfo = streamInfo; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public SSRCInfo getSsrcInfo() { - return ssrcInfo; - } - - public void setSsrcInfo(SSRCInfo ssrcInfo) { - this.ssrcInfo = ssrcInfo; - } - - public String getReceiveIp() { - return receiveIp; - } - - public void setReceiveIp(String receiveIp) { - this.receiveIp = receiveIp; - } - - public Integer getReceivePort() { - return receivePort; - } - - public void setReceivePort(Integer receivePort) { - this.receivePort = receivePort; - } - - public String getStreamMode() { - return streamMode; - } - - public void setStreamMode(String streamMode) { - this.streamMode = streamMode; - } - - - /*=========================设备主子码流逻辑START====================*/ - @Schema(description = "是否为子码流(true-是,false-主码流)") - private boolean subStream; - - public boolean isSubStream() { - return subStream; - } - - public void setSubStream(boolean subStream) { - this.subStream = subStream; - } - - - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteSessionStatus.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteSessionStatus.java deleted file mode 100644 index 04cc7c91..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteSessionStatus.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.genersoft.iot.vmp.common; - -/** - * 标识invite消息发出后的各个状态, - * 收到ok钱停止invite发送cancel, - * 收到200ok后发送BYE停止invite - */ -public enum InviteSessionStatus { - ready, - ok, -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteSessionType.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteSessionType.java deleted file mode 100644 index 5a6eb85b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/InviteSessionType.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.genersoft.iot.vmp.common; - -public enum InviteSessionType { - PLAY, - PLAYBACK, - DOWNLOAD -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java deleted file mode 100644 index 70718c7a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java +++ /dev/null @@ -1,609 +0,0 @@ -package com.genersoft.iot.vmp.common; - -import io.swagger.v3.oas.annotations.media.Schema; - -import java.io.Serializable; -import java.util.Objects; - -@Schema(description = "流信息") -public class StreamInfo implements Serializable, Cloneable{ - - @Schema(description = "应用名") - private String app; - @Schema(description = "流ID") - private String stream; - @Schema(description = "设备编号") - private String deviceID; - @Schema(description = "通道编号") - private String channelId; - - @Schema(description = "IP") - private String ip; - - @Schema(description = "HTTP-FLV流地址") - private StreamURL flv; - - @Schema(description = "HTTPS-FLV流地址") - private StreamURL https_flv; - @Schema(description = "Websocket-FLV流地址") - private StreamURL ws_flv; - @Schema(description = "Websockets-FLV流地址") - private StreamURL wss_flv; - @Schema(description = "HTTP-FMP4流地址") - private StreamURL fmp4; - @Schema(description = "HTTPS-FMP4流地址") - private StreamURL https_fmp4; - @Schema(description = "Websocket-FMP4流地址") - private StreamURL ws_fmp4; - @Schema(description = "Websockets-FMP4流地址") - private StreamURL wss_fmp4; - @Schema(description = "HLS流地址") - private StreamURL hls; - @Schema(description = "HTTPS-HLS流地址") - private StreamURL https_hls; - @Schema(description = "Websocket-HLS流地址") - private StreamURL ws_hls; - @Schema(description = "Websockets-HLS流地址") - private StreamURL wss_hls; - @Schema(description = "HTTP-TS流地址") - private StreamURL ts; - @Schema(description = "HTTPS-TS流地址") - private StreamURL https_ts; - @Schema(description = "Websocket-TS流地址") - private StreamURL ws_ts; - @Schema(description = "Websockets-TS流地址") - private StreamURL wss_ts; - @Schema(description = "RTMP流地址") - private StreamURL rtmp; - @Schema(description = "RTMPS流地址") - private StreamURL rtmps; - @Schema(description = "RTSP流地址") - private StreamURL rtsp; - @Schema(description = "RTSPS流地址") - private StreamURL rtsps; - @Schema(description = "RTC流地址") - private StreamURL rtc; - - @Schema(description = "RTCS流地址") - private StreamURL rtcs; - @Schema(description = "流媒体ID") - private String mediaServerId; - @Schema(description = "流编码信息") - private Object tracks; - @Schema(description = "开始时间") - private String startTime; - @Schema(description = "结束时间") - private String endTime; - @Schema(description = "进度(录像下载使用)") - private double progress; - - @Schema(description = "是否暂停(录像回放使用)") - private boolean pause; - - public void setFlv(StreamURL flv) { - this.flv = flv; - } - - public void setHttps_flv(StreamURL https_flv) { - this.https_flv = https_flv; - } - - public void setWs_flv(StreamURL ws_flv) { - this.ws_flv = ws_flv; - } - - public void setWss_flv(StreamURL wss_flv) { - this.wss_flv = wss_flv; - } - - public void setFmp4(StreamURL fmp4) { - this.fmp4 = fmp4; - } - - public void setHttps_fmp4(StreamURL https_fmp4) { - this.https_fmp4 = https_fmp4; - } - - public void setWs_fmp4(StreamURL ws_fmp4) { - this.ws_fmp4 = ws_fmp4; - } - - public void setWss_fmp4(StreamURL wss_fmp4) { - this.wss_fmp4 = wss_fmp4; - } - - public void setHls(StreamURL hls) { - this.hls = hls; - } - - public void setHttps_hls(StreamURL https_hls) { - this.https_hls = https_hls; - } - - public void setWs_hls(StreamURL ws_hls) { - this.ws_hls = ws_hls; - } - - public void setWss_hls(StreamURL wss_hls) { - this.wss_hls = wss_hls; - } - - public void setTs(StreamURL ts) { - this.ts = ts; - } - - public void setHttps_ts(StreamURL https_ts) { - this.https_ts = https_ts; - } - - public void setWs_ts(StreamURL ws_ts) { - this.ws_ts = ws_ts; - } - - public void setWss_ts(StreamURL wss_ts) { - this.wss_ts = wss_ts; - } - - public void setRtmp(StreamURL rtmp) { - this.rtmp = rtmp; - } - - public void setRtmps(StreamURL rtmps) { - this.rtmps = rtmps; - } - - public void setRtsp(StreamURL rtsp) { - this.rtsp = rtsp; - } - - public void setRtsps(StreamURL rtsps) { - this.rtsps = rtsps; - } - - public void setRtc(StreamURL rtc) { - this.rtc = rtc; - } - - public void setRtcs(StreamURL rtcs) { - this.rtcs = rtcs; - } - - public void setRtmp(String host, int port, int sslPort, String app, String stream, String callIdParam) { - String file = String.format("%s/%s%s", app, stream, callIdParam); - if (port > 0) { - this.rtmp = new StreamURL("rtmp", host, port, file); - } - if (sslPort > 0) { - this.rtmps = new StreamURL("rtmps", host, sslPort, file); - } - } - - public void setRtsp(String host, int port, int sslPort, String app, String stream, String callIdParam) { - String file = String.format("%s/%s%s", app, stream, callIdParam); - if (port > 0) { - this.rtsp = new StreamURL("rtsp", host, port, file); - } - if (sslPort > 0) { - this.rtsps = new StreamURL("rtsps", host, sslPort, file); - } - } - - public void setFlv(String host, int port, int sslPort, String app, String stream, String callIdParam) { - String file = String.format("%s/%s.live.flv%s", app, stream, callIdParam); - if (port > 0) { - this.flv = new StreamURL("http", host, port, file); - } - this.ws_flv = new StreamURL("ws", host, port, file); - if (sslPort > 0) { - this.https_flv = new StreamURL("https", host, sslPort, file); - this.wss_flv = new StreamURL("wss", host, sslPort, file); - } - } - - public void setFmp4(String host, int port, int sslPort, String app, String stream, String callIdParam) { - String file = String.format("%s/%s.live.mp4%s", app, stream, callIdParam); - if (port > 0) { - this.fmp4 = new StreamURL("http", host, port, file); - this.ws_fmp4 = new StreamURL("ws", host, port, file); - } - if (sslPort > 0) { - this.https_fmp4 = new StreamURL("https", host, sslPort, file); - this.wss_fmp4 = new StreamURL("wss", host, sslPort, file); - } - } - - public void setHls(String host, int port, int sslPort, String app, String stream, String callIdParam) { - String file = String.format("%s/%s/hls.m3u8%s", app, stream, callIdParam); - if (port > 0) { - this.hls = new StreamURL("http", host, port, file); - this.ws_hls = new StreamURL("ws", host, port, file); - } - if (sslPort > 0) { - this.https_hls = new StreamURL("https", host, sslPort, file); - this.wss_hls = new StreamURL("wss", host, sslPort, file); - } - } - - public void setTs(String host, int port, int sslPort, String app, String stream, String callIdParam) { - String file = String.format("%s/%s.live.ts%s", app, stream, callIdParam); - - if (port > 0) { - this.ts = new StreamURL("http", host, port, file); - this.ws_ts = new StreamURL("ws", host, port, file); - } - if (sslPort > 0) { - this.https_ts = new StreamURL("https", host, sslPort, file); - this.wss_ts = new StreamURL("wss", host, sslPort, file); - } - } - - public void setRtc(String host, int port, int sslPort, String app, String stream, String callIdParam) { - if (callIdParam != null) { - callIdParam = Objects.equals(callIdParam, "") ? callIdParam : callIdParam.replace("?", "&"); - } - String file = String.format("index/api/webrtc?app=%s&stream=%s&type=play%s", app, stream, callIdParam); - if (port > 0) { - this.rtc = new StreamURL("http", host, port, file); - } - if (sslPort > 0) { - this.rtcs = new StreamURL("https", host, sslPort, file); - } - } - - public void channgeStreamIp(String localAddr) { - if (this.flv != null) { - this.flv.setHost(localAddr); - } - if (this.ws_flv != null ){ - this.ws_flv.setHost(localAddr); - } - if (this.hls != null ) { - this.hls.setHost(localAddr); - } - if (this.ws_hls != null ) { - this.ws_hls.setHost(localAddr); - } - if (this.ts != null ) { - this.ts.setHost(localAddr); - } - if (this.ws_ts != null ) { - this.ws_ts.setHost(localAddr); - } - if (this.fmp4 != null ) { - this.fmp4.setHost(localAddr); - } - if (this.ws_fmp4 != null ) { - this.ws_fmp4.setHost(localAddr); - } - if (this.rtc != null ) { - this.rtc.setHost(localAddr); - } - if (this.https_flv != null) { - this.https_flv.setHost(localAddr); - } - if (this.wss_flv != null) { - this.wss_flv.setHost(localAddr); - } - if (this.https_hls != null) { - this.https_hls.setHost(localAddr); - } - if (this.wss_hls != null) { - this.wss_hls.setHost(localAddr); - } - if (this.wss_ts != null) { - this.wss_ts.setHost(localAddr); - } - if (this.https_fmp4 != null) { - this.https_fmp4.setHost(localAddr); - } - if (this.wss_fmp4 != null) { - this.wss_fmp4.setHost(localAddr); - } - if (this.rtcs != null) { - this.rtcs.setHost(localAddr); - } - if (this.rtsp != null) { - this.rtsp.setHost(localAddr); - } - if (this.rtsps != null) { - this.rtsps.setHost(localAddr); - } - if (this.rtmp != null) { - this.rtmp.setHost(localAddr); - } - if (this.rtmps != null) { - this.rtmps.setHost(localAddr); - } - } - - - public static class TransactionInfo{ - public String callId; - public String localTag; - public String remoteTag; - public String branch; - } - - private TransactionInfo transactionInfo; - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getDeviceID() { - return deviceID; - } - - public void setDeviceID(String deviceID) { - this.deviceID = deviceID; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public StreamURL getFlv() { - return flv; - } - - public StreamURL getHttps_flv() { - return https_flv; - } - - public StreamURL getWs_flv() { - return ws_flv; - } - - - public StreamURL getWss_flv() { - return wss_flv; - } - - public StreamURL getFmp4() { - return fmp4; - } - - - - public StreamURL getHttps_fmp4() { - return https_fmp4; - } - - public StreamURL getWs_fmp4() { - return ws_fmp4; - } - - public StreamURL getWss_fmp4() { - return wss_fmp4; - } - - public StreamURL getHls() { - return hls; - } - - - public StreamURL getHttps_hls() { - return https_hls; - } - - public StreamURL getWs_hls() { - return ws_hls; - } - - public StreamURL getWss_hls() { - return wss_hls; - } - - public StreamURL getTs() { - return ts; - } - - - public StreamURL getHttps_ts() { - return https_ts; - } - - - public StreamURL getWs_ts() { - return ws_ts; - } - - - public StreamURL getWss_ts() { - return wss_ts; - } - - - public StreamURL getRtmp() { - return rtmp; - } - - public StreamURL getRtmps() { - return rtmps; - } - - public StreamURL getRtsp() { - return rtsp; - } - - public StreamURL getRtsps() { - return rtsps; - } - - public StreamURL getRtc() { - return rtc; - } - - public StreamURL getRtcs() { - return rtcs; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public Object getTracks() { - return tracks; - } - - public void setTracks(Object tracks) { - this.tracks = tracks; - } - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public double getProgress() { - return progress; - } - - public void setProgress(double progress) { - this.progress = progress; - } - - public boolean isPause() { - return pause; - } - - public void setPause(boolean pause) { - this.pause = pause; - } - - public TransactionInfo getTransactionInfo() { - return transactionInfo; - } - - public void setTransactionInfo(TransactionInfo transactionInfo) { - this.transactionInfo = transactionInfo; - } - - @Override - public StreamInfo clone() { - StreamInfo instance = null; - try{ - instance = (StreamInfo)super.clone(); - if (this.flv != null) { - instance.flv=this.flv.clone(); - } - if (this.ws_flv != null ){ - instance.ws_flv= this.ws_flv.clone(); - } - if (this.hls != null ) { - instance.hls= this.hls.clone(); - } - if (this.ws_hls != null ) { - instance.ws_hls= this.ws_hls.clone(); - } - if (this.ts != null ) { - instance.ts= this.ts.clone(); - } - if (this.ws_ts != null ) { - instance.ws_ts= this.ws_ts.clone(); - } - if (this.fmp4 != null ) { - instance.fmp4= this.fmp4.clone(); - } - if (this.ws_fmp4 != null ) { - instance.ws_fmp4= this.ws_fmp4.clone(); - } - if (this.rtc != null ) { - instance.rtc= this.rtc.clone(); - } - if (this.https_flv != null) { - instance.https_flv= this.https_flv.clone(); - } - if (this.wss_flv != null) { - instance.wss_flv= this.wss_flv.clone(); - } - if (this.https_hls != null) { - instance.https_hls= this.https_hls.clone(); - } - if (this.wss_hls != null) { - instance.wss_hls= this.wss_hls.clone(); - } - if (this.wss_ts != null) { - instance.wss_ts= this.wss_ts.clone(); - } - if (this.https_fmp4 != null) { - instance.https_fmp4= this.https_fmp4.clone(); - } - if (this.wss_fmp4 != null) { - instance.wss_fmp4= this.wss_fmp4.clone(); - } - if (this.rtcs != null) { - instance.rtcs= this.rtcs.clone(); - } - if (this.rtsp != null) { - instance.rtsp= this.rtsp.clone(); - } - if (this.rtsps != null) { - instance.rtsps= this.rtsps.clone(); - } - if (this.rtmp != null) { - instance.rtmp= this.rtmp.clone(); - } - if (this.rtmps != null) { - instance.rtmps= this.rtmps.clone(); - } - }catch(CloneNotSupportedException e) { - e.printStackTrace(); - } - return instance; - } - - - /*=========================设备主子码流逻辑START====================*/ - @Schema(description = "是否为子码流(true-是,false-主码流)") - private boolean subStream; - - public boolean isSubStream() { - return subStream; - } - - public void setSubStream(boolean subStream) { - this.subStream = subStream; - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/StreamURL.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/StreamURL.java deleted file mode 100644 index 40bd7e25..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/StreamURL.java +++ /dev/null @@ -1,84 +0,0 @@ -package com.genersoft.iot.vmp.common; - -import io.swagger.v3.oas.annotations.media.Schema; - -import java.io.Serializable; - - -@Schema(description = "流地址信息") -public class StreamURL implements Serializable,Cloneable { - - @Schema(description = "协议") - private String protocol; - - @Schema(description = "主机地址") - private String host; - - @Schema(description = "端口") - private int port = -1; - - @Schema(description = "定位位置") - private String file; - - @Schema(description = "拼接后的地址") - private String url; - - public StreamURL() { - } - - public StreamURL(String protocol, String host, int port, String file) { - this.protocol = protocol; - this.host = host; - this.port = port; - this.file = file; - } - - public String getProtocol() { - return protocol; - } - - public void setProtocol(String protocol) { - this.protocol = protocol; - } - - public String getHost() { - return host; - } - - public void setHost(String host) { - this.host = host; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getFile() { - return file; - } - - public void setFile(String file) { - this.file = file; - } - - public String getUrl() { - return this.toString(); - } - - @Override - public String toString() { - if (protocol != null && host != null && port != -1 ) { - return String.format("%s://%s:%s/%s", protocol, host, port, file); - }else { - return null; - } - } - @Override - public StreamURL clone() throws CloneNotSupportedException { - return (StreamURL) super.clone(); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java deleted file mode 100644 index 48485da8..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/SystemAllInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.genersoft.iot.vmp.common; - -import java.util.List; - -public class SystemAllInfo { - - private List cpu; - private List mem; - private List net; - - private long netTotal; - - private Object disk; - - public List getCpu() { - return cpu; - } - - public void setCpu(List cpu) { - this.cpu = cpu; - } - - public List getMem() { - return mem; - } - - public void setMem(List mem) { - this.mem = mem; - } - - public List getNet() { - return net; - } - - public void setNet(List net) { - this.net = net; - } - - public Object getDisk() { - return disk; - } - - public void setDisk(Object disk) { - this.disk = disk; - } - - public long getNetTotal() { - return netTotal; - } - - public void setNetTotal(long netTotal) { - this.netTotal = netTotal; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/VersionPo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/VersionPo.java deleted file mode 100644 index f2c8454c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/VersionPo.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.genersoft.iot.vmp.common; - -import com.alibaba.fastjson2.annotation.JSONField; - -public class VersionPo { - /** - * git的全版本号 - */ - @JSONField(name="GIT_Revision") - private String GIT_Revision; - /** - * maven版本 - */ - @JSONField(name = "Create_By") - private String Create_By; - /** - * git的分支 - */ - @JSONField(name = "GIT_BRANCH") - private String GIT_BRANCH; - /** - * git的url - */ - @JSONField(name = "GIT_URL") - private String GIT_URL; - /** - * 构建日期 - */ - @JSONField(name = "BUILD_DATE") - private String BUILD_DATE; - /** - * 构建日期 - */ - @JSONField(name = "GIT_DATE") - private String GIT_DATE; - /** - * 项目名称 配合pom使用 - */ - @JSONField(name = "artifactId") - private String artifactId; - /** - * git局部版本号 - */ - @JSONField(name = "GIT_Revision_SHORT") - private String GIT_Revision_SHORT; - /** - * 项目的版本如2.0.1.0 配合pom使用 - */ - @JSONField(name = "version") - private String version; - /** - * 子系统名称 - */ - @JSONField(name = "project") - private String project; - /** - * jdk版本 - */ - @JSONField(name="Build_Jdk") - private String Build_Jdk; - - public void setGIT_Revision(String GIT_Revision) { - this.GIT_Revision = GIT_Revision; - } - - public void setCreate_By(String create_By) { - Create_By = create_By; - } - - public void setGIT_BRANCH(String GIT_BRANCH) { - this.GIT_BRANCH = GIT_BRANCH; - } - - public void setGIT_URL(String GIT_URL) { - this.GIT_URL = GIT_URL; - } - - public void setBUILD_DATE(String BUILD_DATE) { - this.BUILD_DATE = BUILD_DATE; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public void setGIT_Revision_SHORT(String GIT_Revision_SHORT) { - this.GIT_Revision_SHORT = GIT_Revision_SHORT; - } - - public void setVersion(String version) { - this.version = version; - } - - public void setProject(String project) { - this.project = project; - } - - public void setBuild_Jdk(String build_Jdk) { - Build_Jdk = build_Jdk; - } - - public String getGIT_Revision() { - return GIT_Revision; - } - - public String getCreate_By() { - return Create_By; - } - - public String getGIT_BRANCH() { - return GIT_BRANCH; - } - - public String getGIT_URL() { - return GIT_URL; - } - - public String getBUILD_DATE() { - return BUILD_DATE; - } - - public String getArtifactId() { - return artifactId; - } - - public String getGIT_Revision_SHORT() { - return GIT_Revision_SHORT; - } - - public String getVersion() { - return version; - } - - public String getProject() { - return project; - } - - public String getBuild_Jdk() { - return Build_Jdk; - } - - public String getGIT_DATE() { - return GIT_DATE; - } - - public void setGIT_DATE(String GIT_DATE) { - this.GIT_DATE = GIT_DATE; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java deleted file mode 100644 index 9d0475c2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java +++ /dev/null @@ -1,168 +0,0 @@ -package com.genersoft.iot.vmp.common; - -/** - * @description: 定义常量 - * @author: swwheihei - * @date: 2019年5月30日 下午3:04:04 - * - */ -public class VideoManagerConstants { - - public static final String WVP_SERVER_PREFIX = "VMP_SIGNALLING_SERVER_INFO_"; - - public static final String WVP_SERVER_STREAM_PREFIX = "VMP_SIGNALLING_STREAM_"; - - public static final String MEDIA_SERVER_PREFIX = "VMP_MEDIA_SERVER_"; - - public static final String MEDIA_SERVERS_ONLINE_PREFIX = "VMP_MEDIA_ONLINE_SERVERS_"; - - public static final String DEVICE_PREFIX = "VMP_DEVICE_"; - - // 设备同步完成 - public static final String DEVICE_SYNC_PREFIX = "VMP_DEVICE_SYNC_"; - - public static final String CACHEKEY_PREFIX = "VMP_CHANNEL_"; - - public static final String KEEPLIVEKEY_PREFIX = "VMP_KEEPALIVE_"; - - // TODO 此处多了一个_,暂不修改 - public static final String INVITE_PREFIX = "VMP_INVITE"; - public static final String PLAYER_PREFIX = "VMP_INVITE_PLAY_"; - public static final String PLAY_BLACK_PREFIX = "VMP_INVITE_PLAYBACK_"; - public static final String DOWNLOAD_PREFIX = "VMP_INVITE_DOWNLOAD_"; - - public static final String PLATFORM_KEEPALIVE_PREFIX = "VMP_PLATFORM_KEEPALIVE_"; - - public static final String PLATFORM_CATCH_PREFIX = "VMP_PLATFORM_CATCH_"; - - public static final String PLATFORM_REGISTER_PREFIX = "VMP_PLATFORM_REGISTER_"; - - public static final String PLATFORM_REGISTER_INFO_PREFIX = "VMP_PLATFORM_REGISTER_INFO_"; - - public static final String PLATFORM_SEND_RTP_INFO_PREFIX = "VMP_PLATFORM_SEND_RTP_INFO_"; - - public static final String EVENT_ONLINE_REGISTER = "1"; - - public static final String EVENT_ONLINE_MESSAGE = "3"; - - public static final String EVENT_OUTLINE_UNREGISTER = "1"; - - public static final String EVENT_OUTLINE_TIMEOUT = "2"; - - public static final String MEDIA_SSRC_USED_PREFIX = "VMP_MEDIA_USED_SSRC_"; - - public static final String MEDIA_TRANSACTION_USED_PREFIX = "VMP_MEDIA_TRANSACTION_"; - - public static final String MEDIA_STREAM_AUTHORITY = "MEDIA_STREAM_AUTHORITY_"; - - public static final String SIP_CSEQ_PREFIX = "VMP_SIP_CSEQ_"; - - public static final String SIP_SN_PREFIX = "VMP_SIP_SN_"; - - public static final String SIP_SUBSCRIBE_PREFIX = "VMP_SIP_SUBSCRIBE_"; - - public static final String REGISTER_EXPIRE_TASK_KEY_PREFIX = "VMP_device_register_expire_"; - - - - - //************************** redis 消息********************************* - - /** - * 流变化的通知 - */ - public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_"; - - /** - * 接收推流设备的GPS变化通知 - */ - public static final String VM_MSG_GPS = "VM_MSG_GPS"; - - /** - * 接收推流设备的GPS变化通知 - */ - public static final String VM_MSG_PUSH_STREAM_STATUS_CHANGE = "VM_MSG_PUSH_STREAM_STATUS_CHANGE"; - /** - * 接收推流设备列表更新变化通知 - */ - public static final String VM_MSG_PUSH_STREAM_LIST_CHANGE = "VM_MSG_PUSH_STREAM_LIST_CHANGE"; - - /** - * redis 消息通知设备推流到平台 - */ - public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED"; - - /** - * redis 消息通知上级平台开始观看流 - */ - public static final String VM_MSG_STREAM_START_PLAY_NOTIFY = "VM_MSG_STREAM_START_PLAY_NOTIFY"; - - /** - * redis 消息通知上级平台停止观看流 - */ - public static final String VM_MSG_STREAM_STOP_PLAY_NOTIFY = "VM_MSG_STREAM_STOP_PLAY_NOTIFY"; - - /** - * redis 消息接收关闭一个推流 - */ - public static final String VM_MSG_STREAM_PUSH_CLOSE_REQUESTED = "VM_MSG_STREAM_PUSH_CLOSE_REQUESTED"; - - - /** - * redis 消息通知平台通知设备推流结果 - */ - public static final String VM_MSG_STREAM_PUSH_RESPONSE = "VM_MSG_STREAM_PUSH_RESPONSE"; - - /** - * redis 通知平台关闭推流 - */ - public static final String VM_MSG_STREAM_PUSH_CLOSE = "VM_MSG_STREAM_PUSH_CLOSE"; - - /** - * redis 消息请求所有的在线通道 - */ - public static final String VM_MSG_GET_ALL_ONLINE_REQUESTED = "VM_MSG_GET_ALL_ONLINE_REQUESTED"; - - /** - * 移动位置订阅通知 - */ - public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition"; - - /** - * 报警订阅的通知(收到报警向redis发出通知) - */ - public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm"; - - - /** - * 报警通知的发送 (收到redis发出的通知,转发给其他平台) - */ - public static final String VM_MSG_SUBSCRIBE_ALARM_RECEIVE= "alarm_receive"; - - /** - * 设备状态订阅的通知 - */ - public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device"; - - - //************************** 第三方 **************************************** - - public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_"; - public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_"; - public static final String WVP_OTHER_SEND_RTP_INFO = "VMP_OTHER_SEND_RTP_INFO_"; - public static final String WVP_OTHER_SEND_PS_INFO = "VMP_OTHER_SEND_PS_INFO_"; - public static final String WVP_OTHER_RECEIVE_RTP_INFO = "VMP_OTHER_RECEIVE_RTP_INFO_"; - public static final String WVP_OTHER_RECEIVE_PS_INFO = "VMP_OTHER_RECEIVE_PS_INFO_"; - - /** - * Redis Const - * 设备录像信息结果前缀 - */ - public static final String REDIS_RECORD_INFO_RES_PRE = "GB_RECORD_INFO_RES_"; - /** - * Redis Const - * 设备录像信息结果前缀 - */ - public static final String REDIS_RECORD_INFO_RES_COUNT_PRE = "GB_RECORD_INFO_RES_COUNT:"; - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/enums/DeviceControlType.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/enums/DeviceControlType.java deleted file mode 100644 index 02202d89..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/common/enums/DeviceControlType.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.genersoft.iot.vmp.common.enums; - -import org.dom4j.Element; -import org.springframework.util.ObjectUtils; - - -/** - * @author gaofuwang - * @date 2023/01/18/ 10:09:00 - * @since 1.0 - */ -public enum DeviceControlType { - - /** - * 云台控制 - * 上下左右,预置位,扫描,辅助功能,巡航 - */ - PTZ("PTZCmd","云台控制"), - /** - * 远程启动 - */ - TELE_BOOT("TeleBoot","远程启动"), - /** - * 录像控制 - */ - RECORD("RecordCmd","录像控制"), - /** - * 布防撤防 - */ - GUARD("GuardCmd","布防撤防"), - /** - * 告警控制 - */ - ALARM("AlarmCmd","告警控制"), - /** - * 强制关键帧 - */ - I_FRAME("IFameCmd","强制关键帧"), - /** - * 拉框放大 - */ - DRAG_ZOOM_IN("DragZoomIn","拉框放大"), - /** - * 拉框缩小 - */ - DRAG_ZOOM_OUT("DragZoomOut","拉框缩小"), - /** - * 看守位 - */ - HOME_POSITION("HomePosition","看守位"); - - private final String val; - - private final String desc; - - DeviceControlType(String val, String desc) { - this.val = val; - this.desc = desc; - } - - public String getVal() { - return val; - } - - public String getDesc() { - return desc; - } - - public static DeviceControlType typeOf(Element rootElement) { - for (DeviceControlType item : DeviceControlType.values()) { - if (!ObjectUtils.isEmpty(rootElement.element(item.val)) || !ObjectUtils.isEmpty(rootElement.elements(item.val))) { - return item; - } - } - return null; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java deleted file mode 100644 index e3f56243..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/CivilCodeFileConf.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import com.genersoft.iot.vmp.common.CivilCodePo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.Lazy; -import org.springframework.core.annotation.Order; -import org.springframework.core.io.ClassPathResource; -import org.springframework.util.ObjectUtils; - -import java.io.BufferedReader; -import java.io.File; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.file.Files; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * 启动时读取行政区划表 - */ -@Configuration -@Order(value=14) -public class CivilCodeFileConf implements CommandLineRunner { - - private final static Logger logger = LoggerFactory.getLogger(CivilCodeFileConf.class); - - private final Map civilCodeMap= new ConcurrentHashMap<>(); - - @Autowired - @Lazy - private UserSetting userSetting; - - @Override - public void run(String... args) throws Exception { - if (ObjectUtils.isEmpty(userSetting.getCivilCodeFile())) { - logger.warn("[行政区划] 文件未设置,可能造成目录刷新结果不完整"); - return; - } - InputStream inputStream; - if (userSetting.getCivilCodeFile().startsWith("classpath:")){ - String filePath = userSetting.getCivilCodeFile().substring("classpath:".length()); - ClassPathResource civilCodeFile = new ClassPathResource(filePath); - if (!civilCodeFile.exists()) { - logger.warn("[行政区划] 文件<{}>不存在,可能造成目录刷新结果不完整", userSetting.getCivilCodeFile()); - return; - } - inputStream = civilCodeFile.getInputStream(); - - }else { - File civilCodeFile = new File(userSetting.getCivilCodeFile()); - if (!civilCodeFile.exists()) { - logger.warn("[行政区划] 文件<{}>不存在,可能造成目录刷新结果不完整", userSetting.getCivilCodeFile()); - return; - } - inputStream = Files.newInputStream(civilCodeFile.toPath()); - } - - BufferedReader inputStreamReader = new BufferedReader(new InputStreamReader(inputStream)); - int index = -1; - String line; - while ((line = inputStreamReader.readLine()) != null) { - index ++; - if (index == 0) { - continue; - } - String[] infoArray = line.split(","); - CivilCodePo civilCodePo = CivilCodePo.getInstance(infoArray); - civilCodeMap.put(civilCodePo.getCode(), civilCodePo); - } - inputStreamReader.close(); - inputStream.close(); - if (civilCodeMap.size() == 0) { - logger.warn("[行政区划] 文件内容为空,可能造成目录刷新结果不完整"); - }else { - logger.info("[行政区划] 加载成功,共加载数据{}条", civilCodeMap.size()); - } - } - - public CivilCodePo getParentCode(String code) { - if (code.length() > 8) { - return null; - } - if (code.length() == 8) { - String parentCode = code.substring(0, 6); - return civilCodeMap.get(parentCode); - }else { - CivilCodePo civilCodePo = civilCodeMap.get(code); - if (civilCodePo == null){ - return null; - } - String parentCode = civilCodePo.getParentCode(); - if (parentCode == null) { - return null; - } - return civilCodeMap.get(parentCode); - } - - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java deleted file mode 100644 index 5a451e35..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java +++ /dev/null @@ -1,158 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import org.apache.commons.lang3.ObjectUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; -import org.springframework.stereotype.Component; - -import javax.annotation.PostConstruct; -import java.time.Instant; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ScheduledFuture; -import java.util.concurrent.TimeUnit; - -/** - * 动态定时任务 - * @author lin - */ -@Component -public class DynamicTask { - - private final Logger logger = LoggerFactory.getLogger(DynamicTask.class); - - private ThreadPoolTaskScheduler threadPoolTaskScheduler; - - private final Map> futureMap = new ConcurrentHashMap<>(); - private final Map runnableMap = new ConcurrentHashMap<>(); - - @PostConstruct - public void DynamicTask() { - threadPoolTaskScheduler = new ThreadPoolTaskScheduler(); - threadPoolTaskScheduler.setPoolSize(300); - threadPoolTaskScheduler.setWaitForTasksToCompleteOnShutdown(true); - threadPoolTaskScheduler.setAwaitTerminationSeconds(10); - threadPoolTaskScheduler.initialize(); - } - - /** - * 循环执行的任务 - * @param key 任务ID - * @param task 任务 - * @param cycleForCatalog 间隔 毫秒 - * @return - */ - public void startCron(String key, Runnable task, int cycleForCatalog) { - if(ObjectUtils.isEmpty(key)) { - return; - } - ScheduledFuture future = futureMap.get(key); - if (future != null) { - if (future.isCancelled()) { - logger.debug("任务【{}】已存在但是关闭状态!!!", key); - } else { - logger.debug("任务【{}】已存在且已启动!!!", key); - return; - } - } - // scheduleWithFixedDelay 必须等待上一个任务结束才开始计时period, cycleForCatalog表示执行的间隔 - future = threadPoolTaskScheduler.scheduleAtFixedRate(task, cycleForCatalog); - if (future != null){ - futureMap.put(key, future); - runnableMap.put(key, task); - logger.debug("任务【{}】启动成功!!!", key); - }else { - logger.debug("任务【{}】启动失败!!!", key); - } - } - - /** - * 延时任务 - * @param key 任务ID - * @param task 任务 - * @param delay 延时 /毫秒 - * @return - */ - public void startDelay(String key, Runnable task, int delay) { - if(ObjectUtils.isEmpty(key)) { - return; - } - stop(key); - - // 获取执行的时刻 - Instant startInstant = Instant.now().plusMillis(TimeUnit.MILLISECONDS.toMillis(delay)); - - ScheduledFuture future = futureMap.get(key); - if (future != null) { - if (future.isCancelled()) { - logger.debug("任务【{}】已存在但是关闭状态!!!", key); - } else { - logger.debug("任务【{}】已存在且已启动!!!", key); - return; - } - } - // scheduleWithFixedDelay 必须等待上一个任务结束才开始计时period, cycleForCatalog表示执行的间隔 - future = threadPoolTaskScheduler.schedule(task, startInstant); - if (future != null){ - futureMap.put(key, future); - runnableMap.put(key, task); - logger.debug("任务【{}】启动成功!!!", key); - }else { - logger.debug("任务【{}】启动失败!!!", key); - } - } - - public boolean stop(String key) { - if(ObjectUtils.isEmpty(key)) { - return false; - } - boolean result = false; - if (!ObjectUtils.isEmpty(futureMap.get(key)) && !futureMap.get(key).isCancelled() && !futureMap.get(key).isDone()) { - result = futureMap.get(key).cancel(false); - futureMap.remove(key); - runnableMap.remove(key); - } - return result; - } - - public boolean contains(String key) { - if(ObjectUtils.isEmpty(key)) { - return false; - } - return futureMap.get(key) != null; - } - - public Set getAllKeys() { - return futureMap.keySet(); - } - - public Runnable get(String key) { - if(ObjectUtils.isEmpty(key)) { - return null; - } - return runnableMap.get(key); - } - - /** - * 每五分钟检查失效的任务,并移除 - */ - @Scheduled(cron="0 0/5 * * * ?") - public void execute(){ - if (futureMap.size() > 0) { - for (String key : futureMap.keySet()) { - ScheduledFuture future = futureMap.get(key); - if (future.isDone() || future.isCancelled()) { - futureMap.remove(key); - runnableMap.remove(key); - } - } - } - } - - public boolean isAlive(String key) { - return futureMap.get(key) != null && !futureMap.get(key).isDone() && !futureMap.get(key).isCancelled(); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java deleted file mode 100644 index 1fa86d44..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/MediaConfig.java +++ /dev/null @@ -1,326 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.utils.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; -import org.springframework.util.ObjectUtils; - -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.util.regex.Pattern; - -@Order(0) -@ConfigurationProperties(prefix = "media") -public class MediaConfig{ - - private final static Logger logger = LoggerFactory.getLogger(MediaConfig.class); - - // 修改必须配置,不再支持自动获取 - private String id; - - /** - * 流媒体ip - */ - private String ip; - - /** - * 流媒体回调ip - */ - private String hookIp; - - /** - * 回调地址前缀 - */ - private String hookPrefix = "gbs/zlm/hook"; - - @Value("${sip.ip}") - private String sipIp; - - @Value("${sip.domain}") - private String sipDomain; - - private String sdpIp; - - private String streamIp; - - private Integer httpPort; - - private Integer httpSSlPort = 0; - - private Integer rtmpPort = 0; - - private Integer rtmpSSlPort = 0; - - @Value("${media.rtp-proxy-port:0}") - private Integer rtpProxyPort = 0; - - @Value("${media.rtsp-port:0}") - private Integer rtspPort = 0; - - @Value("${media.rtsp-ssl-port:0}") - private Integer rtspSSLPort = 0; - - /** - * 自动配置 - */ - private boolean autoConfig = true; - - /** - * zlm服务器的 secret - */ - private String secret; - - @Value("${media.rtp.enable}") - private boolean rtpEnable; - - @Value("${media.rtp.port-range}") - private String rtpPortRange; - - @Value("${media.rtp.send-port-range}") - private String rtpSendPortRange; - - @Value("${media.record-assist-port:0}") - private Integer recordAssistPort = 0; - - public String getId() { - return id; - } - - public String getIp() { - return ip; - } - - public String getHookIp() { - if (ObjectUtils.isEmpty(hookIp)){ - return sipIp.split(",")[0]; - }else { - return hookIp; - } - - } - - public String getSipIp() { - if (sipIp == null) { - return this.ip; - }else { - return sipIp; - } - } - - public int getHttpPort() { - return httpPort; - } - - public int getHttpSSlPort() { - return httpSSlPort; - } - - public int getRtmpPort() { - return rtmpPort; - } - - public int getRtmpSSlPort() { - return rtmpSSlPort; - } - - public int getRtpProxyPort() { - if (rtpProxyPort == null) { - return 0; - }else { - return rtpProxyPort; - } - - } - - public int getRtspPort() { - return rtspPort; - } - - public int getRtspSSLPort() { - return rtspSSLPort; - } - - public boolean isAutoConfig() { - return autoConfig; - } - - public String getSecret() { - return secret; - } - - public boolean isRtpEnable() { - return rtpEnable; - } - - public String getRtpPortRange() { - return rtpPortRange; - } - - public int getRecordAssistPort() { - return recordAssistPort; - } - - public String getSdpIp() { - if (ObjectUtils.isEmpty(sdpIp)){ - return ip; - }else { - if (isValidIPAddress(sdpIp)) { - return sdpIp; - }else { - // 按照域名解析 - String hostAddress = null; - try { - hostAddress = InetAddress.getByName(sdpIp).getHostAddress(); - } catch (UnknownHostException e) { - logger.error("[获取SDP IP]: 域名解析失败"); - } - return hostAddress; - } - } - } - - public void setId(String id) { - this.id = id; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public void setHookIp(String hookIp) { - this.hookIp = hookIp; - } - - public void setHttpPort(Integer httpPort) { - this.httpPort = httpPort; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public String getStreamIp() { - if (ObjectUtils.isEmpty(streamIp)){ - return ip; - }else { - return streamIp; - } - } - - public String getSipDomain() { - return sipDomain; - } - - public MediaServerItem getMediaSerItem(){ - MediaServerItem mediaServerItem = new MediaServerItem(); - mediaServerItem.setId(id); - mediaServerItem.setIp(ip); - mediaServerItem.setDefaultServer(true); - mediaServerItem.setHookIp(getHookIp()); - mediaServerItem.setSdpIp(getSdpIp()); - mediaServerItem.setStreamIp(getStreamIp()); - mediaServerItem.setHttpPort(httpPort); - mediaServerItem.setHttpSSlPort(httpSSlPort); - mediaServerItem.setRtmpPort(rtmpPort); - mediaServerItem.setRtmpSSlPort(rtmpSSlPort); - mediaServerItem.setRtpProxyPort(getRtpProxyPort()); - mediaServerItem.setRtspPort(rtspPort); - mediaServerItem.setRtspSSLPort(rtspSSLPort); - mediaServerItem.setAutoConfig(autoConfig); - mediaServerItem.setSecret(secret); - mediaServerItem.setRtpEnable(rtpEnable); - mediaServerItem.setRtpPortRange(rtpPortRange); - mediaServerItem.setSendRtpPortRange(rtpSendPortRange); - mediaServerItem.setRecordAssistPort(recordAssistPort); - mediaServerItem.setHookAliveInterval(30.00f); - - mediaServerItem.setCreateTime(DateUtil.getNow()); - mediaServerItem.setUpdateTime(DateUtil.getNow()); - - return mediaServerItem; - } - - public String getRtpSendPortRange() { - return rtpSendPortRange; - } - - public void setRtpSendPortRange(String rtpSendPortRange) { - this.rtpSendPortRange = rtpSendPortRange; - } - - private boolean isValidIPAddress(String ipAddress) { - if ((ipAddress != null) && (!ipAddress.isEmpty())) { - return Pattern.matches("^([1-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])(\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])){3}$", ipAddress); - } - return false; - } - - public void setSipIp(String sipIp) { - this.sipIp = sipIp; - } - - public void setSipDomain(String sipDomain) { - this.sipDomain = sipDomain; - } - - public void setSdpIp(String sdpIp) { - this.sdpIp = sdpIp; - } - - public void setStreamIp(String streamIp) { - this.streamIp = streamIp; - } - - public void setHttpSSlPort(Integer httpSSlPort) { - this.httpSSlPort = httpSSlPort; - } - - public void setRtmpPort(Integer rtmpPort) { - this.rtmpPort = rtmpPort; - } - - public void setRtmpSSlPort(Integer rtmpSSlPort) { - this.rtmpSSlPort = rtmpSSlPort; - } - - public void setRtpProxyPort(Integer rtpProxyPort) { - this.rtpProxyPort = rtpProxyPort; - } - - public void setRtspPort(Integer rtspPort) { - this.rtspPort = rtspPort; - } - - public void setRtspSSLPort(Integer rtspSSLPort) { - this.rtspSSLPort = rtspSSLPort; - } - - public void setAutoConfig(boolean autoConfig) { - this.autoConfig = autoConfig; - } - - public void setRtpEnable(boolean rtpEnable) { - this.rtpEnable = rtpEnable; - } - - public void setRtpPortRange(String rtpPortRange) { - this.rtpPortRange = rtpPortRange; - } - - public void setRecordAssistPort(Integer recordAssistPort) { - this.recordAssistPort = recordAssistPort; - } - - public String getHookPrefix() { - return hookPrefix; - } - - public void setHookPrefix(String hookPrefix) { - this.hookPrefix = hookPrefix; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java deleted file mode 100644 index a7416a8e..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ProxyServletConfig.java +++ /dev/null @@ -1,303 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import org.apache.http.HttpHost; -import org.apache.http.HttpRequest; -import org.apache.http.HttpResponse; -import org.springframework.core.annotation.Order; -import org.mitre.dsmiley.httpproxy.ProxyServlet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.web.servlet.ServletRegistrationBean; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.util.ObjectUtils; - -import javax.servlet.ServletException; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.net.ConnectException; - -/** - * @author lin - */ -@SuppressWarnings(value = {"rawtypes", "unchecked"}) -@Configuration -@Order(1) -public class ProxyServletConfig { - - private final static Logger logger = LoggerFactory.getLogger(ProxyServletConfig.class); - - @Autowired - private IMediaServerService mediaServerService; - - @Value("${server.port}") - private int serverPort; - - @Bean - public ServletRegistrationBean zlmServletRegistrationBean(){ - ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new ZlmProxyServlet(),"/zlm/*"); - servletRegistrationBean.setName("zlm_Proxy"); - servletRegistrationBean.addInitParameter("targetUri", "http://127.0.0.1:6080"); - servletRegistrationBean.addUrlMappings(); - if (logger.isDebugEnabled()) { - servletRegistrationBean.addInitParameter("log", "true"); - } - return servletRegistrationBean; - } - - class ZlmProxyServlet extends ProxyServlet{ - @Override - protected String rewriteQueryStringFromRequest(HttpServletRequest servletRequest, String queryString) { - String queryStr = super.rewriteQueryStringFromRequest(servletRequest, queryString); - MediaServerItem mediaInfo = getMediaInfoByUri(servletRequest.getRequestURI()); - if (mediaInfo != null) { - if (!ObjectUtils.isEmpty(queryStr)) { - queryStr += "&secret=" + mediaInfo.getSecret(); - }else { - queryStr = "secret=" + mediaInfo.getSecret(); - } - } - return queryStr; - } - - - @Override - protected HttpResponse doExecute(HttpServletRequest servletRequest, HttpServletResponse servletResponse, - HttpRequest proxyRequest) throws IOException { - HttpResponse response = super.doExecute(servletRequest, servletResponse, proxyRequest); - response.removeHeaders("Access-Control-Allow-Origin"); - response.setHeader("Access-Control-Allow-Credentials","true"); - response.removeHeaders("Access-Control-Allow-Credentials"); - - return response; - } - - /** - * 异常处理 - */ - @Override - protected void handleRequestException(HttpRequest proxyRequest, HttpResponse proxyResonse, Exception e){ - try { - super.handleRequestException(proxyRequest, proxyResonse, e); - } catch (ServletException servletException) { - logger.error("zlm 代理失败: ", e); - } catch (IOException ioException) { - if (ioException instanceof ConnectException) { - logger.error("zlm 连接失败"); - } else { - logger.error("zlm 代理失败: ", e); - } - } catch (RuntimeException exception){ - logger.error("zlm 代理失败: ", e); - } - } - - /** - * 对于为按照格式请求的可以直接返回404 - */ - @Override - protected String getTargetUri(HttpServletRequest servletRequest) { - String requestURI = servletRequest.getRequestURI(); - MediaServerItem mediaInfo = getMediaInfoByUri(requestURI); - - String uri = null; - if (mediaInfo != null) { -// String realRequestURI = requestURI.substring(requestURI.indexOf(mediaInfo.getId())+ mediaInfo.getId().length()); - uri = String.format("http://%s:%s", mediaInfo.getIp(), mediaInfo.getHttpPort()); - }else { - uri = "http://127.0.0.1:" + serverPort +"/index/hook/null"; // 只是一个能返回404的请求而已, 其他的也可以 - } - return uri; - } - - /** - * 动态替换请求目标 - */ - @Override - protected HttpHost getTargetHost(HttpServletRequest servletRequest) { - String requestURI = servletRequest.getRequestURI(); - MediaServerItem mediaInfo = getMediaInfoByUri(requestURI); - HttpHost host; - if (mediaInfo != null) { - host = new HttpHost(mediaInfo.getIp(), mediaInfo.getHttpPort()); - }else { - host = new HttpHost("127.0.0.1", serverPort); - } - return host; - - } - - /** - * 根据uri获取流媒体信息 - */ - MediaServerItem getMediaInfoByUri(String uri){ - String[] split = uri.split("/"); - String mediaServerId = split[2]; - if ("default".equalsIgnoreCase(mediaServerId)) { - return mediaServerService.getDefaultMediaServer(); - }else { - return mediaServerService.getOne(mediaServerId); - } - } - - /** - * 去掉url中的标志信息 - */ - @Override - protected String rewriteUrlFromRequest(HttpServletRequest servletRequest) { - String requestURI = servletRequest.getRequestURI(); - MediaServerItem mediaInfo = getMediaInfoByUri(requestURI); - String url = super.rewriteUrlFromRequest(servletRequest); - if (mediaInfo == null) { - logger.error("[ZLM服务访问代理],错误:处理url信息时未找到流媒体信息=>{}", requestURI); - return url; - } - if (!ObjectUtils.isEmpty(mediaInfo.getId())) { - url = url.replace(mediaInfo.getId() + "/", ""); - } - return url.replace("default/", ""); - } - } - - @Bean - public ServletRegistrationBean recordServletRegistrationBean(){ - ServletRegistrationBean servletRegistrationBean = new ServletRegistrationBean(new RecordProxyServlet(),"/record_proxy/*"); - servletRegistrationBean.setName("record_proxy"); - servletRegistrationBean.addInitParameter("targetUri", "http://127.0.0.1:18081"); - servletRegistrationBean.addUrlMappings(); - if (logger.isDebugEnabled()) { - servletRegistrationBean.addInitParameter("log", "true"); - } - return servletRegistrationBean; - } - - class RecordProxyServlet extends ProxyServlet{ - - @Override - protected String rewriteQueryStringFromRequest(HttpServletRequest servletRequest, String queryString) { - String queryStr = super.rewriteQueryStringFromRequest(servletRequest, queryString); - MediaServerItem mediaInfo = getMediaInfoByUri(servletRequest.getRequestURI()); - if (mediaInfo == null) { - return null; - } - String remoteHost = String.format("http://%s:%s", mediaInfo.getStreamIp(), mediaInfo.getRecordAssistPort()); - if (!ObjectUtils.isEmpty(queryStr)) { - queryStr += "&remoteHost=" + remoteHost; - }else { - queryStr = "remoteHost=" + remoteHost; - } - return queryStr; - } - - - @Override - protected HttpResponse doExecute(HttpServletRequest servletRequest, HttpServletResponse servletResponse, - HttpRequest proxyRequest) throws IOException { - HttpResponse response = super.doExecute(servletRequest, servletResponse, proxyRequest); - String origin = servletRequest.getHeader("origin"); - response.setHeader("Access-Control-Allow-Origin",origin); - response.setHeader("Access-Control-Allow-Credentials","true"); - - return response; - } - - /** - * 异常处理 - */ - @Override - protected void handleRequestException(HttpRequest proxyRequest, HttpResponse proxyResponse, Exception e){ - try { - super.handleRequestException(proxyRequest, proxyResponse, e); - } catch (ServletException servletException) { - logger.error("录像服务 代理失败: ", e); - } catch (IOException ioException) { - if (ioException instanceof ConnectException) { - logger.error("录像服务 连接失败"); -// }else if (ioException instanceof ClientAbortException) { -// /** -// * TODO 使用这个代理库实现代理在遇到代理视频文件时,如果是206结果,会遇到报错蛋市目前功能正常, -// * TODO 暂时去除异常处理。后续使用其他代理框架修改测试 -// */ - - }else { - logger.error("录像服务 代理失败: ", e); - } - } catch (RuntimeException exception){ - logger.error("录像服务 代理失败: ", e); - } - } - - /** - * 对于为按照格式请求的可以直接返回404 - */ - @Override - protected String getTargetUri(HttpServletRequest servletRequest) { - String requestURI = servletRequest.getRequestURI(); - MediaServerItem mediaInfo = getMediaInfoByUri(requestURI); - - String uri = null; - if (mediaInfo != null) { -// String realRequestURI = requestURI.substring(requestURI.indexOf(mediaInfo.getId())+ mediaInfo.getId().length()); - uri = String.format("http://%s:%s", mediaInfo.getIp(), mediaInfo.getRecordAssistPort()); - }else { - uri = "http://127.0.0.1:" + serverPort +"/index/hook/null"; // 只是一个能返回404的请求而已, 其他的也可以 - } - return uri; - } - - /** - * 动态替换请求目标 - */ - @Override - protected HttpHost getTargetHost(HttpServletRequest servletRequest) { - String requestURI = servletRequest.getRequestURI(); - MediaServerItem mediaInfo = getMediaInfoByUri(requestURI); - HttpHost host; - if (mediaInfo != null) { - host = new HttpHost(mediaInfo.getIp(), mediaInfo.getRecordAssistPort()); - }else { - host = new HttpHost("127.0.0.1", serverPort); - } - return host; - - } - - /** - * 根据uri获取流媒体信息 - */ - MediaServerItem getMediaInfoByUri(String uri){ - String[] split = uri.split("/"); - String mediaServerId = split[2]; - if ("default".equalsIgnoreCase(mediaServerId)) { - return mediaServerService.getDefaultMediaServer(); - }else { - return mediaServerService.getOne(mediaServerId); - } - - } - - /** - * 去掉url中的标志信息 - */ - @Override - protected String rewriteUrlFromRequest(HttpServletRequest servletRequest) { - String requestURI = servletRequest.getRequestURI(); - MediaServerItem mediaInfo = getMediaInfoByUri(requestURI); - String url = super.rewriteUrlFromRequest(servletRequest); - if (mediaInfo == null) { - logger.error("[录像服务访问代理],错误:处理url信息时未找到流媒体信息=>{}", requestURI); - return url; - } - if (!ObjectUtils.isEmpty(mediaInfo.getId())) { - url = url.replace(mediaInfo.getId() + "/", ""); - } - return url.replace("default/", ""); - } - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java deleted file mode 100644 index ed3e07db..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ScheduleConfig.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import org.apache.commons.lang3.concurrent.BasicThreadFactory; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.annotation.SchedulingConfigurer; -import org.springframework.scheduling.config.ScheduledTaskRegistrar; - -import java.util.concurrent.ScheduledThreadPoolExecutor; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * "@Scheduled"是Spring框架提供的一种定时任务执行机制,默认情况下它是单线程的,在同时执行多个定时任务时可能会出现阻塞和性能问题。 - * 为了解决这种单线程瓶颈问题,可以将定时任务的执行机制改为支持多线程 - */ -//@Configuration -public class ScheduleConfig implements SchedulingConfigurer { - - public static final int cpuNum = Runtime.getRuntime().availableProcessors(); - - private static final int corePoolSize = cpuNum; - - private static final String threadNamePrefix = "scheduled-task-pool-%d"; - - @Override - public void configureTasks(ScheduledTaskRegistrar taskRegistrar) { - taskRegistrar.setScheduler(new ScheduledThreadPoolExecutor(corePoolSize, - new BasicThreadFactory.Builder().namingPattern(threadNamePrefix).daemon(true).build(), - new ThreadPoolExecutor.CallerRunsPolicy())); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java deleted file mode 100644 index 6a6c54f9..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/SipConfig.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.genersoft.iot.vmp.conf; - - -import org.springframework.core.annotation.Order; -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.stereotype.Component; - -@Component -@ConfigurationProperties(prefix = "sip", ignoreInvalidFields = true) -@Order(0) -public class SipConfig { - - private String ip; - - private String showIp; - - private Integer port; - - private String domain; - - private String id; - - private String password; - - Integer ptzSpeed = 50; - - Integer registerTimeInterval = 120; - - private boolean alarm; - - public void setIp(String ip) { - this.ip = ip; - } - - public void setPort(Integer port) { - this.port = port; - } - - public void setDomain(String domain) { - this.domain = domain; - } - - public void setId(String id) { - this.id = id; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setPtzSpeed(Integer ptzSpeed) { - this.ptzSpeed = ptzSpeed; - } - - - public void setRegisterTimeInterval(Integer registerTimeInterval) { - this.registerTimeInterval = registerTimeInterval; - } - - public String getIp() { - return ip; - } - - - public Integer getPort() { - return port; - } - - - public String getDomain() { - return domain; - } - - - public String getId() { - return id; - } - - public String getPassword() { - return password; - } - - - public Integer getPtzSpeed() { - return ptzSpeed; - } - - public Integer getRegisterTimeInterval() { - return registerTimeInterval; - } - - public boolean isAlarm() { - return alarm; - } - - public void setAlarm(boolean alarm) { - this.alarm = alarm; - } - - public String getShowIp() { - if (this.showIp == null) { - return this.ip; - } - return showIp; - } - - public void setShowIp(String showIp) { - this.showIp = showIp; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java deleted file mode 100644 index 7760bddf..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import java.util.List; - -/** - * 系统启动时控制上级平台重新注册 - * @author lin - */ -@Component -@Order(value=13) -public class SipPlatformRunner implements CommandLineRunner { - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IPlatformService platformService; - - @Autowired - private ISIPCommanderForPlatform sipCommanderForPlatform; - - private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class); - - @Override - public void run(String... args) throws Exception { - // 获取所有启用的平台 - List parentPlatforms = storager.queryEnableParentPlatformList(true); - - for (ParentPlatform parentPlatform : parentPlatforms) { - - ParentPlatformCatch parentPlatformCatchOld = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); - - // 更新缓存 - ParentPlatformCatch parentPlatformCatch = new ParentPlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - if (parentPlatformCatchOld != null) { - // 取消订阅 - try { - sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{ - platformService.login(parentPlatform); - }); - } catch (Exception e) { - logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); - platformService.offline(parentPlatform, true); - continue; - } - } - - // 设置所有平台离线 - platformService.offline(parentPlatform, false); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java deleted file mode 100644 index c7532e38..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/ThreadPoolTaskConfig.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; -import org.springframework.scheduling.annotation.EnableAsync; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import java.util.concurrent.ThreadPoolExecutor; - -/** - * ThreadPoolTask 配置类 - * @author lin - */ -@Configuration -@Order(1) -@EnableAsync(proxyTargetClass = true) -public class ThreadPoolTaskConfig { - - public static final int cpuNum = Runtime.getRuntime().availableProcessors(); - - /** - * 默认情况下,在创建了线程池后,线程池中的线程数为0,当有任务来之后,就会创建一个线程去执行任务, - * 当线程池中的线程数目达到corePoolSize后,就会把到达的任务放到缓存队列当中; - * 当队列满了,就继续创建线程,当线程数量大于等于maxPoolSize后,开始使用拒绝策略拒绝 - */ - - /** - * 核心线程数(默认线程数) - */ - private static final int corePoolSize = cpuNum; - /** - * 最大线程数 - */ - private static final int maxPoolSize = cpuNum*2; - /** - * 允许线程空闲时间(单位:默认为秒) - */ - private static final int keepAliveTime = 30; - - /** - * 缓冲队列大小 - */ - private static final int queueCapacity = 10000; - /** - * 线程池名前缀 - */ - private static final String threadNamePrefix = "wvp-"; - - /** - * - * @return - */ - @Bean("taskExecutor") // bean的名称,默认为首字母小写的方法名 - public ThreadPoolTaskExecutor taskExecutor() { - ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor(); - executor.setCorePoolSize(corePoolSize); - executor.setMaxPoolSize(maxPoolSize); - executor.setQueueCapacity(queueCapacity); - executor.setKeepAliveSeconds(keepAliveTime); - executor.setThreadNamePrefix(threadNamePrefix); - - // 线程池对拒绝任务的处理策略 - // CallerRunsPolicy:由调用线程(提交任务的线程)处理该任务 - executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy()); - // 初始化 - executor.initialize(); - return executor; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java deleted file mode 100644 index 912fbcd8..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java +++ /dev/null @@ -1,318 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; - -/** - * 配置文件 user-settings 映射的配置信息 - */ -@Component -@ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true) -@Order(0) -public class UserSetting { - - private Boolean savePositionHistory = Boolean.FALSE; - - private Boolean autoApplyPlay = Boolean.FALSE; - - private Boolean seniorSdp = Boolean.FALSE; - - private Integer playTimeout = 18000; - - private int platformPlayTimeout = 60000; - - private Boolean interfaceAuthentication = Boolean.TRUE; - - private Boolean recordPushLive = Boolean.TRUE; - - private Boolean recordSip = Boolean.TRUE; - - private Boolean logInDatabase = Boolean.TRUE; - - private Boolean usePushingAsStatus = Boolean.TRUE; - - private Boolean useSourceIpAsStreamIp = Boolean.FALSE; - - private Boolean sipUseSourceIpAsRemoteAddress = Boolean.FALSE; - - private Boolean streamOnDemand = Boolean.TRUE; - - private Boolean pushAuthority = Boolean.TRUE; - - private Boolean syncChannelOnDeviceOnline = Boolean.TRUE; - - private Boolean sipLog = Boolean.FALSE; - private Boolean sqlLog = Boolean.FALSE; - private Boolean sendToPlatformsWhenIdLost = Boolean.FALSE; - - private Boolean refuseChannelStatusChannelFormNotify = Boolean.FALSE; - - private Boolean deviceStatusNotify = Boolean.FALSE; - private Boolean useCustomSsrcForParentInvite = Boolean.TRUE; - - private String serverId = "000000"; - - private String recordPath = null; - - private String thirdPartyGBIdReg = "[\\s\\S]*"; - - private String civilCodeFile = "classpath:civilCode.csv"; - - private List interfaceAuthenticationExcludes = new ArrayList<>(); - - private List allowedOrigins = new ArrayList<>(); - - private int maxNotifyCountQueue = 10000; - - private int registerAgainAfterTime = 60; - - private boolean registerKeepIntDialog = false; - - public Boolean getSavePositionHistory() { - return savePositionHistory; - } - - public Boolean isSavePositionHistory() { - return savePositionHistory; - } - - public Boolean isAutoApplyPlay() { - return autoApplyPlay; - } - - public Boolean isSeniorSdp() { - return seniorSdp; - } - - public Integer getPlayTimeout() { - return playTimeout; - } - - public Boolean isInterfaceAuthentication() { - return interfaceAuthentication; - } - - public Boolean isRecordPushLive() { - return recordPushLive; - } - - public List getInterfaceAuthenticationExcludes() { - return interfaceAuthenticationExcludes; - } - - public void setSavePositionHistory(Boolean savePositionHistory) { - this.savePositionHistory = savePositionHistory; - } - - public void setAutoApplyPlay(Boolean autoApplyPlay) { - this.autoApplyPlay = autoApplyPlay; - } - - public void setSeniorSdp(Boolean seniorSdp) { - this.seniorSdp = seniorSdp; - } - - public void setPlayTimeout(Integer playTimeout) { - this.playTimeout = playTimeout; - } - - public void setInterfaceAuthentication(boolean interfaceAuthentication) { - this.interfaceAuthentication = interfaceAuthentication; - } - - public void setRecordPushLive(Boolean recordPushLive) { - this.recordPushLive = recordPushLive; - } - - public void setInterfaceAuthenticationExcludes(List interfaceAuthenticationExcludes) { - this.interfaceAuthenticationExcludes = interfaceAuthenticationExcludes; - } - - public Boolean getLogInDatabase() { - return logInDatabase; - } - - public void setLogInDatabase(Boolean logInDatabase) { - this.logInDatabase = logInDatabase; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public String getThirdPartyGBIdReg() { - return thirdPartyGBIdReg; - } - - public void setThirdPartyGBIdReg(String thirdPartyGBIdReg) { - this.thirdPartyGBIdReg = thirdPartyGBIdReg; - } - - public Boolean getRecordSip() { - return recordSip; - } - - public void setRecordSip(Boolean recordSip) { - this.recordSip = recordSip; - } - - public int getPlatformPlayTimeout() { - return platformPlayTimeout; - } - - public void setPlatformPlayTimeout(int platformPlayTimeout) { - this.platformPlayTimeout = platformPlayTimeout; - } - - public Boolean isUsePushingAsStatus() { - return usePushingAsStatus; - } - - public void setUsePushingAsStatus(Boolean usePushingAsStatus) { - this.usePushingAsStatus = usePushingAsStatus; - } - - public Boolean getStreamOnDemand() { - return streamOnDemand; - } - - public void setStreamOnDemand(Boolean streamOnDemand) { - this.streamOnDemand = streamOnDemand; - } - - public Boolean getUseSourceIpAsStreamIp() { - return useSourceIpAsStreamIp; - } - - public void setUseSourceIpAsStreamIp(Boolean useSourceIpAsStreamIp) { - this.useSourceIpAsStreamIp = useSourceIpAsStreamIp; - } - - public Boolean getPushAuthority() { - return pushAuthority; - } - - public void setPushAuthority(Boolean pushAuthority) { - this.pushAuthority = pushAuthority; - } - - public Boolean getSyncChannelOnDeviceOnline() { - return syncChannelOnDeviceOnline; - } - - public void setSyncChannelOnDeviceOnline(Boolean syncChannelOnDeviceOnline) { - this.syncChannelOnDeviceOnline = syncChannelOnDeviceOnline; - } - - public Boolean getSipUseSourceIpAsRemoteAddress() { - return sipUseSourceIpAsRemoteAddress; - } - - public void setSipUseSourceIpAsRemoteAddress(Boolean sipUseSourceIpAsRemoteAddress) { - this.sipUseSourceIpAsRemoteAddress = sipUseSourceIpAsRemoteAddress; - } - - public Boolean getSipLog() { - return sipLog; - } - - public void setSipLog(Boolean sipLog) { - this.sipLog = sipLog; - } - - public List getAllowedOrigins() { - return allowedOrigins; - } - - public void setAllowedOrigins(List allowedOrigins) { - this.allowedOrigins = allowedOrigins; - } - - public Boolean getSendToPlatformsWhenIdLost() { - return sendToPlatformsWhenIdLost; - } - - public void setSendToPlatformsWhenIdLost(Boolean sendToPlatformsWhenIdLost) { - this.sendToPlatformsWhenIdLost = sendToPlatformsWhenIdLost; - } - - public Boolean getRefuseChannelStatusChannelFormNotify() { - return refuseChannelStatusChannelFormNotify; - } - - public void setRefuseChannelStatusChannelFormNotify(Boolean refuseChannelStatusChannelFormNotify) { - this.refuseChannelStatusChannelFormNotify = refuseChannelStatusChannelFormNotify; - } - - public String getRecordPath() { - return recordPath; - } - - public void setRecordPath(String recordPath) { - this.recordPath = recordPath; - } - - public int getMaxNotifyCountQueue() { - return maxNotifyCountQueue; - } - - public void setMaxNotifyCountQueue(int maxNotifyCountQueue) { - this.maxNotifyCountQueue = maxNotifyCountQueue; - } - - public Boolean getDeviceStatusNotify() { - return deviceStatusNotify; - } - - public void setDeviceStatusNotify(Boolean deviceStatusNotify) { - this.deviceStatusNotify = deviceStatusNotify; - } - - public Boolean getUseCustomSsrcForParentInvite() { - return useCustomSsrcForParentInvite; - } - - public void setUseCustomSsrcForParentInvite(Boolean useCustomSsrcForParentInvite) { - this.useCustomSsrcForParentInvite = useCustomSsrcForParentInvite; - } - - public Boolean getSqlLog() { - return sqlLog; - } - - public void setSqlLog(Boolean sqlLog) { - this.sqlLog = sqlLog; - } - - public String getCivilCodeFile() { - return civilCodeFile; - } - - public void setCivilCodeFile(String civilCodeFile) { - this.civilCodeFile = civilCodeFile; - } - - public int getRegisterAgainAfterTime() { - return registerAgainAfterTime; - } - - public void setRegisterAgainAfterTime(int registerAgainAfterTime) { - this.registerAgainAfterTime = registerAgainAfterTime; - } - - public boolean isRegisterKeepIntDialog() { - return registerKeepIntDialog; - } - - public void setRegisterKeepIntDialog(boolean registerKeepIntDialog) { - this.registerKeepIntDialog = registerKeepIntDialog; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java deleted file mode 100644 index 77d83ee2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/WVPTimerTask.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.genersoft.iot.vmp.conf; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -@Component -public class WVPTimerTask { - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IMediaServerService mediaServerService; - - @Value("${server.port}") - private int serverPort; - - @Autowired - private SipConfig sipConfig; - - @Scheduled(fixedRate = 2 * 1000) //每3秒执行一次 - public void execute(){ - JSONObject jsonObject = new JSONObject(); - jsonObject.put("ip", sipConfig.getIp()); - jsonObject.put("port", serverPort); - redisCatchStorage.updateWVPInfo(jsonObject, 3); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/exception/ControllerException.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/exception/ControllerException.java deleted file mode 100644 index d2e12069..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/exception/ControllerException.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.genersoft.iot.vmp.conf.exception; - -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; - -/** - * 自定义异常,controller出现错误时直接抛出异常由全局异常捕获并返回结果 - */ -public class ControllerException extends RuntimeException{ - - private int code; - private String msg; - - public ControllerException(int code, String msg) { - this.code = code; - this.msg = msg; - } - public ControllerException(ErrorCode errorCode) { - this.code = errorCode.getCode(); - this.msg = errorCode.getMsg(); - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java deleted file mode 100644 index e1a738ab..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/exception/SsrcTransactionNotFoundException.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.genersoft.iot.vmp.conf.exception; - -/** - * @author lin - */ -public class SsrcTransactionNotFoundException extends Exception{ - private String deviceId; - private String channelId; - private String callId; - private String stream; - - - - public SsrcTransactionNotFoundException(String deviceId, String channelId, String callId, String stream) { - this.deviceId = deviceId; - this.channelId = channelId; - this.callId = callId; - this.stream = stream; - } - - public String getDeviceId() { - return deviceId; - } - - public String getChannelId() { - return channelId; - } - - public String getCallId() { - return callId; - } - - public String getStream() { - return stream; - } - - @Override - public String getMessage() { - StringBuffer msg = new StringBuffer(); - msg.append(String.format("缓存事务信息未找到,device:%s channel: %s ", deviceId, channelId)); - if (callId != null) { - msg.append(",callId: " + callId); - } - if (stream != null) { - msg.append(",stream: " + stream); - } - return msg.toString(); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisMsgListenConfig.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisMsgListenConfig.java deleted file mode 100644 index c14ebcdd..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/conf/redis/RedisMsgListenConfig.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.genersoft.iot.vmp.conf.redis; - - -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.service.redisMsg.*; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.annotation.Order; -import org.springframework.data.redis.connection.RedisConnectionFactory; -import org.springframework.data.redis.listener.PatternTopic; -import org.springframework.data.redis.listener.RedisMessageListenerContainer; - - -/** - * @description:Redis中间件配置类,使用spring-data-redis集成,自动从application.yml中加载redis配置 - * @author: swwheihei - * @date: 2019年5月30日 上午10:58:25 - * - */ -@Configuration -@Order(value=1) -public class RedisMsgListenConfig { - - @Autowired - private RedisGpsMsgListener redisGPSMsgListener; - - @Autowired - private RedisAlarmMsgListener redisAlarmMsgListener; - - @Autowired - private RedisStreamMsgListener redisStreamMsgListener; - - @Autowired - private RedisGbPlayMsgListener redisGbPlayMsgListener; - - @Autowired - private RedisPushStreamStatusMsgListener redisPushStreamStatusMsgListener; - - @Autowired - private RedisPushStreamStatusListMsgListener redisPushStreamListMsgListener; - - @Autowired - private RedisPushStreamResponseListener redisPushStreamResponseListener; - - @Autowired - private RedisCloseStreamMsgListener redisCloseStreamMsgListener; - - @Autowired - private RedisPushStreamCloseResponseListener redisPushStreamCloseResponseListener; - - - /** - * redis消息监听器容器 可以添加多个监听不同话题的redis监听器,只需要把消息监听器和相应的消息订阅处理器绑定,该消息监听器 - * 通过反射技术调用消息订阅处理器的相关方法进行一些业务处理 - * - * @param connectionFactory - * @return - */ - @Bean - RedisMessageListenerContainer container(RedisConnectionFactory connectionFactory) { - - RedisMessageListenerContainer container = new RedisMessageListenerContainer(); - container.setConnectionFactory(connectionFactory); - container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_GPS)); - container.addMessageListener(redisAlarmMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM_RECEIVE)); - container.addMessageListener(redisStreamMsgListener, new PatternTopic(VideoManagerConstants.WVP_MSG_STREAM_CHANGE_PREFIX + "PUSH")); - container.addMessageListener(redisGbPlayMsgListener, new PatternTopic(RedisGbPlayMsgListener.WVP_PUSH_STREAM_KEY)); - container.addMessageListener(redisPushStreamStatusMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_STATUS_CHANGE)); - container.addMessageListener(redisPushStreamListMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_LIST_CHANGE)); - container.addMessageListener(redisPushStreamResponseListener, new PatternTopic(VideoManagerConstants.VM_MSG_STREAM_PUSH_RESPONSE)); - container.addMessageListener(redisCloseStreamMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_STREAM_PUSH_CLOSE)); - container.addMessageListener(redisPushStreamCloseResponseListener, new PatternTopic(VideoManagerConstants.VM_MSG_STREAM_PUSH_CLOSE_REQUESTED)); - return container; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java deleted file mode 100644 index 56663f18..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.genersoft.iot.vmp.gb28181; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.GbStringMsgParserFactory; -import com.genersoft.iot.vmp.gb28181.conf.DefaultProperties; -import com.genersoft.iot.vmp.gb28181.transmit.ISIPProcessorObserver; -import gov.nist.javax.sip.SipProviderImpl; -import gov.nist.javax.sip.SipStackImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.*; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - -@Component -@Order(value=10) -public class SipLayer implements CommandLineRunner { - - private final static Logger logger = LoggerFactory.getLogger(SipLayer.class); - - @Autowired - private SipConfig sipConfig; - - @Autowired - private ISIPProcessorObserver sipProcessorObserver; - - @Autowired - private UserSetting userSetting; - - private final Map tcpSipProviderMap = new ConcurrentHashMap<>(); - private final Map udpSipProviderMap = new ConcurrentHashMap<>(); - - @Override - public void run(String... args) { - List monitorIps = new ArrayList<>(); - // 使用逗号分割多个ip - String separator = ","; - if (sipConfig.getIp().indexOf(separator) > 0) { - String[] split = sipConfig.getIp().split(separator); - monitorIps.addAll(Arrays.asList(split)); - }else { - monitorIps.add(sipConfig.getIp()); - } - - SipFactory.getInstance().setPathName("gov.nist"); - if (monitorIps.size() > 0) { - for (String monitorIp : monitorIps) { - addListeningPoint(monitorIp, sipConfig.getPort()); - } - if (udpSipProviderMap.size() + tcpSipProviderMap.size() == 0) { - System.exit(1); - } - } - } - - private void addListeningPoint(String monitorIp, int port){ - SipStackImpl sipStack; - try { - sipStack = (SipStackImpl)SipFactory.getInstance().createSipStack(DefaultProperties.getProperties("GB28181_SIP", userSetting.getSipLog())); - sipStack.setMessageParserFactory(new GbStringMsgParserFactory()); - } catch (PeerUnavailableException e) { - logger.error("[SIP SERVER] SIP服务启动失败, 监听地址{}失败,请检查ip是否正确", monitorIp); - return; - } - - try { - ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "TCP"); - SipProviderImpl tcpSipProvider = (SipProviderImpl)sipStack.createSipProvider(tcpListeningPoint); - - tcpSipProvider.setDialogErrorsAutomaticallyHandled(); - tcpSipProvider.addSipListener(sipProcessorObserver); - tcpSipProviderMap.put(monitorIp, tcpSipProvider); - logger.info("[SIP SERVER] tcp://{}:{} 启动成功", monitorIp, port); - } catch (TransportNotSupportedException - | TooManyListenersException - | ObjectInUseException - | InvalidArgumentException e) { - logger.error("[SIP SERVER] tcp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确" - , monitorIp, port); - } - - try { - ListeningPoint udpListeningPoint = sipStack.createListeningPoint(monitorIp, port, "UDP"); - - SipProviderImpl udpSipProvider = (SipProviderImpl)sipStack.createSipProvider(udpListeningPoint); - udpSipProvider.addSipListener(sipProcessorObserver); - - udpSipProviderMap.put(monitorIp, udpSipProvider); - - logger.info("[SIP SERVER] udp://{}:{} 启动成功", monitorIp, port); - } catch (TransportNotSupportedException - | TooManyListenersException - | ObjectInUseException - | InvalidArgumentException e) { - logger.error("[SIP SERVER] udp://{}:{} SIP服务启动失败,请检查端口是否被占用或者ip是否正确" - , monitorIp, port); - } - } - - public SipProviderImpl getUdpSipProvider(String ip) { - if (ObjectUtils.isEmpty(ip)) { - return null; - } - return udpSipProviderMap.get(ip); - } - - public SipProviderImpl getUdpSipProvider() { - if (udpSipProviderMap.size() != 1) { - return null; - } - return udpSipProviderMap.values().stream().findFirst().get(); - } - - public SipProviderImpl getTcpSipProvider() { - if (tcpSipProviderMap.size() != 1) { - return null; - } - return tcpSipProviderMap.values().stream().findFirst().get(); - } - - public SipProviderImpl getTcpSipProvider(String ip) { - if (ObjectUtils.isEmpty(ip)) { - return null; - } - return tcpSipProviderMap.get(ip); - } - - public String getLocalIp(String deviceLocalIp) { - if (!ObjectUtils.isEmpty(deviceLocalIp)) { - return deviceLocalIp; - } - return getUdpSipProvider().getListeningPoint().getIPAddress(); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java deleted file mode 100644 index 05ecb078..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java +++ /dev/null @@ -1,241 +0,0 @@ -/* - * Conditions Of Use - * - * This software was developed by employees of the National Institute of - * Standards and Technology (NIST), an agency of the Federal Government. - * Pursuant to title 15 Untied States Code Section 105, works of NIST - * employees are not subject to copyright protection in the United States - * and are considered to be in the public domain. As a result, a formal - * license is not needed to use the software. - * - * This software is provided by NIST as a service and is expressly - * provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND, EXPRESS, IMPLIED - * OR STATUTORY, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT - * AND DATA ACCURACY. NIST does not warrant or make any representations - * regarding the use of the software or the results thereof, including but - * not limited to the correctness, accuracy, reliability or usefulness of - * the software. - * - * Permission to use this software is contingent upon your acceptance - * of the terms of this agreement - * - * . - * - */ -package com.genersoft.iot.vmp.gb28181.auth; - -import gov.nist.core.InternalErrorHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import javax.sip.address.URI; -import javax.sip.header.AuthorizationHeader; -import javax.sip.header.HeaderFactory; -import javax.sip.header.WWWAuthenticateHeader; -import javax.sip.message.Request; -import javax.sip.message.Response; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; -import java.time.Instant; -import java.util.Random; - -/** - * Implements the HTTP digest authentication method server side functionality. - * - * @author M. Ranganathan - * @author Marc Bednarek - */ - -public class DigestServerAuthenticationHelper { - - private Logger logger = LoggerFactory.getLogger(DigestServerAuthenticationHelper.class); - - private MessageDigest messageDigest; - - public static final String DEFAULT_ALGORITHM = "MD5"; - public static final String DEFAULT_SCHEME = "Digest"; - - - - - /** to hex converter */ - private static final char[] toHex = { '0', '1', '2', '3', '4', '5', '6', - '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; - - /** - * Default constructor. - * @throws NoSuchAlgorithmException - */ - public DigestServerAuthenticationHelper() - throws NoSuchAlgorithmException { - messageDigest = MessageDigest.getInstance(DEFAULT_ALGORITHM); - } - - public static String toHexString(byte b[]) { - int pos = 0; - char[] c = new char[b.length * 2]; - for (int i = 0; i < b.length; i++) { - c[pos++] = toHex[(b[i] >> 4) & 0x0F]; - c[pos++] = toHex[b[i] & 0x0f]; - } - return new String(c); - } - - /** - * Generate the challenge string. - * - * @return a generated nonce. - */ - private String generateNonce() { - long time = Instant.now().toEpochMilli(); - Random rand = new Random(); - long pad = rand.nextLong(); - String nonceString = Long.valueOf(time).toString() - + Long.valueOf(pad).toString(); - byte mdbytes[] = messageDigest.digest(nonceString.getBytes()); - return toHexString(mdbytes); - } - - public Response generateChallenge(HeaderFactory headerFactory, Response response, String realm) { - try { - WWWAuthenticateHeader proxyAuthenticate = headerFactory - .createWWWAuthenticateHeader(DEFAULT_SCHEME); - proxyAuthenticate.setParameter("realm", realm); - proxyAuthenticate.setParameter("qop", "auth"); - proxyAuthenticate.setParameter("nonce", generateNonce()); - proxyAuthenticate.setParameter("algorithm", DEFAULT_ALGORITHM); - - response.setHeader(proxyAuthenticate); - } catch (Exception ex) { - InternalErrorHandler.handleException(ex); - } - return response; - } - /** - * Authenticate the inbound request. - * - * @param request - the request to authenticate. - * @param hashedPassword -- the MD5 hashed string of username:realm:plaintext password. - * - * @return true if authentication succeded and false otherwise. - */ - public boolean doAuthenticateHashedPassword(Request request, String hashedPassword) { - AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); - if ( authHeader == null ) { - return false; - } - String realm = authHeader.getRealm(); - String username = authHeader.getUsername(); - - if ( username == null || realm == null ) { - return false; - } - - String nonce = authHeader.getNonce(); - URI uri = authHeader.getURI(); - if (uri == null) { - return false; - } - - - - String A2 = request.getMethod().toUpperCase() + ":" + uri.toString(); - String HA1 = hashedPassword; - - - byte[] mdbytes = messageDigest.digest(A2.getBytes()); - String HA2 = toHexString(mdbytes); - - String cnonce = authHeader.getCNonce(); - String KD = HA1 + ":" + nonce; - if (cnonce != null) { - KD += ":" + cnonce; - } - KD += ":" + HA2; - mdbytes = messageDigest.digest(KD.getBytes()); - String mdString = toHexString(mdbytes); - String response = authHeader.getResponse(); - - - return mdString.equals(response); - } - - /** - * Authenticate the inbound request given plain text password. - * - * @param request - the request to authenticate. - * @param pass -- the plain text password. - * - * @return true if authentication succeded and false otherwise. - */ - public boolean doAuthenticatePlainTextPassword(Request request, String pass) { - AuthorizationHeader authHeader = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); - if ( authHeader == null || authHeader.getRealm() == null) { - return false; - } - String realm = authHeader.getRealm().trim(); - String username = authHeader.getUsername().trim(); - - if ( username == null || realm == null ) { - return false; - } - - String nonce = authHeader.getNonce(); - URI uri = authHeader.getURI(); - if (uri == null) { - return false; - } - // qop 保护质量 包含auth(默认的)和auth-int(增加了报文完整性检测)两种策略 - String qop = authHeader.getQop(); - - // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 - // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 - String cnonce = authHeader.getCNonce(); - - // nonce计数器,是一个16进制的数值,表示同一nonce下客户端发送出请求的数量 - int nc = authHeader.getNonceCount(); - String ncStr = String.format("%08x", nc).toUpperCase(); - // String ncStr = new DecimalFormat("00000000").format(nc); - // String ncStr = new DecimalFormat("00000000").format(Integer.parseInt(nc + "", 16)); - - String A1 = username + ":" + realm + ":" + pass; - - String A2 = request.getMethod().toUpperCase() + ":" + uri.toString(); - - byte mdbytes[] = messageDigest.digest(A1.getBytes()); - String HA1 = toHexString(mdbytes); - logger.debug("A1: " + A1); - logger.debug("A2: " + A2); - mdbytes = messageDigest.digest(A2.getBytes()); - String HA2 = toHexString(mdbytes); - logger.debug("HA1: " + HA1); - logger.debug("HA2: " + HA2); - // String cnonce = authHeader.getCNonce(); - logger.debug("nonce: " + nonce); - logger.debug("nc: " + ncStr); - logger.debug("cnonce: " + cnonce); - logger.debug("qop: " + qop); - String KD = HA1 + ":" + nonce; - - if (qop != null && qop.equalsIgnoreCase("auth") ) { - if (nc != -1) { - KD += ":" + ncStr; - } - if (cnonce != null) { - KD += ":" + cnonce; - } - KD += ":" + qop; - } - KD += ":" + HA2; - logger.debug("KD: " + KD); - mdbytes = messageDigest.digest(KD.getBytes()); - String mdString = toHexString(mdbytes); - logger.debug("mdString: " + mdString); - String response = authHeader.getResponse(); - logger.debug("response: " + response); - return mdString.equals(response); - - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java deleted file mode 100644 index 7f50f4d3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/AlarmChannelMessage.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - - -/** - * 通过redis分发报警消息 - */ -public class AlarmChannelMessage { - /** - * 国标编号 - */ - private String gbId; - /** - * 报警编号 - */ - private int alarmSn; - /** - * 告警类型 - */ - private int alarmType; - - /** - * 报警描述 - */ - private String alarmDescription; - - public String getGbId() { - return gbId; - } - - public void setGbId(String gbId) { - this.gbId = gbId; - } - - public int getAlarmSn() { - return alarmSn; - } - - public void setAlarmSn(int alarmSn) { - this.alarmSn = alarmSn; - } - - public int getAlarmType() { - return alarmType; - } - - public void setAlarmType(int alarmType) { - this.alarmType = alarmType; - } - - public String getAlarmDescription() { - return alarmDescription; - } - - public void setAlarmDescription(String alarmDescription) { - this.alarmDescription = alarmDescription; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/BaiduPoint.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/BaiduPoint.java deleted file mode 100644 index 8f33f308..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/BaiduPoint.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public class BaiduPoint { - - String bdLng; - - String bdLat; - - public String getBdLng() { - return bdLng; - } - - public void setBdLng(String bdLng) { - this.bdLng = bdLng; - } - - public String getBdLat() { - return bdLat; - } - - public void setBdLat(String bdLat) { - this.bdLat = bdLat; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java deleted file mode 100644 index 965d7f2a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CatalogData.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import java.time.Instant; -import java.util.List; - -/** - * @author lin - */ -public class CatalogData { - /** - * 命令序列号 - */ - private int sn; - private int total; - private List channelList; - private Instant lastTime; - private Device device; - private String errorMsg; - - public enum CatalogDataStatus{ - ready, runIng, end - } - private CatalogDataStatus status; - - - public int getSn() { - return sn; - } - - public void setSn(int sn) { - this.sn = sn; - } - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public List getChannelList() { - return channelList; - } - - public void setChannelList(List channelList) { - this.channelList = channelList; - } - - public Instant getLastTime() { - return lastTime; - } - - public void setLastTime(Instant lastTime) { - this.lastTime = lastTime; - } - - public Device getDevice() { - return device; - } - - public void setDevice(Device device) { - this.device = device; - } - - public String getErrorMsg() { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public CatalogDataStatus getStatus() { - return status; - } - - public void setStatus(CatalogDataStatus status) { - this.status = status; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ChannelIdType.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ChannelIdType.java deleted file mode 100644 index 320bbdd0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ChannelIdType.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -/** - * 国标类型编码,国标编码中11-13位为类型编码 - * 详见 附 录 D 编码规则 A - * @author lin - */ -public class ChannelIdType { - /** - * 中心信令控制服务器编码 - */ - public final static String CENTRAL_SIGNALING_CONTROL_SERVER = "200"; - - /** - * 业务分组编码 - */ - public final static String BUSINESS_GROUP = "215"; - - /** - * 虚拟组织编码 - */ - public final static String VIRTUAL_ORGANIZATION = "216"; -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CmdType.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CmdType.java deleted file mode 100644 index ed5cad6c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/CmdType.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public class CmdType { - - public static final String CATALOG = "Catalog"; - public static final String ALARM = "Alarm"; - public static final String MOBILE_POSITION = "MobilePosition"; -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java deleted file mode 100644 index 8ecedf01..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java +++ /dev/null @@ -1,480 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.fasterxml.jackson.annotation.JsonIgnore; -import com.iteaj.framework.Entity; -import io.swagger.v3.oas.annotations.media.Schema; - -import java.beans.Transient; - -/** - * 国标设备/平台 - * @author lin - */ -@TableName("wvp_device") -@Schema(description = "国标设备/平台") -public class Device implements Entity { - - @TableId(type = IdType.AUTO) - private Long id; - - /** - * 设备国标编号 - */ - private String deviceId; - - /** - * 设备名 - */ - private String name; - - /** - * 生产厂商 - */ - private String manufacturer; - - /** - * 型号 - */ - private String model; - - /** - * 固件版本 - */ - private String firmware; - - /** - * 传输协议 - * UDP/TCP - */ - private String transport; - - /** - * 数据流传输模式 - * UDP:udp传输 - * TCP-ACTIVE:tcp主动模式 - * TCP-PASSIVE:tcp被动模式 - */ - private String streamMode; - - /** - * wan地址_ip - */ - private String ip; - - /** - * wan地址_port - */ - private Integer port; - - /** - * wan地址 - */ - private String hostAddress; - - /** - * 是否在线,true为在线,false为离线 - */ - private Boolean onLine; - - - /** - * 注册时间 - */ - private String registerTime; - - - /** - * 心跳时间 - */ - private String keepaliveTime; - - - /** - * 心跳间隔 - */ - private Integer keepaliveIntervalTime; - - /** - * 通道个数 - */ - @TableField(exist = false) - private Integer channelCount; - - /** - * 注册有效期 - */ - private Integer expires; - - /** - * 创建时间 - */ - private String createTime; - - /** - * 更新时间 - */ - private String updateTime; - - /** - * 设备使用的媒体id, 默认为null - */ - private String mediaServerId; - - /** - * 字符集, 支持 UTF-8 与 GB2312 - */ - private String charset ; - - /** - * 目录订阅周期,0为不订阅 - */ - private int subscribeCycleForCatalog; - - /** - * 移动设备位置订阅周期,0为不订阅 - */ - private int subscribeCycleForMobilePosition; - - /** - * 移动设备位置信息上报时间间隔,单位:秒,默认值5 - */ - private int mobilePositionSubmissionInterval = 5; - - /** - * 报警订阅周期,0为不订阅 - */ - private int subscribeCycleForAlarm; - - /** - * 是否开启ssrc校验,默认关闭,开启可以防止串流 - */ - private Boolean ssrcCheck = false; - - /** - * 地理坐标系, 目前支持 WGS84,GCJ02 - */ - private String geoCoordSys; - - /** - * 密码 - */ - private String password; - - /** - * 收流IP - */ - private String sdpIp; - - /** - * SIP交互IP(设备访问平台的IP) - */ - private String localIp; - - /** - * 是否作为消息通道 - */ - private Boolean asMessageChannel; - - /** - * 设备注册的事务信息 - */ - @TableField(exist = false) - private SipTransactionInfo sipTransactionInfo; - - /*======================设备主子码流逻辑START=========================*/ - /** - * 开启主子码流切换的开关(false-不开启,true-开启) - */ - private Boolean switchPrimarySubStream; - - @Override - public Long getId() { - return id; - } - - @Override - public void setId(Long id) { - this.id = id; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getManufacturer() { - return manufacturer; - } - - public void setManufacturer(String manufacturer) { - this.manufacturer = manufacturer; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - public String getFirmware() { - return firmware; - } - - public void setFirmware(String firmware) { - this.firmware = firmware; - } - - public String getTransport() { - return transport; - } - - public void setTransport(String transport) { - this.transport = transport; - } - - public String getStreamMode() { - return streamMode; - } - - @JsonIgnore - public Integer getStreamModeForParam() { - if (streamMode == null) { - return 0; - } - if (streamMode.equalsIgnoreCase("UDP")) { - return 0; - }else if (streamMode.equalsIgnoreCase("TCP-PASSIVE")) { - return 1; - }else if (streamMode.equalsIgnoreCase("TCP-ACTIVE")) { - return 2; - } - return 0; - } - - public void setStreamMode(String streamMode) { - this.streamMode = streamMode; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public String getHostAddress() { - return hostAddress; - } - - public void setHostAddress(String hostAddress) { - this.hostAddress = hostAddress; - } - - public Boolean isOnLine() { - return onLine; - } - - public void setOnLine(Boolean onLine) { - this.onLine = onLine; - } - - public Integer getChannelCount() { - return channelCount; - } - - public void setChannelCount(Integer channelCount) { - this.channelCount = channelCount; - } - - public String getRegisterTime() { - return registerTime; - } - - public void setRegisterTime(String registerTime) { - this.registerTime = registerTime; - } - - public String getKeepaliveTime() { - return keepaliveTime; - } - - public void setKeepaliveTime(String keepaliveTime) { - this.keepaliveTime = keepaliveTime; - } - - public Integer getExpires() { - return expires; - } - - public void setExpires(Integer expires) { - this.expires = expires; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getCharset() { - return charset; - } - - public void setCharset(String charset) { - this.charset = charset; - } - - public Integer getSubscribeCycleForCatalog() { - return subscribeCycleForCatalog; - } - - public void setSubscribeCycleForCatalog(Integer subscribeCycleForCatalog) { - this.subscribeCycleForCatalog = subscribeCycleForCatalog; - } - - public Integer getSubscribeCycleForMobilePosition() { - return subscribeCycleForMobilePosition; - } - - public void setSubscribeCycleForMobilePosition(Integer subscribeCycleForMobilePosition) { - this.subscribeCycleForMobilePosition = subscribeCycleForMobilePosition; - } - - public Integer getMobilePositionSubmissionInterval() { - return mobilePositionSubmissionInterval; - } - - public void setMobilePositionSubmissionInterval(Integer mobilePositionSubmissionInterval) { - this.mobilePositionSubmissionInterval = mobilePositionSubmissionInterval; - } - - public Integer getSubscribeCycleForAlarm() { - return subscribeCycleForAlarm; - } - - public void setSubscribeCycleForAlarm(Integer subscribeCycleForAlarm) { - this.subscribeCycleForAlarm = subscribeCycleForAlarm; - } - - public Boolean isSsrcCheck() { - return ssrcCheck; - } - - public void setSsrcCheck(Boolean ssrcCheck) { - this.ssrcCheck = ssrcCheck; - } - - public String getGeoCoordSys() { - return geoCoordSys; - } - - public void setGeoCoordSys(String geoCoordSys) { - this.geoCoordSys = geoCoordSys; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public String getSdpIp() { - return sdpIp; - } - - public void setSdpIp(String sdpIp) { - this.sdpIp = sdpIp; - } - - public String getLocalIp() { - return localIp; - } - - public void setLocalIp(String localIp) { - this.localIp = localIp; - } - - public Integer getKeepaliveIntervalTime() { - return keepaliveIntervalTime; - } - - public void setKeepaliveIntervalTime(int keepaliveIntervalTime) { - this.keepaliveIntervalTime = keepaliveIntervalTime; - } - - public Boolean isAsMessageChannel() { - return asMessageChannel; - } - - public void setAsMessageChannel(Boolean asMessageChannel) { - this.asMessageChannel = asMessageChannel; - } - - public SipTransactionInfo getSipTransactionInfo() { - return sipTransactionInfo; - } - - public void setSipTransactionInfo(SipTransactionInfo sipTransactionInfo) { - this.sipTransactionInfo = sipTransactionInfo; - } - - public Boolean isSwitchPrimarySubStream() { - return switchPrimarySubStream; - } - - public void setSwitchPrimarySubStream(Boolean switchPrimarySubStream) { - this.switchPrimarySubStream = switchPrimarySubStream; - } - - - /*======================设备主子码流逻辑END=========================*/ - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java deleted file mode 100644 index a66e336d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarm.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * @author lin - */ -@TableName("wvp_device_alarm") -@Schema(description = "报警信息") -public class DeviceAlarm { - - /** - * 数据库id - */ - @Schema(description = "数据库id") - private String id; - - /** - * 设备Id - */ - @Schema(description = "设备的国标编号") - private String deviceId; - - /** - * 通道Id - */ - @Schema(description = "通道的国标编号") - private String channelId; - - /** - * 报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情 - */ - @Schema(description = "报警级别, 1为一级警情, 2为二级警情, 3为三级警情, 4为四级警情") - private String alarmPriority; - - /** - * 报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警, - * 7其他报警;可以为直接组合如12为电话报警或 设备报警- - */ - @Schema(description = "报警方式 , 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警,\n" + - "\t * 7其他报警;可以为直接组合如12为电话报警或设备报警") - private String alarmMethod; - - /** - * 报警时间 - */ - @Schema(description = "报警时间") - private String alarmTime; - - /** - * 报警内容描述 - */ - @Schema(description = "报警内容描述") - private String alarmDescription; - - /** - * 经度 - */ - @Schema(description = "经度") - private double longitude; - - /** - * 纬度 - */ - @Schema(description = "纬度") - private double latitude; - - /** - * 报警类型, - * 报警方式为2时,不携带 AlarmType为默认的报警设备报警, - * 携带 AlarmType取值及对应报警类型如下: - * 1-视频丢失报警; - * 2-设备防拆报警; - * 3-存储设备磁盘满报警; - * 4-设备高温报警; - * 5-设备低温报警。 - * 报警方式为5时,取值如下: - * 1-人工视频报警; - * 2-运动目标检测报警; - * 3-遗留物检测报警; - * 4-物体移除检测报警; - * 5-绊线检测报警; - * 6-入侵检测报警; - * 7-逆行检测报警; - * 8-徘徊检测报警; - * 9-流量统计报警; - * 10-密度检测报警; - * 11-视频异常检测报警; - * 12-快速移动报警。 - * 报警方式为6时,取值下: - * 1-存储设备磁盘故障报警; - * 2-存储设备风扇故障报警。 - */ - @Schema(description = "报警类型") - private String alarmType; - - @Schema(description = "创建时间") - private String createTime; - - @TableField(exist = false) - private String startTime; - - @TableField(exist = false) - private String endTime; - - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getAlarmPriority() { - return alarmPriority; - } - - public void setAlarmPriority(String alarmPriority) { - this.alarmPriority = alarmPriority; - } - - public String getAlarmMethod() { - return alarmMethod; - } - - public void setAlarmMethod(String alarmMethod) { - this.alarmMethod = alarmMethod; - } - - public String getAlarmTime() { - return alarmTime; - } - - public void setAlarmTime(String alarmTime) { - this.alarmTime = alarmTime; - } - - public String getAlarmDescription() { - return alarmDescription; - } - - public void setAlarmDescription(String alarmDescription) { - this.alarmDescription = alarmDescription; - } - - public double getLongitude() { - return longitude; - } - - public void setLongitude(double longitude) { - this.longitude = longitude; - } - - public double getLatitude() { - return latitude; - } - - public void setLatitude(double latitude) { - this.latitude = latitude; - } - - public String getAlarmType() { - return alarmType; - } - - public void setAlarmType(String alarmType) { - this.alarmType = alarmType; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java deleted file mode 100644 index d1fb6db6..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceAlarmMethod.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -/** - * 报警方式 - * @author lin - * 1为电话报警, 2为设备报警, 3为短信报警, 4为 GPS报警, 5为视频报警, 6为设备故障报警, - * 7其他报警;可以为直接组合如12为电话报警或 设备报警- - */ -public enum DeviceAlarmMethod { - // 1为电话报警 - Telephone(1), - - // 2为设备报警 - Device(2), - - // 3为短信报警 - SMS(3), - - // 4为 GPS报警 - GPS(4), - - // 5为视频报警 - Video(5), - - // 6为设备故障报警 - DeviceFailure(6), - - // 7其他报警 - Other(7); - - private final int val; - - DeviceAlarmMethod(int val) { - this.val=val; - } - - public int getVal() { - return val; - } - - /** - * 查询是否匹配类型 - * @param code - * @return - */ - public static DeviceAlarmMethod typeOf(int code) { - for (DeviceAlarmMethod item : DeviceAlarmMethod.values()) { - if (code==item.getVal()) { - return item; - } - } - return null; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java deleted file mode 100644 index 03b3faba..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java +++ /dev/null @@ -1,563 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.iteaj.framework.Entity; -import io.swagger.v3.oas.annotations.media.Schema; - -@TableName("wvp_device_channel") -@Schema(description = "通道信息") -public class DeviceChannel implements Entity { - - - /** - * 数据库自增ID - */ - @TableId(type = IdType.AUTO) - private Long id; - - /** - * 通道国标编号 - */ - private String channelId; - - /** - * 设备国标编号 - */ - private String deviceId; - - /** - * 通道名 - */ - private String name; - - /** - * 生产厂商 - */ - private String manufacture; - - /** - * 型号 - */ - private String model; - - /** - * 设备归属 - */ - private String owner; - - /** - * 行政区域 - */ - private String civilCode; - - /** - * 警区 - */ - private String block; - - /** - * 安装地址 - */ - private String address; - - /** - * 是否有子设备 1有, 0没有 - */ - private Integer parental; - - /** - * 父级id - */ - private String parentId; - - /** - * 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式 - */ - private Integer safetyWay; - - /** - * 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式 - */ - private Integer registerWay; - - /** - * 证书序列号 - */ - private String certNum; - - /** - * 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效 - */ - private Integer certifiable; - - /** - * 证书无效原因码 - */ - private Integer errCode; - - /** - * 证书终止有效期 - */ - private String endTime; - - /** - * 保密属性 缺省为0; 0:不涉密, 1:涉密 - */ - private String secrecy; - - /** - * IP地址 - */ - private String ipAddress; - - /** - * 端口号 - */ - private Integer port; - - /** - * 密码 - */ - private String password; - - /** - * 云台类型 - */ - private Integer ptzType; - - private Integer customPtzType; - - /** - * 云台类型描述字符串 - */ - @TableField(exist = false) - private String ptzTypeText; - - /** - * 创建时间 - */ - private String createTime; - - /** - * 更新时间 - */ - private String updateTime; - - /** - * 在线/离线 - * 1在线,0离线 - * 默认在线 - * 信令: - * ON - * OFF - * 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF - */ - private Boolean status; - - /** - * 经度 - */ - private Double longitude; - - /** - * 纬度 - */ - private Double latitude; - - /** - * GCJ02坐标系经度 - */ - private Double longitudeGcj02; - - /** - * 纬度 GCJ02 - */ - private Double latitudeGcj02; - - /** - * 经度 WGS84 - */ - private Double longitudeWgs84; - - /** - * 纬度 WGS84 - */ - private Double latitudeWgs84; - - /** - * 子设备数 - */ - private Integer subCount; - - /** - * 流唯一编号,存在表示正在直播 - */ - private String streamId; - - /** - * 是否含有音频 - */ - private Boolean hasAudio; - - /** - * 标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划 - */ - @TableField(exist = false) - private Integer channelType; - - /** - * 业务分组 - */ - private String businessGroupId; - - /** - * GPS的更新时间 - */ - private String gpsTime; - - @Override - public Long getId() { - return id; - } - - @Override - public void setId(Long id) { - this.id = id; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public void setPtzType(int ptzType) { - this.ptzType = ptzType; - switch (ptzType) { - case 0: - this.ptzTypeText = "未知"; - break; - case 1: - this.ptzTypeText = "球机"; - break; - case 2: - this.ptzTypeText = "半球"; - break; - case 3: - this.ptzTypeText = "固定枪机"; - break; - case 4: - this.ptzTypeText = "遥控枪机"; - break; - } - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getManufacture() { - return manufacture; - } - - public void setManufacture(String manufacture) { - this.manufacture = manufacture; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getCivilCode() { - return civilCode; - } - - public void setCivilCode(String civilCode) { - this.civilCode = civilCode; - } - - public String getBlock() { - return block; - } - - public void setBlock(String block) { - this.block = block; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public Integer getParental() { - return parental; - } - - public void setParental(Integer parental) { - this.parental = parental; - } - - public String getParentId() { - return parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } - - public Integer getSafetyWay() { - return safetyWay; - } - - public void setSafetyWay(Integer safetyWay) { - this.safetyWay = safetyWay; - } - - public Integer getRegisterWay() { - return registerWay; - } - - public void setRegisterWay(Integer registerWay) { - this.registerWay = registerWay; - } - - public String getCertNum() { - return certNum; - } - - public void setCertNum(String certNum) { - this.certNum = certNum; - } - - public Integer getCertifiable() { - return certifiable; - } - - public void setCertifiable(Integer certifiable) { - this.certifiable = certifiable; - } - - public Integer getErrCode() { - return errCode; - } - - public void setErrCode(Integer errCode) { - this.errCode = errCode; - } - - public String getEndTime() { - return endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getSecrecy() { - return secrecy; - } - - public void setSecrecy(String secrecy) { - this.secrecy = secrecy; - } - - public String getIpAddress() { - return ipAddress; - } - - public void setIpAddress(String ipAddress) { - this.ipAddress = ipAddress; - } - - public Integer getPort() { - return port; - } - - public void setPort(Integer port) { - this.port = port; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public Integer getPtzType() { - return ptzType; - } - - public void setPtzType(Integer ptzType) { - this.ptzType = ptzType; - } - - public Integer getCustomPtzType() { - return customPtzType; - } - - public void setCustomPtzType(Integer customPtzType) { - this.customPtzType = customPtzType; - } - - public String getPtzTypeText() { - return ptzTypeText; - } - - public void setPtzTypeText(String ptzTypeText) { - this.ptzTypeText = ptzTypeText; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public Boolean isStatus() { - return status; - } - - public void setStatus(Boolean status) { - this.status = status; - } - - public Double getLongitude() { - return longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - public Double getLatitude() { - return latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - - public Double getLongitudeGcj02() { - return longitudeGcj02; - } - - public void setLongitudeGcj02(Double longitudeGcj02) { - this.longitudeGcj02 = longitudeGcj02; - } - - public Double getLatitudeGcj02() { - return latitudeGcj02; - } - - public void setLatitudeGcj02(Double latitudeGcj02) { - this.latitudeGcj02 = latitudeGcj02; - } - - public Double getLongitudeWgs84() { - return longitudeWgs84; - } - - public void setLongitudeWgs84(Double longitudeWgs84) { - this.longitudeWgs84 = longitudeWgs84; - } - - public Double getLatitudeWgs84() { - return latitudeWgs84; - } - - public void setLatitudeWgs84(Double latitudeWgs84) { - this.latitudeWgs84 = latitudeWgs84; - } - - public Integer getSubCount() { - return subCount; - } - - public void setSubCount(Integer subCount) { - this.subCount = subCount; - } - - public String getStreamId() { - return streamId; - } - - public void setStreamId(String streamId) { - this.streamId = streamId; - } - - public Boolean isHasAudio() { - return hasAudio; - } - - public void setHasAudio(Boolean hasAudio) { - this.hasAudio = hasAudio; - } - - public Integer getChannelType() { - return channelType; - } - - public void setChannelType(Integer channelType) { - this.channelType = channelType; - } - - public String getBusinessGroupId() { - return businessGroupId; - } - - public void setBusinessGroupId(String businessGroupId) { - this.businessGroupId = businessGroupId; - } - - public String getGpsTime() { - return gpsTime; - } - - public void setGpsTime(String gpsTime) { - this.gpsTime = gpsTime; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannelInPlatform.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannelInPlatform.java deleted file mode 100644 index c61bb088..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannelInPlatform.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public class DeviceChannelInPlatform extends DeviceChannel{ - - private String platFormId; - private String catalogId; - - public String getPlatFormId() { - return platFormId; - } - - public void setPlatFormId(String platFormId) { - this.platFormId = platFormId; - } - - public String getCatalogId() { - return catalogId; - } - - public void setCatalogId(String catalogId) { - this.catalogId = catalogId; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceNotFoundEvent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceNotFoundEvent.java deleted file mode 100644 index c782c3c1..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceNotFoundEvent.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import javax.sip.Dialog; -import java.util.EventObject; - -public class DeviceNotFoundEvent extends EventObject { - - private String callId; - - /** - * Constructs a prototypical Event. - * - * @param dialog - * @throws IllegalArgumentException if source is null. - */ - public DeviceNotFoundEvent(Dialog dialog) { - super(dialog); - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DragZoomRequest.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DragZoomRequest.java deleted file mode 100644 index 86fdb4d2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DragZoomRequest.java +++ /dev/null @@ -1,143 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.genersoft.iot.vmp.gb28181.utils.MessageElement; - -/** - * 设备信息查询响应 - * - * @author Y.G - * @version 1.0 - * @date 2022/6/28 14:55 - */ -public class DragZoomRequest { - /** - * 序列号 - */ - @MessageElement("SN") - private String sn; - - @MessageElement("DeviceID") - private String deviceId; - - @MessageElement(value = "DragZoomIn") - private DragZoom dragZoomIn; - - @MessageElement(value = "DragZoomOut") - private DragZoom dragZoomOut; - - /** - * 基本参数 - */ - public static class DragZoom { - /** - * 播放窗口长度像素值 - */ - @MessageElement("Length") - protected Integer length; - /** - * 播放窗口宽度像素值 - */ - @MessageElement("Width") - protected Integer width; - /** - * 拉框中心的横轴坐标像素值 - */ - @MessageElement("MidPointX") - protected Integer midPointX; - /** - * 拉框中心的纵轴坐标像素值 - */ - @MessageElement("MidPointY") - protected Integer midPointY; - /** - * 拉框长度像素值 - */ - @MessageElement("LengthX") - protected Integer lengthX; - /** - * 拉框宽度像素值 - */ - @MessageElement("LengthY") - protected Integer lengthY; - - public Integer getLength() { - return length; - } - - public void setLength(Integer length) { - this.length = length; - } - - public Integer getWidth() { - return width; - } - - public void setWidth(Integer width) { - this.width = width; - } - - public Integer getMidPointX() { - return midPointX; - } - - public void setMidPointX(Integer midPointX) { - this.midPointX = midPointX; - } - - public Integer getMidPointY() { - return midPointY; - } - - public void setMidPointY(Integer midPointY) { - this.midPointY = midPointY; - } - - public Integer getLengthX() { - return lengthX; - } - - public void setLengthX(Integer lengthX) { - this.lengthX = lengthX; - } - - public Integer getLengthY() { - return lengthY; - } - - public void setLengthY(Integer lengthY) { - this.lengthY = lengthY; - } - } - - public String getSn() { - return sn; - } - - public void setSn(String sn) { - this.sn = sn; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public DragZoom getDragZoomIn() { - return dragZoomIn; - } - - public void setDragZoomIn(DragZoom dragZoomIn) { - this.dragZoomIn = dragZoomIn; - } - - public DragZoom getDragZoomOut() { - return dragZoomOut; - } - - public void setDragZoomOut(DragZoom dragZoomOut) { - this.dragZoomOut = dragZoomOut; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GBStringMsgParser.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GBStringMsgParser.java deleted file mode 100644 index 2abc3569..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GBStringMsgParser.java +++ /dev/null @@ -1,457 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import gov.nist.core.CommonLogger; -import gov.nist.core.Host; -import gov.nist.core.HostNameParser; -import gov.nist.core.StackLogger; -import gov.nist.javax.sip.SIPConstants; -import gov.nist.javax.sip.address.AddressImpl; -import gov.nist.javax.sip.address.GenericURI; -import gov.nist.javax.sip.address.SipUri; -import gov.nist.javax.sip.address.TelephoneNumber; -import gov.nist.javax.sip.header.*; -import gov.nist.javax.sip.message.SIPMessage; -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; -import gov.nist.javax.sip.parser.*; - -import java.io.UnsupportedEncodingException; -import java.text.ParseException; - -public class GBStringMsgParser implements MessageParser { - - protected static boolean computeContentLengthFromMessage = false; - - private static StackLogger logger = CommonLogger.getLogger(StringMsgParser.class); - - /** - * @since v0.9 - */ - public GBStringMsgParser() { - super(); - } - - /** - * Parse a buffer containing a single SIP Message where the body is an array - * of un-interpreted bytes. This is intended for parsing the message from a - * memory buffer when the buffer. Incorporates a bug fix for a bug that was - * noted by Will Sullin of Callcast - * - * @param msgBuffer - * a byte buffer containing the messages to be parsed. This can - * consist of multiple SIP Messages concatenated together. - * @return a SIPMessage[] structure (request or response) containing the - * parsed SIP message. - * @exception ParseException - * is thrown when an illegal message has been encountered - * (and the rest of the buffer is discarded). - * @see ParseExceptionListener - */ - public SIPMessage parseSIPMessage(byte[] msgBuffer, boolean readBody, boolean strict, ParseExceptionListener parseExceptionListener) throws ParseException { - if (msgBuffer == null || msgBuffer.length == 0) - return null; - - int i = 0; - - // Squeeze out any leading control character. - try { - while (msgBuffer[i] < 0x20) - i++; - } - catch (ArrayIndexOutOfBoundsException e) { - // Array contains only control char, return null. - if (logger.isLoggingEnabled(StackLogger.TRACE_DEBUG)) { - logger.logDebug("handled only control char so returning null"); - } - return null; - } - - // Iterate thru the request/status line and headers. - String currentLine = null; - String currentHeader = null; - boolean isFirstLine = true; - SIPMessage message = null; - do - { - int lineStart = i; - - // Find the length of the line. - try { - while (msgBuffer[i] != '\r' && msgBuffer[i] != '\n') - i++; - } - catch (ArrayIndexOutOfBoundsException e) { - // End of the message. - break; - } - int lineLength = i - lineStart; - - // Make it a String. - try { - currentLine = new String(msgBuffer, lineStart, lineLength, "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new ParseException("Bad message encoding!", 0); - } - - currentLine = trimEndOfLine(currentLine); - - if (currentLine.length() == 0) { - // Last header line, process the previous buffered header. - if (currentHeader != null && message != null) { - processHeader(currentHeader, message, parseExceptionListener, msgBuffer); - } - - } - else { - if (isFirstLine) { - message = processFirstLine(currentLine, parseExceptionListener, msgBuffer); - } else { - char firstChar = currentLine.charAt(0); - if (firstChar == '\t' || firstChar == ' ') { - if (currentHeader == null) - throw new ParseException("Bad header continuation.", 0); - - // This is a continuation, append it to the previous line. - currentHeader += currentLine.substring(1); - } - else { - if (currentHeader != null && message != null) { - processHeader(currentHeader, message, parseExceptionListener, msgBuffer); - } - currentHeader = currentLine; - } - } - } - - if (msgBuffer[i] == '\r' && msgBuffer.length > i+1 && msgBuffer[i+1] == '\n') - i++; - - i++; - - isFirstLine = false; - } while (currentLine.length() > 0); // End do - while - - if (message == null) throw new ParseException("Bad message", 0); - message.setSize(i); - - // Check for content legth header - if (readBody && message.getContentLength() != null ) { - if ( message.getContentLength().getContentLength() != 0) { - int bodyLength = msgBuffer.length - i; - - byte[] body = new byte[bodyLength]; - System.arraycopy(msgBuffer, i, body, 0, bodyLength); - message.setMessageContent(body,!strict,computeContentLengthFromMessage,message.getContentLength().getContentLength()); - } else if (message.getCSeqHeader().getMethod().equalsIgnoreCase("MESSAGE")) { - int bodyLength = msgBuffer.length - i; - - byte[] body = new byte[bodyLength]; - System.arraycopy(msgBuffer, i, body, 0, bodyLength); - message.setMessageContent(body,!strict,computeContentLengthFromMessage,bodyLength); - }else if (!computeContentLengthFromMessage && strict) { - String last4Chars = new String(msgBuffer, msgBuffer.length - 4, 4); - if(!"\r\n\r\n".equals(last4Chars)) { - throw new ParseException("Extraneous characters at the end of the message ",i); - } - } - } - - return message; - } - - protected static String trimEndOfLine(String line) { - if (line == null) - return line; - - int i = line.length() - 1; - while (i >= 0 && line.charAt(i) <= 0x20) - i--; - - if (i == line.length() - 1) - return line; - - if (i == -1) - return ""; - - return line.substring(0, i+1); - } - - protected SIPMessage processFirstLine(String firstLine, ParseExceptionListener parseExceptionListener, byte[] msgBuffer) throws ParseException { - SIPMessage message; - if (!firstLine.startsWith(SIPConstants.SIP_VERSION_STRING)) { - message = new SIPRequest(); - try { - RequestLine requestLine = new RequestLineParser(firstLine + "\n") - .parse(); - ((SIPRequest) message).setRequestLine(requestLine); - } catch (ParseException ex) { - if (parseExceptionListener != null) - try { - parseExceptionListener.handleException(ex, message, - RequestLine.class, firstLine, new String(msgBuffer, "UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - else - throw ex; - - } - } else { - message = new SIPResponse(); - try { - StatusLine sl = new StatusLineParser(firstLine + "\n").parse(); - ((SIPResponse) message).setStatusLine(sl); - } catch (ParseException ex) { - if (parseExceptionListener != null) { - try { - parseExceptionListener.handleException(ex, message, - StatusLine.class, firstLine, new String(msgBuffer, "UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - } else - throw ex; - - } - } - return message; - } - - protected void processHeader(String header, SIPMessage message, ParseExceptionListener parseExceptionListener, byte[] rawMessage) throws ParseException { - if (header == null || header.length() == 0) - return; - - HeaderParser headerParser = null; - try { - headerParser = ParserFactory.createParser(header + "\n"); - } catch (ParseException ex) { - // https://java.net/jira/browse/JSIP-456 - if (parseExceptionListener != null) { - parseExceptionListener.handleException(ex, message, null, - header, null); - return; - } else { - throw ex; - } - } - - try { - SIPHeader sipHeader = headerParser.parse(); - message.attachHeader(sipHeader, false); - } catch (ParseException ex) { - if (parseExceptionListener != null) { - String headerName = Lexer.getHeaderName(header); - Class headerClass = NameMap.getClassFromName(headerName); - if (headerClass == null) { - headerClass = ExtensionHeaderImpl.class; - - } - try { - parseExceptionListener.handleException(ex, message, - headerClass, header, new String(rawMessage, "UTF-8")); - } catch (UnsupportedEncodingException e) { - e.printStackTrace(); - } - - } - } - } - - /** - * Parse an address (nameaddr or address spec) and return and address - * structure. - * - * @param address - * is a String containing the address to be parsed. - * @return a parsed address structure. - * @since v1.0 - * @exception ParseException - * when the address is badly formatted. - */ - public AddressImpl parseAddress(String address) throws ParseException { - AddressParser addressParser = new AddressParser(address); - return addressParser.address(true); - } - - /** - * Parse a host:port and return a parsed structure. - * - * @param hostport - * is a String containing the host:port to be parsed - * @return a parsed address structure. - * @since v1.0 - * @exception throws - * a ParseException when the address is badly formatted. - * - public HostPort parseHostPort(String hostport) throws ParseException { - Lexer lexer = new Lexer("charLexer", hostport); - return new HostNameParser(lexer).hostPort(); - - } - */ - - /** - * Parse a host name and return a parsed structure. - * - * @param host - * is a String containing the host name to be parsed - * @return a parsed address structure. - * @since v1.0 - * @exception ParseException - * a ParseException when the hostname is badly formatted. - */ - public Host parseHost(String host) throws ParseException { - Lexer lexer = new Lexer("charLexer", host); - return new HostNameParser(lexer).host(); - - } - - /** - * Parse a telephone number return a parsed structure. - * - * @param telephone_number - * is a String containing the telephone # to be parsed - * @return a parsed address structure. - * @since v1.0 - * @exception ParseException - * a ParseException when the address is badly formatted. - */ - public TelephoneNumber parseTelephoneNumber(String telephone_number) - throws ParseException { - // Bug fix contributed by Will Scullin - return new URLParser(telephone_number).parseTelephoneNumber(true); - - } - - /** - * Parse a SIP url from a string and return a URI structure for it. - * - * @param url - * a String containing the URI structure to be parsed. - * @return A parsed URI structure - * @exception ParseException - * if there was an error parsing the message. - */ - - public SipUri parseSIPUrl(String url) throws ParseException { - try { - return new URLParser(url).sipURL(true); - } catch (ClassCastException ex) { - throw new ParseException(url + " Not a SIP URL ", 0); - } - } - - /** - * Parse a uri from a string and return a URI structure for it. - * - * @param url - * a String containing the URI structure to be parsed. - * @return A parsed URI structure - * @exception ParseException - * if there was an error parsing the message. - */ - - public GenericURI parseUrl(String url) throws ParseException { - return new URLParser(url).parse(); - } - - /** - * Parse an individual SIP message header from a string. - * - * @param header - * String containing the SIP header. - * @return a SIPHeader structure. - * @exception ParseException - * if there was an error parsing the message. - */ - public static SIPHeader parseSIPHeader(String header) throws ParseException { - int start = 0; - int end = header.length() - 1; - try { - // Squeeze out any leading control character. - while (header.charAt(start) <= 0x20) - start++; - - // Squeeze out any trailing control character. - while (header.charAt(end) <= 0x20) - end--; - } - catch (ArrayIndexOutOfBoundsException e) { - // Array contains only control char. - throw new ParseException("Empty header.", 0); - } - - StringBuilder buffer = new StringBuilder(end + 1); - int i = start; - int lineStart = start; - boolean endOfLine = false; - while (i <= end) { - char c = header.charAt(i); - if (c == '\r' || c == '\n') { - if (!endOfLine) { - buffer.append(header.substring(lineStart, i)); - endOfLine = true; - } - } - else { - if (endOfLine) { - endOfLine = false; - if (c == ' ' || c == '\t') { - buffer.append(' '); - lineStart = i + 1; - } - else { - lineStart = i; - } - } - } - - i++; - } - buffer.append(header.substring(lineStart, i)); - buffer.append('\n'); - - HeaderParser hp = ParserFactory.createParser(buffer.toString()); - if (hp == null) - throw new ParseException("could not create parser", 0); - return hp.parse(); - } - - /** - * Parse the SIP Request Line - * - * @param requestLine - * a String containing the request line to be parsed. - * @return a RequestLine structure that has the parsed RequestLine - * @exception ParseException - * if there was an error parsing the requestLine. - */ - - public RequestLine parseSIPRequestLine(String requestLine) - throws ParseException { - requestLine += "\n"; - return new RequestLineParser(requestLine).parse(); - } - - /** - * Parse the SIP Response message status line - * - * @param statusLine - * a String containing the Status line to be parsed. - * @return StatusLine class corresponding to message - * @exception ParseException - * if there was an error parsing - * @see StatusLine - */ - - public StatusLine parseSIPStatusLine(String statusLine) - throws ParseException { - statusLine += "\n"; - return new StatusLineParser(statusLine).parse(); - } - - public static void setComputeContentLengthFromMessage( - boolean computeContentLengthFromMessage) { - GBStringMsgParser.computeContentLengthFromMessage = computeContentLengthFromMessage; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Gb28181Sdp.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Gb28181Sdp.java deleted file mode 100644 index 4b9e26a0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Gb28181Sdp.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import javax.sdp.SessionDescription; - -/** - * 28181 的SDP解析器 - */ -public class Gb28181Sdp { - private SessionDescription baseSdb; - private String ssrc; - - private String mediaDescription; - - public static Gb28181Sdp getInstance(SessionDescription baseSdb, String ssrc, String mediaDescription) { - Gb28181Sdp gb28181Sdp = new Gb28181Sdp(); - gb28181Sdp.setBaseSdb(baseSdb); - gb28181Sdp.setSsrc(ssrc); - gb28181Sdp.setMediaDescription(mediaDescription); - return gb28181Sdp; - } - - - public SessionDescription getBaseSdb() { - return baseSdb; - } - - public void setBaseSdb(SessionDescription baseSdb) { - this.baseSdb = baseSdb; - } - - public String getSsrc() { - return ssrc; - } - - public void setSsrc(String ssrc) { - this.ssrc = ssrc; - } - - public String getMediaDescription() { - return mediaDescription; - } - - public void setMediaDescription(String mediaDescription) { - this.mediaDescription = mediaDescription; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbSipDate.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbSipDate.java deleted file mode 100644 index 0631c5d0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbSipDate.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import gov.nist.core.InternalErrorHandler; -import gov.nist.javax.sip.header.SIPDate; - -import java.util.*; - -/** - * 重写jain sip的SIPDate解决与国标时间格式不一致的问题 - */ -public class GbSipDate extends SIPDate { - - /** - * - */ - private static final long serialVersionUID = 1L; - - private Calendar javaCal; - - public GbSipDate(long timeMillis) { - this.javaCal = new GregorianCalendar(TimeZone.getDefault(), Locale.getDefault()); - Date date = new Date(timeMillis); - this.javaCal.setTime(date); - this.wkday = this.javaCal.get(7); - switch(this.wkday) { - case 1: - this.sipWkDay = "Sun"; - break; - case 2: - this.sipWkDay = "Mon"; - break; - case 3: - this.sipWkDay = "Tue"; - break; - case 4: - this.sipWkDay = "Wed"; - break; - case 5: - this.sipWkDay = "Thu"; - break; - case 6: - this.sipWkDay = "Fri"; - break; - case 7: - this.sipWkDay = "Sat"; - break; - default: - InternalErrorHandler.handleException("No date map for wkday " + this.wkday); - } - - this.day = this.javaCal.get(5); - this.month = this.javaCal.get(2); - switch(this.month) { - case 0: - this.sipMonth = "Jan"; - break; - case 1: - this.sipMonth = "Feb"; - break; - case 2: - this.sipMonth = "Mar"; - break; - case 3: - this.sipMonth = "Apr"; - break; - case 4: - this.sipMonth = "May"; - break; - case 5: - this.sipMonth = "Jun"; - break; - case 6: - this.sipMonth = "Jul"; - break; - case 7: - this.sipMonth = "Aug"; - break; - case 8: - this.sipMonth = "Sep"; - break; - case 9: - this.sipMonth = "Oct"; - break; - case 10: - this.sipMonth = "Nov"; - break; - case 11: - this.sipMonth = "Dec"; - break; - default: - InternalErrorHandler.handleException("No date map for month " + this.month); - } - - this.year = this.javaCal.get(1); - this.hour = this.javaCal.get(11); - this.minute = this.javaCal.get(12); - this.second = this.javaCal.get(13); - } - - @Override - public StringBuilder encode(StringBuilder var1) { - String var2; - if (this.month < 9) { - var2 = "0" + (this.month + 1); - } else { - var2 = "" + (this.month + 1); - } - - String var3; - if (this.day < 10) { - var3 = "0" + this.day; - } else { - var3 = "" + this.day; - } - - String var4; - if (this.hour < 10) { - var4 = "0" + this.hour; - } else { - var4 = "" + this.hour; - } - - String var5; - if (this.minute < 10) { - var5 = "0" + this.minute; - } else { - var5 = "" + this.minute; - } - - String var6; - if (this.second < 10) { - var6 = "0" + this.second; - } else { - var6 = "" + this.second; - } - - int var8 = this.javaCal.get(14); - String var7; - if (var8 < 10) { - var7 = "00" + var8; - } else if (var8 < 100) { - var7 = "0" + var8; - } else { - var7 = "" + var8; - } - - return var1.append(this.year).append("-").append(var2).append("-").append(var3).append("T").append(var4).append(":").append(var5).append(":").append(var6).append(".").append(var7); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java deleted file mode 100644 index 1ef69328..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * 直播流关联国标上级平台 - * @author lin - */ -@TableName("wvp_gb_stream") -@Schema(description = "直播流关联国标上级平台") -public class GbStream extends PlatformGbStream { - - @Schema(description = "应用名") - private String app; - - @Schema(description = "流ID") - private String stream; - - @Schema(description = "国标ID") - private String gbId; - - @Schema(description = "名称") - private String name; - - @Schema(description = "流媒体ID") - private String mediaServerId; - - @Schema(description = "经度") - private double longitude; - - @Schema(description = "纬度") - private double latitude; - - @Schema(description = "流类型(拉流/推流)") - private String streamType; - - @Schema(description = "状态") - private Boolean status; - - @Schema(description = "创建时间") - private String createTime; - - @TableField(exist = false) - private String query; - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getGbId() { - return gbId; - } - - public void setGbId(String gbId) { - this.gbId = gbId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public double getLongitude() { - return longitude; - } - - public void setLongitude(double longitude) { - this.longitude = longitude; - } - - public double getLatitude() { - return latitude; - } - - public void setLatitude(double latitude) { - this.latitude = latitude; - } - - public String getStreamType() { - return streamType; - } - - public void setStreamType(String streamType) { - this.streamType = streamType; - } - - public boolean isStatus() { - return status; - } - - public void setStatus(boolean status) { - this.status = status; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getQuery() { - return query; - } - - public void setQuery(String query) { - this.query = query; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStringMsgParserFactory.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStringMsgParserFactory.java deleted file mode 100644 index 10c3339e..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStringMsgParserFactory.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import gov.nist.javax.sip.parser.MessageParser; -import gov.nist.javax.sip.parser.MessageParserFactory; -import gov.nist.javax.sip.stack.SIPTransactionStack; - -public class GbStringMsgParserFactory implements MessageParserFactory { - - /** - * msg parser is completely stateless, reuse isntance for the whole stack - * fixes https://github.com/RestComm/jain-sip/issues/92 - */ - private static GBStringMsgParser msgParser = new GBStringMsgParser(); - /* - * (non-Javadoc) - * @see gov.nist.javax.sip.parser.MessageParserFactory#createMessageParser(gov.nist.javax.sip.stack.SIPTransactionStack) - */ - @Override - public MessageParser createMessageParser(SIPTransactionStack stack) { - return msgParser; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/HandlerCatchData.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/HandlerCatchData.java deleted file mode 100644 index 97da8630..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/HandlerCatchData.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import org.dom4j.Element; - -import javax.sip.RequestEvent; - -/** - * @author lin - */ -public class HandlerCatchData { - private RequestEvent evt; - private Device device; - private Element rootElement; - - public HandlerCatchData(RequestEvent evt, Device device, Element rootElement) { - this.evt = evt; - this.device = device; - this.rootElement = rootElement; - } - - public RequestEvent getEvt() { - return evt; - } - - public void setEvt(RequestEvent evt) { - this.evt = evt; - } - - public Device getDevice() { - return device; - } - - public void setDevice(Device device) { - this.device = device; - } - - public Element getRootElement() { - return rootElement; - } - - public void setRootElement(Element rootElement) { - this.rootElement = rootElement; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/HomePositionRequest.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/HomePositionRequest.java deleted file mode 100644 index 2c20713b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/HomePositionRequest.java +++ /dev/null @@ -1,94 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.genersoft.iot.vmp.gb28181.utils.MessageElement; - -/** - * 设备信息查询响应 - * - * @author Y.G - * @version 1.0 - * @date 2022/6/28 14:55 - */ -public class HomePositionRequest { - /** - * 序列号 - */ - @MessageElement("SN") - private String sn; - - @MessageElement("DeviceID") - private String deviceId; - - @MessageElement(value = "HomePosition") - private HomePosition homePosition; - - - /** - * 基本参数 - */ - public static class HomePosition { - /** - * 播放窗口长度像素值 - */ - @MessageElement("Enabled") - protected String enabled; - /** - * 播放窗口宽度像素值 - */ - @MessageElement("ResetTime") - protected String resetTime; - /** - * 拉框中心的横轴坐标像素值 - */ - @MessageElement("PresetIndex") - protected String presetIndex; - - public String getEnabled() { - return enabled; - } - - public void setEnabled(String enabled) { - this.enabled = enabled; - } - - public String getResetTime() { - return resetTime; - } - - public void setResetTime(String resetTime) { - this.resetTime = resetTime; - } - - public String getPresetIndex() { - return presetIndex; - } - - public void setPresetIndex(String presetIndex) { - this.presetIndex = presetIndex; - } - } - - public String getSn() { - return sn; - } - - public void setSn(String sn) { - this.sn = sn; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public HomePosition getHomePosition() { - return homePosition; - } - - public void setHomePosition(HomePosition homePosition) { - this.homePosition = homePosition; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Host.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Host.java deleted file mode 100644 index 1b145604..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Host.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - - - -public class Host { - - private String ip; - private int port; - private String address; - - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamCallback.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamCallback.java deleted file mode 100644 index 42a05198..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamCallback.java +++ /dev/null @@ -1,5 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public interface InviteStreamCallback { - void call(InviteStreamInfo inviteStreamInfo); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java deleted file mode 100644 index 134930b3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamInfo.java +++ /dev/null @@ -1,61 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; - -public class InviteStreamInfo { - - public InviteStreamInfo(MediaServerItem mediaServerItem, JSONObject response, String callId, String app, String stream) { - this.mediaServerItem = mediaServerItem; - this.response = response; - this.callId = callId; - this.app = app; - this.stream = stream; - } - - private MediaServerItem mediaServerItem; - private JSONObject response; - private String callId; - private String app; - private String stream; - - public MediaServerItem getMediaServerItem() { - return mediaServerItem; - } - - public void setMediaServerItem(MediaServerItem mediaServerItem) { - this.mediaServerItem = mediaServerItem; - } - - public JSONObject getResponse() { - return response; - } - - public void setResponse(JSONObject response) { - this.response = response; - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java deleted file mode 100644 index 677dcd71..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public enum InviteStreamType { - - PLAY,PLAYBACK,DOWNLOAD,PUSH,PROXY,CLOUD_RECORD_PUSH,CLOUD_RECORD_PROXY - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java deleted file mode 100644 index 00a33f24..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java +++ /dev/null @@ -1,220 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.baomidou.mybatisplus.annotation.TableName; -import com.iteaj.framework.Entity; - -/** - * @description: 移动位置bean - * @author: lawrencehj - * @date: 2021年1月23日 - */ -@TableName("wvp_device_mobile_position") -public class MobilePosition implements Entity { - - private Long id; - - /** - * 设备Id - */ - private String deviceId; - - /** - * 通道Id - */ - private String channelId; - - /** - * 设备名称 - */ - private String deviceName; - - /** - * 通知时间 - */ - private String time; - - /** - * 经度 - */ - private Double longitude; - - /** - * 纬度 - */ - private Double latitude; - - /** - * 海拔高度 - */ - private Double altitude; - - /** - * 速度 - */ - private Double speed; - - /** - * 方向 - */ - private Double direction; - - /** - * 位置信息上报来源(Mobile Position、GPS Alarm) - */ - private String reportSource; - - /** - * 国内坐标系:经度坐标 - */ - private Double longitudeGcj02; - - /** - * 国内坐标系:纬度坐标 - */ - private Double latitudeGcj02; - - /** - * 国内坐标系:经度坐标 - */ - private Double longitudeWgs84; - - /** - * 国内坐标系:纬度坐标 - */ - private Double latitudeWgs84; - - /** - * 创建时间 - */ - private String createTime; - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getDeviceName() { - return deviceName; - } - - public void setDeviceName(String deviceName) { - this.deviceName = deviceName; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public Double getLongitude() { - return longitude; - } - - public void setLongitude(Double longitude) { - this.longitude = longitude; - } - - public Double getLatitude() { - return latitude; - } - - public void setLatitude(Double latitude) { - this.latitude = latitude; - } - - public Double getAltitude() { - return altitude; - } - - public void setAltitude(Double altitude) { - this.altitude = altitude; - } - - public Double getSpeed() { - return speed; - } - - public void setSpeed(Double speed) { - this.speed = speed; - } - - public Double getDirection() { - return direction; - } - - public void setDirection(Double direction) { - this.direction = direction; - } - - public String getReportSource() { - return reportSource; - } - - public void setReportSource(String reportSource) { - this.reportSource = reportSource; - } - - public Double getLongitudeGcj02() { - return longitudeGcj02; - } - - public void setLongitudeGcj02(Double longitudeGcj02) { - this.longitudeGcj02 = longitudeGcj02; - } - - public Double getLatitudeGcj02() { - return latitudeGcj02; - } - - public void setLatitudeGcj02(Double latitudeGcj02) { - this.latitudeGcj02 = latitudeGcj02; - } - - public Double getLongitudeWgs84() { - return longitudeWgs84; - } - - public void setLongitudeWgs84(Double longitudeWgs84) { - this.longitudeWgs84 = longitudeWgs84; - } - - public Double getLatitudeWgs84() { - return latitudeWgs84; - } - - public void setLatitudeWgs84(Double latitudeWgs84) { - this.latitudeWgs84 = latitudeWgs84; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - @Override - public Long getId() { - return null; - } - - @Override - public void setId(Long id) { - this.id = id; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java deleted file mode 100644 index 77374ebe..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java +++ /dev/null @@ -1,452 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * @author lin - */ -@TableName("wvp_platform") -@Schema(description = "平台信息") -public class ParentPlatform { - - /** - * id - */ - @Schema(description = "ID(数据库中)") - private Integer id; - - /** - * 是否启用 - */ - @Schema(description = "是否启用") - private Boolean enable; - - /** - * 名称 - */ - @Schema(description = "名称") - private String name; - - /** - * SIP服务国标编码 - */ - @Schema(description = "SIP服务国标编码") - @TableField("server_gb_id") - private String serverGBId; - - /** - * SIP服务国标域 - */ - @Schema(description = "SIP服务国标域") - @TableField("server_gb_domain") - private String serverGBDomain; - - /** - * SIP服务IP - */ - @Schema(description = "SIP服务IP") - private String serverIp; - - /** - * SIP服务端口 - */ - @Schema(description = "SIP服务端口") - private Integer serverPort; - - /** - * 设备国标编号 - */ - @Schema(description = "设备国标编号") - @TableField("device_gb_id") - private String deviceGBId; - - /** - * 设备ip - */ - @Schema(description = "设备ip") - private String deviceIp; - - /** - * 设备端口 - */ - @Schema(description = "设备端口") - private String devicePort; - - /** - * SIP认证用户名(默认使用设备国标编号) - */ - @Schema(description = "SIP认证用户名(默认使用设备国标编号)") - private String username; - - /** - * SIP认证密码 - */ - @Schema(description = "SIP认证密码") - private String password; - - /** - * 注册周期 (秒) - */ - @Schema(description = "注册周期 (秒)") - private Integer expires; - - /** - * 心跳周期(秒) - */ - @Schema(description = "心跳周期(秒)") - private Integer keepTimeout; - - /** - * 传输协议 - * UDP/TCP - */ - @Schema(description = "传输协议") - private String transport; - - /** - * 字符集 - */ - @Schema(description = "字符集") - private String characterSet; - - /** - * 允许云台控制 - */ - @Schema(description = "允许云台控制") - private Boolean ptz; - - /** - * RTCP流保活 - */ - @Schema(description = "RTCP流保活") - private Boolean rtcp; - - /** - * 在线状态 - */ - @Schema(description = "在线状态") - private Boolean status; - - /** - * 在线状态 - */ - @TableField(exist = false) - @Schema(description = "通道数量") - private Integer channelCount; - - /** - * 默认目录Id,自动添加的通道多放在这个目录下 - */ - @Schema(description = "默认目录Id,自动添加的通道多放在这个目录下") - private String catalogId; - - /** - * 已被订阅目录信息 - */ - @TableField(exist = false) - @Schema(description = "已被订阅目录信息") - private Boolean catalogSubscribe; - - /** - * 已被订阅报警信息 - */ - @TableField(exist = false) - @Schema(description = "已被订阅报警信息") - private Boolean alarmSubscribe; - - /** - * 已被订阅移动位置信息 - */ - @TableField(exist = false) - @Schema(description = "已被订阅移动位置信息") - private Boolean mobilePositionSubscribe; - - /** - * 点播未推流的设备时是否使用redis通知拉起 - */ - @Schema(description = "点播未推流的设备时是否使用redis通知拉起") - private Boolean startOfflinePush; - - /** - * 目录分组-每次向上级发送通道信息时单个包携带的通道数量,取值1,2,4,8 - */ - @Schema(description = "目录分组-每次向上级发送通道信息时单个包携带的通道数量,取值1,2,4,8") - private Integer catalogGroup; - - /** - * 行政区划 - */ - @Schema(description = "行政区划") - private String administrativeDivision; - - /** - * 更新时间 - */ - @Schema(description = "更新时间") - private String updateTime; - - /** - * 创建时间 - */ - @Schema(description = "创建时间") - private String createTime; - - @Schema(description = "是否作为消息通道") - private Boolean asMessageChannel; - - @Schema(description = "是否作为消息通道") - private Boolean autoPushChannel; - - public Integer getId() { - return id; - } - - public void setId(Integer id) { - this.id = id; - } - - public Boolean isEnable() { - return enable; - } - - public void setEnable(Boolean enable) { - this.enable = enable; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getServerGBId() { - return serverGBId; - } - - public void setServerGBId(String serverGBId) { - this.serverGBId = serverGBId; - } - - public String getServerGBDomain() { - return serverGBDomain; - } - - public void setServerGBDomain(String serverGBDomain) { - this.serverGBDomain = serverGBDomain; - } - - - - public int getServerPort() { - return serverPort; - } - - public void setServerPort(int serverPort) { - this.serverPort = serverPort; - } - - public String getDeviceGBId() { - return deviceGBId; - } - - public void setDeviceGBId(String deviceGBId) { - this.deviceGBId = deviceGBId; - } - - public String getDeviceIp() { - return deviceIp; - } - - public void setDeviceIp(String deviceIp) { - this.deviceIp = deviceIp; - } - - public String getDevicePort() { - return devicePort; - } - - public void setDevicePort(String devicePort) { - this.devicePort = devicePort; - } - - public String getUsername() { - return username; - } - - public void setUsername(String username) { - this.username = username; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public int getExpires() { - return expires; - } - - public void setExpires(int expires) { - this.expires = expires; - } - - public int getKeepTimeout() { - return keepTimeout; - } - - public void setKeepTimeout(int keepTimeout) { - this.keepTimeout = keepTimeout; - } - - public String getTransport() { - return transport; - } - - public void setTransport(String transport) { - this.transport = transport; - } - - public String getCharacterSet() { - return characterSet; - } - - public void setCharacterSet(String characterSet) { - this.characterSet = characterSet; - } - - public Boolean isPtz() { - return ptz; - } - - public void setPtz(Boolean ptz) { - this.ptz = ptz; - } - - public Boolean isRtcp() { - return rtcp; - } - - public void setRtcp(Boolean rtcp) { - this.rtcp = rtcp; - } - - public Boolean isStatus() { - return status; - } - - public void setStatus(Boolean status) { - this.status = status; - } - - public int getChannelCount() { - return channelCount; - } - - public void setChannelCount(int channelCount) { - this.channelCount = channelCount; - } - - public String getCatalogId() { - return catalogId; - } - - public void setCatalogId(String catalogId) { - this.catalogId = catalogId; - } - - public Boolean isCatalogSubscribe() { - return catalogSubscribe; - } - - public void setCatalogSubscribe(Boolean catalogSubscribe) { - this.catalogSubscribe = catalogSubscribe; - } - - public Boolean isAlarmSubscribe() { - return alarmSubscribe; - } - - public void setAlarmSubscribe(Boolean alarmSubscribe) { - this.alarmSubscribe = alarmSubscribe; - } - - public Boolean isMobilePositionSubscribe() { - return mobilePositionSubscribe; - } - - public void setMobilePositionSubscribe(Boolean mobilePositionSubscribe) { - this.mobilePositionSubscribe = mobilePositionSubscribe; - } - - public Boolean isStartOfflinePush() { - return startOfflinePush; - } - - public void setStartOfflinePush(Boolean startOfflinePush) { - this.startOfflinePush = startOfflinePush; - } - - public int getCatalogGroup() { - return catalogGroup; - } - - public void setCatalogGroup(int catalogGroup) { - this.catalogGroup = catalogGroup; - } - - public String getAdministrativeDivision() { - return administrativeDivision; - } - - public void setAdministrativeDivision(String administrativeDivision) { - this.administrativeDivision = administrativeDivision; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public Boolean isAsMessageChannel() { - return asMessageChannel; - } - - public void setAsMessageChannel(Boolean asMessageChannel) { - this.asMessageChannel = asMessageChannel; - } - - public Boolean isAutoPushChannel() { - return autoPushChannel; - } - - public void setAutoPushChannel(Boolean autoPushChannel) { - this.autoPushChannel = autoPushChannel; - } - - public String getServerIp() { - return serverIp; - } - - public void setServerIp(String serverIp) { - this.serverIp = serverIp; - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java deleted file mode 100644 index 6ff2fe32..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatformCatch.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public class ParentPlatformCatch { - - private String id; - - /** - * 心跳未回复次数 - */ - private int keepAliveReply; - - // 注册未回复次数 - private int registerAliveReply; - - private String callId; - - private ParentPlatform parentPlatform; - - private SipTransactionInfo sipTransactionInfo; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public int getKeepAliveReply() { - return keepAliveReply; - } - - public void setKeepAliveReply(int keepAliveReply) { - this.keepAliveReply = keepAliveReply; - } - - public int getRegisterAliveReply() { - return registerAliveReply; - } - - public void setRegisterAliveReply(int registerAliveReply) { - this.registerAliveReply = registerAliveReply; - } - - public ParentPlatform getParentPlatform() { - return parentPlatform; - } - - public void setParentPlatform(ParentPlatform parentPlatform) { - this.parentPlatform = parentPlatform; - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } - - public SipTransactionInfo getSipTransactionInfo() { - return sipTransactionInfo; - } - - public void setSipTransactionInfo(SipTransactionInfo sipTransactionInfo) { - this.sipTransactionInfo = sipTransactionInfo; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java deleted file mode 100644 index 6ae7896f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * 国标级联-目录 - * @author lin - */ -@TableName("wvp_platform_catalog") -@Schema(description = "目录信息") -public class PlatformCatalog { - - @Schema(description = "ID") - private String id; - - @Schema(description = "名称") - private String name; - - @Schema(description = "平台ID") - private String platformId; - - @Schema(description = "父级目录ID") - private String parentId; - - @Schema(description = "行政区划") - private String civilCode; - - @Schema(description = "目录分组") - private String businessGroupId; - - /** - * 子节点数 - */ - @TableField(exist = false) - @Schema(description = "子节点数") - private int childrenCount; - - /** - * 0 目录, 1 国标通道, 2 直播流 - */ - @TableField(exist = false) - @Schema(description = "类型:0 目录, 1 国标通道, 2 直播流") - private int type; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public String getParentId() { - return parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } - - public int getChildrenCount() { - return childrenCount; - } - - public void setChildrenCount(int childrenCount) { - this.childrenCount = childrenCount; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public void setTypeForCatalog() { - this.type = 0; - } - - public void setTypeForGb() { - this.type = 1; - } - - public void setTypeForStream() { - this.type = 2; - } - - public String getCivilCode() { - return civilCode; - } - - public void setCivilCode(String civilCode) { - this.civilCode = civilCode; - } - - public String getBusinessGroupId() { - return businessGroupId; - } - - public void setBusinessGroupId(String businessGroupId) { - this.businessGroupId = businessGroupId; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java deleted file mode 100644 index e16a1c41..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.v3.oas.annotations.media.Schema; - -@TableName("wvp_platform_gb_stream") -public class PlatformGbStream { - - @TableId(type = IdType.AUTO) - @Schema(description = "ID") - private Integer gbStreamId; - - @Schema(description = "平台ID") - private String platformId; - - @Schema(description = "目录ID") - private String catalogId; - - public Integer getGbStreamId() { - return gbStreamId; - } - - public void setGbStreamId(Integer gbStreamId) { - this.gbStreamId = gbStreamId; - } - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public String getCatalogId() { - return catalogId; - } - - public void setCatalogId(String catalogId) { - this.catalogId = catalogId; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformRegister.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformRegister.java deleted file mode 100644 index 4a45862c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformRegister.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public class PlatformRegister { - - // 未回复次数 - private int reply; - - public int getReply() { - return reply; - } - - public void setReply(int reply) { - this.reply = reply; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java deleted file mode 100644 index d1971a2e..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - - -/** - * @author chenjialing - */ -public class PresetQuerySipReq { - - private String presetId; - - private String presetName; - - public String getPresetId() { - return presetId; - } - - public void setPresetId(String presetId) { - this.presetId = presetId; - } - - public String getPresetName() { - return presetName; - } - - public void setPresetName(String presetName) { - this.presetName = presetName; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java deleted file mode 100644 index 5b524cf6..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java +++ /dev/null @@ -1,102 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - - -import io.swagger.v3.oas.annotations.media.Schema; - -import java.time.Instant; -import java.util.List; - -/** - * @description:设备录像信息bean - * @author: swwheihei - * @date: 2020年5月8日 下午2:05:56 - */ -@Schema(description = "设备录像查询结果信息") -public class RecordInfo { - - @Schema(description = "设备编号") - private String deviceId; - - @Schema(description = "通道编号") - private String channelId; - - @Schema(description = "命令序列号") - private String sn; - - @Schema(description = "设备名称") - private String name; - - @Schema(description = "列表总数") - private int sumNum; - - private int count; - - private Instant lastTime; - - @Schema(description = "") - private List recordList; - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getSumNum() { - return sumNum; - } - - public void setSumNum(int sumNum) { - this.sumNum = sumNum; - } - - public List getRecordList() { - return recordList; - } - - public void setRecordList(List recordList) { - this.recordList = recordList; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getSn() { - return sn; - } - - public void setSn(String sn) { - this.sn = sn; - } - - public Instant getLastTime() { - return lastTime; - } - - public void setLastTime(Instant lastTime) { - this.lastTime = lastTime; - } - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordItem.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordItem.java deleted file mode 100644 index 452e1388..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordItem.java +++ /dev/null @@ -1,144 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - - -import com.genersoft.iot.vmp.utils.DateUtil; -import io.swagger.v3.oas.annotations.media.Schema; -import org.jetbrains.annotations.NotNull; - -import java.time.Instant; -import java.time.temporal.TemporalAccessor; - -/** - * @description:设备录像bean - * @author: swwheihei - * @date: 2020年5月8日 下午2:06:54 - */ -@Schema(description = "设备录像详情") -public class RecordItem implements Comparable{ - - @Schema(description = "设备编号") - private String deviceId; - - @Schema(description = "名称") - private String name; - - @Schema(description = "文件路径名 (可选)") - private String filePath; - - @Schema(description = "录像文件大小,单位:Byte(可选)") - private String fileSize; - - @Schema(description = "录像地址(可选)") - private String address; - - @Schema(description = "录像开始时间(可选)") - private String startTime; - - @Schema(description = "录像结束时间(可选)") - private String endTime; - - @Schema(description = "保密属性(必选)缺省为0;0:不涉密,1:涉密") - private int secrecy; - - @Schema(description = "录像产生类型(可选)time或alarm 或 manua") - private String type; - - @Schema(description = "录像触发者ID(可选)") - private String recorderId; - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getFilePath() { - return filePath; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public int getSecrecy() { - return secrecy; - } - - public void setSecrecy(int secrecy) { - this.secrecy = secrecy; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getRecorderId() { - return recorderId; - } - - public void setRecorderId(String recorderId) { - this.recorderId = recorderId; - } - - public String getFileSize() { - return fileSize; - } - - public void setFileSize(String fileSize) { - this.fileSize = fileSize; - } - - @Override - public int compareTo(@NotNull RecordItem recordItem) { - TemporalAccessor startTimeNow = DateUtil.formatter.parse(startTime); - TemporalAccessor startTimeParam = DateUtil.formatter.parse(recordItem.getStartTime()); - Instant startTimeParamInstant = Instant.from(startTimeParam); - Instant startTimeNowInstant = Instant.from(startTimeNow); - if (startTimeNowInstant.equals(startTimeParamInstant)) { - return 0; - }else if (Instant.from(startTimeParam).isAfter(Instant.from(startTimeNow)) ) { - return -1; - }else { - return 1; - } - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RemoteAddressInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RemoteAddressInfo.java deleted file mode 100644 index 4107593f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/RemoteAddressInfo.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public class RemoteAddressInfo { - private String ip; - private int port; - - public RemoteAddressInfo(String ip, int port) { - this.ip = ip; - this.port = port; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SDPInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SDPInfo.java deleted file mode 100644 index 39225b57..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SDPInfo.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import javax.sdp.SessionDescription; - -public class SDPInfo { - private byte[] source; - private SessionDescription sdpSource; - private String sessionName; - private Long startTime; - private Long stopTime; - private String username; - private String address; - private String ssrc; -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java deleted file mode 100644 index c1fe2c1f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java +++ /dev/null @@ -1,295 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -public class SendRtpItem { - - /** - * 推流ip - */ - private String ip; - - /** - * 推流端口 - */ - private int port; - - /** - * 推流标识 - */ - private String ssrc; - - /** - * 平台id - */ - private String platformId; - - /** - * 对应设备id - */ - private String deviceId; - - /** - * 直播流的应用名 - */ - private String app; - - /** - * 通道id - */ - private String channelId; - - /** - * 推流状态 - * 0 等待设备推流上来 - * 1 等待上级平台回复ack - * 2 推流中 - */ - private int status = 0; - - - /** - * 设备推流的streamId - */ - private String streamId; - - /** - * 是否为tcp - */ - private boolean tcp; - - /** - * 是否为tcp主动模式 - */ - private boolean tcpActive; - - /** - * 自己推流使用的端口 - */ - private int localPort; - - /** - * 使用的流媒体 - */ - private String mediaServerId; - - /** - * 使用的服务的ID - */ - private String serverId; - - /** - * invite 的 callId - */ - private String CallId; - - /** - * invite 的 fromTag - */ - private String fromTag; - - /** - * invite 的 toTag - */ - private String toTag; - - /** - * 发送时,rtp的pt(uint8_t),不传时默认为96 - */ - private int pt = 96; - - /** - * 发送时,rtp的负载类型。为true时,负载为ps;为false时,为es; - */ - private boolean usePs = true; - - /** - * 当usePs 为false时,有效。为1时,发送音频;为0时,发送视频;不传时默认为0 - */ - private boolean onlyAudio = false; - - /** - * 是否开启rtcp保活 - */ - private boolean rtcp = false; - - - /** - * 播放类型 - */ - private InviteStreamType playType; - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getSsrc() { - return ssrc; - } - - public void setSsrc(String ssrc) { - this.ssrc = ssrc; - } - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public int getStatus() { - return status; - } - - public void setStatus(int status) { - this.status = status; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStreamId() { - return streamId; - } - - public void setStreamId(String streamId) { - this.streamId = streamId; - } - - public boolean isTcp() { - return tcp; - } - - public void setTcp(boolean tcp) { - this.tcp = tcp; - } - - public int getLocalPort() { - return localPort; - } - - public void setLocalPort(int localPort) { - this.localPort = localPort; - } - - public boolean isTcpActive() { - return tcpActive; - } - - public void setTcpActive(boolean tcpActive) { - this.tcpActive = tcpActive; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getCallId() { - return CallId; - } - - public void setCallId(String callId) { - CallId = callId; - } - - public InviteStreamType getPlayType() { - return playType; - } - - public void setPlayType(InviteStreamType playType) { - this.playType = playType; - } - - public int getPt() { - return pt; - } - - public void setPt(int pt) { - this.pt = pt; - } - - public boolean isUsePs() { - return usePs; - } - - public void setUsePs(boolean usePs) { - this.usePs = usePs; - } - - public boolean isOnlyAudio() { - return onlyAudio; - } - - public void setOnlyAudio(boolean onlyAudio) { - this.onlyAudio = onlyAudio; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public String getFromTag() { - return fromTag; - } - - public void setFromTag(String fromTag) { - this.fromTag = fromTag; - } - - public String getToTag() { - return toTag; - } - - public void setToTag(String toTag) { - this.toTag = toTag; - } - - public boolean isRtcp() { - return rtcp; - } - - public void setRtcp(boolean rtcp) { - this.rtcp = rtcp; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipMsgInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipMsgInfo.java deleted file mode 100644 index 302539b6..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipMsgInfo.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import org.dom4j.Element; - -import javax.sip.RequestEvent; - -public class SipMsgInfo { - private RequestEvent evt; - private Device device; - private ParentPlatform platform; - private Element rootElement; - - public SipMsgInfo(RequestEvent evt, Device device, Element rootElement) { - this.evt = evt; - this.device = device; - this.rootElement = rootElement; - } - - public SipMsgInfo(RequestEvent evt, ParentPlatform platform, Element rootElement) { - this.evt = evt; - this.platform = platform; - this.rootElement = rootElement; - } - - public RequestEvent getEvt() { - return evt; - } - - public void setEvt(RequestEvent evt) { - this.evt = evt; - } - - public Device getDevice() { - return device; - } - - public void setDevice(Device device) { - this.device = device; - } - - public ParentPlatform getPlatform() { - return platform; - } - - public void setPlatform(ParentPlatform platform) { - this.platform = platform; - } - - public Element getRootElement() { - return rootElement; - } - - public void setRootElement(Element rootElement) { - this.rootElement = rootElement; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipTransactionInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipTransactionInfo.java deleted file mode 100644 index c04a6959..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SipTransactionInfo.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; - -public class SipTransactionInfo { - - private String callId; - private String fromTag; - private String toTag; - private String viaBranch; - - public SipTransactionInfo(SIPResponse response) { - this.callId = response.getCallIdHeader().getCallId(); - this.fromTag = response.getFromTag(); - this.toTag = response.getToTag(); - this.viaBranch = response.getTopmostViaHeader().getBranch(); - } - - public SipTransactionInfo() { - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } - - public String getFromTag() { - return fromTag; - } - - public void setFromTag(String fromTag) { - this.fromTag = fromTag; - } - - public String getToTag() { - return toTag; - } - - public void setToTag(String toTag) { - this.toTag = toTag; - } - - public String getViaBranch() { - return viaBranch; - } - - public void setViaBranch(String viaBranch) { - this.viaBranch = viaBranch; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java deleted file mode 100644 index 6ed8d144..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SsrcTransaction.java +++ /dev/null @@ -1,81 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.genersoft.iot.vmp.common.InviteSessionType; - -public class SsrcTransaction { - - private String deviceId; - private String channelId; - private String callId; - private String stream; - private String mediaServerId; - private String ssrc; - - private SipTransactionInfo sipTransactionInfo; - - private InviteSessionType type; - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getSsrc() { - return ssrc; - } - - public void setSsrc(String ssrc) { - this.ssrc = ssrc; - } - - public InviteSessionType getType() { - return type; - } - - public void setType(InviteSessionType type) { - this.type = type; - } - - public SipTransactionInfo getSipTransactionInfo() { - return sipTransactionInfo; - } - - public void setSipTransactionInfo(SipTransactionInfo sipTransactionInfo) { - this.sipTransactionInfo = sipTransactionInfo; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java deleted file mode 100644 index d932a208..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeHolder.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeHandlerTask; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author lin - */ -@Component -public class SubscribeHolder { - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private UserSetting userSetting; - - private final String taskOverduePrefix = "subscribe_overdue_"; - - private static ConcurrentHashMap catalogMap = new ConcurrentHashMap<>(); - private static ConcurrentHashMap mobilePositionMap = new ConcurrentHashMap<>(); - - - public void putCatalogSubscribe(String platformId, SubscribeInfo subscribeInfo) { - catalogMap.put(platformId, subscribeInfo); - if (subscribeInfo.getExpires() > 0) { - // 添加订阅到期 - String taskOverdueKey = taskOverduePrefix + "catalog_" + platformId; - // 添加任务处理订阅过期 - dynamicTask.startDelay(taskOverdueKey, () -> removeCatalogSubscribe(subscribeInfo.getId()), - subscribeInfo.getExpires() * 1000); - } - } - - public SubscribeInfo getCatalogSubscribe(String platformId) { - return catalogMap.get(platformId); - } - - public void removeCatalogSubscribe(String platformId) { - - catalogMap.remove(platformId); - String taskOverdueKey = taskOverduePrefix + "catalog_" + platformId; - Runnable runnable = dynamicTask.get(taskOverdueKey); - if (runnable instanceof ISubscribeTask) { - ISubscribeTask subscribeTask = (ISubscribeTask) runnable; - subscribeTask.stop(); - } - // 添加任务处理订阅过期 - dynamicTask.stop(taskOverdueKey); - } - - public void putMobilePositionSubscribe(String platformId, SubscribeInfo subscribeInfo) { - mobilePositionMap.put(platformId, subscribeInfo); - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; - // 添加任务处理GPS定时推送 - dynamicTask.startCron(key, new MobilePositionSubscribeHandlerTask(platformId), - subscribeInfo.getGpsInterval() * 1000); - String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; - if (subscribeInfo.getExpires() > 0) { - // 添加任务处理订阅过期 - dynamicTask.startDelay(taskOverdueKey, () -> { - removeMobilePositionSubscribe(subscribeInfo.getId()); - }, - subscribeInfo.getExpires() * 1000); - } - } - - public SubscribeInfo getMobilePositionSubscribe(String platformId) { - return mobilePositionMap.get(platformId); - } - - public void removeMobilePositionSubscribe(String platformId) { - mobilePositionMap.remove(platformId); - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "MobilePosition_" + platformId; - // 结束任务处理GPS定时推送 - dynamicTask.stop(key); - String taskOverdueKey = taskOverduePrefix + "MobilePosition_" + platformId; - Runnable runnable = dynamicTask.get(taskOverdueKey); - if (runnable instanceof ISubscribeTask) { - ISubscribeTask subscribeTask = (ISubscribeTask) runnable; - subscribeTask.stop(); - } - // 添加任务处理订阅过期 - dynamicTask.stop(taskOverdueKey); - } - - public List getAllCatalogSubscribePlatform() { - List platforms = new ArrayList<>(); - if(catalogMap.size() > 0) { - for (String key : catalogMap.keySet()) { - platforms.add(catalogMap.get(key).getId()); - } - } - return platforms; - } - - public void removeAllSubscribe(String platformId) { - removeMobilePositionSubscribe(platformId); - removeCatalogSubscribe(platformId); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java deleted file mode 100644 index e5c50455..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SubscribeInfo.java +++ /dev/null @@ -1,141 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; - -import javax.sip.header.*; - -public class SubscribeInfo { - - - public SubscribeInfo(SIPRequest request, String id) { - this.id = id; - this.request = request; - this.expires = request.getExpires().getExpires(); - EventHeader eventHeader = (EventHeader)request.getHeader(EventHeader.NAME); - this.eventId = eventHeader.getEventId(); - this.eventType = eventHeader.getEventType(); - - } - - public SubscribeInfo() { - } - - private String id; - - private SIPRequest request; - private int expires; - private String eventId; - private String eventType; - private SIPResponse response; - - /** - * 以下为可选字段 - * @return - */ - private String sn; - private int gpsInterval; - - /** - * 模拟的FromTag - */ - private String simulatedFromTag; - - /** - * 模拟的ToTag - */ - private String simulatedToTag; - - /** - * 模拟的CallID - */ - private String simulatedCallId; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public SIPRequest getRequest() { - return request; - } - - public void setRequest(SIPRequest request) { - this.request = request; - } - - public int getExpires() { - return expires; - } - - public void setExpires(int expires) { - this.expires = expires; - } - - public String getEventId() { - return eventId; - } - - public void setEventId(String eventId) { - this.eventId = eventId; - } - - public String getEventType() { - return eventType; - } - - public void setEventType(String eventType) { - this.eventType = eventType; - } - - public SIPResponse getResponse() { - return response; - } - - public void setResponse(SIPResponse response) { - this.response = response; - } - - public String getSn() { - return sn; - } - - public void setSn(String sn) { - this.sn = sn; - } - - public int getGpsInterval() { - return gpsInterval; - } - - public void setGpsInterval(int gpsInterval) { - this.gpsInterval = gpsInterval; - } - - public String getSimulatedFromTag() { - return simulatedFromTag; - } - - public void setSimulatedFromTag(String simulatedFromTag) { - this.simulatedFromTag = simulatedFromTag; - } - - public String getSimulatedCallId() { - return simulatedCallId; - } - - public void setSimulatedCallId(String simulatedCallId) { - this.simulatedCallId = simulatedCallId; - } - - public String getSimulatedToTag() { - return simulatedToTag; - } - - public void setSimulatedToTag(String simulatedToTag) { - this.simulatedToTag = simulatedToTag; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SyncStatus.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SyncStatus.java deleted file mode 100644 index 373b971c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SyncStatus.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.bean; - -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * 摄像机同步状态 - * @author lin - */ -@Schema(description = "摄像机同步状态") -public class SyncStatus { - @Schema(description = "总数") - private int total; - @Schema(description = "当前更新多少") - private int current; - @Schema(description = "错误描述") - private String errorMsg; - @Schema(description = "是否同步中") - private boolean syncIng; - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public int getCurrent() { - return current; - } - - public void setCurrent(int current) { - this.current = current; - } - - public String getErrorMsg() { - return errorMsg; - } - - public void setErrorMsg(String errorMsg) { - this.errorMsg = errorMsg; - } - - public boolean isSyncIng() { - return syncIng; - } - - public void setSyncIng(boolean syncIng) { - this.syncIng = syncIng; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java deleted file mode 100644 index e2c9ef58..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/DefaultProperties.java +++ /dev/null @@ -1,63 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.conf; - -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd.AlarmNotifyMessageHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Properties; - -/** - * 获取sip默认配置 - * @author lin - */ -public class DefaultProperties { - - public static Properties getProperties(String name, boolean sipLog) { - Properties properties = new Properties(); - properties.setProperty("javax.sip.STACK_NAME", name); -// properties.setProperty("javax.sip.IP_ADDRESS", ip); - // 关闭自动会话 - properties.setProperty("javax.sip.AUTOMATIC_DIALOG_SUPPORT", "off"); - /** - * 完整配置参考 gov.nist.javax.sip.SipStackImpl,需要下载源码 - * gov/nist/javax/sip/SipStackImpl.class - * sip消息的解析在 gov.nist.javax.sip.stack.UDPMessageChannel的processIncomingDataPacket方法 - */ - -// * gov/nist/javax/sip/SipStackImpl.class - // 接收所有notify请求,即使没有订阅 - properties.setProperty("gov.nist.javax.sip.DELIVER_UNSOLICITED_NOTIFY", "true"); - properties.setProperty("gov.nist.javax.sip.AUTOMATIC_DIALOG_ERROR_HANDLING", "false"); - properties.setProperty("gov.nist.javax.sip.CANCEL_CLIENT_TRANSACTION_CHECKED", "true"); - // 为_NULL _对话框传递_终止的_事件 - properties.setProperty("gov.nist.javax.sip.DELIVER_TERMINATED_EVENT_FOR_NULL_DIALOG", "true"); - // 是否自动计算content length的实际长度,默认不计算 - properties.setProperty("gov.nist.javax.sip.COMPUTE_CONTENT_LENGTH_FROM_MESSAGE_BODY", "true"); - // 会话清理策略 - properties.setProperty("gov.nist.javax.sip.RELEASE_REFERENCES_STRATEGY", "Normal"); - // 处理由该服务器处理的基于底层TCP的保持生存超时 - properties.setProperty("gov.nist.javax.sip.RELIABLE_CONNECTION_KEEP_ALIVE_TIMEOUT", "60"); - // 获取实际内容长度,不使用header中的长度信息 - properties.setProperty("gov.nist.javax.sip.COMPUTE_CONTENT_LENGTH_FROM_MESSAGE_BODY", "true"); - // 线程可重入 - properties.setProperty("gov.nist.javax.sip.REENTRANT_LISTENER", "true"); - // 定义应用程序打算多久审计一次 SIP 堆栈,了解其内部线程的健康状况(该属性指定连续审计之间的时间(以毫秒为单位)) - properties.setProperty("gov.nist.javax.sip.THREAD_AUDIT_INTERVAL_IN_MILLISECS", "30000"); - -// properties.setProperty("gov.nist.javax.sip.MESSAGE_PROCESSOR_FACTORY", "gov.nist.javax.sip.stack.NioMessageProcessorFactory"); - - /** - * sip_server_log.log 和 sip_debug_log.log ERROR, INFO, WARNING, OFF, DEBUG, TRACE - */ - Logger logger = LoggerFactory.getLogger(AlarmNotifyMessageHandler.class); - if (sipLog) { - properties.setProperty("gov.nist.javax.sip.STACK_LOGGER", "com.genersoft.iot.vmp.gb28181.conf.StackLoggerImpl"); - properties.setProperty("gov.nist.javax.sip.SERVER_LOGGER", "com.genersoft.iot.vmp.gb28181.conf.ServerLoggerImpl"); - properties.setProperty("gov.nist.javax.sip.LOG_MESSAGE_CONTENT", "true"); - logger.info("[SIP日志]已开启"); - }else { - logger.info("[SIP日志]已关闭"); - } - return properties; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/ServerLoggerImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/ServerLoggerImpl.java deleted file mode 100644 index c7b1f6e6..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/ServerLoggerImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.conf; - -import gov.nist.core.CommonLogger; -import gov.nist.core.ServerLogger; -import gov.nist.core.StackLogger; -import gov.nist.javax.sip.message.SIPMessage; -import gov.nist.javax.sip.stack.SIPTransactionStack; - -import javax.sip.SipStack; -import java.util.Properties; - -public class ServerLoggerImpl implements ServerLogger { - - private boolean showLog = true; - - private SIPTransactionStack sipStack; - - protected StackLogger stackLogger; - - @Override - public void closeLogFile() { - - } - - @Override - public void logMessage(SIPMessage message, String from, String to, boolean sender, long time) { - if (!showLog) { - return; - } - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(sender? "发送:目标--->" + from:"接收:来自--->" + to) - .append("\r\n") - .append(message); - this.stackLogger.logInfo(stringBuilder.toString()); - - } - - @Override - public void logMessage(SIPMessage message, String from, String to, String status, boolean sender, long time) { - if (!showLog) { - return; - } - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(sender? "发送: 目标->" + from :"接收:来自->" + to) - .append("\r\n") - .append(message); - this.stackLogger.logInfo(stringBuilder.toString()); - } - - @Override - public void logMessage(SIPMessage message, String from, String to, String status, boolean sender) { - if (!showLog) { - return; - } - StringBuilder stringBuilder = new StringBuilder(); - stringBuilder.append(sender? "发送: 目标->" + from :"接收:来自->" + to) - .append("\r\n") - .append(message); - this.stackLogger.logInfo(stringBuilder.toString()); - } - - @Override - public void logException(Exception ex) { - if (!showLog) { - return; - } - this.stackLogger.logException(ex); - } - - @Override - public void setStackProperties(Properties stackProperties) { - if (!showLog) { - return; - } - String TRACE_LEVEL = stackProperties.getProperty("gov.nist.javax.sip.TRACE_LEVEL"); - if (TRACE_LEVEL != null) { - showLog = true; - } - } - - @Override - public void setSipStack(SipStack sipStack) { - if (!showLog) { - return; - } - if(sipStack instanceof SIPTransactionStack) { - this.sipStack = (SIPTransactionStack)sipStack; - this.stackLogger = CommonLogger.getLogger(SIPTransactionStack.class); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java deleted file mode 100644 index 5e67bdba..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/conf/StackLoggerImpl.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.conf; - -import gov.nist.core.StackLogger; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.util.Properties; - -@Component -public class StackLoggerImpl implements StackLogger { - - private final static Logger logger = LoggerFactory.getLogger(StackLoggerImpl.class); - - @Override - public void logStackTrace() { - - } - - @Override - public void logStackTrace(int traceLevel) { - System.out.println("traceLevel: " + traceLevel); - } - - @Override - public int getLineCount() { - return 0; - } - - @Override - public void logException(Throwable ex) { - - } - - @Override - public void logDebug(String message) { -// logger.debug(message); - } - - @Override - public void logDebug(String message, Exception ex) { -// logger.debug(message); - } - - @Override - public void logTrace(String message) { - logger.trace(message); - } - - @Override - public void logFatalError(String message) { -// logger.error(message); - } - - @Override - public void logError(String message) { -// logger.error(message); - } - - @Override - public boolean isLoggingEnabled() { - return true; - } - - @Override - public boolean isLoggingEnabled(int logLevel) { - return true; - } - - @Override - public void logError(String message, Exception ex) { -// logger.error(message); - } - - @Override - public void logWarning(String message) { - logger.warn(message); - } - - @Override - public void logInfo(String message) { - logger.info(message); - } - - @Override - public void disableLogging() { - - } - - @Override - public void enableLogging() { - - } - - @Override - public void setBuildTimeStamp(String buildTimeStamp) { - - } - - @Override - public void setStackProperties(Properties stackProperties) { - - } - - @Override - public String getLoggerName() { - return null; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java deleted file mode 100644 index d56e744d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event; - -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent; -import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent; -import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationEventPublisher; -import org.springframework.stereotype.Component; - -import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent; - -import javax.sip.TimeoutEvent; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * @description:Event事件通知推送器,支持推送在线事件、离线事件 - * @author: swwheihei - * @date: 2020年5月6日 上午11:30:50 - */ -@Component -public class EventPublisher { - - @Autowired - private ApplicationEventPublisher applicationEventPublisher; - - /** - * 设备报警事件 - * @param deviceAlarm - */ - public void deviceAlarmEventPublish(DeviceAlarm deviceAlarm) { - AlarmEvent alarmEvent = new AlarmEvent(this); - alarmEvent.setAlarmInfo(deviceAlarm); - applicationEventPublisher.publishEvent(alarmEvent); - } - - public void zlmOfflineEventPublish(String mediaServerId){ - ZLMOfflineEvent outEvent = new ZLMOfflineEvent(this); - outEvent.setMediaServerId(mediaServerId); - applicationEventPublisher.publishEvent(outEvent); - } - - public void zlmOnlineEventPublish(String mediaServerId) { - ZLMOnlineEvent outEvent = new ZLMOnlineEvent(this); - outEvent.setMediaServerId(mediaServerId); - applicationEventPublisher.publishEvent(outEvent); - } - - - public void catalogEventPublish(String platformId, DeviceChannel deviceChannel, String type) { - List deviceChannelList = new ArrayList<>(); - deviceChannelList.add(deviceChannel); - catalogEventPublish(platformId, deviceChannelList, type); - } - - - public void requestTimeOut(TimeoutEvent timeoutEvent) { - RequestTimeoutEvent requestTimeoutEvent = new RequestTimeoutEvent(this); - requestTimeoutEvent.setTimeoutEvent(timeoutEvent); - applicationEventPublisher.publishEvent(requestTimeoutEvent); - } - - - /** - * - * @param platformId - * @param deviceChannels - * @param type - */ - public void catalogEventPublish(String platformId, List deviceChannels, String type) { - CatalogEvent outEvent = new CatalogEvent(this); - List channels = new ArrayList<>(); - if (deviceChannels.size() > 1) { - // 数据去重 - Set gbIdSet = new HashSet<>(); - for (DeviceChannel deviceChannel : deviceChannels) { - if (!gbIdSet.contains(deviceChannel.getChannelId())) { - gbIdSet.add(deviceChannel.getChannelId()); - channels.add(deviceChannel); - } - } - }else { - channels = deviceChannels; - } - outEvent.setDeviceChannels(channels); - outEvent.setType(type); - outEvent.setPlatformId(platformId); - applicationEventPublisher.publishEvent(outEvent); - } - - - public void catalogEventPublishForStream(String platformId, List gbStreams, String type) { - CatalogEvent outEvent = new CatalogEvent(this); - outEvent.setGbStreams(gbStreams); - outEvent.setType(type); - outEvent.setPlatformId(platformId); - applicationEventPublisher.publishEvent(outEvent); - } - - - public void catalogEventPublishForStream(String platformId, GbStream gbStream, String type) { - List gbStreamList = new ArrayList<>(); - gbStreamList.add(gbStream); - catalogEventPublishForStream(platformId, gbStreamList, type); - } - - public void recordEndEventPush(RecordInfo recordInfo) { - RecordEndEvent outEvent = new RecordEndEvent(this); - outEvent.setRecordInfo(recordInfo); - applicationEventPublisher.publishEvent(outEvent); - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java deleted file mode 100644 index 5aa189c5..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java +++ /dev/null @@ -1,180 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event; - -import com.genersoft.iot.vmp.gb28181.bean.DeviceNotFoundEvent; -import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import javax.sip.DialogTerminatedEvent; -import javax.sip.ResponseEvent; -import javax.sip.TimeoutEvent; -import javax.sip.TransactionTerminatedEvent; -import javax.sip.header.CallIdHeader; -import javax.sip.message.Response; -import java.time.Instant; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - -/** - * @author lin - */ -@Component -public class SipSubscribe { - - private final Logger logger = LoggerFactory.getLogger(SipSubscribe.class); - - private Map errorSubscribes = new ConcurrentHashMap<>(); - - private Map okSubscribes = new ConcurrentHashMap<>(); - - private Map okTimeSubscribes = new ConcurrentHashMap<>(); - - private Map errorTimeSubscribes = new ConcurrentHashMap<>(); - - // @Scheduled(cron="*/5 * * * * ?") //每五秒执行一次 - // @Scheduled(fixedRate= 100 * 60 * 60 ) - @Scheduled(cron="0 0/1 * * * ?") //每5分钟执行一次 - public void execute(){ - logger.info("[定时任务] 清理过期的SIP订阅信息"); - - Instant instant = Instant.now().minusMillis(TimeUnit.MINUTES.toMillis(5)); - - for (String key : okTimeSubscribes.keySet()) { - if (okTimeSubscribes.get(key).isBefore(instant)){ - okSubscribes.remove(key); - okTimeSubscribes.remove(key); - } - } - for (String key : errorTimeSubscribes.keySet()) { - if (errorTimeSubscribes.get(key).isBefore(instant)){ - errorSubscribes.remove(key); - errorTimeSubscribes.remove(key); - } - } - logger.debug("okTimeSubscribes.size:{}",okTimeSubscribes.size()); - logger.debug("okSubscribes.size:{}",okSubscribes.size()); - logger.debug("errorTimeSubscribes.size:{}",errorTimeSubscribes.size()); - logger.debug("errorSubscribes.size:{}",errorSubscribes.size()); - } - - public interface Event { void response(EventResult eventResult) ; - } - - /** - * - */ - public enum EventResultType{ - // 超时 - timeout, - // 回复 - response, - // 事务已结束 - transactionTerminated, - // 会话已结束 - dialogTerminated, - // 设备未找到 - deviceNotFoundEvent, - // 设备未找到 - cmdSendFailEvent - } - - public static class EventResult{ - public int statusCode; - public EventResultType type; - public String msg; - public String callId; - public EventObject event; - - public EventResult() { - } - - public EventResult(EventObject event) { - this.event = event; - if (event instanceof ResponseEvent) { - ResponseEvent responseEvent = (ResponseEvent)event; - Response response = responseEvent.getResponse(); - this.type = EventResultType.response; - if (response != null) { - this.msg = response.getReasonPhrase(); - this.statusCode = response.getStatusCode(); - } - this.callId = ((CallIdHeader)response.getHeader(CallIdHeader.NAME)).getCallId(); - - }else if (event instanceof TimeoutEvent) { - TimeoutEvent timeoutEvent = (TimeoutEvent)event; - this.type = EventResultType.timeout; - this.msg = "消息超时未回复"; - this.statusCode = -1024; - if (timeoutEvent.isServerTransaction()) { - this.callId = ((SIPRequest)timeoutEvent.getServerTransaction().getRequest()).getCallIdHeader().getCallId(); - }else { - this.callId = ((SIPRequest)timeoutEvent.getClientTransaction().getRequest()).getCallIdHeader().getCallId(); - } - }else if (event instanceof TransactionTerminatedEvent) { - TransactionTerminatedEvent transactionTerminatedEvent = (TransactionTerminatedEvent)event; - this.type = EventResultType.transactionTerminated; - this.msg = "事务已结束"; - this.statusCode = -1024; - if (transactionTerminatedEvent.isServerTransaction()) { - this.callId = ((SIPRequest)transactionTerminatedEvent.getServerTransaction().getRequest()).getCallIdHeader().getCallId(); - }else { - this.callId = ((SIPRequest)transactionTerminatedEvent.getClientTransaction().getRequest()).getCallIdHeader().getCallId(); - } - }else if (event instanceof DialogTerminatedEvent) { - DialogTerminatedEvent dialogTerminatedEvent = (DialogTerminatedEvent)event; - this.type = EventResultType.dialogTerminated; - this.msg = "会话已结束"; - this.statusCode = -1024; - this.callId = dialogTerminatedEvent.getDialog().getCallId().getCallId(); - }else if (event instanceof DeviceNotFoundEvent) { - this.type = EventResultType.deviceNotFoundEvent; - this.msg = "设备未找到"; - this.statusCode = -1024; - this.callId = ((DeviceNotFoundEvent) event).getCallId(); - } - } - } - - public void addErrorSubscribe(String key, SipSubscribe.Event event) { - errorSubscribes.put(key, event); - errorTimeSubscribes.put(key, Instant.now()); - } - - public void addOkSubscribe(String key, SipSubscribe.Event event) { - okSubscribes.put(key, event); - okTimeSubscribes.put(key, Instant.now()); - } - - public SipSubscribe.Event getErrorSubscribe(String key) { - return errorSubscribes.get(key); - } - - public void removeErrorSubscribe(String key) { - if(key == null){ - return; - } - errorSubscribes.remove(key); - errorTimeSubscribes.remove(key); - } - - public SipSubscribe.Event getOkSubscribe(String key) { - return okSubscribes.get(key); - } - - public void removeOkSubscribe(String key) { - if(key == null){ - return; - } - okSubscribes.remove(key); - okTimeSubscribes.remove(key); - } - public int getErrorSubscribesSize(){ - return errorSubscribes.size(); - } - public int getOkSubscribesSize(){ - return okSubscribes.size(); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java deleted file mode 100644 index 9f91bed9..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.alarm; - -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import org.springframework.context.ApplicationEvent; - -/** - * @description: 报警事件 - * @author: lawrencehj - * @data: 2021-01-20 - */ - -public class AlarmEvent extends ApplicationEvent { - /** - * - */ - private static final long serialVersionUID = 1L; - - public AlarmEvent(Object source) { - super(source); - } - - private DeviceAlarm deviceAlarm; - - public DeviceAlarm getAlarmInfo() { - return deviceAlarm; - } - - public void setAlarmInfo(DeviceAlarm deviceAlarm) { - this.deviceAlarm = deviceAlarm; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java deleted file mode 100644 index aef59076..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEventListener.java +++ /dev/null @@ -1,70 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.alarm; - -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import java.io.PrintWriter; -import java.util.Iterator; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * 报警事件监听器. - * - * @author lawrencehj - * @author xiaoQQya - * @since 2021/01/20 - */ -@Component -public class AlarmEventListener implements ApplicationListener { - - private static final Logger logger = LoggerFactory.getLogger(AlarmEventListener.class); - - private static final Map SSE_CACHE = new ConcurrentHashMap<>(); - - public void addSseEmitter(String browserId, PrintWriter writer) { - SSE_CACHE.put(browserId, writer); - logger.info("SSE 在线数量: {}", SSE_CACHE.size()); - } - - public void removeSseEmitter(String browserId, PrintWriter writer) { - SSE_CACHE.remove(browserId, writer); - logger.info("SSE 在线数量: {}", SSE_CACHE.size()); - } - - @Override - public void onApplicationEvent(@NotNull AlarmEvent event) { - if (logger.isDebugEnabled()) { - logger.debug("设备报警事件触发, deviceId: {}, {}", event.getAlarmInfo().getDeviceId(), event.getAlarmInfo().getAlarmDescription()); - } - - String msg = "设备编号: " + event.getAlarmInfo().getDeviceId() + "" - + "
通道编号: " + event.getAlarmInfo().getChannelId() + "" - + "
报警描述: " + event.getAlarmInfo().getAlarmDescription() + "" - + "
报警时间: " + event.getAlarmInfo().getAlarmTime() + ""; - - for (Iterator> it = SSE_CACHE.entrySet().iterator(); it.hasNext(); ) { - Map.Entry response = it.next(); - logger.info("推送到 SSE 连接, 浏览器 ID: {}", response.getKey()); - try { - PrintWriter writer = response.getValue(); - - if (writer.checkError()) { - it.remove(); - continue; - } - - String sseMsg = "event:message\n" + - "data:" + msg + "\n" + - "\n"; - writer.write(sseMsg); - writer.flush(); - } catch (Exception e) { - it.remove(); - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java deleted file mode 100644 index c4d3baba..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.device; - -import org.springframework.context.ApplicationEvent; - -import javax.sip.TimeoutEvent; - -/** - * @author lin - */ -public class RequestTimeoutEvent extends ApplicationEvent { - public RequestTimeoutEvent(Object source) { - super(source); - } - - - private TimeoutEvent timeoutEvent; - - public TimeoutEvent getTimeoutEvent() { - return timeoutEvent; - } - - public void setTimeoutEvent(TimeoutEvent timeoutEvent) { - this.timeoutEvent = timeoutEvent; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java deleted file mode 100644 index 2008f22e..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.device; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.service.IDeviceService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import javax.sip.ClientTransaction; -import javax.sip.address.SipURI; -import javax.sip.message.Request; - -/** - * @author lin - */ -@Component -public class RequestTimeoutEventImpl implements ApplicationListener { - - @Autowired - private IDeviceService deviceService; - - @Override - public void onApplicationEvent(RequestTimeoutEvent event) { - ClientTransaction clientTransaction = event.getTimeoutEvent().getClientTransaction(); - if (clientTransaction != null) { - Request request = clientTransaction.getRequest(); - if (request != null) { - String host = ((SipURI) request.getRequestURI()).getHost(); - int port = ((SipURI) request.getRequestURI()).getPort(); - Device device = deviceService.getDeviceByHostAndPort(host, port); - if (device == null) { - return; - } - deviceService.offline(device.getDeviceId(), "等待消息超时"); - } - - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java deleted file mode 100644 index cfd2985c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.record; - -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; -import org.springframework.context.ApplicationEvent; - -/** - * @description: 录像查询结束时间 - * @author: pan - * @data: 2022-02-23 - */ - -public class RecordEndEvent extends ApplicationEvent { - /** - * - */ - private static final long serialVersionUID = 1L; - - public RecordEndEvent(Object source) { - super(source); - } - - private RecordInfo recordInfo; - - public RecordInfo getRecordInfo() { - return recordInfo; - } - - public void setRecordInfo(RecordInfo recordInfo) { - this.recordInfo = recordInfo; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java deleted file mode 100644 index cb468230..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.record; - -import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @description: 录像查询结束事件 - * @author: pan - * @data: 2022-02-23 - */ - -@Component -public class RecordEndEventListener implements ApplicationListener { - - private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class); - - private Map handlerMap = new ConcurrentHashMap<>(); - public interface RecordEndEventHandler{ - void handler(RecordInfo recordInfo); - } - - @Override - public void onApplicationEvent(RecordEndEvent event) { - String deviceId = event.getRecordInfo().getDeviceId(); - String channelId = event.getRecordInfo().getChannelId(); - int count = event.getRecordInfo().getCount(); - int sumNum = event.getRecordInfo().getSumNum(); - logger.info("录像查询完成事件触发,deviceId:{}, channelId: {}, 录像数量{}/{}条", event.getRecordInfo().getDeviceId(), - event.getRecordInfo().getChannelId(), count,sumNum); - if (handlerMap.size() > 0) { - RecordEndEventHandler handler = handlerMap.get(deviceId + channelId); - if (handler !=null){ - handler.handler(event.getRecordInfo()); - if (count ==sumNum){ - handlerMap.remove(deviceId + channelId); - } - } - } - } - - /** - * 添加 - * @param device - * @param channelId - * @param recordEndEventHandler - */ - public void addEndEventHandler(String device, String channelId, RecordEndEventHandler recordEndEventHandler) { - handlerMap.put(device + channelId, recordEndEventHandler); - } - /** - * 添加 - * @param device - * @param channelId - */ - public void delEndEventHandler(String device, String channelId) { - handlerMap.remove(device + channelId); - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java deleted file mode 100644 index 5c064f75..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog; - -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import org.springframework.context.ApplicationEvent; - -import java.util.List; - -public class CatalogEvent extends ApplicationEvent { - public CatalogEvent(Object source) { - super(source); - } - - /** - * 上线 - */ - public static final String ON = "ON"; - - /** - * 离线 - */ - public static final String OFF = "OFF"; - - /** - * 视频丢失 - */ - public static final String VLOST = "VLOST"; - - /** - * 故障 - */ - public static final String DEFECT = "DEFECT"; - - /** - * 增加 - */ - public static final String ADD = "ADD"; - - /** - * 删除 - */ - public static final String DEL = "DEL"; - - /** - * 更新 - */ - public static final String UPDATE = "UPDATE"; - - private List deviceChannels; - private List gbStreams; - private String type; - private String platformId; - - public List getDeviceChannels() { - return deviceChannels; - } - - public void setDeviceChannels(List deviceChannels) { - this.deviceChannels = deviceChannels; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public List getGbStreams() { - return gbStreams; - } - - public void setGbStreams(List gbStreams) { - this.gbStreams = gbStreams; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java deleted file mode 100644 index 0448cd20..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ /dev/null @@ -1,200 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.subscribe.catalog; - -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * catalog事件 - */ -@Component -public class CatalogEventLister implements ApplicationListener { - - private final static Logger logger = LoggerFactory.getLogger(CatalogEventLister.class); - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommanderFroPlatform sipCommanderFroPlatform; - - @Autowired - private IGbStreamService gbStreamService; - - @Autowired - private SubscribeHolder subscribeHolder; - - @Autowired - private UserSetting userSetting; - - @Override - public void onApplicationEvent(CatalogEvent event) { - SubscribeInfo subscribe = null; - ParentPlatform parentPlatform = null; - - Map> parentPlatformMap = new HashMap<>(); - if (!ObjectUtils.isEmpty(event.getPlatformId())) { - subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); - if (subscribe == null) { - return; - } - parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); - if (parentPlatform != null && !parentPlatform.isStatus()) { - return; - } - - }else { - // 获取所用订阅 - List platforms = subscribeHolder.getAllCatalogSubscribePlatform(); - if (event.getDeviceChannels() != null) { - if (platforms.size() > 0) { - for (DeviceChannel deviceChannel : event.getDeviceChannels()) { - List parentPlatformsForGB = storager.queryPlatFormListForGBWithGBId(deviceChannel.getChannelId(), platforms); - parentPlatformMap.put(deviceChannel.getChannelId(), parentPlatformsForGB); - } - } - }else if (event.getGbStreams() != null) { - if (platforms.size() > 0) { - for (GbStream gbStream : event.getGbStreams()) { - if (gbStream == null || ObjectUtils.isEmpty(gbStream.getGbId())) { - continue; - } - List parentPlatformsForGB = storager.queryPlatFormListForStreamWithGBId(gbStream.getApp(),gbStream.getStream(), platforms); - parentPlatformMap.put(gbStream.getGbId(), parentPlatformsForGB); - } - } - } - } - switch (event.getType()) { - case CatalogEvent.ON: - case CatalogEvent.OFF: - case CatalogEvent.DEL: - - if (parentPlatform != null || subscribe != null) { - List deviceChannelList = new ArrayList<>(); - if (event.getDeviceChannels() != null) { - deviceChannelList.addAll(event.getDeviceChannels()); - } - if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ - for (GbStream gbStream : event.getGbStreams()) { - if (gbStream != null - && gbStream.getStreamType() != null - && gbStream.getStreamType().equals("push") - && !userSetting.isUsePushingAsStatus()) { - continue; - } - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform); - deviceChannelList.add(deviceChannelByStream); - } - } - if (deviceChannelList.size() > 0) { - logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); - try { - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), parentPlatform, deviceChannelList, subscribe, null); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | - IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); - } - } - }else if (parentPlatformMap.keySet().size() > 0) { - for (String gbId : parentPlatformMap.keySet()) { - List parentPlatforms = parentPlatformMap.get(gbId); - if (parentPlatforms != null && parentPlatforms.size() > 0) { - for (ParentPlatform platform : parentPlatforms) { - SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); - if (subscribeInfo == null) { - continue; - } - logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); - List deviceChannelList = new ArrayList<>(); - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbId); - deviceChannelList.add(deviceChannel); - try { - sipCommanderFroPlatform.sendNotifyForCatalogOther(event.getType(), platform, deviceChannelList, subscribeInfo, null); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | - IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); - } - } - } - } - } - break; - case CatalogEvent.VLOST: - break; - case CatalogEvent.DEFECT: - break; - case CatalogEvent.ADD: - case CatalogEvent.UPDATE: - if (parentPlatform != null || subscribe != null) { - List deviceChannelList = new ArrayList<>(); - if (event.getDeviceChannels() != null) { - deviceChannelList.addAll(event.getDeviceChannels()); - } - if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ - for (GbStream gbStream : event.getGbStreams()) { - deviceChannelList.add( - gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), parentPlatform)); - } - } - if (deviceChannelList.size() > 0) { - logger.info("[Catalog事件: {}]平台:{},影响通道{}个", event.getType(), event.getPlatformId(), deviceChannelList.size()); - try { - sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), parentPlatform, deviceChannelList, subscribe, null); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | - IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); - } - } - }else if (parentPlatformMap.keySet().size() > 0) { - for (String gbId : parentPlatformMap.keySet()) { - List parentPlatforms = parentPlatformMap.get(gbId); - if (parentPlatforms != null && parentPlatforms.size() > 0) { - for (ParentPlatform platform : parentPlatforms) { - SubscribeInfo subscribeInfo = subscribeHolder.getCatalogSubscribe(platform.getServerGBId()); - if (subscribeInfo == null) { - continue; - } - logger.info("[Catalog事件: {}]平台:{},影响通道{}", event.getType(), platform.getServerGBId(), gbId); - List deviceChannelList = new ArrayList<>(); - DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(platform.getServerGBId(), gbId); - deviceChannelList.add(deviceChannel); - GbStream gbStream = storager.queryStreamInParentPlatform(platform.getServerGBId(), gbId); - if(gbStream != null){ - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStreamWithStatus(gbStream, gbStream.getCatalogId(), platform); - deviceChannelList.add(deviceChannelByStream); - } - try { - sipCommanderFroPlatform.sendNotifyForCatalogAddOrUpdate(event.getType(), platform, deviceChannelList, subscribeInfo, null); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | - SipException | IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 Catalog通知: {}", e.getMessage()); - } - } - } - } - } - break; - default: - break; - } - } -} - \ No newline at end of file diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java deleted file mode 100644 index 38cdf7c4..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.session; - -import com.genersoft.iot.vmp.gb28181.bean.CatalogData; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.time.Instant; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - -@Component -public class CatalogDataCatch { - - public static Map data = new ConcurrentHashMap<>(); - - @Autowired - private IVideoManagerStorage storager; - - public void addReady(Device device, int sn ) { - CatalogData catalogData = data.get(device.getDeviceId()); - if (catalogData == null || catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) { - catalogData = new CatalogData(); - catalogData.setChannelList(Collections.synchronizedList(new ArrayList<>())); - catalogData.setDevice(device); - catalogData.setSn(sn); - catalogData.setStatus(CatalogData.CatalogDataStatus.ready); - catalogData.setLastTime(Instant.now()); - data.put(device.getDeviceId(), catalogData); - } - } - - public void put(String deviceId, int sn, int total, Device device, List deviceChannelList) { - CatalogData catalogData = data.get(deviceId); - if (catalogData == null) { - catalogData = new CatalogData(); - catalogData.setSn(sn); - catalogData.setTotal(total); - catalogData.setDevice(device); - catalogData.setChannelList(deviceChannelList); - catalogData.setStatus(CatalogData.CatalogDataStatus.runIng); - catalogData.setLastTime(Instant.now()); - data.put(deviceId, catalogData); - }else { - // 同一个设备的通道同步请求只考虑一个,其他的直接忽略 - if (catalogData.getSn() != sn) { - return; - } - catalogData.setTotal(total); - catalogData.setDevice(device); - catalogData.setStatus(CatalogData.CatalogDataStatus.runIng); - catalogData.getChannelList().addAll(deviceChannelList); - catalogData.setLastTime(Instant.now()); - } - } - - public List get(String deviceId) { - CatalogData catalogData = data.get(deviceId); - if (catalogData == null) { - return null; - } - return catalogData.getChannelList(); - } - - public int getTotal(String deviceId) { - CatalogData catalogData = data.get(deviceId); - if (catalogData == null) { - return 0; - } - return catalogData.getTotal(); - } - - public SyncStatus getSyncStatus(String deviceId) { - CatalogData catalogData = data.get(deviceId); - if (catalogData == null) { - return null; - } - SyncStatus syncStatus = new SyncStatus(); - syncStatus.setCurrent(catalogData.getChannelList().size()); - syncStatus.setTotal(catalogData.getTotal()); - syncStatus.setErrorMsg(catalogData.getErrorMsg()); - if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end)) { - syncStatus.setSyncIng(false); - }else { - syncStatus.setSyncIng(true); - } - return syncStatus; - } - - public boolean isSyncRunning(String deviceId) { - CatalogData catalogData = data.get(deviceId); - if (catalogData == null) { - return false; - } - return !catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end); - } - - @Scheduled(fixedRate = 5 * 1000) //每5秒执行一次, 发现数据5秒未更新则移除数据并认为数据接收超时 - private void timerTask(){ - Set keys = data.keySet(); - - Instant instantBefore5S = Instant.now().minusMillis(TimeUnit.SECONDS.toMillis(5)); - Instant instantBefore30S = Instant.now().minusMillis(TimeUnit.SECONDS.toMillis(30)); - - for (String deviceId : keys) { - CatalogData catalogData = data.get(deviceId); - if ( catalogData.getLastTime().isBefore(instantBefore5S)) { - // 超过五秒收不到消息任务超时, 只更新这一部分数据, 收到数据与声明的总数一致,则重置通道数据,数据不全则只对收到的数据做更新操作 - if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.runIng)) { - if (catalogData.getTotal() == catalogData.getChannelList().size()) { - storager.resetChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); - }else { - storager.updateChannels(catalogData.getDevice().getDeviceId(), catalogData.getChannelList()); - } - String errorMsg = "更新成功,共" + catalogData.getTotal() + "条,已更新" + catalogData.getChannelList().size() + "条"; - catalogData.setErrorMsg(errorMsg); - if (catalogData.getTotal() != catalogData.getChannelList().size()) { - - } - }else if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.ready)) { - String errorMsg = "同步失败,等待回复超时"; - catalogData.setErrorMsg(errorMsg); - } - catalogData.setStatus(CatalogData.CatalogDataStatus.end); - } - if (catalogData.getStatus().equals(CatalogData.CatalogDataStatus.end) && catalogData.getLastTime().isBefore(instantBefore30S)) { // 超过三十秒,如果标记为end则删除 - data.remove(deviceId); - } - } - } - - - public void setChannelSyncEnd(String deviceId, String errorMsg) { - CatalogData catalogData = data.get(deviceId); - if (catalogData == null) { - return; - } - catalogData.setStatus(CatalogData.CatalogDataStatus.end); - catalogData.setErrorMsg(errorMsg); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java deleted file mode 100644 index 3f24dbee..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/RecordDataCatch.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.session; - -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; - -import java.time.Instant; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - -/** - * @author lin - */ -@Component -public class RecordDataCatch { - - public static Map data = new ConcurrentHashMap<>(); - - @Autowired - private DeferredResultHolder deferredResultHolder; - @Autowired - private RecordEndEventListener recordEndEventListener; - - - public int put(String deviceId,String channelId, String sn, int sumNum, List recordItems) { - String key = deviceId + sn; - RecordInfo recordInfo = data.get(key); - if (recordInfo == null) { - recordInfo = new RecordInfo(); - recordInfo.setDeviceId(deviceId); - recordInfo.setChannelId(channelId); - recordInfo.setSn(sn.trim()); - recordInfo.setSumNum(sumNum); - recordInfo.setRecordList(Collections.synchronizedList(new ArrayList<>())); - recordInfo.setLastTime(Instant.now()); - recordInfo.getRecordList().addAll(recordItems); - data.put(key, recordInfo); - }else { - // 同一个设备的通道同步请求只考虑一个,其他的直接忽略 - if (!Objects.equals(sn.trim(), recordInfo.getSn())) { - return 0; - } - recordInfo.getRecordList().addAll(recordItems); - recordInfo.setLastTime(Instant.now()); - } - return recordInfo.getRecordList().size(); - } - - @Scheduled(fixedRate = 5 * 1000) //每5秒执行一次, 发现数据5秒未更新则移除数据并认为数据接收超时 - private void timerTask(){ - Set keys = data.keySet(); - // 获取五秒前的时刻 - Instant instantBefore5S = Instant.now().minusMillis(TimeUnit.SECONDS.toMillis(5)); - for (String key : keys) { - RecordInfo recordInfo = data.get(key); - // 超过五秒收不到消息任务超时, 只更新这一部分数据 - if ( recordInfo.getLastTime().isBefore(instantBefore5S)) { - // 处理录像数据, 返回给前端 - String msgKey = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + recordInfo.getDeviceId() + recordInfo.getSn(); - - // 对数据进行排序 - Collections.sort(recordInfo.getRecordList()); - - RequestMessage msg = new RequestMessage(); - msg.setKey(msgKey); - msg.setData(recordInfo); - deferredResultHolder.invokeAllResult(msg); - recordEndEventListener.delEndEventHandler(recordInfo.getDeviceId(),recordInfo.getChannelId()); - data.remove(key); - } - } - } - - public boolean isComplete(String deviceId, String sn) { - RecordInfo recordInfo = data.get(deviceId + sn); - return recordInfo != null && recordInfo.getRecordList().size() == recordInfo.getSumNum(); - } - - public RecordInfo getRecordInfo(String deviceId, String sn) { - return data.get(deviceId + sn); - } - - public void remove(String deviceId, String sn) { - data.remove(deviceId + sn); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/SSRCFactory.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/SSRCFactory.java deleted file mode 100644 index 7ebc29f3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/SSRCFactory.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.session; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Component; - -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; -import java.util.Set; - -/** - * ssrc使用 - */ -@Component -public class SSRCFactory { - - /** - * 播流最大并发个数 - */ - private static final Integer MAX_STREAM_COUNT = 10000; - - /** - * 播流最大并发个数 - */ - private static final String SSRC_INFO_KEY = "VMP_SSRC_INFO_"; - - @Autowired - private StringRedisTemplate redisTemplate; - - @Autowired - private SipConfig sipConfig; - - @Autowired - private UserSetting userSetting; - - - public void initMediaServerSSRC(String mediaServerId, Set usedSet) { - String ssrcPrefix = sipConfig.getDomain().substring(3, 8); - String redisKey = SSRC_INFO_KEY + userSetting.getServerId() + "_" + mediaServerId; - List ssrcList = new ArrayList<>(); - for (int i = 1; i < MAX_STREAM_COUNT; i++) { - String ssrc = String.format("%s%04d", ssrcPrefix, i); - - if (null == usedSet || !usedSet.contains(ssrc)) { - ssrcList.add(ssrc); - - } - } - if (redisTemplate.opsForSet().size(redisKey) != null) { - redisTemplate.delete(redisKey); - } - redisTemplate.opsForSet().add(redisKey, ssrcList.toArray(new String[0])); - } - - - /** - * 获取视频预览的SSRC值,第一位固定为0 - * - * @return ssrc - */ - public String getPlaySsrc(String mediaServerId) { - return "0" + getSN(mediaServerId); - } - - /** - * 获取录像回放的SSRC值,第一位固定为1 - */ - public String getPlayBackSsrc(String mediaServerId) { - return "1" + getSN(mediaServerId); - } - - /** - * 释放ssrc,主要用完的ssrc一定要释放,否则会耗尽 - * - * @param ssrc 需要重置的ssrc - */ - public void releaseSsrc(String mediaServerId, String ssrc) { - if (ssrc == null) { - return; - } - String sn = ssrc.substring(1); - String redisKey = SSRC_INFO_KEY + userSetting.getServerId() + "_" + mediaServerId; - redisTemplate.opsForSet().add(redisKey, sn); - } - - /** - * 获取后四位数SN,随机数 - */ - private String getSN(String mediaServerId) { - String sn = null; - String redisKey = SSRC_INFO_KEY + userSetting.getServerId() + "_" + mediaServerId; - Long size = redisTemplate.opsForSet().size(redisKey); - if (size == null || size == 0) { - throw new RuntimeException("ssrc已经用完"); - } else { - // 在集合中移除并返回一个随机成员。 - sn = (String) redisTemplate.opsForSet().pop(redisKey); - redisTemplate.opsForSet().remove(redisKey, sn); - } - return sn; - } - - /** - * 重置一个流媒体服务的所有ssrc - * - * @param mediaServerId 流媒体服务ID - */ - public void reset(String mediaServerId) { - this.initMediaServerSSRC(mediaServerId, null); - } - - /** - * 是否已经存在了某个MediaServer的SSRC信息 - * - * @param mediaServerId 流媒体服务ID - */ - public boolean hasMediaServerSSRC(String mediaServerId) { - String redisKey = SSRC_INFO_KEY + userSetting.getServerId() + "_" + mediaServerId; - return Boolean.TRUE.equals(redisTemplate.hasKey(redisKey)); - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java deleted file mode 100644 index 170f412b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.session; - -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; -import com.genersoft.iot.vmp.utils.JsonUtil; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import gov.nist.javax.sip.message.SIPResponse; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * 视频流session管理器,管理视频预览、预览回放的通信句柄 - */ -@Component -public class VideoStreamSessionManager { - - @Autowired - private UserSetting userSetting; - - @Autowired - private RedisTemplate redisTemplate; - - /** - * 添加一个点播/回放的事务信息 - * 后续可以通过流Id/callID - * @param deviceId 设备ID - * @param channelId 通道ID - * @param callId 一次请求的CallID - * @param stream 流名称 - * @param mediaServerId 所使用的流媒体ID - * @param response 回复 - */ - public void put(String deviceId, String channelId, String callId, String stream, String ssrc, String mediaServerId, SIPResponse response, InviteSessionType type){ - SsrcTransaction ssrcTransaction = new SsrcTransaction(); - ssrcTransaction.setDeviceId(deviceId); - ssrcTransaction.setChannelId(channelId); - ssrcTransaction.setStream(stream); - ssrcTransaction.setSipTransactionInfo(new SipTransactionInfo(response)); - ssrcTransaction.setCallId(callId); - ssrcTransaction.setSsrc(ssrc); - ssrcTransaction.setMediaServerId(mediaServerId); - ssrcTransaction.setType(type); - - redisTemplate.opsForValue().set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() - + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); - } - - public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){ - - if (ObjectUtils.isEmpty(deviceId)) { - deviceId ="*"; - } - if (ObjectUtils.isEmpty(channelId)) { - channelId ="*"; - } - if (ObjectUtils.isEmpty(callId)) { - callId ="*"; - } - if (ObjectUtils.isEmpty(stream)) { - stream ="*"; - } - String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; - List scanResult = RedisUtil.scan(redisTemplate, key); - if (scanResult.size() == 0) { - return null; - } - return (SsrcTransaction)redisTemplate.opsForValue().get(scanResult.get(0)); - } - - public List getSsrcTransactionForAll(String deviceId, String channelId, String callId, String stream){ - if (ObjectUtils.isEmpty(deviceId)) { - deviceId ="*"; - } - if (ObjectUtils.isEmpty(channelId)) { - channelId ="*"; - } - if (ObjectUtils.isEmpty(callId)) { - callId ="*"; - } - if (ObjectUtils.isEmpty(stream)) { - stream ="*"; - } - String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; - List scanResult = RedisUtil.scan(redisTemplate, key); - if (scanResult.size() == 0) { - return null; - } - List result = new ArrayList<>(); - for (Object keyObj : scanResult) { - result.add((SsrcTransaction)redisTemplate.opsForValue().get(keyObj)); - } - return result; - } - - public String getMediaServerId(String deviceId, String channelId, String stream){ - SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); - if (ssrcTransaction == null) { - return null; - } - return ssrcTransaction.getMediaServerId(); - } - - public String getSSRC(String deviceId, String channelId, String stream){ - SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); - if (ssrcTransaction == null) { - return null; - } - return ssrcTransaction.getSsrc(); - } - - public void remove(String deviceId, String channelId, String stream) { - List ssrcTransactionList = getSsrcTransactionForAll(deviceId, channelId, null, stream); - if (ssrcTransactionList == null || ssrcTransactionList.isEmpty()) { - return; - } - for (SsrcTransaction ssrcTransaction : ssrcTransactionList) { - redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" - + deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream()); - } - } - - public void removeByCallId(String deviceId, String channelId, String callId) { - SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, callId, null); - if (ssrcTransaction == null ) { - return; - } - redisTemplate.delete(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" - + deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream()); - } - - - public List getAllSsrc() { - List ssrcTransactionKeys = RedisUtil.scan(redisTemplate, String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId())); - List result= new ArrayList<>(); - for (Object ssrcTransactionKey : ssrcTransactionKeys) { - String key = (String) ssrcTransactionKey; - SsrcTransaction ssrcTransaction = JsonUtil.redisJsonToObject(redisTemplate, key, SsrcTransaction.class); - result.add(ssrcTransaction); - } - return result; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java deleted file mode 100644 index a4e711d9..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/ISubscribeTask.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.task; - -import javax.sip.DialogState; - -/** - * @author lin - */ -public interface ISubscribeTask extends Runnable{ - void stop(); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java deleted file mode 100644 index 73cb9eaa..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.task; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.core.annotation.Order; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - - -/** - * 系统启动时控制设备 - * @author lin - */ -@Component -@Order(value=14) -public class SipRunner implements CommandLineRunner { - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private SSRCFactory ssrcFactory; - - @Autowired - private UserSetting userSetting; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private IPlatformService platformService; - - @Autowired - private ISIPCommanderForPlatform commanderForPlatform; - - private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class); - - @Override - public void run(String... args) throws Exception { - List deviceList = deviceService.getAllOnlineDevice(); - - for (Device device : deviceList) { - if (deviceService.expire(device)){ - deviceService.offline(device.getDeviceId(), "注册已过期"); - }else { - deviceService.online(device, null); - } - } - // 重置cseq计数 - redisCatchStorage.resetAllCSEQ(); - // 清理redis - // 清理数据库不存在但是redis中存在的数据 - List devicesInDb = deviceService.getAll(); - if (devicesInDb.size() == 0) { - redisCatchStorage.removeAllDevice(); - }else { - List devicesInRedis = redisCatchStorage.getAllDevices(); - if (devicesInRedis.size() > 0) { - Map deviceMapInDb = new HashMap<>(); - devicesInDb.parallelStream().forEach(device -> { - deviceMapInDb.put(device.getDeviceId(), device); - }); - devicesInRedis.parallelStream().forEach(device -> { - if (deviceMapInDb.get(device.getDeviceId()) == null) { - redisCatchStorage.removeDevice(device.getDeviceId()); - } - }); - } - } - - - // 查找国标推流 - List sendRtpItems = redisCatchStorage.queryAllSendRTPServer(); - if (sendRtpItems.size() > 0) { - for (SendRtpItem sendRtpItem : sendRtpItems) { - MediaServerItem mediaServerItem = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(),sendRtpItem.getChannelId(), sendRtpItem.getCallId(),sendRtpItem.getStreamId()); - if (mediaServerItem != null) { - ssrcFactory.releaseSsrc(sendRtpItem.getMediaServerId(), sendRtpItem.getSsrc()); - Map param = new HashMap<>(); - param.put("vhost","__defaultVhost__"); - param.put("app",sendRtpItem.getApp()); - param.put("stream",sendRtpItem.getStreamId()); - param.put("ssrc",sendRtpItem.getSsrc()); - JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaServerItem, param); - if (jsonObject != null && jsonObject.getInteger("code") == 0) { - ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId()); - if (platform != null) { - try { - commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId()); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - } - } - } - } - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java deleted file mode 100644 index 2ffbfe40..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.task.impl; - -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; - -import javax.sip.*; -import javax.sip.header.ToHeader; -import java.text.ParseException; -import java.util.Timer; -import java.util.TimerTask; - -/** - * 目录订阅任务 - * @author lin - */ -public class CatalogSubscribeTask implements ISubscribeTask { - private final Logger logger = LoggerFactory.getLogger(CatalogSubscribeTask.class); - private Device device; - private final ISIPCommander sipCommander; - private SIPRequest request; - - private DynamicTask dynamicTask; - - private String taskKey = "catalog-subscribe-timeout"; - - - public CatalogSubscribeTask(Device device, ISIPCommander sipCommander, DynamicTask dynamicTask) { - this.device = device; - this.sipCommander = sipCommander; - this.dynamicTask = dynamicTask; - } - - @Override - public void run() { - if (dynamicTask.get(taskKey) != null) { - dynamicTask.stop(taskKey); - } - SIPRequest sipRequest = null; - try { - sipRequest = sipCommander.catalogSubscribe(device, request, eventResult -> { - ResponseEvent event = (ResponseEvent) eventResult.event; - // 成功 - logger.info("[目录订阅]成功: {}", device.getDeviceId()); - ToHeader toHeader = (ToHeader)event.getResponse().getHeader(ToHeader.NAME); - try { - this.request.getToHeader().setTag(toHeader.getTag()); - } catch (ParseException e) { - logger.info("[目录订阅]成功: 但为request设置ToTag失败"); - this.request = null; - } - },eventResult -> { - this.request = null; - // 失败 - logger.warn("[目录订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg); - dynamicTask.startDelay(taskKey, CatalogSubscribeTask.this, 2000); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 目录订阅: {}", e.getMessage()); - - } - if (sipRequest != null) { - this.request = sipRequest; - } - } - - @Override - public void stop() { - /** - * dialog 的各个状态 - * EARLY-> Early state状态-初始请求发送以后,收到了一个临时响应消息 - * CONFIRMED-> Confirmed Dialog状态-已确认 - * COMPLETED-> Completed Dialog状态-已完成 - * TERMINATED-> Terminated Dialog状态-终止 - */ - logger.info("取消目录订阅时dialog状态为{}", DialogState.CONFIRMED); - if (dynamicTask.get(taskKey) != null) { - dynamicTask.stop(taskKey); - } - device.setSubscribeCycleForCatalog(0); - try { - sipCommander.catalogSubscribe(device, request, eventResult -> { - ResponseEvent event = (ResponseEvent) eventResult.event; - if (event.getResponse().getRawContent() != null) { - // 成功 - logger.info("[取消目录订阅]成功: {}", device.getDeviceId()); - }else { - // 成功 - logger.info("[取消目录订阅]成功: {}", device.getDeviceId()); - } - },eventResult -> { - // 失败 - logger.warn("[取消目录订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 取消目录订阅: {}", e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java deleted file mode 100644 index 2e792c1c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.task.impl; - -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.SpringBeanFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Async; - -import javax.sip.DialogState; -import java.util.List; - -/** - * 向已经订阅(移动位置)的上级发送MobilePosition消息 - * @author lin - */ -public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { - - - private IPlatformService platformService; - private String platformId; - - - public MobilePositionSubscribeHandlerTask(String platformId) { - this.platformService = SpringBeanFactory.getBean("platformServiceImpl"); - this.platformId = platformId; - } - - @Override - public void run() { - platformService.sendNotifyMobilePosition(this.platformId); - } - - @Override - public void stop() { - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java deleted file mode 100644 index 0abd3cae..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeTask.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.task.impl; - -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Async; - -import javax.sip.*; -import javax.sip.header.ToHeader; -import java.text.ParseException; -import java.util.Timer; -import java.util.TimerTask; - -/** - * 移动位置订阅的定时更新 - * @author lin - */ -public class MobilePositionSubscribeTask implements ISubscribeTask { - private final Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeTask.class); - private Device device; - private ISIPCommander sipCommander; - - private SIPRequest request; - private DynamicTask dynamicTask; - private String taskKey = "mobile-position-subscribe-timeout"; - - public MobilePositionSubscribeTask(Device device, ISIPCommander sipCommander, DynamicTask dynamicTask) { - this.device = device; - this.sipCommander = sipCommander; - this.dynamicTask = dynamicTask; - } - - @Override - public void run() { - if (dynamicTask.get(taskKey) != null) { - dynamicTask.stop(taskKey); - } - SIPRequest sipRequest = null; - try { - sipRequest = sipCommander.mobilePositionSubscribe(device, request, eventResult -> { - // 成功 - logger.info("[移动位置订阅]成功: {}", device.getDeviceId()); - ResponseEvent event = (ResponseEvent) eventResult.event; - ToHeader toHeader = (ToHeader)event.getResponse().getHeader(ToHeader.NAME); - try { - this.request.getToHeader().setTag(toHeader.getTag()); - } catch (ParseException e) { - logger.info("[移动位置订阅]成功: 为request设置ToTag失败"); - this.request = null; - } - },eventResult -> { - this.request = null; - // 失败 - logger.warn("[移动位置订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg); - dynamicTask.startDelay(taskKey, MobilePositionSubscribeTask.this, 2000); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 移动位置订阅: {}", e.getMessage()); - } - if (sipRequest != null) { - this.request = sipRequest; - } - - } - - @Override - public void stop() { - /** - * dialog 的各个状态 - * EARLY-> Early state状态-初始请求发送以后,收到了一个临时响应消息 - * CONFIRMED-> Confirmed Dialog状态-已确认 - * COMPLETED-> Completed Dialog状态-已完成 - * TERMINATED-> Terminated Dialog状态-终止 - */ - if (dynamicTask.get(taskKey) != null) { - dynamicTask.stop(taskKey); - } - device.setSubscribeCycleForMobilePosition(0); - try { - sipCommander.mobilePositionSubscribe(device, request, eventResult -> { - ResponseEvent event = (ResponseEvent) eventResult.event; - if (event.getResponse().getRawContent() != null) { - // 成功 - logger.info("[取消移动位置订阅]成功: {}", device.getDeviceId()); - }else { - // 成功 - logger.info("[取消移动位置订阅]成功: {}", device.getDeviceId()); - } - },eventResult -> { - // 失败 - logger.warn("[取消移动位置订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 取消移动位置订阅: {}", e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/ISIPProcessorObserver.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/ISIPProcessorObserver.java deleted file mode 100644 index dd0b0cac..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/ISIPProcessorObserver.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit; - -import javax.sip.SipListener; - -public interface ISIPProcessorObserver extends SipListener { - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java deleted file mode 100644 index 52356c1d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java +++ /dev/null @@ -1,205 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit; - -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.response.ISIPResponseProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; -import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import javax.sip.*; -import javax.sip.header.*; -import javax.sip.message.Request; -import javax.sip.message.Response; -import java.net.InetAddress; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @description: SIP信令处理类观察者 - * @author: panlinlin - * @date: 2021年11月5日 下午15:32 - */ -@Component -public class SIPProcessorObserver implements ISIPProcessorObserver { - - private final static Logger logger = LoggerFactory.getLogger(SIPProcessorObserver.class); - - private static Map requestProcessorMap = new ConcurrentHashMap<>(); - private static Map responseProcessorMap = new ConcurrentHashMap<>(); - private static ITimeoutProcessor timeoutProcessor; - - @Autowired - private SipSubscribe sipSubscribe; - - @Autowired - private EventPublisher eventPublisher; - - /** - * 添加 request订阅 - * @param method 方法名 - * @param processor 处理程序 - */ - public void addRequestProcessor(String method, ISIPRequestProcessor processor) { - requestProcessorMap.put(method, processor); - } - - /** - * 添加 response订阅 - * @param method 方法名 - * @param processor 处理程序 - */ - public void addResponseProcessor(String method, ISIPResponseProcessor processor) { - responseProcessorMap.put(method, processor); - } - - /** - * 添加 超时事件订阅 - * @param processor 处理程序 - */ - public void addTimeoutProcessor(ITimeoutProcessor processor) { - timeoutProcessor = processor; - } - - /** - * 分发RequestEvent事件 - * @param requestEvent RequestEvent事件 - */ - @Override - @Async("taskExecutor") - public void processRequest(RequestEvent requestEvent) { - String method = requestEvent.getRequest().getMethod(); - ISIPRequestProcessor sipRequestProcessor = requestProcessorMap.get(method); - if (sipRequestProcessor == null) { - logger.warn("不支持方法{}的request", method); - // TODO 回复错误玛 - return; - } - requestProcessorMap.get(method).process(requestEvent); - - } - - /** - * 分发ResponseEvent事件 - * @param responseEvent responseEvent事件 - */ - @Override - @Async("taskExecutor") - public void processResponse(ResponseEvent responseEvent) { - Response response = responseEvent.getResponse(); - int status = response.getStatusCode(); - - // Success - if (((status >= Response.OK) && (status < Response.MULTIPLE_CHOICES)) || status == Response.UNAUTHORIZED) { - CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME); - String method = cseqHeader.getMethod(); - ISIPResponseProcessor sipRequestProcessor = responseProcessorMap.get(method); - if (sipRequestProcessor != null) { - sipRequestProcessor.process(responseEvent); - } - if (status != Response.UNAUTHORIZED && responseEvent.getResponse() != null && sipSubscribe.getOkSubscribesSize() > 0 ) { - CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME); - if (callIdHeader != null) { - SipSubscribe.Event subscribe = sipSubscribe.getOkSubscribe(callIdHeader.getCallId()); - if (subscribe != null) { - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent); - sipSubscribe.removeOkSubscribe(callIdHeader.getCallId()); - subscribe.response(eventResult); - } - } - } - } else if ((status >= Response.TRYING) && (status < Response.OK)) { - // 增加其它无需回复的响应,如101、180等 - } else { - logger.warn("接收到失败的response响应!status:" + status + ",message:" + response.getReasonPhrase()); - if (responseEvent.getResponse() != null && sipSubscribe.getErrorSubscribesSize() > 0 ) { - CallIdHeader callIdHeader = (CallIdHeader)responseEvent.getResponse().getHeader(CallIdHeader.NAME); - if (callIdHeader != null) { - SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()); - if (subscribe != null) { - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent); - subscribe.response(eventResult); - sipSubscribe.removeErrorSubscribe(callIdHeader.getCallId()); - } - } - } - if (responseEvent.getDialog() != null) { - responseEvent.getDialog().delete(); - } - } - - - } - - /** - * 向超时订阅发送消息 - * @param timeoutEvent timeoutEvent事件 - */ - @Override - public void processTimeout(TimeoutEvent timeoutEvent) { - logger.info("[消息发送超时]"); - ClientTransaction clientTransaction = timeoutEvent.getClientTransaction(); - - if (clientTransaction != null) { - logger.info("[发送错误订阅] clientTransaction != null"); - Request request = clientTransaction.getRequest(); - if (request != null) { - logger.info("[发送错误订阅] request != null"); - CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); - if (callIdHeader != null) { - logger.info("[发送错误订阅]"); - SipSubscribe.Event subscribe = sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()); - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(timeoutEvent); - if (subscribe != null){ - subscribe.response(eventResult); - } - sipSubscribe.removeOkSubscribe(callIdHeader.getCallId()); - sipSubscribe.removeErrorSubscribe(callIdHeader.getCallId()); - } - } - } - eventPublisher.requestTimeOut(timeoutEvent); - } - - @Override - public void processIOException(IOExceptionEvent exceptionEvent) { - System.out.println("processIOException"); - } - - @Override - public void processTransactionTerminated(TransactionTerminatedEvent transactionTerminatedEvent) { -// if (transactionTerminatedEvent.isServerTransaction()) { -// ServerTransaction serverTransaction = transactionTerminatedEvent.getServerTransaction(); -// serverTransaction.get -// } - - -// Transaction transaction = null; -// System.out.println("processTransactionTerminated"); -// if (transactionTerminatedEvent.isServerTransaction()) { -// transaction = transactionTerminatedEvent.getServerTransaction(); -// }else { -// transaction = transactionTerminatedEvent.getClientTransaction(); -// } -// -// System.out.println(transaction.getBranchId()); -// System.out.println(transaction.getState()); -// System.out.println(transaction.getRequest().getMethod()); -// CallIdHeader header = (CallIdHeader)transaction.getRequest().getHeader(CallIdHeader.NAME); -// SipSubscribe.EventResult terminatedEventEventResult = new SipSubscribe.EventResult<>(transactionTerminatedEvent); - -// sipSubscribe.getErrorSubscribe(header.getCallId()).response(terminatedEventEventResult); - } - - @Override - public void processDialogTerminated(DialogTerminatedEvent dialogTerminatedEvent) { - CallIdHeader callId = dialogTerminatedEvent.getDialog().getCallId(); - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java deleted file mode 100644 index e8066b75..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPSender.java +++ /dev/null @@ -1,132 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit; - -import com.genersoft.iot.vmp.gb28181.SipLayer; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.utils.GitUtil; -import gov.nist.javax.sip.SipProviderImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.SipException; -import javax.sip.header.CallIdHeader; -import javax.sip.header.UserAgentHeader; -import javax.sip.header.ViaHeader; -import javax.sip.message.Message; -import javax.sip.message.Request; -import javax.sip.message.Response; -import java.text.ParseException; - -/** - * 发送SIP消息 - * @author lin - */ -@Component -public class SIPSender { - - private final Logger logger = LoggerFactory.getLogger(SIPSender.class); - - @Autowired - private SipLayer sipLayer; - - @Autowired - private GitUtil gitUtil; - - @Autowired - private SipSubscribe sipSubscribe; - - public void transmitRequest(String ip, Message message) throws SipException, ParseException { - transmitRequest(ip, message, null, null); - } - - public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent) throws SipException, ParseException { - transmitRequest(ip, message, errorEvent, null); - } - - public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException { - ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME); - String transport = "UDP"; - if (viaHeader == null) { - logger.warn("[消息头缺失]: ViaHeader, 使用默认的UDP方式处理数据"); - }else { - transport = viaHeader.getTransport(); - } - if (message.getHeader(UserAgentHeader.NAME) == null) { - try { - message.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - } catch (ParseException e) { - logger.error("添加UserAgentHeader失败", e); - } - } - - CallIdHeader callIdHeader = (CallIdHeader) message.getHeader(CallIdHeader.NAME); - // 添加错误订阅 - if (errorEvent != null) { - sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (eventResult -> { - errorEvent.response(eventResult); - sipSubscribe.removeErrorSubscribe(eventResult.callId); - sipSubscribe.removeOkSubscribe(eventResult.callId); - })); - } - // 添加订阅 - if (okEvent != null) { - sipSubscribe.addOkSubscribe(callIdHeader.getCallId(), eventResult -> { - okEvent.response(eventResult); - sipSubscribe.removeOkSubscribe(eventResult.callId); - sipSubscribe.removeErrorSubscribe(eventResult.callId); - }); - } - if ("TCP".equals(transport)) { - SipProviderImpl tcpSipProvider = sipLayer.getTcpSipProvider(ip); - if (tcpSipProvider == null) { - logger.error("[发送信息失败] 未找到tcp://{}的监听信息", ip); - return; - } - if (message instanceof Request) { - tcpSipProvider.sendRequest((Request)message); - }else if (message instanceof Response) { - tcpSipProvider.sendResponse((Response)message); - } - - } else if ("UDP".equals(transport)) { - SipProviderImpl sipProvider = sipLayer.getUdpSipProvider(ip); - if (sipProvider == null) { - logger.error("[发送信息失败] 未找到udp://{}的监听信息", ip); - return; - } - if (message instanceof Request) { - sipProvider.sendRequest((Request)message); - }else if (message instanceof Response) { - sipProvider.sendResponse((Response)message); - } - } - } - - public CallIdHeader getNewCallIdHeader(String ip, String transport){ - if (ObjectUtils.isEmpty(transport)) { - return sipLayer.getUdpSipProvider().getNewCallId(); - } - SipProviderImpl sipProvider; - if (ObjectUtils.isEmpty(ip)) { - sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider() - : sipLayer.getUdpSipProvider(); - }else { - sipProvider = transport.equalsIgnoreCase("TCP") ? sipLayer.getTcpSipProvider(ip) - : sipLayer.getUdpSipProvider(ip); - } - - if (sipProvider == null) { - sipProvider = sipLayer.getUdpSipProvider(); - } - - if (sipProvider != null) { - return sipProvider.getNewCallId(); - }else { - logger.warn("[新建CallIdHeader失败], ip={}, transport={}", ip, transport); - return null; - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java deleted file mode 100644 index 8d0ed7fb..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java +++ /dev/null @@ -1,160 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.callback; - -import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; -import org.springframework.web.context.request.async.DeferredResult; - -import java.util.Collection; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @description: 异步请求处理 - * @author: swwheihei - * @date: 2020年5月8日 下午7:59:05 - */ -@SuppressWarnings(value = {"rawtypes", "unchecked"}) -@Component -public class DeferredResultHolder { - - public static final String CALLBACK_CMD_DEVICESTATUS = "CALLBACK_DEVICESTATUS"; - - public static final String CALLBACK_CMD_DEVICEINFO = "CALLBACK_DEVICEINFO"; - - public static final String CALLBACK_CMD_DEVICECONTROL = "CALLBACK_DEVICECONTROL"; - - public static final String CALLBACK_CMD_DEVICECONFIG = "CALLBACK_DEVICECONFIG"; - - public static final String CALLBACK_CMD_CONFIGDOWNLOAD = "CALLBACK_CONFIGDOWNLOAD"; - - public static final String CALLBACK_CMD_CATALOG = "CALLBACK_CATALOG"; - - public static final String CALLBACK_CMD_RECORDINFO = "CALLBACK_RECORDINFO"; - - public static final String CALLBACK_CMD_PLAY = "CALLBACK_PLAY"; - - public static final String CALLBACK_CMD_PLAYBACK = "CALLBACK_PLAYBACK"; - - public static final String CALLBACK_CMD_DOWNLOAD = "CALLBACK_DOWNLOAD"; - - public static final String CALLBACK_CMD_PROXY = "CALLBACK_PROXY"; - - public static final String CALLBACK_CMD_STOP = "CALLBACK_STOP"; - - public static final String UPLOAD_FILE_CHANNEL = "UPLOAD_FILE_CHANNEL"; - - public static final String CALLBACK_CMD_MOBILE_POSITION = "CALLBACK_CMD_MOBILE_POSITION"; - - public static final String CALLBACK_CMD_PRESETQUERY = "CALLBACK_PRESETQUERY"; - - public static final String CALLBACK_CMD_ALARM = "CALLBACK_ALARM"; - - public static final String CALLBACK_CMD_BROADCAST = "CALLBACK_BROADCAST"; - - public static final String CALLBACK_CMD_SNAP= "CALLBACK_SNAP"; - - private Map> map = new ConcurrentHashMap<>(); - - - public void put(String key, String id, DeferredResultEx result) { - Map deferredResultMap = map.get(key); - if (deferredResultMap == null) { - deferredResultMap = new ConcurrentHashMap<>(); - map.put(key, deferredResultMap); - } - deferredResultMap.put(id, result); - } - - public void put(String key, String id, DeferredResult result) { - Map deferredResultMap = map.get(key); - if (deferredResultMap == null) { - deferredResultMap = new ConcurrentHashMap<>(); - map.put(key, deferredResultMap); - } - deferredResultMap.put(id, new DeferredResultEx(result)); - } - - public DeferredResultEx get(String key, String id) { - Map deferredResultMap = map.get(key); - if (deferredResultMap == null || ObjectUtils.isEmpty(id)) { - return null; - } - return deferredResultMap.get(id); - } - - public Collection getAllByKey(String key) { - Map deferredResultMap = map.get(key); - if (deferredResultMap == null) { - return null; - } - return deferredResultMap.values(); - } - - public boolean exist(String key, String id){ - if (key == null) { - return false; - } - Map deferredResultMap = map.get(key); - if (id == null) { - return deferredResultMap != null; - }else { - return deferredResultMap != null && deferredResultMap.get(id) != null; - } - } - - /** - * 释放单个请求 - * @param msg - */ - public void invokeResult(RequestMessage msg) { - Map deferredResultMap = map.get(msg.getKey()); - if (deferredResultMap == null) { - return; - } - DeferredResultEx result = deferredResultMap.get(msg.getId()); - if (result == null) { - return; - } - result.getDeferredResult().setResult(msg.getData()); - deferredResultMap.remove(msg.getId()); - if (deferredResultMap.size() == 0) { - map.remove(msg.getKey()); - } - } - - /** - * 释放所有的请求 - * @param msg - */ - public void invokeAllResult(RequestMessage msg) { - Map deferredResultMap = map.get(msg.getKey()); - if (deferredResultMap == null) { - return; - } - synchronized (this) { - deferredResultMap = map.get(msg.getKey()); - if (deferredResultMap == null) { - return; - } - Set ids = deferredResultMap.keySet(); - for (String id : ids) { - DeferredResultEx result = deferredResultMap.get(id); - if (result == null) { - return; - } - if (result.getFilter() != null) { - Object handler = result.getFilter().handler(msg.getData()); - result.getDeferredResult().setResult(handler); - }else { - result.getDeferredResult().setResult(msg.getData()); - } - - } - map.remove(msg.getKey()); - } - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java deleted file mode 100644 index f4e2d201..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.callback; - -/** - * @description: 请求信息定义 - * @author: swwheihei - * @date: 2020年5月8日 下午1:09:18 - */ -public class RequestMessage { - - private String id; - - private String key; - - private Object data; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public void setKey(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - public Object getData() { - return data; - } - - public void setData(Object data) { - this.data = data; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java deleted file mode 100644 index a169a317..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ /dev/null @@ -1,364 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.cmd; - -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import gov.nist.javax.sip.message.SIPRequest; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; - -/** - * @description:设备能力接口,用于定义设备的控制、查询能力 - * @author: swwheihei - * @date: 2020年5月3日 下午9:16:34 - */ -public interface ISIPCommander { - - /** - * 云台方向放控制,使用配置文件中的默认镜头移动速度 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - */ - void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException; - - /** - * 云台方向放控制 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - * @param moveSpeed 镜头移动速度 - */ - void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException; - - /** - * 云台缩放控制,使用配置文件中的默认镜头缩放速度 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - */ - void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException; - - /** - * 云台缩放控制 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - */ - void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException; - - /** - * 云台控制,支持方向与缩放控制 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - * @param moveSpeed 镜头移动速度 - * @param zoomSpeed 镜头缩放速度 - */ - void ptzCmd(Device device,String channelId,int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) throws InvalidArgumentException, SipException, ParseException; - - /** - * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param cmdCode 指令码 - * @param parameter1 数据1 - * @param parameter2 数据2 - * @param combineCode2 组合码2 - */ - void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException; - - /** - * 前端控制指令(用于转发上级指令) - * @param device 控制设备 - * @param channelId 预览通道 - * @param cmdString 前端控制指令串 - */ - void fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 请求预览视频流 - * @param device 视频设备 - * @param channelId 预览通道 - */ - void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 请求回放视频流 - * - * @param device 视频设备 - * @param channelId 预览通道 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss - */ - void playbackStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInf, Device device, String channelId, String startTime, String endTime,ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 请求历史媒体下载 - * - * @param device 视频设备 - * @param channelId 预览通道 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param downloadSpeed 下载倍速参数 - */ - void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - String startTime, String endTime, int downloadSpeed, ZlmHttpHookSubscribe.Event hookEvent, - SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 视频流停止 - */ - void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException; - - void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException; - - /** - * 回放暂停 - */ - void playPauseCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException; - - /** - * 回放恢复 - */ - void playResumeCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException; - - /** - * 回放拖动播放 - */ - void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) throws InvalidArgumentException, ParseException, SipException; - - /** - * 回放倍速播放 - */ - void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException; - - /** - * 回放控制 - * @param device - * @param streamInfo - * @param content - */ - void playbackControlCmd(Device device, StreamInfo streamInfo, String content,SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException; - - - /** - * 语音广播 - * - * @param device 视频设备 - * @param channelId 预览通道 - */ - void audioBroadcastCmd(Device device,String channelId); - - /** - * 语音广播 - * - * @param device 视频设备 - */ - void audioBroadcastCmd(Device device, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException; - - /** - * 音视频录像控制 - * - * @param device 视频设备 - * @param channelId 预览通道 - * @param recordCmdStr 录像命令:Record / StopRecord - */ - void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 远程启动控制命令 - * - * @param device 视频设备 - */ - void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException; - - /** - * 报警布防/撤防命令 - * - * @param device 视频设备 - */ - void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 报警复位命令 - * - * @param device 视频设备 - * @param alarmMethod 报警方式(可选) - * @param alarmType 报警类型(可选) - */ - void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧 - * - * @param device 视频设备 - * @param channelId 预览通道 - */ - void iFrameCmd(Device device, String channelId) throws InvalidArgumentException, SipException, ParseException; - - /** - * 看守位控制命令 - * - * @param device 视频设备 - * @param channelId 通道id,非通道则是设备本身 - * @param enabled 看守位使能:1 = 开启,0 = 关闭 - * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s) - * @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255 - */ - void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 设备配置命令 - * - * @param device 视频设备 - */ - void deviceConfigCmd(Device device); - - /** - * 设备配置命令:basicParam - * - * @param device 视频设备 - * @param channelId 通道编码(可选) - * @param name 设备/通道名称(可选) - * @param expiration 注册过期时间(可选) - * @param heartBeatInterval 心跳间隔时间(可选) - * @param heartBeatCount 心跳超时次数(可选) - */ - void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 查询设备状态 - * - * @param device 视频设备 - */ - void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 查询设备信息 - * - * @param device 视频设备 - * @return - */ - void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException; - - /** - * 查询目录列表 - * - * @param device 视频设备 - */ - void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException; - - /** - * 查询录像信息 - * - * @param device 视频设备 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param sn - */ - void recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer Secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 查询报警信息 - * - * @param device 视频设备 - * @param startPriority 报警起始级别(可选) - * @param endPriority 报警终止级别(可选) - * @param alarmMethod 报警方式条件(可选) - * @param alarmType 报警类型 - * @param startTime 报警发生起始时间(可选) - * @param endTime 报警发生终止时间(可选) - * @return true = 命令发送成功 - */ - void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod, - String alarmType, String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 查询设备配置 - * - * @param device 视频设备 - * @param channelId 通道编码(可选) - * @param configType 配置类型: - */ - void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 查询设备预置位置 - * - * @param device 视频设备 - */ - void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 查询移动设备位置数据 - * - * @param device 视频设备 - */ - void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 订阅、取消订阅移动位置 - * - * @param device 视频设备 - * @return true = 命令发送成功 - */ - SIPRequest mobilePositionSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent , SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 订阅、取消订阅报警信息 - * @param device 视频设备 - * @param expires 订阅过期时间(0 = 取消订阅) - * @param startPriority 报警起始级别(可选) - * @param endPriority 报警终止级别(可选) - * @param alarmType 报警类型 - * @param startTime 报警发生起始时间(可选) - * @param endTime 报警发生终止时间(可选) - * @return true = 命令发送成功 - */ - void alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String startTime, String endTime) throws InvalidArgumentException, SipException, ParseException; - - /** - * 订阅、取消订阅目录信息 - * @param device 视频设备 - * @return true = 命令发送成功 - */ - SIPRequest catalogSubscribe(Device device, SIPRequest request, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException; - - /** - * 拉框控制命令 - * - * @param device 控制设备 - * @param channelId 通道id - * @param cmdString 前端控制指令串 - */ - void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException; - - - /** - * 向设备发送报警NOTIFY消息, 用于互联结构下,此时将设备当成一个平级平台看待 - * @param device 设备 - * @param deviceAlarm 报警信息信息 - * @return - */ - void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException; - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java deleted file mode 100644 index a4558c75..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java +++ /dev/null @@ -1,128 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.cmd; - -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import javax.sip.header.WWWAuthenticateHeader; -import java.text.ParseException; -import java.util.List; - -public interface ISIPCommanderForPlatform { - - /** - * 向上级平台注册 - * @param parentPlatform - * @return - */ - void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException; - - void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException; - - - void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, WWWAuthenticateHeader www, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean isRegister) throws SipException, InvalidArgumentException, ParseException; - - /** - * 向上级平台注销 - * @param parentPlatform - * @return - */ - void unregister(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException; - - - /** - * 向上级平发送心跳信息 - * @param parentPlatform - * @return callId(作为接受回复的判定) - */ - String keepalive(ParentPlatform parentPlatform,SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException; - - - /** - * 向上级回复通道信息 - * @param channel 通道信息 - * @param parentPlatform 平台信息 - * @param sn - * @param fromTag - * @param size - * @return - */ - void catalogQuery(DeviceChannel channel, ParentPlatform parentPlatform, String sn, String fromTag, int size) throws SipException, InvalidArgumentException, ParseException; - void catalogQuery(List channels, ParentPlatform parentPlatform, String sn, String fromTag) throws InvalidArgumentException, ParseException, SipException; - - /** - * 向上级回复DeviceInfo查询信息 - * @param parentPlatform 平台信息 - * @param sn SN - * @param fromTag FROM头的tag信息 - * @return - */ - void deviceInfoResponse(ParentPlatform parentPlatform,Device device, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException; - - /** - * 向上级回复DeviceStatus查询信息 - * @param parentPlatform 平台信息 - * @param sn - * @param fromTag - * @return - */ - void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,boolean status) throws SipException, InvalidArgumentException, ParseException; - - /** - * 向上级回复移动位置订阅消息 - * @param parentPlatform 平台信息 - * @param gpsMsgInfo GPS信息 - * @param subscribeInfo 订阅相关的信息 - * @return - */ - void sendNotifyMobilePosition(ParentPlatform parentPlatform, GPSMsgInfo gpsMsgInfo, SubscribeInfo subscribeInfo) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; - - /** - * 向上级回复报警消息 - * @param parentPlatform 平台信息 - * @param deviceAlarm 报警信息信息 - * @return - */ - void sendAlarmMessage(ParentPlatform parentPlatform, DeviceAlarm deviceAlarm) throws SipException, InvalidArgumentException, ParseException; - - /** - * 回复catalog事件-增加/更新 - * @param parentPlatform - * @param deviceChannels - */ - void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; - - /** - * 回复catalog事件-删除 - * @param parentPlatform - * @param deviceChannels - */ - void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException; - - /** - * 回复recordInfo - * @param deviceChannel 通道信息 - * @param parentPlatform 平台信息 - * @param fromTag fromTag - * @param recordInfo 录像信息 - */ - void recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) throws SipException, InvalidArgumentException, ParseException; - - /** - * 录像播放推送完成时发送MediaStatus消息 - * @param platform - * @param sendRtpItem - * @return - */ - void sendMediaStatusNotify(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException; - - /** - * 向发起点播的上级回复bye - * @param platform 平台信息 - * @param callId callId - */ - void streamByeCmd(ParentPlatform platform, String callId) throws SipException, InvalidArgumentException, ParseException; - void streamByeCmd(ParentPlatform platform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException; -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java deleted file mode 100644 index 77c0a08c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderPlarformProvider.java +++ /dev/null @@ -1,316 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.cmd; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.SipLayer; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.utils.GitUtil; -import gov.nist.javax.sip.message.MessageFactoryImpl; -import gov.nist.javax.sip.message.SIPRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.DigestUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.PeerUnavailableException; -import javax.sip.SipFactory; -import javax.sip.address.Address; -import javax.sip.address.SipURI; -import javax.sip.header.*; -import javax.sip.message.Request; -import javax.validation.constraints.NotNull; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.UUID; - -/** - * @description: 平台命令request创造器 TODO 冗余代码太多待优化 - * @author: panll - * @date: 2020年5月6日 上午9:29:02 - */ -@Component -public class SIPRequestHeaderPlarformProvider { - - @Autowired - private SipConfig sipConfig; - - @Autowired - private SipLayer sipLayer; - - @Autowired - private GitUtil gitUtil; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, long CSeq, String fromTag, String toTag, CallIdHeader callIdHeader, int expires) throws ParseException, InvalidArgumentException, PeerUnavailableException { - Request request = null; - String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); - //请求行 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), - parentPlatform.getServerIp() + ":" + parentPlatform.getServerPort()); - //via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), - Integer.parseInt(parentPlatform.getDevicePort()), parentPlatform.getTransport(), SipUtils.getNewViaTag()); - viaHeader.setRPort(); - viaHeaders.add(viaHeader); - //from - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); - //to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,toTag); - - //Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - - //ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(CSeq, Request.REGISTER); - request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.REGISTER, callIdHeader, - cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); - - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory() - .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - - ExpiresHeader expiresHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(expires); - request.addHeader(expiresHeader); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - return request; - } - - public Request createRegisterRequest(@NotNull ParentPlatform parentPlatform, String fromTag, String toTag, - WWWAuthenticateHeader www , CallIdHeader callIdHeader, int expires) throws ParseException, PeerUnavailableException, InvalidArgumentException { - - - Request registerRequest = createRegisterRequest(parentPlatform, redisCatchStorage.getCSEQ(), fromTag, toTag, callIdHeader, expires); - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIp() + ":" + parentPlatform.getServerPort()); - if (www == null) { - AuthorizationHeader authorizationHeader = SipFactory.getInstance().createHeaderFactory().createAuthorizationHeader("Digest"); - String username = parentPlatform.getUsername(); - if ( username == null || username == "" ) - { - authorizationHeader.setUsername(parentPlatform.getDeviceGBId()); - } else { - authorizationHeader.setUsername(username); - } - authorizationHeader.setURI(requestURI); - authorizationHeader.setAlgorithm("MD5"); - registerRequest.addHeader(authorizationHeader); - return registerRequest; - } - String realm = www.getRealm(); - String nonce = www.getNonce(); - String scheme = www.getScheme(); - - // 参考 https://blog.csdn.net/y673533511/article/details/88388138 - // qop 保护质量 包含auth(默认的)和auth-int(增加了报文完整性检测)两种策略 - String qop = www.getQop(); - - String cNonce = null; - String nc = "00000001"; - if (qop != null) { - if ("auth".equalsIgnoreCase(qop)) { - // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 - // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 - cNonce = UUID.randomUUID().toString(); - - }else if ("auth-int".equalsIgnoreCase(qop)){ - // TODO - } - } - String HA1 = DigestUtils.md5DigestAsHex((parentPlatform.getDeviceGBId() + ":" + realm + ":" + parentPlatform.getPassword()).getBytes()); - String HA2=DigestUtils.md5DigestAsHex((Request.REGISTER + ":" + requestURI.toString()).getBytes()); - - StringBuffer reStr = new StringBuffer(200); - reStr.append(HA1); - reStr.append(":"); - reStr.append(nonce); - reStr.append(":"); - if (qop != null) { - reStr.append(nc); - reStr.append(":"); - reStr.append(cNonce); - reStr.append(":"); - reStr.append(qop); - reStr.append(":"); - } - reStr.append(HA2); - - String RESPONSE = DigestUtils.md5DigestAsHex(reStr.toString().getBytes()); - - AuthorizationHeader authorizationHeader = SipFactory.getInstance().createHeaderFactory().createAuthorizationHeader(scheme); - authorizationHeader.setUsername(parentPlatform.getDeviceGBId()); - authorizationHeader.setRealm(realm); - authorizationHeader.setNonce(nonce); - authorizationHeader.setURI(requestURI); - authorizationHeader.setResponse(RESPONSE); - authorizationHeader.setAlgorithm("MD5"); - if (qop != null) { - authorizationHeader.setQop(qop); - authorizationHeader.setCNonce(cNonce); - authorizationHeader.setNonceCount(1); - } - registerRequest.addHeader(authorizationHeader); - - return registerRequest; - } - - public Request createMessageRequest(ParentPlatform parentPlatform, String content, SendRtpItem sendRtpItem) throws PeerUnavailableException, ParseException, InvalidArgumentException { - CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); - callIdHeader.setCallId(sendRtpItem.getCallId()); - return createMessageRequest(parentPlatform, content, sendRtpItem.getToTag(), SipUtils.getNewViaTag(), sendRtpItem.getFromTag(), callIdHeader); - } - - public Request createMessageRequest(ParentPlatform parentPlatform, String content, String fromTag, String viaTag, CallIdHeader callIdHeader) throws PeerUnavailableException, ParseException, InvalidArgumentException { - return createMessageRequest(parentPlatform, content, fromTag, viaTag, null, callIdHeader); - } - - - public Request createMessageRequest(ParentPlatform parentPlatform, String content, String fromTag, String viaTag, String toTag, CallIdHeader callIdHeader) throws PeerUnavailableException, ParseException, InvalidArgumentException { - Request request = null; - String serverAddress = parentPlatform.getServerIp()+ ":" + parentPlatform.getServerPort(); - // sipuri - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); - // via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), - parentPlatform.getTransport(), viaTag); - viaHeader.setRPort(); - viaHeaders.add(viaHeader); - // from - // SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), parentPlatform.getDeviceIp() + ":" + parentPlatform.getDeviceIp()); - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), sipConfig.getDomain()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); - // to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), serverAddress); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, toTag); - - // Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - // ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); - MessageFactoryImpl messageFactory = (MessageFactoryImpl) SipFactory.getInstance().createMessageFactory(); - // 设置编码, 防止中文乱码 - messageFactory.setDefaultContentEncodingCharset(parentPlatform.getCharacterSet()); - request = messageFactory.createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, - toHeader, viaHeaders, maxForwards); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); - request.setContent(content, contentTypeHeader); - return request; - } - - public SIPRequest createNotifyRequest(ParentPlatform parentPlatform, String content, SubscribeInfo subscribeInfo) throws PeerUnavailableException, ParseException, InvalidArgumentException { - SIPRequest request = null; - // sipuri - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerIp()+ ":" + parentPlatform.getServerPort()); - // via - ArrayList viaHeaders = new ArrayList<>(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(parentPlatform.getDeviceIp(), Integer.parseInt(parentPlatform.getDevicePort()), - parentPlatform.getTransport(), SipUtils.getNewViaTag()); - viaHeader.setRPort(); - viaHeaders.add(viaHeader); - // from - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getDeviceGBId(), - parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, subscribeInfo.getResponse() != null ? subscribeInfo.getResponse().getToTag(): subscribeInfo.getSimulatedToTag()); - // to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(parentPlatform.getServerGBId(), parentPlatform.getServerGBDomain()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, subscribeInfo.getRequest() != null ?subscribeInfo.getRequest().getFromTag(): subscribeInfo.getSimulatedFromTag()); - - // Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - // ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.NOTIFY); - MessageFactoryImpl messageFactory = (MessageFactoryImpl) SipFactory.getInstance().createMessageFactory(); - // 设置编码, 防止中文乱码 - messageFactory.setDefaultContentEncodingCharset("gb2312"); - - CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(subscribeInfo.getRequest() != null ? subscribeInfo.getRequest().getCallIdHeader().getCallId(): subscribeInfo.getSimulatedCallId()); - - request = (SIPRequest) messageFactory.createRequest(requestURI, Request.NOTIFY, callIdHeader, cSeqHeader, fromHeader, - toHeader, viaHeaders, maxForwards); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - EventHeader event = SipFactory.getInstance().createHeaderFactory().createEventHeader(subscribeInfo.getEventType()); - if (subscribeInfo.getEventId() != null) { - event.setEventId(subscribeInfo.getEventId()); - } - - request.addHeader(event); - - SubscriptionStateHeader active = SipFactory.getInstance().createHeaderFactory().createSubscriptionStateHeader("active"); - request.setHeader(active); - - String sipAddress = parentPlatform.getDeviceIp() + ":" + parentPlatform.getDevicePort(); - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory() - .createSipURI(parentPlatform.getDeviceGBId(), sipAddress)); - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); - request.setContent(content, contentTypeHeader); - return request; - } - - public SIPRequest createByeRequest(ParentPlatform platform, SendRtpItem sendRtpItem) throws PeerUnavailableException, ParseException, InvalidArgumentException { - - if (sendRtpItem == null ) { - return null; - } - - SIPRequest request = null; - // sipuri - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIp()+ ":" + platform.getServerPort()); - // via - ArrayList viaHeaders = new ArrayList<>(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(platform.getDeviceIp(), Integer.parseInt(platform.getDevicePort()), - platform.getTransport(), SipUtils.getNewViaTag()); - viaHeader.setRPort(); - viaHeaders.add(viaHeader); - // from - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sendRtpItem.getChannelId(), - platform.getDeviceIp() + ":" + platform.getDevicePort()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, sendRtpItem.getToTag()); - // to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerGBDomain()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, sendRtpItem.getFromTag()); - - // Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - // ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); - - CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(sendRtpItem.getCallId()); - - request = (SIPRequest) SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.BYE, callIdHeader, cSeqHeader, fromHeader, - toHeader, viaHeaders, maxForwards); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - String sipAddress = platform.getDeviceIp() + ":" + platform.getDevicePort(); - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory() - .createSipURI(platform.getDeviceGBId(), sipAddress)); - - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - - return request; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java deleted file mode 100644 index 8ae20a26..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java +++ /dev/null @@ -1,351 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.cmd; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.SipLayer; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.utils.GitUtil; -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.PeerUnavailableException; -import javax.sip.SipException; -import javax.sip.SipFactory; -import javax.sip.address.Address; -import javax.sip.address.SipURI; -import javax.sip.header.*; -import javax.sip.message.Request; -import java.text.ParseException; -import java.util.ArrayList; - -/** - * @description:摄像头命令request创造器 TODO 冗余代码太多待优化 - * @author: swwheihei - * @date: 2020年5月6日 上午9:29:02 - */ -@Component -public class SIPRequestHeaderProvider { - - @Autowired - private SipConfig sipConfig; - - @Autowired - private SipLayer sipLayer; - - @Autowired - private GitUtil gitUtil; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private VideoStreamSessionManager streamSession; - - private Logger logger = LoggerFactory.getLogger(getClass()); - - public Request createMessageRequest(Device device, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { - Request request = null; - // sipuri - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); - // via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); - viaHeader.setRPort(); - viaHeaders.add(viaHeader); - // from(IBoot) -// SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); // 不支持海康威视 - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getIp() + ":" + sipConfig.getPort()); // 支持海康威视 - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); - // to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, toTag); - - // Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - // ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.MESSAGE); - - // Contact(IBoot) - SipURI sipConcatURI = SipFactory.getInstance().createAddressFactory().createSipURI(null, sipLayer.getLocalIp(device.getLocalIp()) + ":" + sipConfig.getPort()); - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(sipConcatURI); - ContactHeader contactHeader = SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress); - - request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader, - toHeader, viaHeaders, maxForwards); - - request.addHeader(contactHeader); - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); - request.setContent(content, contentTypeHeader); - - if(logger.isDebugEnabled()) { - logger.debug("SIP[MESSAGE]请求: {}", request); - } - return request; - } - - public Request createInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, String ssrc, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { - Request request = null; - //请求行 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress()); - //via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); - viaHeader.setRPort(); - viaHeaders.add(viaHeader); - - //from - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack - //to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null); - - //Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - - //ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); - request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); - // Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - // Subject - SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); - request.addHeader(subjectHeader); - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); - request.setContent(content, contentTypeHeader); - - if(logger.isDebugEnabled()) { - logger.debug("SIP[INVITE]请求: {}", request); - } - return request; - } - - public Request createPlaybackInviteRequest(Device device, String channelId, String content, String viaTag, String fromTag, String toTag, CallIdHeader callIdHeader, String ssrc) throws ParseException, InvalidArgumentException, PeerUnavailableException { - Request request = null; - //请求行 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress()); - // via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), viaTag); - viaHeader.setRPort(); - viaHeaders.add(viaHeader); - //from - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, fromTag); //必须要有标记,否则无法创建会话,无法回应ack - //to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress,null); - - //Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - - //ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INVITE); - request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INVITE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); - - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); - // Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), device.getHost().getIp()+":"+device.getHost().getPort())); - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - // Subject - SubjectHeader subjectHeader = SipFactory.getInstance().createHeaderFactory().createSubjectHeader(String.format("%s:%s,%s:%s", channelId, ssrc, sipConfig.getId(), 0)); - request.addHeader(subjectHeader); - - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); - request.setContent(content, contentTypeHeader); - if(logger.isDebugEnabled()) { - logger.debug("SIP[Playback Invite]请求: {}", request); - } - return request; - } - - public Request createByteRequest(Device device, String channelId, SipTransactionInfo transactionInfo) throws ParseException, InvalidArgumentException, PeerUnavailableException { - Request request = null; - //请求行 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress()); -// SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); - // via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); - viaHeaders.add(viaHeader); - //from - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); - //to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress()); -// SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(),device.getHostAddress()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); - - //Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - - //ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.BYE); - CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); - request = SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.BYE, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - if(logger.isDebugEnabled()) { - logger.debug("SIP[BYE]请求: {}", request); - } - return request; - } - - public Request createSubscribeRequest(Device device, String content, SIPRequest requestOld, Integer expires, String event, CallIdHeader callIdHeader) throws ParseException, InvalidArgumentException, PeerUnavailableException { - Request request = null; - // sipuri - SipURI requestURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); - // via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), - device.getTransport(), SipUtils.getNewViaTag()); - viaHeader.setRPort(); - viaHeaders.add(viaHeader); - // from - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipConfig.getDomain()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, requestOld == null ? SipUtils.getNewFromTag() :requestOld.getFromTag()); - // to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(device.getDeviceId(), device.getHostAddress()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, requestOld == null ? null :requestOld.getToTag()); - - // Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - - // ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.SUBSCRIBE); - - request = SipFactory.getInstance().createMessageFactory().createRequest(requestURI, Request.SUBSCRIBE, callIdHeader, cSeqHeader, fromHeader, - toHeader, viaHeaders, maxForwards); - - - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - - // Expires - ExpiresHeader expireHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(expires); - request.addHeader(expireHeader); - - // Event - EventHeader eventHeader = SipFactory.getInstance().createHeaderFactory().createEventHeader(event); - - int random = (int) Math.floor(Math.random() * 10000); - eventHeader.setEventId(random + ""); - request.addHeader(eventHeader); - - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); - request.setContent(content, contentTypeHeader); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - if(logger.isDebugEnabled()) { - logger.debug("SIP[SUBSCRIBE]请求: {}", request); - } - return request; - } - - public SIPRequest createInfoRequest(Device device, String channelId, String content, SipTransactionInfo transactionInfo) - throws SipException, ParseException, InvalidArgumentException { - if (device == null || transactionInfo == null) { - return null; - } - SIPRequest request = null; - //请求行 - SipURI requestLine = SipFactory.getInstance().createAddressFactory().createSipURI(channelId, device.getHostAddress()); - // via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(sipLayer.getLocalIp(device.getLocalIp()), sipConfig.getPort(), device.getTransport(), SipUtils.getNewViaTag()); - viaHeaders.add(viaHeader); - //from - SipURI fromSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(),sipConfig.getDomain()); - Address fromAddress = SipFactory.getInstance().createAddressFactory().createAddress(fromSipURI); - FromHeader fromHeader = SipFactory.getInstance().createHeaderFactory().createFromHeader(fromAddress, transactionInfo.getFromTag()); - //to - SipURI toSipURI = SipFactory.getInstance().createAddressFactory().createSipURI(channelId,device.getHostAddress()); - Address toAddress = SipFactory.getInstance().createAddressFactory().createAddress(toSipURI); - ToHeader toHeader = SipFactory.getInstance().createHeaderFactory().createToHeader(toAddress, transactionInfo.getToTag()); - - //Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - - //ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(redisCatchStorage.getCSEQ(), Request.INFO); - CallIdHeader callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(transactionInfo.getCallId()); - request = (SIPRequest)SipFactory.getInstance().createMessageFactory().createRequest(requestLine, Request.INFO, callIdHeader, cSeqHeader,fromHeader, toHeader, viaHeaders, maxForwards); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), sipLayer.getLocalIp(device.getLocalIp())+":"+sipConfig.getPort())); - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - if (content != null) { - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", - "MANSRTSP"); - request.setContent(content, contentTypeHeader); - } - - if(logger.isDebugEnabled()) { - logger.debug("SIP[INFO]请求: {}", request); - } - return request; - } - - public Request createAckRequest(String localIp, SipURI sipURI, SIPResponse sipResponse) throws ParseException, InvalidArgumentException, PeerUnavailableException { - - - // via - ArrayList viaHeaders = new ArrayList(); - ViaHeader viaHeader = SipFactory.getInstance().createHeaderFactory().createViaHeader(localIp, sipConfig.getPort(), sipResponse.getTopmostViaHeader().getTransport(), SipUtils.getNewViaTag()); - viaHeaders.add(viaHeader); - - //Forwards - MaxForwardsHeader maxForwards = SipFactory.getInstance().createHeaderFactory().createMaxForwardsHeader(70); - - //ceq - CSeqHeader cSeqHeader = SipFactory.getInstance().createHeaderFactory().createCSeqHeader(sipResponse.getCSeqHeader().getSeqNumber(), Request.ACK); - - Request request = SipFactory.getInstance().createMessageFactory().createRequest(sipURI, Request.ACK, sipResponse.getCallIdHeader(), cSeqHeader, sipResponse.getFromHeader(), sipResponse.getToHeader(), viaHeaders, maxForwards); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress(SipFactory.getInstance().createAddressFactory().createSipURI(sipConfig.getId(), localIp + ":"+sipConfig.getPort())); - request.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - - request.addHeader(SipUtils.createUserAgentHeader(gitUtil)); - if(logger.isDebugEnabled()) { - logger.debug("SIP[ACK]请求: {}", request); - } - return request; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java deleted file mode 100644 index a2bc2e54..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ /dev/null @@ -1,1429 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; - -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.SipLayer; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; -import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.genersoft.iot.vmp.utils.DateUtil; -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.DependsOn; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.ResponseEvent; -import javax.sip.SipException; -import javax.sip.SipFactory; -import javax.sip.header.CallIdHeader; -import javax.sip.message.Request; -import java.text.ParseException; -import java.util.List; - -/** - * @description:设备能力接口,用于定义设备的控制、查询能力 - * @author: swwheihei - * @date: 2020年5月3日 下午9:22:48 - */ -@Component -@DependsOn("sipLayer") -public class SIPCommander implements ISIPCommander { - - private final Logger logger = LoggerFactory.getLogger(SIPCommander.class); - - @Autowired - private SipConfig sipConfig; - - @Autowired - private SipLayer sipLayer; - - @Autowired - private SIPSender sipSender; - - @Autowired - private SIPRequestHeaderProvider headerProvider; - - @Autowired - private VideoStreamSessionManager streamSession; - - @Autowired - private UserSetting userSetting; - - @Autowired - private ZlmHttpHookSubscribe subscribe; - - - - @Autowired - private IMediaServerService mediaServerService; - - - /** - * 云台方向放控制,使用配置文件中的默认镜头移动速度 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - */ - @Override - public void ptzdirectCmd(Device device, String channelId, int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException { - ptzCmd(device, channelId, leftRight, upDown, 0, sipConfig.getPtzSpeed(), 0); - } - - /** - * 云台方向放控制 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - * @param moveSpeed 镜头移动速度 - */ - @Override - public void ptzdirectCmd(Device device, String channelId, int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException { - ptzCmd(device, channelId, leftRight, upDown, 0, moveSpeed, 0); - } - - /** - * 云台缩放控制,使用配置文件中的默认镜头缩放速度 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - */ - @Override - public void ptzZoomCmd(Device device, String channelId, int inOut) throws InvalidArgumentException, ParseException, SipException { - ptzCmd(device, channelId, 0, 0, inOut, 0, sipConfig.getPtzSpeed()); - } - - /** - * 云台缩放控制 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - * @param zoomSpeed 镜头缩放速度 - */ - @Override - public void ptzZoomCmd(Device device, String channelId, int inOut, int zoomSpeed) throws InvalidArgumentException, ParseException, SipException { - ptzCmd(device, channelId, 0, 0, inOut, 0, zoomSpeed); - } - - /** - * 云台指令码计算 - * - * @param cmdCode 指令码 - * @param parameter1 数据1 - * @param parameter2 数据2 - * @param combineCode2 组合码2 - */ - public static String frontEndCmdString(int cmdCode, int parameter1, int parameter2, int combineCode2) { - StringBuilder builder = new StringBuilder("A50F01"); - String strTmp; - strTmp = String.format("%02X", cmdCode); - builder.append(strTmp, 0, 2); - strTmp = String.format("%02X", parameter1); - builder.append(strTmp, 0, 2); - strTmp = String.format("%02X", parameter2); - builder.append(strTmp, 0, 2); - //优化zoom变倍速率 - if ((combineCode2 > 0) && (combineCode2 <16)) - { - combineCode2 = 16; - } - strTmp = String.format("%X", combineCode2); - builder.append(strTmp, 0, 1).append("0"); - //计算校验码 - int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + parameter1 + parameter2 + (combineCode2 & 0XF0)) % 0X100; - strTmp = String.format("%02X", checkCode); - builder.append(strTmp, 0, 2); - return builder.toString(); - } - - /** - * 云台控制,支持方向与缩放控制 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - * @param moveSpeed 镜头移动速度 - * @param zoomSpeed 镜头缩放速度 - */ - @Override - public void ptzCmd(Device device, String channelId, int leftRight, int upDown, int inOut, int moveSpeed, - int zoomSpeed) throws InvalidArgumentException, SipException, ParseException { - String cmdStr = SipUtils.cmdString(leftRight, upDown, inOut, moveSpeed, zoomSpeed); - StringBuilder ptzXml = new StringBuilder(200); - String charset = device.getCharset(); - ptzXml.append("\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("DeviceControl\r\n"); - ptzXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - ptzXml.append("" + channelId + "\r\n"); - ptzXml.append("" + cmdStr + "\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("5\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("\r\n"); - - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); - } - - /** - * 前端控制,包括PTZ指令、FI指令、预置位指令、巡航指令、扫描指令和辅助开关指令 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param cmdCode 指令码 - * @param parameter1 数据1 - * @param parameter2 数据2 - * @param combineCode2 组合码2 - */ - @Override - public void frontEndCmd(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combineCode2) throws SipException, InvalidArgumentException, ParseException { - - String cmdStr = frontEndCmdString(cmdCode, parameter1, parameter2, combineCode2); - StringBuffer ptzXml = new StringBuffer(200); - String charset = device.getCharset(); - ptzXml.append("\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("DeviceControl\r\n"); - ptzXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - ptzXml.append("" + channelId + "\r\n"); - ptzXml.append("" + cmdStr + "\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("5\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("\r\n"); - - - - - SIPRequest request = (SIPRequest) headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); - - } - - /** - * 前端控制指令(用于转发上级指令) - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param cmdString 前端控制指令串 - */ - @Override - public void fronEndCmd(Device device, String channelId, String cmdString, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer ptzXml = new StringBuffer(200); - String charset = device.getCharset(); - ptzXml.append("\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("DeviceControl\r\n"); - ptzXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - ptzXml.append("" + channelId + "\r\n"); - ptzXml.append("" + cmdString + "\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("5\r\n"); - ptzXml.append("\r\n"); - ptzXml.append("\r\n"); - - - Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request, errorEvent, okEvent); - - } - - /** - * 请求预览视频流 - * - * @param device 视频设备 - * @param channelId 预览通道 - * @param event hook订阅 - * @param errorEvent sip错误订阅 - */ - @Override - public void playStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - ZlmHttpHookSubscribe.Event event, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - String stream = ssrcInfo.getStream(); - - if (device == null) { - return; - } - - logger.info("{} 分配的ZLM为: {} [{}:{}]", stream, mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); - HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", stream, true, "rtsp", mediaServerItem.getId()); - subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, HookParam hookParam) -> { - if (event != null) { - event.response(mediaServerItemInUse, hookParam); - subscribe.removeSubscribe(hookSubscribe); - } - }); - String sdpIp; - if (!ObjectUtils.isEmpty(device.getSdpIp())) { - sdpIp = device.getSdpIp(); - }else { - sdpIp = mediaServerItem.getSdpIp(); - } - StringBuffer content = new StringBuffer(200); - content.append("v=0\r\n"); - content.append("o=" + channelId + " 0 0 IN IP4 " + sdpIp + "\r\n"); - content.append("s=Play\r\n"); - content.append("c=IN IP4 " + sdpIp + "\r\n"); - content.append("t=0 0\r\n"); - - if (userSetting.isSeniorSdp()) { - if ("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - } else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - } else if ("UDP".equalsIgnoreCase(device.getStreamMode())) { - content.append("m=video " + ssrcInfo.getPort() + " RTP/AVP 96 126 125 99 34 98 97\r\n"); - } - content.append("a=recvonly\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); - content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); - content.append("a=rtpmap:126 H264/90000\r\n"); - content.append("a=rtpmap:125 H264S/90000\r\n"); - content.append("a=fmtp:125 profile-level-id=42e01e\r\n"); - content.append("a=rtpmap:99 H265/90000\r\n"); - content.append("a=rtpmap:98 H264/90000\r\n"); - content.append("a=rtpmap:97 MPEG4/90000\r\n"); - if ("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp被动模式 - content.append("a=setup:passive\r\n"); - content.append("a=connection:new\r\n"); - } else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp主动模式 - content.append("a=setup:active\r\n"); - content.append("a=connection:new\r\n"); - } - } else { - if ("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 97 98 99\r\n"); - } else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 97 98 99\r\n"); - } else if ("UDP".equalsIgnoreCase(device.getStreamMode())) { - content.append("m=video " + ssrcInfo.getPort() + " RTP/AVP 96 97 98 99\r\n"); - } - content.append("a=recvonly\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); - content.append("a=rtpmap:98 H264/90000\r\n"); - content.append("a=rtpmap:97 MPEG4/90000\r\n"); - content.append("a=rtpmap:99 H265/90000\r\n"); - if ("TCP-PASSIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp被动模式 - content.append("a=setup:passive\r\n"); - content.append("a=connection:new\r\n"); - } else if ("TCP-ACTIVE".equalsIgnoreCase(device.getStreamMode())) { // tcp主动模式 - content.append("a=setup:active\r\n"); - content.append("a=connection:new\r\n"); - } - } - - if( device.isSwitchPrimarySubStream() ){ - if("TP-LINK".equals(device.getManufacturer())){ - if (device.isSwitchPrimarySubStream()){ - content.append("a=streamMode:sub\r\n"); - }else { - content.append("a=streamMode:main\r\n"); - } - }else { - if (device.isSwitchPrimarySubStream()){ - content.append("a=streamprofile:1\r\n"); - }else { - content.append("a=streamprofile:0\r\n"); - } - } - } - - content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc - // f字段:f= v/编码格式/分辨率/帧率/码率类型/码率大小a/编码格式/码率大小/采样率 -// content.append("f=v/2/5/25/1/4000a/1/8/1" + "\r\n"); // 未发现支持此特性的设备 - - - - Request request = headerProvider.createInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null, ssrcInfo.getSsrc(),sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, (e -> { - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - errorEvent.response(e); - }), e -> { - ResponseEvent responseEvent = (ResponseEvent) e.event; - SIPResponse response = (SIPResponse) responseEvent.getResponse(); - String callId = response.getCallIdHeader().getCallId(); - streamSession.put(device.getDeviceId(), channelId, callId, stream, ssrcInfo.getSsrc(), mediaServerItem.getId(), response, - InviteSessionType.PLAY); - okEvent.response(e); - }); - } - - /** - * 请求回放视频流 - * - * @param device 视频设备 - * @param channelId 预览通道 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss - */ - @Override - public void playbackStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - String startTime, String endTime, ZlmHttpHookSubscribe.Event hookEvent, - SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - - logger.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); - String sdpIp; - if (!ObjectUtils.isEmpty(device.getSdpIp())) { - sdpIp = device.getSdpIp(); - }else { - sdpIp = mediaServerItem.getSdpIp(); - } - StringBuffer content = new StringBuffer(200); - content.append("v=0\r\n"); - content.append("o=" + channelId + " 0 0 IN IP4 " + sdpIp + "\r\n"); - content.append("s=Playback\r\n"); - content.append("u=" + channelId + ":0\r\n"); - content.append("c=IN IP4 " + sdpIp + "\r\n"); - content.append("t=" + DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime) + " " - + DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) + "\r\n"); - - String streamMode = device.getStreamMode(); - - if (userSetting.isSeniorSdp()) { - if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - } else if ("UDP".equalsIgnoreCase(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " RTP/AVP 96 126 125 99 34 98 97\r\n"); - } - content.append("a=recvonly\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); - content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); - content.append("a=rtpmap:126 H264/90000\r\n"); - content.append("a=rtpmap:125 H264S/90000\r\n"); - content.append("a=fmtp:125 profile-level-id=42e01e\r\n"); - content.append("a=rtpmap:99 H265/90000\r\n"); - content.append("a=rtpmap:98 H264/90000\r\n"); - content.append("a=rtpmap:97 MPEG4/90000\r\n"); - if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { // tcp被动模式 - content.append("a=setup:passive\r\n"); - content.append("a=connection:new\r\n"); - } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { // tcp主动模式 - content.append("a=setup:active\r\n"); - content.append("a=connection:new\r\n"); - } - } else { - if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 97 98 99\r\n"); - } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 97 98 99\r\n"); - } else if ("UDP".equalsIgnoreCase(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " RTP/AVP 96 97 98 99\r\n"); - } - content.append("a=recvonly\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); - content.append("a=rtpmap:97 MPEG4/90000\r\n"); - content.append("a=rtpmap:98 H264/90000\r\n"); - content.append("a=rtpmap:99 H265/90000\r\n"); - if ("TCP-PASSIVE".equalsIgnoreCase(streamMode)) { - // tcp被动模式 - content.append("a=setup:passive\r\n"); - content.append("a=connection:new\r\n"); - } else if ("TCP-ACTIVE".equalsIgnoreCase(streamMode)) { - // tcp主动模式 - content.append("a=setup:active\r\n"); - content.append("a=connection:new\r\n"); - } - } - - //ssrc - content.append("y=" + ssrcInfo.getSsrc() + "\r\n"); - - HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); - // 添加订阅 - subscribe.addSubscribe(hookSubscribe, (MediaServerItem mediaServerItemInUse, HookParam hookParam) -> { - if (hookEvent != null) { - hookEvent.response(mediaServerItemInUse, hookParam); - } - subscribe.removeSubscribe(hookSubscribe); - }); - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()), ssrcInfo.getSsrc()); - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, event -> { - ResponseEvent responseEvent = (ResponseEvent) event.event; - SIPResponse response = (SIPResponse) responseEvent.getResponse(); - streamSession.put(device.getDeviceId(), channelId,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()).getCallId(), ssrcInfo.getStream(), ssrcInfo.getSsrc(), mediaServerItem.getId(), response, InviteSessionType.PLAYBACK); - okEvent.response(event); - }); - } - - /** - * 请求历史媒体下载 - * - * @param device 视频设备 - * @param channelId 预览通道 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param downloadSpeed 下载倍速参数 - */ - @Override - public void downloadStreamCmd(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - String startTime, String endTime, int downloadSpeed, - ZlmHttpHookSubscribe.Event hookEvent, - SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { - - logger.info("{} 分配的ZLM为: {} [{}:{}]", ssrcInfo.getStream(), mediaServerItem.getId(), mediaServerItem.getSdpIp(), ssrcInfo.getPort()); - String sdpIp; - if (!ObjectUtils.isEmpty(device.getSdpIp())) { - sdpIp = device.getSdpIp(); - }else { - sdpIp = mediaServerItem.getSdpIp(); - } - StringBuffer content = new StringBuffer(200); - content.append("v=0\r\n"); - content.append("o=" + channelId + " 0 0 IN IP4 " + sdpIp + "\r\n"); - content.append("s=Download\r\n"); - content.append("u=" + channelId + ":0\r\n"); - content.append("c=IN IP4 " + sdpIp + "\r\n"); - content.append("t=" + DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime) + " " - + DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime) + "\r\n"); - - String streamMode = device.getStreamMode().toUpperCase(); - - if (userSetting.isSeniorSdp()) { - if ("TCP-PASSIVE".equals(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - } else if ("TCP-ACTIVE".equals(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 126 125 99 34 98 97\r\n"); - } else if ("UDP".equals(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " RTP/AVP 96 126 125 99 34 98 97\r\n"); - } - content.append("a=recvonly\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); - content.append("a=fmtp:126 profile-level-id=42e01e\r\n"); - content.append("a=rtpmap:126 H264/90000\r\n"); - content.append("a=rtpmap:125 H264S/90000\r\n"); - content.append("a=fmtp:125 profile-level-id=42e01e\r\n"); - content.append("a=rtpmap:99 MP4V-ES/90000\r\n"); - content.append("a=fmtp:99 profile-level-id=3\r\n"); - content.append("a=rtpmap:98 H264/90000\r\n"); - content.append("a=rtpmap:97 MPEG4/90000\r\n"); - if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 - content.append("a=setup:passive\r\n"); - content.append("a=connection:new\r\n"); - } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 - content.append("a=setup:active\r\n"); - content.append("a=connection:new\r\n"); - } - } else { - if ("TCP-PASSIVE".equals(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 97 98 99\r\n"); - } else if ("TCP-ACTIVE".equals(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " TCP/RTP/AVP 96 97 98 99\r\n"); - } else if ("UDP".equals(streamMode)) { - content.append("m=video " + ssrcInfo.getPort() + " RTP/AVP 96 97 98 99\r\n"); - } - content.append("a=recvonly\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); - content.append("a=rtpmap:97 MPEG4/90000\r\n"); - content.append("a=rtpmap:98 H264/90000\r\n"); - content.append("a=rtpmap:99 H265/90000\r\n"); - if ("TCP-PASSIVE".equals(streamMode)) { // tcp被动模式 - content.append("a=setup:passive\r\n"); - content.append("a=connection:new\r\n"); - } else if ("TCP-ACTIVE".equals(streamMode)) { // tcp主动模式 - content.append("a=setup:active\r\n"); - content.append("a=connection:new\r\n"); - } - } - content.append("a=downloadspeed:" + downloadSpeed + "\r\n"); - - content.append("y=" + ssrcInfo.getSsrc() + "\r\n");//ssrc - logger.debug("此时请求下载信令的ssrc===>{}",ssrcInfo.getSsrc()); - HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); - // 添加订阅 - CallIdHeader newCallIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()), device.getTransport()); - String callId= newCallIdHeader.getCallId(); - subscribe.addSubscribe(hookSubscribe, (mediaServerItemInUse, hookParam) -> { - logger.debug("sipc 添加订阅===callId {}",callId); - hookEvent.response(mediaServerItemInUse, hookParam); - subscribe.removeSubscribe(hookSubscribe); - hookSubscribe.getContent().put("regist", false); - hookSubscribe.getContent().put("schema", "rtsp"); - // 添加流注销的订阅,注销了后向设备发送bye - subscribe.addSubscribe(hookSubscribe, - (mediaServerItemForEnd, hookParam1) -> { - logger.info("[录像]下载结束, 发送BYE"); - try { - streamByeCmd(device, channelId, ssrcInfo.getStream(), callId); - } catch (InvalidArgumentException | ParseException | SipException | - SsrcTransactionNotFoundException e) { - logger.error("[录像]下载结束, 发送BYE失败 {}", e.getMessage()); - } - }); - }); - - Request request = headerProvider.createPlaybackInviteRequest(device, channelId, content.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,newCallIdHeader, ssrcInfo.getSsrc()); - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, event -> { - ResponseEvent responseEvent = (ResponseEvent) event.event; - SIPResponse response = (SIPResponse) responseEvent.getResponse(); - String contentString =new String(response.getRawContent()); - String ssrc = SipUtils.getSsrcFromSdp(contentString); - streamSession.put(device.getDeviceId(), channelId, response.getCallIdHeader().getCallId(), ssrcInfo.getStream(), ssrc, mediaServerItem.getId(), response, InviteSessionType.DOWNLOAD); - okEvent.response(event); - }); - } - - /** - * 视频流停止, 不使用回调 - */ - @Override - public void streamByeCmd(Device device, String channelId, String stream, String callId) throws InvalidArgumentException, ParseException, SipException, SsrcTransactionNotFoundException { - streamByeCmd(device, channelId, stream, callId, null); - } - - /** - * 视频流停止 - */ - @Override - public void streamByeCmd(Device device, String channelId, String stream, String callId, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException, SsrcTransactionNotFoundException { - List ssrcTransactionList = streamSession.getSsrcTransactionForAll(device.getDeviceId(), channelId, callId, stream); - if (ssrcTransactionList == null || ssrcTransactionList.isEmpty()) { - logger.info("[发送BYE] 未找到事务信息,设备: device: {}, channel: {}", device.getDeviceId(), channelId); - throw new SsrcTransactionNotFoundException(device.getDeviceId(), channelId, callId, stream); - } - - for (SsrcTransaction ssrcTransaction : ssrcTransactionList) { - logger.info("[发送BYE] 设备: device: {}, channel: {}, callId: {}", device.getDeviceId(), channelId, ssrcTransaction.getCallId()); - mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc()); - - mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream()); - streamSession.removeByCallId(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getCallId()); - Request byteRequest = headerProvider.createByteRequest(device, channelId, ssrcTransaction.getSipTransactionInfo()); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), byteRequest, null, okEvent); - } - } - - /** - * 语音广播 - * - * @param device 视频设备 - * @param channelId 预览通道 - */ - @Override - public void audioBroadcastCmd(Device device, String channelId) { - } - - /** - * 语音广播 - * - * @param device 视频设备 - */ - @Override - public void audioBroadcastCmd(Device device) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer broadcastXml = new StringBuffer(200); - String charset = device.getCharset(); - broadcastXml.append("\r\n"); - broadcastXml.append("\r\n"); - broadcastXml.append("Broadcast\r\n"); - broadcastXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - broadcastXml.append("" + sipConfig.getId() + "\r\n"); - broadcastXml.append("" + device.getDeviceId() + "\r\n"); - broadcastXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); - - } - - @Override - public void audioBroadcastCmd(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer broadcastXml = new StringBuffer(200); - String charset = device.getCharset(); - broadcastXml.append("\r\n"); - broadcastXml.append("\r\n"); - broadcastXml.append("Broadcast\r\n"); - broadcastXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - broadcastXml.append("" + sipConfig.getId() + "\r\n"); - broadcastXml.append("" + device.getDeviceId() + "\r\n"); - broadcastXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, broadcastXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - - } - - - /** - * 音视频录像控制 - * - * @param device 视频设备 - * @param channelId 预览通道 - * @param recordCmdStr 录像命令:Record / StopRecord - */ - @Override - public void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("DeviceControl\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - if (ObjectUtils.isEmpty(channelId)) { - cmdXml.append("" + device.getDeviceId() + "\r\n"); - } else { - cmdXml.append("" + channelId + "\r\n"); - } - cmdXml.append("" + recordCmdStr + "\r\n"); - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); - } - - /** - * 远程启动控制命令 - * - * @param device 视频设备 - */ - @Override - public void teleBootCmd(Device device) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("DeviceControl\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - cmdXml.append("" + device.getDeviceId() + "\r\n"); - cmdXml.append("Boot\r\n"); - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); - } - - /** - * 报警布防/撤防命令 - * - * @param device 视频设备 - * @param guardCmdStr "SetGuard"/"ResetGuard" - */ - @Override - public void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("DeviceControl\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - cmdXml.append("" + device.getDeviceId() + "\r\n"); - cmdXml.append("" + guardCmdStr + "\r\n"); - cmdXml.append("\r\n"); - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); - } - - /** - * 报警复位命令 - * - * @param device 视频设备 - */ - @Override - public void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("DeviceControl\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - cmdXml.append("" + device.getDeviceId() + "\r\n"); - cmdXml.append("ResetAlarm\r\n"); - if (!ObjectUtils.isEmpty(alarmMethod) || !ObjectUtils.isEmpty(alarmType)) { - cmdXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(alarmMethod)) { - cmdXml.append("" + alarmMethod + "\r\n"); - } - if (!ObjectUtils.isEmpty(alarmType)) { - cmdXml.append("" + alarmType + "\r\n"); - } - if (!ObjectUtils.isEmpty(alarmMethod) || !ObjectUtils.isEmpty(alarmType)) { - cmdXml.append("\r\n"); - } - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); - } - - /** - * 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧 - * - * @param device 视频设备 - * @param channelId 预览通道 - */ - @Override - public void iFrameCmd(Device device, String channelId) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("DeviceControl\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - if (ObjectUtils.isEmpty(channelId)) { - cmdXml.append("" + device.getDeviceId() + "\r\n"); - } else { - cmdXml.append("" + channelId + "\r\n"); - } - cmdXml.append("Send\r\n"); - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); - } - - /** - * 看守位控制命令 - * - * @param device 视频设备 - * @param channelId 通道id,非通道则是设备本身 - * @param enabled 看守位使能:1 = 开启,0 = 关闭 - * @param resetTime 自动归位时间间隔,开启看守位时使用,单位:秒(s) - * @param presetIndex 调用预置位编号,开启看守位时使用,取值范围0~255 - */ - @Override - public void homePositionCmd(Device device, String channelId, String enabled, String resetTime, String presetIndex, SipSubscribe.Event errorEvent,SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("DeviceControl\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - if (ObjectUtils.isEmpty(channelId)) { - cmdXml.append("" + device.getDeviceId() + "\r\n"); - } else { - cmdXml.append("" + channelId + "\r\n"); - } - cmdXml.append("\r\n"); - if (NumericUtil.isInteger(enabled) && (!enabled.equals("0"))) { - cmdXml.append("1\r\n"); - if (NumericUtil.isInteger(resetTime)) { - cmdXml.append("" + resetTime + "\r\n"); - } else { - cmdXml.append("0\r\n"); - } - if (NumericUtil.isInteger(presetIndex)) { - cmdXml.append("" + presetIndex + "\r\n"); - } else { - cmdXml.append("0\r\n"); - } - } else { - cmdXml.append("0\r\n"); - } - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent); - } - - /** - * 设备配置命令 - * - * @param device 视频设备 - */ - @Override - public void deviceConfigCmd(Device device) { - // TODO Auto-generated method stub - } - - /** - * 设备配置命令:basicParam - * - * @param device 视频设备 - * @param channelId 通道编码(可选) - * @param name 设备/通道名称(可选) - * @param expiration 注册过期时间(可选) - * @param heartBeatInterval 心跳间隔时间(可选) - * @param heartBeatCount 心跳超时次数(可选) - */ - @Override - public void deviceBasicConfigCmd(Device device, String channelId, String name, String expiration, - String heartBeatInterval, String heartBeatCount, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("DeviceConfig\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - if (ObjectUtils.isEmpty(channelId)) { - cmdXml.append("" + device.getDeviceId() + "\r\n"); - } else { - cmdXml.append("" + channelId + "\r\n"); - } - cmdXml.append("\r\n"); - if (!ObjectUtils.isEmpty(name)) { - cmdXml.append("" + name + "\r\n"); - } - if (NumericUtil.isInteger(expiration)) { - if (Integer.valueOf(expiration) > 0) { - cmdXml.append("" + expiration + "\r\n"); - } - } - if (NumericUtil.isInteger(heartBeatInterval)) { - if (Integer.valueOf(heartBeatInterval) > 0) { - cmdXml.append("" + heartBeatInterval + "\r\n"); - } - } - if (NumericUtil.isInteger(heartBeatCount)) { - if (Integer.valueOf(heartBeatCount) > 0) { - cmdXml.append("" + heartBeatCount + "\r\n"); - } - } - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - } - - /** - * 查询设备状态 - * - * @param device 视频设备 - */ - @Override - public void deviceStatusQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - String charset = device.getCharset(); - StringBuffer catalogXml = new StringBuffer(200); - catalogXml.append("\r\n"); - catalogXml.append("\r\n"); - catalogXml.append("DeviceStatus\r\n"); - catalogXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - catalogXml.append("" + device.getDeviceId() + "\r\n"); - catalogXml.append("\r\n"); - - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - } - - /** - * 查询设备信息 - * - * @param device 视频设备 - */ - @Override - public void deviceInfoQuery(Device device) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer catalogXml = new StringBuffer(200); - String charset = device.getCharset(); - catalogXml.append("\r\n"); - catalogXml.append("\r\n"); - catalogXml.append("DeviceInfo\r\n"); - catalogXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - catalogXml.append("" + device.getDeviceId() + "\r\n"); - catalogXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); - - } - - /** - * 查询目录列表 - * - * @param device 视频设备 - */ - @Override - public void catalogQuery(Device device, int sn, SipSubscribe.Event errorEvent) throws SipException, InvalidArgumentException, ParseException { - - StringBuffer catalogXml = new StringBuffer(200); - String charset = device.getCharset(); - catalogXml.append("\r\n"); - catalogXml.append("\r\n"); - catalogXml.append(" Catalog\r\n"); - catalogXml.append(" " + sn + "\r\n"); - catalogXml.append(" " + device.getDeviceId() + "\r\n"); - catalogXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - } - - /** - * 查询录像信息 - * - * @param device 视频设备 - * @param startTime 开始时间,格式要求:yyyy-MM-dd HH:mm:ss - * @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss - */ - @Override - public void recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - if (secrecy == null) { - secrecy = 0; - } - if (type == null) { - type = "all"; - } - - StringBuffer recordInfoXml = new StringBuffer(200); - String charset = device.getCharset(); - recordInfoXml.append("\r\n"); - recordInfoXml.append("\r\n"); - recordInfoXml.append("RecordInfo\r\n"); - recordInfoXml.append("" + sn + "\r\n"); - recordInfoXml.append("" + channelId + "\r\n"); - if (startTime != null) { - recordInfoXml.append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "\r\n"); - } - if (endTime != null) { - recordInfoXml.append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "\r\n"); - } - if (secrecy != null) { - recordInfoXml.append(" " + secrecy + " \r\n"); - } - if (type != null) { - // 大华NVR要求必须增加一个值为all的文本元素节点Type - recordInfoXml.append("" + type + "\r\n"); - } - recordInfoXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), - SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); - } - - /** - * 查询报警信息 - * - * @param device 视频设备 - * @param startPriority 报警起始级别(可选) - * @param endPriority 报警终止级别(可选) - * @param alarmMethod 报警方式条件(可选) - * @param alarmType 报警类型 - * @param startTime 报警发生起始时间(可选) - * @param endTime 报警发生终止时间(可选) - * @return true = 命令发送成功 - */ - @Override - public void alarmInfoQuery(Device device, String startPriority, String endPriority, String alarmMethod, String alarmType, - String startTime, String endTime, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("Alarm\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - cmdXml.append("" + device.getDeviceId() + "\r\n"); - if (!ObjectUtils.isEmpty(startPriority)) { - cmdXml.append("" + startPriority + "\r\n"); - } - if (!ObjectUtils.isEmpty(endPriority)) { - cmdXml.append("" + endPriority + "\r\n"); - } - if (!ObjectUtils.isEmpty(alarmMethod)) { - cmdXml.append("" + alarmMethod + "\r\n"); - } - if (!ObjectUtils.isEmpty(alarmType)) { - cmdXml.append("" + alarmType + "\r\n"); - } - if (!ObjectUtils.isEmpty(startTime)) { - cmdXml.append("" + startTime + "\r\n"); - } - if (!ObjectUtils.isEmpty(endTime)) { - cmdXml.append("" + endTime + "\r\n"); - } - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - } - - /** - * 查询设备配置 - * - * @param device 视频设备 - * @param channelId 通道编码(可选) - * @param configType 配置类型: - */ - @Override - public void deviceConfigQuery(Device device, String channelId, String configType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("ConfigDownload\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - if (ObjectUtils.isEmpty(channelId)) { - cmdXml.append("" + device.getDeviceId() + "\r\n"); - } else { - cmdXml.append("" + channelId + "\r\n"); - } - cmdXml.append("" + configType + "\r\n"); - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - } - - /** - * 查询设备预置位置 - * - * @param device 视频设备 - */ - @Override - public void presetQuery(Device device, String channelId, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("PresetQuery\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - if (ObjectUtils.isEmpty(channelId)) { - cmdXml.append("" + device.getDeviceId() + "\r\n"); - } else { - cmdXml.append("" + channelId + "\r\n"); - } - cmdXml.append("\r\n"); - - - Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - } - - /** - * 查询移动设备位置数据 - * - * @param device 视频设备 - */ - @Override - public void mobilePostitionQuery(Device device, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer mobilePostitionXml = new StringBuffer(200); - String charset = device.getCharset(); - mobilePostitionXml.append("\r\n"); - mobilePostitionXml.append("\r\n"); - mobilePostitionXml.append("MobilePosition\r\n"); - mobilePostitionXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - mobilePostitionXml.append("" + device.getDeviceId() + "\r\n"); - mobilePostitionXml.append("60\r\n"); - mobilePostitionXml.append("\r\n"); - - - - Request request = headerProvider.createMessageRequest(device, mobilePostitionXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent); - - } - - /** - * 订阅、取消订阅移动位置 - * - * @param device 视频设备 - * @return true = 命令发送成功 - */ - @Override - public SIPRequest mobilePositionSubscribe(Device device, SIPRequest requestOld, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer subscribePostitionXml = new StringBuffer(200); - String charset = device.getCharset(); - subscribePostitionXml.append("\r\n"); - subscribePostitionXml.append("\r\n"); - subscribePostitionXml.append("MobilePosition\r\n"); - subscribePostitionXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - subscribePostitionXml.append("" + device.getDeviceId() + "\r\n"); - if (device.getSubscribeCycleForMobilePosition() > 0) { - subscribePostitionXml.append("" + device.getMobilePositionSubmissionInterval() + "\r\n"); - } - subscribePostitionXml.append("\r\n"); - - CallIdHeader callIdHeader; - - if (requestOld != null) { - callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); - } else { - callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()); - } - SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), requestOld, device.getSubscribeCycleForMobilePosition(), "presence",callIdHeader); //Position;id=" + tm.substring(tm.length() - 4)); - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); - return request; - } - - /** - * 订阅、取消订阅报警信息 - * - * @param device 视频设备 - * @param expires 订阅过期时间(0 = 取消订阅) - * @param startPriority 报警起始级别(可选) - * @param endPriority 报警终止级别(可选) - * @param alarmMethod 报警方式条件(可选) - * @param alarmType 报警类型 - * @param startTime 报警发生起始时间(可选) - * @param endTime 报警发生终止时间(可选) - * @return true = 命令发送成功 - */ - @Override - public void alarmSubscribe(Device device, int expires, String startPriority, String endPriority, String alarmMethod, String startTime, String endTime) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("Alarm\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - cmdXml.append("" + device.getDeviceId() + "\r\n"); - if (!ObjectUtils.isEmpty(startPriority)) { - cmdXml.append("" + startPriority + "\r\n"); - } - if (!ObjectUtils.isEmpty(endPriority)) { - cmdXml.append("" + endPriority + "\r\n"); - } - if (!ObjectUtils.isEmpty(alarmMethod)) { - cmdXml.append("" + alarmMethod + "\r\n"); - } - if (!ObjectUtils.isEmpty(startTime)) { - cmdXml.append("" + startTime + "\r\n"); - } - if (!ObjectUtils.isEmpty(endTime)) { - cmdXml.append("" + endTime + "\r\n"); - } - cmdXml.append("\r\n"); - - - - Request request = headerProvider.createSubscribeRequest(device, cmdXml.toString(), null, expires, "presence",sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request); - - } - - @Override - public SIPRequest catalogSubscribe(Device device, SIPRequest requestOld, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer cmdXml = new StringBuffer(200); - String charset = device.getCharset(); - cmdXml.append("\r\n"); - cmdXml.append("\r\n"); - cmdXml.append("Catalog\r\n"); - cmdXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - cmdXml.append("" + device.getDeviceId() + "\r\n"); - cmdXml.append("\r\n"); - - CallIdHeader callIdHeader; - - if (requestOld != null) { - callIdHeader = SipFactory.getInstance().createHeaderFactory().createCallIdHeader(requestOld.getCallIdHeader().getCallId()); - } else { - callIdHeader = sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()); - } - - // 有效时间默认为60秒以上 - SIPRequest request = (SIPRequest) headerProvider.createSubscribeRequest(device, cmdXml.toString(), requestOld, device.getSubscribeCycleForCatalog(), "Catalog", - callIdHeader); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); - return request; - } - - @Override - public void dragZoomCmd(Device device, String channelId, String cmdString) throws InvalidArgumentException, SipException, ParseException { - - StringBuffer dragXml = new StringBuffer(200); - String charset = device.getCharset(); - dragXml.append("\r\n"); - dragXml.append("\r\n"); - dragXml.append("DeviceControl\r\n"); - dragXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - if (ObjectUtils.isEmpty(channelId)) { - dragXml.append("" + device.getDeviceId() + "\r\n"); - } else { - dragXml.append("" + channelId + "\r\n"); - } - dragXml.append(cmdString); - dragXml.append("\r\n"); - - Request request = headerProvider.createMessageRequest(device, dragXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - logger.debug("拉框信令: " + request.toString()); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); - } - - - - - - /** - * 回放暂停 - */ - @Override - public void playPauseCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException { - StringBuffer content = new StringBuffer(200); - content.append("PAUSE RTSP/1.0\r\n"); - content.append("CSeq: " + getInfoCseq() + "\r\n"); - content.append("PauseTime: now\r\n"); - - playbackControlCmd(device, streamInfo, content.toString(), null, null); - } - - - /** - * 回放恢复 - */ - @Override - public void playResumeCmd(Device device, StreamInfo streamInfo) throws InvalidArgumentException, ParseException, SipException { - StringBuffer content = new StringBuffer(200); - content.append("PLAY RTSP/1.0\r\n"); - content.append("CSeq: " + getInfoCseq() + "\r\n"); - content.append("Range: npt=now-\r\n"); - - playbackControlCmd(device, streamInfo, content.toString(), null, null); - } - - /** - * 回放拖动播放 - */ - @Override - public void playSeekCmd(Device device, StreamInfo streamInfo, long seekTime) throws InvalidArgumentException, ParseException, SipException { - StringBuffer content = new StringBuffer(200); - content.append("PLAY RTSP/1.0\r\n"); - content.append("CSeq: " + getInfoCseq() + "\r\n"); - content.append("Range: npt=" + Math.abs(seekTime) + "-\r\n"); - - playbackControlCmd(device, streamInfo, content.toString(), null, null); - } - - /** - * 回放倍速播放 - */ - @Override - public void playSpeedCmd(Device device, StreamInfo streamInfo, Double speed) throws InvalidArgumentException, ParseException, SipException { - StringBuffer content = new StringBuffer(200); - content.append("PLAY RTSP/1.0\r\n"); - content.append("CSeq: " + getInfoCseq() + "\r\n"); - content.append("Scale: " + String.format("%.6f", speed) + "\r\n"); - - playbackControlCmd(device, streamInfo, content.toString(), null, null); - } - - private int getInfoCseq() { - return (int) ((Math.random() * 9 + 1) * Math.pow(10, 8)); - } - - @Override - public void playbackControlCmd(Device device, StreamInfo streamInfo, String content, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException { - - SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(device.getDeviceId(), streamInfo.getChannelId(), null, streamInfo.getStream()); - if (ssrcTransaction == null) { - logger.info("[回放控制]未找到视频流信息,设备:{}, 流ID: {}", device.getDeviceId(), streamInfo.getStream()); - return; - } - - SIPRequest request = headerProvider.createInfoRequest(device, streamInfo.getChannelId(), content.toString(), ssrcTransaction.getSipTransactionInfo()); - if (request == null) { - logger.info("[回放控制]构建Request信息失败,设备:{}, 流ID: {}", device.getDeviceId(), streamInfo.getStream()); - return; - } - - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent, okEvent); - } - - @Override - public void sendAlarmMessage(Device device, DeviceAlarm deviceAlarm) throws InvalidArgumentException, SipException, ParseException { - if (device == null) { - return; - } - logger.info("[发送报警通知]设备: {}/{}->{},{}", device.getDeviceId(), deviceAlarm.getChannelId(), - deviceAlarm.getLongitude(), deviceAlarm.getLatitude()); - - String characterSet = device.getCharset(); - StringBuffer deviceStatusXml = new StringBuffer(600); - deviceStatusXml.append("\r\n"); - deviceStatusXml.append("\r\n"); - deviceStatusXml.append("Alarm\r\n"); - deviceStatusXml.append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n"); - deviceStatusXml.append("" + deviceAlarm.getChannelId() + "\r\n"); - deviceStatusXml.append("" + deviceAlarm.getAlarmPriority() + "\r\n"); - deviceStatusXml.append("" + deviceAlarm.getAlarmMethod() + "\r\n"); - deviceStatusXml.append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(deviceAlarm.getAlarmTime()) + "\r\n"); - deviceStatusXml.append("" + deviceAlarm.getAlarmDescription() + "\r\n"); - deviceStatusXml.append("" + deviceAlarm.getLongitude() + "\r\n"); - deviceStatusXml.append("" + deviceAlarm.getLatitude() + "\r\n"); - deviceStatusXml.append("\r\n"); - deviceStatusXml.append("" + deviceAlarm.getAlarmType() + "\r\n"); - deviceStatusXml.append("\r\n"); - deviceStatusXml.append("\r\n"); - - - Request request = headerProvider.createMessageRequest(device, deviceStatusXml.toString(), SipUtils.getNewViaTag(), SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport())); - sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()),request); - - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java deleted file mode 100644 index 49e82043..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ /dev/null @@ -1,831 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; - -import com.alibaba.fastjson2.JSON; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.gb28181.SipLayer; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.utils.GitUtil; -import gov.nist.javax.sip.message.MessageFactoryImpl; -import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.DependsOn; -import org.springframework.lang.Nullable; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import javax.sip.SipFactory; -import javax.sip.header.CallIdHeader; -import javax.sip.header.WWWAuthenticateHeader; -import javax.sip.message.Request; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.List; - -@Component -@DependsOn("sipLayer") -public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { - - private final Logger logger = LoggerFactory.getLogger(SIPCommanderFroPlatform.class); - - @Autowired - private SIPRequestHeaderPlarformProvider headerProviderPlatformProvider; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private SipSubscribe sipSubscribe; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private SipLayer sipLayer; - - @Autowired - private SIPSender sipSender; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private GitUtil gitUtil; - - @Override - public void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException { - register(parentPlatform, null, null, errorEvent, okEvent, true); - } - - @Override - public void register(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException { - - register(parentPlatform, sipTransactionInfo, null, errorEvent, okEvent, true); - } - - @Override - public void unregister(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException { - register(parentPlatform, sipTransactionInfo, null, errorEvent, okEvent, false); - } - - @Override - public void register(ParentPlatform parentPlatform, @Nullable SipTransactionInfo sipTransactionInfo, @Nullable WWWAuthenticateHeader www, - SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent, boolean isRegister) throws SipException, InvalidArgumentException, ParseException { - Request request; - - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); - String fromTag = SipUtils.getNewFromTag(); - String toTag = null; - if (sipTransactionInfo != null ) { - if (sipTransactionInfo.getCallId() != null) { - callIdHeader.setCallId(sipTransactionInfo.getCallId()); - } - if (sipTransactionInfo.getFromTag() != null) { - fromTag = sipTransactionInfo.getFromTag(); - } - if (sipTransactionInfo.getToTag() != null) { - toTag = sipTransactionInfo.getToTag(); - } - } - - if (www == null ) { - request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, - redisCatchStorage.getCSEQ(), fromTag, - toTag, callIdHeader, isRegister? parentPlatform.getExpires() : 0); - // 将 callid 写入缓存, 等注册成功可以更新状态 - String callIdFromHeader = callIdHeader.getCallId(); - redisCatchStorage.updatePlatformRegisterInfo(callIdFromHeader, PlatformRegisterInfo.getInstance(parentPlatform.getServerGBId(), isRegister)); - - sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{ - if (event != null) { - logger.info("向上级平台 [ {} ] 注册发生错误: {} ", - parentPlatform.getServerGBId(), - event.msg); - } - redisCatchStorage.delPlatformRegisterInfo(callIdFromHeader); - if (errorEvent != null ) { - errorEvent.response(event); - } - }); - - }else { - request = headerProviderPlatformProvider.createRegisterRequest(parentPlatform, fromTag, toTag, www, callIdHeader, isRegister? parentPlatform.getExpires() : 0); - } - - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, okEvent); - } - - @Override - public String keepalive(ParentPlatform parentPlatform,SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException { - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer keepaliveXml = new StringBuffer(200); - keepaliveXml.append("\r\n") - .append("\r\n") - .append("Keepalive\r\n") - .append("" + (int)((Math.random()*9+1)*100000) + "\r\n") - .append("" + parentPlatform.getDeviceGBId() + "\r\n") - .append("OK\r\n") - .append("\r\n"); - - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); - - Request request = headerProviderPlatformProvider.createMessageRequest( - parentPlatform, - keepaliveXml.toString(), - SipUtils.getNewFromTag(), - SipUtils.getNewViaTag(), - callIdHeader); - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, errorEvent, okEvent); - return callIdHeader.getCallId(); - } - - /** - * 向上级回复通道信息 - * @param channel 通道信息 - * @param parentPlatform 平台信息 - */ - @Override - public void catalogQuery(DeviceChannel channel, ParentPlatform parentPlatform, String sn, String fromTag, int size) throws SipException, InvalidArgumentException, ParseException { - - if ( parentPlatform ==null) { - return ; - } - List channels = new ArrayList<>(); - if (channel != null) { - channels.add(channel); - } - String catalogXml = getCatalogXml(channels, sn, parentPlatform, size); - - // callid - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); - - Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); - - } - - @Override - public void catalogQuery(List channels, ParentPlatform parentPlatform, String sn, String fromTag) throws InvalidArgumentException, ParseException, SipException { - if ( parentPlatform ==null) { - return ; - } - sendCatalogResponse(channels, parentPlatform, sn, fromTag, 0, true); - } - private String getCatalogXml(List channels, String sn, ParentPlatform parentPlatform, int size) { - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer catalogXml = new StringBuffer(600); - catalogXml.append("\r\n") - .append("\r\n") - .append("Catalog\r\n") - .append("" +sn + "\r\n") - .append("" + parentPlatform.getDeviceGBId() + "\r\n") - .append("" + size + "\r\n") - .append("\r\n"); - if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } - catalogXml.append("\r\n"); - // 行政区划分组只需要这两项就可以 - catalogXml.append("" + channel.getChannelId() + "\r\n"); - catalogXml.append("" + channel.getName() + "\r\n"); - if (channel.getChannelId().length() <= 8) { - catalogXml.append("\r\n"); - continue; - }else { - if (channel.getChannelId().length() != 20) { - catalogXml.append("\r\n"); - logger.warn("[编号长度异常] {} 长度错误,请使用20位长度的国标编号,当前长度:{}", channel.getChannelId(), channel.getChannelId().length()); - catalogXml.append("\r\n"); - continue; - } - switch (Integer.parseInt(channel.getChannelId().substring(10, 13))){ - case 200: -// catalogXml.append("三永华通\r\n"); -// GitUtil gitUtil = SpringBeanFactory.getBean("gitUtil"); -// String model = (gitUtil == null || gitUtil.getBuildVersion() == null)?"1.0": gitUtil.getBuildVersion(); -// catalogXml.append("" + model + "\r\n"); -// catalogXml.append("三永华通\r\n"); - if (channel.getCivilCode() != null) { - catalogXml.append(""+channel.getCivilCode()+"\r\n"); - }else { - catalogXml.append("\r\n"); - } - - catalogXml.append("1\r\n"); - catalogXml.append("0\r\n"); - break; - case 215: - if (!ObjectUtils.isEmpty(channel.getParentId())) { - catalogXml.append("" + channel.getParentId() + "\r\n"); - } - - break; - case 216: - if (!ObjectUtils.isEmpty(channel.getParentId())) { - catalogXml.append("" + channel.getParentId() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getBusinessGroupId())) { - catalogXml.append("" + channel.getBusinessGroupId() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - break; - default: - // 通道项 - if (channel.getManufacture() != null) { - catalogXml.append("" + channel.getManufacture() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (channel.getSecrecy() != null) { - catalogXml.append("" + channel.getSecrecy() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - catalogXml.append("" + channel.getRegisterWay() + "\r\n"); - if (channel.getModel() != null) { - catalogXml.append("" + channel.getModel() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (channel.getOwner() != null) { - catalogXml.append("" + channel.getOwner()+ "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (channel.getCivilCode() != null) { - catalogXml.append("" + channel.getCivilCode() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (channel.getAddress() == null) { - catalogXml.append("
\r\n"); - }else { - catalogXml.append("
" + channel.getAddress() + "
\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getParentId())) { - catalogXml.append("" + channel.getParentId() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getBlock())) { - catalogXml.append("" + channel.getBlock() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getSafetyWay())) { - catalogXml.append("" + channel.getSafetyWay() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getCertNum())) { - catalogXml.append("" + channel.getCertNum() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getCertifiable())) { - catalogXml.append("" + channel.getCertifiable() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getErrCode())) { - catalogXml.append("" + channel.getErrCode() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getEndTime())) { - catalogXml.append("" + channel.getEndTime() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getSecrecy())) { - catalogXml.append("" + channel.getSecrecy() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getIpAddress())) { - catalogXml.append("" + channel.getIpAddress() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - catalogXml.append("" + channel.getPort() + "\r\n"); - if (!ObjectUtils.isEmpty(channel.getPassword())) { - catalogXml.append("" + channel.getPassword() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - if (!ObjectUtils.isEmpty(channel.getPtzType())) { - catalogXml.append("" + channel.getPtzType() + "\r\n"); - }else { - catalogXml.append("\r\n"); - } - catalogXml.append("" + (channel.isStatus() ?"ON":"OFF") + "\r\n"); - - catalogXml.append("" + - (channel.getLongitudeWgs84() != 0? channel.getLongitudeWgs84():channel.getLongitude()) - + "\r\n"); - catalogXml.append("" + - (channel.getLatitudeWgs84() != 0? channel.getLatitudeWgs84():channel.getLatitude()) - + "\r\n"); - break; - - } - catalogXml.append("\r\n"); - } - } - } - - catalogXml.append("
\r\n"); - catalogXml.append("
\r\n"); - return catalogXml.toString(); - } - - private void sendCatalogResponse(List channels, ParentPlatform parentPlatform, String sn, String fromTag, int index, boolean sendAfterResponse) throws SipException, InvalidArgumentException, ParseException { - if (index >= channels.size()) { - return; - } - List deviceChannels; - if (index + parentPlatform.getCatalogGroup() < channels.size()) { - deviceChannels = channels.subList(index, index + parentPlatform.getCatalogGroup()); - }else { - deviceChannels = channels.subList(index, channels.size()); - } - String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size()); - // callid - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); - - SIPRequest request = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader); - - String timeoutTaskKey = "catalog_task_" + parentPlatform.getServerGBId() + sn; - - String callId = request.getCallIdHeader().getCallId(); - - logger.info("[命令发送] 国标级联{} 目录查询回复: 共{}条,已发送{}条", parentPlatform.getServerGBId(), - channels.size(), Math.min(index + parentPlatform.getCatalogGroup(), channels.size())); - logger.debug(catalogXml); - if (sendAfterResponse) { - // 默认按照收到200回复后发送下一条, 如果超时收不到回复,就以30毫秒的间隔直接发送。 - dynamicTask.startDelay(timeoutTaskKey, ()->{ - sipSubscribe.removeOkSubscribe(callId); - int indexNext = index + parentPlatform.getCatalogGroup(); - try { - sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext, false); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage()); - } - }, 3000); - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, eventResult -> { - logger.error("[目录推送失败] 国标级联 platform : {}, code: {}, msg: {}, 停止发送", parentPlatform.getServerGBId(), eventResult.statusCode, eventResult.msg); - dynamicTask.stop(timeoutTaskKey); - }, eventResult -> { - dynamicTask.stop(timeoutTaskKey); - int indexNext = index + parentPlatform.getCatalogGroup(); - try { - sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext, true); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage()); - } - }); - }else { - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, eventResult -> { - logger.error("[目录推送失败] 国标级联 platform : {}, code: {}, msg: {}, 停止发送", parentPlatform.getServerGBId(), eventResult.statusCode, eventResult.msg); - dynamicTask.stop(timeoutTaskKey); - }, null); - dynamicTask.startDelay(timeoutTaskKey, ()->{ - int indexNext = index + parentPlatform.getCatalogGroup(); - try { - sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext, false); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage()); - } - }, 30); - } - } - - /** - * 向上级回复DeviceInfo查询信息 - * @param parentPlatform 平台信息 - * @param sn - * @param fromTag - * @return - */ - @Override - public void deviceInfoResponse(ParentPlatform parentPlatform,Device device, String sn, String fromTag) throws SipException, InvalidArgumentException, ParseException { - if (parentPlatform == null) { - return; - } - String deviceId = device == null ? parentPlatform.getDeviceGBId() : device.getDeviceId(); - String deviceName = device == null ? parentPlatform.getName() : device.getName(); - String manufacturer = device == null ? "WVP-28181-PRO" : device.getManufacturer(); - String model = device == null ? "platform" : device.getModel(); - String firmware = device == null ? gitUtil.getBuildVersion() : device.getFirmware(); - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer deviceInfoXml = new StringBuffer(600); - deviceInfoXml.append("\r\n"); - deviceInfoXml.append("\r\n"); - deviceInfoXml.append("DeviceInfo\r\n"); - deviceInfoXml.append("" +sn + "\r\n"); - deviceInfoXml.append("" + deviceId + "\r\n"); - deviceInfoXml.append("" + deviceName + "\r\n"); - deviceInfoXml.append("" + manufacturer + "\r\n"); - deviceInfoXml.append("" + model + "\r\n"); - deviceInfoXml.append("" + firmware + "\r\n"); - deviceInfoXml.append("OK\r\n"); - deviceInfoXml.append("\r\n"); - - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); - - Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceInfoXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); - } - - /** - * 向上级回复DeviceStatus查询信息 - * @param parentPlatform 平台信息 - * @param sn - * @param fromTag - * @return - */ - @Override - public void deviceStatusResponse(ParentPlatform parentPlatform,String channelId, String sn, String fromTag,boolean status) throws SipException, InvalidArgumentException, ParseException { - if (parentPlatform == null) { - return ; - } - String statusStr = (status)?"ONLINE":"OFFLINE"; - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer deviceStatusXml = new StringBuffer(600); - deviceStatusXml.append("\r\n") - .append("\r\n") - .append("DeviceStatus\r\n") - .append("" +sn + "\r\n") - .append("" + channelId + "\r\n") - .append("OK\r\n") - .append(""+statusStr+"\r\n") - .append("OK\r\n") - .append("\r\n"); - - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); - - Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); - } - - @Override - public void sendNotifyMobilePosition(ParentPlatform parentPlatform, GPSMsgInfo gpsMsgInfo, SubscribeInfo subscribeInfo) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { - if (parentPlatform == null) { - return; - } - if (logger.isDebugEnabled()) { - logger.debug("[发送 移动位置订阅] {}/{}->{},{}", parentPlatform.getServerGBId(), gpsMsgInfo.getId(), gpsMsgInfo.getLng(), gpsMsgInfo.getLat()); - } - - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer deviceStatusXml = new StringBuffer(600); - deviceStatusXml.append("\r\n") - .append("\r\n") - .append("MobilePosition\r\n") - .append("" + (int)((Math.random()*9+1)*100000) + "\r\n") - .append("" + gpsMsgInfo.getId() + "\r\n") - .append("\r\n") - .append("" + gpsMsgInfo.getLng() + "\r\n") - .append("" + gpsMsgInfo.getLat() + "\r\n") - .append("" + gpsMsgInfo.getSpeed() + "\r\n") - .append("" + gpsMsgInfo.getDirection() + "\r\n") - .append("" + gpsMsgInfo.getAltitude() + "\r\n") - .append("\r\n"); - - sendNotify(parentPlatform, deviceStatusXml.toString(), subscribeInfo, eventResult -> { - logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); - }, null); - - } - - @Override - public void sendAlarmMessage(ParentPlatform parentPlatform, DeviceAlarm deviceAlarm) throws SipException, InvalidArgumentException, ParseException { - if (parentPlatform == null) { - return; - } - logger.info("[发送报警通知]平台: {}/{}->{},{}: {}", parentPlatform.getServerGBId(), deviceAlarm.getChannelId(), - deviceAlarm.getLongitude(), deviceAlarm.getLatitude(), JSON.toJSONString(deviceAlarm)); - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer deviceStatusXml = new StringBuffer(600); - deviceStatusXml.append("\r\n") - .append("\r\n") - .append("Alarm\r\n") - .append("" + (int)((Math.random()*9+1)*100000) + "\r\n") - .append("" + deviceAlarm.getChannelId() + "\r\n") - .append("" + deviceAlarm.getAlarmPriority() + "\r\n") - .append("" + deviceAlarm.getAlarmMethod() + "\r\n") - .append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(deviceAlarm.getAlarmTime()) + "\r\n") - .append("" + deviceAlarm.getAlarmDescription() + "\r\n") - .append("" + deviceAlarm.getLongitude() + "\r\n") - .append("" + deviceAlarm.getLatitude() + "\r\n") - .append("\r\n") - .append("" + deviceAlarm.getAlarmType() + "\r\n") - .append("\r\n") - .append("\r\n"); - - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); - - Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, deviceStatusXml.toString(), SipUtils.getNewFromTag(), SipUtils.getNewViaTag(), callIdHeader); - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); - - } - - @Override - public void sendNotifyForCatalogAddOrUpdate(String type, ParentPlatform parentPlatform, List deviceChannels, SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { - if (parentPlatform == null || deviceChannels == null || deviceChannels.size() == 0 || subscribeInfo == null) { - return; - } - if (index == null) { - index = 0; - } - if (index >= deviceChannels.size()) { - return; - } - List channels; - if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) { - channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup()); - }else { - channels = deviceChannels.subList(index, deviceChannels.size()); - } - Integer finalIndex = index; - String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channels, - deviceChannels.size(), type, subscribeInfo); - sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { - logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); - }, (eventResult -> { - try { - sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo, - finalIndex + parentPlatform.getCatalogGroup()); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | - IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 NOTIFY通知: {}", e.getMessage()); - } - })); - } - - private void sendNotify(ParentPlatform parentPlatform, String catalogXmlContent, - SubscribeInfo subscribeInfo, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent ) - throws SipException, ParseException, InvalidArgumentException { - MessageFactoryImpl messageFactory = (MessageFactoryImpl) SipFactory.getInstance().createMessageFactory(); - String characterSet = parentPlatform.getCharacterSet(); - // 设置编码, 防止中文乱码 - messageFactory.setDefaultContentEncodingCharset(characterSet); - - SIPRequest notifyRequest = headerProviderPlatformProvider.createNotifyRequest(parentPlatform, catalogXmlContent, subscribeInfo); - - sipSender.transmitRequest(parentPlatform.getDeviceIp(), notifyRequest); - } - - private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List channels, int sumNum, String type, SubscribeInfo subscribeInfo) { - StringBuffer catalogXml = new StringBuffer(600); - - String characterSet = parentPlatform.getCharacterSet(); - catalogXml.append("\r\n") - .append("\r\n") - .append("Catalog\r\n") - .append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n") - .append("" + parentPlatform.getDeviceGBId() + "\r\n") - .append("1\r\n") - .append("\r\n"); - if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } - catalogXml.append("\r\n"); - // 行政区划分组只需要这两项就可以 - catalogXml.append("" + channel.getChannelId() + "\r\n"); - catalogXml.append("" + channel.getName() + "\r\n"); - if (channel.getParentId() != null) { - // 业务分组加上这一项即可,提高兼容性, - catalogXml.append("" + channel.getParentId() + "\r\n"); - } - if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { - // 虚拟组织增加BusinessGroupID字段 - catalogXml.append("" + channel.getParentId() + "\r\n"); - } - catalogXml.append("" + channel.getParental() + "\r\n"); - if (channel.getParental() == 0) { - // 通道项 - catalogXml.append("" + channel.getManufacture() + "\r\n") - .append("" + channel.getSecrecy() + "\r\n") - .append("" + channel.getRegisterWay() + "\r\n") - .append("" + (channel.isStatus() ? "ON" : "OFF") + "\r\n"); - - if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性 - catalogXml.append("" + channel.getModel() + "\r\n") - .append(" " + channel.getOwner()+ "\r\n") - .append("" + channel.getCivilCode() + "\r\n") - .append("
" + channel.getAddress() + "
\r\n"); - } - if (!"presence".equals(subscribeInfo.getEventType())) { - catalogXml.append("" + type + "\r\n"); - } - - } - catalogXml.append("
\r\n"); - } - } - catalogXml.append("
\r\n") - .append("
\r\n"); - return catalogXml.toString(); - } - - @Override - public void sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List deviceChannels, - SubscribeInfo subscribeInfo, Integer index) throws InvalidArgumentException, ParseException, NoSuchFieldException, SipException, IllegalAccessException { - if (parentPlatform == null - || deviceChannels == null - || deviceChannels.size() == 0 - || subscribeInfo == null) { - logger.warn("[缺少必要参数]"); - return; - } - - if (index == null) { - index = 0; - } - if (index >= deviceChannels.size()) { - return; - } - List channels; - if (index + parentPlatform.getCatalogGroup() < deviceChannels.size()) { - channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup()); - }else { - channels = deviceChannels.subList(index, deviceChannels.size()); - } - Integer finalIndex = index; - String catalogXmlContent = getCatalogXmlContentForCatalogOther(parentPlatform, channels, type); - sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { - logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); - }, eventResult -> { - try { - sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo, - finalIndex + parentPlatform.getCatalogGroup()); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | - IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 NOTIFY通知: {}", e.getMessage()); - } - }); - } - - private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, List channels, String type) { - - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer catalogXml = new StringBuffer(600); - catalogXml.append("\r\n") - .append("\r\n") - .append("Catalog\r\n") - .append("" + (int) ((Math.random() * 9 + 1) * 100000) + "\r\n") - .append("" + parentPlatform.getDeviceGBId() + "\r\n") - .append("1\r\n") - .append("\r\n"); - if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (parentPlatform.getServerGBId().equals(channel.getParentId())) { - channel.setParentId(parentPlatform.getDeviceGBId()); - } - catalogXml.append("\r\n") - .append("" + channel.getChannelId() + "\r\n") - .append("" + type + "\r\n") - .append("\r\n"); - } - } - catalogXml.append("\r\n") - .append("\r\n"); - return catalogXml.toString(); - } - @Override - public void recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) throws SipException, InvalidArgumentException, ParseException { - if ( parentPlatform ==null) { - return ; - } - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer recordXml = new StringBuffer(600); - recordXml.append("\r\n") - .append("\r\n") - .append("RecordInfo\r\n") - .append("" +recordInfo.getSn() + "\r\n") - .append("" + recordInfo.getChannelId() + "\r\n") - .append("" + recordInfo.getSumNum() + "\r\n"); - if (recordInfo.getRecordList() == null ) { - recordXml.append("\r\n"); - }else { - recordXml.append("\r\n"); - if (recordInfo.getRecordList().size() > 0) { - for (RecordItem recordItem : recordInfo.getRecordList()) { - recordXml.append("\r\n"); - if (deviceChannel != null) { - recordXml.append("" + recordItem.getDeviceId() + "\r\n") - .append("" + recordItem.getName() + "\r\n") - .append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getStartTime()) + "\r\n") - .append("" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "\r\n") - .append("" + recordItem.getSecrecy() + "\r\n") - .append("" + recordItem.getType() + "\r\n"); - if (!ObjectUtils.isEmpty(recordItem.getFileSize())) { - recordXml.append("" + recordItem.getFileSize() + "\r\n"); - } - if (!ObjectUtils.isEmpty(recordItem.getFilePath())) { - recordXml.append("" + recordItem.getFilePath() + "\r\n"); - } - } - recordXml.append("\r\n"); - } - } - } - - recordXml.append("\r\n") - .append("\r\n"); - - // callid - CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport()); - - Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, SipUtils.getNewViaTag(), callIdHeader); - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request); - - } - - @Override - public void sendMediaStatusNotify(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { - if (sendRtpItem == null || parentPlatform == null) { - return; - } - - - String characterSet = parentPlatform.getCharacterSet(); - StringBuffer mediaStatusXml = new StringBuffer(200); - mediaStatusXml.append("\r\n") - .append("\r\n") - .append("MediaStatus\r\n") - .append("" + (int)((Math.random()*9+1)*100000) + "\r\n") - .append("" + sendRtpItem.getChannelId() + "\r\n") - .append("121\r\n") - .append("\r\n"); - - SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, mediaStatusXml.toString(), - sendRtpItem); - - sipSender.transmitRequest(parentPlatform.getDeviceIp(),messageRequest); - - } - - @Override - public void streamByeCmd(ParentPlatform platform, String callId) throws SipException, InvalidArgumentException, ParseException { - if (platform == null) { - return; - } - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(platform.getServerGBId(), null, null, callId); - if (sendRtpItem != null) { - streamByeCmd(platform, sendRtpItem); - } - } - - @Override - public void streamByeCmd(ParentPlatform parentPlatform, SendRtpItem sendRtpItem) throws SipException, InvalidArgumentException, ParseException { - if (sendRtpItem == null ) { - logger.info("[向上级发送BYE], sendRtpItem 为NULL"); - return; - } - if (parentPlatform == null) { - logger.info("[向上级发送BYE], platform 为NULL"); - return; - } - logger.info("[向上级发送BYE], {}/{}", parentPlatform.getServerGBId(), sendRtpItem.getChannelId()); - String mediaServerId = sendRtpItem.getMediaServerId(); - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); - if (mediaServerItem != null) { - mediaServerService.releaseSsrc(mediaServerItem.getId(), sendRtpItem.getSsrc()); - zlmServerFactory.closeRtpServer(mediaServerItem, sendRtpItem.getStreamId()); - } - SIPRequest byeRequest = headerProviderPlatformProvider.createByeRequest(parentPlatform, sendRtpItem); - if (byeRequest == null) { - logger.warn("[向上级发送bye]:无法创建 byeRequest"); - } - sipSender.transmitRequest(parentPlatform.getDeviceIp(),byeRequest); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/ISIPRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/ISIPRequestProcessor.java deleted file mode 100644 index 8e79941f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/ISIPRequestProcessor.java +++ /dev/null @@ -1,14 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request; - -import javax.sip.RequestEvent; - -/** - * @description: 对SIP事件进行处理,包括request, response, timeout, ioException, transactionTerminated,dialogTerminated - * @author: panlinlin - * @date: 2021年11月5日 15:47 - */ -public interface ISIPRequestProcessor { - - void process(RequestEvent event); - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java deleted file mode 100644 index 0d07a9b3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ /dev/null @@ -1,223 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request; - -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.google.common.primitives.Bytes; -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; -import org.apache.commons.lang3.ArrayUtils; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.dom4j.io.SAXReader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; - -import javax.sip.*; -import javax.sip.address.Address; -import javax.sip.address.SipURI; -import javax.sip.header.ContentTypeHeader; -import javax.sip.header.ExpiresHeader; -import javax.sip.header.HeaderFactory; -import javax.sip.message.MessageFactory; -import javax.sip.message.Request; -import javax.sip.message.Response; -import java.io.ByteArrayInputStream; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -/** - * @description:处理接收IPCamera发来的SIP协议请求消息 - * @author: songww - * @date: 2020年5月3日 下午4:42:22 - */ -public abstract class SIPRequestProcessorParent { - - private final static Logger logger = LoggerFactory.getLogger(SIPRequestProcessorParent.class); - - @Autowired - private SIPSender sipSender; - - public HeaderFactory getHeaderFactory() { - try { - return SipFactory.getInstance().createHeaderFactory(); - } catch (PeerUnavailableException e) { - logger.error("未处理的异常 ", e); - } - return null; - } - - public MessageFactory getMessageFactory() { - try { - return SipFactory.getInstance().createMessageFactory(); - } catch (PeerUnavailableException e) { - logger.error("未处理的异常 ", e); - } - return null; - } - - class ResponseAckExtraParam{ - String content; - ContentTypeHeader contentTypeHeader; - SipURI sipURI; - int expires = -1; - } - - /*** - * 回复状态码 - * 100 trying - * 200 OK - * 400 - * 404 - */ - public SIPResponse responseAck(SIPRequest sipRequest, int statusCode) throws SipException, InvalidArgumentException, ParseException { - return responseAck(sipRequest, statusCode, null); - } - - public SIPResponse responseAck(SIPRequest sipRequest, int statusCode, String msg) throws SipException, InvalidArgumentException, ParseException { - return responseAck(sipRequest, statusCode, msg, null); - } - - public SIPResponse responseAck(SIPRequest sipRequest, int statusCode, String msg, ResponseAckExtraParam responseAckExtraParam) throws SipException, InvalidArgumentException, ParseException { - if (sipRequest.getToHeader().getTag() == null) { - sipRequest.getToHeader().setTag(SipUtils.getNewTag()); - } - SIPResponse response = (SIPResponse)getMessageFactory().createResponse(statusCode, sipRequest); - response.setStatusCode(statusCode); - if (msg != null) { - response.setReasonPhrase(msg); - } - - if (responseAckExtraParam != null) { - if (responseAckExtraParam.sipURI != null && sipRequest.getMethod().equals(Request.INVITE)) { - logger.debug("responseSdpAck SipURI: {}:{}", responseAckExtraParam.sipURI.getHost(), responseAckExtraParam.sipURI.getPort()); - Address concatAddress = SipFactory.getInstance().createAddressFactory().createAddress( - SipFactory.getInstance().createAddressFactory().createSipURI(responseAckExtraParam.sipURI.getUser(), responseAckExtraParam.sipURI.getHost()+":"+responseAckExtraParam.sipURI.getPort() - )); - response.addHeader(SipFactory.getInstance().createHeaderFactory().createContactHeader(concatAddress)); - } - if (responseAckExtraParam.contentTypeHeader != null) { - response.setContent(responseAckExtraParam.content, responseAckExtraParam.contentTypeHeader); - } - - if (sipRequest.getMethod().equals(Request.SUBSCRIBE)) { - if (responseAckExtraParam.expires == -1) { - logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); - }else { - ExpiresHeader expiresHeader = SipFactory.getInstance().createHeaderFactory().createExpiresHeader(responseAckExtraParam.expires); - response.addHeader(expiresHeader); - } - } - }else { - if (sipRequest.getMethod().equals(Request.SUBSCRIBE)) { - logger.error("[参数不全] 2xx的SUBSCRIBE回复,必须设置Expires header"); - } - } - - // 发送response - sipSender.transmitRequest(sipRequest.getLocalAddress().getHostAddress(), response); - - return response; - } - - /** - * 回复带sdp的200 - */ - public SIPResponse responseSdpAck(SIPRequest request, String sdp, ParentPlatform platform) throws SipException, InvalidArgumentException, ParseException { - - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); - - // 兼容国标中的使用编码@域名作为RequestURI的情况 - SipURI sipURI = (SipURI)request.getRequestURI(); - if (sipURI.getPort() == -1) { - sipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIp()+":"+platform.getServerPort()); - } - ResponseAckExtraParam responseAckExtraParam = new ResponseAckExtraParam(); - responseAckExtraParam.contentTypeHeader = contentTypeHeader; - responseAckExtraParam.content = sdp; - responseAckExtraParam.sipURI = sipURI; - - return responseAck(request, Response.OK, null, responseAckExtraParam); - } - - /** - * 回复带xml的200 - */ - public SIPResponse responseXmlAck(SIPRequest request, String xml, ParentPlatform platform, Integer expires) throws SipException, InvalidArgumentException, ParseException { - ContentTypeHeader contentTypeHeader = SipFactory.getInstance().createHeaderFactory().createContentTypeHeader("Application", "MANSCDP+xml"); - - SipURI sipURI = (SipURI)request.getRequestURI(); - if (sipURI.getPort() == -1) { - sipURI = SipFactory.getInstance().createAddressFactory().createSipURI(platform.getServerGBId(), platform.getServerIp()+":"+platform.getServerPort()); - } - ResponseAckExtraParam responseAckExtraParam = new ResponseAckExtraParam(); - responseAckExtraParam.contentTypeHeader = contentTypeHeader; - responseAckExtraParam.content = xml; - responseAckExtraParam.sipURI = sipURI; - responseAckExtraParam.expires = expires; - return responseAck(request, Response.OK, null, responseAckExtraParam); - } - - public Element getRootElement(RequestEvent evt) throws DocumentException { - return getRootElement(evt, "gb2312"); - } - public Element getRootElement(RequestEvent evt, String charset) throws DocumentException { - if (charset == null) { - charset = "gb2312"; - } - Request request = evt.getRequest(); - SAXReader reader = new SAXReader(); - reader.setEncoding(charset); - // 对海康出现的未转义字符做处理。 - String[] destStrArray = new String[]{"<",">","&","'","""}; - char despChar = '&'; // 或许可扩展兼容其他字符 - byte destBye = (byte) despChar; - List result = new ArrayList<>(); - byte[] rawContent = request.getRawContent(); - if (rawContent == null) { - return null; - } - for (int i = 0; i < rawContent.length; i++) { - if (rawContent[i] == destBye) { - boolean resul = false; - for (String destStr : destStrArray) { - if (i + destStr.length() <= rawContent.length) { - byte[] bytes = Arrays.copyOfRange(rawContent, i, i + destStr.length()); - resul = resul || (Arrays.equals(bytes,destStr.getBytes())); - } - } - if (resul) { - result.add(rawContent[i]); - } - }else { - result.add(rawContent[i]); - } - } - byte[] bytesResult = Bytes.toArray(result); - - Document xml; - try { - xml = reader.read(new ByteArrayInputStream(bytesResult)); - }catch (DocumentException e) { - logger.warn("[xml解析异常]: 原文如下: \r\n{}", new String(bytesResult)); - logger.warn("[xml解析异常]: 原文如下: 尝试兼容性处理"); - String[] xmlLineArray = new String(bytesResult).split("\\r?\\n"); - - // 兼容海康的address字段带有<破换xml结构导致无法解析xml的问题 - StringBuilder stringBuilder = new StringBuilder(); - for (String s : xmlLineArray) { - if (s.startsWith("{}", platformGbId); - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformGbId); - // 取消设置的超时任务 - dynamicTask.stop(callIdHeader.getCallId()); - String channelId = ((SipURI) ((HeaderAddress) evt.getRequest().getHeader(ToHeader.NAME)).getAddress().getURI()).getUser(); - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(platformGbId, channelId, null, callIdHeader.getCallId()); - if (sendRtpItem == null) { - logger.warn("[收到ACK]:未找到通道({})的推流信息", channelId); - return; - } - // tcp主动时,此时是级联下级平台,在回复200ok时,本地已经请求zlm开启监听,跳过下面步骤 - if (sendRtpItem.isTcpActive()) { - logger.info("收到ACK,rtp/{} TCP主动方式后续处理", sendRtpItem.getStreamId()); - return; - } - String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; - MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - logger.info("收到ACK,rtp/{}开始向上级推流, 目标={}:{},SSRC={}, 协议:{}", - sendRtpItem.getStreamId(), - sendRtpItem.getIp(), - sendRtpItem.getPort(), - sendRtpItem.getSsrc(), - sendRtpItem.isTcp()?(sendRtpItem.isTcpActive()?"TCP主动":"TCP被动"):"UDP" - ); - Map param = new HashMap<>(12); - param.put("vhost","__defaultVhost__"); - param.put("app",sendRtpItem.getApp()); - param.put("stream",sendRtpItem.getStreamId()); - param.put("ssrc", sendRtpItem.getSsrc()); - param.put("dst_url",sendRtpItem.getIp()); - param.put("dst_port", sendRtpItem.getPort()); - param.put("is_udp", is_Udp); - param.put("src_port", sendRtpItem.getLocalPort()); - param.put("pt", sendRtpItem.getPt()); - param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0"); - param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0"); - if (!sendRtpItem.isTcp()) { - // 开启rtcp保活 - param.put("udp_rtcp_timeout", sendRtpItem.isRtcp()? "1":"0"); - } - if (mediaInfo == null) { - RequestPushStreamMsg requestPushStreamMsg = RequestPushStreamMsg.getInstance( - sendRtpItem.getMediaServerId(), sendRtpItem.getApp(), sendRtpItem.getStreamId(), - sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc(), sendRtpItem.isTcp(), - sendRtpItem.getLocalPort(), sendRtpItem.getPt(), sendRtpItem.isUsePs(), sendRtpItem.isOnlyAudio()); - redisGbPlayMsgListener.sendMsgForStartSendRtpStream(sendRtpItem.getServerId(), requestPushStreamMsg, jsonObject->{ - startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, jsonObject, param, callIdHeader); - }); - }else { - JSONObject startSendRtpStreamResult = zlmServerFactory.startSendRtpStream(mediaInfo, param); - if (startSendRtpStreamResult != null) { - startSendRtpStreamHand(evt, sendRtpItem, parentPlatform, startSendRtpStreamResult, param, callIdHeader); - } - } - } - private void startSendRtpStreamHand(RequestEvent evt, SendRtpItem sendRtpItem, ParentPlatform parentPlatform, - JSONObject jsonObject, Map param, CallIdHeader callIdHeader) { - if (jsonObject == null) { - logger.error("RTP推流失败: 请检查ZLM服务"); - } else if (jsonObject.getInteger("code") == 0) { - logger.info("调用ZLM推流接口, 结果: {}", jsonObject); - logger.info("RTP推流成功[ {}/{} ],{}->{}:{}, " ,param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); - if (sendRtpItem.getPlayType() == InviteStreamType.PUSH) { - MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0, sendRtpItem.getApp(), sendRtpItem.getStreamId(), - sendRtpItem.getChannelId(), parentPlatform.getServerGBId(), parentPlatform.getName(), userSetting.getServerId(), - sendRtpItem.getMediaServerId()); - messageForPushChannel.setPlatFormIndex(parentPlatform.getId()); - redisCatchStorage.sendPlatformStartPlayMsg(messageForPushChannel); - } - } else { - logger.error("RTP推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param)); - if (sendRtpItem.isOnlyAudio()) { - // TODO 可能是语音对讲 - }else { - // 向上级平台 - try { - commanderForPlatform.streamByeCmd(parentPlatform, callIdHeader.getCallId()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - } - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java deleted file mode 100644 index f437ca9c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java +++ /dev/null @@ -1,184 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; - -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.*; -import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.CallIdHeader; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.HashMap; -import java.util.Map; - -/** - * SIP命令类型: BYE请求 - */ -@Component -public class ByeRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - private final Logger logger = LoggerFactory.getLogger(ByeRequestProcessor.class); - private final String method = "BYE"; - - @Autowired - private ISIPCommander cmder; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private IPlatformService platformService; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private IDeviceChannelService channelService; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private SSRCFactory ssrcFactory; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Autowired - private VideoStreamSessionManager streamSession; - - @Autowired - private UserSetting userSetting; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addRequestProcessor(method, this); - } - - /** - * 处理BYE请求 - * @param evt - */ - @Override - public void process(RequestEvent evt) { - SIPRequest request = (SIPRequest) evt.getRequest(); - try { - responseAck(request, Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[回复BYE信息失败],{}", e.getMessage()); - } - CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); - - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId()); - - if (sendRtpItem != null){ - logger.info("[收到bye] 来自平台{}, 停止通道:{}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId()); - String streamId = sendRtpItem.getStreamId(); - Map param = new HashMap<>(); - param.put("vhost","__defaultVhost__"); - param.put("app",sendRtpItem.getApp()); - param.put("stream",streamId); - param.put("ssrc",sendRtpItem.getSsrc()); - logger.info("[收到bye] 停止向上级推流:{}", streamId); - MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), - callIdHeader.getCallId(), null); - zlmServerFactory.stopSendRtpStream(mediaInfo, param); - if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) { - ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId()); - if (platform != null) { - MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0, - sendRtpItem.getApp(), sendRtpItem.getStreamId(), sendRtpItem.getChannelId(), - sendRtpItem.getPlatformId(), platform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId()); - messageForPushChannel.setPlatFormIndex(platform.getId()); - redisCatchStorage.sendPlatformStopPlayMsg(messageForPushChannel); - }else { - logger.info("[上级平台停止观看] 未找到平台{}的信息,发送redis消息失败", sendRtpItem.getPlatformId()); - } - } - - int totalReaderCount = zlmServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId); - if (totalReaderCount <= 0) { - logger.info("[收到bye] {} 无其它观看者,通知设备停止推流", streamId); - if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) { - Device device = deviceService.getDevice(sendRtpItem.getDeviceId()); - if (device == null) { - logger.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId); - } - try { - logger.info("[停止点播] {}/{}", sendRtpItem.getDeviceId(), sendRtpItem.getChannelId()); - cmder.streamByeCmd(device, sendRtpItem.getChannelId(), streamId, null); - } catch (InvalidArgumentException | ParseException | SipException | - SsrcTransactionNotFoundException e) { - logger.error("[收到bye] {} 无其它观看者,通知设备停止推流, 发送BYE失败 {}",streamId, e.getMessage()); - } - } - } - }else { - - // 可能是设备发送的停止 - SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); - if (ssrcTransaction == null) { - return; - } - logger.info("[收到bye] 来自设备:{}, 通道已停止推流: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); - - Device device = deviceService.getDevice(ssrcTransaction.getDeviceId()); - if (device == null) { - logger.info("[收到bye] 未找到设备:{} ", ssrcTransaction.getDeviceId()); - return; - } - DeviceChannel channel = channelService.getOne(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); - if (channel == null) { - logger.info("[收到bye] 未找到通道,设备:{}, 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); - return; - } - storager.stopPlay(device.getDeviceId(), channel.getChannelId()); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channel.getChannelId()); - if (inviteInfo != null) { - inviteStreamService.removeInviteInfo(inviteInfo); - if (inviteInfo.getStreamInfo() != null) { - mediaServerService.closeRTPServer(inviteInfo.getStreamInfo().getMediaServerId(), inviteInfo.getStreamInfo().getStream()); - } - } - // 释放ssrc - MediaServerItem mediaServerItem = mediaServerService.getOne(ssrcTransaction.getMediaServerId()); - if (mediaServerItem != null) { - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcTransaction.getSsrc()); - } - streamSession.removeByCallId(device.getDeviceId(), channel.getChannelId(), ssrcTransaction.getCallId()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/CancelRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/CancelRequestProcessor.java deleted file mode 100644 index b04352a6..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/CancelRequestProcessor.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; - -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.RequestEvent; - -/** - * SIP命令类型: CANCEL请求 - */ -@Component -public class CancelRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - private final String method = "CANCEL"; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addRequestProcessor(method, this); - } - - /** - * 处理CANCEL请求 - * - * @param evt 事件 - */ - @Override - public void process(RequestEvent evt) { - // TODO 优先级99 Cancel Request消息实现,此消息一般为级联消息,上级给下级发送请求取消指令 - - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java deleted file mode 100644 index a4f3b5e7..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ /dev/null @@ -1,987 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.*; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.service.*; -import com.genersoft.iot.vmp.service.bean.ErrorCallback; -import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener; -import com.genersoft.iot.vmp.service.redisMsg.RedisPushStreamResponseListener; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import gov.nist.javax.sdp.TimeDescriptionImpl; -import gov.nist.javax.sdp.fields.TimeField; -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sdp.*; -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.CallIdHeader; -import javax.sip.message.Response; -import java.text.ParseException; -import java.time.Instant; -import java.util.HashMap; -import java.util.Map; -import java.util.Random; -import java.util.Vector; - -/** - * SIP命令类型: INVITE请求 - */ -@SuppressWarnings("rawtypes") -@Component -public class InviteRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - private final static Logger logger = LoggerFactory.getLogger(InviteRequestProcessor.class); - - private final String method = "INVITE"; - - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IStreamPushService streamPushService; - @Autowired - private IStreamProxyService streamProxyService; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private SSRCFactory ssrcFactory; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private RedisPushStreamResponseListener redisPushStreamResponseListener; - - @Autowired - private IPlayService playService; - - @Autowired - private SIPSender sipSender; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private ZlmHttpHookSubscribe zlmHttpHookSubscribe; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Autowired - private UserSetting userSetting; - - @Autowired - private ZLMMediaListManager mediaListManager; - - - @Autowired - private RedisGbPlayMsgListener redisGbPlayMsgListener; - - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addRequestProcessor(method, this); - } - - /** - * 处理invite请求 - * - * @param evt 请求消息 - */ - @Override - public void process(RequestEvent evt) { - // Invite Request消息实现,此消息一般为级联消息,上级给下级发送请求视频指令 - try { - SIPRequest request = (SIPRequest)evt.getRequest(); - String channelId = SipUtils.getChannelIdFromRequest(request); - String requesterId = SipUtils.getUserIdFromFromHeader(request); - CallIdHeader callIdHeader = (CallIdHeader) request.getHeader(CallIdHeader.NAME); - if (requesterId == null || channelId == null) { - logger.info("无法从FromHeader的Address中获取到平台id,返回400"); - // 参数不全, 发400,请求错误 - try { - responseAck(request, Response.BAD_REQUEST); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite BAD_REQUEST: {}", e.getMessage()); - } - return; - } - - - // 查询请求是否来自上级平台\设备 - ParentPlatform platform = storager.queryParentPlatByServerGBId(requesterId); - if (platform == null) { - inviteFromDeviceHandle(request, requesterId); - - } else { - // 查询平台下是否有该通道 - DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId); - GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId); - PlatformCatalog catalog = storager.getCatalog(requesterId, channelId); - - MediaServerItem mediaServerItem = null; - StreamPushItem streamPushItem = null; - StreamProxyItem proxyByAppAndStream =null; - // 不是通道可能是直播流 - if (channel != null && gbStream == null) { - // 通道存在,发100,TRYING - try { - responseAck(request, Response.TRYING); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite TRYING: {}", e.getMessage()); - } - } else if (channel == null && gbStream != null) { - - String mediaServerId = gbStream.getMediaServerId(); - mediaServerItem = mediaServerService.getOne(mediaServerId); - if (mediaServerItem == null) { - if ("proxy".equals(gbStream.getStreamType())) { - logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); - try { - responseAck(request, Response.GONE); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); - } - return; - } else { - streamPushItem = streamPushService.getPush(gbStream.getApp(), gbStream.getStream()); - if (streamPushItem != null) { - mediaServerItem = mediaServerService.getOne(streamPushItem.getMediaServerId()); - } - if (mediaServerItem == null) { - mediaServerItem = mediaServerService.getDefaultMediaServer(); - } - } - } else { - if ("push".equals(gbStream.getStreamType())) { - streamPushItem = streamPushService.getPush(gbStream.getApp(), gbStream.getStream()); - if (streamPushItem == null) { - logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); - try { - responseAck(request, Response.GONE); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); - } - return; - } - }else if("proxy".equals(gbStream.getStreamType())){ - proxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(gbStream.getApp(), gbStream.getStream()); - if (proxyByAppAndStream == null) { - logger.info("[ app={}, stream={} ]找不到zlm {},返回410", gbStream.getApp(), gbStream.getStream(), mediaServerId); - try { - responseAck(request, Response.GONE); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite GONE: {}", e.getMessage()); - } - return; - } - } - } - try { - responseAck(request, Response.CALL_IS_BEING_FORWARDED); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite CALL_IS_BEING_FORWARDED: {}", e.getMessage()); - } - } else if (catalog != null) { - try { - // 目录不支持点播 - responseAck(request, Response.BAD_REQUEST, "catalog channel can not play"); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 目录不支持点播: {}", e.getMessage()); - } - return; - } else { - logger.info("通道不存在,返回404: {}", channelId); - try { - // 通道不存在,发404,资源不存在 - responseAck(request, Response.NOT_FOUND); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 通道不存在: {}", e.getMessage()); - } - return; - } - // 解析sdp消息, 使用jainsip 自带的sdp解析方式 - String contentString = new String(request.getRawContent()); - - Gb28181Sdp gb28181Sdp = SipUtils.parseSDP(contentString); - SessionDescription sdp = gb28181Sdp.getBaseSdb(); - String sessionName = sdp.getSessionName().getValue(); - - Long startTime = null; - Long stopTime = null; - Instant start = null; - Instant end = null; - if (sdp.getTimeDescriptions(false) != null && sdp.getTimeDescriptions(false).size() > 0) { - TimeDescriptionImpl timeDescription = (TimeDescriptionImpl) (sdp.getTimeDescriptions(false).get(0)); - TimeField startTimeFiled = (TimeField) timeDescription.getTime(); - startTime = startTimeFiled.getStartTime(); - stopTime = startTimeFiled.getStopTime(); - - start = Instant.ofEpochSecond(startTime); - end = Instant.ofEpochSecond(stopTime); - } - // 获取支持的格式 - Vector mediaDescriptions = sdp.getMediaDescriptions(true); - // 查看是否支持PS 负载96 - //String ip = null; - int port = -1; - boolean mediaTransmissionTCP = false; - Boolean tcpActive = null; - for (Object description : mediaDescriptions) { - MediaDescription mediaDescription = (MediaDescription) description; - Media media = mediaDescription.getMedia(); - - Vector mediaFormats = media.getMediaFormats(false); - if (mediaFormats.contains("96")) { - port = media.getMediaPort(); - //String mediaType = media.getMediaType(); - String protocol = media.getProtocol(); - - // 区分TCP发流还是udp, 当前默认udp - if ("TCP/RTP/AVP".equalsIgnoreCase(protocol)) { - String setup = mediaDescription.getAttribute("setup"); - if (setup != null) { - mediaTransmissionTCP = true; - if ("active".equalsIgnoreCase(setup)) { - tcpActive = true; - } else if ("passive".equalsIgnoreCase(setup)) { - tcpActive = false; - } - } - } - break; - } - } - if (port == -1) { - logger.info("不支持的媒体格式,返回415"); - // 回复不支持的格式 - try { - // 不支持的格式,发415 - responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 不支持的格式: {}", e.getMessage()); - } - return; - } - String username = sdp.getOrigin().getUsername(); - String addressStr = sdp.getConnection().getAddress(); - - - Device device = null; - // 通过 channel 和 gbStream 是否为null 值判断来源是直播流合适国标 - if (channel != null) { - device = storager.queryVideoDeviceByPlatformIdAndChannelId(requesterId, channelId); - if (device == null) { - logger.warn("点播平台{}的通道{}时未找到设备信息", requesterId, channel); - try { - responseAck(request, Response.SERVER_INTERNAL_ERROR); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 未找到设备信息: {}", e.getMessage()); - } - return; - } - mediaServerItem = playService.getNewMediaServerItem(device); - if (mediaServerItem == null) { - logger.warn("未找到可用的zlm"); - try { - responseAck(request, Response.BUSY_HERE); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite BUSY_HERE: {}", e.getMessage()); - } - return; - } - - String ssrc; - if (userSetting.getUseCustomSsrcForParentInvite() || gb28181Sdp.getSsrc() == null) { - // 上级平台点播时不使用上级平台指定的ssrc,使用自定义的ssrc,参考国标文档-点播外域设备媒体流SSRC处理方式 - ssrc = "Play".equalsIgnoreCase(sessionName) ? ssrcFactory.getPlaySsrc(mediaServerItem.getId()) : ssrcFactory.getPlayBackSsrc(mediaServerItem.getId()); - }else { - ssrc = gb28181Sdp.getSsrc(); - } - String streamTypeStr = null; - if (mediaTransmissionTCP) { - if (tcpActive) { - streamTypeStr = "TCP-ACTIVE"; - }else { - streamTypeStr = "TCP-PASSIVE"; - } - }else { - streamTypeStr = "UDP"; - } - logger.info("[上级Invite] {}, 平台:{}, 通道:{}, 收流地址:{}:{},收流方式:{}, ssrc:{}", sessionName, username, channelId, addressStr, port, streamTypeStr, ssrc); - SendRtpItem sendRtpItem = zlmServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, - device.getDeviceId(), channelId, mediaTransmissionTCP, platform.isRtcp()); - - if (tcpActive != null) { - sendRtpItem.setTcpActive(tcpActive); - } - if (sendRtpItem == null) { - logger.warn("服务器端口资源不足"); - try { - responseAck(request, Response.BUSY_HERE); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); - } - return; - } - sendRtpItem.setCallId(callIdHeader.getCallId()); - sendRtpItem.setPlayType("Play".equalsIgnoreCase(sessionName) ? InviteStreamType.PLAY : InviteStreamType.PLAYBACK); - - Long finalStartTime = startTime; - Long finalStopTime = stopTime; - ErrorCallback hookEvent = (code, msg, data) -> { - StreamInfo streamInfo = (StreamInfo)data; - MediaServerItem mediaServerItemInUSe = mediaServerService.getOne(streamInfo.getMediaServerId()); - logger.info("[上级Invite]下级已经开始推流。 回复200OK(SDP), {}/{}", streamInfo.getApp(), streamInfo.getStream()); - // * 0 等待设备推流上来 - // * 1 下级已经推流,等待上级平台回复ack - // * 2 推流中 - sendRtpItem.setStatus(1); - redisCatchStorage.updateSendRTPSever(sendRtpItem); - - StringBuffer content = new StringBuffer(200); - content.append("v=0\r\n"); - content.append("o=" + channelId + " 0 0 IN IP4 " + mediaServerItemInUSe.getSdpIp() + "\r\n"); - content.append("s=" + sessionName + "\r\n"); - content.append("c=IN IP4 " + mediaServerItemInUSe.getSdpIp() + "\r\n"); - if ("Playback".equalsIgnoreCase(sessionName)) { - content.append("t=" + finalStartTime + " " + finalStopTime + "\r\n"); - } else { - content.append("t=0 0\r\n"); - } - int localPort = sendRtpItem.getLocalPort(); - if (localPort == 0) { - // 非严格模式端口不统一, 增加兼容性,修改为一个不为0的端口 - localPort = new Random().nextInt(65535) + 1; - } - content.append("m=video " + localPort + " RTP/AVP 96\r\n"); - content.append("a=sendonly\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); - content.append("y=" + sendRtpItem.getSsrc() + "\r\n"); - content.append("f=\r\n"); - - - try { - // 超时未收到Ack应该回复bye,当前等待时间为10秒 - dynamicTask.startDelay(callIdHeader.getCallId(), () -> { - logger.info("Ack 等待超时"); - mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), sendRtpItem.getSsrc()); - // 回复bye - try { - cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - } - }, 60 * 1000); - responseSdpAck(request, content.toString(), platform); - // tcp主动模式,回复sdp后开启监听 - if (sendRtpItem.isTcpActive()) { - MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - Map param = new HashMap<>(12); - param.put("vhost","__defaultVhost__"); - param.put("app",sendRtpItem.getApp()); - param.put("stream",sendRtpItem.getStreamId()); - param.put("ssrc", sendRtpItem.getSsrc()); - if (!sendRtpItem.isTcpActive()) { - param.put("dst_url",sendRtpItem.getIp()); - param.put("dst_port", sendRtpItem.getPort()); - } - String is_Udp = sendRtpItem.isTcp() ? "0" : "1"; - param.put("is_udp", is_Udp); - param.put("src_port", localPort); - param.put("pt", sendRtpItem.getPt()); - param.put("use_ps", sendRtpItem.isUsePs() ? "1" : "0"); - param.put("only_audio", sendRtpItem.isOnlyAudio() ? "1" : "0"); - if (!sendRtpItem.isTcp()) { - // 开启rtcp保活 - param.put("udp_rtcp_timeout", sendRtpItem.isRtcp()? "1":"0"); - } - JSONObject startSendRtpStreamResult = zlmServerFactory.startSendRtpStreamForPassive(mediaInfo, param); - if (startSendRtpStreamResult != null) { - startSendRtpStreamHand(evt, sendRtpItem, null, startSendRtpStreamResult, param, callIdHeader); - } - } - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 回复SdpAck", e); - } - }; - ErrorCallback errorEvent = ((statusCode, msg, data) -> { - // 未知错误。直接转发设备点播的错误 - try { - if (statusCode > 0) { - Response response = getMessageFactory().createResponse(statusCode, evt.getRequest()); - sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); - } - } catch (ParseException | SipException e) { - logger.error("未处理的异常 ", e); - } - }); - sendRtpItem.setApp("rtp"); - if ("Playback".equalsIgnoreCase(sessionName)) { - sendRtpItem.setPlayType(InviteStreamType.PLAYBACK); - String startTimeStr = DateUtil.urlFormatter.format(start); - String endTimeStr = DateUtil.urlFormatter.format(end); - String stream = device.getDeviceId() + "_" + channelId + "_" + startTimeStr + "_" + endTimeStr; - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, stream, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam()); - sendRtpItem.setStreamId(ssrcInfo.getStream()); - // 写入redis, 超时时回复 - redisCatchStorage.updateSendRTPSever(sendRtpItem); - playService.playBack(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start), - DateUtil.formatter.format(end), - (code, msg, data) -> { - if (code == InviteErrorCode.SUCCESS.getCode()){ - hookEvent.run(code, msg, data); - }else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()){ - logger.info("[录像回放]超时, 用户:{}, 通道:{}", username, channelId); - redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); - errorEvent.run(code, msg, data); - }else { - errorEvent.run(code, msg, data); - } - }); - } else if ("Download".equalsIgnoreCase(sessionName)) { - // 获取指定的下载速度 - Vector sdpMediaDescriptions = sdp.getMediaDescriptions(true); - MediaDescription mediaDescription = null; - String downloadSpeed = "1"; - if (sdpMediaDescriptions.size() > 0) { - mediaDescription = (MediaDescription) sdpMediaDescriptions.get(0); - } - if (mediaDescription != null) { - downloadSpeed = mediaDescription.getAttribute("downloadspeed"); - } - - sendRtpItem.setPlayType(InviteStreamType.DOWNLOAD); - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam()); - sendRtpItem.setStreamId(ssrcInfo.getStream()); - // 写入redis, 超时时回复 - redisCatchStorage.updateSendRTPSever(sendRtpItem); - playService.download(mediaServerItem, ssrcInfo, device.getDeviceId(), channelId, DateUtil.formatter.format(start), - DateUtil.formatter.format(end), Integer.parseInt(downloadSpeed), - (code, msg, data) -> { - if (code == InviteErrorCode.SUCCESS.getCode()) { - hookEvent.run(code, msg, data); - } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) { - logger.info("[录像下载]超时, 用户:{}, 通道:{}", username, channelId); - redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); - errorEvent.run(code, msg, data); - } else { - errorEvent.run(code, msg, data); - } - }); - } else { - - SSRCInfo ssrcInfo = playService.play(mediaServerItem, device.getDeviceId(), channelId, ssrc, ((code, msg, data) -> { - if (code == InviteErrorCode.SUCCESS.getCode()) { - hookEvent.run(code, msg, data); - } else if (code == InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode() || code == InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode()) { - logger.info("[上级点播]超时, 用户:{}, 通道:{}", username, channelId); - redisCatchStorage.deleteSendRTPServer(platform.getServerGBId(), channelId, callIdHeader.getCallId(), null); - errorEvent.run(code, msg, data); - } else { - errorEvent.run(code, msg, data); - } - })); - sendRtpItem.setPlayType(InviteStreamType.PLAY); - String streamId = String.format("%s_%s", device.getDeviceId(), channelId); - sendRtpItem.setStreamId(streamId); - sendRtpItem.setSsrc(ssrcInfo.getSsrc()); - redisCatchStorage.updateSendRTPSever(sendRtpItem); - - } - } else if (gbStream != null) { - - String ssrc; - if (userSetting.getUseCustomSsrcForParentInvite() || gb28181Sdp.getSsrc() == null) { - // 上级平台点播时不使用上级平台指定的ssrc,使用自定义的ssrc,参考国标文档-点播外域设备媒体流SSRC处理方式 - ssrc = "Play".equalsIgnoreCase(sessionName) ? ssrcFactory.getPlaySsrc(mediaServerItem.getId()) : ssrcFactory.getPlayBackSsrc(mediaServerItem.getId()); - }else { - ssrc = gb28181Sdp.getSsrc(); - } - - if("push".equals(gbStream.getStreamType())) { - if (streamPushItem != null && streamPushItem.isPushIng()) { - // 推流状态 - pushStream(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - } else { - // 未推流 拉起 - notifyStreamOnline(evt, request,gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - } - }else if ("proxy".equals(gbStream.getStreamType())){ - if (null != proxyByAppAndStream) { - if(proxyByAppAndStream.isStatus()){ - pushProxyStream(evt, request, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - }else{ - //开启代理拉流 - notifyStreamOnline(evt, request,gbStream, null, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - } - } - - - } - } - } - } catch (SdpParseException e) { - logger.error("sdp解析错误", e); - } catch (SdpException e) { - logger.error("未处理的异常 ", e); - } - } - - private void startSendRtpStreamHand(RequestEvent evt, SendRtpItem sendRtpItem, ParentPlatform parentPlatform, - JSONObject jsonObject, Map param, CallIdHeader callIdHeader) { - if (jsonObject == null) { - logger.error("下级TCP被动启动监听失败: 请检查ZLM服务"); - } else if (jsonObject.getInteger("code") == 0) { - logger.info("调用ZLM-TCP被动推流接口, 结果: {}", jsonObject); - logger.info("启动监听TCP被动推流成功[ {}/{} ],{}->{}:{}, " ,param.get("app"), param.get("stream"), jsonObject.getString("local_port"), param.get("dst_url"), param.get("dst_port")); - } else { - logger.error("启动监听TCP被动推流失败: {}, 参数:{}",jsonObject.getString("msg"), JSON.toJSONString(param)); - } - } - - /** - * 安排推流 - */ - private void pushProxyStream(RequestEvent evt, SIPRequest request, GbStream gbStream, ParentPlatform platform, - CallIdHeader callIdHeader, MediaServerItem mediaServerItem, - int port, Boolean tcpActive, boolean mediaTransmissionTCP, - String channelId, String addressStr, String ssrc, String requesterId) { - Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, gbStream.getApp(), gbStream.getStream()); - if (streamReady != null && streamReady) { - // 自平台内容 - SendRtpItem sendRtpItem = zlmServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, - gbStream.getApp(), gbStream.getStream(), channelId, mediaTransmissionTCP, platform.isRtcp()); - - if (sendRtpItem == null) { - logger.warn("服务器端口资源不足"); - try { - responseAck(request, Response.BUSY_HERE); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); - } - return; - } - if (tcpActive != null) { - sendRtpItem.setTcpActive(tcpActive); - } - sendRtpItem.setPlayType(InviteStreamType.PUSH); - // 写入redis, 超时时回复 - sendRtpItem.setStatus(1); - sendRtpItem.setCallId(callIdHeader.getCallId()); - sendRtpItem.setFromTag(request.getFromTag()); - - SIPResponse response = sendStreamAck(mediaServerItem, request, sendRtpItem, platform, evt); - if (response != null) { - sendRtpItem.setToTag(response.getToTag()); - } - redisCatchStorage.updateSendRTPSever(sendRtpItem); - - } - - } - private void pushStream(RequestEvent evt, SIPRequest request, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, - CallIdHeader callIdHeader, MediaServerItem mediaServerItem, - int port, Boolean tcpActive, boolean mediaTransmissionTCP, - String channelId, String addressStr, String ssrc, String requesterId) { - // 推流 - if (streamPushItem.isSelf()) { - Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, gbStream.getApp(), gbStream.getStream()); - if (streamReady != null && streamReady) { - // 自平台内容 - SendRtpItem sendRtpItem = zlmServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, - gbStream.getApp(), gbStream.getStream(), channelId, mediaTransmissionTCP, platform.isRtcp()); - - if (sendRtpItem == null) { - logger.warn("服务器端口资源不足"); - try { - responseAck(request, Response.BUSY_HERE); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 服务器端口资源不足: {}", e.getMessage()); - } - return; - } - if (tcpActive != null) { - sendRtpItem.setTcpActive(tcpActive); - } - sendRtpItem.setPlayType(InviteStreamType.PUSH); - // 写入redis, 超时时回复 - sendRtpItem.setStatus(1); - sendRtpItem.setCallId(callIdHeader.getCallId()); - - sendRtpItem.setFromTag(request.getFromTag()); - SIPResponse response = sendStreamAck(mediaServerItem, request, sendRtpItem, platform, evt); - if (response != null) { - sendRtpItem.setToTag(response.getToTag()); - } - - redisCatchStorage.updateSendRTPSever(sendRtpItem); - - } else { - // 不在线 拉起 - notifyStreamOnline(evt, request,gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - } - - } else { - // 其他平台内容 - otherWvpPushStream(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - } - } - /** - * 通知流上线 - */ - private void notifyStreamOnline(RequestEvent evt, SIPRequest request, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, - CallIdHeader callIdHeader, MediaServerItem mediaServerItem, - int port, Boolean tcpActive, boolean mediaTransmissionTCP, - String channelId, String addressStr, String ssrc, String requesterId) { - if ("proxy".equals(gbStream.getStreamType())) { - // TODO 控制启用以使设备上线 - logger.info("[ app={}, stream={} ]通道未推流,启用流后开始推流", gbStream.getApp(), gbStream.getStream()); - // 监听流上线 - HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed(gbStream.getApp(), gbStream.getStream(), true, "rtsp", mediaServerItem.getId()); - zlmHttpHookSubscribe.addSubscribe(hookSubscribe, (mediaServerItemInUSe, hookParam) -> { - OnStreamChangedHookParam streamChangedHookParam = (OnStreamChangedHookParam)hookParam; - logger.info("[上级点播]拉流代理已经就绪, {}/{}", streamChangedHookParam.getApp(), streamChangedHookParam.getStream()); - dynamicTask.stop(callIdHeader.getCallId()); - pushProxyStream(evt, request, gbStream, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - }); - dynamicTask.startDelay(callIdHeader.getCallId(), () -> { - logger.info("[ app={}, stream={} ] 等待拉流代理流超时", gbStream.getApp(), gbStream.getStream()); - zlmHttpHookSubscribe.removeSubscribe(hookSubscribe); - }, userSetting.getPlatformPlayTimeout()); - boolean start = streamProxyService.start(gbStream.getApp(), gbStream.getStream()); - if (!start) { - try { - responseAck(request, Response.BUSY_HERE, "channel [" + gbStream.getGbId() + "] offline"); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); - } - zlmHttpHookSubscribe.removeSubscribe(hookSubscribe); - dynamicTask.stop(callIdHeader.getCallId()); - } - - - - } else if ("push".equals(gbStream.getStreamType())) { - if (!platform.isStartOfflinePush()) { - // 平台设置中关闭了拉起离线的推流则直接回复 - try { - logger.info("[上级点播] 失败,推流设备未推流,channel: {}, app: {}, stream: {}", gbStream.getGbId(), gbStream.getApp(), gbStream.getStream()); - responseAck(request, Response.TEMPORARILY_UNAVAILABLE, "channel stream not pushing"); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 通道未推流: {}", e.getMessage()); - } - return; - } - // 发送redis消息以使设备上线 - logger.info("[ app={}, stream={} ]通道未推流,发送redis信息控制设备开始推流", gbStream.getApp(), gbStream.getStream()); - - MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(1, - gbStream.getApp(), gbStream.getStream(), gbStream.getGbId(), gbStream.getPlatformId(), - platform.getName(), null, gbStream.getMediaServerId()); - redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel); - // 设置超时 - dynamicTask.startDelay(callIdHeader.getCallId(), () -> { - logger.info("[ app={}, stream={} ] 等待设备开始推流超时", gbStream.getApp(), gbStream.getStream()); - try { - mediaListManager.removedChannelOnlineEventLister(gbStream.getApp(), gbStream.getStream()); - responseAck(request, Response.REQUEST_TIMEOUT); // 超时 - } catch (SipException e) { - logger.error("未处理的异常 ", e); - } catch (InvalidArgumentException e) { - logger.error("未处理的异常 ", e); - } catch (ParseException e) { - logger.error("未处理的异常 ", e); - } - }, userSetting.getPlatformPlayTimeout()); - // 添加监听 - int finalPort = port; - Boolean finalTcpActive = tcpActive; - - // 添加在本机上线的通知 - mediaListManager.addChannelOnlineEventLister(gbStream.getApp(), gbStream.getStream(), (app, stream, serverId) -> { - dynamicTask.stop(callIdHeader.getCallId()); - if (serverId.equals(userSetting.getServerId())) { - SendRtpItem sendRtpItem = zlmServerFactory.createSendRtpItem(mediaServerItem, addressStr, finalPort, ssrc, requesterId, - app, stream, channelId, mediaTransmissionTCP, platform.isRtcp()); - - if (sendRtpItem == null) { - logger.warn("上级点时创建sendRTPItem失败,可能是服务器端口资源不足"); - try { - responseAck(request, Response.BUSY_HERE); - } catch (SipException e) { - logger.error("未处理的异常 ", e); - } catch (InvalidArgumentException e) { - logger.error("未处理的异常 ", e); - } catch (ParseException e) { - logger.error("未处理的异常 ", e); - } - return; - } - if (finalTcpActive != null) { - sendRtpItem.setTcpActive(finalTcpActive); - } - sendRtpItem.setPlayType(InviteStreamType.PUSH); - // 写入redis, 超时时回复 - sendRtpItem.setStatus(1); - sendRtpItem.setCallId(callIdHeader.getCallId()); - - sendRtpItem.setFromTag(request.getFromTag()); - SIPResponse response = sendStreamAck(mediaServerItem, request, sendRtpItem, platform, evt); - if (response != null) { - sendRtpItem.setToTag(response.getToTag()); - } - redisCatchStorage.updateSendRTPSever(sendRtpItem); - } else { - // 其他平台内容 - otherWvpPushStream(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - } - }); - - // 添加回复的拒绝或者错误的通知 - redisPushStreamResponseListener.addEvent(gbStream.getApp(), gbStream.getStream(), response -> { - if (response.getCode() != 0) { - dynamicTask.stop(callIdHeader.getCallId()); - mediaListManager.removedChannelOnlineEventLister(gbStream.getApp(), gbStream.getStream()); - try { - responseAck(request, Response.TEMPORARILY_UNAVAILABLE, response.getMsg()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 点播回复: {}", e.getMessage()); - } - } - }); - } - } - - /** - * 来自其他wvp的推流 - */ - private void otherWvpPushStream(RequestEvent evt, SIPRequest request, GbStream gbStream, StreamPushItem streamPushItem, ParentPlatform platform, - CallIdHeader callIdHeader, MediaServerItem mediaServerItem, - int port, Boolean tcpActive, boolean mediaTransmissionTCP, - String channelId, String addressStr, String ssrc, String requesterId) { - logger.info("[级联点播]直播流来自其他平台,发送redis消息"); - // 发送redis消息 - redisGbPlayMsgListener.sendMsg(streamPushItem.getServerId(), streamPushItem.getMediaServerId(), - streamPushItem.getApp(), streamPushItem.getStream(), addressStr, port, ssrc, requesterId, - channelId, mediaTransmissionTCP, platform.isRtcp(),null, responseSendItemMsg -> { - SendRtpItem sendRtpItem = responseSendItemMsg.getSendRtpItem(); - if (sendRtpItem == null || responseSendItemMsg.getMediaServerItem() == null) { - logger.warn("服务器端口资源不足"); - try { - responseAck(request, Response.BUSY_HERE); - } catch (SipException e) { - logger.error("未处理的异常 ", e); - } catch (InvalidArgumentException e) { - logger.error("未处理的异常 ", e); - } catch (ParseException e) { - logger.error("未处理的异常 ", e); - } - return; - } - // 收到sendItem - if (tcpActive != null) { - sendRtpItem.setTcpActive(tcpActive); - } - sendRtpItem.setPlayType(InviteStreamType.PUSH); - // 写入redis, 超时时回复 - sendRtpItem.setStatus(1); - sendRtpItem.setCallId(callIdHeader.getCallId()); - - sendRtpItem.setFromTag(request.getFromTag()); - SIPResponse response = sendStreamAck(responseSendItemMsg.getMediaServerItem(), request,sendRtpItem, platform, evt); - if (response != null) { - sendRtpItem.setToTag(response.getToTag()); - } - redisCatchStorage.updateSendRTPSever(sendRtpItem); - }, (wvpResult) -> { - - // 错误 - if (wvpResult.getCode() == RedisGbPlayMsgListener.ERROR_CODE_OFFLINE) { - // 离线 - // 查询是否在本机上线了 - StreamPushItem currentStreamPushItem = streamPushService.getPush(streamPushItem.getApp(), streamPushItem.getStream()); - if (currentStreamPushItem.isPushIng()) { - // 在线状态 - pushStream(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - - } else { - // 不在线 拉起 - notifyStreamOnline(evt, request, gbStream, streamPushItem, platform, callIdHeader, mediaServerItem, port, tcpActive, - mediaTransmissionTCP, channelId, addressStr, ssrc, requesterId); - } - } - try { - responseAck(request, Response.BUSY_HERE); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 国标级联 点播回复 BUSY_HERE: {}", e.getMessage()); - } - }); - } - - public SIPResponse sendStreamAck(MediaServerItem mediaServerItem, SIPRequest request, SendRtpItem sendRtpItem, ParentPlatform platform, RequestEvent evt) { - - StringBuffer content = new StringBuffer(200); - content.append("v=0\r\n"); - content.append("o=" + sendRtpItem.getChannelId() + " 0 0 IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); - content.append("s=Play\r\n"); - content.append("c=IN IP4 " + mediaServerItem.getSdpIp() + "\r\n"); - content.append("t=0 0\r\n"); - // 非严格模式端口不统一, 增加兼容性,修改为一个不为0的端口 - int localPort = sendRtpItem.getLocalPort(); - if(localPort == 0) - { - localPort = new Random().nextInt(65535) + 1; - } - content.append("m=video " + localPort + " RTP/AVP 96\r\n"); - content.append("a=sendonly\r\n"); - content.append("a=rtpmap:96 PS/90000\r\n"); - if (sendRtpItem.isTcp()) { - content.append("a=connection:new\r\n"); - if (!sendRtpItem.isTcpActive()) { - content.append("a=setup:active\r\n"); - } else { - content.append("a=setup:passive\r\n"); - } - } - content.append("y=" + sendRtpItem.getSsrc() + "\r\n"); - content.append("f=\r\n"); - - try { - return responseSdpAck(request, content.toString(), platform); - } catch (SipException e) { - logger.error("未处理的异常 ", e); - } catch (InvalidArgumentException e) { - logger.error("未处理的异常 ", e); - } catch (ParseException e) { - logger.error("未处理的异常 ", e); - } - return null; - } - - public void inviteFromDeviceHandle(SIPRequest request, String requesterId) { - - // 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备) - Device device = redisCatchStorage.getDevice(requesterId); - if (device != null) { - logger.info("收到设备" + requesterId + "的语音广播Invite请求"); - try { - responseAck(request, Response.TRYING); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite BAD_REQUEST: {}", e.getMessage()); - } - String contentString = new String(request.getRawContent()); - // jainSip不支持y=字段, 移除移除以解析。 - String ssrc = "0000000404"; - - try { - Gb28181Sdp gb28181Sdp = SipUtils.parseSDP(contentString); - SessionDescription sdp = gb28181Sdp.getBaseSdb(); - // 获取支持的格式 - Vector mediaDescriptions = sdp.getMediaDescriptions(true); - // 查看是否支持PS 负载96 - int port = -1; - //boolean recvonly = false; - boolean mediaTransmissionTCP = false; - Boolean tcpActive = null; - for (int i = 0; i < mediaDescriptions.size(); i++) { - MediaDescription mediaDescription = (MediaDescription) mediaDescriptions.get(i); - Media media = mediaDescription.getMedia(); - - Vector mediaFormats = media.getMediaFormats(false); - if (mediaFormats.contains("8")) { - port = media.getMediaPort(); - String protocol = media.getProtocol(); - // 区分TCP发流还是udp, 当前默认udp - if ("TCP/RTP/AVP".equals(protocol)) { - String setup = mediaDescription.getAttribute("setup"); - if (setup != null) { - mediaTransmissionTCP = true; - if ("active".equals(setup)) { - tcpActive = true; - } else if ("passive".equals(setup)) { - tcpActive = false; - } - } - } - break; - } - } - if (port == -1) { - logger.info("不支持的媒体格式,返回415"); - // 回复不支持的格式 - try { - responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE); // 不支持的格式,发415 - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 不支持的媒体格式,返回415, {}", e.getMessage()); - } - return; - } - String username = sdp.getOrigin().getUsername(); - String addressStr = sdp.getConnection().getAddress(); - logger.info("设备{}请求语音流,地址:{}:{},ssrc:{}", username, addressStr, port, ssrc); - } catch (SdpException e) { - logger.error("[SDP解析异常]", e); - } - - - - } else { - logger.warn("来自无效设备/平台的请求"); - try { - responseAck(request, Response.BAD_REQUEST);; // 不支持的格式,发415 - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] invite 来自无效设备/平台的请求, {}", e.getMessage()); - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java deleted file mode 100644 index a78404e2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestForCatalogProcessor.java +++ /dev/null @@ -1,311 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; - -import com.genersoft.iot.vmp.conf.CivilCodeFileConf; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.RequestEvent; -import javax.sip.header.FromHeader; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * SIP命令类型: NOTIFY请求中的目录请求处理 - */ -@Component -public class NotifyRequestForCatalogProcessor extends SIPRequestProcessorParent { - - - private final static Logger logger = LoggerFactory.getLogger(NotifyRequestForCatalogProcessor.class); - - private final List updateChannelOnlineList = new CopyOnWriteArrayList<>(); - private final List updateChannelOfflineList = new CopyOnWriteArrayList<>(); - private final Map updateChannelMap = new ConcurrentHashMap<>(); - - private final Map addChannelMap = new ConcurrentHashMap<>(); - private final List deleteChannelList = new CopyOnWriteArrayList<>(); - - - @Autowired - private UserSetting userSetting; - - @Autowired - private EventPublisher eventPublisher; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IDeviceChannelService deviceChannelService; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private CivilCodeFileConf civilCodeFileConf; - - @Autowired - private SipConfig sipConfig; - - private final static String talkKey = "notify-request-for-catalog-task"; - - public void process(RequestEvent evt) { - try { - long start = System.currentTimeMillis(); - FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); - String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader); - - Device device = redisCatchStorage.getDevice(deviceId); - if (device == null || !device.isOnLine()) { - logger.warn("[收到目录订阅]:{}, 但是设备已经离线", (device != null ? device.getDeviceId():"" )); - return; - } - Element rootElement = getRootElement(evt, device.getCharset()); - if (rootElement == null) { - logger.warn("[ 收到目录订阅 ] content cannot be null, {}", evt.getRequest()); - return; - } - Element deviceListElement = rootElement.element("DeviceList"); - if (deviceListElement == null) { - return; - } - Iterator deviceListIterator = deviceListElement.elementIterator(); - if (deviceListIterator != null) { - - // 遍历DeviceList - while (deviceListIterator.hasNext()) { - Element itemDevice = deviceListIterator.next(); - Element channelDeviceElement = itemDevice.element("DeviceID"); - if (channelDeviceElement == null) { - continue; - } - Element eventElement = itemDevice.element("Event"); - String event; - if (eventElement == null) { - logger.warn("[收到目录订阅]:{}, 但是Event为空, 设为默认值 ADD", (device != null ? device.getDeviceId():"" )); - event = CatalogEvent.ADD; - }else { - event = eventElement.getText().toUpperCase(); - } - DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, event, civilCodeFileConf); - if (channel == null) { - logger.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent())); - continue; - } - if (channel.getParentId() != null && channel.getParentId().equals(sipConfig.getId())) { - channel.setParentId(null); - } - channel.setDeviceId(device.getDeviceId()); - logger.info("[收到目录订阅]:{}/{}", device.getDeviceId(), channel.getChannelId()); - switch (event) { - case CatalogEvent.ON: - // 上线 - logger.info("[收到通道上线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - updateChannelOnlineList.add(channel); - if (updateChannelOnlineList.size() > 300) { - executeSaveForOnline(); - } - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), channel.getChannelId(), true); - } - - break; - case CatalogEvent.OFF : - // 离线 - logger.info("[收到通道离线通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - if (userSetting.getRefuseChannelStatusChannelFormNotify()) { - logger.info("[收到通道离线通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - }else { - updateChannelOfflineList.add(channel); - if (updateChannelOfflineList.size() > 300) { - executeSaveForOffline(); - } - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), channel.getChannelId(), false); - } - } - break; - case CatalogEvent.VLOST: - // 视频丢失 - logger.info("[收到通道视频丢失通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - if (userSetting.getRefuseChannelStatusChannelFormNotify()) { - logger.info("[收到通道视频丢失通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - }else { - updateChannelOfflineList.add(channel); - if (updateChannelOfflineList.size() > 300) { - executeSaveForOffline(); - } - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), channel.getChannelId(), false); - } - } - break; - case CatalogEvent.DEFECT: - // 故障 - logger.info("[收到通道视频故障通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - if (userSetting.getRefuseChannelStatusChannelFormNotify()) { - logger.info("[收到通道视频故障通知] 但是平台已配置拒绝此消息,来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - }else { - updateChannelOfflineList.add(channel); - if (updateChannelOfflineList.size() > 300) { - executeSaveForOffline(); - } - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), channel.getChannelId(), false); - } - } - break; - case CatalogEvent.ADD: - // 增加 - logger.info("[收到增加通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - // 判断此通道是否存在 - DeviceChannel deviceChannel = deviceChannelService.getOne(deviceId, channel.getChannelId()); - if (deviceChannel != null) { - channel.setId(deviceChannel.getId()); - updateChannelMap.put(channel.getChannelId(), channel); - if (updateChannelMap.keySet().size() > 300) { - executeSaveForUpdate(); - } - }else { - addChannelMap.put(channel.getChannelId(), channel); - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendChannelAddOrDelete(device.getDeviceId(), channel.getChannelId(), true); - } - - if (addChannelMap.keySet().size() > 300) { - executeSaveForAdd(); - } - } - - break; - case CatalogEvent.DEL: - // 删除 - logger.info("[收到删除通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - deleteChannelList.add(channel); - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendChannelAddOrDelete(device.getDeviceId(), channel.getChannelId(), false); - } - if (deleteChannelList.size() > 300) { - executeSaveForDelete(); - } - break; - case CatalogEvent.UPDATE: - // 更新 - logger.info("[收到更新通道通知] 来自设备: {}, 通道 {}", device.getDeviceId(), channel.getChannelId()); - // 判断此通道是否存在 - DeviceChannel deviceChannelForUpdate = deviceChannelService.getOne(deviceId, channel.getChannelId()); - if (deviceChannelForUpdate != null) { - channel.setId(deviceChannelForUpdate.getId()); - updateChannelMap.put(channel.getChannelId(), channel); - if (updateChannelMap.keySet().size() > 300) { - executeSaveForUpdate(); - } - }else { - addChannelMap.put(channel.getChannelId(), channel); - if (addChannelMap.keySet().size() > 300) { - executeSaveForAdd(); - } - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendChannelAddOrDelete(device.getDeviceId(), channel.getChannelId(), true); - } - } - break; - default: - logger.warn("[ NotifyCatalog ] event not found : {}", event ); - - } - // 转发变化信息 - eventPublisher.catalogEventPublish(null, channel, event); - - if (updateChannelMap.keySet().size() > 0 - || addChannelMap.keySet().size() > 0 - || updateChannelOnlineList.size() > 0 - || updateChannelOfflineList.size() > 0 - || deleteChannelList.size() > 0) { - - if (!dynamicTask.contains(talkKey)) { - dynamicTask.startDelay(talkKey, this::executeSave, 1000); - } - } - } - } - } catch (DocumentException e) { - logger.error("未处理的异常 ", e); - } - } - - private void executeSave(){ - executeSaveForAdd(); - executeSaveForUpdate(); - executeSaveForDelete(); - executeSaveForOnline(); - executeSaveForOffline(); - dynamicTask.stop(talkKey); - } - - private void executeSaveForUpdate(){ - if (updateChannelMap.values().size() > 0) { - ArrayList deviceChannels = new ArrayList<>(updateChannelMap.values()); - updateChannelMap.clear(); - deviceChannelService.batchUpdateChannel(deviceChannels); - } - - } - - private void executeSaveForAdd(){ - if (addChannelMap.values().size() > 0) { - ArrayList deviceChannels = new ArrayList<>(addChannelMap.values()); - addChannelMap.clear(); - deviceChannelService.batchAddChannel(deviceChannels); - } - } - - private void executeSaveForDelete(){ - if (deleteChannelList.size() > 0) { - deviceChannelService.deleteChannels(deleteChannelList); - deleteChannelList.clear(); - } - } - - private void executeSaveForOnline(){ - if (updateChannelOnlineList.size() > 0) { - deviceChannelService.channelsOnline(updateChannelOnlineList); - updateChannelOnlineList.clear(); - } - } - - private void executeSaveForOffline(){ - if (updateChannelOfflineList.size() > 0) { - deviceChannelService.channelsOffline(updateChannelOfflineList); - updateChannelOfflineList.clear(); - } - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java deleted file mode 100644 index d35c6a63..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ /dev/null @@ -1,397 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.CivilCodeFileConf; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.FromHeader; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * SIP命令类型: NOTIFY请求,这是作为上级发送订阅请求后,设备才会响应的 - */ -@Component -public class NotifyRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - - private final static Logger logger = LoggerFactory.getLogger(NotifyRequestProcessor.class); - - @Autowired - private UserSetting userSetting; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private EventPublisher eventPublisher; - - @Autowired - private SipConfig sipConfig; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private EventPublisher publisher; - - private final String method = "NOTIFY"; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Autowired - private IDeviceChannelService deviceChannelService; - - @Autowired - private NotifyRequestForCatalogProcessor notifyRequestForCatalogProcessor; - - @Autowired - private CivilCodeFileConf civilCodeFileConf; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - private int maxQueueCount = 30000; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addRequestProcessor(method, this); - } - - @Override - public void process(RequestEvent evt) { - try { - - if (taskQueue.size() >= userSetting.getMaxNotifyCountQueue()) { - responseAck((SIPRequest) evt.getRequest(), Response.BUSY_HERE, null, null); - logger.error("[notify] 待处理消息队列已满 {},返回486 BUSY_HERE,消息不做处理", userSetting.getMaxNotifyCountQueue()); - return; - }else { - responseAck((SIPRequest) evt.getRequest(), Response.OK, null, null); - } - - }catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); - } - boolean runed = !taskQueue.isEmpty(); - logger.info("[notify] 待处理消息数量: {}", taskQueue.size()); - taskQueue.offer(new HandlerCatchData(evt, null, null)); - if (!runed) { - taskExecutor.execute(()-> { - while (!taskQueue.isEmpty()) { - try { - HandlerCatchData take = taskQueue.poll(); - if (take == null) { - continue; - } - Element rootElement = getRootElement(take.getEvt()); - if (rootElement == null) { - logger.error("处理NOTIFY消息时未获取到消息体,{}", take.getEvt().getRequest()); - continue; - } - String cmd = XmlUtil.getText(rootElement, "CmdType"); - - if (CmdType.CATALOG.equals(cmd)) { - logger.info("接收到Catalog通知"); - notifyRequestForCatalogProcessor.process(take.getEvt()); - } else if (CmdType.ALARM.equals(cmd)) { - logger.info("接收到Alarm通知"); - processNotifyAlarm(take.getEvt()); - } else if (CmdType.MOBILE_POSITION.equals(cmd)) { - logger.info("接收到MobilePosition通知"); - processNotifyMobilePosition(take.getEvt()); - } else { - logger.info("接收到消息:" + cmd); - } - } catch (DocumentException e) { - logger.error("处理NOTIFY消息时错误", e); - } - } - }); - } - } - - /** - * 处理MobilePosition移动位置Notify - * - * @param evt - */ - private void processNotifyMobilePosition(RequestEvent evt) { - try { - FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); - String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader); - - // 回复 200 OK - Element rootElement = getRootElement(evt); - if (rootElement == null) { - logger.error("处理MobilePosition移动位置Notify时未获取到消息体,{}", evt.getRequest()); - return; - } - - MobilePosition mobilePosition = new MobilePosition(); - mobilePosition.setCreateTime(DateUtil.getNow()); - - Element deviceIdElement = rootElement.element("DeviceID"); - String channelId = deviceIdElement.getTextTrim().toString(); - Device device = redisCatchStorage.getDevice(deviceId); - - if (device == null) { - device = redisCatchStorage.getDevice(channelId); - if (device == null) { - // 根据通道id查询设备Id - List deviceList = deviceChannelService.getDeviceByChannelId(channelId); - if (deviceList.size() > 0) { - device = deviceList.get(0); - } - } - } - if (device == null) { - logger.warn("[mobilePosition移动位置Notify] 未找到通道{}所属的设备", channelId); - return; - } - if (!ObjectUtils.isEmpty(device.getName())) { - mobilePosition.setDeviceName(device.getName()); - } - - mobilePosition.setDeviceId(device.getDeviceId()); - mobilePosition.setChannelId(channelId); - String time = XmlUtil.getText(rootElement, "Time"); - if (ObjectUtils.isEmpty(time)){ - mobilePosition.setTime(DateUtil.getNow()); - }else { - mobilePosition.setTime(SipUtils.parseTime(time)); - } - - mobilePosition.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude"))); - mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude"))); - if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) { - mobilePosition.setSpeed(Double.parseDouble(XmlUtil.getText(rootElement, "Speed"))); - } else { - mobilePosition.setSpeed(0.0); - } - if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Direction"))) { - mobilePosition.setDirection(Double.parseDouble(XmlUtil.getText(rootElement, "Direction"))); - } else { - mobilePosition.setDirection(0.0); - } - if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Altitude"))) { - mobilePosition.setAltitude(Double.parseDouble(XmlUtil.getText(rootElement, "Altitude"))); - } else { - mobilePosition.setAltitude(0.0); - } - logger.info("[收到移动位置订阅通知]:{}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(), - mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setReportSource("Mobile Position"); - - - // 更新device channel 的经纬度 - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(device.getDeviceId()); - deviceChannel.setChannelId(channelId); - deviceChannel.setLongitude(mobilePosition.getLongitude()); - deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setGpsTime(mobilePosition.getTime()); - deviceChannel = deviceChannelService.updateGps(deviceChannel, device); - - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } - - storager.updateChannelPosition(deviceChannel); - - // 发送redis消息。 通知位置信息的变化 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); - jsonObject.put("serial", deviceId); - jsonObject.put("code", channelId); - jsonObject.put("longitude", mobilePosition.getLongitude()); - jsonObject.put("latitude", mobilePosition.getLatitude()); - jsonObject.put("altitude", mobilePosition.getAltitude()); - jsonObject.put("direction", mobilePosition.getDirection()); - jsonObject.put("speed", mobilePosition.getSpeed()); - redisCatchStorage.sendMobilePositionMsg(jsonObject); - } catch (DocumentException e) { - logger.error("未处理的异常 ", e); - } - } - - /*** - * 处理alarm设备报警Notify - * - * @param evt - */ - private void processNotifyAlarm(RequestEvent evt) { - if (!sipConfig.isAlarm()) { - return; - } - try { - FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); - String deviceId = SipUtils.getUserIdFromFromHeader(fromHeader); - - Element rootElement = getRootElement(evt); - if (rootElement == null) { - logger.error("处理alarm设备报警Notify时未获取到消息体{}", evt.getRequest()); - return; - } - Element deviceIdElement = rootElement.element("DeviceID"); - String channelId = deviceIdElement.getText().toString(); - - Device device = redisCatchStorage.getDevice(deviceId); - if (device == null) { - logger.warn("[ NotifyAlarm ] 未找到设备:{}", deviceId); - return; - } - rootElement = getRootElement(evt, device.getCharset()); - if (rootElement == null) { - logger.warn("[ NotifyAlarm ] content cannot be null, {}", evt.getRequest()); - return; - } - DeviceAlarm deviceAlarm = new DeviceAlarm(); - deviceAlarm.setDeviceId(deviceId); - deviceAlarm.setAlarmPriority(XmlUtil.getText(rootElement, "AlarmPriority")); - deviceAlarm.setAlarmMethod(XmlUtil.getText(rootElement, "AlarmMethod")); - String alarmTime = XmlUtil.getText(rootElement, "AlarmTime"); - if (alarmTime == null) { - logger.warn("[ NotifyAlarm ] AlarmTime cannot be null"); - return; - } - deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime)); - if (XmlUtil.getText(rootElement, "AlarmDescription") == null) { - deviceAlarm.setAlarmDescription(""); - } else { - deviceAlarm.setAlarmDescription(XmlUtil.getText(rootElement, "AlarmDescription")); - } - if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Longitude"))) { - deviceAlarm.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude"))); - } else { - deviceAlarm.setLongitude(0.00); - } - if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Latitude"))) { - deviceAlarm.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude"))); - } else { - deviceAlarm.setLatitude(0.00); - } - logger.info("[收到Notify-Alarm]:{}/{}", device.getDeviceId(), deviceAlarm.getChannelId()); - if ("4".equals(deviceAlarm.getAlarmMethod())) { - MobilePosition mobilePosition = new MobilePosition(); - mobilePosition.setChannelId(channelId); - mobilePosition.setCreateTime(DateUtil.getNow()); - mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); - mobilePosition.setTime(deviceAlarm.getAlarmTime()); - mobilePosition.setLongitude(deviceAlarm.getLongitude()); - mobilePosition.setLatitude(deviceAlarm.getLatitude()); - mobilePosition.setReportSource("GPS Alarm"); - - // 更新device channel 的经纬度 - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(device.getDeviceId()); - deviceChannel.setChannelId(channelId); - deviceChannel.setLongitude(mobilePosition.getLongitude()); - deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setGpsTime(mobilePosition.getTime()); - - deviceChannel = deviceChannelService.updateGps(deviceChannel, device); - - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } - - storager.updateChannelPosition(deviceChannel); - // 发送redis消息。 通知位置信息的变化 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); - jsonObject.put("serial", deviceChannel.getDeviceId()); - jsonObject.put("code", deviceChannel.getChannelId()); - jsonObject.put("longitude", mobilePosition.getLongitude()); - jsonObject.put("latitude", mobilePosition.getLatitude()); - jsonObject.put("altitude", mobilePosition.getAltitude()); - jsonObject.put("direction", mobilePosition.getDirection()); - jsonObject.put("speed", mobilePosition.getSpeed()); - redisCatchStorage.sendMobilePositionMsg(jsonObject); - - } - // TODO: 需要实现存储报警信息、报警分类 - - // 回复200 OK - if (redisCatchStorage.deviceIsOnline(deviceId)) { - publisher.deviceAlarmEventPublish(deviceAlarm); - } - } catch (DocumentException e) { - logger.error("未处理的异常 ", e); - } - } - - public void setCmder(SIPCommander cmder) { - } - - public void setStorager(IVideoManagerStorage storager) { - this.storager = storager; - } - - public void setPublisher(EventPublisher publisher) { - this.publisher = publisher; - } - - public void setRedis(RedisUtil redis) { - } - - public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) { - } - - public IRedisCatchStorage getRedisCatchStorage() { - return redisCatchStorage; - } - - public void setRedisCatchStorage(IRedisCatchStorage redisCatchStorage) { - this.redisCatchStorage = redisCatchStorage; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java deleted file mode 100644 index 761781c0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ /dev/null @@ -1,238 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.auth.DigestServerAuthenticationHelper; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo; -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; -import com.genersoft.iot.vmp.gb28181.bean.GbSipDate; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.utils.DateUtil; -import gov.nist.javax.sip.RequestEventExt; -import gov.nist.javax.sip.address.AddressImpl; -import gov.nist.javax.sip.address.SipUri; -import gov.nist.javax.sip.header.SIPDateHeader; -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.AuthorizationHeader; -import javax.sip.header.ContactHeader; -import javax.sip.header.FromHeader; -import javax.sip.header.ViaHeader; -import javax.sip.message.Request; -import javax.sip.message.Response; -import java.security.NoSuchAlgorithmException; -import java.text.ParseException; -import java.util.Calendar; -import java.util.Locale; - -/** - * SIP命令类型: REGISTER请求 - */ -@Component -public class RegisterRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - private final Logger logger = LoggerFactory.getLogger(RegisterRequestProcessor.class); - - public final String method = "REGISTER"; - - @Autowired - private SipConfig sipConfig; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private SIPSender sipSender; - - @Autowired - private UserSetting userSetting; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addRequestProcessor(method, this); - } - - /** - * 收到注册请求 处理 - * - * @param evt - */ - @Override - public void process(RequestEvent evt) { - try { - RequestEventExt evtExt = (RequestEventExt) evt; - - SIPRequest request = (SIPRequest)evt.getRequest(); - Response response = null; - boolean passwordCorrect = false; - // 注册标志 - boolean registerFlag = true; - if (request.getExpires().getExpires() == 0) { - // 注销成功 - registerFlag = false; - } - FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME); - AddressImpl address = (AddressImpl) fromHeader.getAddress(); - SipUri uri = (SipUri) address.getURI(); - String deviceId = uri.getUser(); - - Device device = deviceService.getDevice(deviceId); - - RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request, - userSetting.getSipUseSourceIpAsRemoteAddress()); - String requestAddress = remoteAddressInfo.getIp() + ":" + remoteAddressInfo.getPort(); - String title = registerFlag ? "[注册请求]": "[注销请求]"; - logger.info(title + "设备:{}, 开始处理: {}", deviceId, requestAddress); - if (device != null && - device.getSipTransactionInfo() != null && - request.getCallIdHeader().getCallId().equals(device.getSipTransactionInfo().getCallId())) { - logger.info(title + "设备:{}, 注册续订: {}",device.getDeviceId(), device.getDeviceId()); - device.setExpires(request.getExpires().getExpires()); - device.setIp(remoteAddressInfo.getIp()); - device.setPort(remoteAddressInfo.getPort()); - device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); - device.setLocalIp(request.getLocalAddress().getHostAddress()); - Response registerOkResponse = getRegisterOkResponse(request); - // 判断TCP还是UDP - ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); - String transport = reqViaHeader.getTransport(); - device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP"); - sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), registerOkResponse); - device.setRegisterTime(DateUtil.getNow()); - SipTransactionInfo sipTransactionInfo = new SipTransactionInfo((SIPResponse)registerOkResponse); - deviceService.online(device, sipTransactionInfo); - return; - } - String password = (device != null && !ObjectUtils.isEmpty(device.getPassword()))? device.getPassword() : sipConfig.getPassword(); - AuthorizationHeader authHead = (AuthorizationHeader) request.getHeader(AuthorizationHeader.NAME); - if (authHead == null && !ObjectUtils.isEmpty(password)) { - logger.info(title + " 设备:{}, 回复401: {}",deviceId, requestAddress); - response = getMessageFactory().createResponse(Response.UNAUTHORIZED, request); - new DigestServerAuthenticationHelper().generateChallenge(getHeaderFactory(), response, sipConfig.getDomain()); - sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); - return; - } - - // 校验密码是否正确 - passwordCorrect = ObjectUtils.isEmpty(password) || - new DigestServerAuthenticationHelper().doAuthenticatePlainTextPassword(request, password); - - if (!passwordCorrect) { - // 注册失败 - response = getMessageFactory().createResponse(Response.FORBIDDEN, request); - response.setReasonPhrase("wrong password"); - logger.info(title + " 设备:{}, 密码/SIP服务器ID错误, 回复403: {}", deviceId, requestAddress); - sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); - return; - } - - // 携带授权头并且密码正确 - response = getMessageFactory().createResponse(Response.OK, request); - // 添加date头 - SIPDateHeader dateHeader = new SIPDateHeader(); - // 使用自己修改的 - GbSipDate gbSipDate = new GbSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis()); - dateHeader.setDate(gbSipDate); - response.addHeader(dateHeader); - - if (request.getExpires() == null) { - response = getMessageFactory().createResponse(Response.BAD_REQUEST, request); - sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); - return; - } - // 添加Contact头 - response.addHeader(request.getHeader(ContactHeader.NAME)); - // 添加Expires头 - response.addHeader(request.getExpires()); - - if (device == null) { - device = new Device(); - device.setStreamMode("UDP"); - device.setCharset("GB2312"); - device.setGeoCoordSys("WGS84"); - device.setDeviceId(deviceId); - device.setOnLine(false); - }else { - if (ObjectUtils.isEmpty(device.getStreamMode())) { - device.setStreamMode("UDP"); - } - if (ObjectUtils.isEmpty(device.getCharset())) { - device.setCharset("GB2312"); - } - if (ObjectUtils.isEmpty(device.getGeoCoordSys())) { - device.setGeoCoordSys("WGS84"); - } - } - - device.setIp(remoteAddressInfo.getIp()); - device.setPort(remoteAddressInfo.getPort()); - device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); - device.setLocalIp(request.getLocalAddress().getHostAddress()); - if (request.getExpires().getExpires() == 0) { - // 注销成功 - registerFlag = false; - } else { - // 注册成功 - device.setExpires(request.getExpires().getExpires()); - registerFlag = true; - // 判断TCP还是UDP - ViaHeader reqViaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME); - String transport = reqViaHeader.getTransport(); - device.setTransport("TCP".equalsIgnoreCase(transport) ? "TCP" : "UDP"); - } - - sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); - // 注册成功 - // 保存到redis - if (registerFlag) { - logger.info("[注册成功] deviceId: {}->{}", deviceId, requestAddress); - device.setRegisterTime(DateUtil.getNow()); - SipTransactionInfo sipTransactionInfo = new SipTransactionInfo((SIPResponse)response); - deviceService.online(device, sipTransactionInfo); - } else { - logger.info("[注销成功] deviceId: {}->{}" ,deviceId, requestAddress); - deviceService.offline(deviceId, "主动注销"); - } - } catch (SipException | NoSuchAlgorithmException | ParseException e) { - logger.error("未处理的异常 ", e); - } - } - - private Response getRegisterOkResponse(Request request) throws ParseException { - // 携带授权头并且密码正确 - Response response = getMessageFactory().createResponse(Response.OK, request); - // 添加date头 - SIPDateHeader dateHeader = new SIPDateHeader(); - // 使用自己修改的 - GbSipDate gbSipDate = new GbSipDate(Calendar.getInstance(Locale.ENGLISH).getTimeInMillis()); - dateHeader.setDate(gbSipDate); - response.addHeader(dateHeader); - - // 添加Contact头 - response.addHeader(request.getHeader(ContactHeader.NAME)); - // 添加Expires头 - response.addHeader(request.getExpires()); - - return response; - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java deleted file mode 100644 index 8aa3b0df..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; - -import com.genersoft.iot.vmp.gb28181.bean.CmdType; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; -import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import gov.nist.javax.sip.message.SIPResponse; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.ExpiresHeader; -import javax.sip.message.Response; -import java.text.ParseException; - -/** - * SIP命令类型: SUBSCRIBE请求 - * @author lin - */ -@Component -public class SubscribeRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - private final Logger logger = LoggerFactory.getLogger(SubscribeRequestProcessor.class); - private final String method = "SUBSCRIBE"; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SubscribeHolder subscribeHolder; - - @Autowired - private SIPSender sipSender; - - - @Autowired - private IPlatformService platformService; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addRequestProcessor(method, this); - } - - /** - * 处理SUBSCRIBE请求 - * - * @param evt 事件 - */ - @Override - public void process(RequestEvent evt) { - SIPRequest request = (SIPRequest) evt.getRequest(); - try { - Element rootElement = getRootElement(evt); - if (rootElement == null) { - logger.error("处理SUBSCRIBE请求 未获取到消息体{}", evt.getRequest()); - return; - } - String cmd = XmlUtil.getText(rootElement, "CmdType"); - if (CmdType.MOBILE_POSITION.equals(cmd)) { - processNotifyMobilePosition(request, rootElement); -// } else if (CmdType.ALARM.equals(cmd)) { -// logger.info("接收到Alarm订阅"); -// processNotifyAlarm(serverTransaction, rootElement); - } else if (CmdType.CATALOG.equals(cmd)) { - processNotifyCatalogList(request, rootElement); - } else { - logger.info("接收到消息:" + cmd); - - Response response = getMessageFactory().createResponse(200, request); - if (response != null) { - ExpiresHeader expireHeader = getHeaderFactory().createExpiresHeader(30); - response.setExpires(expireHeader); - } - logger.info("response : " + response); - sipSender.transmitRequest(request.getLocalAddress().getHostAddress(), response); - } - } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { - logger.error("未处理的异常 ", e); - } - - } - - /** - * 处理移动位置订阅消息 - */ - private void processNotifyMobilePosition(SIPRequest request, Element rootElement) throws SipException { - if (request == null) { - return; - } - String platformId = SipUtils.getUserIdFromFromHeader(request); - String deviceId = XmlUtil.getText(rootElement, "DeviceID"); - ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); - SubscribeInfo subscribeInfo = new SubscribeInfo(request, platformId); - if (platform == null) { - return; - } - - String sn = XmlUtil.getText(rootElement, "SN"); - logger.info("[回复上级的移动位置订阅请求]: {}", platformId); - StringBuilder resultXml = new StringBuilder(200); - resultXml.append("\r\n") - .append("\r\n") - .append("MobilePosition\r\n") - .append("").append(sn).append("\r\n") - .append("").append(deviceId).append("\r\n") - .append("OK\r\n") - .append("\r\n"); - - if (subscribeInfo.getExpires() > 0) { - // GPS上报时间间隔 - String interval = XmlUtil.getText(rootElement, "Interval"); - if (interval == null) { - subscribeInfo.setGpsInterval(5); - }else { - subscribeInfo.setGpsInterval(Integer.parseInt(interval)); - } - subscribeInfo.setSn(sn); - } - - try { - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); - SIPResponse response = responseXmlAck(request, resultXml.toString(), parentPlatform, subscribeInfo.getExpires()); - if (subscribeInfo.getExpires() == 0) { - subscribeHolder.removeMobilePositionSubscribe(platformId); - }else { - subscribeInfo.setResponse(response); - subscribeHolder.putMobilePositionSubscribe(platformId, subscribeInfo); - } - - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); - } - } - - private void processNotifyAlarm(RequestEvent evt, Element rootElement) { - - } - - private void processNotifyCatalogList(SIPRequest request, Element rootElement) throws SipException { - if (request == null) { - return; - } - String platformId = SipUtils.getUserIdFromFromHeader(request); - String deviceId = XmlUtil.getText(rootElement, "DeviceID"); - ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); - if (platform == null){ - return; - } - SubscribeInfo subscribeInfo = new SubscribeInfo(request, platformId); - - String sn = XmlUtil.getText(rootElement, "SN"); - logger.info("[回复上级的目录订阅请求]: {}/{}", platformId, deviceId); - StringBuilder resultXml = new StringBuilder(200); - resultXml.append("\r\n") - .append("\r\n") - .append("Catalog\r\n") - .append("").append(sn).append("\r\n") - .append("").append(deviceId).append("\r\n") - .append("OK\r\n") - .append("\r\n"); - - if (subscribeInfo.getExpires() > 0) { - subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); - }else if (subscribeInfo.getExpires() == 0) { - subscribeHolder.removeCatalogSubscribe(platformId); - } - try { - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(platformId); - SIPResponse response = responseXmlAck(request, resultXml.toString(), parentPlatform, subscribeInfo.getExpires()); - if (subscribeInfo.getExpires() == 0) { - subscribeHolder.removeCatalogSubscribe(platformId); - }else { - subscribeInfo.setResponse(response); - subscribeHolder.putCatalogSubscribe(platformId, subscribeInfo); - } - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("未处理的异常 ", e); - } - if (subscribeHolder.getCatalogSubscribe(platformId) == null && platform.isAutoPushChannel()) { - platformService.addSimulatedSubscribeInfo(platform); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java deleted file mode 100644 index c794fdb2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java +++ /dev/null @@ -1,149 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.info; - -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.CallIdHeader; -import javax.sip.header.ContentTypeHeader; -import javax.sip.message.Response; -import java.text.ParseException; - -@Component -public class InfoRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - private final static Logger logger = LoggerFactory.getLogger(InfoRequestProcessor.class); - - private final String method = "INFO"; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Autowired - private IVideoManagerStorage storage; - - @Autowired - private SipSubscribe sipSubscribe; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommander cmder; - - @Autowired - private VideoStreamSessionManager sessionManager; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addRequestProcessor(method, this); - } - - @Override - public void process(RequestEvent evt) { - logger.debug("接收到消息:" + evt.getRequest()); - SIPRequest request = (SIPRequest) evt.getRequest(); - String deviceId = SipUtils.getUserIdFromFromHeader(request); - CallIdHeader callIdHeader = request.getCallIdHeader(); - // 先从会话内查找 - SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); - - // 兼容海康 媒体通知 消息from字段不是设备ID的问题 - if (ssrcTransaction != null) { - deviceId = ssrcTransaction.getDeviceId(); - } - // 查询设备是否存在 - Device device = redisCatchStorage.getDevice(deviceId); - // 查询上级平台是否存在 - ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId); - try { - if (device != null && parentPlatform != null) { - logger.warn("[重复]平台与设备编号重复:{}", deviceId); - String hostAddress = request.getRemoteAddress().getHostAddress(); - int remotePort = request.getRemotePort(); - if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) { - parentPlatform = null; - }else { - device = null; - } - } - if (device == null && parentPlatform == null) { - // 不存在则回复404 - responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found"); - logger.warn("[设备未找到 ]: {}", deviceId); - if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){ - DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog()); - deviceNotFoundEvent.setCallId(callIdHeader.getCallId()); - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(deviceNotFoundEvent); - sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult); - }; - }else { - ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME); - String contentType = header.getContentType(); - String contentSubType = header.getContentSubType(); - if ("Application".equalsIgnoreCase(contentType) && "MANSRTSP".equalsIgnoreCase(contentSubType)) { - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, null, null, callIdHeader.getCallId()); - String streamId = sendRtpItem.getStreamId(); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId); - if (null == inviteInfo) { - responseAck(request, Response.NOT_FOUND, "stream " + streamId + " not found"); - return; - } - Device device1 = storager.queryVideoDevice(inviteInfo.getDeviceId()); - if (inviteInfo.getStreamInfo() != null) { - cmder.playbackControlCmd(device1,inviteInfo.getStreamInfo(),new String(evt.getRequest().getRawContent()),eventResult -> { - // 失败的回复 - try { - responseAck(request, eventResult.statusCode, eventResult.msg); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage()); - } - }, eventResult -> { - // 成功的回复 - try { - responseAck(request, eventResult.statusCode); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 录像控制: {}", e.getMessage()); - } - }); - } - - } - } - } catch (SipException e) { - logger.warn("SIP 回复错误", e); - } catch (InvalidArgumentException e) { - logger.warn("参数无效", e); - } catch (ParseException e) { - logger.warn("SIP回复时解析异常", e); - } - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/IMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/IMessageHandler.java deleted file mode 100644 index 7eba0d52..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/IMessageHandler.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import org.dom4j.Element; - -import javax.sip.RequestEvent; - -public interface IMessageHandler { - /** - * 处理来自设备的信息 - * @param evt - * @param device - */ - void handForDevice(RequestEvent evt, Device device, Element element); - - /** - * 处理来自平台的信息 - * @param evt - * @param parentPlatform - */ - void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java deleted file mode 100644 index 6dcefa72..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageHandlerAbstract.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd.CatalogQueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.dom4j.Element; -import org.springframework.beans.factory.annotation.Autowired; - -import javax.sip.RequestEvent; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -public abstract class MessageHandlerAbstract extends SIPRequestProcessorParent implements IMessageHandler{ - - public Map messageHandlerMap = new ConcurrentHashMap<>(); - - @Autowired - private IVideoManagerStorage storage; - - public void addHandler(String cmdType, IMessageHandler messageHandler) { - messageHandlerMap.put(cmdType, messageHandler); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - String cmd = getText(element, "CmdType"); - IMessageHandler messageHandler = messageHandlerMap.get(cmd); - - if (messageHandler != null) { - //两个国标平台互相级联时由于上一步判断导致本该在平台处理的消息 放到了设备的处理逻辑 - //所以对目录查询单独做了校验 - if(messageHandler instanceof CatalogQueryMessageHandler){ - ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(device.getDeviceId()); - messageHandler.handForPlatform(evt, parentPlatform, element); - return; - } - messageHandler.handForDevice(evt, device, element); - } - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - String cmd = getText(element, "CmdType"); - IMessageHandler messageHandler = messageHandlerMap.get(cmd); - if (messageHandler != null) { - messageHandler.handForPlatform(evt, parentPlatform, element); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java deleted file mode 100644 index 0c23acea..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceNotFoundEvent; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.CallIdHeader; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -@Component -public class MessageRequestProcessor extends SIPRequestProcessorParent implements InitializingBean, ISIPRequestProcessor { - - private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); - - private final String method = "MESSAGE"; - - private static Map messageHandlerMap = new ConcurrentHashMap<>(); - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Autowired - private IVideoManagerStorage storage; - - @Autowired - private SipSubscribe sipSubscribe; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private VideoStreamSessionManager sessionManager; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addRequestProcessor(method, this); - } - - public void addHandler(String name, IMessageHandler handler) { - messageHandlerMap.put(name, handler); - } - - @Override - public void process(RequestEvent evt) { - SIPRequest sipRequest = (SIPRequest)evt.getRequest(); -// logger.info("接收到消息:" + evt.getRequest()); - String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); - CallIdHeader callIdHeader = sipRequest.getCallIdHeader(); - // 先从会话内查找 - SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); - // 兼容海康 媒体通知 消息from字段不是设备ID的问题 - if (ssrcTransaction != null) { - deviceId = ssrcTransaction.getDeviceId(); - } - SIPRequest request = (SIPRequest) evt.getRequest(); - // 查询设备是否存在 - Device device = redisCatchStorage.getDevice(deviceId); - // 查询上级平台是否存在 - ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(deviceId); - try { - if (device != null && parentPlatform != null) { - String hostAddress = request.getRemoteAddress().getHostAddress(); - int remotePort = request.getRemotePort(); - if (device.getHostAddress().equals(hostAddress + ":" + remotePort)) { - parentPlatform = null; - }else { - device = null; - } - } - if (device == null && parentPlatform == null) { - // 不存在则回复404 - responseAck(request, Response.NOT_FOUND, "device "+ deviceId +" not found"); - logger.warn("[设备未找到 ]deviceId: {}, callId: {}", deviceId, callIdHeader.getCallId()); - if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){ - DeviceNotFoundEvent deviceNotFoundEvent = new DeviceNotFoundEvent(evt.getDialog()); - deviceNotFoundEvent.setCallId(callIdHeader.getCallId()); - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(deviceNotFoundEvent); - sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult); - }; - }else { - Element rootElement = null; - try { - rootElement = getRootElement(evt); - if (rootElement == null) { - logger.error("处理MESSAGE请求 未获取到消息体{}", evt.getRequest()); - responseAck(request, Response.BAD_REQUEST, "content is null"); - return; - } - } catch (DocumentException e) { - logger.warn("解析XML消息内容异常", e); - // 不存在则回复404 - responseAck(request, Response.BAD_REQUEST, e.getMessage()); - } - String name = rootElement.getName(); - IMessageHandler messageHandler = messageHandlerMap.get(name); - if (messageHandler != null) { - if (device != null) { - messageHandler.handForDevice(evt, device, rootElement); - }else { // 由于上面已经判断都为null则直接返回,所以这里device和parentPlatform必有一个不为null - messageHandler.handForPlatform(evt, parentPlatform, rootElement); - } - }else { - // 不支持的message - // 不存在则回复415 - responseAck(request, Response.UNSUPPORTED_MEDIA_TYPE, "Unsupported message type, must Control/Notify/Query/Response"); - } - } - } catch (SipException e) { - logger.warn("SIP 回复错误", e); - } catch (InvalidArgumentException e) { - logger.warn("参数无效", e); - } catch (ParseException e) { - logger.warn("SIP回复时解析异常", e); - } - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/ControlMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/ControlMessageHandler.java deleted file mode 100644 index 235a4770..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/ControlMessageHandler.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control; - -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.MessageHandlerAbstract; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.MessageRequestProcessor; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * 命令类型: 控制命令 - * 命令类型: 设备控制: 远程启动, 录像控制(TODO), 报警布防/撤防命令(TODO), 报警复位命令(TODO), - * 强制关键帧命令(TODO), 拉框放大/缩小控制命令(TODO), 看守位控制(TODO), 报警复位(TODO) - * 命令类型: 设备配置: SVAC编码配置(TODO), 音频参数(TODO), SVAC解码配置(TODO) - */ -@Component -public class ControlMessageHandler extends MessageHandlerAbstract implements InitializingBean { - - private final String messageType = "Control"; - - @Autowired - private MessageRequestProcessor messageRequestProcessor; - - @Override - public void afterPropertiesSet() throws Exception { - messageRequestProcessor.addHandler(messageType, this); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java deleted file mode 100644 index b2dd76b5..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ /dev/null @@ -1,358 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.cmd; - -import com.genersoft.iot.vmp.common.enums.DeviceControlType; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DragZoomRequest; -import com.genersoft.iot.vmp.gb28181.bean.HomePositionRequest; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.*; -import javax.sip.address.SipURI; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.List; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.*; - -@Component -public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(DeviceControlQueryMessageHandler.class); - private final String cmdType = "DeviceControl"; - - @Autowired - private ControlMessageHandler controlMessageHandler; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommander cmder; - - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Override - public void afterPropertiesSet() throws Exception { - controlMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - SIPRequest request = (SIPRequest) evt.getRequest(); - - // 此处是上级发出的DeviceControl指令 - String targetGBId = ((SipURI) request.getToHeader().getAddress().getURI()).getUser(); - String channelId = getText(rootElement, "DeviceID"); - // 远程启动功能 - if (!ObjectUtils.isEmpty(getText(rootElement, "TeleBoot"))) { - // TODO 拒绝远程启动命令 - logger.warn("[国标级联]收到平台的远程启动命令, 不处理"); - -// if (parentPlatform.getServerGBId().equals(targetGBId)) { -// // 远程启动本平台:需要在重新启动程序后先对SipStack解绑 -// logger.info("执行远程启动本平台命令"); -// try { -// cmderFroPlatform.unregister(parentPlatform, null, null); -// } catch (InvalidArgumentException | ParseException | SipException e) { -// logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); -// } -// taskExecutor.execute(() -> { -// // 远程启动 -//// try { -//// Thread.sleep(3000); -//// SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); -//// SipStackImpl stack = (SipStackImpl)up.getSipStack(); -//// stack.stop(); -//// Iterator listener = stack.getListeningPoints(); -//// while (listener.hasNext()) { -//// stack.deleteListeningPoint((ListeningPoint) listener.next()); -//// } -//// Iterator providers = stack.getSipProviders(); -//// while (providers.hasNext()) { -//// stack.deleteSipProvider((SipProvider) providers.next()); -//// } -//// VManageBootstrap.restart(); -//// } catch (InterruptedException | ObjectInUseException e) { -//// logger.error("[任务执行失败] 服务重启: {}", e.getMessage()); -//// } -// }); -// } - } - DeviceControlType deviceControlType = DeviceControlType.typeOf(rootElement); - logger.info("[接受deviceControl命令] 命令: {}", deviceControlType); - if (!ObjectUtils.isEmpty(deviceControlType) && !parentPlatform.getServerGBId().equals(targetGBId)) { - //判断是否存在该通道 - Device deviceForPlatform = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); - if (deviceForPlatform == null) { - try { - responseAck(request, Response.NOT_FOUND); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 错误信息: {}", e.getMessage()); - } - return; - } - switch (deviceControlType) { - case PTZ: - handlePtzCmd(deviceForPlatform, channelId, rootElement, request, DeviceControlType.PTZ); - break; - case ALARM: - handleAlarmCmd(deviceForPlatform, rootElement, request); - break; - case GUARD: - handleGuardCmd(deviceForPlatform, rootElement, request, DeviceControlType.GUARD); - break; - case RECORD: - handleRecordCmd(deviceForPlatform, channelId, rootElement, request, DeviceControlType.RECORD); - break; - case I_FRAME: - handleIFameCmd(deviceForPlatform, request, channelId); - break; - case TELE_BOOT: - handleTeleBootCmd(deviceForPlatform, request); - break; - case DRAG_ZOOM_IN: - handleDragZoom(deviceForPlatform, channelId, rootElement, request, DeviceControlType.DRAG_ZOOM_IN); - break; - case DRAG_ZOOM_OUT: - handleDragZoom(deviceForPlatform, channelId, rootElement, request, DeviceControlType.DRAG_ZOOM_OUT); - break; - case HOME_POSITION: - handleHomePositionCmd(deviceForPlatform, channelId, rootElement, request, DeviceControlType.HOME_POSITION); - break; - default: - break; - } - } - } - - /** - * 处理云台指令 - * - * @param device 设备 - * @param channelId 通道id - * @param rootElement - * @param request - */ - private void handlePtzCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) { - String cmdString = getText(rootElement, type.getVal()); - try { - cmder.fronEndCmd(device, channelId, cmdString, - errorResult -> onError(request, errorResult), - okResult -> onOk(request, okResult)); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 云台/前端: {}", e.getMessage()); - } - } - - /** - * 处理强制关键帧 - * - * @param device 设备 - * @param channelId 通道id - */ - private void handleIFameCmd(Device device, SIPRequest request, String channelId) { - try { - cmder.iFrameCmd(device, channelId); - responseAck(request, Response.OK); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage()); - } - } - - /** - * 处理重启命令 - * - * @param device 设备信息 - */ - private void handleTeleBootCmd(Device device, SIPRequest request) { - try { - cmder.teleBootCmd(device); - responseAck(request, Response.OK); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 重启: {}", e.getMessage()); - } - - } - - /** - * 处理拉框控制*** - * - * @param device 设备信息 - * @param channelId 通道id - * @param rootElement 根节点 - * @param type 消息类型 - */ - private void handleDragZoom(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) { - try { - DragZoomRequest dragZoomRequest = loadElement(rootElement, DragZoomRequest.class); - DragZoomRequest.DragZoom dragZoom = dragZoomRequest.getDragZoomIn(); - if (dragZoom == null) { - dragZoom = dragZoomRequest.getDragZoomOut(); - } - StringBuffer cmdXml = new StringBuffer(200); - cmdXml.append("<" + type.getVal() + ">\r\n"); - cmdXml.append("" + dragZoom.getLength() + "\r\n"); - cmdXml.append("" + dragZoom.getWidth() + "\r\n"); - cmdXml.append("" + dragZoom.getMidPointX() + "\r\n"); - cmdXml.append("" + dragZoom.getMidPointY() + "\r\n"); - cmdXml.append("" + dragZoom.getLengthX() + "\r\n"); - cmdXml.append("" + dragZoom.getLengthY() + "\r\n"); - cmdXml.append("\r\n"); - cmder.dragZoomCmd(device, channelId, cmdXml.toString()); - responseAck(request, Response.OK); - } catch (Exception e) { - logger.error("[命令发送失败] 拉框控制: {}", e.getMessage()); - } - - } - - /** - * 处理看守位命令*** - * - * @param device 设备信息 - * @param channelId 通道id - * @param rootElement 根节点 - * @param request 请求信息 - * @param type 消息类型 - */ - private void handleHomePositionCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) { - try { - HomePositionRequest homePosition = loadElement(rootElement, HomePositionRequest.class); - //获取整个消息主体,我们只需要修改请求头即可 - HomePositionRequest.HomePosition info = homePosition.getHomePosition(); - cmder.homePositionCmd(device, channelId, info.getEnabled(), info.getResetTime(), info.getPresetIndex(), - errorResult -> onError(request, errorResult), - okResult -> onOk(request, okResult)); - } catch (Exception e) { - logger.error("[命令发送失败] 看守位设置: {}", e.getMessage()); - } - } - - /** - * 处理告警消息*** - * - * @param device 设备信息 - * @param rootElement 根节点 - * @param request 请求信息 - */ - private void handleAlarmCmd(Device device, Element rootElement, SIPRequest request) { - //告警方法 - String alarmMethod = ""; - //告警类型 - String alarmType = ""; - List info = rootElement.elements("Info"); - if (info != null) { - for (Element element : info) { - alarmMethod = getText(element, "AlarmMethod"); - alarmType = getText(element, "AlarmType"); - } - } - try { - cmder.alarmCmd(device, alarmMethod, alarmType, - errorResult -> onError(request, errorResult), - okResult -> onOk(request, okResult)); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 告警消息: {}", e.getMessage()); - } - } - - /** - * 处理录像控制 - * - * @param device 设备信息 - * @param channelId 通道id - * @param rootElement 根节点 - * @param request 请求信息 - * @param type 消息类型 - */ - private void handleRecordCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) { - //获取整个消息主体,我们只需要修改请求头即可 - String cmdString = getText(rootElement, type.getVal()); - try { - cmder.recordCmd(device, channelId, cmdString, - errorResult -> onError(request, errorResult), - okResult -> onOk(request, okResult)); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 录像控制: {}", e.getMessage()); - } - } - - /** - * 处理报警布防/撤防命令 - * - * @param device 设备信息 - * @param rootElement 根节点 - * @param request 请求信息 - * @param type 消息类型 - */ - private void handleGuardCmd(Device device, Element rootElement, SIPRequest request, DeviceControlType type) { - //获取整个消息主体,我们只需要修改请求头即可 - String cmdString = getText(rootElement, type.getVal()); - try { - cmder.guardCmd(device, cmdString, - errorResult -> onError(request, errorResult), - okResult -> onOk(request, okResult)); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage()); - } - } - - - /** - * 错误响应处理 - * - * @param request 请求 - * @param eventResult 响应结构 - */ - private void onError(SIPRequest request, SipSubscribe.EventResult eventResult) { - // 失败的回复 - try { - responseAck(request, eventResult.statusCode, eventResult.msg); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 回复: {}", e.getMessage()); - } - } - - /** - * 成功响应处理 - * - * @param request 请求 - * @param eventResult 响应结构 - */ - private void onOk(SIPRequest request, SipSubscribe.EventResult eventResult) { - // 成功的回复 - try { - responseAck(request, eventResult.statusCode); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 回复: {}", e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/NotifyMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/NotifyMessageHandler.java deleted file mode 100644 index bb34189e..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/NotifyMessageHandler.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify; - -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.MessageHandlerAbstract; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.MessageRequestProcessor; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * 命令类型: 通知命令, 参看 A.2.5 通知命令 - * 命令类型: 状态信息(心跳)报送, 报警通知, 媒体通知, 移动设备位置数据,语音广播通知(TODO), 设备预置位(TODO) - * @author lin - */ -@Component -public class NotifyMessageHandler extends MessageHandlerAbstract implements InitializingBean { - - private final String messageType = "Notify"; - - @Autowired - private MessageRequestProcessor messageRequestProcessor; - - @Override - public void afterPropertiesSet() throws Exception { - messageRequestProcessor.addHandler(messageType, this); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java deleted file mode 100644 index 2fc7ae0e..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ /dev/null @@ -1,284 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.service.IDeviceAlarmService; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.concurrent.ConcurrentLinkedQueue; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -/** - * 报警事件的处理,参考:9.4 - */ -@Component -public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private final Logger logger = LoggerFactory.getLogger(AlarmNotifyMessageHandler.class); - private final String cmdType = "Alarm"; - - @Autowired - private NotifyMessageHandler notifyMessageHandler; - - @Autowired - private EventPublisher publisher; - - @Autowired - private UserSetting userSetting; - - @Autowired - private SipConfig sipConfig; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IDeviceAlarmService deviceAlarmService; - - @Autowired - private IDeviceChannelService deviceChannelService; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - - @Override - public void afterPropertiesSet() throws Exception { - notifyMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - logger.info("[收到报警通知]设备:{}", device.getDeviceId()); - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(new SipMsgInfo(evt, device, rootElement)); - // 回复200 OK - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 报警通知回复: {}", e.getMessage()); - } - if (isEmpty) { - taskExecutor.execute(() -> { - logger.info("[处理报警通知]待处理数量:{}", taskQueue.size() ); - while (!taskQueue.isEmpty()) { - try { - SipMsgInfo sipMsgInfo = taskQueue.poll(); - - Element deviceIdElement = sipMsgInfo.getRootElement().element("DeviceID"); - String channelId = deviceIdElement.getText().toString(); - - DeviceAlarm deviceAlarm = new DeviceAlarm(); - deviceAlarm.setCreateTime(DateUtil.getNow()); - deviceAlarm.setDeviceId(sipMsgInfo.getDevice().getDeviceId()); - deviceAlarm.setChannelId(channelId); - deviceAlarm.setAlarmPriority(getText(sipMsgInfo.getRootElement(), "AlarmPriority")); - deviceAlarm.setAlarmMethod(getText(sipMsgInfo.getRootElement(), "AlarmMethod")); - String alarmTime = XmlUtil.getText(sipMsgInfo.getRootElement(), "AlarmTime"); - if (alarmTime == null) { - continue; - } - deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime)); - String alarmDescription = getText(sipMsgInfo.getRootElement(), "AlarmDescription"); - if (alarmDescription == null) { - deviceAlarm.setAlarmDescription(""); - } else { - deviceAlarm.setAlarmDescription(alarmDescription); - } - String longitude = getText(sipMsgInfo.getRootElement(), "Longitude"); - if (longitude != null && NumericUtil.isDouble(longitude)) { - deviceAlarm.setLongitude(Double.parseDouble(longitude)); - } else { - deviceAlarm.setLongitude(0.00); - } - String latitude = getText(sipMsgInfo.getRootElement(), "Latitude"); - if (latitude != null && NumericUtil.isDouble(latitude)) { - deviceAlarm.setLatitude(Double.parseDouble(latitude)); - } else { - deviceAlarm.setLatitude(0.00); - } - - if (!ObjectUtils.isEmpty(deviceAlarm.getAlarmMethod())) { - if ( deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.GPS.getVal() + "")) { - MobilePosition mobilePosition = new MobilePosition(); - mobilePosition.setCreateTime(DateUtil.getNow()); - mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); - mobilePosition.setChannelId(channelId); - mobilePosition.setTime(deviceAlarm.getAlarmTime()); - mobilePosition.setLongitude(deviceAlarm.getLongitude()); - mobilePosition.setLatitude(deviceAlarm.getLatitude()); - mobilePosition.setReportSource("GPS Alarm"); - - // 更新device channel 的经纬度 - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(sipMsgInfo.getDevice().getDeviceId()); - deviceChannel.setChannelId(channelId); - deviceChannel.setLongitude(mobilePosition.getLongitude()); - deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setGpsTime(mobilePosition.getTime()); - - deviceChannel = deviceChannelService.updateGps(deviceChannel, sipMsgInfo.getDevice()); - - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } - storager.updateChannelPosition(deviceChannel); - - // 发送redis消息。 通知位置信息的变化 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); - jsonObject.put("serial", deviceChannel.getDeviceId()); - jsonObject.put("code", deviceChannel.getChannelId()); - jsonObject.put("longitude", mobilePosition.getLongitude()); - jsonObject.put("latitude", mobilePosition.getLatitude()); - jsonObject.put("altitude", mobilePosition.getAltitude()); - jsonObject.put("direction", mobilePosition.getDirection()); - jsonObject.put("speed", mobilePosition.getSpeed()); - redisCatchStorage.sendMobilePositionMsg(jsonObject); - } - } - if (!ObjectUtils.isEmpty(deviceAlarm.getDeviceId())) { - if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) { - deviceAlarm.setAlarmType(getText(sipMsgInfo.getRootElement().element("Info"), "AlarmType")); - } - } - logger.info("[收到报警通知]内容:{}", JSON.toJSONString(deviceAlarm)); - // 作者自用判断,其他小伙伴需要此消息可以自行修改,但是不要提在pr里 - if (DeviceAlarmMethod.Other.getVal() == Integer.parseInt(deviceAlarm.getAlarmMethod())) { - // 发送给平台的报警信息。 发送redis通知 - logger.info("[发送给平台的报警信息]内容:{}", JSONObject.toJSONString(deviceAlarm)); - AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage(); - if (deviceAlarm.getAlarmMethod() != null) { - alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); - } - alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); - if (deviceAlarm.getAlarmType() != null) { - alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); - } - alarmChannelMessage.setGbId(channelId); - redisCatchStorage.sendAlarmMsg(alarmChannelMessage); - continue; - } - - logger.debug("存储报警信息、报警分类"); - // 存储报警信息、报警分类 - if (sipConfig.isAlarm()) { - deviceAlarmService.add(deviceAlarm); - } - - if (redisCatchStorage.deviceIsOnline(sipMsgInfo.getDevice().getDeviceId())) { - publisher.deviceAlarmEventPublish(deviceAlarm); - } - }catch (Exception e) { - logger.error("未处理的异常 ", e); - logger.warn("[收到报警通知] 发现未处理的异常, {}\r\n{}",e.getMessage(), evt.getRequest()); - } - } - }); - } - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - logger.info("收到来自平台[{}]的报警通知", parentPlatform.getServerGBId()); - // 回复200 OK - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 报警通知回复: {}", e.getMessage()); - } - Element deviceIdElement = rootElement.element("DeviceID"); - String channelId = deviceIdElement.getText().toString(); - - - DeviceAlarm deviceAlarm = new DeviceAlarm(); - deviceAlarm.setCreateTime(DateUtil.getNow()); - deviceAlarm.setDeviceId(parentPlatform.getServerGBId()); - deviceAlarm.setChannelId(channelId); - deviceAlarm.setAlarmPriority(getText(rootElement, "AlarmPriority")); - deviceAlarm.setAlarmMethod(getText(rootElement, "AlarmMethod")); - String alarmTime = XmlUtil.getText(rootElement, "AlarmTime"); - if (alarmTime == null) { - return; - } - deviceAlarm.setAlarmTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(alarmTime)); - String alarmDescription = getText(rootElement, "AlarmDescription"); - if (alarmDescription == null) { - deviceAlarm.setAlarmDescription(""); - } else { - deviceAlarm.setAlarmDescription(alarmDescription); - } - String longitude = getText(rootElement, "Longitude"); - if (longitude != null && NumericUtil.isDouble(longitude)) { - deviceAlarm.setLongitude(Double.parseDouble(longitude)); - } else { - deviceAlarm.setLongitude(0.00); - } - String latitude = getText(rootElement, "Latitude"); - if (latitude != null && NumericUtil.isDouble(latitude)) { - deviceAlarm.setLatitude(Double.parseDouble(latitude)); - } else { - deviceAlarm.setLatitude(0.00); - } - - if (!ObjectUtils.isEmpty(deviceAlarm.getAlarmMethod())) { - - if (deviceAlarm.getAlarmMethod().contains(DeviceAlarmMethod.Video.getVal() + "")) { - deviceAlarm.setAlarmType(getText(rootElement.element("Info"), "AlarmType")); - } - } - - if (channelId.equals(parentPlatform.getDeviceGBId())) { - // 发送给平台的报警信息。 发送redis通知 - AlarmChannelMessage alarmChannelMessage = new AlarmChannelMessage(); - if (deviceAlarm.getAlarmMethod() != null) { - alarmChannelMessage.setAlarmSn(Integer.parseInt(deviceAlarm.getAlarmMethod())); - } - alarmChannelMessage.setAlarmDescription(deviceAlarm.getAlarmDescription()); - alarmChannelMessage.setGbId(channelId); - if (deviceAlarm.getAlarmType() != null) { - alarmChannelMessage.setAlarmType(Integer.parseInt(deviceAlarm.getAlarmType())); - } - redisCatchStorage.sendAlarmMsg(alarmChannelMessage); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java deleted file mode 100644 index 389e4013..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; - -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.utils.DateUtil; -import gov.nist.javax.sip.message.SIPRequest; -import org.apache.commons.lang3.ObjectUtils; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; - -/** - * 状态信息(心跳)报送 - */ -@Component -public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - - private final Logger logger = LoggerFactory.getLogger(KeepaliveNotifyMessageHandler.class); - private final static String cmdType = "Keepalive"; - - @Autowired - private NotifyMessageHandler notifyMessageHandler; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private UserSetting userSetting; - - @Autowired - private DynamicTask dynamicTask; - - @Override - public void afterPropertiesSet() throws Exception { - notifyMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - if (device == null) { - // 未注册的设备不做处理 - return; - } - SIPRequest request = (SIPRequest) evt.getRequest(); - logger.info("[收到心跳] device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); - - // 回复200 OK - try { - responseAck(request, Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 心跳回复: {}", e.getMessage()); - } - if (!ObjectUtils.isEmpty(device.getKeepaliveTime()) && DateUtil.getDifferenceForNow(device.getKeepaliveTime()) <= 3000L) { - logger.info("[收到心跳] 心跳发送过于频繁,已忽略 device: {}, callId: {}", device.getDeviceId(), request.getCallIdHeader().getCallId()); - return; - } - - RemoteAddressInfo remoteAddressInfo = SipUtils.getRemoteAddressFromRequest(request, userSetting.getSipUseSourceIpAsRemoteAddress()); - if (!device.getIp().equalsIgnoreCase(remoteAddressInfo.getIp()) || device.getPort() != remoteAddressInfo.getPort()) { - logger.info("[心跳] 设备{}地址变化, 远程地址为: {}:{}", device.getDeviceId(), remoteAddressInfo.getIp(), remoteAddressInfo.getPort()); - device.setPort(remoteAddressInfo.getPort()); - device.setHostAddress(remoteAddressInfo.getIp().concat(":").concat(String.valueOf(remoteAddressInfo.getPort()))); - device.setIp(remoteAddressInfo.getIp()); - // 设备地址变化会引起目录订阅任务失效,需要重新添加 - if (device.getSubscribeCycleForCatalog() > 0) { - deviceService.removeCatalogSubscribe(device); - deviceService.addCatalogSubscribe(device); - } - } - if (device.getKeepaliveTime() == null) { - device.setKeepaliveIntervalTime(60); - }else { - long lastTime = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(device.getKeepaliveTime()); - if (System.currentTimeMillis()/1000-lastTime > 10) { - device.setKeepaliveIntervalTime(Long.valueOf(System.currentTimeMillis()/1000-lastTime).intValue()); - } - } - - device.setKeepaliveTime(DateUtil.getNow()); - - if (device.isOnLine()) { - deviceService.updateDevice(device); - }else { - // 对于已经离线的设备判断他的注册是否已经过期 - if (!deviceService.expire(device)){ - device.setOnLine(false); - deviceService.online(device, null); - } - } - // 刷新过期任务 - String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId(); - // 如果三次心跳失败,则设置设备离线 - dynamicTask.startDelay(registerExpireTaskKey, ()-> deviceService.offline(device.getDeviceId(), "三次心跳失败"), device.getKeepaliveIntervalTime()*1000*3); - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - // 个别平台保活不回复200OK会判定离线 - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 心跳回复: {}", e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java deleted file mode 100644 index fdcd5e4b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java +++ /dev/null @@ -1,136 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; - -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.CallIdHeader; -import javax.sip.message.Response; -import java.text.ParseException; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -/** - * 媒体通知 - */ -@Component -public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(MediaStatusNotifyMessageHandler.class); - private final String cmdType = "MediaStatus"; - - @Autowired - private NotifyMessageHandler notifyMessageHandler; - - @Autowired - private SIPCommander cmder; - - @Autowired - private SIPCommanderFroPlatform sipCommanderFroPlatform; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IVideoManagerStorage storage; - - @Autowired - private VideoStreamSessionManager sessionManager; - - @Autowired - private ZlmHttpHookSubscribe subscribe; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private VideoStreamSessionManager streamSession; - - @Override - public void afterPropertiesSet() throws Exception { - notifyMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - - // 回复200 OK - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 录像流推送完毕,回复200OK: {}", e.getMessage()); - } - CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); - String NotifyType =getText(rootElement, "NotifyType"); - if ("121".equals(NotifyType)){ - logger.info("[录像流]推送完毕,收到关流通知"); - - SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(null, null, callIdHeader.getCallId(), null); - if (ssrcTransaction != null) { - logger.info("[录像流]推送完毕,关流通知, device: {}, channelId: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); - InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream()); - if (inviteInfo.getStreamInfo() != null) { - inviteInfo.getStreamInfo().setProgress(1); - inviteStreamService.updateInviteInfo(inviteInfo); - } - - try { - cmder.streamByeCmd(device, ssrcTransaction.getChannelId(), null, callIdHeader.getCallId()); - } catch (InvalidArgumentException | ParseException | SsrcTransactionNotFoundException | SipException e) { - logger.error("[录像流]推送完毕,收到关流通知, 发送BYE失败 {}", e.getMessage()); - } - // 去除监听流注销自动停止下载的监听 - HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcTransaction.getStream(), false, "rtsp", ssrcTransaction.getMediaServerId()); - subscribe.removeSubscribe(hookSubscribe); - - // 如果级联播放,需要给上级发送此通知 TODO 多个上级同时观看一个下级 可能存在停错的问题,需要将点播CallId进行上下级绑定 - SendRtpItem sendRtpItem = redisCatchStorage.querySendRTPServer(null, ssrcTransaction.getChannelId(), null, null); - if (sendRtpItem != null) { - ParentPlatform parentPlatform = storage.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); - if (parentPlatform == null) { - logger.warn("[级联消息发送]:发送MediaStatus发现上级平台{}不存在", sendRtpItem.getPlatformId()); - return; - } - try { - sipCommanderFroPlatform.sendMediaStatusNotify(parentPlatform, sendRtpItem); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 录像播放完毕: {}", e.getMessage()); - } - } - }else { - logger.info("[录像流]推送完毕,关流通知, 但是未找到对应的下载信息"); - } - } - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java deleted file mode 100644 index 9a82b8ab..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java +++ /dev/null @@ -1,172 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.concurrent.ConcurrentLinkedQueue; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -/** - * 移动设备位置数据通知,设备主动发起,不需要上级订阅 - */ -@Component -public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(MobilePositionNotifyMessageHandler.class); - private final String cmdType = "MobilePosition"; - - @Autowired - private NotifyMessageHandler notifyMessageHandler; - - @Autowired - private UserSetting userSetting; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IDeviceChannelService deviceChannelService; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Override - public void afterPropertiesSet() throws Exception { - notifyMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(new SipMsgInfo(evt, device, rootElement)); - // 回复200 OK - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 移动位置通知回复: {}", e.getMessage()); - } - if (isEmpty) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - SipMsgInfo sipMsgInfo = taskQueue.poll(); - try { - Element rootElementAfterCharset = getRootElement(sipMsgInfo.getEvt(), sipMsgInfo.getDevice().getCharset()); - if (rootElementAfterCharset == null) { - logger.warn("[移动位置通知] {}处理失败,未识别到信息体", device.getDeviceId()); - continue; - } - MobilePosition mobilePosition = new MobilePosition(); - mobilePosition.setCreateTime(DateUtil.getNow()); - if (!ObjectUtils.isEmpty(sipMsgInfo.getDevice().getName())) { - mobilePosition.setDeviceName(sipMsgInfo.getDevice().getName()); - } - mobilePosition.setDeviceId(sipMsgInfo.getDevice().getDeviceId()); - mobilePosition.setChannelId(getText(rootElementAfterCharset, "DeviceID")); - String time = getText(rootElementAfterCharset, "Time"); - if (ObjectUtils.isEmpty(time)){ - mobilePosition.setTime(DateUtil.getNow()); - }else { - mobilePosition.setTime(SipUtils.parseTime(time)); - } - mobilePosition.setLongitude(Double.parseDouble(getText(rootElementAfterCharset, "Longitude"))); - mobilePosition.setLatitude(Double.parseDouble(getText(rootElementAfterCharset, "Latitude"))); - if (NumericUtil.isDouble(getText(rootElementAfterCharset, "Speed"))) { - mobilePosition.setSpeed(Double.parseDouble(getText(rootElementAfterCharset, "Speed"))); - } else { - mobilePosition.setSpeed(0.0); - } - if (NumericUtil.isDouble(getText(rootElementAfterCharset, "Direction"))) { - mobilePosition.setDirection(Double.parseDouble(getText(rootElementAfterCharset, "Direction"))); - } else { - mobilePosition.setDirection(0.0); - } - if (NumericUtil.isDouble(getText(rootElementAfterCharset, "Altitude"))) { - mobilePosition.setAltitude(Double.parseDouble(getText(rootElementAfterCharset, "Altitude"))); - } else { - mobilePosition.setAltitude(0.0); - } - mobilePosition.setReportSource("Mobile Position"); - - - // 更新device channel 的经纬度 - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(sipMsgInfo.getDevice().getDeviceId()); - deviceChannel.setChannelId(mobilePosition.getChannelId()); - deviceChannel.setLongitude(mobilePosition.getLongitude()); - deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setGpsTime(mobilePosition.getTime()); - - deviceChannel = deviceChannelService.updateGps(deviceChannel, sipMsgInfo.getDevice()); - - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } - storager.updateChannelPosition(deviceChannel); - - // 发送redis消息。 通知位置信息的变化 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); - jsonObject.put("serial", deviceChannel.getDeviceId()); - jsonObject.put("code", deviceChannel.getChannelId()); - jsonObject.put("longitude", mobilePosition.getLongitude()); - jsonObject.put("latitude", mobilePosition.getLatitude()); - jsonObject.put("altitude", mobilePosition.getAltitude()); - jsonObject.put("direction", mobilePosition.getDirection()); - jsonObject.put("speed", mobilePosition.getSpeed()); - redisCatchStorage.sendMobilePositionMsg(jsonObject); - - } catch (DocumentException e) { - logger.error("未处理的异常 ", e); - } catch (Exception e) { - logger.warn("[移动位置通知] 发现未处理的异常, \r\n{}", evt.getRequest()); - logger.error("[移动位置通知] 异常内容: ", e); - } - } - }); - } - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/QueryMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/QueryMessageHandler.java deleted file mode 100644 index 9a29955c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/QueryMessageHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query; - -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.MessageHandlerAbstract; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.MessageRequestProcessor; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * 命令类型: 查询指令 - * 命令类型: 设备状态, 设备目录信息, 设备信息, 文件目录检索(TODO), 报警(TODO), 设备配置(TODO), 设备预置位(TODO), 移动设备位置数据(TODO) - */ -@Component -public class QueryMessageHandler extends MessageHandlerAbstract implements InitializingBean { - - private final String messageType = "Query"; - - @Autowired - private MessageRequestProcessor messageRequestProcessor; - - @Override - public void afterPropertiesSet() throws Exception { - messageRequestProcessor.addHandler(messageType, this); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java deleted file mode 100644 index ce8c9397..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; - -@Component -public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(AlarmQueryMessageHandler.class); - private final String cmdType = "Alarm"; - - @Autowired - private QueryMessageHandler queryMessageHandler; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private SipConfig config; - - @Autowired - private EventPublisher publisher; - - @Override - public void afterPropertiesSet() throws Exception { - queryMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - logger.info("不支持alarm查询"); - try { - responseAck((SIPRequest) evt.getRequest(), Response.NOT_FOUND, "not support alarm query"); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 alarm查询回复200OK: {}", e.getMessage()); - } - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java deleted file mode 100644 index 25a3df37..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java +++ /dev/null @@ -1,130 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.FromHeader; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.List; - -@Component -public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(CatalogQueryMessageHandler.class); - private final String cmdType = "Catalog"; - - @Autowired - private QueryMessageHandler queryMessageHandler; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private SipConfig config; - - @Autowired - private EventPublisher publisher; - - @Autowired - private IVideoManagerStorage storage; - - @Override - public void afterPropertiesSet() throws Exception { - queryMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); - try { - // 回复200 OK - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 目录查询回复200OK: {}", e.getMessage()); - } - Element snElement = rootElement.element("SN"); - String sn = snElement.getText(); - // 准备回复通道信息 - List deviceChannelInPlatforms = storager.queryChannelWithCatalog(parentPlatform.getServerGBId()); - // 查询关联的直播通道 - List gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); - // 回复目录信息 - List catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); - - List allChannels = new ArrayList<>(); - - // 回复平台 -// DeviceChannel deviceChannel = getChannelForPlatform(parentPlatform); -// allChannels.add(deviceChannel); - - // 回复目录 - if (catalogs.size() > 0) { - allChannels.addAll(catalogs); - } - // 回复级联的通道 - if (deviceChannelInPlatforms.size() > 0) { - allChannels.addAll(deviceChannelInPlatforms); - } - // 回复直播的通道 - if (gbStreams.size() > 0) { - allChannels.addAll(gbStreams); - } - try { - if (allChannels.size() > 0) { - cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag()); - }else { - // 回复无通道 - cmderFroPlatform.catalogQuery(null, parentPlatform, sn, fromHeader.getTag(), 0); - } - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage()); - } - - - - } - - private DeviceChannel getChannelForPlatform(ParentPlatform platform) { - DeviceChannel deviceChannel = new DeviceChannel(); - - deviceChannel.setChannelId(platform.getDeviceGBId()); - deviceChannel.setName(platform.getName()); - deviceChannel.setManufacture("wvp-pro"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setCivilCode(platform.getAdministrativeDivision()); - deviceChannel.setAddress("wvp-pro"); - deviceChannel.setRegisterWay(0); - deviceChannel.setSecrecy("0"); - - return deviceChannel; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java deleted file mode 100644 index 8b774e10..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.FromHeader; -import javax.sip.message.Response; -import java.text.ParseException; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -@Component -public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(DeviceInfoQueryMessageHandler.class); - private final String cmdType = "DeviceInfo"; - - @Autowired - private QueryMessageHandler queryMessageHandler; - - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - @Autowired - private IVideoManagerStorage storager; - - @Override - public void afterPropertiesSet() throws Exception { - queryMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - logger.info("[DeviceInfo查询]消息"); - FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); - try { - // 回复200 OK - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); - return; - } - String sn = rootElement.element("SN").getText(); - - /*根据WVP原有的数据结构,设备和通道是分开放置,设备信息都是存放在设备表里,通道表里的设备信息不可作为真实信息处理 - 大部分NVR/IPC设备对他的通道信息实现都是返回默认的值没有什么参考价值。NVR/IPC通道我们统一使用设备表的设备信息来作为返回。 - 我们这里使用查询数据库的方式来实现这个设备信息查询的功能,在其他地方对设备信息更新达到正确的目的。*/ - - String channelId = getText(rootElement, "DeviceID"); - // 查询这是通道id还是设备id - Device device = null; - // 如果id指向平台的国标编号,那么就是查询平台的信息 - if (!parentPlatform.getDeviceGBId().equals(channelId)) { - device = storager.queryDeviceInfoByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); - if (device ==null){ - logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); - return; - } - } - try { - cmderFroPlatform.deviceInfoResponse(parentPlatform, device, sn, fromHeader.getTag()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java deleted file mode 100644 index f9edfb39..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.header.FromHeader; -import javax.sip.message.Response; -import java.text.ParseException; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -@Component -public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(DeviceStatusQueryMessageHandler.class); - private final String cmdType = "DeviceStatus"; - - @Autowired - private QueryMessageHandler queryMessageHandler; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private SipConfig config; - - @Autowired - private EventPublisher publisher; - - @Override - public void afterPropertiesSet() throws Exception { - queryMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - logger.info("接收到DeviceStatus查询消息"); - FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); - // 回复200 OK - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复200OK: {}", e.getMessage()); - } - String sn = rootElement.element("SN").getText(); - String channelId = getText(rootElement, "DeviceID"); - DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId); - if (deviceChannel ==null){ - logger.error("[平台没有该通道的使用权限]:platformId"+parentPlatform.getServerGBId()+" deviceID:"+channelId); - return; - } - try { - cmderFroPlatform.deviceStatusResponse(parentPlatform,channelId, sn, fromHeader.getTag(),deviceChannel.isStatus()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 DeviceStatus查询回复: {}", e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java deleted file mode 100644 index f3170a5d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.List; - -@Component -public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(RecordInfoQueryMessageHandler.class); - private final String cmdType = "RecordInfo"; - - @Autowired - private QueryMessageHandler queryMessageHandler; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private SIPCommander commander; - - @Autowired - private RecordEndEventListener recordEndEventListener; - - @Autowired - private SipConfig config; - - @Autowired - private EventPublisher publisher; - - @Override - public void afterPropertiesSet() throws Exception { - queryMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - SIPRequest request = (SIPRequest) evt.getRequest(); - Element snElement = rootElement.element("SN"); - int sn = Integer.parseInt(snElement.getText()); - Element deviceIDElement = rootElement.element("DeviceID"); - String channelId = deviceIDElement.getText(); - Element startTimeElement = rootElement.element("StartTime"); - String startTime = null; - if (startTimeElement != null) { - startTime = startTimeElement.getText(); - } - Element endTimeElement = rootElement.element("EndTime"); - String endTime = null; - if (endTimeElement != null) { - endTime = endTimeElement.getText(); - } - Element secrecyElement = rootElement.element("Secrecy"); - int secrecy = 0; - if (secrecyElement != null) { - secrecy = Integer.parseInt(secrecyElement.getText().trim()); - } - String type = "all"; - Element typeElement = rootElement.element("Type"); - if (typeElement != null) { - type = typeElement.getText(); - } - // 确认是直播还是国标, 国标直接请求下级,直播请求录像管理服务 - List channelSources = storager.getChannelSource(parentPlatform.getServerGBId(), channelId); - - if (channelSources.get(0).getCount() > 0) { // 国标 - // 向国标设备请求录像数据 - Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); - DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId); - // 接收录像数据 - recordEndEventListener.addEndEventHandler(deviceChannel.getDeviceId(), channelId, (recordInfo)->{ - try { - cmderFroPlatform.recordInfo(deviceChannel, parentPlatform, request.getFromTag(), recordInfo); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 回复录像数据: {}", e.getMessage()); - } - }); - try { - commander.recordInfoQuery(device, channelId, DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTime), - DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTime), sn, secrecy, type, (eventResult -> { - // 回复200 OK - try { - responseAck(request, Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 录像查询回复: {}", e.getMessage()); - } - }),(eventResult -> { - // 查询失败 - try { - responseAck(request, eventResult.statusCode, eventResult.msg); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 录像查询回复: {}", e.getMessage()); - } - })); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 录像查询: {}", e.getMessage()); - } - - }else if (channelSources.get(1).getCount() > 0) { // 直播流 - // TODO - try { - responseAck(request, Response.NOT_IMPLEMENTED); // 回复未实现 - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 录像查询: {}", e.getMessage()); - } - }else { // 错误的请求 - try { - responseAck(request, Response.BAD_REQUEST); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 录像查询: {}", e.getMessage()); - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/ResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/ResponseMessageHandler.java deleted file mode 100644 index 18da9cde..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/ResponseMessageHandler.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response; - -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.MessageHandlerAbstract; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.MessageRequestProcessor; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -/** - * 命令类型: 请求动作的应答 - * 命令类型: 设备控制, 报警通知, 设备目录信息查询, 目录信息查询, 目录收到, 设备信息查询, 设备状态信息查询 ...... - */ -@Component -public class ResponseMessageHandler extends MessageHandlerAbstract implements InitializingBean { - - private final String messageType = "Response"; - - @Autowired - private MessageRequestProcessor messageRequestProcessor; - - @Override - public void afterPropertiesSet() throws Exception { - messageRequestProcessor.addHandler(messageType, this); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java deleted file mode 100644 index 3edf02fe..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/AlarmResponseMessageHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.RequestEvent; - -@Component -public class AlarmResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(AlarmResponseMessageHandler.class); - private final String cmdType = "Alarm"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - Element deviceIdElement = rootElement.element("DeviceID"); - String channelId = deviceIdElement.getText().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_ALARM + device.getDeviceId() + channelId; - JSONObject json = new JSONObject(); - XmlUtil.node2Json(rootElement, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); - } - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setData(json); - deferredResultHolder.invokeAllResult(msg); - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java deleted file mode 100644 index 2e0d0716..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/BroadcastResponseMessageHandler.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -@Component -public class BroadcastResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(BroadcastResponseMessageHandler.class); - private final String cmdType = "Broadcast"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - try { - String channelId = getText(rootElement, "DeviceID"); - String key = DeferredResultHolder.CALLBACK_CMD_BROADCAST + device.getDeviceId() + channelId; - // 回复200 OK - responseAck((SIPRequest) evt.getRequest(), Response.OK); - // 此处是对本平台发出Broadcast指令的应答 - JSONObject json = new JSONObject(); - XmlUtil.node2Json(rootElement, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); - } - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setData(json); - deferredResultHolder.invokeAllResult(msg); - - - } catch (ParseException | SipException | InvalidArgumentException e) { - logger.error("[命令发送失败] 国标级联 语音喊话: {}", e.getMessage()); - } - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java deleted file mode 100644 index cc2eee81..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ /dev/null @@ -1,195 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.genersoft.iot.vmp.conf.CivilCodeFileConf; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.session.CatalogDataCatch; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; - -/** - * 目录查询的回复 - */ -@Component -public class CatalogResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(CatalogResponseMessageHandler.class); - private final String cmdType = "Catalog"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - private final ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private CatalogDataCatch catalogDataCatch; - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Autowired - private CivilCodeFileConf civilCodeFileConf; - - @Autowired - private SipConfig sipConfig; - private AtomicBoolean processing = new AtomicBoolean(false); - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - taskQueue.offer(new HandlerCatchData(evt, device, element)); - // 回复200 OK - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 目录查询回复: {}", e.getMessage()); - } - // 已经开启消息处理则跳过 - if (processing.compareAndSet(false, true)) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - // 全局异常捕获,保证下一条可以得到处理 - try { - HandlerCatchData take = taskQueue.poll(); - Element rootElement; - try { - rootElement = getRootElement(take.getEvt(), take.getDevice().getCharset()); - } catch (DocumentException e) { - logger.error("[xml解析] 失败: ", e); - continue; - } - if (rootElement == null) { - logger.warn("[ 收到通道 ] content cannot be null, {}", evt.getRequest()); - continue; - } - Element deviceListElement = rootElement.element("DeviceList"); - Element sumNumElement = rootElement.element("SumNum"); - Element snElement = rootElement.element("SN"); - int sumNum = Integer.parseInt(sumNumElement.getText()); - - if (sumNum == 0) { - logger.info("[收到通道]设备:{}的: 0个", take.getDevice().getDeviceId()); - // 数据已经完整接收 - storager.cleanChannelsForDevice(take.getDevice().getDeviceId()); - catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), null); - } else { - Iterator deviceListIterator = deviceListElement.elementIterator(); - if (deviceListIterator != null) { - List channelList = new ArrayList<>(); - List parentChannelIds = new ArrayList<>(); - // 遍历DeviceList - while (deviceListIterator.hasNext()) { - Element itemDevice = deviceListIterator.next(); - Element channelDeviceElement = itemDevice.element("DeviceID"); - if (channelDeviceElement == null) { - continue; - } - DeviceChannel channel = XmlUtil.channelContentHandler(itemDevice, device, null, civilCodeFileConf); - if (channel == null) { - logger.info("[收到目录订阅]:但是解析失败 {}", new String(evt.getRequest().getRawContent())); - continue; - } - if (channel.getParentId() != null && channel.getParentId().equals(sipConfig.getId())) { - channel.setParentId(null); - } - SipUtils.updateGps(channel, device.getGeoCoordSys()); - channel.setDeviceId(take.getDevice().getDeviceId()); - - channelList.add(channel); - } - int sn = Integer.parseInt(snElement.getText()); - catalogDataCatch.put(take.getDevice().getDeviceId(), sn, sumNum, take.getDevice(), channelList); - logger.info("[收到通道]设备: {} -> {}个,{}/{}", take.getDevice().getDeviceId(), channelList.size(), catalogDataCatch.get(take.getDevice().getDeviceId()) == null ? 0 : catalogDataCatch.get(take.getDevice().getDeviceId()).size(), sumNum); - if (catalogDataCatch.get(take.getDevice().getDeviceId()).size() == sumNum) { - // 数据已经完整接收, 此时可能存在某个设备离线变上线的情况,但是考虑到性能,此处不做处理, - // 目前支持设备通道上线通知时和设备上线时向上级通知 - try { - boolean resetChannelsResult = storager.resetChannels(take.getDevice().getDeviceId(), catalogDataCatch.get(take.getDevice().getDeviceId())); - if (!resetChannelsResult) { - String errorMsg = "接收成功,写入失败,共" + sumNum + "条,已接收" + catalogDataCatch.get(take.getDevice().getDeviceId()).size() + "条"; - catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), errorMsg); - } else { - catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), null); - } - } catch (Exception e) { - String errorMsg = "接收成功,写入失败,共" + sumNum + "条,已接收" + catalogDataCatch.get(take.getDevice().getDeviceId()).size() + "条"; - logger.error(errorMsg, e.getMessage(), e); - catalogDataCatch.setChannelSyncEnd(take.getDevice().getDeviceId(), errorMsg); - } - } - } - - } - } catch (Exception e) { - logger.warn("[收到通道] 发现未处理的异常, \r\n{}", evt.getRequest()); - logger.error("[收到通道] 异常内容: ", e); - } - } - processing.set(false); - }); - } - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - } - - public SyncStatus getChannelSyncProgress(String deviceId) { - if (catalogDataCatch.get(deviceId) == null) { - return null; - } else { - return catalogDataCatch.getSyncStatus(deviceId); - } - } - - public boolean isSyncRunning(String deviceId) { - if (catalogDataCatch.get(deviceId) == null) { - return false; - } else { - return catalogDataCatch.isSyncRunning(deviceId); - } - } - - public void setChannelSyncReady(Device device, int sn) { - catalogDataCatch.addReady(device, sn); - } - - public void setChannelSyncEnd(String deviceId, String errorMsg) { - catalogDataCatch.setChannelSyncEnd(deviceId, errorMsg); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java deleted file mode 100644 index 47ae1a9c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/ConfigDownloadResponseMessageHandler.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -@Component -public class ConfigDownloadResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(ConfigDownloadResponseMessageHandler.class); - private final String cmdType = "ConfigDownload"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private EventPublisher publisher; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - String channelId = getText(element, "DeviceID"); - String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + device.getDeviceId() + channelId; - try { - // 回复200 OK - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 设备配置查询: {}", e.getMessage()); - } - // 此处是对本平台发出DeviceControl指令的应答 - JSONObject json = new JSONObject(); - XmlUtil.node2Json(element, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); - } - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setData(json); - deferredResultHolder.invokeAllResult(msg); - - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - // 不会收到上级平台的心跳信息 - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java deleted file mode 100644 index b18a87b2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceConfigResponseMessageHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.RequestEvent; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -@Component -public class DeviceConfigResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(DeviceConfigResponseMessageHandler.class); - private final String cmdType = "DeviceConfig"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - JSONObject json = new JSONObject(); - XmlUtil.node2Json(element, json); - String channelId = getText(element, "DeviceID"); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); - } - String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONFIG + device.getDeviceId() + channelId; - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setData(json); - deferredResultHolder.invokeAllResult(msg); - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java deleted file mode 100644 index af08e13b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceControlResponseMessageHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; - -import java.text.ParseException; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -@Component -public class DeviceControlResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(DeviceControlResponseMessageHandler.class); - private final String cmdType = "DeviceControl"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - // 此处是对本平台发出DeviceControl指令的应答 - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 设备控制: {}", e.getMessage()); - } - JSONObject json = new JSONObject(); - String channelId = getText(element, "DeviceID"); - XmlUtil.node2Json(element, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); - } - RequestMessage msg = new RequestMessage(); - String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + device.getDeviceId() + channelId; - msg.setKey(key); - msg.setData(json); - deferredResultHolder.invokeAllResult(msg); - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java deleted file mode 100644 index 849be81f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.service.IDeviceService; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -/** - * @author lin - */ -@Component -public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(DeviceInfoResponseMessageHandler.class); - private final String cmdType = "DeviceInfo"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - - @Autowired - private IDeviceService deviceService; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - logger.debug("接收到DeviceInfo应答消息"); - // 检查设备是否存在, 不存在则不回复 - if (device == null || !device.isOnLine()) { - logger.warn("[接收到DeviceInfo应答消息,但是设备已经离线]:" + (device != null ? device.getDeviceId():"" )); - return; - } - SIPRequest request = (SIPRequest) evt.getRequest(); - try { - rootElement = getRootElement(evt, device.getCharset()); - - if (rootElement == null) { - logger.warn("[ 接收到DeviceInfo应答消息 ] content cannot be null, {}", evt.getRequest()); - try { - responseAck((SIPRequest) evt.getRequest(), Response.BAD_REQUEST); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] DeviceInfo应答消息 BAD_REQUEST: {}", e.getMessage()); - } - return; - } - Element deviceIdElement = rootElement.element("DeviceID"); - String channelId = deviceIdElement.getTextTrim(); - String key = DeferredResultHolder.CALLBACK_CMD_DEVICEINFO + device.getDeviceId() + channelId; - device.setName(getText(rootElement, "DeviceName")); - - device.setManufacturer(getText(rootElement, "Manufacturer")); - device.setModel(getText(rootElement, "Model")); - device.setFirmware(getText(rootElement, "Firmware")); - if (ObjectUtils.isEmpty(device.getStreamMode())) { - device.setStreamMode("UDP"); - } - deviceService.updateDevice(device); - - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setData(device); - deferredResultHolder.invokeAllResult(msg); - } catch (DocumentException e) { - throw new RuntimeException(e); - } - try { - // 回复200 OK - responseAck(request, Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] DeviceInfo应答消息 200: {}", e.getMessage()); - } - - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java deleted file mode 100644 index da4743f6..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceStatusResponseMessageHandler.java +++ /dev/null @@ -1,89 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; - -@Component -public class DeviceStatusResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(DeviceStatusResponseMessageHandler.class); - private final String cmdType = "DeviceStatus"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - logger.info("接收到DeviceStatus应答消息"); - // 检查设备是否存在, 不存在则不回复 - if (device == null) { - return; - } - // 回复200 OK - try { - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 设备状态应答回复200OK: {}", e.getMessage()); - } - Element deviceIdElement = element.element("DeviceID"); - Element onlineElement = element.element("Online"); - String channelId = deviceIdElement.getText(); - JSONObject json = new JSONObject(); - XmlUtil.node2Json(element, json); - if (logger.isDebugEnabled()) { - logger.debug(json.toJSONString()); - } - String text = onlineElement.getText(); - if ("ONLINE".equalsIgnoreCase(text.trim())) { - deviceService.online(device, null); - }else { - deviceService.offline(device.getDeviceId(), "设备状态查询结果:" + text.trim()); - } - RequestMessage msg = new RequestMessage(); - msg.setKey(DeferredResultHolder.CALLBACK_CMD_DEVICESTATUS + device.getDeviceId()); - msg.setData(json); - deferredResultHolder.invokeAllResult(msg); - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java deleted file mode 100644 index 36a72bcd..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -/** - * 移动设备位置数据查询回复 - * @author lin - */ -@Component -public class MobilePositionResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(MobilePositionResponseMessageHandler.class); - private final String cmdType = "MobilePosition"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private UserSetting userSetting; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IDeviceChannelService deviceChannelService; - - @Autowired - private DeferredResultHolder resultHolder; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - SIPRequest request = (SIPRequest) evt.getRequest(); - - try { - rootElement = getRootElement(evt, device.getCharset()); - if (rootElement == null) { - logger.warn("[ 移动设备位置数据查询回复 ] content cannot be null, {}", evt.getRequest()); - try { - responseAck(request, Response.BAD_REQUEST); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 移动设备位置数据查询 BAD_REQUEST: {}", e.getMessage()); - } - return; - } - MobilePosition mobilePosition = new MobilePosition(); - mobilePosition.setCreateTime(DateUtil.getNow()); - if (!ObjectUtils.isEmpty(device.getName())) { - mobilePosition.setDeviceName(device.getName()); - } - mobilePosition.setDeviceId(device.getDeviceId()); - mobilePosition.setChannelId(getText(rootElement, "DeviceID")); - //兼容ISO 8601格式时间 - String time = getText(rootElement, "Time"); - if (ObjectUtils.isEmpty(time)){ - mobilePosition.setTime(DateUtil.getNow()); - }else { - mobilePosition.setTime(SipUtils.parseTime(time)); - } - mobilePosition.setLongitude(Double.parseDouble(getText(rootElement, "Longitude"))); - mobilePosition.setLatitude(Double.parseDouble(getText(rootElement, "Latitude"))); - if (NumericUtil.isDouble(getText(rootElement, "Speed"))) { - mobilePosition.setSpeed(Double.parseDouble(getText(rootElement, "Speed"))); - } else { - mobilePosition.setSpeed(0.0); - } - if (NumericUtil.isDouble(getText(rootElement, "Direction"))) { - mobilePosition.setDirection(Double.parseDouble(getText(rootElement, "Direction"))); - } else { - mobilePosition.setDirection(0.0); - } - if (NumericUtil.isDouble(getText(rootElement, "Altitude"))) { - mobilePosition.setAltitude(Double.parseDouble(getText(rootElement, "Altitude"))); - } else { - mobilePosition.setAltitude(0.0); - } - mobilePosition.setReportSource("Mobile Position"); - - // 更新device channel 的经纬度 - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(device.getDeviceId()); - deviceChannel.setChannelId(mobilePosition.getChannelId()); - deviceChannel.setLongitude(mobilePosition.getLongitude()); - deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setGpsTime(mobilePosition.getTime()); - - deviceChannel = deviceChannelService.updateGps(deviceChannel, device); - - mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); - mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); - mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); - mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); - - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } - - storager.updateChannelPosition(deviceChannel); - - String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + device.getDeviceId(); - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setData(mobilePosition); - resultHolder.invokeAllResult(msg); - - // 发送redis消息。 通知位置信息的变化 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("time", DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(mobilePosition.getTime())); - jsonObject.put("serial", deviceChannel.getDeviceId()); - jsonObject.put("code", deviceChannel.getChannelId()); - jsonObject.put("longitude", mobilePosition.getLongitude()); - jsonObject.put("latitude", mobilePosition.getLatitude()); - jsonObject.put("altitude", mobilePosition.getAltitude()); - jsonObject.put("direction", mobilePosition.getDirection()); - jsonObject.put("speed", mobilePosition.getSpeed()); - redisCatchStorage.sendMobilePositionMsg(jsonObject); - //回复 200 OK - try { - responseAck(request, Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 移动设备位置数据查询 200: {}", e.getMessage()); - } - - } catch (DocumentException e) { - logger.error("未处理的异常 ", e); - } - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java deleted file mode 100644 index 862a8eea..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -/** - * 设备预置位查询应答 - */ -@Component -public class PresetQueryResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private Logger logger = LoggerFactory.getLogger(PresetQueryResponseMessageHandler.class); - private final String cmdType = "PresetQuery"; - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element element) { - - SIPRequest request = (SIPRequest) evt.getRequest(); - - try { - Element rootElement = getRootElement(evt, device.getCharset()); - - if (rootElement == null) { - logger.warn("[ 设备预置位查询应答 ] content cannot be null, {}", evt.getRequest()); - try { - responseAck(request, Response.BAD_REQUEST); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); - } - return; - } - Element presetListNumElement = rootElement.element("PresetList"); - Element snElement = rootElement.element("SN"); - //该字段可能为通道或则设备的id - String deviceId = getText(rootElement, "DeviceID"); - String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + deviceId; - if (snElement == null || presetListNumElement == null) { - try { - responseAck(request, Response.BAD_REQUEST, "xml error"); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); - } - return; - } - int sumNum = Integer.parseInt(presetListNumElement.attributeValue("Num")); - List presetQuerySipReqList = new ArrayList<>(); - if (sumNum > 0) { - for (Iterator presetIterator = presetListNumElement.elementIterator(); presetIterator.hasNext(); ) { - Element itemListElement = presetIterator.next(); - PresetQuerySipReq presetQuerySipReq = new PresetQuerySipReq(); - for (Iterator itemListIterator = itemListElement.elementIterator(); itemListIterator.hasNext(); ) { - // 遍历item - Element itemOne = itemListIterator.next(); - String name = itemOne.getName(); - String textTrim = itemOne.getTextTrim(); - if ("PresetID".equalsIgnoreCase(name)) { - presetQuerySipReq.setPresetId(textTrim); - } else { - presetQuerySipReq.setPresetName(textTrim); - } - } - presetQuerySipReqList.add(presetQuerySipReq); - } - } - RequestMessage requestMessage = new RequestMessage(); - requestMessage.setKey(key); - requestMessage.setData(presetQuerySipReqList); - deferredResultHolder.invokeAllResult(requestMessage); - try { - responseAck(request, Response.OK); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 设备预置位查询应答处理: {}", e.getMessage()); - } - } catch (DocumentException e) { - logger.error("[解析xml]失败: ", e); - } - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { - - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java deleted file mode 100644 index fc0fda8d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; - -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.utils.UJson; -import gov.nist.javax.sip.message.SIPRequest; -import org.dom4j.Element; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.SipException; -import javax.sip.message.Response; -import java.text.ParseException; -import java.util.*; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.TimeUnit; -import java.util.stream.Collectors; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; - -/** - * @author lin - */ -@Component -public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - - private final Logger logger = LoggerFactory.getLogger(RecordInfoResponseMessageHandler.class); - private final String cmdType = "RecordInfo"; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Autowired - private ResponseMessageHandler responseMessageHandler; - - @Autowired - private DeferredResultHolder deferredResultHolder; - - @Autowired - private EventPublisher eventPublisher; - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Autowired - private RedisTemplate redisTemplate; - - private Long recordInfoTtl = 1800L; - - @Override - public void afterPropertiesSet() throws Exception { - responseMessageHandler.addHandler(cmdType, this); - } - - @Override - public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - try { - // 回复200 OK - responseAck((SIPRequest) evt.getRequest(), Response.OK); - }catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 国标录像: {}", e.getMessage()); - } - taskExecutor.execute(()->{ - try { - String sn = getText(rootElement, "SN"); - String channelId = getText(rootElement, "DeviceID"); - RecordInfo recordInfo = new RecordInfo(); - recordInfo.setChannelId(channelId); - recordInfo.setDeviceId(device.getDeviceId()); - recordInfo.setSn(sn); - recordInfo.setName(getText(rootElement, "Name")); - String sumNumStr = getText(rootElement, "SumNum"); - int sumNum = 0; - if (!ObjectUtils.isEmpty(sumNumStr)) { - sumNum = Integer.parseInt(sumNumStr); - } - recordInfo.setSumNum(sumNum); - Element recordListElement = rootElement.element("RecordList"); - if (recordListElement == null || sumNum == 0) { - logger.info("无录像数据"); - recordInfo.setCount(sumNum); - eventPublisher.recordEndEventPush(recordInfo); - releaseRequest(device.getDeviceId(), sn,recordInfo); - } else { - Iterator recordListIterator = recordListElement.elementIterator(); - if (recordListIterator != null) { - List recordList = new ArrayList<>(); - // 遍历DeviceList - while (recordListIterator.hasNext()) { - Element itemRecord = recordListIterator.next(); - Element recordElement = itemRecord.element("DeviceID"); - if (recordElement == null) { - logger.info("记录为空,下一个..."); - continue; - } - RecordItem record = new RecordItem(); - record.setDeviceId(getText(itemRecord, "DeviceID")); - record.setName(getText(itemRecord, "Name")); - record.setFilePath(getText(itemRecord, "FilePath")); - record.setFileSize(getText(itemRecord, "FileSize")); - record.setAddress(getText(itemRecord, "Address")); - - String startTimeStr = getText(itemRecord, "StartTime"); - record.setStartTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTimeStr)); - - String endTimeStr = getText(itemRecord, "EndTime"); - record.setEndTime(DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTimeStr)); - - record.setSecrecy(itemRecord.element("Secrecy") == null ? 0 - : Integer.parseInt(getText(itemRecord, "Secrecy"))); - record.setType(getText(itemRecord, "Type")); - record.setRecorderId(getText(itemRecord, "RecorderID")); - recordList.add(record); - } - Map map = recordList.stream() - .filter(record -> record.getDeviceId() != null) - .collect(Collectors.toMap(record -> record.getStartTime()+ record.getEndTime(), UJson::writeJson)); - // 获取任务结果数据 - String resKey = VideoManagerConstants.REDIS_RECORD_INFO_RES_PRE + channelId + sn; - redisTemplate.opsForHash().putAll(resKey, map); - redisTemplate.expire(resKey, recordInfoTtl, TimeUnit.SECONDS); - String resCountKey = VideoManagerConstants.REDIS_RECORD_INFO_RES_COUNT_PRE + channelId + sn; - long incr = redisTemplate.opsForValue().increment(resCountKey, map.size()); - redisTemplate.expire(resCountKey, recordInfoTtl, TimeUnit.SECONDS); - recordInfo.setRecordList(recordList); - recordInfo.setCount(Math.toIntExact(incr)); - eventPublisher.recordEndEventPush(recordInfo); - if (incr < sumNum) { - return; - } - // 已接收完成 - List resList = redisTemplate.opsForHash().entries(resKey).values().stream().map(e -> UJson.readJson(e.toString(), RecordItem.class)).collect(Collectors.toList()); - if (resList.size() < sumNum) { - return; - } - recordInfo.setRecordList(resList); - releaseRequest(device.getDeviceId(), sn,recordInfo); - } - } - } catch (Exception e) { - logger.error("[国标录像] 发现未处理的异常, \r\n{}", evt.getRequest()); - logger.error("[国标录像] 异常内容: ", e); - } - }); - } - - @Override - public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element element) { - - } - - public void releaseRequest(String deviceId, String sn,RecordInfo recordInfo){ - String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn; - // 对数据进行排序 - if(recordInfo!=null && recordInfo.getRecordList()!=null) { - Collections.sort(recordInfo.getRecordList()); - }else{ - recordInfo.setRecordList(new ArrayList<>()); - } - - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setData(recordInfo); - deferredResultHolder.invokeAllResult(msg); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/ISIPResponseProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/ISIPResponseProcessor.java deleted file mode 100644 index 50fb2021..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/ISIPResponseProcessor.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.response; - -import javax.sip.ResponseEvent; - -/** - * @description:处理接收IPCamera发来的SIP协议响应消息 - * @author: swwheihei - * @date: 2020年5月3日 下午4:42:22 - */ -public interface ISIPResponseProcessor { - - void process(ResponseEvent evt); - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/SIPResponseProcessorAbstract.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/SIPResponseProcessorAbstract.java deleted file mode 100644 index 9f2a10b0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/SIPResponseProcessorAbstract.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.response; - -import org.springframework.beans.factory.InitializingBean; - -public abstract class SIPResponseProcessorAbstract implements InitializingBean, ISIPResponseProcessor { - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/ByeResponseProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/ByeResponseProcessor.java deleted file mode 100644 index ff63fad0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/ByeResponseProcessor.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.SipLayer; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.ResponseEvent; - -/** - * @description: BYE请求响应器 - * @author: swwheihei - * @date: 2020年5月3日 下午5:32:05 - */ -@Component -public class ByeResponseProcessor extends SIPResponseProcessorAbstract { - - private final String method = "BYE"; - - @Autowired - private SipLayer sipLayer; - - @Autowired - private SipConfig config; - - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addResponseProcessor(method, this); - } - /** - * 处理BYE响应 - * - * @param evt - */ - @Override - public void process(ResponseEvent evt) { - // TODO Auto-generated method stub - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/CancelResponseProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/CancelResponseProcessor.java deleted file mode 100644 index 775beeb6..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/CancelResponseProcessor.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; - -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.SipLayer; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.ResponseEvent; - -/** - * @description: CANCEL响应处理器 - * @author: panlinlin - * @date: 2021年11月5日 16:35 - */ -@Component -public class CancelResponseProcessor extends SIPResponseProcessorAbstract { - - private final String method = "CANCEL"; - - @Autowired - private SipLayer sipLayer; - - @Autowired - private SipConfig config; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addResponseProcessor(method, this); - } - /** - * 处理CANCEL响应 - * - * @param evt - */ - @Override - public void process(ResponseEvent evt) { - // TODO Auto-generated method stub - - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java deleted file mode 100644 index 436d2a43..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/InviteResponseProcessor.java +++ /dev/null @@ -1,96 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; - -import com.genersoft.iot.vmp.gb28181.SipLayer; -import com.genersoft.iot.vmp.gb28181.bean.Gb28181Sdp; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderProvider; -import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import gov.nist.javax.sip.ResponseEventExt; -import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sdp.SdpParseException; -import javax.sdp.SessionDescription; -import javax.sip.InvalidArgumentException; -import javax.sip.ResponseEvent; -import javax.sip.SipException; -import javax.sip.SipFactory; -import javax.sip.address.SipURI; -import javax.sip.message.Request; -import javax.sip.message.Response; -import java.text.ParseException; - - -/** - * @description: 处理INVITE响应 - * @author: panlinlin - * @date: 2021年11月5日 16:40 - */ -@Component -public class InviteResponseProcessor extends SIPResponseProcessorAbstract { - - private final static Logger logger = LoggerFactory.getLogger(InviteResponseProcessor.class); - private final String method = "INVITE"; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - - @Autowired - private SipLayer sipLayer; - - @Autowired - private SIPSender sipSender; - - @Autowired - private SIPRequestHeaderProvider headerProvider; - - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addResponseProcessor(method, this); - } - - - - /** - * 处理invite响应 - * - * @param evt 响应消息 - * @throws ParseException - */ - @Override - public void process(ResponseEvent evt ){ - logger.debug("接收到消息:" + evt.getResponse()); - try { - SIPResponse response = (SIPResponse)evt.getResponse(); - int statusCode = response.getStatusCode(); - // trying不会回复 - if (statusCode == Response.TRYING) { - } - // 成功响应 - // 下发ack - if (statusCode == Response.OK) { - ResponseEventExt event = (ResponseEventExt)evt; - - String contentString = new String(response.getRawContent()); - Gb28181Sdp gb28181Sdp = SipUtils.parseSDP(contentString); - SessionDescription sdp = gb28181Sdp.getBaseSdb(); - SipURI requestUri = SipFactory.getInstance().createAddressFactory().createSipURI(sdp.getOrigin().getUsername(), event.getRemoteIpAddress() + ":" + event.getRemotePort()); - Request reqAck = headerProvider.createAckRequest(response.getLocalAddress().getHostAddress(), requestUri, response); - - logger.info("[回复ack] {}-> {}:{} ", sdp.getOrigin().getUsername(), event.getRemoteIpAddress(), event.getRemotePort()); - sipSender.transmitRequest( response.getLocalAddress().getHostAddress(), reqAck); - } - } catch (InvalidArgumentException | ParseException | SipException | SdpParseException e) { - logger.info("[点播回复ACK],异常:", e ); - } - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java deleted file mode 100644 index edf2c680..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.response.impl; - -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; -import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; -import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.ResponseEvent; -import javax.sip.SipException; -import javax.sip.header.WWWAuthenticateHeader; -import javax.sip.message.Response; -import java.text.ParseException; - -/** - * @description:Register响应处理器 - * @author: swwheihei - * @date: 2020年5月3日 下午5:32:23 - */ -@Component -public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { - - private final Logger logger = LoggerFactory.getLogger(RegisterResponseProcessor.class); - private final String method = "REGISTER"; - - @Autowired - private ISIPCommanderForPlatform sipCommanderForPlatform; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private SIPProcessorObserver sipProcessorObserver; - - @Autowired - private SubscribeHolder subscribeHolder; - - @Autowired - private IPlatformService platformService; - - @Override - public void afterPropertiesSet() throws Exception { - // 添加消息处理的订阅 - sipProcessorObserver.addResponseProcessor(method, this); - } - - /** - * 处理Register响应 - * - * @param evt 事件 - */ - @Override - public void process(ResponseEvent evt) { - SIPResponse response = (SIPResponse)evt.getResponse(); - String callId = response.getCallIdHeader().getCallId(); - PlatformRegisterInfo platformRegisterInfo = redisCatchStorage.queryPlatformRegisterInfo(callId); - if (platformRegisterInfo == null) { - logger.info(String.format("[国标级联]未找到callId: %s 的注册/注销平台id", callId )); - return; - } - - ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(platformRegisterInfo.getPlatformId()); - if (parentPlatformCatch == null) { - logger.warn(String.format("[国标级联]收到注册/注销%S请求,平台:%s,但是平台缓存信息未查询到!!!", response.getStatusCode(),platformRegisterInfo.getPlatformId())); - return; - } - - String action = platformRegisterInfo.isRegister() ? "注册" : "注销"; - logger.info(String.format("[国标级联]%s %S响应,%s ", action, response.getStatusCode(), platformRegisterInfo.getPlatformId() )); - ParentPlatform parentPlatform = parentPlatformCatch.getParentPlatform(); - if (parentPlatform == null) { - logger.warn(String.format("[国标级联]收到 %s %s的%S请求, 但是平台信息未查询到!!!", platformRegisterInfo.getPlatformId(), action, response.getStatusCode())); - return; - } - - if (response.getStatusCode() == Response.UNAUTHORIZED) { - WWWAuthenticateHeader www = (WWWAuthenticateHeader)response.getHeader(WWWAuthenticateHeader.NAME); - SipTransactionInfo sipTransactionInfo = new SipTransactionInfo(response); - try { - sipCommanderForPlatform.register(parentPlatform, sipTransactionInfo, www, null, null, platformRegisterInfo.isRegister()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 再次注册: {}", e.getMessage()); - } - }else if (response.getStatusCode() == Response.OK){ - - if (platformRegisterInfo.isRegister()) { - SipTransactionInfo sipTransactionInfo = new SipTransactionInfo(response); - platformService.online(parentPlatform, sipTransactionInfo); - }else { - platformService.offline(parentPlatform, true); - } - - // 注册/注销成功移除缓存的信息 - redisCatchStorage.delPlatformRegisterInfo(callId); - } - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/ITimeoutProcessor.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/ITimeoutProcessor.java deleted file mode 100644 index e0bb1f89..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/ITimeoutProcessor.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.timeout; - -import javax.sip.TimeoutEvent; - -public interface ITimeoutProcessor { - void process(TimeoutEvent event); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/impl/TimeoutProcessorImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/impl/TimeoutProcessorImpl.java deleted file mode 100644 index b2041e59..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/timeout/impl/TimeoutProcessorImpl.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.transmit.event.timeout.impl; - -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; -import com.genersoft.iot.vmp.gb28181.transmit.event.timeout.ITimeoutProcessor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import javax.sip.TimeoutEvent; -import javax.sip.header.CallIdHeader; - -@Component -public class TimeoutProcessorImpl implements InitializingBean, ITimeoutProcessor { - - private Logger logger = LoggerFactory.getLogger(TimeoutProcessorImpl.class); - - @Autowired - private SIPProcessorObserver processorObserver; - - @Autowired - private SipSubscribe sipSubscribe; - - @Override - public void afterPropertiesSet() throws Exception { - processorObserver.addTimeoutProcessor(this); - } - - @Override - public void process(TimeoutEvent event) { - try { - // TODO Auto-generated method stub - CallIdHeader callIdHeader = event.getClientTransaction().getDialog().getCallId(); - String callId = callIdHeader.getCallId(); - SipSubscribe.Event errorSubscribe = sipSubscribe.getErrorSubscribe(callId); - SipSubscribe.EventResult timeoutEventEventResult = new SipSubscribe.EventResult<>(event); - errorSubscribe.response(timeoutEventEventResult); - sipSubscribe.removeErrorSubscribe(callId); - sipSubscribe.removeOkSubscribe(callId); - } catch (Exception e) { - logger.error("[超时事件失败]: {}", e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/Coordtransform.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/Coordtransform.java deleted file mode 100644 index 5c12ff6c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/Coordtransform.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.utils; - -/** - * 坐标转换 - * 一个提供了百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换的工具类 - * 参考https://github.com/wandergis/coordtransform 写的Java版本 - * @author Xinconan - * @date 2016-03-18 - * @url https://github.com/xinconan/coordtransform - */ -public class Coordtransform { - - private static double x_PI = 3.14159265358979324 * 3000.0 / 180.0; - private static double PI = 3.1415926535897932384626; - private static double a = 6378245.0; - private static double ee = 0.00669342162296594323; - - /** - * 百度坐标系 (BD-09) 与 火星坐标系 (GCJ-02)的转换 - * 即 百度 转 谷歌、高德 - * @param bd_lon - * @param bd_lat - * @return Double[lon,lat] - */ - public static Double[] BD09ToGCJ02(Double bd_lon,Double bd_lat){ - double x = bd_lon - 0.0065; - double y = bd_lat - 0.006; - double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI); - double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI); - Double[] arr = new Double[2]; - arr[0] = z * Math.cos(theta); - arr[1] = z * Math.sin(theta); - return arr; - } - - /** - * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换 - * 即谷歌、高德 转 百度 - * @param gcj_lon - * @param gcj_lat - * @return Double[lon,lat] - */ - public static Double[] GCJ02ToBD09(Double gcj_lon,Double gcj_lat){ - double z = Math.sqrt(gcj_lon * gcj_lon + gcj_lat * gcj_lat) + 0.00002 * Math.sin(gcj_lat * x_PI); - double theta = Math.atan2(gcj_lat, gcj_lon) + 0.000003 * Math.cos(gcj_lon * x_PI); - Double[] arr = new Double[2]; - arr[0] = z * Math.cos(theta) + 0.0065; - arr[1] = z * Math.sin(theta) + 0.006; - return arr; - } - - /** - * WGS84转GCJ02 - * @param wgs_lon - * @param wgs_lat - * @return Double[lon,lat] - */ - public static Double[] WGS84ToGCJ02(Double wgs_lon,Double wgs_lat){ - if(outOfChina(wgs_lon, wgs_lat)){ - return new Double[]{wgs_lon,wgs_lat}; - } - double dlat = transformlat(wgs_lon - 105.0, wgs_lat - 35.0); - double dlng = transformlng(wgs_lon - 105.0, wgs_lat - 35.0); - double radlat = wgs_lat / 180.0 * PI; - double magic = Math.sin(radlat); - magic = 1 - ee * magic * magic; - double sqrtmagic = Math.sqrt(magic); - dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); - dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); - Double[] arr = new Double[2]; - arr[0] = wgs_lon + dlng; - arr[1] = wgs_lat + dlat; - return arr; - } - - /** - * GCJ02转WGS84 - * @param gcj_lon - * @param gcj_lat - * @return Double[lon,lat] - */ - public static Double[] GCJ02ToWGS84(Double gcj_lon,Double gcj_lat){ - if(outOfChina(gcj_lon, gcj_lat)){ - return new Double[]{gcj_lon,gcj_lat}; - } - double dlat = transformlat(gcj_lon - 105.0, gcj_lat - 35.0); - double dlng = transformlng(gcj_lon - 105.0, gcj_lat - 35.0); - double radlat = gcj_lat / 180.0 * PI; - double magic = Math.sin(radlat); - magic = 1 - ee * magic * magic; - double sqrtmagic = Math.sqrt(magic); - dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); - dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); - double mglat = gcj_lat + dlat; - double mglng = gcj_lon + dlng; - return new Double[]{gcj_lon * 2 - mglng, gcj_lat * 2 - mglat}; - } - - private static Double transformlat(double lng, double lat) { - double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng)); - ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; - ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0; - ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0; - return ret; - } - - private static Double transformlng(double lng,double lat) { - double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng)); - ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; - ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0; - ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0; - return ret; - } - - /** - * outOfChina - * @描述: 判断是否在国内,不在国内则不做偏移 - * @param lng - * @param lat - * @return {boolean} - */ - private static boolean outOfChina(Double lng,Double lat) { - return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false); - }; - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/MessageElement.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/MessageElement.java deleted file mode 100644 index f94237cd..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/MessageElement.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.utils; - -import java.lang.annotation.*; - -/** - * @author gaofuwang - * @version 1.0 - * @date 2022/6/28 14:58 - */ -@Target({ElementType.FIELD}) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface MessageElement { - String value(); - - String subVal() default ""; -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java deleted file mode 100644 index d990db93..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.utils; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 数值格式判断和处理 - * @author lawrencehj - * @date 2021年1月27日 - */ -public class NumericUtil { - - private static Logger logger = LoggerFactory.getLogger(NumericUtil.class); - - /** - * 判断是否Double格式 - * @param str - * @return true/false - */ - public static boolean isDouble(String str) { - try { - Double num2 = Double.valueOf(str); -// logger.debug(num2 + " is a valid numeric string!"); - return true; - } catch (Exception e) { -// logger.debug(str + " is an invalid numeric string!"); - return false; - } - } - - /** - * 判断是否Double格式 - * @param str - * @return true/false - */ - public static boolean isInteger(String str) { - try { - int num2 = Integer.valueOf(str); -// logger.debug(num2 + " is an integer!"); - return true; - } catch (Exception e) { -// logger.debug(str + " is not an integer!"); - return false; - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java deleted file mode 100644 index 98d62b2d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java +++ /dev/null @@ -1,266 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.utils; - -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.Gb28181Sdp; -import com.genersoft.iot.vmp.gb28181.bean.RemoteAddressInfo; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.utils.GitUtil; -import gov.nist.javax.sip.address.AddressImpl; -import gov.nist.javax.sip.address.SipUri; -import gov.nist.javax.sip.header.Subject; -import gov.nist.javax.sip.message.SIPRequest; -import org.apache.commons.lang3.RandomStringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.ObjectUtils; - -import javax.sdp.SdpFactory; -import javax.sdp.SdpParseException; -import javax.sdp.SessionDescription; -import javax.sip.PeerUnavailableException; -import javax.sip.SipFactory; -import javax.sip.header.FromHeader; -import javax.sip.header.Header; -import javax.sip.header.UserAgentHeader; -import javax.sip.message.Request; -import java.text.ParseException; -import java.time.LocalDateTime; -import java.time.format.DateTimeParseException; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -/** - * @author panlinlin - * @version 1.0.0 - * @description JAIN SIP的工具类 - * @createTime 2021年09月27日 15:12:00 - */ -public class SipUtils { - - private final static Logger logger = LoggerFactory.getLogger(SipUtils.class); - - public static String getUserIdFromFromHeader(Request request) { - FromHeader fromHeader = (FromHeader)request.getHeader(FromHeader.NAME); - return getUserIdFromFromHeader(fromHeader); - } - /** - * 从subject读取channelId - * */ - public static String getChannelIdFromRequest(Request request) { - Header subject = request.getHeader("subject"); - if (subject == null) { - // 如果缺失subject - return null; - } - return ((Subject) subject).getSubject().split(":")[0]; - } - - public static String getUserIdFromFromHeader(FromHeader fromHeader) { - AddressImpl address = (AddressImpl)fromHeader.getAddress(); - SipUri uri = (SipUri) address.getURI(); - return uri.getUser(); - } - - public static String getNewViaTag() { - return "z9hG4bK" + RandomStringUtils.randomNumeric(10); - } - - public static UserAgentHeader createUserAgentHeader(GitUtil gitUtil) throws PeerUnavailableException, ParseException { - List agentParam = new ArrayList<>(); - agentParam.add("WVP-Pro "); - if (gitUtil != null ) { - if (!ObjectUtils.isEmpty(gitUtil.getBuildVersion())) { - agentParam.add("v"); - agentParam.add(gitUtil.getBuildVersion()); - } -// if (!ObjectUtils.isEmpty(gitUtil.getCommitTime())) { -// agentParam.add(gitUtil.getCommitTime()); -// } - } - return SipFactory.getInstance().createHeaderFactory().createUserAgentHeader(agentParam); - } - - public static String getNewFromTag(){ - return UUID.randomUUID().toString().replace("-", ""); - -// return getNewTag(); - } - - public static String getNewTag(){ - return String.valueOf(System.currentTimeMillis()); - } - - - /** - * 云台指令码计算 - * - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - * @param moveSpeed 镜头移动速度 默认 0XFF (0-255) - * @param zoomSpeed 镜头缩放速度 默认 0X1 (0-255) - */ - public static String cmdString(int leftRight, int upDown, int inOut, int moveSpeed, int zoomSpeed) { - int cmdCode = 0; - if (leftRight == 2) { - cmdCode|=0x01; // 右移 - } else if(leftRight == 1) { - cmdCode|=0x02; // 左移 - } - if (upDown == 2) { - cmdCode|=0x04; // 下移 - } else if(upDown == 1) { - cmdCode|=0x08; // 上移 - } - if (inOut == 2) { - cmdCode |= 0x10; // 放大 - } else if(inOut == 1) { - cmdCode |= 0x20; // 缩小 - } - StringBuilder builder = new StringBuilder("A50F01"); - String strTmp; - strTmp = String.format("%02X", cmdCode); - builder.append(strTmp, 0, 2); - strTmp = String.format("%02X", moveSpeed); - builder.append(strTmp, 0, 2); - builder.append(strTmp, 0, 2); - - //优化zoom低倍速下的变倍速率 - if ((zoomSpeed > 0) && (zoomSpeed <16)) - { - zoomSpeed = 16; - } - strTmp = String.format("%X", zoomSpeed); - builder.append(strTmp, 0, 1).append("0"); - //计算校验码 - int checkCode = (0XA5 + 0X0F + 0X01 + cmdCode + moveSpeed + moveSpeed + (zoomSpeed /*<< 4*/ & 0XF0)) % 0X100; - strTmp = String.format("%02X", checkCode); - builder.append(strTmp, 0, 2); - return builder.toString(); - } - - /** - * 从请求中获取设备ip地址和端口号 - * @param request 请求 - * @param sipUseSourceIpAsRemoteAddress false 从via中获取地址, true 直接获取远程地址 - * @return 地址信息 - */ - public static RemoteAddressInfo getRemoteAddressFromRequest(SIPRequest request, boolean sipUseSourceIpAsRemoteAddress) { - - String remoteAddress; - int remotePort; - if (sipUseSourceIpAsRemoteAddress) { - remoteAddress = request.getPeerPacketSourceAddress().getHostAddress(); - remotePort = request.getPeerPacketSourcePort(); - - }else { - // 判断RPort是否改变,改变则说明路由nat信息变化,修改设备信息 - // 获取到通信地址等信息 - remoteAddress = request.getTopmostViaHeader().getReceived(); - remotePort = request.getTopmostViaHeader().getRPort(); - // 解析本地地址替代 - if (ObjectUtils.isEmpty(remoteAddress) || remotePort == -1) { - remoteAddress = request.getPeerPacketSourceAddress().getHostAddress(); - remotePort = request.getPeerPacketSourcePort(); - } - } - - return new RemoteAddressInfo(remoteAddress, remotePort); - } - - public static DeviceChannel updateGps(DeviceChannel deviceChannel, String geoCoordSys) { - if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) { - - if (geoCoordSys == null) { - geoCoordSys = "WGS84"; - } - if ("WGS84".equals(geoCoordSys)) { - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeGcj02(position[0]); - deviceChannel.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(geoCoordSys)) { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(position[0]); - deviceChannel.setLatitudeWgs84(position[1]); - }else { - deviceChannel.setLongitudeGcj02(0.00); - deviceChannel.setLatitudeGcj02(0.00); - deviceChannel.setLongitudeWgs84(0.00); - deviceChannel.setLatitudeWgs84(0.00); - } - }else { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - } - return deviceChannel; - } - - public static Gb28181Sdp parseSDP(String sdpStr) throws SdpParseException { - - // jainSip不支持y= f=字段, 移除以解析。 - int ssrcIndex = sdpStr.indexOf("y="); - int mediaDescriptionIndex = sdpStr.indexOf("f="); - // 检查是否有y字段 - SessionDescription sdp; - String ssrc = null; - String mediaDescription = null; - if (mediaDescriptionIndex == 0 && ssrcIndex == 0) { - sdp = SdpFactory.getInstance().createSessionDescription(sdpStr); - }else { - String lines[] = sdpStr.split("\\r?\\n"); - StringBuilder sdpBuffer = new StringBuilder(); - for (String line : lines) { - if (line.trim().startsWith("y=")) { - ssrc = line.substring(2); - }else if (line.trim().startsWith("f=")) { - mediaDescription = line.substring(2); - }else { - sdpBuffer.append(line.trim()).append("\r\n"); - } - } - sdp = SdpFactory.getInstance().createSessionDescription(sdpBuffer.toString()); - } - return Gb28181Sdp.getInstance(sdp, ssrc, mediaDescription); - } - - public static String getSsrcFromSdp(String sdpStr) { - - // jainSip不支持y= f=字段, 移除以解析。 - int ssrcIndex = sdpStr.indexOf("y="); - if (ssrcIndex == 0) { - return null; - } - String lines[] = sdpStr.split("\\r?\\n"); - for (String line : lines) { - if (line.trim().startsWith("y=")) { - return line.substring(2); - } - } - return null; - } - - public static String parseTime(String timeStr) { - if (ObjectUtils.isEmpty(timeStr)){ - return null; - } - LocalDateTime localDateTime; - try { - localDateTime = LocalDateTime.parse(timeStr); - }catch (DateTimeParseException e) { - try { - localDateTime = LocalDateTime.parse(timeStr, DateUtil.formatterISO8601); - }catch (DateTimeParseException e2) { - logger.error("[格式化时间] 无法格式化时间: {}", timeStr); - return null; - } - } - return localDateTime.format(DateUtil.formatter); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java deleted file mode 100644 index e0a71f22..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ /dev/null @@ -1,647 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.utils; - -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.CivilCodePo; -import com.genersoft.iot.vmp.conf.CivilCodeFileConf; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.utils.DateUtil; -import org.apache.commons.lang3.math.NumberUtils; -import org.dom4j.Attribute; -import org.dom4j.Document; -import org.dom4j.DocumentException; -import org.dom4j.Element; -import org.dom4j.io.SAXReader; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.util.ObjectUtils; -import org.springframework.util.ReflectionUtils; - -import javax.sip.RequestEvent; -import javax.sip.message.Request; -import java.io.ByteArrayInputStream; -import java.io.StringReader; -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.*; - -/** - * 基于dom4j的工具包 - * - * - */ -public class XmlUtil { - /** - * 日志服务 - */ - private static Logger logger = LoggerFactory.getLogger(XmlUtil.class); - - /** - * 解析XML为Document对象 - * - * @param xml 被解析的XMl - * - * @return Document - */ - public static Element parseXml(String xml) { - Document document = null; - // - StringReader sr = new StringReader(xml); - SAXReader saxReader = new SAXReader(); - try { - document = saxReader.read(sr); - } catch (DocumentException e) { - logger.error("解析失败", e); - } - return null == document ? null : document.getRootElement(); - } - - /** - * 获取element对象的text的值 - * - * @param em 节点的对象 - * @param tag 节点的tag - * @return 节点 - */ - public static String getText(Element em, String tag) { - if (null == em) { - return null; - } - Element e = em.element(tag); - // - return null == e ? null : e.getText().trim(); - } - - /** - * 递归解析xml节点,适用于 多节点数据 - * - * @param node node - * @param nodeName nodeName - * @return List> - */ - public static List> listNodes(Element node, String nodeName) { - if (null == node) { - return null; - } - // 初始化返回 - List> listMap = new ArrayList>(); - // 首先获取当前节点的所有属性节点 - List list = node.attributes(); - - Map map = null; - // 遍历属性节点 - for (Attribute attribute : list) { - if (nodeName.equals(node.getName())) { - if (null == map) { - map = new HashMap(); - listMap.add(map); - } - // 取到的节点属性放到map中 - map.put(attribute.getName(), attribute.getValue()); - } - - } - // 遍历当前节点下的所有节点 ,nodeName 要解析的节点名称 - // 使用递归 - Iterator iterator = node.elementIterator(); - while (iterator.hasNext()) { - Element e = iterator.next(); - listMap.addAll(listNodes(e, nodeName)); - } - return listMap; - } - - /** - * xml转json - * - * @param element - * @param json - */ - public static void node2Json(Element element, JSONObject json) { - // 如果是属性 - for (Object o : element.attributes()) { - Attribute attr = (Attribute) o; - if (!ObjectUtils.isEmpty(attr.getValue())) { - json.put("@" + attr.getName(), attr.getValue()); - } - } - List chdEl = element.elements(); - if (chdEl.isEmpty() && !ObjectUtils.isEmpty(element.getText())) {// 如果没有子元素,只有一个值 - json.put(element.getName(), element.getText()); - } - - for (Element e : chdEl) { // 有子元素 - if (!e.elements().isEmpty()) { // 子元素也有子元素 - JSONObject chdjson = new JSONObject(); - node2Json(e, chdjson); - Object o = json.get(e.getName()); - if (o != null) { - JSONArray jsona = null; - if (o instanceof JSONObject) { // 如果此元素已存在,则转为jsonArray - JSONObject jsono = (JSONObject) o; - json.remove(e.getName()); - jsona = new JSONArray(); - jsona.add(jsono); - jsona.add(chdjson); - } - if (o instanceof JSONArray) { - jsona = (JSONArray) o; - jsona.add(chdjson); - } - json.put(e.getName(), jsona); - } else { - if (!chdjson.isEmpty()) { - json.put(e.getName(), chdjson); - } - } - } else { // 子元素没有子元素 - for (Object o : element.attributes()) { - Attribute attr = (Attribute) o; - if (!ObjectUtils.isEmpty(attr.getValue())) { - json.put("@" + attr.getName(), attr.getValue()); - } - } - if (!e.getText().isEmpty()) { - json.put(e.getName(), e.getText()); - } - } - } - } - public static Element getRootElement(RequestEvent evt) throws DocumentException { - - return getRootElement(evt, "gb2312"); - } - - public static Element getRootElement(RequestEvent evt, String charset) throws DocumentException { - Request request = evt.getRequest(); - return getRootElement(request.getRawContent(), charset); - } - - public static Element getRootElement(byte[] content, String charset) throws DocumentException { - if (charset == null) { - charset = "gb2312"; - } - SAXReader reader = new SAXReader(); - reader.setEncoding(charset); - Document xml = reader.read(new ByteArrayInputStream(content)); - return xml.getRootElement(); - } - - private enum ChannelType{ - CivilCode, BusinessGroup,VirtualOrganization,Other - } - - public static DeviceChannel channelContentHandler(Element itemDevice, Device device, String event, CivilCodeFileConf civilCodeFileConf){ - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setDeviceId(device.getDeviceId()); - Element channdelIdElement = itemDevice.element("DeviceID"); - if (channdelIdElement == null) { - logger.warn("解析Catalog消息时发现缺少 DeviceID"); - return null; - } - String channelId = channdelIdElement.getTextTrim(); - if (ObjectUtils.isEmpty(channelId)) { - logger.warn("解析Catalog消息时发现缺少 DeviceID"); - return null; - } - deviceChannel.setChannelId(channelId); - if (event != null && !event.equals(CatalogEvent.ADD) && !event.equals(CatalogEvent.UPDATE)) { - // 除了ADD和update情况下需要识别全部内容, - return deviceChannel; - } - Element nameElement = itemDevice.element("Name"); - if (nameElement != null) { - deviceChannel.setName(nameElement.getText()); - } - if(channelId.length() <= 8) { - deviceChannel.setHasAudio(false); - CivilCodePo parentCode = civilCodeFileConf.getParentCode(channelId); - if (parentCode != null) { - deviceChannel.setParentId(parentCode.getCode()); - deviceChannel.setCivilCode(parentCode.getCode()); - }else { - logger.warn("[xml解析] 无法确定行政区划{}的上级行政区划", channelId); - } - deviceChannel.setStatus(true); - return deviceChannel; - }else { - if(channelId.length() != 20) { - logger.warn("[xml解析] 失败,编号不符合国标28181定义: {}", channelId); - return null; - } - - int code = Integer.parseInt(channelId.substring(10, 13)); - if (code == 136 || code == 137 || code == 138) { - deviceChannel.setHasAudio(true); - }else { - deviceChannel.setHasAudio(false); - } - // 设备厂商 - String manufacturer = getText(itemDevice, "Manufacturer"); - // 设备型号 - String model = getText(itemDevice, "Model"); - // 设备归属 - String owner = getText(itemDevice, "Owner"); - // 行政区域 - String civilCode = getText(itemDevice, "CivilCode"); - // 虚拟组织所属的业务分组ID,业务分组根据特定的业务需求制定,一个业务分组包含一组特定的虚拟组织 - String businessGroupID = getText(itemDevice, "BusinessGroupID"); - // 父设备/区域/系统ID - String parentID = getText(itemDevice, "ParentID"); - if (parentID != null && parentID.equalsIgnoreCase("null")) { - parentID = null; - } - // 注册方式(必选)缺省为1;1:符合IETFRFC3261标准的认证注册模式;2:基于口令的双向认证注册模式;3:基于数字证书的双向认证注册模式 - String registerWay = getText(itemDevice, "RegisterWay"); - // 保密属性(必选)缺省为0;0:不涉密,1:涉密 - String secrecy = getText(itemDevice, "Secrecy"); - // 安装地址 - String address = getText(itemDevice, "Address"); - - switch (code){ - case 200: - // 系统目录 - if (!ObjectUtils.isEmpty(manufacturer)) { - deviceChannel.setManufacture(manufacturer); - } - if (!ObjectUtils.isEmpty(model)) { - deviceChannel.setModel(model); - } - if (!ObjectUtils.isEmpty(owner)) { - deviceChannel.setOwner(owner); - } - if (!ObjectUtils.isEmpty(civilCode)) { - deviceChannel.setCivilCode(civilCode); - deviceChannel.setParentId(civilCode); - }else { - if (!ObjectUtils.isEmpty(parentID)) { - deviceChannel.setParentId(parentID); - } - } - if (!ObjectUtils.isEmpty(address)) { - deviceChannel.setAddress(address); - } - deviceChannel.setStatus(true); - if (!ObjectUtils.isEmpty(registerWay)) { - try { - deviceChannel.setRegisterWay(Integer.parseInt(registerWay)); - }catch (NumberFormatException exception) { - logger.warn("[xml解析] 从通道数据获取registerWay失败: {}", registerWay); - } - } - if (!ObjectUtils.isEmpty(secrecy)) { - deviceChannel.setSecrecy(secrecy); - } - return deviceChannel; - case 215: - // 业务分组 - deviceChannel.setStatus(true); - if (!ObjectUtils.isEmpty(parentID)) { - if (!parentID.trim().equalsIgnoreCase(device.getDeviceId())) { - deviceChannel.setParentId(parentID); - } - }else { - logger.warn("[xml解析] 业务分组数据中缺少关键信息->ParentId"); - if (!ObjectUtils.isEmpty(civilCode)) { - deviceChannel.setCivilCode(civilCode); - } - } - break; - case 216: - // 虚拟组织 - deviceChannel.setStatus(true); - if (!ObjectUtils.isEmpty(businessGroupID)) { - deviceChannel.setBusinessGroupId(businessGroupID); - } - - if (!ObjectUtils.isEmpty(parentID)) { - if (parentID.contains("/")) { - String[] parentIdArray = parentID.split("/"); - parentID = parentIdArray[parentIdArray.length - 1]; - } - deviceChannel.setParentId(parentID); - }else { - if (!ObjectUtils.isEmpty(businessGroupID)) { - deviceChannel.setParentId(businessGroupID); - } - } - break; - default: - // 设备目录 - if (!ObjectUtils.isEmpty(manufacturer)) { - deviceChannel.setManufacture(manufacturer); - } - if (!ObjectUtils.isEmpty(model)) { - deviceChannel.setModel(model); - } - if (!ObjectUtils.isEmpty(owner)) { - deviceChannel.setOwner(owner); - } - if (!ObjectUtils.isEmpty(civilCode) - && civilCode.length() <= 8 - && NumberUtils.isParsable(civilCode) - && civilCode.length()%2 == 0 - ) { - deviceChannel.setCivilCode(civilCode); - } - if (!ObjectUtils.isEmpty(businessGroupID)) { - deviceChannel.setBusinessGroupId(businessGroupID); - } - - // 警区 - String block = getText(itemDevice, "Block"); - if (!ObjectUtils.isEmpty(block)) { - deviceChannel.setBlock(block); - } - if (!ObjectUtils.isEmpty(address)) { - deviceChannel.setAddress(address); - } - - if (!ObjectUtils.isEmpty(secrecy)) { - deviceChannel.setSecrecy(secrecy); - } - - // 当为设备时,是否有子设备(必选)1有,0没有 - String parental = getText(itemDevice, "Parental"); - if (!ObjectUtils.isEmpty(parental)) { - try { - // 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1 - if (!ObjectUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) { - deviceChannel.setParental(0); - }else { - deviceChannel.setParental(1); - } - }catch (NumberFormatException e) { - logger.warn("[xml解析] 从通道数据获取 parental失败: {}", parental); - } - } - // 父设备/区域/系统ID - - if (!ObjectUtils.isEmpty(parentID) ) { - if (parentID.contains("/")) { - String[] parentIdArray = parentID.split("/"); - deviceChannel.setParentId(parentIdArray[parentIdArray.length - 1]); - }else { - if (parentID.length()%2 == 0) { - deviceChannel.setParentId(parentID); - }else { - logger.warn("[xml解析] 不规范的parentID:{}, 已舍弃", parentID); - } - } - }else { - if (!ObjectUtils.isEmpty(businessGroupID)) { - deviceChannel.setParentId(businessGroupID); - }else { - if (!ObjectUtils.isEmpty(deviceChannel.getCivilCode())) { - deviceChannel.setParentId(deviceChannel.getCivilCode()); - } - } - } - // 注册方式 - if (!ObjectUtils.isEmpty(registerWay)) { - try { - int registerWayInt = Integer.parseInt(registerWay); - deviceChannel.setRegisterWay(registerWayInt); - }catch (NumberFormatException exception) { - logger.warn("[xml解析] 从通道数据获取registerWay失败: {}", registerWay); - deviceChannel.setRegisterWay(1); - } - }else { - deviceChannel.setRegisterWay(1); - } - - // 信令安全模式(可选)缺省为0; 0:不采用;2:S/MIME 签名方式;3:S/MIME加密签名同时采用方式;4:数字摘要方式 - String safetyWay = getText(itemDevice, "SafetyWay"); - if (!ObjectUtils.isEmpty(safetyWay)) { - try { - deviceChannel.setSafetyWay(Integer.parseInt(safetyWay)); - }catch (NumberFormatException e) { - logger.warn("[xml解析] 从通道数据获取 safetyWay失败: {}", safetyWay); - } - } - - // 证书序列号(有证书的设备必选) - String certNum = getText(itemDevice, "CertNum"); - if (!ObjectUtils.isEmpty(certNum)) { - deviceChannel.setCertNum(certNum); - } - - // 证书有效标识(有证书的设备必选)缺省为0;证书有效标识:0:无效 1:有效 - String certifiable = getText(itemDevice, "Certifiable"); - if (!ObjectUtils.isEmpty(certifiable)) { - try { - deviceChannel.setCertifiable(Integer.parseInt(certifiable)); - }catch (NumberFormatException e) { - logger.warn("[xml解析] 从通道数据获取 Certifiable失败: {}", certifiable); - } - } - - // 无效原因码(有证书且证书无效的设备必选) - String errCode = getText(itemDevice, "ErrCode"); - if (!ObjectUtils.isEmpty(errCode)) { - try { - deviceChannel.setErrCode(Integer.parseInt(errCode)); - }catch (NumberFormatException e) { - logger.warn("[xml解析] 从通道数据获取 ErrCode失败: {}", errCode); - } - } - - // 证书终止有效期(有证书的设备必选) - String endTime = getText(itemDevice, "EndTime"); - if (!ObjectUtils.isEmpty(endTime)) { - deviceChannel.setEndTime(endTime); - } - - - // 设备/区域/系统IP地址 - String ipAddress = getText(itemDevice, "IPAddress"); - if (!ObjectUtils.isEmpty(ipAddress)) { - deviceChannel.setIpAddress(ipAddress); - } - - // 设备/区域/系统端口 - String port = getText(itemDevice, "Port"); - if (!ObjectUtils.isEmpty(port)) { - try { - deviceChannel.setPort(Integer.parseInt(port)); - }catch (NumberFormatException e) { - logger.warn("[xml解析] 从通道数据获取 Port失败: {}", port); - } - } - - // 设备口令 - String password = getText(itemDevice, "Password"); - if (!ObjectUtils.isEmpty(password)) { - deviceChannel.setPassword(password); - } - - - // 设备状态 - String status = getText(itemDevice, "Status"); - if (status != null) { - // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) { - deviceChannel.setStatus(true); - } - if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { - deviceChannel.setStatus(false); - } - }else { - deviceChannel.setStatus(true); - } - - // 经度 - String longitude = getText(itemDevice, "Longitude"); - if (NumericUtil.isDouble(longitude)) { - deviceChannel.setLongitude(Double.parseDouble(longitude)); - } else { - deviceChannel.setLongitude(0.00); - } - - // 纬度 - String latitude = getText(itemDevice, "Latitude"); - if (NumericUtil.isDouble(latitude)) { - deviceChannel.setLatitude(Double.parseDouble(latitude)); - } else { - deviceChannel.setLatitude(0.00); - } - - deviceChannel.setGpsTime(DateUtil.getNow()); - - // -摄像机类型扩展,标识摄像机类型:1-球机;2-半球;3-固定枪机;4-遥控枪机。当目录项为摄像机时可选 - String ptzType = getText(itemDevice, "PTZType"); - if (ObjectUtils.isEmpty(ptzType)) { - //兼容INFO中的信息 - Element info = itemDevice.element("Info"); - String ptzTypeFromInfo = XmlUtil.getText(info, "PTZType"); - if(!ObjectUtils.isEmpty(ptzTypeFromInfo)){ - try { - deviceChannel.setPtzType(Integer.parseInt(ptzTypeFromInfo)); - }catch (NumberFormatException e){ - logger.warn("[xml解析] 从通道数据info中获取PTZType失败: {}", ptzTypeFromInfo); - } - } - } else { - try { - deviceChannel.setPtzType(Integer.parseInt(ptzType)); - }catch (NumberFormatException e){ - logger.warn("[xml解析] 从通道数据中获取PTZType失败: {}", ptzType); - } - } - - // TODO 摄像机位置类型扩展。 - // 1-省际检查站、 - // 2-党政机关、 - // 3-车站码头、 - // 4-中心广场、 - // 5-体育场馆、 - // 6-商业中心、 - // 7-宗教场所、 - // 8-校园周边、 - // 9-治安复杂区域、 - // 10-交通干线。 - // String positionType = getText(itemDevice, "PositionType"); - - // TODO 摄像机安装位置室外、室内属性。1-室外、2-室内。 - // String roomType = getText(itemDevice, "RoomType"); - // TODO 摄像机用途属性 - // String useType = getText(itemDevice, "UseType"); - // TODO 摄像机补光属性。1-无补光、2-红外补光、3-白光补光 - // String supplyLightType = getText(itemDevice, "SupplyLightType"); - // TODO 摄像机监视方位属性。1-东、2-西、3-南、4-北、5-东南、6-东北、7-西南、8-西北。 - // String directionType = getText(itemDevice, "DirectionType"); - // TODO 摄像机支持的分辨率,可有多个分辨率值,各个取值间以“/”分隔。分辨率取值参见附录 F中SDPf字段规定 - // String resolution = getText(itemDevice, "Resolution"); - - // TODO 下载倍速范围(可选),各可选参数以“/”分隔,如设备支持1,2,4倍速下载则应写为“1/2/4 - // String downloadSpeed = getText(itemDevice, "DownloadSpeed"); - // TODO 空域编码能力,取值0:不支持;1:1级增强(1个增强层);2:2级增强(2个增强层);3:3级增强(3个增强层) - // String svcSpaceSupportMode = getText(itemDevice, "SVCSpaceSupportMode"); - // TODO 时域编码能力,取值0:不支持;1:1级增强;2:2级增强;3:3级增强 - // String svcTimeSupportMode = getText(itemDevice, "SVCTimeSupportMode"); - - - deviceChannel.setSecrecy(secrecy); - break; - } - } - - return deviceChannel; - } - - /** - * 新增方法支持内部嵌套 - * - * @param element xmlElement - * @param clazz 结果类 - * @param 泛型 - * @return 结果对象 - * @throws NoSuchMethodException - * @throws InvocationTargetException - * @throws InstantiationException - * @throws IllegalAccessException - */ - public static T loadElement(Element element, Class clazz) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException { - Field[] fields = clazz.getDeclaredFields(); - T t = clazz.getDeclaredConstructor().newInstance(); - for (Field field : fields) { - ReflectionUtils.makeAccessible(field); - MessageElement annotation = field.getAnnotation(MessageElement.class); - if (annotation == null) { - continue; - } - String value = annotation.value(); - String subVal = annotation.subVal(); - Element element1 = element.element(value); - if (element1 == null) { - continue; - } - if ("".equals(subVal)) { - // 无下级数据 - Object fieldVal = element1.isTextOnly() ? element1.getText() : loadElement(element1, field.getType()); - Object o = simpleTypeDeal(field.getType(), fieldVal); - ReflectionUtils.setField(field, t, o); - } else { - // 存在下级数据 - ArrayList list = new ArrayList<>(); - Type genericType = field.getGenericType(); - if (!(genericType instanceof ParameterizedType)) { - continue; - } - Class aClass = (Class) ((ParameterizedType) genericType).getActualTypeArguments()[0]; - for (Element element2 : element1.elements(subVal)) { - list.add(loadElement(element2, aClass)); - } - ReflectionUtils.setField(field, t, list); - } - } - return t; - } - - /** - * 简单类型处理 - * - * @param tClass - * @param val - * @return - */ - private static Object simpleTypeDeal(Class tClass, Object val) { - if (tClass.equals(String.class)) { - return val.toString(); - } - if (tClass.equals(Integer.class)) { - return Integer.valueOf(val.toString()); - } - if (tClass.equals(Double.class)) { - return Double.valueOf(val.toString()); - } - if (tClass.equals(Long.class)) { - return Long.valueOf(val.toString()); - } - return val; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/rtvs/RTVSGatewayController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/rtvs/RTVSGatewayController.java deleted file mode 100644 index 75b01bf3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/rtvs/RTVSGatewayController.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.genersoft.iot.vmp.media.rtvs; - -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.service.IPlayService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import javax.servlet.http.HttpServletRequest; -import java.util.Base64; -import java.util.Map; - -@RestController -@RequestMapping(value = "/gbs/RTVS") -public class RTVSGatewayController { - - @Autowired - private SIPCommander sipCommander; - - @RequestMapping("/**") - public String test(HttpServletRequest request) { - Map parameterMap = request.getParameterMap(); - String sdp = parameterMap.get("SDP")[0]; - byte[] decode = Base64.getDecoder().decode(sdp); - String s = new String(decode); - System.out.println(s); - System.out.println(request); -// sipCommander.playStreamCmd(); -// playService.play() - return "-1"; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java deleted file mode 100644 index cf71bf1d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import okhttp3.*; -import okhttp3.logging.HttpLoggingInterceptor; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.io.IOException; -import java.net.ConnectException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; - -@Component -public class AssistRESTfulUtils { - - private final static Logger logger = LoggerFactory.getLogger(AssistRESTfulUtils.class); - - - public interface RequestCallback{ - void run(JSONObject response); - } - - private OkHttpClient getClient(){ - OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); - if (logger.isDebugEnabled()) { - HttpLoggingInterceptor logging = new HttpLoggingInterceptor(message -> { - logger.debug("http请求参数:" + message); - }); - logging.setLevel(HttpLoggingInterceptor.Level.BASIC); - // OkHttp進行添加攔截器loggingInterceptor - httpClientBuilder.addInterceptor(logging); - } - return httpClientBuilder.build(); - } - - - public JSONObject sendGet(MediaServerItem mediaServerItem, String api, Map param, RequestCallback callback) { - OkHttpClient client = getClient(); - - if (mediaServerItem == null) { - return null; - } - if (mediaServerItem.getRecordAssistPort() <= 0) { - logger.warn("未启用Assist服务"); - return null; - } - StringBuffer stringBuffer = new StringBuffer(); - stringBuffer.append(String.format("http://%s:%s/%s", mediaServerItem.getIp(), mediaServerItem.getRecordAssistPort(), api)); - JSONObject responseJSON = null; - - if (param != null && param.keySet().size() > 0) { - stringBuffer.append("?"); - int index = 1; - for (String key : param.keySet()){ - if (param.get(key) != null) { - stringBuffer.append(key + "=" + param.get(key)); - if (index < param.size()) { - stringBuffer.append("&"); - } - } - index++; - } - } - - String url = stringBuffer.toString(); - Request request = new Request.Builder() - .get() - .url(url) - .build(); - if (callback == null) { - try { - Response response = client.newCall(request).execute(); - if (response.isSuccessful()) { - ResponseBody responseBody = response.body(); - if (responseBody != null) { - String responseStr = responseBody.string(); - responseJSON = JSON.parseObject(responseStr); - } - }else { - response.close(); - Objects.requireNonNull(response.body()).close(); - } - } catch (ConnectException e) { - logger.error(String.format("连接Assist失败: %s, %s", e.getCause().getMessage(), e.getMessage())); - logger.info("请检查media配置并确认Assist已启动..."); - }catch (IOException e) { - logger.error(String.format("[ %s ]请求失败: %s", url, e.getMessage())); - } - }else { - client.newCall(request).enqueue(new Callback(){ - - @Override - public void onResponse(@NotNull Call call, @NotNull Response response){ - if (response.isSuccessful()) { - try { - String responseStr = Objects.requireNonNull(response.body()).string(); - callback.run(JSON.parseObject(responseStr)); - } catch (IOException e) { - logger.error(String.format("[ %s ]请求失败: %s", url, e.getMessage())); - } - - }else { - response.close(); - Objects.requireNonNull(response.body()).close(); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - logger.error(String.format("连接Assist失败: %s, %s", e.getCause().getMessage(), e.getMessage())); - logger.info("请检查media配置并确认Assist已启动..."); - } - }); - } - - - - return responseJSON; - } - - - public JSONObject fileDuration(MediaServerItem mediaServerItem, String app, String stream, RequestCallback callback){ - Map param = new HashMap<>(); - param.put("app",app); - param.put("stream",stream); - param.put("recordIng",true); - return sendGet(mediaServerItem, "api/record/file/duration",param, callback); - } - - public JSONObject getInfo(MediaServerItem mediaServerItem, RequestCallback callback){ - Map param = new HashMap<>(); - return sendGet(mediaServerItem, "api/record/info",param, callback); - } - - public JSONObject addStreamCallInfo(MediaServerItem mediaServerItem, String app, String stream, String callId, RequestCallback callback){ - Map param = new HashMap<>(); - param.put("app",app); - param.put("stream",stream); - param.put("callId",callId); - return sendGet(mediaServerItem, "api/record/addStreamCallInfo",param, callback); - } - - public JSONObject getDateList(MediaServerItem mediaServerItem, String app, String stream, int year, int month) { - Map param = new HashMap<>(); - param.put("app", app); - param.put("stream", stream); - param.put("year", year); - param.put("month", month); - return sendGet(mediaServerItem, "api/record/date/list", param, null); - } - - public JSONObject getFileList(MediaServerItem mediaServerItem, int page, int count, String app, String stream, - String startTime, String endTime) { - Map param = new HashMap<>(); - param.put("app", app); - param.put("stream", stream); - param.put("page", page); - param.put("count", count); - param.put("startTime", startTime); - param.put("endTime", endTime); - return sendGet(mediaServerItem, "api/record/file/listWithDate", param, null); - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java deleted file mode 100644 index 3f28d02a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/SendRtpPortManager.java +++ /dev/null @@ -1,135 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import org.apache.commons.lang3.math.NumberUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.support.atomic.RedisAtomicInteger; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -@Component -public class SendRtpPortManager { - - private final static Logger logger = LoggerFactory.getLogger(SendRtpPortManager.class); - - @Autowired - private UserSetting userSetting; - - @Autowired - private RedisTemplate redisTemplate; - - private final String KEY = "VM_MEDIA_SEND_RTP_PORT_"; - - public synchronized int getNextPort(MediaServerItem mediaServer) { - if (mediaServer == null) { - logger.warn("[发送端口管理] 参数错误,mediaServer为NULL"); - return -1; - } - String sendIndexKey = KEY + userSetting.getServerId() + "_" + mediaServer.getId(); - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*"; - List queryResult = RedisUtil.scan(redisTemplate, key); - Map sendRtpItemMap = new HashMap<>(); - - for (Object o : queryResult) { - SendRtpItem sendRtpItem = (SendRtpItem) redisTemplate.opsForValue().get(o); - if (sendRtpItem != null) { - sendRtpItemMap.put(sendRtpItem.getLocalPort(), sendRtpItem); - } - } - String sendRtpPortRange = mediaServer.getSendRtpPortRange(); - int startPort; - int endPort; - if (sendRtpPortRange != null) { - String[] portArray = sendRtpPortRange.split(","); - if (portArray.length != 2 || !NumberUtils.isParsable(portArray[0]) || !NumberUtils.isParsable(portArray[1])) { - logger.warn("{}发送端口配置格式错误,自动使用50000-60000作为端口范围", mediaServer.getId()); - startPort = 50000; - endPort = 60000; - }else { - if ( Integer.parseInt(portArray[1]) - Integer.parseInt(portArray[0]) < 1) { - logger.warn("{}发送端口配置错误,结束端口至少比开始端口大一,自动使用50000-60000作为端口范围", mediaServer.getId()); - startPort = 50000; - endPort = 60000; - }else { - startPort = Integer.parseInt(portArray[0]); - endPort = Integer.parseInt(portArray[1]); - } - } - }else { - logger.warn("{}未设置发送端口默认值,自动使用50000-60000作为端口范围", mediaServer.getId()); - startPort = 50000; - endPort = 60000; - } - if (redisTemplate == null || redisTemplate.getConnectionFactory() == null) { - logger.warn("{}获取redis连接信息失败", mediaServer.getId()); - return -1; - } -// RedisAtomicInteger redisAtomicInteger = new RedisAtomicInteger(sendIndexKey , redisTemplate.getConnectionFactory()); -// return redisAtomicInteger.getAndUpdate((current)->{ -// return getPort(current, startPort, endPort, checkPort-> !sendRtpItemMap.containsKey(checkPort)); -// }); - return getSendPort(startPort, endPort, sendIndexKey, sendRtpItemMap); - } - - private synchronized int getSendPort(int startPort, int endPort, String sendIndexKey, Map sendRtpItemMap){ - RedisAtomicInteger redisAtomicInteger = new RedisAtomicInteger(sendIndexKey , redisTemplate.getConnectionFactory()); - if (redisAtomicInteger.get() < startPort) { - redisAtomicInteger.set(startPort); - return startPort; - }else { - int port = redisAtomicInteger.getAndIncrement(); - if (port > endPort) { - redisAtomicInteger.set(startPort); - if (sendRtpItemMap.containsKey(startPort)) { - return getSendPort(startPort, endPort, sendIndexKey, sendRtpItemMap); - }else { - return startPort; - } - } - if (sendRtpItemMap.containsKey(port)) { - return getSendPort(startPort, endPort, sendIndexKey, sendRtpItemMap); - }else { - return port; - } - } - - } - - interface CheckPortCallback{ - boolean check(int port); - } - - private int getPort(int current, int start, int end, CheckPortCallback checkPortCallback) { - if (current <= 0) { - if (start%2 == 0) { - current = start; - }else { - current = start + 1; - } - }else { - current += 2; - if (current > end) { - if (start%2 == 0) { - current = start; - }else { - current = start + 1; - } - } - } - if (!checkPortCallback.check(current)) { - return getPort(current + 2, start, end, checkPortCallback); - } - return current; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java deleted file mode 100644 index 4738b902..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ /dev/null @@ -1,797 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.media.zlm.dto.HookType; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.media.zlm.dto.hook.*; -import com.genersoft.iot.vmp.service.*; -import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.OtherPsSendInfo; -import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo; -import com.genersoft.iot.vmp.vmanager.bean.StreamContent; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.servlet.http.HttpServletRequest; -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * @description:针对 ZLMediaServer的hook事件监听 - * @author: swwheihei - * @date: 2020年5月8日 上午10:46:48 - */ -@RestController -@RequestMapping("/gbs/zlm/hook") -public class ZLMHttpHookListener { - - private final static Logger logger = LoggerFactory.getLogger(ZLMHttpHookListener.class); - - @Autowired - private SIPCommander cmder; - - @Autowired - private SIPCommanderFroPlatform commanderFroPlatform; - - @Autowired - private IPlayService playService; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private IStreamProxyService streamProxyService; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private IMediaService mediaService; - - @Autowired - private EventPublisher eventPublisher; - - @Autowired - private ZLMMediaListManager zlmMediaListManager; - - @Autowired - private ZlmHttpHookSubscribe subscribe; - - @Autowired - private UserSetting userSetting; - - @Autowired - private VideoStreamSessionManager sessionManager; - - @Autowired - private AssistRESTfulUtils assistRESTfulUtils; - - @Autowired - private SSRCFactory ssrcFactory; - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Autowired - private RedisTemplate redisTemplate; - - /** - * 服务器定时上报时间,上报间隔可配置,默认10s上报一次 - */ - @ResponseBody - - @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8") - public HookResult onServerKeepalive(@RequestBody OnServerKeepaliveHookParam param) { - - - taskExecutor.execute(() -> { - List subscribes = this.subscribe.getSubscribes(HookType.on_server_keepalive); - if (subscribes != null && subscribes.size() > 0) { - for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { - subscribe.response(null, param); - } - } - }); - mediaServerService.updateMediaServerKeepalive(param.getMediaServerId(), param.getData()); - - return HookResult.SUCCESS(); - } - - /** - * 播放器鉴权事件,rtsp/rtmp/http-flv/ws-flv/hls的播放都将触发此鉴权事件。 - */ - @ResponseBody - - @PostMapping(value = "/on_play", produces = "application/json;charset=UTF-8") - public HookResult onPlay(@RequestBody OnPlayHookParam param) { - if (logger.isDebugEnabled()) { - logger.debug("[ZLM HOOK] 播放鉴权:{}->{}" + param.getMediaServerId(), param); - } - String mediaServerId = param.getMediaServerId(); - - taskExecutor.execute(() -> { - JSONObject json = (JSONObject) JSON.toJSON(param); - ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json); - if (subscribe != null) { - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); - if (mediaInfo != null) { - subscribe.response(mediaInfo, param); - } - } - }); - if (!"rtp".equals(param.getApp())) { - Map paramMap = urlParamToMap(param.getParams()); - StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); - if (streamAuthorityInfo != null && streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId"))) { - return new HookResult(401, "Unauthorized"); - } - } - - return HookResult.SUCCESS(); - } - - /** - * rtsp/rtmp/rtp推流鉴权事件。 - */ - @ResponseBody - @PostMapping(value = "/on_publish", produces = "application/json;charset=UTF-8") - public HookResultForOnPublish onPublish(@RequestBody OnPublishHookParam param) { - - JSONObject json = (JSONObject) JSON.toJSON(param); - - logger.info("[ZLM HOOK]推流鉴权:{}->{}", param.getMediaServerId(), param); - - String mediaServerId = json.getString("mediaServerId"); - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); - if (mediaInfo == null) { - return new HookResultForOnPublish(200, "success"); - } - // 推流鉴权的处理 - if (!"rtp".equals(param.getApp())) { - StreamProxyItem stream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); - if (stream != null) { - HookResultForOnPublish result = HookResultForOnPublish.SUCCESS(); - result.setEnable_audio(stream.isEnableAudio()); - result.setEnable_mp4(stream.isEnableMp4()); - return result; - } - if (userSetting.getPushAuthority()) { - // 推流鉴权 - if (param.getParams() == null) { - logger.info("推流鉴权失败: 缺少必要参数:sign=md5(user表的pushKey)"); - return new HookResultForOnPublish(401, "Unauthorized"); - } - Map paramMap = urlParamToMap(param.getParams()); - String sign = paramMap.get("sign"); - if (sign == null) { - logger.info("推流鉴权失败: 缺少必要参数:sign=md5(user表的pushKey)"); - return new HookResultForOnPublish(401, "Unauthorized"); - } - // 推流自定义播放鉴权码 - String callId = paramMap.get("callId"); - // 鉴权配置 - boolean hasAuthority = true; //userService.checkPushAuthority(callId, sign); - if (!hasAuthority) { - logger.info("推流鉴权失败: sign 无权限: callId={}. sign={}", callId, sign); - return new HookResultForOnPublish(401, "Unauthorized"); - } - StreamAuthorityInfo streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); - streamAuthorityInfo.setCallId(callId); - streamAuthorityInfo.setSign(sign); - // 鉴权通过 - redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); - // 通知assist新的callId - if (mediaInfo != null && mediaInfo.getRecordAssistPort() > 0) { - taskExecutor.execute(() -> { - assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null); - }); - } - } - } else { - zlmMediaListManager.sendStreamEvent(param.getApp(), param.getStream(), param.getMediaServerId()); - } - - - HookResultForOnPublish result = HookResultForOnPublish.SUCCESS(); - result.setEnable_audio(true); - taskExecutor.execute(() -> { - ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_publish, json); - if (subscribe != null) { - if (mediaInfo != null) { - subscribe.response(mediaInfo, param); - } else { - new HookResultForOnPublish(1, "zlm not register"); - } - } - }); - - // 是否录像 - if ("rtp".equals(param.getApp())) { - result.setEnable_mp4(userSetting.getRecordSip()); - } else { - result.setEnable_mp4(userSetting.isRecordPushLive()); - } - - // 国标流 - if ("rtp".equals(param.getApp())) { - - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream()); - - // 单端口模式下修改流 ID - if (!mediaInfo.isRtpEnable() && inviteInfo == null) { - String ssrc = String.format("%010d", Long.parseLong(param.getStream(), 16)); - inviteInfo = inviteStreamService.getInviteInfoBySSRC(ssrc); - if (inviteInfo != null) { - result.setStream_replace(inviteInfo.getStream()); - logger.info("[ZLM HOOK]推流鉴权 stream: {} 替换为 {}", param.getStream(), inviteInfo.getStream()); - } - } - - // 设置音频信息及录制信息 - List ssrcTransactionForAll = (inviteInfo == null ? null : - sessionManager.getSsrcTransactionForAll(inviteInfo.getDeviceId(), inviteInfo.getChannelId(), null, null)); - if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) { - String deviceId = ssrcTransactionForAll.get(0).getDeviceId(); - String channelId = ssrcTransactionForAll.get(0).getChannelId(); - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); - if (deviceChannel != null) { - result.setEnable_audio(deviceChannel.isHasAudio()); - } - // 如果是录像下载就设置视频间隔十秒 - if (ssrcTransactionForAll.get(0).getType() == InviteSessionType.DOWNLOAD) { - result.setMp4_max_second(10); - result.setEnable_mp4(true); - } - } - } - if (mediaInfo.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) { - logger.info("推流时发现尚未设置录像路径,从assist服务中读取"); - JSONObject info = assistRESTfulUtils.getInfo(mediaInfo, null); - if (info != null && info.getInteger("code") != null && info.getInteger("code") == 0 ) { - JSONObject dataJson = info.getJSONObject("data"); - if (dataJson != null) { - String recordPath = dataJson.getString("record"); - userSetting.setRecordPath(recordPath); - result.setMp4_save_path(recordPath); - // 修改zlm中的录像路径 - if (mediaInfo.isAutoConfig()) { - taskExecutor.execute(() -> { - mediaServerService.setZLMConfig(mediaInfo, false); - }); - } - } - } - } - if (param.getApp().equalsIgnoreCase("rtp")) { - String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + param.getStream(); - OtherRtpSendInfo otherRtpSendInfo = (OtherRtpSendInfo)redisTemplate.opsForValue().get(receiveKey); - - String receiveKeyForPS = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_" + param.getStream(); - OtherPsSendInfo otherPsSendInfo = (OtherPsSendInfo)redisTemplate.opsForValue().get(receiveKeyForPS); - if (otherRtpSendInfo != null || otherPsSendInfo != null) { - result.setEnable_mp4(true); - } - } - logger.info("[ZLM HOOK]推流鉴权 响应:{}->{}->>>>{}", param.getMediaServerId(), param, result); - return result; - } - - - /** - * rtsp/rtmp流注册或注销时触发此事件;此事件对回复不敏感。 - */ - @ResponseBody - @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8") - public HookResult onStreamChanged(@RequestBody OnStreamChangedHookParam param) { - - if (param.isRegist()) { - logger.info("[ZLM HOOK] 流注册, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); - } else { - logger.info("[ZLM HOOK] 流注销, {}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); - } - - - JSONObject json = (JSONObject) JSON.toJSON(param); - taskExecutor.execute(() -> { - ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_stream_changed, json); - MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); - if (mediaInfo == null) { - logger.info("[ZLM HOOK] 流变化未找到ZLM, {}", param.getMediaServerId()); - return; - } - if (subscribe != null) { - subscribe.response(mediaInfo, param); - } - - List tracks = param.getTracks(); - // TODO 重构此处逻辑 - boolean isPush = false; - if (param.isRegist()) { - // 处理流注册的鉴权信息 - if (param.getOriginType() == OriginType.RTMP_PUSH.ordinal() - || param.getOriginType() == OriginType.RTSP_PUSH.ordinal() - || param.getOriginType() == OriginType.RTC_PUSH.ordinal()) { - isPush = true; - StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream()); - if (streamAuthorityInfo == null) { - streamAuthorityInfo = StreamAuthorityInfo.getInstanceByHook(param); - } else { - streamAuthorityInfo.setOriginType(param.getOriginType()); - streamAuthorityInfo.setOriginTypeStr(param.getOriginTypeStr()); - } - redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); - } - } else { - redisCatchStorage.removeStreamAuthorityInfo(param.getApp(), param.getStream()); - } - - if ("rtsp".equals(param.getSchema())) { - // 更新流媒体负载信息 - if (param.isRegist()) { - mediaServerService.addCount(param.getMediaServerId()); - } else { - mediaServerService.removeCount(param.getMediaServerId()); - } - // 设置拉流代理上线/离线 - int updateStatusResult = streamProxyService.updateStatus(param.isRegist(), param.getApp(), param.getStream()); - if (updateStatusResult > 0) { - - } - - if ("rtp".equals(param.getApp()) && !param.isRegist()) { - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream()); - if (inviteInfo != null && (inviteInfo.getType() == InviteSessionType.PLAY || inviteInfo.getType() == InviteSessionType.PLAYBACK)) { - inviteStreamService.removeInviteInfo(inviteInfo); - storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); - } - } else { - if (!"rtp".equals(param.getApp())) { - String type = OriginType.values()[param.getOriginType()].getType(); - if (param.isRegist()) { - StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo( - param.getApp(), param.getStream()); - String callId = null; - if (streamAuthorityInfo != null) { - callId = streamAuthorityInfo.getCallId(); - } - StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaInfo, - param.getApp(), param.getStream(), tracks, callId); - param.setStreamInfo(new StreamContent(streamInfoByAppAndStream)); - redisCatchStorage.addStream(mediaInfo, type, param.getApp(), param.getStream(), param); - if (param.getOriginType() == OriginType.RTSP_PUSH.ordinal() - || param.getOriginType() == OriginType.RTMP_PUSH.ordinal() - || param.getOriginType() == OriginType.RTC_PUSH.ordinal()) { - param.setSeverId(userSetting.getServerId()); - zlmMediaListManager.addPush(param); - } - } else { - // 兼容流注销时类型从redis记录获取 - OnStreamChangedHookParam onStreamChangedHookParam = redisCatchStorage.getStreamInfo( - param.getApp(), param.getStream(), param.getMediaServerId()); - if (onStreamChangedHookParam != null) { - type = OriginType.values()[onStreamChangedHookParam.getOriginType()].getType(); - redisCatchStorage.removeStream(mediaInfo.getId(), type, param.getApp(), param.getStream()); - } - GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream()); - if (gbStream != null) { -// eventPublisher.catalogEventPublishForStream(null, gbStream, CatalogEvent.OFF); - } - zlmMediaListManager.removeMedia(param.getApp(), param.getStream()); - } - GbStream gbStream = storager.getGbStream(param.getApp(), param.getStream()); - if (gbStream != null) { - if (userSetting.isUsePushingAsStatus()) { - eventPublisher.catalogEventPublishForStream(null, gbStream, param.isRegist()?CatalogEvent.ON:CatalogEvent.OFF); - } - } - if (type != null) { - // 发送流变化redis消息 - JSONObject jsonObject = new JSONObject(); - jsonObject.put("serverId", userSetting.getServerId()); - jsonObject.put("app", param.getApp()); - jsonObject.put("stream", param.getStream()); - jsonObject.put("register", param.isRegist()); - jsonObject.put("mediaServerId", param.getMediaServerId()); - redisCatchStorage.sendStreamChangeMsg(type, jsonObject); - } - } - } - if (!param.isRegist()) { - List sendRtpItems = redisCatchStorage.querySendRTPServerByStream(param.getStream()); - if (sendRtpItems.size() > 0) { - for (SendRtpItem sendRtpItem : sendRtpItems) { - if (sendRtpItem != null && sendRtpItem.getApp().equals(param.getApp())) { - String platformId = sendRtpItem.getPlatformId(); - ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); - Device device = deviceService.getDevice(platformId); - - try { - if (platform != null) { - commanderFroPlatform.streamByeCmd(platform, sendRtpItem); - redisCatchStorage.deleteSendRTPServer(platformId, sendRtpItem.getChannelId(), - sendRtpItem.getCallId(), sendRtpItem.getStreamId()); - } else { - cmder.streamByeCmd(device, sendRtpItem.getChannelId(), param.getStream(), sendRtpItem.getCallId()); - } - } catch (SipException | InvalidArgumentException | ParseException | - SsrcTransactionNotFoundException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - } - } - } - } - } - } - }); - - return HookResult.SUCCESS(); - } - - /** - * 流无人观看时事件,用户可以通过此事件选择是否关闭无人看的流。 - */ - @ResponseBody - @PostMapping(value = "/on_stream_none_reader", produces = "application/json;charset=UTF-8") - public JSONObject onStreamNoneReader(@RequestBody OnStreamNoneReaderHookParam param) { - - logger.info("[ZLM HOOK]流无人观看:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), - param.getApp(), param.getStream()); - JSONObject ret = new JSONObject(); - ret.put("code", 0); - // 国标类型的流 - if ("rtp".equals(param.getApp())) { - ret.put("close", userSetting.getStreamOnDemand()); - // 国标流, 点播/录像回放/录像下载 - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, param.getStream()); - // 点播 - if (inviteInfo != null) { - // 录像下载 - if (inviteInfo.getType() == InviteSessionType.DOWNLOAD) { - ret.put("close", false); - return ret; - } - // 收到无人观看说明流也没有在往上级推送 - if (redisCatchStorage.isChannelSendingRTP(inviteInfo.getChannelId())) { - List sendRtpItems = redisCatchStorage.querySendRTPServerByChnnelId( - inviteInfo.getChannelId()); - if (sendRtpItems.size() > 0) { - for (SendRtpItem sendRtpItem : sendRtpItems) { - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); - try { - commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - } - redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(), - sendRtpItem.getCallId(), sendRtpItem.getStreamId()); - if (InviteStreamType.PUSH == sendRtpItem.getPlayType()) { - MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0, - sendRtpItem.getApp(), sendRtpItem.getStreamId(), sendRtpItem.getChannelId(), - sendRtpItem.getPlatformId(), parentPlatform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId()); - messageForPushChannel.setPlatFormIndex(parentPlatform.getId()); - redisCatchStorage.sendPlatformStopPlayMsg(messageForPushChannel); - } - } - } - } - Device device = deviceService.getDevice(inviteInfo.getDeviceId()); - if (device != null) { - try { - // 多查询一次防止已经被处理了 - InviteInfo info = inviteStreamService.getInviteInfo(inviteInfo.getType(), - inviteInfo.getDeviceId(), inviteInfo.getChannelId(), inviteInfo.getStream()); - if (info != null) { - cmder.streamByeCmd(device, inviteInfo.getChannelId(), - inviteInfo.getStream(), null); - }else { - logger.info("[无人观看] 未找到设备的点播信息: {}, 流:{}", inviteInfo.getDeviceId(), param.getStream()); - } - } catch (InvalidArgumentException | ParseException | SipException | - SsrcTransactionNotFoundException e) { - logger.error("[无人观看]点播, 发送BYE失败 {}", e.getMessage()); - } - }else { - logger.info("[无人观看] 未找到设备: {},流:{}", inviteInfo.getDeviceId(), param.getStream()); - } - - inviteStreamService.removeInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), - inviteInfo.getChannelId(), inviteInfo.getStream()); - storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); - return ret; - } - } else { - // 非国标流 推流/拉流代理 - // 拉流代理 - StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); - if (streamProxyItem != null) { - if (streamProxyItem.isEnableRemoveNoneReader()) { - // 无人观看自动移除 - ret.put("close", true); - streamProxyService.del(param.getApp(), param.getStream()); - String url = streamProxyItem.getUrl() != null ? streamProxyItem.getUrl() : streamProxyItem.getSrcUrl(); - logger.info("[{}/{}]<-[{}] 拉流代理无人观看已经移除", param.getApp(), param.getStream(), url); - } else if (streamProxyItem.isEnableDisableNoneReader()) { - // 无人观看停用 - ret.put("close", true); - // 修改数据 - streamProxyService.stop(param.getApp(), param.getStream()); - } else { - // 无人观看不做处理 - ret.put("close", false); - } - return ret; - } - // TODO 推流具有主动性,暂时不做处理 -// StreamPushItem streamPushItem = streamPushService.getPush(app, streamId); -// if (streamPushItem != null) { -// // TODO 发送停止 -// -// } - } - return ret; - } - - /** - * 流未找到事件,用户可以在此事件触发时,立即去拉流,这样可以实现按需拉流;此事件对回复不敏感。 - */ - @ResponseBody - @PostMapping(value = "/on_stream_not_found", produces = "application/json;charset=UTF-8") - public DeferredResult onStreamNotFound(@RequestBody OnStreamNotFoundHookParam param) { - logger.info("[ZLM HOOK] 流未找到:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); - - DeferredResult defaultResult = new DeferredResult<>(); - - MediaServerItem mediaInfo = mediaServerService.getOne(param.getMediaServerId()); - if (!userSetting.isAutoApplyPlay() || mediaInfo == null) { - defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg())); - return defaultResult; - } - - if ("rtp".equals(param.getApp())) { - String[] s = param.getStream().split("_"); - if ((s.length != 2 && s.length != 4)) { - defaultResult.setResult(HookResult.SUCCESS()); - return defaultResult; - } - String deviceId = s[0]; - String channelId = s[1]; - Device device = redisCatchStorage.getDevice(deviceId); - if (device == null || !device.isOnLine()) { - defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg())); - return defaultResult; - } - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); - if (deviceChannel == null) { - defaultResult.setResult(new HookResult(ErrorCode.ERROR404.getCode(), ErrorCode.ERROR404.getMsg())); - return defaultResult; - } - if (s.length == 2) { - logger.info("[ZLM HOOK] 预览流未找到, 发起自动点播:{}->{}->{}/{}", param.getMediaServerId(), param.getSchema(), param.getApp(), param.getStream()); - - RequestMessage msg = new RequestMessage(); - String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId; - boolean exist = resultHolder.exist(key, null); - msg.setKey(key); - String uuid = UUID.randomUUID().toString(); - msg.setId(uuid); - DeferredResult result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); - - result.onTimeout(() -> { - logger.info("[ZLM HOOK] 预览流自动点播, 等待超时"); - msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "点播超时")); - resultHolder.invokeAllResult(msg); - inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - storager.stopPlay(deviceId, channelId); - }); - - resultHolder.put(key, uuid, result); - - if (!exist) { - playService.play(mediaInfo, deviceId, channelId, null, (code, message, data) -> { - msg.setData(new HookResult(code, message)); - resultHolder.invokeResult(msg); - }); - } - return result; - }else if(s.length == 4){ - // 此时为录像回放, 录像回放格式为> 设备ID_通道ID_开始时间_结束时间 - String startTimeStr = s[2]; - String endTimeStr = s[3]; - if (startTimeStr == null || endTimeStr == null || startTimeStr.length() != 14 || endTimeStr.length() != 14) { - defaultResult.setResult(HookResult.SUCCESS()); - return defaultResult; - } - String startTime = DateUtil.urlToyyyy_MM_dd_HH_mm_ss(startTimeStr); - String endTime = DateUtil.urlToyyyy_MM_dd_HH_mm_ss(endTimeStr); - logger.info("[ZLM HOOK] 回放流未找到, 发起自动点播:{}->{}->{}/{}-{}-{}", - param.getMediaServerId(), param.getSchema(), - param.getApp(), param.getStream(), - startTime, endTime - ); - RequestMessage msg = new RequestMessage(); - String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId; - boolean exist = resultHolder.exist(key, null); - msg.setKey(key); - String uuid = UUID.randomUUID().toString(); - msg.setId(uuid); - DeferredResult result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); - - result.onTimeout(() -> { - logger.info("[ZLM HOOK] 回放流自动点播, 等待超时"); - // 释放rtpserver - msg.setData(new HookResult(ErrorCode.ERROR100.getCode(), "点播超时")); - resultHolder.invokeResult(msg); - }); - - resultHolder.put(key, uuid, result); - - if (!exist) { - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaInfo, param.getStream(), null, - device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam()); - playService.playBack(mediaInfo, ssrcInfo, deviceId, channelId, startTime, endTime, (code, message, data) -> { - msg.setData(new HookResult(code, message)); - resultHolder.invokeResult(msg); - }); - } - return result; - }else { - defaultResult.setResult(HookResult.SUCCESS()); - return defaultResult; - } - - } else { - // 拉流代理 - StreamProxyItem streamProxyByAppAndStream = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); - if (streamProxyByAppAndStream != null && streamProxyByAppAndStream.isEnableDisableNoneReader()) { - streamProxyService.start(param.getApp(), param.getStream()); - } - DeferredResult result = new DeferredResult<>(); - result.setResult(HookResult.SUCCESS()); - return result; - } - } - - /** - * 服务器启动事件,可以用于监听服务器崩溃重启;此事件对回复不敏感。 - */ - @ResponseBody - @PostMapping(value = "/on_server_started", produces = "application/json;charset=UTF-8") - public HookResult onServerStarted(HttpServletRequest request, @RequestBody JSONObject jsonObject) { - - jsonObject.put("ip", request.getRemoteAddr()); - ZLMServerConfig zlmServerConfig = JSON.to(ZLMServerConfig.class, jsonObject); - zlmServerConfig.setIp(request.getRemoteAddr()); - logger.info("[ZLM HOOK] zlm 启动 " + zlmServerConfig.getGeneralMediaServerId()); - taskExecutor.execute(() -> { - List subscribes = this.subscribe.getSubscribes(HookType.on_server_started); - if (subscribes != null && subscribes.size() > 0) { - for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { - subscribe.response(null, zlmServerConfig); - } - } - mediaServerService.zlmServerOnline(zlmServerConfig); - }); - - return HookResult.SUCCESS(); - } - - /** - * 发送rtp(startSendRtp)被动关闭时回调 - */ - @ResponseBody - @PostMapping(value = "/on_send_rtp_stopped", produces = "application/json;charset=UTF-8") - public HookResult onSendRtpStopped(HttpServletRequest request, @RequestBody OnSendRtpStoppedHookParam param) { - - logger.info("[ZLM HOOK] rtp发送关闭:{}->{}/{}", param.getMediaServerId(), param.getApp(), param.getStream()); - - // 查找对应的上级推流,发送停止 - if (!"rtp".equals(param.getApp())) { - return HookResult.SUCCESS(); - } - taskExecutor.execute(() -> { - List sendRtpItems = redisCatchStorage.querySendRTPServerByStream(param.getStream()); - if (sendRtpItems.size() > 0) { - for (SendRtpItem sendRtpItem : sendRtpItems) { - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); - ssrcFactory.releaseSsrc(sendRtpItem.getMediaServerId(), sendRtpItem.getSsrc()); - try { - commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem.getCallId()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - } - redisCatchStorage.deleteSendRTPServer(parentPlatform.getServerGBId(), sendRtpItem.getChannelId(), - sendRtpItem.getCallId(), sendRtpItem.getStreamId()); - } - } - }); - - return HookResult.SUCCESS(); - } - - /** - * rtpServer收流超时 - */ - @ResponseBody - @PostMapping(value = "/on_rtp_server_timeout", produces = "application/json;charset=UTF-8") - public HookResult onRtpServerTimeout(HttpServletRequest request, @RequestBody OnRtpServerTimeoutHookParam param) { - logger.info("[ZLM HOOK] rtpServer收流超时:{}->{}({})", param.getMediaServerId(), param.getStream_id(), param.getSsrc()); - - taskExecutor.execute(() -> { - JSONObject json = (JSONObject) JSON.toJSON(param); - List subscribes = this.subscribe.getSubscribes(HookType.on_rtp_server_timeout); - if (subscribes != null && subscribes.size() > 0) { - for (ZlmHttpHookSubscribe.Event subscribe : subscribes) { - subscribe.response(null, param); - } - } - }); - - return HookResult.SUCCESS(); - } - - private Map urlParamToMap(String params) { - HashMap map = new HashMap<>(); - if (ObjectUtils.isEmpty(params)) { - return map; - } - String[] paramsArray = params.split("&"); - if (paramsArray.length == 0) { - return map; - } - for (String param : paramsArray) { - String[] paramArray = param.split("="); - if (paramArray.length == 2) { - map.put(paramArray[0], paramArray[1]); - } - } - return map; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java deleted file mode 100644 index e5ae2c2a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.media.zlm.dto.*; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IStreamProxyService; -import com.genersoft.iot.vmp.service.IStreamPushService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; -import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; -import com.genersoft.iot.vmp.storager.dao.StreamPushMapper; -import com.genersoft.iot.vmp.utils.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.text.ParseException; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - -/** - * @author lin - */ -@Component -public class ZLMMediaListManager { - - private Logger logger = LoggerFactory.getLogger("ZLMMediaListManager"); - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private GbStreamMapper gbStreamMapper; - - @Autowired - private IGbStreamService gbStreamService; - - @Autowired - private PlatformGbStreamMapper platformGbStreamMapper; - - @Autowired - private IStreamPushService streamPushService; - - @Autowired - private IStreamProxyService streamProxyService; - - @Autowired - private StreamPushMapper streamPushMapper; - - @Autowired - private ZlmHttpHookSubscribe subscribe; - - @Autowired - private UserSetting userSetting; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private IMediaServerService mediaServerService; - - private Map channelOnPublishEvents = new ConcurrentHashMap<>(); - - public StreamPushItem addPush(OnStreamChangedHookParam onStreamChangedHookParam) { - StreamPushItem transform = streamPushService.transform(onStreamChangedHookParam); - StreamPushItem pushInDb = streamPushService.getPush(onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream()); - transform.setPushIng(onStreamChangedHookParam.isRegist()); - transform.setUpdateTime(DateUtil.getNow()); - transform.setPushTime(DateUtil.getNow()); - transform.setSelf(userSetting.getServerId().equals(onStreamChangedHookParam.getSeverId())); - if (pushInDb == null) { - transform.setCreateTime(DateUtil.getNow()); - streamPushMapper.insert(transform); - }else { - streamPushService.update(transform, Wrappers.lambdaUpdate() - .eq(StreamPushItem::getApp, transform.getApp()) - .eq(StreamPushItem::getStream, transform.getStream())); - gbStreamMapper.updateMediaServer(onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream(), onStreamChangedHookParam.getMediaServerId()); - } - ChannelOnlineEvent channelOnlineEventLister = getChannelOnlineEventLister(transform.getApp(), transform.getStream()); - if ( channelOnlineEventLister != null) { - try { - channelOnlineEventLister.run(transform.getApp(), transform.getStream(), transform.getServerId());; - } catch (ParseException e) { - logger.error("addPush: ", e); - } - removedChannelOnlineEventLister(transform.getApp(), transform.getStream()); - } - return transform; - } - - public void sendStreamEvent(String app, String stream, String mediaServerId) { - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); - // 查看推流状态 - Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, app, stream); - if (streamReady != null && streamReady) { - ChannelOnlineEvent channelOnlineEventLister = getChannelOnlineEventLister(app, stream); - if (channelOnlineEventLister != null) { - try { - channelOnlineEventLister.run(app, stream, mediaServerId); - } catch (ParseException e) { - logger.error("sendStreamEvent: ", e); - } - removedChannelOnlineEventLister(app, stream); - } - } - } - - public int removeMedia(String app, String streamId) { - // 查找是否关联了国标, 关联了不删除, 置为离线 - GbStream gbStream = gbStreamService.selectByAppAndStream(app, streamId); - int result; - if (gbStream == null) { - result = storager.removeMedia(app, streamId); - }else { - result =storager.mediaOffline(app, streamId); - } - return result; - } - - public void addChannelOnlineEventLister(String app, String stream, ChannelOnlineEvent callback) { - this.channelOnPublishEvents.put(app + "_" + stream, callback); - } - - public void removedChannelOnlineEventLister(String app, String stream) { - this.channelOnPublishEvents.remove(app + "_" + stream); - } - - public ChannelOnlineEvent getChannelOnlineEventLister(String app, String stream) { - return this.channelOnPublishEvents.get(app + "_" + stream); - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java deleted file mode 100644 index 52bc9028..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java +++ /dev/null @@ -1,401 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import okhttp3.*; -import okhttp3.logging.HttpLoggingInterceptor; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Component; - -import java.io.*; -import java.net.ConnectException; -import java.net.SocketTimeoutException; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; -import java.util.concurrent.TimeUnit; - -@Component -public class ZLMRESTfulUtils { - - private final static Logger logger = LoggerFactory.getLogger(ZLMRESTfulUtils.class); - - private OkHttpClient client; - - - - public interface RequestCallback{ - void run(JSONObject response); - } - - private OkHttpClient getClient(){ - return getClient(null); - } - - private OkHttpClient getClient(Integer readTimeOut){ - if (client == null) { - if (readTimeOut == null) { - readTimeOut = 10; - } - OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); - //todo 暂时写死超时时间 均为5s - // 设置连接超时时间 - httpClientBuilder.connectTimeout(8,TimeUnit.SECONDS); - // 设置读取超时时间 - httpClientBuilder.readTimeout(readTimeOut,TimeUnit.SECONDS); - // 设置连接池 - httpClientBuilder.connectionPool(new ConnectionPool(16, 5, TimeUnit.MINUTES)); - if (logger.isDebugEnabled()) { - HttpLoggingInterceptor logging = new HttpLoggingInterceptor(message -> { - logger.debug("http请求参数:" + message); - }); - logging.setLevel(HttpLoggingInterceptor.Level.BASIC); - // OkHttp進行添加攔截器loggingInterceptor - httpClientBuilder.addInterceptor(logging); - } - client = httpClientBuilder.build(); - } - return client; - - } - - public JSONObject sendPost(MediaServerItem mediaServerItem, String api, Map param, RequestCallback callback) { - return sendPost(mediaServerItem, api, param, callback, null); - } - - - public JSONObject sendPost(MediaServerItem mediaServerItem, String api, Map param, RequestCallback callback, Integer readTimeOut) { - OkHttpClient client = getClient(readTimeOut); - - if (mediaServerItem == null) { - return null; - } - String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api); - JSONObject responseJSON = new JSONObject(); - //-2自定义流媒体 调用错误码 - responseJSON.put("code",-2); - responseJSON.put("msg","流媒体调用失败"); - - FormBody.Builder builder = new FormBody.Builder(); - builder.add("secret",mediaServerItem.getSecret()); - if (param != null && param.keySet().size() > 0) { - for (String key : param.keySet()){ - if (param.get(key) != null) { - builder.add(key, param.get(key).toString()); - } - } - } - - FormBody body = builder.build(); - - Request request = new Request.Builder() - .post(body) - .url(url) - .build(); - if (callback == null) { - try { - Response response = client.newCall(request).execute(); - if (response.isSuccessful()) { - ResponseBody responseBody = response.body(); - if (responseBody != null) { - String responseStr = responseBody.string(); - responseJSON = JSON.parseObject(responseStr); - } - }else { - response.close(); - Objects.requireNonNull(response.body()).close(); - } - }catch (IOException e) { - logger.error(String.format("[ %s ]请求失败: %s", url, e.getMessage())); - - if(e instanceof SocketTimeoutException){ - //读取超时超时异常 - logger.error(String.format("读取ZLM数据失败: %s, %s", url, e.getMessage())); - } - if(e instanceof ConnectException){ - //判断连接异常,我这里是报Failed to connect to 10.7.5.144 - logger.error(String.format("连接ZLM失败: %s, %s", url, e.getMessage())); - } - - }catch (Exception e){ - logger.error(String.format("访问ZLM失败: %s, %s", url, e.getMessage())); - } - }else { - client.newCall(request).enqueue(new Callback(){ - - @Override - public void onResponse(@NotNull Call call, @NotNull Response response){ - if (response.isSuccessful()) { - try { - String responseStr = Objects.requireNonNull(response.body()).string(); - callback.run(JSON.parseObject(responseStr)); - } catch (IOException e) { - logger.error(String.format("[ %s ]请求失败: %s", url, e.getMessage())); - } - - }else { - response.close(); - Objects.requireNonNull(response.body()).close(); - } - } - - @Override - public void onFailure(@NotNull Call call, @NotNull IOException e) { - logger.error(String.format("连接ZLM失败: %s, %s", call.request().toString(), e.getMessage())); - - if(e instanceof SocketTimeoutException){ - //读取超时超时异常 - logger.error(String.format("读取ZLM数据失败: %s, %s", call.request().toString(), e.getMessage())); - } - if(e instanceof ConnectException){ - //判断连接异常,我这里是报Failed to connect to 10.7.5.144 - logger.error(String.format("连接ZLM失败: %s, %s", call.request().toString(), e.getMessage())); - } - } - }); - } - - - - return responseJSON; - } - - public void sendGetForImg(MediaServerItem mediaServerItem, String api, Map params, String targetPath, String fileName) { - String url = String.format("http://%s:%s/index/api/%s", mediaServerItem.getIp(), mediaServerItem.getHttpPort(), api); - HttpUrl parseUrl = HttpUrl.parse(url); - if (parseUrl == null) { - return; - } - HttpUrl.Builder httpBuilder = parseUrl.newBuilder(); - - httpBuilder.addQueryParameter("secret", mediaServerItem.getSecret()); - if (params != null) { - for (Map.Entry param : params.entrySet()) { - httpBuilder.addQueryParameter(param.getKey(), param.getValue().toString()); - } - } - - Request request = new Request.Builder() - .url(httpBuilder.build()) - .build(); - logger.info(request.toString()); - try { - OkHttpClient client = getClient(); - Response response = client.newCall(request).execute(); - if (response.isSuccessful()) { - if (targetPath != null) { - File snapFolder = new File(targetPath); - if (!snapFolder.exists()) { - if (!snapFolder.mkdirs()) { - logger.warn("{}路径创建失败", snapFolder.getAbsolutePath()); - } - - } - File snapFile = new File(targetPath + File.separator + fileName); - FileOutputStream outStream = new FileOutputStream(snapFile); - - outStream.write(Objects.requireNonNull(response.body()).bytes()); - outStream.flush(); - outStream.close(); - } else { - logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message())); - } - } else { - logger.error(String.format("[ %s ]请求失败: %s %s", url, response.code(), response.message())); - } - Objects.requireNonNull(response.body()).close(); - } catch (ConnectException e) { - logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage())); - logger.info("请检查media配置并确认ZLM已启动..."); - } catch (IOException e) { - logger.error(String.format("[ %s ]请求失败: %s", url, e.getMessage())); - } - } - - public JSONObject isMediaOnline(MediaServerItem mediaServerItem, String app, String stream, String schema){ - Map param = new HashMap<>(); - if (app != null) { - param.put("app",app); - } - if (stream != null) { - param.put("stream",stream); - } - if (schema != null) { - param.put("schema",schema); - } - param.put("vhost","__defaultVhost__"); - return sendPost(mediaServerItem, "isMediaOnline", param, null); - } - - public JSONObject getMediaList(MediaServerItem mediaServerItem, String app, String stream, String schema, RequestCallback callback){ - Map param = new HashMap<>(); - if (app != null) { - param.put("app",app); - } - if (stream != null) { - param.put("stream",stream); - } - if (schema != null) { - param.put("schema",schema); - } - param.put("vhost","__defaultVhost__"); - return sendPost(mediaServerItem, "getMediaList",param, callback); - } - - public JSONObject getMediaList(MediaServerItem mediaServerItem, String app, String stream){ - return getMediaList(mediaServerItem, app, stream,null, null); - } - - public JSONObject getMediaList(MediaServerItem mediaServerItem, RequestCallback callback){ - return sendPost(mediaServerItem, "getMediaList",null, callback); - } - - public JSONObject getMediaInfo(MediaServerItem mediaServerItem, String app, String schema, String stream){ - Map param = new HashMap<>(); - param.put("app",app); - param.put("schema",schema); - param.put("stream",stream); - param.put("vhost","__defaultVhost__"); - return sendPost(mediaServerItem, "getMediaInfo",param, null); - } - - public JSONObject getRtpInfo(MediaServerItem mediaServerItem, String stream_id){ - Map param = new HashMap<>(); - param.put("stream_id",stream_id); - return sendPost(mediaServerItem, "getRtpInfo",param, null); - } - - public JSONObject addFFmpegSource(MediaServerItem mediaServerItem, String src_url, String dst_url, String timeout_ms, - boolean enable_audio, boolean enable_mp4, String ffmpeg_cmd_key){ - logger.info(src_url); - logger.info(dst_url); - Map param = new HashMap<>(); - param.put("src_url", src_url); - param.put("dst_url", dst_url); - param.put("timeout_ms", timeout_ms); - param.put("enable_mp4", enable_mp4); - param.put("ffmpeg_cmd_key", ffmpeg_cmd_key); - return sendPost(mediaServerItem, "addFFmpegSource",param, null); - } - - public JSONObject delFFmpegSource(MediaServerItem mediaServerItem, String key){ - Map param = new HashMap<>(); - param.put("key", key); - return sendPost(mediaServerItem, "delFFmpegSource",param, null); - } - - public JSONObject delStreamProxy(MediaServerItem mediaServerItem, String key){ - Map param = new HashMap<>(); - param.put("key", key); - return sendPost(mediaServerItem, "delStreamProxy",param, null); - } - - public JSONObject getMediaServerConfig(MediaServerItem mediaServerItem){ - return sendPost(mediaServerItem, "getServerConfig",null, null); - } - - public JSONObject setServerConfig(MediaServerItem mediaServerItem, Map param){ - return sendPost(mediaServerItem,"setServerConfig",param, null); - } - - public JSONObject openRtpServer(MediaServerItem mediaServerItem, Map param){ - return sendPost(mediaServerItem, "openRtpServer",param, null); - } - - public JSONObject closeRtpServer(MediaServerItem mediaServerItem, Map param) { - return sendPost(mediaServerItem, "closeRtpServer",param, null); - } - - public void closeRtpServer(MediaServerItem mediaServerItem, Map param, RequestCallback callback) { - sendPost(mediaServerItem, "closeRtpServer",param, callback); - } - - public JSONObject listRtpServer(MediaServerItem mediaServerItem) { - return sendPost(mediaServerItem, "listRtpServer",null, null); - } - - public JSONObject startSendRtp(MediaServerItem mediaServerItem, Map param) { - return sendPost(mediaServerItem, "startSendRtp",param, null); - } - - public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map param) { - return sendPost(mediaServerItem, "startSendRtpPassive",param, null); - } - - public JSONObject stopSendRtp(MediaServerItem mediaServerItem, Map param) { - return sendPost(mediaServerItem, "stopSendRtp",param, null); - } - - public JSONObject restartServer(MediaServerItem mediaServerItem) { - return sendPost(mediaServerItem, "restartServer",null, null); - } - - public JSONObject addStreamProxy(MediaServerItem mediaServerItem, String app, String stream, String url, boolean enable_audio, boolean enable_mp4, String rtp_type) { - Map param = new HashMap<>(); - param.put("vhost", "__defaultVhost__"); - param.put("app", app); - param.put("stream", stream); - param.put("url", url); - param.put("enable_mp4", enable_mp4?1:0); - param.put("enable_audio", enable_audio?1:0); - param.put("rtp_type", rtp_type); - return sendPost(mediaServerItem, "addStreamProxy",param, null, 20); - } - - public JSONObject closeStreams(MediaServerItem mediaServerItem, String app, String stream) { - Map param = new HashMap<>(); - param.put("vhost", "__defaultVhost__"); - param.put("app", app); - param.put("stream", stream); - param.put("force", 1); - return sendPost(mediaServerItem, "close_streams",param, null); - } - - public JSONObject getAllSession(MediaServerItem mediaServerItem) { - return sendPost(mediaServerItem, "getAllSession",null, null); - } - - public void kickSessions(MediaServerItem mediaServerItem, String localPortSStr) { - Map param = new HashMap<>(); - param.put("local_port", localPortSStr); - sendPost(mediaServerItem, "kick_sessions",param, null); - } - - public void getSnap(MediaServerItem mediaServerItem, String streamUrl, int timeout_sec, int expire_sec, String targetPath, String fileName) { - Map param = new HashMap<>(3); - param.put("url", streamUrl); - param.put("timeout_sec", timeout_sec); - param.put("expire_sec", expire_sec); - sendGetForImg(mediaServerItem, "getSnap", param, targetPath, fileName); - } - - public JSONObject pauseRtpCheck(MediaServerItem mediaServerItem, String streamId) { - Map param = new HashMap<>(1); - param.put("stream_id", streamId); - return sendPost(mediaServerItem, "pauseRtpCheck",param, null); - } - - public JSONObject resumeRtpCheck(MediaServerItem mediaServerItem, String streamId) { - Map param = new HashMap<>(1); - param.put("stream_id", streamId); - return sendPost(mediaServerItem, "resumeRtpCheck",param, null); - } - - public JSONObject connectRtpServer(MediaServerItem mediaServerItem, String dst_url, int dst_port, String stream_id) { - Map param = new HashMap<>(1); - param.put("dst_url", dst_url); - param.put("dst_port", dst_port); - param.put("stream_id", stream_id); - return sendPost(mediaServerItem, "connectRtpServer",param, null); - } - - public JSONObject updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc) { - Map param = new HashMap<>(1); - param.put("ssrc", ssrc); - param.put("stream_id", streamId); - return sendPost(mediaServerItem, "updateRtpServerSSRC",param, null); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java deleted file mode 100644 index 4a781f31..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java +++ /dev/null @@ -1,173 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.MediaConfig; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForServerStarted; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.CommandLineRunner; -import org.springframework.core.annotation.Order; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - -@Component -@Order(value=12) -public class ZLMRunner implements CommandLineRunner { - - private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class); - - private Map startGetMedia; - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private ZlmHttpHookSubscribe hookSubscribe; - - @Autowired - private EventPublisher publisher; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private MediaConfig mediaConfig; - - @Autowired - private DynamicTask dynamicTask; - - - @Override - public void run(String... strings) throws Exception { - mediaServerService.clearMediaServerForOnline(); - MediaServerItem defaultMediaServer = mediaServerService.getDefaultMediaServer(); - if (defaultMediaServer == null) { - mediaServerService.addToDatabase(mediaConfig.getMediaSerItem()); - }else { - MediaServerItem mediaSerItem = mediaConfig.getMediaSerItem(); - mediaServerService.updateToDatabase(mediaSerItem); - } - mediaServerService.syncCatchFromDatabase(); - HookSubscribeForServerStarted hookSubscribeForServerStarted = HookSubscribeFactory.on_server_started(); - // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 - hookSubscribe.addSubscribe(hookSubscribeForServerStarted, - (mediaServerItem, hookParam)->{ - ZLMServerConfig zlmServerConfig = (ZLMServerConfig)hookParam; - if (zlmServerConfig !=null ) { - if (startGetMedia != null) { - startGetMedia.remove(zlmServerConfig.getGeneralMediaServerId()); - if (startGetMedia.size() == 0) { - hookSubscribe.removeSubscribe(HookSubscribeFactory.on_server_started()); - } - } - } - }); - - // 获取zlm信息 - logger.info("[zlm] 等待默认zlm中..."); - - // 获取所有的zlm, 并开启主动连接 - List all = mediaServerService.getAllFromDatabase(); - Map allMap = new HashMap<>(); - mediaServerService.updateVmServer(all); - if (all.size() == 0) { - all.add(mediaConfig.getMediaSerItem()); - } - for (MediaServerItem mediaServerItem : all) { - if (startGetMedia == null) { - startGetMedia = new ConcurrentHashMap<>(); - } - startGetMedia.put(mediaServerItem.getId(), true); - connectZlmServer(mediaServerItem); - allMap.put(mediaServerItem.getId(), mediaServerItem); - } - String taskKey = "zlm-connect-timeout"; - dynamicTask.startDelay(taskKey, ()->{ - if (startGetMedia != null && startGetMedia.size() > 0) { - Set allZlmId = startGetMedia.keySet(); - for (String id : allZlmId) { - logger.error("[ {} ]]主动连接失败,不再尝试连接", id); - } - startGetMedia = null; - } - // 获取redis中所有的zlm - List allInRedis = mediaServerService.getAll(); - for (MediaServerItem mediaServerItem : allInRedis) { - if (!allMap.containsKey(mediaServerItem.getId())) { - mediaServerService.delete(mediaServerItem.getId()); - } - } - }, 60 * 1000 ); - } - - @Async("taskExecutor") - public void connectZlmServer(MediaServerItem mediaServerItem){ - String connectZlmServerTaskKey = "connect-zlm-" + mediaServerItem.getId(); - ZLMServerConfig zlmServerConfigFirst = getMediaServerConfig(mediaServerItem); - if (zlmServerConfigFirst != null) { - zlmServerConfigFirst.setIp(mediaServerItem.getIp()); - zlmServerConfigFirst.setHttpPort(mediaServerItem.getHttpPort()); - startGetMedia.remove(mediaServerItem.getId()); - if (startGetMedia.size() == 0) { - hookSubscribe.removeSubscribe(HookSubscribeFactory.on_server_started()); - } - mediaServerService.zlmServerOnline(zlmServerConfigFirst); - }else { - logger.info("[ {} ]-[ {}:{} ]主动连接失败, 清理相关资源, 开始尝试重试连接", - mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort()); - publisher.zlmOfflineEventPublish(mediaServerItem.getId()); - } - - dynamicTask.startCron(connectZlmServerTaskKey, ()->{ - ZLMServerConfig zlmServerConfig = getMediaServerConfig(mediaServerItem); - if (zlmServerConfig != null) { - dynamicTask.stop(connectZlmServerTaskKey); - zlmServerConfig.setIp(mediaServerItem.getIp()); - zlmServerConfig.setHttpPort(mediaServerItem.getHttpPort()); - startGetMedia.remove(mediaServerItem.getId()); - if (startGetMedia.size() == 0) { - hookSubscribe.removeSubscribe(HookSubscribeFactory.on_server_started()); - } - mediaServerService.zlmServerOnline(zlmServerConfig); - } - }, 2000); - } - - public ZLMServerConfig getMediaServerConfig(MediaServerItem mediaServerItem) { - if (startGetMedia == null) { return null;} - if (!mediaServerItem.isDefaultServer() && mediaServerService.getOne(mediaServerItem.getId()) == null) { - return null; - } - if ( startGetMedia.get(mediaServerItem.getId()) == null || !startGetMedia.get(mediaServerItem.getId())) { - return null; - } - JSONObject responseJson = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); - ZLMServerConfig zlmServerConfig = null; - if (responseJson != null) { - JSONArray data = responseJson.getJSONArray("data"); - if (data != null && data.size() > 0) { - zlmServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); - } - } else { - logger.error("[ {} ]-[ {}:{} ]主动连接失败, 2s后重试", - mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort()); - } - return zlmServerConfig; - - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java deleted file mode 100644 index 80910c02..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerConfig.java +++ /dev/null @@ -1,1214 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.alibaba.fastjson2.annotation.JSONField; -import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam; - -public class ZLMServerConfig extends HookParam { - - @JSONField(name = "api.apiDebug") - private String apiDebug; - - @JSONField(name = "api.secret") - private String apiSecret; - - @JSONField(name = "api.snapRoot") - private String apiSnapRoot; - - @JSONField(name = "api.defaultSnap") - private String apiDefaultSnap; - - @JSONField(name = "ffmpeg.bin") - private String ffmpegBin; - - @JSONField(name = "ffmpeg.cmd") - private String ffmpegCmd; - - @JSONField(name = "ffmpeg.snap") - private String ffmpegSnap; - - @JSONField(name = "ffmpeg.log") - private String ffmpegLog; - - @JSONField(name = "ffmpeg.restart_sec") - private String ffmpegRestartSec; - - @JSONField(name = "protocol.modify_stamp") - private String protocolModifyStamp; - - @JSONField(name = "protocol.enable_audio") - private String protocolEnableAudio; - - @JSONField(name = "protocol.add_mute_audio") - private String protocolAddMuteAudio; - - @JSONField(name = "protocol.continue_push_ms") - private String protocolContinuePushMs; - - @JSONField(name = "protocol.enable_hls") - private String protocolEnableHls; - - @JSONField(name = "protocol.enable_mp4") - private String protocolEnableMp4; - - @JSONField(name = "protocol.enable_rtsp") - private String protocolEnableRtsp; - - @JSONField(name = "protocol.enable_rtmp") - private String protocolEnableRtmp; - - @JSONField(name = "protocol.enable_ts") - private String protocolEnableTs; - - @JSONField(name = "protocol.enable_fmp4") - private String protocolEnableFmp4; - - @JSONField(name = "protocol.mp4_as_player") - private String protocolMp4AsPlayer; - - @JSONField(name = "protocol.mp4_max_second") - private String protocolMp4MaxSecond; - - @JSONField(name = "protocol.mp4_save_path") - private String protocolMp4SavePath; - - @JSONField(name = "protocol.hls_save_path") - private String protocolHlsSavePath; - - @JSONField(name = "protocol.hls_demand") - private String protocolHlsDemand; - - @JSONField(name = "protocol.rtsp_demand") - private String protocolRtspDemand; - - @JSONField(name = "protocol.rtmp_demand") - private String protocolRtmpDemand; - - @JSONField(name = "protocol.ts_demand") - private String protocolTsDemand; - - @JSONField(name = "protocol.fmp4_demand") - private String protocolFmp4Demand; - - @JSONField(name = "general.enableVhost") - private String generalEnableVhost; - - @JSONField(name = "general.flowThreshold") - private String generalFlowThreshold; - - @JSONField(name = "general.maxStreamWaitMS") - private String generalMaxStreamWaitMS; - - @JSONField(name = "general.streamNoneReaderDelayMS") - private int generalStreamNoneReaderDelayMS; - - @JSONField(name = "general.resetWhenRePlay") - private String generalResetWhenRePlay; - - @JSONField(name = "general.mergeWriteMS") - private String generalMergeWriteMS; - - @JSONField(name = "general.mediaServerId") - private String generalMediaServerId; - - @JSONField(name = "general.wait_track_ready_ms") - private String generalWaitTrackReadyMs; - - @JSONField(name = "general.wait_add_track_ms") - private String generalWaitAddTrackMs; - - @JSONField(name = "general.unready_frame_cache") - private String generalUnreadyFrameCache; - - - @JSONField(name = "ip") - private String ip; - - private String sdpIp; - - private String streamIp; - - private String hookIp; - - private String updateTime; - - private String createTime; - - @JSONField(name = "hls.fileBufSize") - private String hlsFileBufSize; - - @JSONField(name = "hls.filePath") - private String hlsFilePath; - - @JSONField(name = "hls.segDur") - private String hlsSegDur; - - @JSONField(name = "hls.segNum") - private String hlsSegNum; - - @JSONField(name = "hls.segRetain") - private String hlsSegRetain; - - @JSONField(name = "hls.broadcastRecordTs") - private String hlsBroadcastRecordTs; - - @JSONField(name = "hls.deleteDelaySec") - private String hlsDeleteDelaySec; - - @JSONField(name = "hls.segKeep") - private String hlsSegKeep; - - @JSONField(name = "hook.access_file_except_hls") - private String hookAccessFileExceptHLS; - - @JSONField(name = "hook.admin_params") - private String hookAdminParams; - - @JSONField(name = "hook.alive_interval") - private Float hookAliveInterval; - - @JSONField(name = "hook.enable") - private String hookEnable; - - @JSONField(name = "hook.on_flow_report") - private String hookOnFlowReport; - - @JSONField(name = "hook.on_http_access") - private String hookOnHttpAccess; - - @JSONField(name = "hook.on_play") - private String hookOnPlay; - - @JSONField(name = "hook.on_publish") - private String hookOnPublish; - - @JSONField(name = "hook.on_record_mp4") - private String hookOnRecordMp4; - - @JSONField(name = "hook.on_rtsp_auth") - private String hookOnRtspAuth; - - @JSONField(name = "hook.on_rtsp_realm") - private String hookOnRtspRealm; - - @JSONField(name = "hook.on_shell_login") - private String hookOnShellLogin; - - @JSONField(name = "hook.on_stream_changed") - private String hookOnStreamChanged; - - @JSONField(name = "hook.on_stream_none_reader") - private String hookOnStreamNoneReader; - - @JSONField(name = "hook.on_stream_not_found") - private String hookOnStreamNotFound; - - @JSONField(name = "hook.on_server_started") - private String hookOnServerStarted; - - @JSONField(name = "hook.on_server_keepalive") - private String hookOnServerKeepalive; - - @JSONField(name = "hook.on_send_rtp_stopped") - private String hookOnSendRtpStopped; - - @JSONField(name = "hook.on_rtp_server_timeout") - private String hookOnRtpServerTimeout; - - @JSONField(name = "hook.timeoutSec") - private String hookTimeoutSec; - - @JSONField(name = "http.charSet") - private String httpCharSet; - - @JSONField(name = "http.keepAliveSecond") - private String httpKeepAliveSecond; - - @JSONField(name = "http.maxReqCount") - private String httpMaxReqCount; - - @JSONField(name = "http.maxReqSize") - private String httpMaxReqSize; - - @JSONField(name = "http.notFound") - private String httpNotFound; - - @JSONField(name = "http.port") - private int httpPort; - - @JSONField(name = "http.rootPath") - private String httpRootPath; - - @JSONField(name = "http.sendBufSize") - private String httpSendBufSize; - - @JSONField(name = "http.sslport") - private int httpSSLport; - - @JSONField(name = "multicast.addrMax") - private String multicastAddrMax; - - @JSONField(name = "multicast.addrMin") - private String multicastAddrMin; - - @JSONField(name = "multicast.udpTTL") - private String multicastUdpTTL; - - @JSONField(name = "record.appName") - private String recordAppName; - - @JSONField(name = "record.filePath") - private String recordFilePath; - - @JSONField(name = "record.fileSecond") - private String recordFileSecond; - - @JSONField(name = "record.sampleMS") - private String recordFileSampleMS; - - @JSONField(name = "rtmp.handshakeSecond") - private String rtmpHandshakeSecond; - - @JSONField(name = "rtmp.keepAliveSecond") - private String rtmpKeepAliveSecond; - - @JSONField(name = "rtmp.modifyStamp") - private String rtmpModifyStamp; - - @JSONField(name = "rtmp.port") - private int rtmpPort; - - @JSONField(name = "rtmp.sslport") - private int rtmpSslPort; - - @JSONField(name = "rtp.audioMtuSize") - private String rtpAudioMtuSize; - - @JSONField(name = "rtp.clearCount") - private String rtpClearCount; - - @JSONField(name = "rtp.cycleMS") - private String rtpCycleMS; - - @JSONField(name = "rtp.maxRtpCount") - private String rtpMaxRtpCount; - - @JSONField(name = "rtp.videoMtuSize") - private String rtpVideoMtuSize; - - @JSONField(name = "rtp_proxy.checkSource") - private String rtpProxyCheckSource; - - @JSONField(name = "rtp_proxy.dumpDir") - private String rtpProxyDumpDir; - - @JSONField(name = "rtp_proxy.port") - private int rtpProxyPort; - - @JSONField(name = "rtp_proxy.port_range") - private String portRange; - - @JSONField(name = "rtp_proxy.timeoutSec") - private String rtpProxyTimeoutSec; - - @JSONField(name = "rtsp.authBasic") - private String rtspAuthBasic; - - @JSONField(name = "rtsp.handshakeSecond") - private String rtspHandshakeSecond; - - @JSONField(name = "rtsp.keepAliveSecond") - private String rtspKeepAliveSecond; - - @JSONField(name = "rtsp.port") - private int rtspPort; - - @JSONField(name = "rtsp.sslport") - private int rtspSSlport; - - @JSONField(name = "shell.maxReqSize") - private String shellMaxReqSize; - - @JSONField(name = "shell.shell") - private String shellPhell; - - - public String getHookIp() { - return hookIp; - } - - public void setHookIp(String hookIp) { - this.hookIp = hookIp; - } - - public String getApiDebug() { - return apiDebug; - } - - public void setApiDebug(String apiDebug) { - this.apiDebug = apiDebug; - } - - public String getApiSecret() { - return apiSecret; - } - - public void setApiSecret(String apiSecret) { - this.apiSecret = apiSecret; - } - - public String getFfmpegBin() { - return ffmpegBin; - } - - public void setFfmpegBin(String ffmpegBin) { - this.ffmpegBin = ffmpegBin; - } - - public String getFfmpegCmd() { - return ffmpegCmd; - } - - public void setFfmpegCmd(String ffmpegCmd) { - this.ffmpegCmd = ffmpegCmd; - } - - public String getFfmpegLog() { - return ffmpegLog; - } - - public void setFfmpegLog(String ffmpegLog) { - this.ffmpegLog = ffmpegLog; - } - - public String getGeneralEnableVhost() { - return generalEnableVhost; - } - - public void setGeneralEnableVhost(String generalEnableVhost) { - this.generalEnableVhost = generalEnableVhost; - } - - public String getGeneralMediaServerId() { - return generalMediaServerId; - } - - public void setGeneralMediaServerId(String generalMediaServerId) { - this.generalMediaServerId = generalMediaServerId; - } - - public String getGeneralFlowThreshold() { - return generalFlowThreshold; - } - - public void setGeneralFlowThreshold(String generalFlowThreshold) { - this.generalFlowThreshold = generalFlowThreshold; - } - - public String getGeneralMaxStreamWaitMS() { - return generalMaxStreamWaitMS; - } - - public void setGeneralMaxStreamWaitMS(String generalMaxStreamWaitMS) { - this.generalMaxStreamWaitMS = generalMaxStreamWaitMS; - } - - public int getGeneralStreamNoneReaderDelayMS() { - return generalStreamNoneReaderDelayMS; - } - - public void setGeneralStreamNoneReaderDelayMS(int generalStreamNoneReaderDelayMS) { - this.generalStreamNoneReaderDelayMS = generalStreamNoneReaderDelayMS; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public String getSdpIp() { - return sdpIp; - } - - public void setSdpIp(String sdpIp) { - this.sdpIp = sdpIp; - } - - public String getStreamIp() { - return streamIp; - } - - public void setStreamIp(String streamIp) { - this.streamIp = streamIp; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getHlsFileBufSize() { - return hlsFileBufSize; - } - - public void setHlsFileBufSize(String hlsFileBufSize) { - this.hlsFileBufSize = hlsFileBufSize; - } - - public String getHlsFilePath() { - return hlsFilePath; - } - - public void setHlsFilePath(String hlsFilePath) { - this.hlsFilePath = hlsFilePath; - } - - public String getHlsSegDur() { - return hlsSegDur; - } - - public void setHlsSegDur(String hlsSegDur) { - this.hlsSegDur = hlsSegDur; - } - - public String getHlsSegNum() { - return hlsSegNum; - } - - public void setHlsSegNum(String hlsSegNum) { - this.hlsSegNum = hlsSegNum; - } - - public String getHookAccessFileExceptHLS() { - return hookAccessFileExceptHLS; - } - - public void setHookAccessFileExceptHLS(String hookAccessFileExceptHLS) { - this.hookAccessFileExceptHLS = hookAccessFileExceptHLS; - } - - public String getHookAdminParams() { - return hookAdminParams; - } - - public void setHookAdminParams(String hookAdminParams) { - this.hookAdminParams = hookAdminParams; - } - - public String getHookEnable() { - return hookEnable; - } - - public void setHookEnable(String hookEnable) { - this.hookEnable = hookEnable; - } - - public String getHookOnFlowReport() { - return hookOnFlowReport; - } - - public void setHookOnFlowReport(String hookOnFlowReport) { - this.hookOnFlowReport = hookOnFlowReport; - } - - public String getHookOnHttpAccess() { - return hookOnHttpAccess; - } - - public void setHookOnHttpAccess(String hookOnHttpAccess) { - this.hookOnHttpAccess = hookOnHttpAccess; - } - - public String getHookOnPlay() { - return hookOnPlay; - } - - public void setHookOnPlay(String hookOnPlay) { - this.hookOnPlay = hookOnPlay; - } - - public String getHookOnPublish() { - return hookOnPublish; - } - - public void setHookOnPublish(String hookOnPublish) { - this.hookOnPublish = hookOnPublish; - } - - public String getHookOnRecordMp4() { - return hookOnRecordMp4; - } - - public void setHookOnRecordMp4(String hookOnRecordMp4) { - this.hookOnRecordMp4 = hookOnRecordMp4; - } - - public String getHookOnRtspAuth() { - return hookOnRtspAuth; - } - - public void setHookOnRtspAuth(String hookOnRtspAuth) { - this.hookOnRtspAuth = hookOnRtspAuth; - } - - public String getHookOnRtspRealm() { - return hookOnRtspRealm; - } - - public void setHookOnRtspRealm(String hookOnRtspRealm) { - this.hookOnRtspRealm = hookOnRtspRealm; - } - - public String getHookOnShellLogin() { - return hookOnShellLogin; - } - - public void setHookOnShellLogin(String hookOnShellLogin) { - this.hookOnShellLogin = hookOnShellLogin; - } - - public String getHookOnStreamChanged() { - return hookOnStreamChanged; - } - - public void setHookOnStreamChanged(String hookOnStreamChanged) { - this.hookOnStreamChanged = hookOnStreamChanged; - } - - public String getHookOnStreamNoneReader() { - return hookOnStreamNoneReader; - } - - public void setHookOnStreamNoneReader(String hookOnStreamNoneReader) { - this.hookOnStreamNoneReader = hookOnStreamNoneReader; - } - - public String getHookOnStreamNotFound() { - return hookOnStreamNotFound; - } - - public void setHookOnStreamNotFound(String hookOnStreamNotFound) { - this.hookOnStreamNotFound = hookOnStreamNotFound; - } - - public String getHookTimeoutSec() { - return hookTimeoutSec; - } - - public void setHookTimeoutSec(String hookTimeoutSec) { - this.hookTimeoutSec = hookTimeoutSec; - } - - public String getHttpCharSet() { - return httpCharSet; - } - - public void setHttpCharSet(String httpCharSet) { - this.httpCharSet = httpCharSet; - } - - public String getHttpKeepAliveSecond() { - return httpKeepAliveSecond; - } - - public void setHttpKeepAliveSecond(String httpKeepAliveSecond) { - this.httpKeepAliveSecond = httpKeepAliveSecond; - } - - public String getHttpMaxReqCount() { - return httpMaxReqCount; - } - - public void setHttpMaxReqCount(String httpMaxReqCount) { - this.httpMaxReqCount = httpMaxReqCount; - } - - public String getHttpMaxReqSize() { - return httpMaxReqSize; - } - - public void setHttpMaxReqSize(String httpMaxReqSize) { - this.httpMaxReqSize = httpMaxReqSize; - } - - public String getHttpNotFound() { - return httpNotFound; - } - - public void setHttpNotFound(String httpNotFound) { - this.httpNotFound = httpNotFound; - } - - public int getHttpPort() { - return httpPort; - } - - public void setHttpPort(int httpPort) { - this.httpPort = httpPort; - } - - public String getHttpRootPath() { - return httpRootPath; - } - - public void setHttpRootPath(String httpRootPath) { - this.httpRootPath = httpRootPath; - } - - public String getHttpSendBufSize() { - return httpSendBufSize; - } - - public void setHttpSendBufSize(String httpSendBufSize) { - this.httpSendBufSize = httpSendBufSize; - } - - public int getHttpSSLport() { - return httpSSLport; - } - - public void setHttpSSLport(int httpSSLport) { - this.httpSSLport = httpSSLport; - } - - public String getMulticastAddrMax() { - return multicastAddrMax; - } - - public void setMulticastAddrMax(String multicastAddrMax) { - this.multicastAddrMax = multicastAddrMax; - } - - public String getMulticastAddrMin() { - return multicastAddrMin; - } - - public void setMulticastAddrMin(String multicastAddrMin) { - this.multicastAddrMin = multicastAddrMin; - } - - public String getMulticastUdpTTL() { - return multicastUdpTTL; - } - - public void setMulticastUdpTTL(String multicastUdpTTL) { - this.multicastUdpTTL = multicastUdpTTL; - } - - public String getRecordAppName() { - return recordAppName; - } - - public void setRecordAppName(String recordAppName) { - this.recordAppName = recordAppName; - } - - public String getRecordFilePath() { - return recordFilePath; - } - - public void setRecordFilePath(String recordFilePath) { - this.recordFilePath = recordFilePath; - } - - public String getRecordFileSecond() { - return recordFileSecond; - } - - public void setRecordFileSecond(String recordFileSecond) { - this.recordFileSecond = recordFileSecond; - } - - public String getRecordFileSampleMS() { - return recordFileSampleMS; - } - - public void setRecordFileSampleMS(String recordFileSampleMS) { - this.recordFileSampleMS = recordFileSampleMS; - } - - public String getRtmpHandshakeSecond() { - return rtmpHandshakeSecond; - } - - public void setRtmpHandshakeSecond(String rtmpHandshakeSecond) { - this.rtmpHandshakeSecond = rtmpHandshakeSecond; - } - - public String getRtmpKeepAliveSecond() { - return rtmpKeepAliveSecond; - } - - public void setRtmpKeepAliveSecond(String rtmpKeepAliveSecond) { - this.rtmpKeepAliveSecond = rtmpKeepAliveSecond; - } - - public String getRtmpModifyStamp() { - return rtmpModifyStamp; - } - - public void setRtmpModifyStamp(String rtmpModifyStamp) { - this.rtmpModifyStamp = rtmpModifyStamp; - } - - public int getRtmpPort() { - return rtmpPort; - } - - public void setRtmpPort(int rtmpPort) { - this.rtmpPort = rtmpPort; - } - - public int getRtmpSslPort() { - return rtmpSslPort; - } - - public void setRtmpSslPort(int rtmpSslPort) { - this.rtmpSslPort = rtmpSslPort; - } - - public String getRtpAudioMtuSize() { - return rtpAudioMtuSize; - } - - public void setRtpAudioMtuSize(String rtpAudioMtuSize) { - this.rtpAudioMtuSize = rtpAudioMtuSize; - } - - public String getRtpClearCount() { - return rtpClearCount; - } - - public void setRtpClearCount(String rtpClearCount) { - this.rtpClearCount = rtpClearCount; - } - - public String getRtpCycleMS() { - return rtpCycleMS; - } - - public void setRtpCycleMS(String rtpCycleMS) { - this.rtpCycleMS = rtpCycleMS; - } - - public String getRtpMaxRtpCount() { - return rtpMaxRtpCount; - } - - public void setRtpMaxRtpCount(String rtpMaxRtpCount) { - this.rtpMaxRtpCount = rtpMaxRtpCount; - } - - public String getRtpVideoMtuSize() { - return rtpVideoMtuSize; - } - - public void setRtpVideoMtuSize(String rtpVideoMtuSize) { - this.rtpVideoMtuSize = rtpVideoMtuSize; - } - - public String getRtpProxyCheckSource() { - return rtpProxyCheckSource; - } - - public void setRtpProxyCheckSource(String rtpProxyCheckSource) { - this.rtpProxyCheckSource = rtpProxyCheckSource; - } - - public String getRtpProxyDumpDir() { - return rtpProxyDumpDir; - } - - public void setRtpProxyDumpDir(String rtpProxyDumpDir) { - this.rtpProxyDumpDir = rtpProxyDumpDir; - } - - public int getRtpProxyPort() { - return rtpProxyPort; - } - - public void setRtpProxyPort(int rtpProxyPort) { - this.rtpProxyPort = rtpProxyPort; - } - - public String getRtpProxyTimeoutSec() { - return rtpProxyTimeoutSec; - } - - public void setRtpProxyTimeoutSec(String rtpProxyTimeoutSec) { - this.rtpProxyTimeoutSec = rtpProxyTimeoutSec; - } - - public String getRtspAuthBasic() { - return rtspAuthBasic; - } - - public void setRtspAuthBasic(String rtspAuthBasic) { - this.rtspAuthBasic = rtspAuthBasic; - } - - public String getRtspHandshakeSecond() { - return rtspHandshakeSecond; - } - - public void setRtspHandshakeSecond(String rtspHandshakeSecond) { - this.rtspHandshakeSecond = rtspHandshakeSecond; - } - - public String getRtspKeepAliveSecond() { - return rtspKeepAliveSecond; - } - - public void setRtspKeepAliveSecond(String rtspKeepAliveSecond) { - this.rtspKeepAliveSecond = rtspKeepAliveSecond; - } - - public int getRtspPort() { - return rtspPort; - } - - public void setRtspPort(int rtspPort) { - this.rtspPort = rtspPort; - } - - public int getRtspSSlport() { - return rtspSSlport; - } - - public void setRtspSSlport(int rtspSSlport) { - this.rtspSSlport = rtspSSlport; - } - - public String getShellMaxReqSize() { - return shellMaxReqSize; - } - - public void setShellMaxReqSize(String shellMaxReqSize) { - this.shellMaxReqSize = shellMaxReqSize; - } - - public String getShellPhell() { - return shellPhell; - } - - public void setShellPhell(String shellPhell) { - this.shellPhell = shellPhell; - } - - public Float getHookAliveInterval() { - return hookAliveInterval; - } - - public void setHookAliveInterval(Float hookAliveInterval) { - this.hookAliveInterval = hookAliveInterval; - } - - public String getPortRange() { - return portRange; - } - - public void setPortRange(String portRange) { - this.portRange = portRange; - } - - public String getApiSnapRoot() { - return apiSnapRoot; - } - - public void setApiSnapRoot(String apiSnapRoot) { - this.apiSnapRoot = apiSnapRoot; - } - - public String getApiDefaultSnap() { - return apiDefaultSnap; - } - - public void setApiDefaultSnap(String apiDefaultSnap) { - this.apiDefaultSnap = apiDefaultSnap; - } - - public String getFfmpegSnap() { - return ffmpegSnap; - } - - public void setFfmpegSnap(String ffmpegSnap) { - this.ffmpegSnap = ffmpegSnap; - } - - public String getFfmpegRestartSec() { - return ffmpegRestartSec; - } - - public void setFfmpegRestartSec(String ffmpegRestartSec) { - this.ffmpegRestartSec = ffmpegRestartSec; - } - - public String getProtocolModifyStamp() { - return protocolModifyStamp; - } - - public void setProtocolModifyStamp(String protocolModifyStamp) { - this.protocolModifyStamp = protocolModifyStamp; - } - - public String getProtocolEnableAudio() { - return protocolEnableAudio; - } - - public void setProtocolEnableAudio(String protocolEnableAudio) { - this.protocolEnableAudio = protocolEnableAudio; - } - - public String getProtocolAddMuteAudio() { - return protocolAddMuteAudio; - } - - public void setProtocolAddMuteAudio(String protocolAddMuteAudio) { - this.protocolAddMuteAudio = protocolAddMuteAudio; - } - - public String getProtocolContinuePushMs() { - return protocolContinuePushMs; - } - - public void setProtocolContinuePushMs(String protocolContinuePushMs) { - this.protocolContinuePushMs = protocolContinuePushMs; - } - - public String getProtocolEnableHls() { - return protocolEnableHls; - } - - public void setProtocolEnableHls(String protocolEnableHls) { - this.protocolEnableHls = protocolEnableHls; - } - - public String getProtocolEnableMp4() { - return protocolEnableMp4; - } - - public void setProtocolEnableMp4(String protocolEnableMp4) { - this.protocolEnableMp4 = protocolEnableMp4; - } - - public String getProtocolEnableRtsp() { - return protocolEnableRtsp; - } - - public void setProtocolEnableRtsp(String protocolEnableRtsp) { - this.protocolEnableRtsp = protocolEnableRtsp; - } - - public String getProtocolEnableRtmp() { - return protocolEnableRtmp; - } - - public void setProtocolEnableRtmp(String protocolEnableRtmp) { - this.protocolEnableRtmp = protocolEnableRtmp; - } - - public String getProtocolEnableTs() { - return protocolEnableTs; - } - - public void setProtocolEnableTs(String protocolEnableTs) { - this.protocolEnableTs = protocolEnableTs; - } - - public String getProtocolEnableFmp4() { - return protocolEnableFmp4; - } - - public void setProtocolEnableFmp4(String protocolEnableFmp4) { - this.protocolEnableFmp4 = protocolEnableFmp4; - } - - public String getProtocolMp4AsPlayer() { - return protocolMp4AsPlayer; - } - - public void setProtocolMp4AsPlayer(String protocolMp4AsPlayer) { - this.protocolMp4AsPlayer = protocolMp4AsPlayer; - } - - public String getProtocolMp4MaxSecond() { - return protocolMp4MaxSecond; - } - - public void setProtocolMp4MaxSecond(String protocolMp4MaxSecond) { - this.protocolMp4MaxSecond = protocolMp4MaxSecond; - } - - public String getProtocolMp4SavePath() { - return protocolMp4SavePath; - } - - public void setProtocolMp4SavePath(String protocolMp4SavePath) { - this.protocolMp4SavePath = protocolMp4SavePath; - } - - public String getProtocolHlsSavePath() { - return protocolHlsSavePath; - } - - public void setProtocolHlsSavePath(String protocolHlsSavePath) { - this.protocolHlsSavePath = protocolHlsSavePath; - } - - public String getProtocolHlsDemand() { - return protocolHlsDemand; - } - - public void setProtocolHlsDemand(String protocolHlsDemand) { - this.protocolHlsDemand = protocolHlsDemand; - } - - public String getProtocolRtspDemand() { - return protocolRtspDemand; - } - - public void setProtocolRtspDemand(String protocolRtspDemand) { - this.protocolRtspDemand = protocolRtspDemand; - } - - public String getProtocolRtmpDemand() { - return protocolRtmpDemand; - } - - public void setProtocolRtmpDemand(String protocolRtmpDemand) { - this.protocolRtmpDemand = protocolRtmpDemand; - } - - public String getProtocolTsDemand() { - return protocolTsDemand; - } - - public void setProtocolTsDemand(String protocolTsDemand) { - this.protocolTsDemand = protocolTsDemand; - } - - public String getProtocolFmp4Demand() { - return protocolFmp4Demand; - } - - public void setProtocolFmp4Demand(String protocolFmp4Demand) { - this.protocolFmp4Demand = protocolFmp4Demand; - } - - public String getGeneralResetWhenRePlay() { - return generalResetWhenRePlay; - } - - public void setGeneralResetWhenRePlay(String generalResetWhenRePlay) { - this.generalResetWhenRePlay = generalResetWhenRePlay; - } - - public String getGeneralMergeWriteMS() { - return generalMergeWriteMS; - } - - public void setGeneralMergeWriteMS(String generalMergeWriteMS) { - this.generalMergeWriteMS = generalMergeWriteMS; - } - - public String getGeneralWaitTrackReadyMs() { - return generalWaitTrackReadyMs; - } - - public void setGeneralWaitTrackReadyMs(String generalWaitTrackReadyMs) { - this.generalWaitTrackReadyMs = generalWaitTrackReadyMs; - } - - public String getGeneralWaitAddTrackMs() { - return generalWaitAddTrackMs; - } - - public void setGeneralWaitAddTrackMs(String generalWaitAddTrackMs) { - this.generalWaitAddTrackMs = generalWaitAddTrackMs; - } - - public String getGeneralUnreadyFrameCache() { - return generalUnreadyFrameCache; - } - - public void setGeneralUnreadyFrameCache(String generalUnreadyFrameCache) { - this.generalUnreadyFrameCache = generalUnreadyFrameCache; - } - - public String getHlsSegRetain() { - return hlsSegRetain; - } - - public void setHlsSegRetain(String hlsSegRetain) { - this.hlsSegRetain = hlsSegRetain; - } - - public String getHlsBroadcastRecordTs() { - return hlsBroadcastRecordTs; - } - - public void setHlsBroadcastRecordTs(String hlsBroadcastRecordTs) { - this.hlsBroadcastRecordTs = hlsBroadcastRecordTs; - } - - public String getHlsDeleteDelaySec() { - return hlsDeleteDelaySec; - } - - public void setHlsDeleteDelaySec(String hlsDeleteDelaySec) { - this.hlsDeleteDelaySec = hlsDeleteDelaySec; - } - - public String getHlsSegKeep() { - return hlsSegKeep; - } - - public void setHlsSegKeep(String hlsSegKeep) { - this.hlsSegKeep = hlsSegKeep; - } - - public String getHookOnServerStarted() { - return hookOnServerStarted; - } - - public void setHookOnServerStarted(String hookOnServerStarted) { - this.hookOnServerStarted = hookOnServerStarted; - } - - public String getHookOnServerKeepalive() { - return hookOnServerKeepalive; - } - - public void setHookOnServerKeepalive(String hookOnServerKeepalive) { - this.hookOnServerKeepalive = hookOnServerKeepalive; - } - - public String getHookOnSendRtpStopped() { - return hookOnSendRtpStopped; - } - - public void setHookOnSendRtpStopped(String hookOnSendRtpStopped) { - this.hookOnSendRtpStopped = hookOnSendRtpStopped; - } - - public String getHookOnRtpServerTimeout() { - return hookOnRtpServerTimeout; - } - - public void setHookOnRtpServerTimeout(String hookOnRtpServerTimeout) { - this.hookOnRtpServerTimeout = hookOnRtpServerTimeout; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerFactory.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerFactory.java deleted file mode 100644 index 8c84133f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMServerFactory.java +++ /dev/null @@ -1,315 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.CommonCallback; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; - -import java.util.HashMap; -import java.util.Map; - -@Component -public class ZLMServerFactory { - - private Logger logger = LoggerFactory.getLogger("ZLMRTPServerFactory"); - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private UserSetting userSetting; - - @Autowired - private ZlmHttpHookSubscribe hookSubscribe; - - @Autowired - private SendRtpPortManager sendRtpPortManager; - - - /** - * 开启rtpServer - * @param mediaServerItem zlm服务实例 - * @param streamId 流Id - * @param ssrc ssrc - * @param port 端口, 0/null为使用随机 - * @param reUsePort 是否重用端口 - * @param tcpMode 0/null udp 模式,1 tcp 被动模式, 2 tcp 主动模式。 - * @return - */ - public int createRTPServer(MediaServerItem mediaServerItem, String streamId, long ssrc, Integer port, Boolean reUsePort, Integer tcpMode) { - int result = -1; - // 查询此rtp server 是否已经存在 - JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId); - logger.info(JSONObject.toJSONString(rtpInfo)); - if(rtpInfo.getInteger("code") == 0){ - if (rtpInfo.getBoolean("exist")) { - result = rtpInfo.getInteger("local_port"); - if (result == 0) { - // 此时说明rtpServer已经创建但是流还没有推上来 - // 此时重新打开rtpServer - Map param = new HashMap<>(); - param.put("stream_id", streamId); - JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param); - if (jsonObject != null ) { - if (jsonObject.getInteger("code") == 0) { - return createRTPServer(mediaServerItem, streamId, ssrc, port, reUsePort, tcpMode); - }else { - logger.warn("[开启rtpServer], 重启RtpServer错误"); - } - } - } - return result; - } - }else if(rtpInfo.getInteger("code") == -2){ - return result; - } - - Map param = new HashMap<>(); - - if (tcpMode == null) { - tcpMode = 0; - } - param.put("tcp_mode", tcpMode); - param.put("stream_id", streamId); - if (reUsePort != null) { - param.put("re_use_port", reUsePort?"1":"0"); - } - // 推流端口设置0则使用随机端口 - if (port == null) { - param.put("port", 0); - }else { - param.put("port", port); - } - if (ssrc != 0) { - param.put("ssrc", ssrc); - } - - JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param); - logger.info(JSONObject.toJSONString(openRtpServerResultJson)); - if (openRtpServerResultJson != null) { - if (openRtpServerResultJson.getInteger("code") == 0) { - result= openRtpServerResultJson.getInteger("port"); - }else { - logger.error("创建RTP Server 失败 {}: ", openRtpServerResultJson.getString("msg")); - } - }else { - // 检查ZLM状态 - logger.error("创建RTP Server 失败 {}: 请检查ZLM服务", param.get("port")); - } - return result; - } - - public boolean closeRtpServer(MediaServerItem serverItem, String streamId) { - boolean result = false; - if (serverItem !=null){ - Map param = new HashMap<>(); - param.put("stream_id", streamId); - JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(serverItem, param); - if (jsonObject != null ) { - if (jsonObject.getInteger("code") == 0) { - result = jsonObject.getInteger("hit") == 1; - }else { - logger.error("关闭RTP Server 失败: " + jsonObject.getString("msg")); - } - }else { - // 检查ZLM状态 - logger.error("关闭RTP Server 失败: 请检查ZLM服务"); - } - } - return result; - } - - public void closeRtpServer(MediaServerItem serverItem, String streamId, CommonCallback callback) { - if (serverItem == null) { - callback.run(false); - return; - } - Map param = new HashMap<>(); - param.put("stream_id", streamId); - zlmresTfulUtils.closeRtpServer(serverItem, param, jsonObject -> { - if (jsonObject != null ) { - if (jsonObject.getInteger("code") == 0) { - callback.run(jsonObject.getInteger("hit") == 1); - return; - }else { - logger.error("关闭RTP Server 失败: " + jsonObject.getString("msg")); - } - }else { - // 检查ZLM状态 - logger.error("关闭RTP Server 失败: 请检查ZLM服务"); - } - callback.run(false); - }); - - - } - - - /** - * 创建一个国标推流 - * @param ip 推流ip - * @param port 推流端口 - * @param ssrc 推流唯一标识 - * @param platformId 平台id - * @param channelId 通道id - * @param tcp 是否为tcp - * @return SendRtpItem - */ - public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, - String deviceId, String channelId, boolean tcp, boolean rtcp){ - - int localPort = sendRtpPortManager.getNextPort(serverItem); - if (localPort == 0) { - return null; - } - SendRtpItem sendRtpItem = new SendRtpItem(); - sendRtpItem.setIp(ip); - sendRtpItem.setPort(port); - sendRtpItem.setSsrc(ssrc); - sendRtpItem.setPlatformId(platformId); - sendRtpItem.setDeviceId(deviceId); - sendRtpItem.setChannelId(channelId); - sendRtpItem.setTcp(tcp); - sendRtpItem.setRtcp(rtcp); - sendRtpItem.setApp("rtp"); - sendRtpItem.setLocalPort(localPort); - sendRtpItem.setServerId(userSetting.getServerId()); - sendRtpItem.setMediaServerId(serverItem.getId()); - return sendRtpItem; - } - - /** - * 创建一个直播推流 - * @param ip 推流ip - * @param port 推流端口 - * @param ssrc 推流唯一标识 - * @param platformId 平台id - * @param channelId 通道id - * @param tcp 是否为tcp - * @return SendRtpItem - */ - public SendRtpItem createSendRtpItem(MediaServerItem serverItem, String ip, int port, String ssrc, String platformId, - String app, String stream, String channelId, boolean tcp, boolean rtcp){ - - int localPort = sendRtpPortManager.getNextPort(serverItem); - if (localPort == 0) { - return null; - } - SendRtpItem sendRtpItem = new SendRtpItem(); - sendRtpItem.setIp(ip); - sendRtpItem.setPort(port); - sendRtpItem.setSsrc(ssrc); - sendRtpItem.setApp(app); - sendRtpItem.setStreamId(stream); - sendRtpItem.setPlatformId(platformId); - sendRtpItem.setChannelId(channelId); - sendRtpItem.setTcp(tcp); - sendRtpItem.setLocalPort(localPort); - sendRtpItem.setServerId(userSetting.getServerId()); - sendRtpItem.setMediaServerId(serverItem.getId()); - sendRtpItem.setRtcp(rtcp); - return sendRtpItem; - } - - /** - * 调用zlm RESTFUL API —— startSendRtp - */ - public JSONObject startSendRtpStream(MediaServerItem mediaServerItem, Mapparam) { - return zlmresTfulUtils.startSendRtp(mediaServerItem, param); - } - - /** - * 调用zlm RESTFUL API —— startSendRtpPassive - */ - public JSONObject startSendRtpStreamForPassive(MediaServerItem mediaServerItem, Mapparam) { - return zlmresTfulUtils.startSendRtpPassive(mediaServerItem, param); - } - - /** - * 查询待转推的流是否就绪 - */ - public Boolean isRtpReady(MediaServerItem mediaServerItem, String streamId) { - JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem,"rtp", "rtsp", streamId); - if (mediaInfo.getInteger("code") == -2) { - return null; - } - return (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")); - } - - /** - * 查询待转推的流是否就绪 - */ - public Boolean isStreamReady(MediaServerItem mediaServerItem, String app, String streamId) { - JSONObject mediaInfo = zlmresTfulUtils.getMediaList(mediaServerItem, app, streamId); - if (mediaInfo == null || (mediaInfo.getInteger("code") == -2)) { - return null; - } - return (mediaInfo.getInteger("code") == 0 - && mediaInfo.getJSONArray("data") != null - && mediaInfo.getJSONArray("data").size() > 0); - } - - /** - * 查询转推的流是否有其它观看者 - * @param streamId - * @return - */ - public int totalReaderCount(MediaServerItem mediaServerItem, String app, String streamId) { - JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtsp", streamId); - if (mediaInfo == null) { - return 0; - } - Integer code = mediaInfo.getInteger("code"); - if ( code < 0) { - logger.warn("查询流({}/{})是否有其它观看者时得到: {}", app, streamId, mediaInfo.getString("msg")); - return -1; - } - if ( code == 0 && mediaInfo.getBoolean("online") != null && !mediaInfo.getBoolean("online")) { - logger.warn("查询流({}/{})是否有其它观看者时得到: {}", app, streamId, mediaInfo.getString("msg")); - return -1; - } - return mediaInfo.getInteger("totalReaderCount"); - } - - /** - * 调用zlm RESTful API —— stopSendRtp - */ - public Boolean stopSendRtpStream(MediaServerItem mediaServerItem, Mapparam) { - Boolean result = false; - JSONObject jsonObject = zlmresTfulUtils.stopSendRtp(mediaServerItem, param); - if (jsonObject == null) { - logger.error("[停止RTP推流] 失败: 请检查ZLM服务"); - } else if (jsonObject.getInteger("code") == 0) { - result= true; - logger.info("[停止RTP推流] 成功"); - } else { - logger.error("[停止RTP推流] 失败: {}, 参数:{}->\r\n{}",jsonObject.getString("msg"), JSON.toJSON(param), jsonObject); - } - return result; - } - - public void closeAllSendRtpStream() { - - } - - public Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc) { - boolean result = false; - JSONObject jsonObject = zlmresTfulUtils.updateRtpServerSSRC(mediaServerItem, streamId, ssrc); - if (jsonObject == null) { - logger.error("[更新RTPServer] 失败: 请检查ZLM服务"); - } else if (jsonObject.getInteger("code") == 0) { - result= true; - logger.info("[更新RTPServer] 成功"); - } else { - logger.error("[更新RTPServer] 失败: {}, streamId:{},ssrc:{}->\r\n{}",jsonObject.getString("msg"), - streamId, ssrc, jsonObject); - } - return result; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java deleted file mode 100644 index cad119ad..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/ZlmHttpHookSubscribe.java +++ /dev/null @@ -1,159 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.media.zlm.dto.HookType; -import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.time.Instant; -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; - -/** - * ZLMediaServer的hook事件订阅 - * @author lin - */ -@Component -public class ZlmHttpHookSubscribe { - - private final static Logger logger = LoggerFactory.getLogger(ZlmHttpHookSubscribe.class); - - @FunctionalInterface - public interface Event{ - void response(MediaServerItem mediaServerItem, HookParam hookParam); - } - - private Map> allSubscribes = new ConcurrentHashMap<>(); - - public void addSubscribe(IHookSubscribe hookSubscribe, ZlmHttpHookSubscribe.Event event) { - if (hookSubscribe.getExpires() == null) { - // 默认5分钟过期 - Instant expiresInstant = Instant.now().plusSeconds(TimeUnit.MINUTES.toSeconds(5)); - hookSubscribe.setExpires(expiresInstant); - } - allSubscribes.computeIfAbsent(hookSubscribe.getHookType(), k -> new ConcurrentHashMap<>()).put(hookSubscribe, event); - } - - public ZlmHttpHookSubscribe.Event sendNotify(HookType type, JSONObject hookResponse) { - ZlmHttpHookSubscribe.Event event= null; - Map eventMap = allSubscribes.get(type); - if (eventMap == null) { - return null; - } - for (IHookSubscribe key : eventMap.keySet()) { - Boolean result = null; - for (String s : key.getContent().keySet()) { - if (result == null) { - result = key.getContent().getString(s).equals(hookResponse.getString(s)); - }else { - if (key.getContent().getString(s) == null) { - continue; - } - result = result && key.getContent().getString(s).equals(hookResponse.getString(s)); - } - } - if (null != result && result) { - event = eventMap.get(key); - } - } - return event; - } - - public void removeSubscribe(IHookSubscribe hookSubscribe) { - Map eventMap = allSubscribes.get(hookSubscribe.getHookType()); - if (eventMap == null) { - return; - } - - Set> entries = eventMap.entrySet(); - if (entries.size() > 0) { - List> entriesToRemove = new ArrayList<>(); - for (Map.Entry entry : entries) { - JSONObject content = entry.getKey().getContent(); - if (content == null || content.size() == 0) { - entriesToRemove.add(entry); - continue; - } - Boolean result = null; - for (String s : content.keySet()) { - if (result == null) { - result = content.getString(s).equals(hookSubscribe.getContent().getString(s)); - }else { - if (content.getString(s) == null) { - continue; - } - result = result && content.getString(s).equals(hookSubscribe.getContent().getString(s)); - } - } - if (result){ - entriesToRemove.add(entry); - } - } - - if (!CollectionUtils.isEmpty(entriesToRemove)) { - for (Map.Entry entry : entriesToRemove) { - eventMap.remove(entry.getKey()); - } - if (eventMap.size() == 0) { - allSubscribes.remove(hookSubscribe.getHookType()); - } - } - - } - } - - /** - * 获取某个类型的所有的订阅 - * @param type - * @return - */ - public List getSubscribes(HookType type) { - Map eventMap = allSubscribes.get(type); - if (eventMap == null) { - return null; - } - List result = new ArrayList<>(); - for (IHookSubscribe key : eventMap.keySet()) { - result.add(eventMap.get(key)); - } - return result; - } - - public List getAll(){ - ArrayList result = new ArrayList<>(); - Collection> values = allSubscribes.values(); - for (Map value : values) { - result.addAll(value.keySet()); - } - return result; - } - - /** - * 对订阅数据进行过期清理 - */ -// @Scheduled(cron="0 0/5 * * * ?") //每5分钟执行一次 - @Scheduled(fixedRate = 2 * 1000) - public void execute(){ - Instant instant = Instant.now().minusMillis(TimeUnit.MINUTES.toMillis(5)); - int total = 0; - for (HookType hookType : allSubscribes.keySet()) { - Map hookSubscribeEventMap = allSubscribes.get(hookType); - if (hookSubscribeEventMap.size() > 0) { - for (IHookSubscribe hookSubscribe : hookSubscribeEventMap.keySet()) { - if (hookSubscribe.getExpires().isBefore(instant)) { - // 过期的 - hookSubscribeEventMap.remove(hookSubscribe); - total ++; - } - } - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java deleted file mode 100644 index 714838ed..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -import java.text.ParseException; - -/** - * @author lin - */ -public interface ChannelOnlineEvent { - - void run(String app, String stream, String serverId) throws ParseException; -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java deleted file mode 100644 index f3f389a7..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeFactory.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - - -import com.alibaba.fastjson2.JSONObject; - -/** - * hook 订阅工厂 - * @author lin - */ -public class HookSubscribeFactory { - - public static HookSubscribeForStreamChange on_stream_changed(String app, String stream, boolean regist, String scheam, String mediaServerId) { - HookSubscribeForStreamChange hookSubscribe = new HookSubscribeForStreamChange(); - JSONObject subscribeKey = new com.alibaba.fastjson2.JSONObject(); - subscribeKey.put("app", app); - subscribeKey.put("stream", stream); - subscribeKey.put("regist", regist); - if (scheam != null) { - subscribeKey.put("schema", scheam); - } - subscribeKey.put("mediaServerId", mediaServerId); - hookSubscribe.setContent(subscribeKey); - - return hookSubscribe; - } - - public static HookSubscribeForRtpServerTimeout on_rtp_server_timeout(String stream, String ssrc, String mediaServerId) { - HookSubscribeForRtpServerTimeout hookSubscribe = new HookSubscribeForRtpServerTimeout(); - JSONObject subscribeKey = new com.alibaba.fastjson2.JSONObject(); - subscribeKey.put("stream_id", stream); - subscribeKey.put("ssrc", ssrc); - subscribeKey.put("mediaServerId", mediaServerId); - hookSubscribe.setContent(subscribeKey); - - return hookSubscribe; - } - - public static HookSubscribeForServerStarted on_server_started() { - HookSubscribeForServerStarted hookSubscribe = new HookSubscribeForServerStarted(); - hookSubscribe.setContent(new JSONObject()); - - return hookSubscribe; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForRtpServerTimeout.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForRtpServerTimeout.java deleted file mode 100644 index d633560d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForRtpServerTimeout.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -import com.alibaba.fastjson2.JSONObject; -import com.alibaba.fastjson2.annotation.JSONField; - -import java.time.Instant; - -/** - * hook订阅-收流超时 - * @author lin - */ -public class HookSubscribeForRtpServerTimeout implements IHookSubscribe{ - - private HookType hookType = HookType.on_rtp_server_timeout; - - private JSONObject content; - - @JSONField(format="yyyy-MM-dd HH:mm:ss") - private Instant expires; - - @Override - public HookType getHookType() { - return hookType; - } - - @Override - public JSONObject getContent() { - return content; - } - - public void setContent(JSONObject content) { - this.content = content; - } - - @Override - public Instant getExpires() { - return expires; - } - - @Override - public void setExpires(Instant expires) { - this.expires = expires; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForServerStarted.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForServerStarted.java deleted file mode 100644 index 8bcde0a0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForServerStarted.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -import com.alibaba.fastjson2.JSONObject; -import com.alibaba.fastjson2.annotation.JSONField; - -import java.time.Instant; - -/** - * hook订阅-流变化 - * @author lin - */ -public class HookSubscribeForServerStarted implements IHookSubscribe{ - - private HookType hookType = HookType.on_server_started; - - private JSONObject content; - - @JSONField(format="yyyy-MM-dd HH:mm:ss") - private Instant expires; - - @Override - public HookType getHookType() { - return hookType; - } - - @Override - public JSONObject getContent() { - return content; - } - - public void setContent(JSONObject content) { - this.content = content; - } - - @Override - public Instant getExpires() { - return expires; - } - - @Override - public void setExpires(Instant expires) { - this.expires = expires; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamChange.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamChange.java deleted file mode 100644 index b73d74c1..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookSubscribeForStreamChange.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -import com.alibaba.fastjson2.JSONObject; -import com.alibaba.fastjson2.annotation.JSONField; - -import java.time.Instant; - -/** - * hook订阅-流变化 - * @author lin - */ -public class HookSubscribeForStreamChange implements IHookSubscribe{ - - private HookType hookType = HookType.on_stream_changed; - - private JSONObject content; - - @JSONField(format="yyyy-MM-dd HH:mm:ss") - private Instant expires; - - @Override - public HookType getHookType() { - return hookType; - } - - @Override - public JSONObject getContent() { - return content; - } - - public void setContent(JSONObject content) { - this.content = content; - } - - @Override - public Instant getExpires() { - return expires; - } - - @Override - public void setExpires(Instant expires) { - this.expires = expires; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookType.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookType.java deleted file mode 100644 index 235cea7b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/HookType.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -/** - * hook类型 - * @author lin - */ - -public enum HookType { - - on_flow_report, - on_http_access, - on_play, - on_publish, - on_record_mp4, - on_rtsp_auth, - on_rtsp_realm, - on_shell_login, - on_stream_changed, - on_stream_none_reader, - on_stream_not_found, - on_server_started, - - on_rtp_server_timeout, - on_server_keepalive, - on_send_rtp_stopped -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/IHookSubscribe.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/IHookSubscribe.java deleted file mode 100644 index 7b76a959..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/IHookSubscribe.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -import com.alibaba.fastjson2.JSONObject; - -import java.time.Instant; - -/** - * zlm hook事件的参数 - * @author lin - */ -public interface IHookSubscribe { - - /** - * 获取hook类型 - * @return hook类型 - */ - HookType getHookType(); - - /** - * 获取hook的具体内容 - * @return hook的具体内容 - */ - JSONObject getContent(); - - /** - * 设置过期时间 - * @param instant 过期时间 - */ - void setExpires(Instant instant); - - /** - * 获取过期时间 - * @return 过期时间 - */ - Instant getExpires(); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaServerItem.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaServerItem.java deleted file mode 100644 index 0c753913..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaServerItem.java +++ /dev/null @@ -1,367 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; -import io.swagger.v3.oas.annotations.media.Schema; -import org.springframework.util.ObjectUtils; - -/** - * 流媒体服务信息 - */ -@TableName("wvp_media_server") -public class MediaServerItem{ - - private String id; - - /** - * IP - */ - private String ip; - - /** - * hook使用的IP(zlm访问WVP使用的IP) - */ - private String hookIp; - - /** - * SDP IP - */ - private String sdpIp; - - /** - * 流IP - */ - private String streamIp; - - /** - * HTTP端口 - */ - private int httpPort; - - /** - * HTTPS端口 - */ - @TableField("http_ssl_port") - private int httpSSlPort; - - /** - * RTMP端口 - */ - private int rtmpPort; - - /** - * RTMPS端口 - */ - @TableField("rtmp_ssl_port") - private int rtmpSSlPort; - - /** - * RTP收流端口(单端口模式有用) - */ - private int rtpProxyPort; - - /** - * RTSP端口 - */ - private int rtspPort; - - /** - * RTSPS端口 - */ - @TableField("rtsp_ssl_port") - private int rtspSSLPort; - - /** - * 是否开启自动配置ZLM - */ - private boolean autoConfig; - - /** - * ZLM鉴权参数 - */ - private String secret; - - /** - * keepalive hook触发间隔,单位秒 - */ - private Float hookAliveInterval; - - /** - * 是否使用多端口模式 - */ - private boolean rtpEnable; - - /** - * 状态 - */ - @TableField(exist = false) - private boolean status; - - /** - * 多端口RTP收流端口范围 - */ - private String rtpPortRange; - - /** - * RTP发流端口范围 - */ - private String sendRtpPortRange; - - /** - * assist服务端口 - */ - private int recordAssistPort; - - /** - * 创建时间 - */ - private String createTime; - - /** - * 更新时间 - */ - private String updateTime; - - /** - * 上次心跳时间 - */ - @TableField(exist = false) - private String lastKeepaliveTime; - - /** - * 是否是默认ZLM - */ - private boolean defaultServer; - - /** - * 当前使用到的端口 - */ - @TableField(exist = false) - private int currentPort; - - public MediaServerItem() { } - - public MediaServerItem(ZLMServerConfig zlmServerConfig, String sipIp) { - id = zlmServerConfig.getGeneralMediaServerId(); - ip = zlmServerConfig.getIp(); - hookIp = ObjectUtils.isEmpty(zlmServerConfig.getHookIp())? sipIp: zlmServerConfig.getHookIp(); - sdpIp = ObjectUtils.isEmpty(zlmServerConfig.getSdpIp())? zlmServerConfig.getIp(): zlmServerConfig.getSdpIp(); - streamIp = ObjectUtils.isEmpty(zlmServerConfig.getStreamIp())? zlmServerConfig.getIp(): zlmServerConfig.getStreamIp(); - httpPort = zlmServerConfig.getHttpPort(); - httpSSlPort = zlmServerConfig.getHttpSSLport(); - rtmpPort = zlmServerConfig.getRtmpPort(); - rtmpSSlPort = zlmServerConfig.getRtmpSslPort(); - rtpProxyPort = zlmServerConfig.getRtpProxyPort(); - rtspPort = zlmServerConfig.getRtspPort(); - rtspSSLPort = zlmServerConfig.getRtspSSlport(); - autoConfig = true; // 默认值true; - secret = zlmServerConfig.getApiSecret(); - hookAliveInterval = zlmServerConfig.getHookAliveInterval(); - rtpEnable = false; // 默认使用单端口;直到用户自己设置开启多端口 - rtpPortRange = zlmServerConfig.getPortRange().replace("_",","); // 默认使用30000,30500作为级联时发送流的端口号 - recordAssistPort = 0; // 默认关闭 - - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public String getHookIp() { - return hookIp; - } - - public void setHookIp(String hookIp) { - this.hookIp = hookIp; - } - - public String getSdpIp() { - return sdpIp; - } - - public void setSdpIp(String sdpIp) { - this.sdpIp = sdpIp; - } - - public String getStreamIp() { - return streamIp; - } - - public void setStreamIp(String streamIp) { - this.streamIp = streamIp; - } - - public int getHttpPort() { - return httpPort; - } - - public void setHttpPort(int httpPort) { - this.httpPort = httpPort; - } - - public int getHttpSSlPort() { - return httpSSlPort; - } - - public void setHttpSSlPort(int httpSSlPort) { - this.httpSSlPort = httpSSlPort; - } - - public int getRtmpPort() { - return rtmpPort; - } - - public void setRtmpPort(int rtmpPort) { - this.rtmpPort = rtmpPort; - } - - public int getRtmpSSlPort() { - return rtmpSSlPort; - } - - public void setRtmpSSlPort(int rtmpSSlPort) { - this.rtmpSSlPort = rtmpSSlPort; - } - - public int getRtpProxyPort() { - return rtpProxyPort; - } - - public void setRtpProxyPort(int rtpProxyPort) { - this.rtpProxyPort = rtpProxyPort; - } - - public int getRtspPort() { - return rtspPort; - } - - public void setRtspPort(int rtspPort) { - this.rtspPort = rtspPort; - } - - public int getRtspSSLPort() { - return rtspSSLPort; - } - - public void setRtspSSLPort(int rtspSSLPort) { - this.rtspSSLPort = rtspSSLPort; - } - - public boolean isAutoConfig() { - return autoConfig; - } - - public void setAutoConfig(boolean autoConfig) { - this.autoConfig = autoConfig; - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public boolean isRtpEnable() { - return rtpEnable; - } - - public void setRtpEnable(boolean rtpEnable) { - this.rtpEnable = rtpEnable; - } - - public String getRtpPortRange() { - return rtpPortRange; - } - - public void setRtpPortRange(String rtpPortRange) { - this.rtpPortRange = rtpPortRange; - } - - public int getRecordAssistPort() { - return recordAssistPort; - } - - public void setRecordAssistPort(int recordAssistPort) { - this.recordAssistPort = recordAssistPort; - } - - public boolean isDefaultServer() { - return defaultServer; - } - - public void setDefaultServer(boolean defaultServer) { - this.defaultServer = defaultServer; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public int getCurrentPort() { - return currentPort; - } - - public void setCurrentPort(int currentPort) { - this.currentPort = currentPort; - } - - public boolean isStatus() { - return status; - } - - public void setStatus(boolean status) { - this.status = status; - } - - public String getLastKeepaliveTime() { - return lastKeepaliveTime; - } - - public void setLastKeepaliveTime(String lastKeepaliveTime) { - this.lastKeepaliveTime = lastKeepaliveTime; - } - - public Float getHookAliveInterval() { - return hookAliveInterval; - } - - public void setHookAliveInterval(Float hookAliveInterval) { - this.hookAliveInterval = hookAliveInterval; - } - - public String getSendRtpPortRange() { - return sendRtpPortRange; - } - - public void setSendRtpPortRange(String sendRtpPortRange) { - this.sendRtpPortRange = sendRtpPortRange; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ServerKeepaliveData.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ServerKeepaliveData.java deleted file mode 100644 index 0cc81f27..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ServerKeepaliveData.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -public class ServerKeepaliveData { -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamAuthorityInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamAuthorityInfo.java deleted file mode 100644 index ef77225d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamAuthorityInfo.java +++ /dev/null @@ -1,117 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnPublishHookParam; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; - -/** - * 流的鉴权信息 - * @author lin - */ -public class StreamAuthorityInfo { - - private String id; - private String app; - private String stream; - - /** - * 产生源类型, - * unknown = 0, - * rtmp_push=1, - * rtsp_push=2, - * rtp_push=3, - * pull=4, - * ffmpeg_pull=5, - * mp4_vod=6, - * device_chn=7 - */ - private int originType; - - /** - * 产生源类型的字符串描述 - */ - private String originTypeStr; - - /** - * 推流时自定义的播放鉴权ID - */ - private String callId; - - /** - * 推流的鉴权签名 - */ - private String sign; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public int getOriginType() { - return originType; - } - - public void setOriginType(int originType) { - this.originType = originType; - } - - public String getOriginTypeStr() { - return originTypeStr; - } - - public void setOriginTypeStr(String originTypeStr) { - this.originTypeStr = originTypeStr; - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } - - public String getSign() { - return sign; - } - - public void setSign(String sign) { - this.sign = sign; - } - - public static StreamAuthorityInfo getInstanceByHook(OnPublishHookParam hookParam) { - StreamAuthorityInfo streamAuthorityInfo = new StreamAuthorityInfo(); - streamAuthorityInfo.setApp(hookParam.getApp()); - streamAuthorityInfo.setStream(hookParam.getStream()); - streamAuthorityInfo.setId(hookParam.getId()); - return streamAuthorityInfo; - } - - public static StreamAuthorityInfo getInstanceByHook(OnStreamChangedHookParam onStreamChangedHookParam) { - StreamAuthorityInfo streamAuthorityInfo = new StreamAuthorityInfo(); - streamAuthorityInfo.setApp(onStreamChangedHookParam.getApp()); - streamAuthorityInfo.setStream(onStreamChangedHookParam.getStream()); - streamAuthorityInfo.setId(onStreamChangedHookParam.getMediaServerId()); - streamAuthorityInfo.setOriginType(onStreamChangedHookParam.getOriginType()); - streamAuthorityInfo.setOriginTypeStr(onStreamChangedHookParam.getOriginTypeStr()); - return streamAuthorityInfo; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java deleted file mode 100644 index c1b4ac09..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamProxyItem.java +++ /dev/null @@ -1,203 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * @author lin - */ -@TableName(value = "wvp_stream_proxy", excludeProperty = {"gbStreamId", "platformId" - , "catalogId", "gbId", "longitude", "latitude", "streamType"}) -@Schema(description = "拉流代理的信息") -public class StreamProxyItem extends GbStream { - - @TableId - private Long id; - @Schema(description = "类型") - private String type; - @Schema(description = "拉流地址") - private String url; - @Schema(description = "拉流地址") - private String srcUrl; - @Schema(description = "目标地址") - private String dstUrl; - @Schema(description = "超时时间") - private int timeoutMs; - @Schema(description = "ffmpeg模板KEY") - private String ffmpegCmdKey; - @Schema(description = "rtsp拉流时,拉流方式,0:tcp,1:udp,2:组播") - private String rtpType; - @Schema(description = "是否启用") - private Boolean enable; - @Schema(description = "是否启用音频") - private Boolean enableAudio; - @Schema(description = "是否启用MP4") - private Boolean enableMp4; - @Schema(description = "是否 无人观看时删除") - private Boolean enableRemoveNoneReader; - - @Schema(description = "是否 无人观看时自动停用") - private Boolean enableDisableNoneReader; - - @Schema(description = "拉流代理时zlm返回的key,用于停止拉流代理") - private String streamKey; - /** - * 更新时间 - */ - @Schema(description = "更新时间") - private String updateTime; - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getSrcUrl() { - return srcUrl; - } - - public void setSrcUrl(String src_url) { - this.srcUrl = src_url; - } - - public String getDstUrl() { - return dstUrl; - } - - public void setDstUrl(String dst_url) { - this.dstUrl = dst_url; - } - - public int getTimeoutMs() { - return timeoutMs; - } - - public void setTimeoutMs(int timeout_ms) { - this.timeoutMs = timeout_ms; - } - - public String getFfmpegCmdKey() { - return ffmpegCmdKey; - } - - public void setFfmpegCmdKey(String ffmpeg_cmd_key) { - this.ffmpegCmdKey = ffmpeg_cmd_key; - } - - public String getRtpType() { - return rtpType; - } - - public void setRtpType(String rtp_type) { - this.rtpType = rtp_type; - } - - public boolean isEnable() { - return enable; - } - - public void setEnable(boolean enable) { - this.enable = enable; - } - - public boolean isEnableMp4() { - return enableMp4; - } - - public void setEnableMp4(boolean enable_mp4) { - this.enableMp4 = enable_mp4; - } - - public boolean isEnableRemoveNoneReader() { - return enableRemoveNoneReader; - } - - public void setEnableRemoveNoneReader(boolean enable_remove_none_reader) { - this.enableRemoveNoneReader = enable_remove_none_reader; - } - - public boolean isEnableDisableNoneReader() { - return enableDisableNoneReader; - } - - public void setEnableDisableNoneReader(boolean enable_disable_none_reader) { - this.enableDisableNoneReader = enable_disable_none_reader; - } - - public boolean isEnableAudio() { - return enableAudio; - } - - public void setEnableAudio(boolean enable_audio) { - this.enableAudio = enable_audio; - } - - public String getStreamKey() { - return streamKey; - } - - public void setStreamKey(String streamKey) { - this.streamKey = streamKey; - } - - public Boolean getEnable() { - return enable; - } - - public void setEnable(Boolean enable) { - this.enable = enable; - } - - public Boolean getEnableAudio() { - return enableAudio; - } - - public void setEnableAudio(Boolean enableAudio) { - this.enableAudio = enableAudio; - } - - public Boolean getEnableMp4() { - return enableMp4; - } - - public void setEnableMp4(Boolean enableMp4) { - this.enableMp4 = enableMp4; - } - - public Boolean getEnableRemoveNoneReader() { - return enableRemoveNoneReader; - } - - public void setEnableRemoveNoneReader(Boolean enableRemoveNoneReader) { - this.enableRemoveNoneReader = enableRemoveNoneReader; - } - - public Boolean getEnableDisableNoneReader() { - return enableDisableNoneReader; - } - - public void setEnableDisableNoneReader(Boolean enableDisableNoneReader) { - this.enableDisableNoneReader = enableDisableNoneReader; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java deleted file mode 100644 index fae6f045..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.utils.DateUtil; -import io.swagger.v3.oas.annotations.media.Schema; -import org.jetbrains.annotations.NotNull; - -import java.util.List; - -@TableName(value = "wvp_stream_push", excludeProperty = {"gbStreamId", "platformId" - , "catalogId", "gbId", "name", "longitude", "latitude", "streamType"}) -@Schema(description = "推流信息") -public class StreamPushItem extends GbStream implements Comparable{ - - /** - * id - */ - @TableId - @Schema(description = "id") - private Long id; - - /** - * 观看总人数,包括hls/rtsp/rtmp/http-flv/ws-flv - */ - @Schema(description = "观看总人数") - private String totalReaderCount; - - /** - * 协议 包括hls/rtsp/rtmp/http-flv/ws-flv - */ - @TableField(exist = false) - @Schema(description = "协议 包括hls/rtsp/rtmp/http-flv/ws-flv") - private List schemas; - - /** - * 产生源类型, - * unknown = 0, - * rtmp_push=1, - * rtsp_push=2, - * rtp_push=3, - * pull=4, - * ffmpeg_pull=5, - * mp4_vod=6, - * device_chn=7 - */ - @Schema(description = "产生源类型") - private Integer originType; - - /** - * 客户端和服务器网络信息,可能为null类型 - */ - @TableField(exist = false) - @Schema(description = "客户端和服务器网络信息,可能为null类型") - private OnStreamChangedHookParam.OriginSock originSock; - - /** - * 产生源类型的字符串描述 - */ - @Schema(description = "产生源类型的字符串描述") - private String originTypeStr; - - /** - * 产生源的url - */ - @TableField(exist = false) - @Schema(description = "产生源的url") - private String originUrl; - - /** - * 存活时间,单位秒 - */ - @Schema(description = "存活时间,单位秒") - private Long aliveSecond; - - /** - * 音视频轨道 - */ - @TableField(exist = false) - @Schema(description = "音视频轨道") - private List tracks; - - /** - * 音视频轨道 - */ - @TableField(exist = false) - @Schema(description = "音视频轨道") - private String vhost; - - /** - * 使用的服务ID - */ - @TableField(exist = false) - @Schema(description = "使用的服务ID") - private String serverId; - - /** - * 推流时间 - */ - @Schema(description = "推流时间") - private String pushTime; - - /** - * 更新时间 - */ - @Schema(description = "更新时间") - private String updateTime; - - /** - * 是否正在推流 - */ - @Schema(description = "是否正在推流") - private Boolean pushIng; - - /** - * 是否自己平台的推流 - */ - @Schema(description = "是否自己平台的推流") - private Boolean self; - - public String getVhost() { - return vhost; - } - - public void setVhost(String vhost) { - this.vhost = vhost; - } - - @Override - public int compareTo(@NotNull StreamPushItem streamPushItem) { - return Long.valueOf(DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(this.getCreateTime()) - - DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(streamPushItem.getCreateTime())).intValue(); - } - - public static class MediaSchema { - private String schema; - private Long bytesSpeed; - - public String getSchema() { - return schema; - } - - public void setSchema(String schema) { - this.schema = schema; - } - - public Long getBytesSpeed() { - return bytesSpeed; - } - - public void setBytesSpeed(Long bytesSpeed) { - this.bytesSpeed = bytesSpeed; - } - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public String getTotalReaderCount() { - return totalReaderCount; - } - - public void setTotalReaderCount(String totalReaderCount) { - this.totalReaderCount = totalReaderCount; - } - - public List getSchemas() { - return schemas; - } - - public void setSchemas(List schemas) { - this.schemas = schemas; - } - - public int getOriginType() { - return originType; - } - - public void setOriginType(int originType) { - this.originType = originType; - } - - public OnStreamChangedHookParam.OriginSock getOriginSock() { - return originSock; - } - - public void setOriginSock(OnStreamChangedHookParam.OriginSock originSock) { - this.originSock = originSock; - } - - - public String getOriginTypeStr() { - return originTypeStr; - } - - public void setOriginTypeStr(String originTypeStr) { - this.originTypeStr = originTypeStr; - } - - public String getOriginUrl() { - return originUrl; - } - - public void setOriginUrl(String originUrl) { - this.originUrl = originUrl; - } - - public Long getAliveSecond() { - return aliveSecond; - } - - public void setAliveSecond(Long aliveSecond) { - this.aliveSecond = aliveSecond; - } - - public List getTracks() { - return tracks; - } - - public void setTracks(List tracks) { - this.tracks = tracks; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public String getPushTime() { - return pushTime; - } - - public void setPushTime(String pushTime) { - this.pushTime = pushTime; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public boolean isPushIng() { - return pushIng; - } - - public void setPushIng(boolean pushIng) { - this.pushIng = pushIng; - } - - public boolean isSelf() { - return self; - } - - public void setSelf(boolean self) { - this.self = self; - } - -} - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ZLMRunInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ZLMRunInfo.java deleted file mode 100644 index 624e4e13..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ZLMRunInfo.java +++ /dev/null @@ -1,33 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto; - -/** - * 记录zlm运行中一些参数 - */ -public class ZLMRunInfo { - - /** - * zlm当前流数量 - */ - private int mediaCount; - - /** - * 在线状态 - */ - private boolean online; - - public int getMediaCount() { - return mediaCount; - } - - public void setMediaCount(int mediaCount) { - this.mediaCount = mediaCount; - } - - public boolean isOnline() { - return online; - } - - public void setOnline(boolean online) { - this.online = online; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookParam.java deleted file mode 100644 index 46ccf227..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookParam.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -/** - * zlm hook事件的参数 - * @author lin - */ -public class HookParam { - private String mediaServerId; - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookResult.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookResult.java deleted file mode 100644 index b327f13a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookResult.java +++ /dev/null @@ -1,40 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -public class HookResult { - - private int code; - private String msg; - - - public HookResult() { - } - - public HookResult(int code, String msg) { - this.code = code; - this.msg = msg; - } - - public static HookResult SUCCESS(){ - return new HookResult(0, "success"); - } - - public static HookResult Fail(){ - return new HookResult(-1, "fail"); - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookResultForOnPublish.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookResultForOnPublish.java deleted file mode 100644 index 12d83627..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/HookResultForOnPublish.java +++ /dev/null @@ -1,73 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -public class HookResultForOnPublish extends HookResult{ - - private boolean enable_audio; - private boolean enable_mp4; - private int mp4_max_second; - private String mp4_save_path; - private String stream_replace; - - public HookResultForOnPublish() { - } - - public static HookResultForOnPublish SUCCESS(){ - return new HookResultForOnPublish(0, "success"); - } - - public HookResultForOnPublish(int code, String msg) { - setCode(code); - setMsg(msg); - } - - public boolean isEnable_audio() { - return enable_audio; - } - - public void setEnable_audio(boolean enable_audio) { - this.enable_audio = enable_audio; - } - - public boolean isEnable_mp4() { - return enable_mp4; - } - - public void setEnable_mp4(boolean enable_mp4) { - this.enable_mp4 = enable_mp4; - } - - public int getMp4_max_second() { - return mp4_max_second; - } - - public void setMp4_max_second(int mp4_max_second) { - this.mp4_max_second = mp4_max_second; - } - - public String getMp4_save_path() { - return mp4_save_path; - } - - public void setMp4_save_path(String mp4_save_path) { - this.mp4_save_path = mp4_save_path; - } - - public String getStream_replace() { - return stream_replace; - } - - public void setStream_replace(String stream_replace) { - this.stream_replace = stream_replace; - } - - @Override - public String toString() { - return "HookResultForOnPublish{" + - "enable_audio=" + enable_audio + - ", enable_mp4=" + enable_mp4 + - ", mp4_max_second=" + mp4_max_second + - ", stream_replace=" + stream_replace + - ", mp4_save_path='" + mp4_save_path + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPlayHookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPlayHookParam.java deleted file mode 100644 index 6e41ccea..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPlayHookParam.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -/** - * zlm hook事件中的on_play事件的参数 - * @author lin - */ -public class OnPlayHookParam extends HookParam{ - private String id; - private String app; - private String stream; - private String ip; - private String params; - private int port; - private String schema; - private String vhost; - - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public String getParams() { - return params; - } - - public void setParams(String params) { - this.params = params; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getSchema() { - return schema; - } - - public void setSchema(String schema) { - this.schema = schema; - } - - public String getVhost() { - return vhost; - } - - public void setVhost(String vhost) { - this.vhost = vhost; - } - - @Override - public String toString() { - return "OnPlayHookParam{" + - "id='" + id + '\'' + - ", app='" + app + '\'' + - ", stream='" + stream + '\'' + - ", ip='" + ip + '\'' + - ", params='" + params + '\'' + - ", port=" + port + - ", schema='" + schema + '\'' + - ", vhost='" + vhost + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPublishHookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPublishHookParam.java deleted file mode 100644 index 8a3e084d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnPublishHookParam.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -/** - * zlm hook事件中的on_publish事件的参数 - * @author lin - */ -public class OnPublishHookParam extends HookParam{ - private String id; - private String app; - private String stream; - private String ip; - private String params; - private int port; - private String schema; - private String vhost; - - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public String getParams() { - return params; - } - - public void setParams(String params) { - this.params = params; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getSchema() { - return schema; - } - - public void setSchema(String schema) { - this.schema = schema; - } - - public String getVhost() { - return vhost; - } - - public void setVhost(String vhost) { - this.vhost = vhost; - } - - @Override - public String toString() { - return "OnPublishHookParam{" + - "id='" + id + '\'' + - ", app='" + app + '\'' + - ", stream='" + stream + '\'' + - ", ip='" + ip + '\'' + - ", params='" + params + '\'' + - ", port=" + port + - ", schema='" + schema + '\'' + - ", vhost='" + vhost + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRtpServerTimeoutHookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRtpServerTimeoutHookParam.java deleted file mode 100644 index 6179ce46..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnRtpServerTimeoutHookParam.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -/** - * zlm hook事件中的on_rtp_server_timeout事件的参数 - * @author lin - */ -public class OnRtpServerTimeoutHookParam extends HookParam{ - private int local_port; - private String stream_id; - private int tcpMode; - private boolean re_use_port; - private String ssrc; - - public int getLocal_port() { - return local_port; - } - - public void setLocal_port(int local_port) { - this.local_port = local_port; - } - - public String getStream_id() { - return stream_id; - } - - public void setStream_id(String stream_id) { - this.stream_id = stream_id; - } - - public int getTcpMode() { - return tcpMode; - } - - public void setTcpMode(int tcpMode) { - this.tcpMode = tcpMode; - } - - public boolean isRe_use_port() { - return re_use_port; - } - - public void setRe_use_port(boolean re_use_port) { - this.re_use_port = re_use_port; - } - - public String getSsrc() { - return ssrc; - } - - public void setSsrc(String ssrc) { - this.ssrc = ssrc; - } - - @Override - public String toString() { - return "OnRtpServerTimeoutHookParam{" + - "local_port=" + local_port + - ", stream_id='" + stream_id + '\'' + - ", tcpMode=" + tcpMode + - ", re_use_port=" + re_use_port + - ", ssrc='" + ssrc + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnSendRtpStoppedHookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnSendRtpStoppedHookParam.java deleted file mode 100644 index 4989b4ab..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnSendRtpStoppedHookParam.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -/** - * zlm hook事件中的on_send_rtp_stopped事件的参数 - * @author lin - */ -public class OnSendRtpStoppedHookParam extends HookParam{ - private String app; - private String stream; - - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - @Override - public String toString() { - return "OnSendRtpStoppedHookParam{" + - "app='" + app + '\'' + - ", stream='" + stream + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnServerKeepaliveHookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnServerKeepaliveHookParam.java deleted file mode 100644 index 5439f20f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnServerKeepaliveHookParam.java +++ /dev/null @@ -1,27 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; - -/** - * zlm hook事件中的on_play事件的参数 - * @author lin - */ -public class OnServerKeepaliveHookParam extends HookParam{ - - private ServerKeepaliveData data; - - public ServerKeepaliveData getData() { - return data; - } - - public void setData(ServerKeepaliveData data) { - this.data = data; - } - - @Override - public String toString() { - return "OnServerKeepaliveHookParam{" + - "data=" + data + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamChangedHookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamChangedHookParam.java deleted file mode 100644 index ffca0d5a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamChangedHookParam.java +++ /dev/null @@ -1,508 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -import com.genersoft.iot.vmp.vmanager.bean.StreamContent; - -import java.util.List; - -/** - * @author lin - */ -public class OnStreamChangedHookParam extends HookParam{ - - /** - * 注册/注销 - */ - private boolean regist; - - /** - * 应用名 - */ - private String app; - - /** - * 流id - */ - private String stream; - - /** - * 推流鉴权Id - */ - private String callId; - - /** - * 观看总人数,包括hls/rtsp/rtmp/http-flv/ws-flv - */ - private String totalReaderCount; - - /** - * 协议 包括hls/rtsp/rtmp/http-flv/ws-flv - */ - private String schema; - - - /** - * 产生源类型, - * unknown = 0, - * rtmp_push=1, - * rtsp_push=2, - * rtp_push=3, - * pull=4, - * ffmpeg_pull=5, - * mp4_vod=6, - * device_chn=7 - */ - private int originType; - - /** - * 客户端和服务器网络信息,可能为null类型 - */ - private OriginSock originSock; - - /** - * 产生源类型的字符串描述 - */ - private String originTypeStr; - - /** - * 产生源的url - */ - private String originUrl; - - /** - * 服务器id - */ - private String severId; - - /** - * GMT unix系统时间戳,单位秒 - */ - private Long createStamp; - - /** - * 存活时间,单位秒 - */ - private Long aliveSecond; - - /** - * 数据产生速度,单位byte/s - */ - private Long bytesSpeed; - - /** - * 音视频轨道 - */ - private List tracks; - - /** - * 音视频轨道 - */ - private String vhost; - - public boolean isRegist() { - return regist; - } - - public void setRegist(boolean regist) { - this.regist = regist; - } - - /** - * 是否是docker部署, docker部署不会自动更新zlm使用的端口,需要自己手动修改 - */ - private boolean docker; - - public static class MediaTrack { - /** - * 音频通道数 - */ - private int channels; - - /** - * H264 = 0, H265 = 1, AAC = 2, G711A = 3, G711U = 4 - */ - private int codec_id; - - /** - * 编码类型名称 CodecAAC CodecH264 - */ - private String codec_id_name; - - /** - * Video = 0, Audio = 1 - */ - private int codec_type; - - /** - * 轨道是否准备就绪 - */ - private boolean ready; - - /** - * 音频采样位数 - */ - private int sample_bit; - - /** - * 音频采样率 - */ - private int sample_rate; - - /** - * 视频fps - */ - private float fps; - - /** - * 视频高 - */ - private int height; - - /** - * 视频宽 - */ - private int width; - - /** - * 帧数 - */ - private int frames; - - /** - * 关键帧数 - */ - private int key_frames; - - /** - * GOP大小 - */ - private int gop_size; - - /** - * GOP间隔时长(ms) - */ - private int gop_interval_ms; - - /** - * 丢帧率 - */ - private float loss; - - public int getChannels() { - return channels; - } - - public void setChannels(int channels) { - this.channels = channels; - } - - public int getCodec_id() { - return codec_id; - } - - public void setCodec_id(int codec_id) { - this.codec_id = codec_id; - } - - public String getCodec_id_name() { - return codec_id_name; - } - - public void setCodec_id_name(String codec_id_name) { - this.codec_id_name = codec_id_name; - } - - public int getCodec_type() { - return codec_type; - } - - public void setCodec_type(int codec_type) { - this.codec_type = codec_type; - } - - public boolean isReady() { - return ready; - } - - public void setReady(boolean ready) { - this.ready = ready; - } - - public int getSample_bit() { - return sample_bit; - } - - public void setSample_bit(int sample_bit) { - this.sample_bit = sample_bit; - } - - public int getSample_rate() { - return sample_rate; - } - - public void setSample_rate(int sample_rate) { - this.sample_rate = sample_rate; - } - - public float getFps() { - return fps; - } - - public void setFps(float fps) { - this.fps = fps; - } - - public int getHeight() { - return height; - } - - public void setHeight(int height) { - this.height = height; - } - - public int getWidth() { - return width; - } - - public void setWidth(int width) { - this.width = width; - } - - public int getFrames() { - return frames; - } - - public void setFrames(int frames) { - this.frames = frames; - } - - public int getKey_frames() { - return key_frames; - } - - public void setKey_frames(int key_frames) { - this.key_frames = key_frames; - } - - public int getGop_size() { - return gop_size; - } - - public void setGop_size(int gop_size) { - this.gop_size = gop_size; - } - - public int getGop_interval_ms() { - return gop_interval_ms; - } - - public void setGop_interval_ms(int gop_interval_ms) { - this.gop_interval_ms = gop_interval_ms; - } - - public float getLoss() { - return loss; - } - - public void setLoss(float loss) { - this.loss = loss; - } - } - - public static class OriginSock{ - private String identifier; - private String local_ip; - private int local_port; - private String peer_ip; - private int peer_port; - - public String getIdentifier() { - return identifier; - } - - public void setIdentifier(String identifier) { - this.identifier = identifier; - } - - public String getLocal_ip() { - return local_ip; - } - - public void setLocal_ip(String local_ip) { - this.local_ip = local_ip; - } - - public int getLocal_port() { - return local_port; - } - - public void setLocal_port(int local_port) { - this.local_port = local_port; - } - - public String getPeer_ip() { - return peer_ip; - } - - public void setPeer_ip(String peer_ip) { - this.peer_ip = peer_ip; - } - - public int getPeer_port() { - return peer_port; - } - - public void setPeer_port(int peer_port) { - this.peer_port = peer_port; - } - } - - private StreamContent streamInfo; - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getTotalReaderCount() { - return totalReaderCount; - } - - public void setTotalReaderCount(String totalReaderCount) { - this.totalReaderCount = totalReaderCount; - } - - - public int getOriginType() { - return originType; - } - - public void setOriginType(int originType) { - this.originType = originType; - } - - - public String getOriginTypeStr() { - return originTypeStr; - } - - public void setOriginTypeStr(String originTypeStr) { - this.originTypeStr = originTypeStr; - } - - public String getOriginUrl() { - return originUrl; - } - - public void setOriginUrl(String originUrl) { - this.originUrl = originUrl; - } - - public Long getCreateStamp() { - return createStamp; - } - - public void setCreateStamp(Long createStamp) { - this.createStamp = createStamp; - } - - public Long getAliveSecond() { - return aliveSecond; - } - - public void setAliveSecond(Long aliveSecond) { - this.aliveSecond = aliveSecond; - } - - public List getTracks() { - return tracks; - } - - public void setTracks(List tracks) { - this.tracks = tracks; - } - - public String getSchema() { - return schema; - } - - public void setSchema(String schema) { - this.schema = schema; - } - - public void setOriginSock(OriginSock originSock) { - this.originSock = originSock; - } - - public Long getBytesSpeed() { - return bytesSpeed; - } - - public void setBytesSpeed(Long bytesSpeed) { - this.bytesSpeed = bytesSpeed; - } - - public String getVhost() { - return vhost; - } - - public void setVhost(String vhost) { - this.vhost = vhost; - } - - public OriginSock getOriginSock() { - return originSock; - } - - public boolean isDocker() { - return docker; - } - - public void setDocker(boolean docker) { - this.docker = docker; - } - - public StreamContent getStreamInfo() { - return streamInfo; - } - - public void setStreamInfo(StreamContent streamInfo) { - this.streamInfo = streamInfo; - } - - public String getSeverId() { - return severId; - } - - public void setSeverId(String severId) { - this.severId = severId; - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } - - @Override - public String toString() { - return "OnStreamChangedHookParam{" + - "regist=" + regist + - ", app='" + app + '\'' + - ", stream='" + stream + '\'' + - ", severId='" + severId + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNoneReaderHookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNoneReaderHookParam.java deleted file mode 100644 index 3b628428..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNoneReaderHookParam.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -public class OnStreamNoneReaderHookParam extends HookParam{ - - private String schema; - private String app; - private String stream; - private String vhost; - - public String getSchema() { - return schema; - } - - public void setSchema(String schema) { - this.schema = schema; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getVhost() { - return vhost; - } - - public void setVhost(String vhost) { - this.vhost = vhost; - } - - @Override - public String toString() { - return "OnStreamNoneReaderHookParam{" + - "schema='" + schema + '\'' + - ", app='" + app + '\'' + - ", stream='" + stream + '\'' + - ", vhost='" + vhost + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNotFoundHookParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNotFoundHookParam.java deleted file mode 100644 index 76e6a721..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OnStreamNotFoundHookParam.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -/** - * zlm hook事件中的on_stream_not_found事件的参数 - * @author lin - */ -public class OnStreamNotFoundHookParam extends HookParam{ - private String id; - private String app; - private String stream; - private String ip; - private String params; - private int port; - private String schema; - private String vhost; - - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public String getParams() { - return params; - } - - public void setParams(String params) { - this.params = params; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getSchema() { - return schema; - } - - public void setSchema(String schema) { - this.schema = schema; - } - - public String getVhost() { - return vhost; - } - - public void setVhost(String vhost) { - this.vhost = vhost; - } - - @Override - public String toString() { - return "OnStreamNotFoundHookParam{" + - "id='" + id + '\'' + - ", app='" + app + '\'' + - ", stream='" + stream + '\'' + - ", ip='" + ip + '\'' + - ", params='" + params + '\'' + - ", port=" + port + - ", schema='" + schema + '\'' + - ", vhost='" + vhost + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OriginType.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OriginType.java deleted file mode 100644 index 926cf4d4..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/hook/OriginType.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.dto.hook; - -public enum OriginType { - // 不可调整顺序 - UNKNOWN("UNKNOWN"), - RTMP_PUSH("PUSH"), - RTSP_PUSH("PUSH"), - RTP_PUSH("RTP"), - PULL("PULL"), - FFMPEG_PULL("PULL"), - MP4_VOD("MP4_VOD"), - DEVICE_CHN("DEVICE_CHN"), - RTC_PUSH("PUSH"); - - private final String type; - OriginType(String type) { - this.type = type; - } - - public String getType() { - return type; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMEventAbstract.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMEventAbstract.java deleted file mode 100644 index 8ffbddea..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMEventAbstract.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.event; - -import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; -import org.springframework.context.ApplicationEvent; - -public abstract class ZLMEventAbstract extends ApplicationEvent { - - - private static final long serialVersionUID = 1L; - - private String mediaServerId; - - - public ZLMEventAbstract(Object source) { - super(source); - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOfflineEvent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOfflineEvent.java deleted file mode 100644 index 8207bdd3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOfflineEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.event; - -/** - * zlm离线事件类 - */ -public class ZLMOfflineEvent extends ZLMEventAbstract { - - public ZLMOfflineEvent(Object source) { - super(source); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOnlineEvent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOnlineEvent.java deleted file mode 100644 index 612ff9d0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMOnlineEvent.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.event; - -/** - * zlm在线事件 - */ -public class ZLMOnlineEvent extends ZLMEventAbstract { - - public ZLMOnlineEvent(Object source) { - super(source); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java deleted file mode 100644 index bad8e560..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMStatusEventListener.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.genersoft.iot.vmp.media.zlm.event; - -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IPlayService; -import com.genersoft.iot.vmp.service.IStreamProxyService; -import com.genersoft.iot.vmp.service.IStreamPushService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.event.EventListener; -import org.springframework.scheduling.annotation.Async; -import org.springframework.stereotype.Component; - - -/** - * @description: 在线事件监听器,监听到离线后,修改设备离在线状态。 设备在线有两个来源: - * 1、设备主动注销,发送注销指令 - * 2、设备未知原因离线,心跳超时 - * @author: swwheihei - * @date: 2020年5月6日 下午1:51:23 - */ -@Component -public class ZLMStatusEventListener { - - private final static Logger logger = LoggerFactory.getLogger(ZLMStatusEventListener.class); - - @Autowired - private IStreamPushService streamPushService; - - @Autowired - private IStreamProxyService streamProxyService; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private IPlayService playService; - - @Async("taskExecutor") - @EventListener - public void onApplicationEvent(ZLMOnlineEvent event) { - logger.info("[ZLM] 上线 ID:" + event.getMediaServerId()); - streamPushService.zlmServerOnline(event.getMediaServerId()); - streamProxyService.zlmServerOnline(event.getMediaServerId()); - playService.zlmServerOnline(event.getMediaServerId()); - } - - @Async("taskExecutor") - @EventListener - public void onApplicationEvent(ZLMOfflineEvent event) { - - logger.info("[ZLM] 离线,ID:" + event.getMediaServerId()); - // 处理ZLM离线 - mediaServerService.zlmServerOffline(event.getMediaServerId()); - streamProxyService.zlmServerOffline(event.getMediaServerId()); - streamPushService.zlmServerOffline(event.getMediaServerId()); - playService.zlmServerOffline(event.getMediaServerId()); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceAlarmService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceAlarmService.java deleted file mode 100644 index 532e9174..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceAlarmService.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; - -import java.util.List; - -/** - * 报警相关业务处理 - */ -public interface IDeviceAlarmService { - - /** - * 根据多个添加获取报警列表 - * @param page 当前页 - * @param entity 设备告警 - * @return 报警列表 - */ - Page listByPage(Page page, DeviceAlarm entity); - - /** - * 添加一个报警 - * @param deviceAlarm 添加报警 - */ - void add(DeviceAlarm deviceAlarm); - - /** - * 清空时间以前的报警 - * @param id 数据库id - * @param deviceIdList 制定需要清理的设备id - * @param time 不写时间则清空所有时间的 - */ - int clearAlarmBeforeTime(Integer id, List deviceIdList, String time); - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java deleted file mode 100644 index 5485f1c7..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.iteaj.framework.IBaseService; - -import java.util.List; - -/** - * 国标通道业务类 - * @author lin - */ -public interface IDeviceChannelService extends IBaseService { - - /** - * 更新gps信息 - */ - DeviceChannel updateGps(DeviceChannel deviceChannel, Device device); - - /** - * 添加设备通道 - * - * @param deviceId 设备id - * @param channel 通道 - */ - void updateChannel(String deviceId, DeviceChannel channel); - - /** - * 批量添加设备通道 - * - * @param deviceId 设备id - * @param channels 多个通道 - */ - int updateChannels(String deviceId, List channels); - - /** - * 获取统计信息 - * @return - */ - ResourceBaseInfo getOverview(); - - /** - * 查询所有未分配的通道 - * @param platformId - * @return - */ - List queryAllChannelList(String platformId); - - /** - * 数据位置信息格式处理 - */ - boolean updateAllGps(Device device); - - /** - * 查询通道所属的设备 - */ - List getDeviceByChannelId(String channelId); - - /** - * 批量删除通道 - * @param deleteChannelList 待删除的通道列表 - */ - int deleteChannels(List deleteChannelList); - - /** - * 批量上线 - */ - int channelsOnline(List channels); - - /** - * 批量下线 - */ - int channelsOffline(List channels); - - /** - * 获取一个通道 - */ - DeviceChannel getOne(String deviceId, String channelId); - - /** - * 直接批量更新通道 - */ - void batchUpdateChannel(List channels); - - /** - * 直接批量添加 - */ - void batchAddChannel(List deviceChannels); - - /** - * 查询指定设备下面的通道 - * @param deviceId - * @return - */ - List selectChannelsByDeviceId(String deviceId); - - List getAllChannelWithCoordinate(String deviceId); - - void updatePosition(DeviceChannel deviceChannel); - - DeviceChannel getByDeviceIdAndChannelId(String deviceId, String channelId); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java deleted file mode 100644 index fc50ad6b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java +++ /dev/null @@ -1,190 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; -import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; -import com.genersoft.iot.vmp.storager.dao.DeviceMapper; -import com.genersoft.iot.vmp.vmanager.bean.BaseTree; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; - -import java.util.List; - -/** - * 设备相关业务处理 - * @author lin - */ -public interface IDeviceService { - - /** - * 设备上线 - * @param device 设备信息 - */ - void online(Device device, SipTransactionInfo sipTransactionInfo); - - /** - * 设备下线 - * @param deviceId 设备编号 - */ - void offline(String deviceId, String reason); - - /** - * 添加目录订阅 - * @param device 设备信息 - * @return 布尔 - */ - boolean addCatalogSubscribe(Device device); - - /** - * 移除目录订阅 - * @param device 设备信息 - * @return 布尔 - */ - boolean removeCatalogSubscribe(Device device); - - /** - * 添加移动位置订阅 - * @param device 设备信息 - * @return 布尔 - */ - boolean addMobilePositionSubscribe(Device device); - - /** - * 移除移动位置订阅 - * @param device 设备信息 - * @return 布尔 - */ - boolean removeMobilePositionSubscribe(Device device); - - /** - * 移除移动位置订阅 - * @param deviceId 设备ID - * @return 同步状态 - */ - SyncStatus getChannelSyncStatus(String deviceId); - - /** - * 查看是否仍在同步 - * @param deviceId 设备ID - * @return 布尔 - */ - Boolean isSyncRunning(String deviceId); - - /** - * 通道同步 - * @param device 设备信息 - */ - void sync(Device device); - - /** - * 查询设备信息 - * @param deviceId 设备编号 - * @return 设备信息 - */ - Device getDevice(String deviceId); - - /** - * 获取所有在线设备 - * @return 设备列表 - */ - List getAllOnlineDevice(); - - /** - * 判断是否注册已经失效 - * @param device 设备信息 - * @return 布尔 - */ - boolean expire(Device device); - - /** - * 检查设备状态 - * @param device 设备信息 - */ - void checkDeviceStatus(Device device); - - /** - * 根据IP和端口获取设备信息 - * @param host IP - * @param port 端口 - * @return 设备信息 - */ - Device getDeviceByHostAndPort(String host, int port); - - /** - * 更新设备 - * @param device 设备信息 - */ - void updateDevice(Device device); - - /** - * 树形查询接口 - * @param deviceId 设备ID - * @param parentId 父ID - * @param onlyCatalog 只获取目录 - * @return - */ - List> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog); - - /** - * 查询树节点下的通道 - * @param deviceId 设备ID - * @param parentId 父ID - * @return - */ - List queryVideoDeviceInTreeNode(String deviceId, String parentId); - - /** - * 检查设备编号是否已经存在 - * @param deviceId 设备编号 - * @return - */ - boolean isExist(String deviceId); - - /** - * 添加设备 - * @param device - */ - void addDevice(Device device); - - /** - * 页面表单更新设备信息 - * @param device - */ - void updateCustomDevice(Device device); - - /** - * 删除设备 - * @param deviceId - * @return - */ - boolean delete(String deviceId); - - /** - * 获取统计信息 - * @return - */ - ResourceBaseInfo getOverview(); - - /** - * 获取所有设备 - */ - List getAll(); - - /** - * 更新设备 - * @param device - */ - int updateByDeviceId(Device device); - - /** - * 删除设备 - * @param deviceId - * @return - */ - int deleteByDeviceId(String deviceId); - - DeviceMapper getDeviceMapper(); - - Page detailByPage(Page page, Device device); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java deleted file mode 100644 index a89c7ce0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.IService; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; - -import java.util.List; - -/** - * 级联国标平台关联流业务接口 - */ -public interface IGbStreamService extends IService { - - /** - * 分页获取所有 - * @param page - * @param entity - * @return - */ - Page getAll(Page page, GbStream entity); - - /** - * 移除 - * @param app - * @param stream - */ - int del(String app, String stream); - - /** - * 保存国标关联 - * @param gbStreams - */ - boolean addPlatformInfo(List gbStreams, String platformId, String catalogId); - - /** - * 移除国标关联 - * @param gbStreams - * @param platformId - */ - boolean delPlatformInfo(String platformId, List gbStreams); - - DeviceChannel getDeviceChannelListByStream(GbStream gbStream, String catalogId, ParentPlatform platform); - - void sendCatalogMsg(GbStream gbStream, String type); - - void sendCatalogMsgs(List gbStreams, String type); - - /** - * 修改gbId或name - * @param streamPushItemForUpdate - * @return - */ - int updateGbIdOrName(List streamPushItemForUpdate); - - DeviceChannel getDeviceChannelListByStreamWithStatus(GbStream gbStream, String catalogId, ParentPlatform platform); - - /** - * 查询所有未分配的通道 - * @param platformId - * @return - */ - List getAllGBChannels(String platformId); - - /** - * 移除所有关联的通道 - * @param platformId - * @param catalogId - */ - void delAllPlatformInfo(String platformId, String catalogId); - - List getGbChannelWithGbid(String gbId); - - boolean updateByAppAndStream(GbStream gbStream); - - GbStream selectByAppAndStream(String app, String stream); - - void deleteWithoutGBId(String type, String mediaServerId); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java deleted file mode 100644 index c06400dc..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IInviteStreamService.java +++ /dev/null @@ -1,86 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.service.bean.ErrorCallback; - -/** - * 记录国标点播的状态,包括实时预览,下载,录像回放 - */ -public interface IInviteStreamService { - - /** - * 更新点播的状态信息 - */ - void updateInviteInfo(InviteInfo inviteInfo); - - InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream); - - /** - * 获取点播的状态信息 - */ - InviteInfo getInviteInfo(InviteSessionType type, - String deviceId, - String channelId, - String stream); - - /** - * 移除点播的状态信息 - */ - void removeInviteInfo(InviteSessionType type, - String deviceId, - String channelId, - String stream); - /** - * 移除点播的状态信息 - */ - void removeInviteInfo(InviteInfo inviteInfo); - /** - * 移除点播的状态信息 - */ - void removeInviteInfoByDeviceAndChannel(InviteSessionType inviteSessionType, String deviceId, String channelId); - - /** - * 获取点播的状态信息 - */ - InviteInfo getInviteInfoByDeviceAndChannel(InviteSessionType type, - String deviceId, - String channelId); - - /** - * 获取点播的状态信息 - */ - InviteInfo getInviteInfoByStream(InviteSessionType type, String stream); - - - /** - * 添加一个invite回调 - */ - void once(InviteSessionType type, String deviceId, String channelId, String stream, ErrorCallback callback); - - /** - * 调用一个invite回调 - */ - void call(InviteSessionType type, String deviceId, String channelId, String stream, int code, String msg, Object data); - - /** - * 清空一个设备的所有invite信息 - */ - void clearInviteInfo(String deviceId); - - /** - * 统计同一个zlm下的国标收流个数 - */ - int getStreamInfoCount(String mediaServerId); - - - /** - * 获取MediaServer下的流信息 - */ - InviteInfo getInviteInfoBySSRC(String ssrc); - - /** - * 更新ssrc - */ - InviteInfo updateInviteInfoForSSRC(InviteInfo inviteInfo, String ssrcInResponse); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java deleted file mode 100644 index b54312f2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IMediaServerService.java +++ /dev/null @@ -1,109 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.genersoft.iot.vmp.common.CommonCallback; -import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; -import com.genersoft.iot.vmp.service.bean.MediaServerLoad; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.genersoft.iot.vmp.vmanager.bean.RecordFile; - -import java.util.List; - -/** - * 媒体服务节点 - */ -public interface IMediaServerService { - - List getAll(); - - List getAllFromDatabase(); - - List getAllOnline(); - - MediaServerItem getOne(String generalMediaServerId); - - void syncCatchFromDatabase(); - - /** - * 新的节点加入 - * @param zlmServerConfig - * @return - */ - void zlmServerOnline(ZLMServerConfig zlmServerConfig); - - /** - * 节点离线 - * @param mediaServerId - * @return - */ - void zlmServerOffline(String mediaServerId); - - MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist); - - void setZLMConfig(MediaServerItem mediaServerItem, boolean restart); - - void updateVmServer(List mediaServerItemList); - - SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String ssrc, boolean ssrcCheck, - boolean isPlayback, Integer port, Boolean reUsePort, Integer tcpMode); - - void closeRTPServer(MediaServerItem mediaServerItem, String streamId); - - void closeRTPServer(MediaServerItem mediaServerItem, String streamId, CommonCallback callback); - Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc); - - void closeRTPServer(String mediaServerId, String streamId); - - void clearRTPServer(MediaServerItem mediaServerItem); - - void update(MediaServerItem mediaSerItem); - - void addCount(String mediaServerId); - - void removeCount(String mediaServerId); - - void releaseSsrc(String mediaServerItemId, String ssrc); - - void clearMediaServerForOnline(); - - void add(MediaServerItem mediaSerItem); - - int addToDatabase(MediaServerItem mediaSerItem); - - int updateToDatabase(MediaServerItem mediaSerItem); - - void resetOnlineServerItem(MediaServerItem serverItem); - - MediaServerItem checkMediaServer(String ip, int port, String secret); - - boolean checkMediaRecordServer(String ip, int port); - - void delete(String id); - - void deleteDb(String id); - - MediaServerItem getDefaultMediaServer(); - - void updateMediaServerKeepalive(String mediaServerId, ServerKeepaliveData data); - - boolean checkRtpServer(MediaServerItem mediaServerItem, String rtp, String stream); - - /** - * 获取负载信息 - * @return - */ - MediaServerLoad getLoad(MediaServerItem mediaServerItem); - - /** - * 按时间查找录像文件 - */ - List getRecords(String app, String stream, String startTime, String endTime, List mediaServerItems); - - /** - * 查找存在录像文件的时间 - */ - List getRecordDates(String app, String stream, int year, int month, List mediaServerItems); - - MediaServerItem getByHostAndPort(String ip, int port); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java deleted file mode 100644 index c05f1977..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IMediaService.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.alibaba.fastjson2.JSONArray; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; - -/** - * 媒体信息业务 - */ -public interface IMediaService { - - /** - * 根据应用名和流ID获取播放地址, 通过zlm接口检查是否存在 - * @param app - * @param stream - * @return - */ - StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId,String addr, boolean authority); - - - /** - * 根据应用名和流ID获取播放地址, 通过zlm接口检查是否存在, 返回的ip使用远程访问ip,适用与zlm与wvp在一台主机的情况 - * @param app - * @param stream - * @return - */ - StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId, boolean authority); - - /** - * 根据应用名和流ID获取播放地址, 只是地址拼接 - * @param app - * @param stream - * @return - */ - StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaServerItem, String app, String stream, Object tracks, String callId); - - /** - * 根据应用名和流ID获取播放地址, 只是地址拼接,返回的ip使用远程访问ip,适用与zlm与wvp在一台主机的情况 - * @param app - * @param stream - * @return - */ - StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, String callId); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java deleted file mode 100644 index 49d74282..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; - -import java.util.List; - -/** - * 平台关联通道管理 - * @author lin - */ -public interface IPlatformChannelService { - - /** - * 更新目录下的通道 - * @param platformId 平台编号 - * @param channelReduces 通道信息 - * @param catalogId 目录编号 - * @return - */ - int updateChannelForGB(String platformId, List channelReduces, String catalogId); - - /** - * 移除目录下的所有通道 - * @param platformId - * @param catalogId - * @return - */ - int delAllChannelForGB(String platformId, String catalogId); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java deleted file mode 100644 index ff6ed812..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlatformService.java +++ /dev/null @@ -1,60 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.SipTransactionInfo; - -/** - * 国标平台的业务类 - * @author lin - */ -public interface IPlatformService { - - ParentPlatform queryPlatformByServerGBId(String platformGbId); - - /** - * 分页获取上级平台 - * @param page - * @param entity - * @return - */ - Page parentPlatformByPage(Page page, ParentPlatform entity); - - /** - * 添加级联平台 - * @param parentPlatform 级联平台 - */ - boolean add(ParentPlatform parentPlatform); - - /** - * 添加级联平台 - * @param parentPlatform 级联平台 - */ - boolean update(ParentPlatform parentPlatform); - - /** - * 平台上线 - * @param parentPlatform 平台信息 - */ - void online(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo); - - /** - * 平台离线 - * @param parentPlatform 平台信息 - */ - void offline(ParentPlatform parentPlatform, boolean stopRegisterTask); - - /** - * 向上级平台发起注册 - * @param parentPlatform - */ - void login(ParentPlatform parentPlatform); - - /** - * 向上级平台发送位置订阅 - * @param platformId 平台 - */ - void sendNotifyMobilePosition(String platformId); - - void addSimulatedSubscribeInfo(ParentPlatform parentPlatform); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java deleted file mode 100644 index 7dcd875d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IPlayService.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.bean.ErrorCallback; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.iteaj.framework.exception.ServiceException; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; - -/** - * 点播处理 - */ -public interface IPlayService { - - void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - ErrorCallback callback); - SSRCInfo play(MediaServerItem mediaServerItem, String deviceId, String channelId, String ssrc, ErrorCallback callback); - - MediaServerItem getNewMediaServerItem(Device device); - - /** - * 获取包含assist服务的节点 - */ - MediaServerItem getNewMediaServerItemHasAssist(Device device); - - void playBack(String deviceId, String channelId, String startTime, String endTime, ErrorCallback callback); - void playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, ErrorCallback callback); - void zlmServerOffline(String mediaServerId); - - void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback callback); - void download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo,String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback callback); - - StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream); - - void zlmServerOnline(String mediaServerId); - - void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException; - - void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException; - - void getSnap(String deviceId, String channelId, String fileName, ErrorCallback errorCallback); - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java deleted file mode 100644 index 23678781..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.alibaba.fastjson2.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.common.GeneralCallback; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; - -public interface IStreamProxyService { - - /** - * 保存视频代理 - * @param param - */ - void save(StreamProxyItem param, GeneralCallback callback); - - /** - * 添加视频代理到zlm - * @param param - * @return - */ - JSONObject addStreamProxyToZlm(StreamProxyItem param); - - /** - * 从zlm移除视频代理 - * @param param - * @return - */ - JSONObject removeStreamProxyFromZlm(StreamProxyItem param); - - /** - * 分页查询 - * @param page - * @return - */ - Page getAll(Page page, StreamProxyItem entity); - - /** - * 删除视频代理 - * @param app - * @param stream - */ - void del(String app, String stream); - - /** - * 启用视频代理 - * @param app - * @param stream - * @return - */ - boolean start(String app, String stream); - - /** - * 更新状态 - * @param status 状态 - * @param app - * @param stream - */ - int updateStatus(boolean status, String app, String stream); - - - - /** - * 停用用视频代理 - * @param app - * @param stream - * @return - */ - boolean stop(String app, String stream); - - /** - * 获取ffmpeg.cmd模板 - * @return - */ - JSONObject getFFmpegCMDs(MediaServerItem mediaServerItem); - - /** - * 根据app与stream获取streamProxy - * @return - */ - StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); - - - /** - * 新的节点加入 - * @param mediaServerId - * @return - */ - void zlmServerOnline(String mediaServerId); - - /** - * 节点离线 - * @param mediaServerId - * @return - */ - void zlmServerOffline(String mediaServerId); - - void clean(); - - /** - * 更新代理流 - */ - boolean updateStreamProxy(StreamProxyItem streamProxyItem); - - /** - * 获取统计信息 - * @return - */ - ResourceBaseInfo getOverview(); - - boolean updateByAppAndStream(StreamProxyItem streamProxyItem); - - int deleteByAppAndStream(String app, String stream); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java deleted file mode 100644 index 0c74f7dd..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.genersoft.iot.vmp.service; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.IService; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; - -import java.util.List; -import java.util.Map; - -/** - * @author lin - */ -public interface IStreamPushService extends IService { - - List handleJSON(String json, MediaServerItem mediaServerItem); - - /** - * 将应用名和流ID加入国标关联 - * @param stream - * @return - */ - boolean saveToGB(GbStream stream); - - /** - * 将应用名和流ID移出国标关联 - * @param stream - * @return - */ - boolean removeFromGB(GbStream stream); - - /** - * 获取 - */ - Page getPushList(Page page, String query, Boolean pushing, String mediaServerId); - - List getPushList(String mediaSererId); - - StreamPushItem transform(OnStreamChangedHookParam item); - - StreamPushItem getPush(String app, String streamId); - - /** - * 停止一路推流 - * @param app 应用名 - * @param streamId 流ID - */ - boolean stop(String app, String streamId); - - /** - * 新的节点加入 - */ - void zlmServerOnline(String mediaServerId); - - /** - * 节点离线 - */ - void zlmServerOffline(String mediaServerId); - - /** - * 清空 - */ - void clean(); - - - boolean saveToRandomGB(); - - /** - * 批量添加 - */ - void batchAdd(List streamPushExcelDtoList); - - /** - * 中止多个推流 - */ - boolean batchStop(List streamPushItems); - - /** - * 导入时批量增加 - */ - void batchAddForUpload(List streamPushItems, Map> streamPushItemsForAll); - - /** - * 全部离线 - */ - void allStreamOffline(); - - /** - * 推流离线 - */ - void offline(List offlineStreams); - - /** - * 推流上线 - */ - void online(List onlineStreams); - - /** - * 增加推流 - */ - boolean add(StreamPushItem stream); - - /** - * 获取全部的app+Streanm 用于判断推流列表是新增还是修改 - * @return - */ - List getAllAppAndStream(); - - /** - * 获取统计信息 - * @return - */ - ResourceBaseInfo getOverview(); - - boolean deleteByAppAndStream(String app, String stream); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ErrorCallback.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ErrorCallback.java deleted file mode 100644 index 6211d003..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ErrorCallback.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -public interface ErrorCallback { - - void run(int code, String msg, T data); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/GPSMsgInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/GPSMsgInfo.java deleted file mode 100644 index b814c18f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/GPSMsgInfo.java +++ /dev/null @@ -1,106 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -public class GPSMsgInfo { - - /** - * - */ - private String id; - - /** - * 经度 (必选) - */ - private double lng; - - /** - * 纬度 (必选) - */ - private double lat; - - /** - * 速度,单位:km/h (可选) - */ - private double speed; - - /** - * 产生通知时间, 时间格式: 2020-01-14T14:32:12 - */ - private String time; - - /** - * 方向,取值为当前摄像头方向与正北方的顺时针夹角,取值范围0°~360°,单位:(°)(可选) - */ - private String direction; - - /** - * 海拔高度,单位:m(可选) - */ - private String altitude; - - private boolean stored; - - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public double getLng() { - return lng; - } - - public void setLng(double lng) { - this.lng = lng; - } - - public double getLat() { - return lat; - } - - public void setLat(double lat) { - this.lat = lat; - } - - public double getSpeed() { - return speed; - } - - public void setSpeed(double speed) { - this.speed = speed; - } - - public String getTime() { - return time; - } - - public void setTime(String time) { - this.time = time; - } - - public String getDirection() { - return direction; - } - - public void setDirection(String direction) { - this.direction = direction; - } - - public String getAltitude() { - return altitude; - } - - public void setAltitude(String altitude) { - this.altitude = altitude; - } - - public boolean isStored() { - return stored; - } - - public void setStored(boolean stored) { - this.stored = stored; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/InviteErrorCode.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/InviteErrorCode.java deleted file mode 100644 index d43792e7..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/InviteErrorCode.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -/** - * 全局错误码 - */ -public enum InviteErrorCode { - SUCCESS(0, "成功"), - FAIL(-100, "失败"), - ERROR_FOR_SIGNALLING_TIMEOUT(-1, "信令超时"), - ERROR_FOR_STREAM_TIMEOUT(-2, "收流超时"), - ERROR_FOR_RESOURCE_EXHAUSTION(-3, "资源耗尽"), - ERROR_FOR_CATCH_DATA(-4, "缓存数据异常"), - ERROR_FOR_SIGNALLING_ERROR(-5, "收到信令错误"), - ERROR_FOR_STREAM_PARSING_EXCEPTIONS(-6, "流地址解析错误"), - ERROR_FOR_SDP_PARSING_EXCEPTIONS(-7, "SDP信息解析失败"), - ERROR_FOR_SSRC_UNAVAILABLE(-8, "SSRC不可用"), - ERROR_FOR_RESET_SSRC(-9, "重新设置收流信息失败"), - ERROR_FOR_SIP_SENDING_FAILED(-10, "命令发送失败"), - ERROR_FOR_ASSIST_NOT_READY(-11, "没有可用的assist服务"), - ERROR_FOR_PARAMETER_ERROR(-13, "参数异常"); - - private final int code; - private final String msg; - - InviteErrorCode(int code, String msg) { - this.code = code; - this.msg = msg; - } - - public int getCode() { - return code; - } - - public String getMsg() { - return msg; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/InviteTimeOutCallback.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/InviteTimeOutCallback.java deleted file mode 100644 index e30db5d9..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/InviteTimeOutCallback.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -public interface InviteTimeOutCallback { - - void run(int code, String msg); // code: 0 sip超时, 1 收流超时 -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MediaServerLoad.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MediaServerLoad.java deleted file mode 100644 index cb30f67a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MediaServerLoad.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -public class MediaServerLoad { - - private String id; - private int push; - private int proxy; - private int gbReceive; - private int gbSend; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public int getPush() { - return push; - } - - public void setPush(int push) { - this.push = push; - } - - public int getProxy() { - return proxy; - } - - public void setProxy(int proxy) { - this.proxy = proxy; - } - - public int getGbReceive() { - return gbReceive; - } - - public void setGbReceive(int gbReceive) { - this.gbReceive = gbReceive; - } - - public int getGbSend() { - return gbSend; - } - - public void setGbSend(int gbSend) { - this.gbSend = gbSend; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java deleted file mode 100644 index 1a9e3e5c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java +++ /dev/null @@ -1,142 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -/** - * 当上级平台 - * @author lin - */ -public class MessageForPushChannel { - /** - * 消息类型 - * 0 流注销 1 流注册 - */ - private int type; - - /** - * 流应用名 - */ - private String app; - - /** - * 流Id - */ - private String stream; - - /** - * 国标ID - */ - private String gbId; - - /** - * 请求的平台国标编号 - */ - private String platFormId; - - /** - * 请求的平台自增ID - */ - private int platFormIndex; - - /** - * 请求平台名称 - */ - private String platFormName; - - /** - * WVP服务ID - */ - private String serverId; - - /** - * 目标流媒体节点ID - */ - private String mediaServerId; - - - - public static MessageForPushChannel getInstance(int type, String app, String stream, String gbId, - String platFormId, String platFormName, String serverId, - String mediaServerId){ - MessageForPushChannel messageForPushChannel = new MessageForPushChannel(); - messageForPushChannel.setType(type); - messageForPushChannel.setGbId(gbId); - messageForPushChannel.setApp(app); - messageForPushChannel.setStream(stream); - messageForPushChannel.setMediaServerId(mediaServerId); - messageForPushChannel.setPlatFormId(platFormId); - messageForPushChannel.setPlatFormName(platFormName); - return messageForPushChannel; - } - - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getGbId() { - return gbId; - } - - public void setGbId(String gbId) { - this.gbId = gbId; - } - - public String getPlatFormId() { - return platFormId; - } - - public void setPlatFormId(String platFormId) { - this.platFormId = platFormId; - } - - public String getPlatFormName() { - return platFormName; - } - - public void setPlatFormName(String platFormName) { - this.platFormName = platFormName; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public int getPlatFormIndex() { - return platFormIndex; - } - - public void setPlatFormIndex(int platFormIndex) { - this.platFormIndex = platFormIndex; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannelResponse.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannelResponse.java deleted file mode 100644 index 10d1b43c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannelResponse.java +++ /dev/null @@ -1,71 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -/** - * 当redis回复推流结果上级平台 - * @author lin - */ -public class MessageForPushChannelResponse { - /** - * 错误玛 - * 0 成功 1 失败 - */ - private int code; - /** - * 错误内容 - */ - private String msg; - - /** - * 流应用名 - */ - private String app; - - /** - * 流Id - */ - private String stream; - - - - public static MessageForPushChannelResponse getInstance(int code, String msg, String app, String stream){ - MessageForPushChannelResponse messageForPushChannel = new MessageForPushChannelResponse(); - messageForPushChannel.setCode(code); - messageForPushChannel.setMsg(msg); - messageForPushChannel.setApp(app); - messageForPushChannel.setStream(stream); - return messageForPushChannel; - } - - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackCallback.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackCallback.java deleted file mode 100644 index 33a09bd4..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackCallback.java +++ /dev/null @@ -1,7 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -public interface PlayBackCallback { - - void call(PlayBackResult msg); - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackResult.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackResult.java deleted file mode 100644 index 0a332ef0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PlayBackResult.java +++ /dev/null @@ -1,69 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; - -import java.util.EventObject; - - -/** - * @author lin - */ -public class PlayBackResult { - private int code; - - private String msg; - private T data; - private MediaServerItem mediaServerItem; - private JSONObject response; - private SipSubscribe.EventResult event; - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } - - public MediaServerItem getMediaServerItem() { - return mediaServerItem; - } - - public void setMediaServerItem(MediaServerItem mediaServerItem) { - this.mediaServerItem = mediaServerItem; - } - - public JSONObject getResponse() { - return response; - } - - public void setResponse(JSONObject response) { - this.response = response; - } - - public SipSubscribe.EventResult getEvent() { - return event; - } - - public void setEvent(SipSubscribe.EventResult event) { - this.event = event; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PushStreamStatusChangeFromRedisDto.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PushStreamStatusChangeFromRedisDto.java deleted file mode 100644 index 5bb7b77f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/PushStreamStatusChangeFromRedisDto.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -import java.util.List; - -/** - * 收到redis通知修改推流通道状态 - * @author lin - */ -public class PushStreamStatusChangeFromRedisDto { - - private boolean setAllOffline; - - private List onlineStreams; - - private List offlineStreams; - - - public boolean isSetAllOffline() { - return setAllOffline; - } - - public void setSetAllOffline(boolean setAllOffline) { - this.setAllOffline = setAllOffline; - } - - public List getOnlineStreams() { - return onlineStreams; - } - - public void setOnlineStreams(List onlineStreams) { - this.onlineStreams = onlineStreams; - } - - public List getOfflineStreams() { - return offlineStreams; - } - - public void setOfflineStreams(List offlineStreams) { - this.offlineStreams = offlineStreams; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/RequestPushStreamMsg.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/RequestPushStreamMsg.java deleted file mode 100644 index 5827d013..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/RequestPushStreamMsg.java +++ /dev/null @@ -1,170 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -/** - * redis消息:请求下级推送流信息 - * @author lin - */ -public class RequestPushStreamMsg { - - - /** - * 下级服务ID - */ - private String mediaServerId; - - /** - * 流ID - */ - private String app; - - /** - * 应用名 - */ - private String stream; - - /** - * 目标IP - */ - private String ip; - - /** - * 目标端口 - */ - private int port; - - /** - * ssrc - */ - private String ssrc; - - /** - * 是否使用TCP方式 - */ - private boolean tcp; - - /** - * 本地使用的端口 - */ - private int srcPort; - - /** - * 发送时,rtp的pt(uint8_t),不传时默认为96 - */ - private int pt; - - /** - * 发送时,rtp的负载类型。为true时,负载为ps;为false时,为es; - */ - private boolean ps; - - /** - * 是否只有音频 - */ - private boolean onlyAudio; - - - public static RequestPushStreamMsg getInstance(String mediaServerId, String app, String stream, String ip, int port, String ssrc, - boolean tcp, int srcPort, int pt, boolean ps, boolean onlyAudio) { - RequestPushStreamMsg requestPushStreamMsg = new RequestPushStreamMsg(); - requestPushStreamMsg.setMediaServerId(mediaServerId); - requestPushStreamMsg.setApp(app); - requestPushStreamMsg.setStream(stream); - requestPushStreamMsg.setIp(ip); - requestPushStreamMsg.setPort(port); - requestPushStreamMsg.setSsrc(ssrc); - requestPushStreamMsg.setTcp(tcp); - requestPushStreamMsg.setSrcPort(srcPort); - requestPushStreamMsg.setPt(pt); - requestPushStreamMsg.setPs(ps); - requestPushStreamMsg.setOnlyAudio(onlyAudio); - return requestPushStreamMsg; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getSsrc() { - return ssrc; - } - - public void setSsrc(String ssrc) { - this.ssrc = ssrc; - } - - public boolean isTcp() { - return tcp; - } - - public void setTcp(boolean tcp) { - this.tcp = tcp; - } - - public int getSrcPort() { - return srcPort; - } - - public void setSrcPort(int srcPort) { - this.srcPort = srcPort; - } - - public int getPt() { - return pt; - } - - public void setPt(int pt) { - this.pt = pt; - } - - public boolean isPs() { - return ps; - } - - public void setPs(boolean ps) { - this.ps = ps; - } - - public boolean isOnlyAudio() { - return onlyAudio; - } - - public void setOnlyAudio(boolean onlyAudio) { - this.onlyAudio = onlyAudio; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/RequestSendItemMsg.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/RequestSendItemMsg.java deleted file mode 100644 index 0c6502d1..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/RequestSendItemMsg.java +++ /dev/null @@ -1,188 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -/** - * redis消息:请求下级回复推送信息 - * @author lin - */ -public class RequestSendItemMsg { - - /** - * 下级服务ID - */ - private String serverId; - - /** - * 下级服务ID - */ - private String mediaServerId; - - /** - * 流ID - */ - private String app; - - /** - * 应用名 - */ - private String stream; - - /** - * 目标IP - */ - private String ip; - - /** - * 目标端口 - */ - private int port; - - /** - * ssrc - */ - private String ssrc; - - /** - * 平台国标编号 - */ - private String platformId; - - /** - * 平台名称 - */ - private String platformName; - - /** - * 通道ID - */ - private String channelId; - - - /** - * 是否使用TCP - */ - private Boolean isTcp; - - - /** - * 是否使用TCP - */ - private Boolean rtcp; - - - - - public static RequestSendItemMsg getInstance(String serverId, String mediaServerId, String app, String stream, String ip, int port, - String ssrc, String platformId, String channelId, Boolean isTcp, Boolean rtcp, String platformName) { - RequestSendItemMsg requestSendItemMsg = new RequestSendItemMsg(); - requestSendItemMsg.setServerId(serverId); - requestSendItemMsg.setMediaServerId(mediaServerId); - requestSendItemMsg.setApp(app); - requestSendItemMsg.setStream(stream); - requestSendItemMsg.setIp(ip); - requestSendItemMsg.setPort(port); - requestSendItemMsg.setSsrc(ssrc); - requestSendItemMsg.setPlatformId(platformId); - requestSendItemMsg.setPlatformName(platformName); - requestSendItemMsg.setChannelId(channelId); - requestSendItemMsg.setTcp(isTcp); - requestSendItemMsg.setRtcp(rtcp); - - return requestSendItemMsg; - } - - public String getServerId() { - return serverId; - } - - public void setServerId(String serverId) { - this.serverId = serverId; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getSsrc() { - return ssrc; - } - - public void setSsrc(String ssrc) { - this.ssrc = ssrc; - } - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public String getPlatformName() { - return platformName; - } - - public void setPlatformName(String platformName) { - this.platformName = platformName; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public Boolean getTcp() { - return isTcp; - } - - public void setTcp(Boolean tcp) { - isTcp = tcp; - } - - public Boolean getRtcp() { - return rtcp; - } - - public void setRtcp(Boolean rtcp) { - this.rtcp = rtcp; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ResponseSendItemMsg.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ResponseSendItemMsg.java deleted file mode 100644 index 501621bb..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ResponseSendItemMsg.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; - -/** - * redis消息:下级回复推送信息 - * @author lin - */ -public class ResponseSendItemMsg { - - private SendRtpItem sendRtpItem; - - private MediaServerItem mediaServerItem; - - public SendRtpItem getSendRtpItem() { - return sendRtpItem; - } - - public void setSendRtpItem(SendRtpItem sendRtpItem) { - this.sendRtpItem = sendRtpItem; - } - - public MediaServerItem getMediaServerItem() { - return mediaServerItem; - } - - public void setMediaServerItem(MediaServerItem mediaServerItem) { - this.mediaServerItem = mediaServerItem; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/SSRCInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/SSRCInfo.java deleted file mode 100644 index 468b6bfa..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/SSRCInfo.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -public class SSRCInfo { - - private int port; - private String ssrc; - private String Stream; - - public SSRCInfo() { - - } - - public SSRCInfo(int port, String ssrc, String stream) { - this.port = port; - this.ssrc = ssrc; - Stream = stream; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getSsrc() { - return ssrc; - } - - public void setSsrc(String ssrc) { - this.ssrc = ssrc; - } - - public String getStream() { - return Stream; - } - - public void setStream(String stream) { - Stream = stream; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/StreamPushItemFromRedis.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/StreamPushItemFromRedis.java deleted file mode 100644 index ff32d791..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/StreamPushItemFromRedis.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - - -public class StreamPushItemFromRedis { - private String app; - private String stream; - private long timeStamp; - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public long getTimeStamp() { - return timeStamp; - } - - public void setTimeStamp(long timeStamp) { - this.timeStamp = timeStamp; - } -} - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ThirdPartyGB.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ThirdPartyGB.java deleted file mode 100644 index 9d6b06a4..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/ThirdPartyGB.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -public class ThirdPartyGB { - - private String name; - private String nationalStandardNo; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getNationalStandardNo() { - return nationalStandardNo; - } - - public void setNationalStandardNo(String nationalStandardNo) { - this.nationalStandardNo = nationalStandardNo; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/WvpRedisMsg.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/WvpRedisMsg.java deleted file mode 100644 index 12d79cb2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/WvpRedisMsg.java +++ /dev/null @@ -1,116 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -/** - * @author lin - */ -public class WvpRedisMsg { - - public static WvpRedisMsg getInstance(String fromId, String toId, String type, String cmd, String serial, String content){ - WvpRedisMsg wvpRedisMsg = new WvpRedisMsg(); - wvpRedisMsg.setFromId(fromId); - wvpRedisMsg.setToId(toId); - wvpRedisMsg.setType(type); - wvpRedisMsg.setCmd(cmd); - wvpRedisMsg.setSerial(serial); - wvpRedisMsg.setContent(content); - return wvpRedisMsg; - } - - private String fromId; - - private String toId; - /** - * req 请求, res 回复 - */ - private String type; - private String cmd; - - /** - * 消息的ID - */ - private String serial; - private Object content; - - private final static String requestTag = "req"; - private final static String responseTag = "res"; - - public static WvpRedisMsg getRequestInstance(String fromId, String toId, String cmd, String serial, Object content) { - WvpRedisMsg wvpRedisMsg = new WvpRedisMsg(); - wvpRedisMsg.setType(requestTag); - wvpRedisMsg.setFromId(fromId); - wvpRedisMsg.setToId(toId); - wvpRedisMsg.setCmd(cmd); - wvpRedisMsg.setSerial(serial); - wvpRedisMsg.setContent(content); - return wvpRedisMsg; - } - - public static WvpRedisMsg getResponseInstance() { - WvpRedisMsg wvpRedisMsg = new WvpRedisMsg(); - wvpRedisMsg.setType(responseTag); - return wvpRedisMsg; - } - - public static WvpRedisMsg getResponseInstance(String fromId, String toId, String cmd, String serial, Object content) { - WvpRedisMsg wvpRedisMsg = new WvpRedisMsg(); - wvpRedisMsg.setType(responseTag); - wvpRedisMsg.setFromId(fromId); - wvpRedisMsg.setToId(toId); - wvpRedisMsg.setCmd(cmd); - wvpRedisMsg.setSerial(serial); - wvpRedisMsg.setContent(content); - return wvpRedisMsg; - } - - public static boolean isRequest(WvpRedisMsg wvpRedisMsg) { - return requestTag.equals(wvpRedisMsg.getType()); - } - - public String getSerial() { - return serial; - } - - public void setSerial(String serial) { - this.serial = serial; - } - - public String getFromId() { - return fromId; - } - - public void setFromId(String fromId) { - this.fromId = fromId; - } - - public String getToId() { - return toId; - } - - public void setToId(String toId) { - this.toId = toId; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getCmd() { - return cmd; - } - - public void setCmd(String cmd) { - this.cmd = cmd; - } - - public Object getContent() { - return content; - } - - public void setContent(Object content) { - this.content = content; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/WvpRedisMsgCmd.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/WvpRedisMsgCmd.java deleted file mode 100644 index cb118865..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/bean/WvpRedisMsgCmd.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.genersoft.iot.vmp.service.bean; - -/** - * @author lin - */ - -public class WvpRedisMsgCmd { - - public static final String GET_SEND_ITEM = "GetSendItem"; - public static final String REQUEST_PUSH_STREAM = "RequestPushStream"; - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java deleted file mode 100644 index 192b9061..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import com.genersoft.iot.vmp.service.IDeviceAlarmService; -import com.genersoft.iot.vmp.storager.dao.DeviceAlarmMapper; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import java.util.List; - -@Service -public class DeviceAlarmServiceImpl implements IDeviceAlarmService { - - @Autowired - private DeviceAlarmMapper deviceAlarmMapper; - - @Override - public Page listByPage(Page page, DeviceAlarm entity) { - return deviceAlarmMapper.selectPage(page, Wrappers.lambdaQuery(entity) - .ge(StrUtil.isNotBlank(entity.getStartTime()), DeviceAlarm::getStartTime, entity.getStartTime()) - .le(StrUtil.isNotBlank(entity.getEndTime()), DeviceAlarm::getEndTime, entity.getEndTime())); - } - - @Override - public void add(DeviceAlarm deviceAlarm) { - deviceAlarmMapper.insert(deviceAlarm); - } - - @Override - public int clearAlarmBeforeTime(Integer id, List deviceIdList, String time) { - return deviceAlarmMapper.clearAlarmBeforeTime(id, deviceIdList, time); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java deleted file mode 100644 index bff2bfe9..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java +++ /dev/null @@ -1,294 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; -import com.genersoft.iot.vmp.storager.dao.DeviceMapper; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.iteaj.framework.BaseServiceImpl; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.CollectionUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - -/** - * @author lin - */ -@Service -public class DeviceChannelServiceImpl extends BaseServiceImpl implements IDeviceChannelService { - - private final static Logger logger = LoggerFactory.getLogger(DeviceChannelServiceImpl.class); - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private DeviceChannelMapper channelMapper; - - @Autowired - private DeviceMapper deviceMapper; - - @Override - public DeviceChannel updateGps(DeviceChannel deviceChannel, Device device) { - if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) { - if (device == null) { - device = deviceMapper.getDeviceByDeviceId(deviceChannel.getDeviceId()); - } - - if ("WGS84".equals(device.getGeoCoordSys())) { - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeGcj02(position[0]); - deviceChannel.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(position[0]); - deviceChannel.setLatitudeWgs84(position[1]); - }else { - deviceChannel.setLongitudeGcj02(0.00); - deviceChannel.setLatitudeGcj02(0.00); - deviceChannel.setLongitudeWgs84(0.00); - deviceChannel.setLatitudeWgs84(0.00); - } - }else { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - } - return deviceChannel; - } - - @Override - public void updateChannel(String deviceId, DeviceChannel channel) { - String channelId = channel.getChannelId(); - channel.setDeviceId(deviceId); -// StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - if (inviteInfo != null && inviteInfo.getStreamInfo() != null) { - channel.setStreamId(inviteInfo.getStreamInfo().getStream()); - } - String now = DateUtil.getNow(); - channel.setUpdateTime(now); - DeviceChannel deviceChannel = this.getOne(deviceId, channelId); - channel = updateGps(channel, null); - if (deviceChannel == null) { - channel.setCreateTime(now); - channelMapper.insert(channel); - }else { - channelMapper.updateById(channel); - } - channelMapper.updateChannelSubCount(deviceId,channel.getParentId()); - } - - @Override - public int updateChannels(String deviceId, List channels) { - List addChannels = new ArrayList<>(); - List updateChannels = new ArrayList<>(); - HashMap channelsInStore = new HashMap<>(); - Device device = deviceMapper.getDeviceByDeviceId(deviceId); - if (channels != null && channels.size() > 0) { - List channelList = channelMapper.queryChannels(deviceId, null, null, null, null,null); - if (channelList.size() == 0) { - for (DeviceChannel channel : channels) { - channel.setDeviceId(deviceId); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channel.getChannelId()); - if (inviteInfo != null && inviteInfo.getStreamInfo() != null) { - channel.setStreamId(inviteInfo.getStreamInfo().getStream()); - } - String now = DateUtil.getNow(); - channel.setUpdateTime(now); - channel.setCreateTime(now); - channel = updateGps(channel, device); - addChannels.add(channel); - } - }else { - for (DeviceChannel deviceChannel : channelList) { - channelsInStore.put(deviceChannel.getChannelId(), deviceChannel); - } - for (DeviceChannel channel : channels) { - channel.setDeviceId(deviceId); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channel.getChannelId()); - if (inviteInfo != null && inviteInfo.getStreamInfo() != null) { - channel.setStreamId(inviteInfo.getStreamInfo().getStream()); - } - String now = DateUtil.getNow(); - channel.setUpdateTime(now); - channel = updateGps(channel, device); - if (channelsInStore.get(channel.getChannelId()) != null) { - updateChannels.add(channel); - }else { - addChannels.add(channel); - channel.setCreateTime(now); - } - } - } - int limitCount = 50; - if (addChannels.size() > 0) { - this.saveBatch(addChannels); - } - if (updateChannels.size() > 0) { - if (updateChannels.size() > limitCount) { - for (int i = 0; i < updateChannels.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > updateChannels.size()) { - toIndex = updateChannels.size(); - } - channelMapper.batchUpdate(updateChannels.subList(i, toIndex)); - } - }else { - channelMapper.batchUpdate(updateChannels); - } - this.saveOrUpdateBatch(updateChannels); - } - } - return addChannels.size() + updateChannels.size(); - } - - @Override - public ResourceBaseInfo getOverview() { - int online = channelMapper.getOnlineCount(); - int total = channelMapper.selectCount(Wrappers.emptyWrapper()); - return new ResourceBaseInfo(total, online); - } - - - @Override - public List queryAllChannelList(String platformId) { - return channelMapper.queryChannelListInAll(null, null, null, platformId, null); - } - - @Override - public boolean updateAllGps(Device device) { - List deviceChannels = channelMapper.getChannelsWithoutTransform(device.getDeviceId()); - List result = new CopyOnWriteArrayList<>(); - if (deviceChannels.size() == 0) { - return true; - } - String now = DateUtil.getNow(); - deviceChannels.parallelStream().forEach(deviceChannel -> { - deviceChannel.setUpdateTime(now); - result.add(updateGps(deviceChannel, device)); - }); - int limitCount = 50; - if (result.size() > limitCount) { - for (int i = 0; i < result.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > result.size()) { - toIndex = result.size(); - } - channelMapper.batchUpdate(result.subList(i, toIndex)); - } - }else { - channelMapper.batchUpdate(result); - } - - return true; - } - - @Override - public List getDeviceByChannelId(String channelId) { - return channelMapper.getDeviceByChannelId(channelId); - } - - @Override - public int deleteChannels(List deleteChannelList) { - if(CollectionUtils.isEmpty(deleteChannelList)) { - return 0; - } - - return channelMapper.batchDel(deleteChannelList); - } - - @Override - public int channelsOnline(List channels) { - if(CollectionUtils.isEmpty(channels)) { - return 0; - } - - return channelMapper.batchOnline(channels); - } - - @Override - public int channelsOffline(List channels) { - return channelMapper.batchOffline(channels); - } - - @Override - public DeviceChannel getOne(String deviceId, String channelId){ - return channelMapper.selectOne(Wrappers.lambdaQuery() - .eq(DeviceChannel::getDeviceId, deviceId) - .eq(DeviceChannel::getChannelId, channelId)); - } - - @Override - public void batchUpdateChannel(List channels) { - String now = DateUtil.getNow(); - for (DeviceChannel channel : channels) { - channel.setUpdateTime(now); - } - - this.saveOrUpdateBatch(channels); - for (DeviceChannel channel : channels) { - if (channel.getParentId() != null) { - channelMapper.updateChannelSubCount(channel.getDeviceId(), channel.getParentId()); - } - } - } - - @Override - public void batchAddChannel(List channels) { - this.saveBatch(channels); - for (DeviceChannel channel : channels) { - if (channel.getParentId() != null) { - channelMapper.updateChannelSubCount(channel.getDeviceId(), channel.getParentId()); - } - } - } - - @Override - public List selectChannelsByDeviceId(String deviceId) { - return this.list(Wrappers.lambdaQuery().eq(DeviceChannel::getDeviceId, deviceId)).getData(); - } - - @Override - public List getAllChannelWithCoordinate(String deviceId) { - return this.list(Wrappers.lambdaQuery() - .eq(DeviceChannel::getDeviceId, deviceId) - .apply("longitude*latitude > 0")) - .getData(); - } - - @Override - public void updatePosition(DeviceChannel deviceChannel) { - this.update(deviceChannel, Wrappers.lambdaUpdate() - .eq(DeviceChannel::getDeviceId, deviceChannel.getDeviceId()) - .eq(deviceChannel.getChannelId() != null, DeviceChannel::getChannelId, deviceChannel.getChannelId())); - } - - @Override - public DeviceChannel getByDeviceIdAndChannelId(String deviceId, String channelId) { - return this.getOne(deviceId, channelId); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java deleted file mode 100644 index df1ba0c7..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ /dev/null @@ -1,650 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; -import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; -import com.genersoft.iot.vmp.storager.dao.DeviceMapper; -import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.BaseTree; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; -import com.iteaj.framework.exception.ServiceException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.stereotype.Service; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.time.Instant; -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.concurrent.TimeUnit; - -/** - * 设备业务(目录订阅) - */ -@Service("WvpDeviceServiceImpl") -public class DeviceServiceImpl implements IDeviceService { - - private final static Logger logger = LoggerFactory.getLogger(DeviceServiceImpl.class); - - @Autowired - private SIPCommander cmder; - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private ISIPCommander sipCommander; - - @Autowired - private CatalogResponseMessageHandler catalogResponseMessageHandler; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private DeviceMapper deviceMapper; - - @Autowired - private PlatformChannelMapper platformChannelMapper; - - @Autowired - private IDeviceChannelService deviceChannelService; - - @Autowired - private DeviceChannelMapper deviceChannelMapper; - - @Autowired - DataSourceTransactionManager dataSourceTransactionManager; - - @Autowired - TransactionDefinition transactionDefinition; - - @Autowired - private UserSetting userSetting; - - @Autowired - private ISIPCommander commander; - - @Autowired - private VideoStreamSessionManager streamSession; - - @Autowired - private IMediaServerService mediaServerService; - - @Override - public void online(Device device, SipTransactionInfo sipTransactionInfo) { - logger.info("[设备上线] deviceId:{}->{}:{}", device.getDeviceId(), device.getIp(), device.getPort()); - Device deviceInRedis = redisCatchStorage.getDevice(device.getDeviceId()); - Device deviceInDb = deviceMapper.getDeviceByDeviceId(device.getDeviceId()); - - String now = DateUtil.getNow(); - if (deviceInRedis != null && deviceInDb == null) { - // redis 存在脏数据 - inviteStreamService.clearInviteInfo(device.getDeviceId()); - } - device.setUpdateTime(now); - device.setKeepaliveTime(now); - if (device.getKeepaliveIntervalTime() == null) { - // 默认心跳间隔60 - device.setKeepaliveIntervalTime(60); - } - if (sipTransactionInfo != null) { - device.setSipTransactionInfo(sipTransactionInfo); - }else { - if (deviceInRedis != null) { - device.setSipTransactionInfo(deviceInRedis.getSipTransactionInfo()); - } - } - - // 第一次上线 或则设备之前是离线状态--进行通道同步和设备信息查询 - if (deviceInDb == null) { - device.setOnLine(true); - device.setCreateTime(now); - device.setUpdateTime(now); - logger.info("[设备上线,首次注册]: {},查询设备信息以及通道信息", device.getDeviceId()); - deviceMapper.insert(device); - redisCatchStorage.updateDevice(device); - try { - commander.deviceInfoQuery(device); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage()); - } - sync(device); - }else { - - if (deviceInDb != null) { - device.setSwitchPrimarySubStream(deviceInDb.isSwitchPrimarySubStream()); - } - if(!device.isOnLine()){ - device.setOnLine(true); - device.setCreateTime(now); - this.updateByDeviceId(device); - redisCatchStorage.updateDevice(device); - if (userSetting.getSyncChannelOnDeviceOnline()) { - logger.info("[设备上线,离线状态下重新注册]: {},查询设备信息以及通道信息", device.getDeviceId()); - try { - commander.deviceInfoQuery(device); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 查询设备信息: {}", e.getMessage()); - } - sync(device); - // TODO 如果设备下的通道级联到了其他平台,那么需要发送事件或者notify给上级平台 - } - }else { - if (!deviceChannelMapper.isChannel(device.getDeviceId())) { - logger.info("[设备上线]: {},通道数为0,查询通道信息", device.getDeviceId()); - sync(device); - } - - this.updateByDeviceId(device); - redisCatchStorage.updateDevice(device); - } - - } - - // 上线添加订阅 - if (device.getSubscribeCycleForCatalog() > 0) { - // 查询在线设备那些开启了订阅,为设备开启定时的目录订阅 - addCatalogSubscribe(device); - } - if (device.getSubscribeCycleForMobilePosition() > 0) { - addMobilePositionSubscribe(device); - } - // 刷新过期任务 - String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + device.getDeviceId(); - // 如果第一次注册那么必须在60 * 3时间内收到一个心跳,否则设备离线 - dynamicTask.startDelay(registerExpireTaskKey, ()-> offline(device.getDeviceId(), "首次注册后未能收到心跳"), device.getKeepaliveIntervalTime() * 1000 * 3); - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, true); - } - -// -// try { -// cmder.alarmSubscribe(device, 600, "0", "4", "0", "2023-7-27T00:00:00", "2023-7-28T00:00:00"); -// } catch (InvalidArgumentException e) { -// throw new RuntimeException(e); -// } catch (SipException e) { -// throw new RuntimeException(e); -// } catch (ParseException e) { -// throw new RuntimeException(e); -// } - - } - - @Override - public void offline(String deviceId, String reason) { - logger.warn("[设备离线],{}, device:{}", reason, deviceId); - Device device = deviceMapper.getDeviceByDeviceId(deviceId); - if (device == null) { - return; - } - String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId; - dynamicTask.stop(registerExpireTaskKey); - device.setOnLine(false); - redisCatchStorage.updateDevice(device); - this.updateByDeviceId(device); - //进行通道离线 -// deviceChannelMapper.offlineByDeviceId(deviceId); - // 离线释放所有ssrc - List ssrcTransactions = streamSession.getSsrcTransactionForAll(deviceId, null, null, null); - if (ssrcTransactions != null && ssrcTransactions.size() > 0) { - for (SsrcTransaction ssrcTransaction : ssrcTransactions) { - mediaServerService.releaseSsrc(ssrcTransaction.getMediaServerId(), ssrcTransaction.getSsrc()); - mediaServerService.closeRTPServer(ssrcTransaction.getMediaServerId(), ssrcTransaction.getStream()); - streamSession.removeByCallId(deviceId, ssrcTransaction.getChannelId(), ssrcTransaction.getCallId()); - } - } - // 移除订阅 - removeCatalogSubscribe(device); - removeMobilePositionSubscribe(device); - if (userSetting.getDeviceStatusNotify()) { - // 发送redis消息 - redisCatchStorage.sendDeviceOrChannelStatus(device.getDeviceId(), null, false); - } - - } - - @Override - public boolean addCatalogSubscribe(Device device) { - if (device == null || device.getSubscribeCycleForCatalog() < 0) { - return false; - } - logger.info("[添加目录订阅] 设备{}", device.getDeviceId()); - // 添加目录订阅 - CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander, dynamicTask); - // 刷新订阅 - int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForCatalog(),30); - // 设置最小值为30 - dynamicTask.startCron(device.getDeviceId() + "catalog", catalogSubscribeTask, (subscribeCycleForCatalog -1) * 1000); - return true; - } - - @Override - public boolean removeCatalogSubscribe(Device device) { - if (device == null || device.getSubscribeCycleForCatalog() < 0) { - return false; - } - logger.info("[移除目录订阅]: {}", device.getDeviceId()); - String taskKey = device.getDeviceId() + "catalog"; - if (device.isOnLine()) { - Runnable runnable = dynamicTask.get(taskKey); - if (runnable instanceof ISubscribeTask) { - ISubscribeTask subscribeTask = (ISubscribeTask) runnable; - subscribeTask.stop(); - } - } - dynamicTask.stop(taskKey); - return true; - } - - @Override - public boolean addMobilePositionSubscribe(Device device) { - if (device == null || device.getSubscribeCycleForMobilePosition() < 0) { - return false; - } - logger.info("[添加移动位置订阅] 设备{}", device.getDeviceId()); - // 添加目录订阅 - MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander, dynamicTask); - // 设置最小值为30 - int subscribeCycleForCatalog = Math.max(device.getSubscribeCycleForMobilePosition(),30); - // 刷新订阅 - dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, (subscribeCycleForCatalog) * 1000); - return true; - } - - @Override - public boolean removeMobilePositionSubscribe(Device device) { - if (device == null || device.getSubscribeCycleForCatalog() < 0) { - return false; - } - logger.info("[移除移动位置订阅]: {}", device.getDeviceId()); - String taskKey = device.getDeviceId() + "mobile_position"; - if (device.isOnLine()) { - Runnable runnable = dynamicTask.get(taskKey); - if (runnable instanceof ISubscribeTask) { - ISubscribeTask subscribeTask = (ISubscribeTask) runnable; - subscribeTask.stop(); - } - } - dynamicTask.stop(taskKey); - return true; - } - - @Override - public SyncStatus getChannelSyncStatus(String deviceId) { - return catalogResponseMessageHandler.getChannelSyncProgress(deviceId); - } - - @Override - public Boolean isSyncRunning(String deviceId) { - return catalogResponseMessageHandler.isSyncRunning(deviceId); - } - - @Override - public void sync(Device device) { - if (catalogResponseMessageHandler.isSyncRunning(device.getDeviceId())) { - logger.info("开启同步时发现同步已经存在"); - return; - } - int sn = (int)((Math.random()*9+1)*100000); - catalogResponseMessageHandler.setChannelSyncReady(device, sn); - try { - sipCommander.catalogQuery(device, sn, event -> { - String errorMsg = String.format("同步通道失败,错误码: %s, %s", event.statusCode, event.msg); - catalogResponseMessageHandler.setChannelSyncEnd(device.getDeviceId(), errorMsg); - }); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[同步通道], 信令发送失败:{}", e.getMessage(), e); - String errorMsg = String.format("同步通道失败,信令发送失败: %s", e.getMessage()); - catalogResponseMessageHandler.setChannelSyncEnd(device.getDeviceId(), errorMsg); - } - } - - @Override - public Device getDevice(String deviceId) { - Device device = redisCatchStorage.getDevice(deviceId); - if (device == null) { - device = deviceMapper.getDeviceByDeviceId(deviceId); - if (device != null) { - redisCatchStorage.updateDevice(device); - } - } - return device; - } - - @Override - public List getAllOnlineDevice() { - return deviceMapper.selectList(Wrappers.lambdaQuery().eq(Device::isOnLine, true)); - } - - @Override - public boolean expire(Device device) { - Instant registerTimeDate = Instant.from(DateUtil.formatter.parse(device.getRegisterTime())); - Instant expireInstant = registerTimeDate.plusMillis(TimeUnit.SECONDS.toMillis(device.getExpires())); - return expireInstant.isBefore(Instant.now()); - } - - @Override - public void checkDeviceStatus(Device device) { - if (device == null || !device.isOnLine()) { - return; - } - try { - sipCommander.deviceStatusQuery(device, null); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 设备状态查询: {}", e.getMessage()); - } - - } - - @Override - public Device getDeviceByHostAndPort(String host, int port) { - return deviceMapper.selectOne(Wrappers.lambdaQuery() - .eq(Device::getIp, host) - .eq(Device::getPort, port)); - } - - @Override - public void updateDevice(Device device) { - - String now = DateUtil.getNow(); - device.setUpdateTime(now); - device.setCharset(device.getCharset().toUpperCase()); - device.setUpdateTime(DateUtil.getNow()); - if (this.updateByDeviceId(device) > 0) { - redisCatchStorage.updateDevice(device); - } - } - - /** - * 更新通道坐标系 - */ - private void updateDeviceChannelGeoCoordSys(Device device) { - List deviceChannels = deviceChannelService.getAllChannelWithCoordinate(device.getDeviceId()); - if (deviceChannels.size() > 0) { - List deviceChannelsForStore = new ArrayList<>(); - for (DeviceChannel deviceChannel : deviceChannels) { - deviceChannelsForStore.add(deviceChannelService.updateGps(deviceChannel, device)); - } - deviceChannelService.updateChannels(device.getDeviceId(), deviceChannelsForStore); - } - } - - - @Override - public List> queryVideoDeviceTree(String deviceId, String parentId, boolean onlyCatalog) { - Device device = deviceMapper.getDeviceByDeviceId(deviceId); - if (device == null) { - return null; - } - if (ObjectUtils.isEmpty(parentId) ) { - parentId = deviceId; - } - List rootNodes = deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, onlyCatalog); - return transportChannelsToTree(rootNodes, ""); - } - - @Override - public List queryVideoDeviceInTreeNode(String deviceId, String parentId) { - Device device = deviceMapper.getDeviceByDeviceId(deviceId); - if (device == null) { - return null; - } - if (ObjectUtils.isEmpty(parentId) || parentId.equals(deviceId)) { - return deviceChannelMapper.getSubChannelsByDeviceId(deviceId, null, false); - }else { - return deviceChannelMapper.getSubChannelsByDeviceId(deviceId, parentId, false); - } - } - - private List> transportChannelsToTree(List channels, String parentId) { - if (channels == null) { - return null; - } - List> treeNotes = new ArrayList<>(); - if (channels.size() == 0) { - return treeNotes; - } - for (DeviceChannel channel : channels) { - - BaseTree node = new BaseTree<>(); - node.setId(channel.getChannelId()); - node.setDeviceId(channel.getDeviceId()); - node.setName(channel.getName()); - node.setPid(parentId); - node.setBasicData(channel); - node.setParent(false); - if (channel.getChannelId().length() <= 8) { - node.setParent(true); - }else { - if (channel.getChannelId().length() != 20) { - node.setParent(channel.getParental() == 1); - }else { - try { - int type = Integer.parseInt(channel.getChannelId().substring(10, 13)); - if (type == 215 || type == 216 || type == 200) { - node.setParent(true); - } - }catch (NumberFormatException e) { - node.setParent(false); - } - } - } - treeNotes.add(node); - } - Collections.sort(treeNotes); - return treeNotes; - } - - @Override - public boolean isExist(String deviceId) { - return deviceMapper.getDeviceByDeviceId(deviceId) != null; - } - - @Override - public void addDevice(Device device) { - device.setOnLine(false); - device.setCreateTime(DateUtil.getNow()); - device.setUpdateTime(DateUtil.getNow()); - if(StrUtil.isBlank(device.getDeviceId())) { - throw new ServiceException("设备国标编号必填"); - } - - Device byDeviceId = deviceMapper.getDeviceByDeviceId(device.getDeviceId()); - if(byDeviceId != null) { - throw new ServiceException("设备已存在["+device.getDeviceId()+"]"); - } - - deviceMapper.insert(device); - } - - @Override - public void updateCustomDevice(Device device) { - Device deviceInStore = deviceMapper.getDeviceByDeviceId(device.getDeviceId()); - if (deviceInStore == null) { - logger.warn("更新设备时未找到设备信息"); - return; - } - if(!deviceInStore.isSwitchPrimarySubStream().equals(device.isSwitchPrimarySubStream())){ - //当修改设备的主子码流开关时,需要校验是否存在流,如果存在流则直接关闭 - List ssrcTransactionForAll = streamSession.getSsrcTransactionForAll(device.getDeviceId(), null, null, null); - if(ssrcTransactionForAll != null){ - for (SsrcTransaction ssrcTransaction: ssrcTransactionForAll) { - try { - cmder.streamByeCmd(device, ssrcTransaction.getChannelId(), ssrcTransaction.getStream(), null, null); - } catch (InvalidArgumentException | SsrcTransactionNotFoundException | ParseException | SipException e) { - throw new RuntimeException(e); - } - } - } - - deviceChannelMapper.update(null, Wrappers.lambdaUpdate() - .set(DeviceChannel::getStreamId, null) - .eq(DeviceChannel::getDeviceId, device.getDeviceId())); - inviteStreamService.clearInviteInfo(device.getDeviceId()); - } - - if (!ObjectUtils.isEmpty(device.getName())) { - deviceInStore.setName(device.getName()); - } - if (!ObjectUtils.isEmpty(device.getCharset())) { - deviceInStore.setCharset(device.getCharset()); - } - if (!ObjectUtils.isEmpty(device.getMediaServerId())) { - deviceInStore.setMediaServerId(device.getMediaServerId()); - } - if (!ObjectUtils.isEmpty(device.getCharset())) { - deviceInStore.setCharset(device.getCharset()); - } - if (!ObjectUtils.isEmpty(device.getSdpIp())) { - deviceInStore.setSdpIp(device.getSdpIp()); - } - if (!ObjectUtils.isEmpty(device.getPassword())) { - deviceInStore.setPassword(device.getPassword()); - } - if (!ObjectUtils.isEmpty(device.getStreamMode())) { - deviceInStore.setStreamMode(device.getStreamMode()); - } - - - // 目录订阅相关的信息 - if (deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) { - if (device.getSubscribeCycleForCatalog() > 0) { - // 若已开启订阅,但订阅周期不同,则先取消 - if (deviceInStore.getSubscribeCycleForCatalog() != 0) { - removeCatalogSubscribe(deviceInStore); - } - // 开启订阅 - deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); - addCatalogSubscribe(deviceInStore); - }else if (device.getSubscribeCycleForCatalog() == 0) { - // 取消订阅 - deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); - removeCatalogSubscribe(deviceInStore); - } - } - - // 移动位置订阅相关的信息 - if (device.getSubscribeCycleForMobilePosition() > 0) { - if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) { - deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval()); - deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition()); - // 开启订阅 - addMobilePositionSubscribe(deviceInStore); - } - }else if (device.getSubscribeCycleForMobilePosition() == 0) { - if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) { - deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval()); - deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition()); - // 取消订阅 - removeMobilePositionSubscribe(deviceInStore); - } - } - if (deviceInStore.getGeoCoordSys() != null) { - // 坐标系变化,需要重新计算GCJ02坐标和WGS84坐标 - if (!deviceInStore.getGeoCoordSys().equals(device.getGeoCoordSys())) { - deviceInStore.setGeoCoordSys(device.getGeoCoordSys()); - updateDeviceChannelGeoCoordSys(deviceInStore); - } - }else { - deviceInStore.setGeoCoordSys("WGS84"); - } - if (device.getCharset() == null) { - deviceInStore.setCharset("GB2312"); - } - //SSRC校验 - deviceInStore.setSsrcCheck(device.isSsrcCheck()); - //作为消息通道 - deviceInStore.setAsMessageChannel(device.isAsMessageChannel()); - - // 更新redis - this.updateByDeviceId(deviceInStore); - redisCatchStorage.removeDevice(deviceInStore.getDeviceId()); - } - - @Override - public boolean delete(String deviceId) { - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - boolean result = false; - try { - platformChannelMapper.delChannelForDeviceId(deviceId); - deviceChannelMapper.cleanChannelsByDeviceId(deviceId); - if ( this.deleteByDeviceId(deviceId) < 0 ) { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - } - result = true; - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - }catch (Exception e) { - dataSourceTransactionManager.rollback(transactionStatus); - } - if (result) { - redisCatchStorage.removeDevice(deviceId); - } - return result; - } - - @Override - public ResourceBaseInfo getOverview() { - List onlineDevices = this.getAllOnlineDevice(); - List all = deviceMapper.selectList(Wrappers.emptyWrapper()); - return new ResourceBaseInfo(all.size(), onlineDevices.size()); - } - - @Override - public List getAll() { - return deviceMapper.selectList(Wrappers.emptyWrapper()); - } - - @Override - public int updateByDeviceId(Device device) { - return deviceMapper.update(device, Wrappers.lambdaUpdate() - .eq(Device::getDeviceId, device.getDeviceId())); - } - - @Override - public int deleteByDeviceId(String deviceId) { - return deviceMapper.delete(Wrappers.lambdaQuery() - .eq(Device::getDeviceId, deviceId)); - } - - @Override - public DeviceMapper getDeviceMapper() { - return deviceMapper; - } - - @Override - public Page detailByPage(Page page, Device device) { - return getDeviceMapper().detailByPage(page, device); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java deleted file mode 100644 index b4eeb754..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java +++ /dev/null @@ -1,291 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; -import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; -import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper; -import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.stereotype.Service; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.util.ObjectUtils; - -import java.util.ArrayList; -import java.util.List; - -@Service -public class GbStreamServiceImpl extends ServiceImpl implements IGbStreamService { - - private final static Logger logger = LoggerFactory.getLogger(GbStreamServiceImpl.class); - - @Autowired - DataSourceTransactionManager dataSourceTransactionManager; - - @Autowired - TransactionDefinition transactionDefinition; - - @Autowired - private GbStreamMapper gbStreamMapper; - - @Autowired - private PlatformGbStreamMapper platformGbStreamMapper; - - @Autowired - private SubscribeHolder subscribeHolder; - - @Autowired - private ParentPlatformMapper platformMapper; - - @Autowired - private PlatformCatalogMapper catalogMapper; - - @Autowired - private EventPublisher eventPublisher; - - @Override - public Page getAll(Page page, GbStream entity) { - return gbStreamMapper.selectAllByPage(page, entity); - } - - @Override - public int del(String app, String stream) { - return gbStreamMapper.delete(Wrappers.lambdaQuery().eq(GbStream::getApp, app).eq(GbStream::getStream, stream)); - } - - - @Override - public boolean addPlatformInfo(List gbStreams, String platformId, String catalogId) { - // 放在事务内执行 - boolean result = false; - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - ParentPlatform parentPlatform = platformMapper.getParentPlatByServerGBId(platformId); - if (catalogId == null) { - catalogId = parentPlatform.getCatalogId(); - } - try { - List deviceChannelList = new ArrayList<>(); - - - for (int i = 0; i < gbStreams.size(); i++) { - GbStream gbStream = gbStreams.get(i); - gbStream.setCatalogId(catalogId); - gbStream.setPlatformId(platformId); - // TODO 修改为批量提交 - platformGbStreamMapper.insert(gbStream); - logger.info("[关联通道]直播流通道 平台:{}, 共需关联通道数:{}, 已关联:{}", platformId, gbStreams.size(), i + 1); - DeviceChannel deviceChannelListByStream = getDeviceChannelListByStreamWithStatus(gbStream, catalogId, parentPlatform); - deviceChannelList.add(deviceChannelListByStream); - } - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - if (subscribeHolder.getCatalogSubscribe(platformId) != null) { - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD); - } - - result = true; - }catch (Exception e) { - logger.error("批量保存流与平台的关系时错误", e); - dataSourceTransactionManager.rollback(transactionStatus); - } - return result; - } - - @Override - public DeviceChannel getDeviceChannelListByStream(GbStream gbStream, String catalogId, ParentPlatform platform) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); - deviceChannel.setName(gbStream.getName()); - deviceChannel.setLongitude(gbStream.getLongitude()); - deviceChannel.setLatitude(gbStream.getLatitude()); - deviceChannel.setDeviceId(platform.getDeviceGBId()); - deviceChannel.setManufacture("wvp-pro"); - deviceChannel.setStatus(gbStream.isStatus()); - - deviceChannel.setRegisterWay(1); - - PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platform.getServerGBId(), catalogId); - if (catalog != null) { - deviceChannel.setCivilCode(catalog.getCivilCode()); - deviceChannel.setParentId(catalog.getParentId()); - deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId()); - }else { - deviceChannel.setCivilCode(platform.getAdministrativeDivision()); - deviceChannel.setParentId(platform.getDeviceGBId()); - } - - deviceChannel.setModel("live"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setParental(0); - deviceChannel.setSecrecy("0"); - return deviceChannel; - } - - @Override - public boolean delPlatformInfo(String platformId, List gbStreams) { - // 放在事务内执行 - boolean result = false; - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - try { - List deviceChannelList = new ArrayList<>(); - platformGbStreamMapper.delByAppAndStreamsByPlatformId(gbStreams, platformId); - for (GbStream gbStream : gbStreams) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); - deviceChannelList.add(deviceChannel); - } - - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - result = true; - }catch (Exception e) { - logger.error("批量移除流与平台的关系时错误", e); - dataSourceTransactionManager.rollback(transactionStatus); - } - return result; - } - - @Override - public void sendCatalogMsg(GbStream gbStream, String type) { - if (gbStream == null || type == null) { - logger.warn("[发送目录订阅]类型:流信息或类型为NULL"); - return; - } - List gbStreams = new ArrayList<>(); - if (gbStream.getGbId() != null) { - gbStreams.add(gbStream); - }else { - GbStream gbStreamIndb = this.selectByAppAndStream(gbStream.getApp(), gbStream.getStream()); - if (gbStreamIndb != null && gbStreamIndb.getGbId() != null){ - gbStreams.add(gbStreamIndb); - } - } - sendCatalogMsgs(gbStreams, type); - } - - @Override - public void sendCatalogMsgs(List gbStreams, String type) { - if (gbStreams.size() > 0) { - for (GbStream gs : gbStreams) { - if (ObjectUtils.isEmpty(gs.getGbId())){ - continue; - } - List parentPlatforms = platformGbStreamMapper.selectByAppAndStream(gs.getApp(), gs.getStream()); - if (parentPlatforms.size() > 0) { - for (ParentPlatform parentPlatform : parentPlatforms) { - if (parentPlatform != null) { - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), gs, type); - } - } - } - } - } - } - - @Override - public int updateGbIdOrName(List streamPushItemForUpdate) { - return gbStreamMapper.updateGbIdOrName(streamPushItemForUpdate); - } - - @Override - public DeviceChannel getDeviceChannelListByStreamWithStatus(GbStream gbStream, String catalogId, ParentPlatform platform) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); - deviceChannel.setName(gbStream.getName()); - deviceChannel.setLongitude(gbStream.getLongitude()); - deviceChannel.setLatitude(gbStream.getLatitude()); - deviceChannel.setDeviceId(platform.getDeviceGBId()); - deviceChannel.setManufacture("wvp-pro"); - // todo 目前是每一条查询一次,需要优化 - Boolean status = null; - if ("proxy".equals(gbStream.getStreamType())) { - status = gbStreamMapper.selectStatusForProxy(gbStream.getApp(), gbStream.getStream()); - }else { - status = gbStreamMapper.selectStatusForPush(gbStream.getApp(), gbStream.getStream()); - } - deviceChannel.setStatus(status != null && status); - - deviceChannel.setRegisterWay(1); - PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platform.getServerGBId(), catalogId); - if (catalog != null) { - deviceChannel.setCivilCode(catalog.getCivilCode()); - deviceChannel.setParentId(catalog.getParentId()); - deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId()); - }else { - deviceChannel.setCivilCode(platform.getAdministrativeDivision()); - deviceChannel.setParentId(platform.getDeviceGBId()); - } - - deviceChannel.setModel("live"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setParental(0); - deviceChannel.setSecrecy("0"); - return deviceChannel; - } - - @Override - public List getAllGBChannels(String platformId) { - GbStream gbStream = new GbStream(); - gbStream.setPlatformId(platformId); - return gbStreamMapper.selectAll(gbStream); - - } - - @Override - public void delAllPlatformInfo(String platformId, String catalogId) { - if (platformId == null) { - return ; - } - ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId); - if (platform == null) { - return ; - } - if (ObjectUtils.isEmpty(catalogId)) { - catalogId = platform.getDeviceGBId(); - } - if (platformGbStreamMapper.delByPlatformAndCatalogId(platformId, catalogId) > 0) { - List gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId); - List deviceChannelList = new ArrayList<>(); - for (GbStream gbStream : gbStreams) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); - deviceChannelList.add(deviceChannel); - } - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); - } - } - - @Override - public List getGbChannelWithGbid(String gbId) { - return gbStreamMapper.selectList(Wrappers.lambdaQuery().eq(GbStream::getGbId, gbId)); - } - - @Override - public boolean updateByAppAndStream(GbStream gbStream) { - return this.update(gbStream, Wrappers.lambdaUpdate() - .eq(GbStream::getApp, gbStream.getApp()) - .eq(GbStream::getStream, gbStream.getStream())); - } - - @Override - public GbStream selectByAppAndStream(String app, String stream) { - return gbStreamMapper.selectOne(Wrappers.lambdaQuery().eq(GbStream::getApp, app).eq(GbStream::getStream, stream)); - } - - @Override - public void deleteWithoutGBId(String type, String mediaServerId) { - gbStreamMapper.delete(Wrappers.lambdaQuery() - .eq(GbStream::getStreamType, type) - .isNull(GbStream::getGbId) - .eq(GbStream::getMediaServerId, mediaServerId)); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java deleted file mode 100644 index 752d0631..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/InviteStreamServiceImpl.java +++ /dev/null @@ -1,267 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.alibaba.fastjson2.JSON; -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionStatus; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.service.bean.ErrorCallback; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Service; - -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.CopyOnWriteArrayList; - -@Service -public class InviteStreamServiceImpl implements IInviteStreamService { - - private final Logger logger = LoggerFactory.getLogger(InviteStreamServiceImpl.class); - - private final Map>> inviteErrorCallbackMap = new ConcurrentHashMap<>(); - - @Autowired - private RedisTemplate redisTemplate; - - @Override - public void updateInviteInfo(InviteInfo inviteInfo) { - if (inviteInfo == null || (inviteInfo.getDeviceId() == null || inviteInfo.getChannelId() == null)) { - logger.warn("[更新Invite信息],参数不全: {}", JSON.toJSON(inviteInfo)); - return; - } - InviteInfo inviteInfoForUpdate = null; - - if (InviteSessionStatus.ready == inviteInfo.getStatus()) { - if (inviteInfo.getDeviceId() == null - || inviteInfo.getChannelId() == null - || inviteInfo.getType() == null - || inviteInfo.getStream() == null - ) { - return; - } - inviteInfoForUpdate = inviteInfo; - } else { - InviteInfo inviteInfoInRedis = getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), - inviteInfo.getChannelId(), inviteInfo.getStream()); - if (inviteInfoInRedis == null) { - logger.warn("[更新Invite信息],未从缓存中读取到Invite信息: deviceId: {}, channel: {}, stream: {}", - inviteInfo.getDeviceId(), inviteInfo.getChannelId(), inviteInfo.getStream()); - return; - } - if (inviteInfo.getStreamInfo() != null) { - inviteInfoInRedis.setStreamInfo(inviteInfo.getStreamInfo()); - } - if (inviteInfo.getSsrcInfo() != null) { - inviteInfoInRedis.setSsrcInfo(inviteInfo.getSsrcInfo()); - } - if (inviteInfo.getStreamMode() != null) { - inviteInfoInRedis.setStreamMode(inviteInfo.getStreamMode()); - } - if (inviteInfo.getReceiveIp() != null) { - inviteInfoInRedis.setReceiveIp(inviteInfo.getReceiveIp()); - } - if (inviteInfo.getReceivePort() != null) { - inviteInfoInRedis.setReceivePort(inviteInfo.getReceivePort()); - } - if (inviteInfo.getStatus() != null) { - inviteInfoInRedis.setStatus(inviteInfo.getStatus()); - } - - inviteInfoForUpdate = inviteInfoInRedis; - - } - String key = VideoManagerConstants.INVITE_PREFIX + - ":" + inviteInfoForUpdate.getType() + - ":" + inviteInfoForUpdate.getDeviceId() + - ":" + inviteInfoForUpdate.getChannelId() + - ":" + inviteInfoForUpdate.getStream()+ - ":" + inviteInfoForUpdate.getSsrcInfo().getSsrc(); - redisTemplate.opsForValue().set(key, inviteInfoForUpdate); - } - - @Override - public InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream) { - - InviteInfo inviteInfoInDb = getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), inviteInfo.getChannelId(), inviteInfo.getStream()); - if (inviteInfoInDb == null) { - return null; - } - removeInviteInfo(inviteInfoInDb); - String key = VideoManagerConstants.INVITE_PREFIX + - ":" + inviteInfo.getType() + - ":" + inviteInfo.getDeviceId() + - ":" + inviteInfo.getChannelId() + - ":" + stream + - ":" + inviteInfo.getSsrcInfo().getSsrc(); - inviteInfoInDb.setStream(stream); - if (inviteInfoInDb.getSsrcInfo() != null) { - inviteInfoInDb.getSsrcInfo().setStream(stream); - } - redisTemplate.opsForValue().set(key, inviteInfoInDb); - return inviteInfoInDb; - } - - @Override - public InviteInfo getInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) { - String key = VideoManagerConstants.INVITE_PREFIX + - ":" + (type != null ? type : "*") + - ":" + (deviceId != null ? deviceId : "*") + - ":" + (channelId != null ? channelId : "*") + - ":" + (stream != null ? stream : "*") - + ":*"; - List scanResult = RedisUtil.scan(redisTemplate, key); - if (scanResult.size() != 1) { - return null; - } - - return (InviteInfo) redisTemplate.opsForValue().get(scanResult.get(0)); - } - - @Override - public InviteInfo getInviteInfoByDeviceAndChannel(InviteSessionType type, String deviceId, String channelId) { - return getInviteInfo(type, deviceId, channelId, null); - } - - @Override - public InviteInfo getInviteInfoByStream(InviteSessionType type, String stream) { - return getInviteInfo(type, null, null, stream); - } - - @Override - public void removeInviteInfo(InviteSessionType type, String deviceId, String channelId, String stream) { - String scanKey = VideoManagerConstants.INVITE_PREFIX + - ":" + (type != null ? type : "*") + - ":" + (deviceId != null ? deviceId : "*") + - ":" + (channelId != null ? channelId : "*") + - ":" + (stream != null ? stream : "*") + - ":*"; - List scanResult = RedisUtil.scan(redisTemplate, scanKey); - if (scanResult.size() > 0) { - for (Object keyObj : scanResult) { - String key = (String) keyObj; - InviteInfo inviteInfo = (InviteInfo) redisTemplate.opsForValue().get(key); - if (inviteInfo == null) { - continue; - } - redisTemplate.delete(key); - inviteErrorCallbackMap.remove(buildKey(type, deviceId, channelId, inviteInfo.getStream())); - } - } - } - - @Override - public void removeInviteInfoByDeviceAndChannel(InviteSessionType inviteSessionType, String deviceId, String channelId) { - removeInviteInfo(inviteSessionType, deviceId, channelId, null); - } - - @Override - public void removeInviteInfo(InviteInfo inviteInfo) { - removeInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), inviteInfo.getChannelId(), inviteInfo.getStream()); - } - - @Override - public void once(InviteSessionType type, String deviceId, String channelId, String stream, ErrorCallback callback) { - String key = buildKey(type, deviceId, channelId, stream); - List> callbacks = inviteErrorCallbackMap.get(key); - if (callbacks == null) { - callbacks = new CopyOnWriteArrayList<>(); - inviteErrorCallbackMap.put(key, callbacks); - } - callbacks.add(callback); - - } - - private String buildKey(InviteSessionType type, String deviceId, String channelId, String stream) { - String key = type + ":" + deviceId + ":" + channelId; - // 如果ssrc未null那么可以实现一个通道只能一次操作,ssrc不为null则可以支持一个通道多次invite - if (stream != null) { - key += (":" + stream); - } - return key; - } - - - @Override - public void clearInviteInfo(String deviceId) { - removeInviteInfo(null, deviceId, null, null); - } - - @Override - public int getStreamInfoCount(String mediaServerId) { - int count = 0; - String key = VideoManagerConstants.INVITE_PREFIX + ":*:*:*:*:*"; - List scanResult = RedisUtil.scan(redisTemplate, key); - if (scanResult.size() == 0) { - return 0; - }else { - for (Object keyObj : scanResult) { - String keyStr = (String) keyObj; - InviteInfo inviteInfo = (InviteInfo) redisTemplate.opsForValue().get(keyStr); - if (inviteInfo != null && inviteInfo.getStreamInfo() != null && inviteInfo.getStreamInfo().getMediaServerId().equals(mediaServerId)) { - count++; - } - } - } - return count; - } - - @Override - public void call(InviteSessionType type, String deviceId, String channelId, String stream, int code, String msg, Object data) { - String key = buildSubStreamKey(type, deviceId, channelId, stream); - List> callbacks = inviteErrorCallbackMap.get(key); - if (callbacks == null) { - return; - } - for (ErrorCallback callback : callbacks) { - callback.run(code, msg, data); - } - inviteErrorCallbackMap.remove(key); - } - - - private String buildSubStreamKey(InviteSessionType type, String deviceId, String channelId, String stream) { - String key = type + ":" + ":" + deviceId + ":" + channelId; - // 如果ssrc为null那么可以实现一个通道只能一次操作,ssrc不为null则可以支持一个通道多次invite - if (stream != null) { - key += (":" + stream); - } - return key; - } - - @Override - public InviteInfo getInviteInfoBySSRC(String ssrc) { - String key = VideoManagerConstants.INVITE_PREFIX + ":*:*:*:*:" + ssrc; - List scanResult = RedisUtil.scan(redisTemplate, key); - if (scanResult.size() != 1) { - return null; - } - - return (InviteInfo) redisTemplate.opsForValue().get(scanResult.get(0)); - } - - @Override - public InviteInfo updateInviteInfoForSSRC(InviteInfo inviteInfo, String ssrc) { - InviteInfo inviteInfoInDb = getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId(), inviteInfo.getChannelId(), inviteInfo.getStream()); - if (inviteInfoInDb == null) { - return null; - } - removeInviteInfo(inviteInfoInDb); - String key = VideoManagerConstants.INVITE_PREFIX + - ":" + inviteInfo.getType() + - ":" + inviteInfo.getDeviceId() + - ":" + inviteInfo.getChannelId() + - ":" + inviteInfo.getStream() + - ":" + ssrc; - if (inviteInfoInDb.getSsrcInfo() != null) { - inviteInfoInDb.getSsrcInfo().setSsrc(ssrc); - } - redisTemplate.opsForValue().set(key, inviteInfoInDb); - return inviteInfoInDb; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java deleted file mode 100644 index bcf2b8ed..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ /dev/null @@ -1,863 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.genersoft.iot.vmp.common.CommonCallback; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.MediaConfig; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; -import com.genersoft.iot.vmp.media.zlm.*; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.bean.MediaServerLoad; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.dao.MediaServerItemMapper; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.utils.JsonUtil; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.RecordFile; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import okhttp3.Response; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.scheduling.annotation.Async; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.util.Assert; -import org.springframework.util.ObjectUtils; - -import java.io.File; -import java.time.LocalDateTime; -import java.util.*; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -/** - * 媒体服务器节点管理 - */ -@Service -public class MediaServerServiceImpl implements IMediaServerService { - - private final static Logger logger = LoggerFactory.getLogger(MediaServerServiceImpl.class); - - private final String zlmKeepaliveKeyPrefix = "zlm-keepalive_"; - - @Autowired - private SipConfig sipConfig; - - @Autowired - private MediaConfig mediaConfig; - - @Autowired - private SSRCFactory ssrcFactory; - - @Value("${server.ssl.enabled:false}") - private boolean sslEnabled; - - @Value("${server.port}") - private Integer serverPort; - - @Autowired - private UserSetting userSetting; - - @Autowired - private SendRtpPortManager sendRtpPortManager; - - @Autowired - private AssistRESTfulUtils assistRESTfulUtils; - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private MediaServerItemMapper mediaServerMapper; - - @Autowired - private DataSourceTransactionManager dataSourceTransactionManager; - - @Autowired - private TransactionDefinition transactionDefinition; - - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private EventPublisher publisher; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private RedisTemplate redisTemplate; - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - - - /** - * 初始化 - */ - @Override - public void updateVmServer(List mediaServerItemList) { - logger.info("[zlm] 缓存初始化 "); - for (MediaServerItem mediaServerItem : mediaServerItemList) { - if (ObjectUtils.isEmpty(mediaServerItem.getId())) { - continue; - } - // 更新 - if (!ssrcFactory.hasMediaServerSSRC(mediaServerItem.getId())) { - ssrcFactory.initMediaServerSSRC(mediaServerItem.getId(), null); - } - // 查询redis是否存在此mediaServer - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId(); - Boolean hasKey = redisTemplate.hasKey(key); - if (hasKey != null && ! hasKey) { - redisTemplate.opsForValue().set(key, mediaServerItem); - } - } - } - - - @Override - public SSRCInfo openRTPServer(MediaServerItem mediaServerItem, String streamId, String presetSsrc, boolean ssrcCheck, - boolean isPlayback, Integer port, Boolean reUsePort, Integer tcpMode) { - if (mediaServerItem == null || mediaServerItem.getId() == null) { - logger.info("[openRTPServer] 失败, mediaServerItem == null || mediaServerItem.getId() == null"); - return null; - } - // 获取mediaServer可用的ssrc - String ssrc; - if (presetSsrc != null) { - ssrc = presetSsrc; - }else { - if (isPlayback) { - ssrc = ssrcFactory.getPlayBackSsrc(mediaServerItem.getId()); - }else { - ssrc = ssrcFactory.getPlaySsrc(mediaServerItem.getId()); - } - } - - if (streamId == null) { - streamId = String.format("%08x", Long.parseLong(ssrc)).toUpperCase(); - } - if (ssrcCheck && tcpMode > 0) { - // 目前zlm不支持 tcp模式更新ssrc,暂时关闭ssrc校验 - logger.warn("[openRTPServer] 平台对接时下级可能自定义ssrc,但是tcp模式zlm收流目前无法更新ssrc,可能收流超时,此时请使用udp收流或者关闭ssrc校验"); - } - int rtpServerPort; - if (mediaServerItem.isRtpEnable()) { - rtpServerPort = zlmServerFactory.createRTPServer(mediaServerItem, streamId, ssrcCheck ? Long.parseLong(ssrc) : 0, port, reUsePort, tcpMode); - } else { - rtpServerPort = mediaServerItem.getRtpProxyPort(); - } - return new SSRCInfo(rtpServerPort, ssrc, streamId); - } - - @Override - public void closeRTPServer(MediaServerItem mediaServerItem, String streamId) { - if (mediaServerItem == null) { - return; - } - zlmServerFactory.closeRtpServer(mediaServerItem, streamId); - } - - @Override - public void closeRTPServer(MediaServerItem mediaServerItem, String streamId, CommonCallback callback) { - if (mediaServerItem == null) { - callback.run(false); - return; - } - zlmServerFactory.closeRtpServer(mediaServerItem, streamId, callback); - } - - @Override - public void closeRTPServer(String mediaServerId, String streamId) { - MediaServerItem mediaServerItem = this.getOne(mediaServerId); - if (mediaServerItem.isRtpEnable()) { - closeRTPServer(mediaServerItem, streamId); - } - zlmresTfulUtils.closeStreams(mediaServerItem, "rtp", streamId); - } - - @Override - public Boolean updateRtpServerSSRC(MediaServerItem mediaServerItem, String streamId, String ssrc) { - return zlmServerFactory.updateRtpServerSSRC(mediaServerItem, streamId, ssrc); - } - - @Override - public void releaseSsrc(String mediaServerItemId, String ssrc) { - MediaServerItem mediaServerItem = getOne(mediaServerItemId); - if (mediaServerItem == null || ssrc == null) { - return; - } - ssrcFactory.releaseSsrc(mediaServerItemId, ssrc); - } - - /** - * zlm 重启后重置他的推流信息, TODO 给正在使用的设备发送停止命令 - */ - @Override - public void clearRTPServer(MediaServerItem mediaServerItem) { - ssrcFactory.reset(mediaServerItem.getId()); - - } - - - @Override - public void update(MediaServerItem mediaSerItem) { - mediaServerMapper.updateById(mediaSerItem); - MediaServerItem mediaServerItemInRedis = getOne(mediaSerItem.getId()); - MediaServerItem mediaServerItemInDataBase = mediaServerMapper.selectById(mediaSerItem.getId()); - if (mediaServerItemInRedis == null || !ssrcFactory.hasMediaServerSSRC(mediaSerItem.getId())) { - ssrcFactory.initMediaServerSSRC(mediaServerItemInDataBase.getId(),null); - } - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItemInDataBase.getId(); - redisTemplate.opsForValue().set(key, mediaServerItemInDataBase); - } - - @Override - public List getAll() { - List result = new ArrayList<>(); - List mediaServerKeys = RedisUtil.scan(redisTemplate, String.format("%S*", VideoManagerConstants.MEDIA_SERVER_PREFIX+ userSetting.getServerId() + "_" )); - String onlineKey = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); - for (Object mediaServerKey : mediaServerKeys) { - String key = (String) mediaServerKey; - MediaServerItem mediaServerItem = JsonUtil.redisJsonToObject(redisTemplate, key, MediaServerItem.class); - if (Objects.isNull(mediaServerItem)) { - continue; - } - // 检查状态 - Double aDouble = redisTemplate.opsForZSet().score(onlineKey, mediaServerItem.getId()); - if (aDouble != null) { - mediaServerItem.setStatus(true); - } - result.add(mediaServerItem); - } - result.sort((serverItem1, serverItem2)->{ - int sortResult = 0; - LocalDateTime localDateTime1 = LocalDateTime.parse(serverItem1.getCreateTime(), DateUtil.formatter); - LocalDateTime localDateTime2 = LocalDateTime.parse(serverItem2.getCreateTime(), DateUtil.formatter); - - sortResult = localDateTime1.compareTo(localDateTime2); - return sortResult; - }); - return result; - } - - - @Override - public List getAllFromDatabase() { - return mediaServerMapper.selectList(Wrappers.emptyWrapper()); - } - - @Override - public List getAllOnline() { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); - Set mediaServerIdSet = redisTemplate.opsForZSet().reverseRange(key, 0, -1); - - List result = new ArrayList<>(); - if (mediaServerIdSet != null && mediaServerIdSet.size() > 0) { - for (Object mediaServerId : mediaServerIdSet) { - String mediaServerIdStr = (String) mediaServerId; - String serverKey = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerIdStr; - result.add((MediaServerItem) redisTemplate.opsForValue().get(serverKey)); - } - } - Collections.reverse(result); - return result; - } - - /** - * 获取单个zlm服务器 - * @param mediaServerId 服务id - * @return MediaServerItem - */ - @Override - public MediaServerItem getOne(String mediaServerId) { - if (mediaServerId == null) { - return null; - } - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerId; - return JsonUtil.redisJsonToObject(redisTemplate, key, MediaServerItem.class); - } - - @Override - public MediaServerItem getDefaultMediaServer() { - return mediaServerMapper.selectOne(Wrappers.lambdaQuery().eq(MediaServerItem::isDefaultServer, true)); - } - - @Override - public void clearMediaServerForOnline() { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); - redisTemplate.delete(key); - } - - @Override - public void add(MediaServerItem mediaServerItem) { - mediaServerItem.setCreateTime(DateUtil.getNow()); - mediaServerItem.setUpdateTime(DateUtil.getNow()); - mediaServerItem.setHookAliveInterval(30f); - JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); - if (responseJSON != null) { - JSONArray data = responseJSON.getJSONArray("data"); - if (data != null && data.size() > 0) { - ZLMServerConfig zlmServerConfig= JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); - if (mediaServerMapper.selectById(zlmServerConfig.getGeneralMediaServerId()) != null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"保存失败,媒体服务ID [ " + zlmServerConfig.getGeneralMediaServerId() + " ] 已存在,请修改媒体服务器配置"); - } - mediaServerItem.setId(zlmServerConfig.getGeneralMediaServerId()); - zlmServerConfig.setIp(mediaServerItem.getIp()); - mediaServerMapper.insert(mediaServerItem); - zlmServerOnline(zlmServerConfig); - }else { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"连接失败"); - } - - }else { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"连接失败"); - } - } - - @Override - public int addToDatabase(MediaServerItem mediaSerItem) { - return mediaServerMapper.insert(mediaSerItem); - } - - @Override - public int updateToDatabase(MediaServerItem mediaSerItem) { - int result = 0; - if (mediaSerItem.isDefaultServer()) { - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - int delResult = mediaServerMapper.delete(Wrappers.lambdaQuery() - .eq(MediaServerItem::isDefaultServer, true)); - if (delResult == 0) { - logger.error("移除数据库默认zlm节点失败"); - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return 0; - } - result = mediaServerMapper.insert(mediaSerItem); - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - }else { - result = mediaServerMapper.updateById(mediaSerItem); - } - return result; - } - - /** - * 处理zlm上线 - * @param zlmServerConfig zlm上线携带的参数 - */ - @Override - public void zlmServerOnline(ZLMServerConfig zlmServerConfig) { - - MediaServerItem serverItem = mediaServerMapper.selectById(zlmServerConfig.getGeneralMediaServerId()); - if (serverItem == null) { - logger.warn("[未注册的zlm] 拒接接入:{}来自{}:{}", zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(),zlmServerConfig.getHttpPort() ); - logger.warn("请检查ZLM的配置是否与WVP的一致"); - return; - }else { - logger.info("[ZLM] 正在连接 : {} -> {}:{}", - zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(), zlmServerConfig.getHttpPort()); - } - serverItem.setHookAliveInterval(zlmServerConfig.getHookAliveInterval()); - if (serverItem.getHttpPort() == 0) { - serverItem.setHttpPort(zlmServerConfig.getHttpPort()); - } - if (serverItem.getHttpSSlPort() == 0) { - serverItem.setHttpSSlPort(zlmServerConfig.getHttpSSLport()); - } - if (serverItem.getRtmpPort() == 0) { - serverItem.setRtmpPort(zlmServerConfig.getRtmpPort()); - } - if (serverItem.getRtmpSSlPort() == 0) { - serverItem.setRtmpSSlPort(zlmServerConfig.getRtmpSslPort()); - } - if (serverItem.getRtspPort() == 0) { - serverItem.setRtspPort(zlmServerConfig.getRtspPort()); - } - if (serverItem.getRtspSSLPort() == 0) { - serverItem.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); - } - if (serverItem.getRtpProxyPort() == 0) { - serverItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); - } - serverItem.setStatus(true); - - if (ObjectUtils.isEmpty(serverItem.getId())) { - logger.warn("[未注册的zlm] serverItem缺少ID, 无法接入:{}:{}", zlmServerConfig.getIp(),zlmServerConfig.getHttpPort() ); - return; - } - mediaServerMapper.updateById(serverItem); - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + zlmServerConfig.getGeneralMediaServerId(); - if (!ssrcFactory.hasMediaServerSSRC(serverItem.getId())) { - ssrcFactory.initMediaServerSSRC(zlmServerConfig.getGeneralMediaServerId(), null); - } - redisTemplate.opsForValue().set(key, serverItem); - resetOnlineServerItem(serverItem); - - - if (serverItem.isAutoConfig()) { - // 查看assist服务的录像路径配置 - if (serverItem.getRecordAssistPort() > 0 && userSetting.getRecordPath() == null) { - JSONObject info = assistRESTfulUtils.getInfo(serverItem, null); - if (info != null && info.getInteger("code") != null && info.getInteger("code") == 0 ) { - JSONObject dataJson = info.getJSONObject("data"); - if (dataJson != null) { - String recordPath = dataJson.getString("record"); - userSetting.setRecordPath(recordPath); - } - } - } - setZLMConfig(serverItem, "0".equals(zlmServerConfig.getHookEnable())); - } - final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + serverItem.getId(); - dynamicTask.stop(zlmKeepaliveKey); - dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(serverItem), (serverItem.getHookAliveInterval().intValue() + 5) * 1000); - publisher.zlmOnlineEventPublish(serverItem.getId()); - - logger.info("[ZLM] 连接成功 {} - {}:{} ", - zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(), zlmServerConfig.getHttpPort()); - } - - class KeepAliveTimeoutRunnable implements Runnable{ - - private MediaServerItem serverItem; - - public KeepAliveTimeoutRunnable(MediaServerItem serverItem) { - this.serverItem = serverItem; - } - - @Override - public void run() { - logger.info("[zlm心跳到期]:" + serverItem.getId()); - // 发起http请求验证zlm是否确实无法连接,如果确实无法连接则发送离线事件,否则不作处理 - JSONObject mediaServerConfig = zlmresTfulUtils.getMediaServerConfig(serverItem); - if (mediaServerConfig != null && mediaServerConfig.getInteger("code") == 0) { - logger.info("[zlm心跳到期]:{}验证后zlm仍在线,恢复心跳信息,请检查zlm是否可以正常向wvp发送心跳", serverItem.getId()); - // 添加zlm信息 - updateMediaServerKeepalive(serverItem.getId(), null); - }else { - publisher.zlmOfflineEventPublish(serverItem.getId()); - } - } - } - - - @Override - public void zlmServerOffline(String mediaServerId) { - delete(mediaServerId); - final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + mediaServerId; - dynamicTask.stop(zlmKeepaliveKey); - } - - @Override - public void resetOnlineServerItem(MediaServerItem serverItem) { - // 更新缓存 - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); - // 使用zset的分数作为当前并发量, 默认值设置为0 - if (redisTemplate.opsForZSet().score(key, serverItem.getId()) == null) { // 不存在则设置默认值 已存在则重置 - redisTemplate.opsForZSet().add(key, serverItem.getId(), 0L); - // 查询服务流数量 - zlmresTfulUtils.getMediaList(serverItem, null, null, "rtsp",(mediaList ->{ - Integer code = mediaList.getInteger("code"); - if (code == 0) { - JSONArray data = mediaList.getJSONArray("data"); - if (data != null) { - redisTemplate.opsForZSet().add(key, serverItem.getId(), data.size()); - } - } - })); - }else { - clearRTPServer(serverItem); - } - } - - - @Override - public void addCount(String mediaServerId) { - if (mediaServerId == null) { - return; - } - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); - redisTemplate.opsForZSet().incrementScore(key, mediaServerId, 1); - - } - - @Override - public void removeCount(String mediaServerId) { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); - redisTemplate.opsForZSet().incrementScore(key, mediaServerId, - 1); - } - - /** - * 获取负载最低的节点 - * @return MediaServerItem - */ - @Override - public MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist) { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); - Long size = redisTemplate.opsForZSet().zCard(key); - if (size == null || size == 0) { - logger.info("获取负载最低的节点时无在线节点"); - return null; - } - - // 获取分数最低的,及并发最低的 - Set objects = redisTemplate.opsForZSet().range(key, 0, -1); - ArrayList mediaServerObjectS = new ArrayList<>(objects); - MediaServerItem mediaServerItem = null; - if (hasAssist == null) { - String mediaServerId = (String)mediaServerObjectS.get(0); - mediaServerItem = getOne(mediaServerId); - }else if (hasAssist) { - for (Object mediaServerObject : mediaServerObjectS) { - String mediaServerId = (String)mediaServerObject; - MediaServerItem serverItem = getOne(mediaServerId); - if (serverItem.getRecordAssistPort() > 0) { - mediaServerItem = serverItem; - break; - } - } - }else if (!hasAssist) { - for (Object mediaServerObject : mediaServerObjectS) { - String mediaServerId = (String)mediaServerObject; - MediaServerItem serverItem = getOne(mediaServerId); - if (serverItem.getRecordAssistPort() == 0) { - mediaServerItem = serverItem; - break; - } - } - } - - return mediaServerItem; - } - - /** - * 对zlm服务器进行基础配置 - * @param mediaServerItem 服务ID - * @param restart 是否重启zlm - */ - @Override - public void setZLMConfig(MediaServerItem mediaServerItem, boolean restart) { - logger.info("[ZLM] 正在设置 :{} -> {}:{}", - mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort()); - String protocol = sslEnabled ? "https" : "http"; - String hookPrex = String.format("%s://%s:%s/%s", protocol, mediaServerItem.getHookIp(), serverPort, mediaConfig.getHookPrefix()); - - Map param = new HashMap<>(); - param.put("api.secret",mediaServerItem.getSecret()); // -profile:v Baseline - if (mediaServerItem.getRtspPort() != 0) { - param.put("ffmpeg.snap", "%s -rtsp_transport tcp -i %s -y -f mjpeg -frames:v 1 %s"); - } - param.put("hook.enable","1"); - param.put("hook.on_flow_report",""); - param.put("hook.on_play",String.format("%s/on_play", hookPrex)); - param.put("hook.on_http_access",""); - param.put("hook.on_publish", String.format("%s/on_publish", hookPrex)); - param.put("hook.on_record_ts",""); - param.put("hook.on_rtsp_auth",""); - param.put("hook.on_rtsp_realm",""); - param.put("hook.on_server_started",String.format("%s/on_server_started", hookPrex)); - param.put("hook.on_shell_login",""); - param.put("hook.on_stream_changed",String.format("%s/on_stream_changed", hookPrex)); - param.put("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrex)); - param.put("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrex)); - param.put("hook.on_server_keepalive",String.format("%s/on_server_keepalive", hookPrex)); - param.put("hook.on_send_rtp_stopped",String.format("%s/on_send_rtp_stopped", hookPrex)); - param.put("hook.on_rtp_server_timeout",String.format("%s/on_rtp_server_timeout", hookPrex)); - if (mediaServerItem.getRecordAssistPort() > 0) { - param.put("hook.on_record_mp4",String.format("http://127.0.0.1:%s/gbs/record/on_record_mp4", mediaServerItem.getRecordAssistPort())); - }else { - param.put("hook.on_record_mp4",""); - } - param.put("hook.timeoutSec","20"); - // 推流断开后可以在超时时间内重新连接上继续推流,这样播放器会接着播放。 - // 置0关闭此特性(推流断开会导致立即断开播放器) - // 此参数不应大于播放器超时时间 - // 优化此消息以更快的收到流注销事件 - param.put("protocol.continue_push_ms", "3000" ); - // 最多等待未初始化的Track时间,单位毫秒,超时之后会忽略未初始化的Track, 设置此选项优化那些音频错误的不规范流, - // 等zlm支持给每个rtpServer设置关闭音频的时候可以不设置此选项 -// param.put("general.wait_track_ready_ms", "3000" ); - if (mediaServerItem.isRtpEnable() && !ObjectUtils.isEmpty(mediaServerItem.getRtpPortRange())) { - param.put("rtp_proxy.port_range", mediaServerItem.getRtpPortRange().replace(",", "-")); - } - - if (userSetting.getRecordPath() != null) { - File recordPathFile = new File(userSetting.getRecordPath()); - File mp4SavePathFile = recordPathFile.getParentFile().getAbsoluteFile(); - param.put("protocol.mp4_save_path", mp4SavePathFile.getAbsoluteFile()); - param.put("record.appName", recordPathFile.getName()); - } - - JSONObject responseJSON = zlmresTfulUtils.setServerConfig(mediaServerItem, param); - - if (responseJSON != null && responseJSON.getInteger("code") == 0) { - if (restart) { - logger.info("[ZLM] 设置成功,开始重启以保证配置生效 {} -> {}:{}", - mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort()); - zlmresTfulUtils.restartServer(mediaServerItem); - }else { - logger.info("[ZLM] 设置成功 {} -> {}:{}", - mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort()); - } - - - }else { - logger.info("[ZLM] 设置zlm失败 {} -> {}:{}", - mediaServerItem.getId(), mediaServerItem.getIp(), mediaServerItem.getHttpPort()); - } - - - } - - - @Override - public MediaServerItem checkMediaServer(String ip, int port, String secret) { - if (this.getByHostAndPort(ip, port) != null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "此连接已存在"); - } - MediaServerItem mediaServerItem = new MediaServerItem(); - mediaServerItem.setIp(ip); - mediaServerItem.setHttpPort(port); - mediaServerItem.setSecret(secret); - JSONObject responseJSON = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); - if (responseJSON == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "连接失败"); - } - JSONArray data = responseJSON.getJSONArray("data"); - ZLMServerConfig zlmServerConfig = JSON.parseObject(JSON.toJSONString(data.get(0)), ZLMServerConfig.class); - if (zlmServerConfig == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "读取配置失败"); - } - if (mediaServerMapper.selectById(zlmServerConfig.getGeneralMediaServerId()) != null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "媒体服务ID [" + zlmServerConfig.getGeneralMediaServerId() + " ] 已存在,请修改媒体服务器配置"); - } - mediaServerItem.setHttpSSlPort(zlmServerConfig.getHttpPort()); - mediaServerItem.setRtmpPort(zlmServerConfig.getRtmpPort()); - mediaServerItem.setRtmpSSlPort(zlmServerConfig.getRtmpSslPort()); - mediaServerItem.setRtspPort(zlmServerConfig.getRtspPort()); - mediaServerItem.setRtspSSLPort(zlmServerConfig.getRtspSSlport()); - mediaServerItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort()); - mediaServerItem.setStreamIp(ip); - mediaServerItem.setHookIp(sipConfig.getIp().split(",")[0]); - mediaServerItem.setSdpIp(ip); - return mediaServerItem; - } - - @Override - public boolean checkMediaRecordServer(String ip, int port) { - boolean result = false; - OkHttpClient client = new OkHttpClient(); - String url = String.format("http://%s:%s/index/api/record", ip, port); - Request request = new Request.Builder() - .get() - .url(url) - .build(); - try { - Response response = client.newCall(request).execute(); - if (response != null) { - result = true; - } - } catch (Exception e) {} - - return result; - } - - @Override - public void delete(String id) { - redisTemplate.opsForZSet().remove(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), id); - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + id; - redisTemplate.delete(key); - } - @Override - public void deleteDb(String id){ - //同步删除数据库中的数据 - mediaServerMapper.deleteById(id); - } - - @Override - public void updateMediaServerKeepalive(String mediaServerId, ServerKeepaliveData data) { - MediaServerItem mediaServerItem = getOne(mediaServerId); - if (mediaServerItem == null) { - // 缓存不存在,从数据库查询,如果数据库不存在则是错误的 - mediaServerItem = getOneFromDatabase(mediaServerId); - if (mediaServerItem == null) { - logger.warn("[更新ZLM 保活信息] 流媒体{}尚未加入使用,请检查节点中是否含有此流媒体 ", mediaServerId); - return; - } - // zlm连接重试 - logger.warn("[更新ZLM 保活信息]尝试链接zml id {}", mediaServerId); - ssrcFactory.initMediaServerSSRC(mediaServerItem.getId(), null); - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId(); - redisTemplate.opsForValue().set(key, mediaServerItem); - clearRTPServer(mediaServerItem); - } - final String zlmKeepaliveKey = zlmKeepaliveKeyPrefix + mediaServerItem.getId(); - dynamicTask.stop(zlmKeepaliveKey); - dynamicTask.startDelay(zlmKeepaliveKey, new KeepAliveTimeoutRunnable(mediaServerItem), (mediaServerItem.getHookAliveInterval().intValue() + 5) * 1000); - } - - private MediaServerItem getOneFromDatabase(String mediaServerId) { - return mediaServerMapper.selectById(mediaServerId); - } - - @Override - public void syncCatchFromDatabase() { - List allInCatch = getAll(); - List allInDatabase = mediaServerMapper.selectList(Wrappers.emptyWrapper()); - Map mediaServerItemMap = new HashMap<>(); - - for (MediaServerItem mediaServerItem : allInDatabase) { - mediaServerItemMap.put(mediaServerItem.getId(), mediaServerItem); - } - for (MediaServerItem mediaServerItem : allInCatch) { - if (!mediaServerItemMap.containsKey(mediaServerItem.getId())) { - delete(mediaServerItem.getId()); - } - } - } - - @Override - public boolean checkRtpServer(MediaServerItem mediaServerItem, String app, String stream) { - JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, stream); - if(rtpInfo.getInteger("code") == 0){ - return rtpInfo.getBoolean("exist"); - } - return false; - } - - @Override - public MediaServerLoad getLoad(MediaServerItem mediaServerItem) { - MediaServerLoad result = new MediaServerLoad(); - result.setId(mediaServerItem.getId()); - result.setPush(redisCatchStorage.getPushStreamCount(mediaServerItem.getId())); - result.setProxy(redisCatchStorage.getProxyStreamCount(mediaServerItem.getId())); - - result.setGbReceive(inviteStreamService.getStreamInfoCount(mediaServerItem.getId())); - result.setGbSend(redisCatchStorage.getGbSendCount(mediaServerItem.getId())); - return result; - } - - @Override - public List getRecords(String app, String stream, String startTime, String endTime, List mediaServerItems) { - Assert.notNull(app, "app不存在"); - Assert.notNull(stream, "stream不存在"); - Assert.notNull(startTime, "startTime不存在"); - Assert.notNull(endTime, "endTime不存在"); - Assert.notEmpty(mediaServerItems, "流媒体列表为空"); - - CompletableFuture[] completableFutures = new CompletableFuture[mediaServerItems.size()]; - for (int i = 0; i < mediaServerItems.size(); i++) { - completableFutures[i] = getRecordFilesForOne(app, stream, startTime, endTime, mediaServerItems.get(i)); - } - List result = new ArrayList<>(); - for (int i = 0; i < completableFutures.length; i++) { - try { - List list = (List) completableFutures[i].get(); - if (!list.isEmpty()) { - for (int g = 0; g < list.size(); g++) { - list.get(g).setMediaServerId(mediaServerItems.get(i).getId()); - } - result.addAll(list); - } - } catch (InterruptedException e) { - throw new RuntimeException(e); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } - } - Comparator comparator = Comparator.comparing(RecordFile::getFileName); - result.sort(comparator); - return result; - } - - @Override - public List getRecordDates(String app, String stream, int year, int month, List mediaServerItems) { - Assert.notNull(app, "app不存在"); - Assert.notNull(stream, "stream不存在"); - Assert.notEmpty(mediaServerItems, "流媒体列表为空"); - CompletableFuture[] completableFutures = new CompletableFuture[mediaServerItems.size()]; - - for (int i = 0; i < mediaServerItems.size(); i++) { - completableFutures[i] = getRecordDatesForOne(app, stream, year, month, mediaServerItems.get(i)); - } - List result = new ArrayList<>(); - CompletableFuture.allOf(completableFutures).join(); - for (CompletableFuture completableFuture : completableFutures) { - try { - List list = (List) completableFuture.get(); - result.addAll(list); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } catch (ExecutionException e) { - throw new RuntimeException(e); - } - } - Collections.sort(result); - return result; - } - - @Async - public CompletableFuture> getRecordDatesForOne(String app, String stream, int year, int month, MediaServerItem mediaServerItem) { - JSONObject fileListJson = assistRESTfulUtils.getDateList(mediaServerItem, app, stream, year, month); - if (fileListJson != null && !fileListJson.isEmpty()) { - if (fileListJson.getString("code") != null && fileListJson.getInteger("code") == 0) { - JSONArray data = fileListJson.getJSONArray("data"); - return CompletableFuture.completedFuture(data.toJavaList(String.class)); - } - } - return CompletableFuture.completedFuture(new ArrayList<>()); - } - - @Async - public CompletableFuture> getRecordFilesForOne(String app, String stream, String startTime, String endTime, MediaServerItem mediaServerItem) { - JSONObject fileListJson = assistRESTfulUtils.getFileList(mediaServerItem, 1, 100000000, app, stream, startTime, endTime); - if (fileListJson != null && !fileListJson.isEmpty()) { - if (fileListJson.getString("code") != null && fileListJson.getInteger("code") == 0) { - JSONObject data = fileListJson.getJSONObject("data"); - JSONArray list = data.getJSONArray("list"); - if (list != null) { - return CompletableFuture.completedFuture(list.toJavaList(RecordFile.class)); - } - } - } - return CompletableFuture.completedFuture(new ArrayList<>()); - } - - @Override - public MediaServerItem getByHostAndPort(String ip, int port) { - return mediaServerMapper.selectOne(Wrappers.lambdaQuery() - .eq(MediaServerItem::getIp, ip) - .eq(MediaServerItem::getHttpPort, port)); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java deleted file mode 100644 index b8241d7a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ /dev/null @@ -1,113 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.common.StreamURL; -import com.genersoft.iot.vmp.conf.MediaConfig; -import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.service.IMediaService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.ObjectUtils; - -import java.net.URL; - -@Service -public class MediaServiceImpl implements IMediaService { - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IMediaServerService mediaServerService; - - - @Autowired - private MediaConfig mediaConfig; - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - - - @Override - public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String callId) { - return getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, null, callId); - } - - @Override - public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId, String addr, boolean authority) { - StreamInfo streamInfo = null; - if (mediaServerId == null) { - mediaServerId = mediaConfig.getId(); - } - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); - if (mediaInfo == null) { - return null; - } - String calld = null; - StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); - if (streamAuthorityInfo != null) { - calld = streamAuthorityInfo.getCallId(); - } - JSONObject mediaList = zlmresTfulUtils.getMediaList(mediaInfo, app, stream); - if (mediaList != null) { - if (mediaList.getInteger("code") == 0) { - JSONArray data = mediaList.getJSONArray("data"); - if (data == null) { - return null; - } - JSONObject mediaJSON = JSON.parseObject(JSON.toJSONString(data.get(0)), JSONObject.class); - JSONArray tracks = mediaJSON.getJSONArray("tracks"); - if (authority) { - streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr, calld); - }else { - streamInfo = getStreamInfoByAppAndStream(mediaInfo, app, stream, tracks, addr,null); - } - } - } - return streamInfo; - } - - - - @Override - public StreamInfo getStreamInfoByAppAndStreamWithCheck(String app, String stream, String mediaServerId, boolean authority) { - return getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, null, authority); - } - - @Override - public StreamInfo getStreamInfoByAppAndStream(MediaServerItem mediaInfo, String app, String stream, Object tracks, String addr, String callId) { - StreamInfo streamInfoResult = new StreamInfo(); - streamInfoResult.setStream(stream); - streamInfoResult.setApp(app); - if (addr == null) { - addr = mediaInfo.getStreamIp(); - } - - streamInfoResult.setIp(addr); - streamInfoResult.setMediaServerId(mediaInfo.getId()); - String callIdParam = ObjectUtils.isEmpty(callId)?"":"?callId=" + callId; - streamInfoResult.setRtmp(addr, mediaInfo.getRtmpPort(),mediaInfo.getRtmpSSlPort(), app, stream, callIdParam); - streamInfoResult.setRtsp(addr, mediaInfo.getRtspPort(),mediaInfo.getRtspSSLPort(), app, stream, callIdParam); - streamInfoResult.setFlv(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); - streamInfoResult.setFmp4(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); - streamInfoResult.setHls(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); - streamInfoResult.setTs(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); - streamInfoResult.setRtc(addr, mediaInfo.getHttpPort(),mediaInfo.getHttpSSlPort(), app, stream, callIdParam); - - streamInfoResult.setTracks(tracks); - return streamInfoResult; - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java deleted file mode 100644 index 434a2e94..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.service.IPlatformChannelService; -import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; -import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; -import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper; -import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.stereotype.Service; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.util.ObjectUtils; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * @author lin - */ -@Service -public class PlatformChannelServiceImpl implements IPlatformChannelService { - - private final static Logger logger = LoggerFactory.getLogger(PlatformChannelServiceImpl.class); - - @Autowired - private PlatformChannelMapper platformChannelMapper; - - @Autowired - TransactionDefinition transactionDefinition; - - @Autowired - DataSourceTransactionManager dataSourceTransactionManager; - - @Autowired - private SubscribeHolder subscribeHolder; - - @Autowired - private IDeviceChannelService deviceChannelService; - - @Autowired - private DeviceChannelMapper deviceChannelMapper; - - @Autowired - private PlatformCatalogMapper catalogManager; - - @Autowired - private ParentPlatformMapper platformMapper; - - @Autowired - EventPublisher eventPublisher; - - @Override - public int updateChannelForGB(String platformId, List channelReduces, String catalogId) { - ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId); - if (platform == null) { - logger.warn("更新级联通道信息时未找到平台{}的信息", platformId); - return 0; - } - Map deviceAndChannels = new HashMap<>(); - for (ChannelReduce channelReduce : channelReduces) { - channelReduce.setCatalogId(catalogId); - deviceAndChannels.put(channelReduce.getId(), channelReduce); - } - List deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); - // 查询当前已经存在的 - List channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces); - if (deviceAndChannelList != null) { - deviceAndChannelList.removeAll(channelIds); - } - for (Integer channelId : channelIds) { - deviceAndChannels.remove(channelId); - } - List channelReducesToAdd = new ArrayList<>(deviceAndChannels.values()); - // 对剩下的数据进行存储 - int allCount = 0; - boolean result = false; - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - int limitCount = 50; - if (channelReducesToAdd.size() > 0) { - if (channelReducesToAdd.size() > limitCount) { - for (int i = 0; i < channelReducesToAdd.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > channelReducesToAdd.size()) { - toIndex = channelReducesToAdd.size(); - } - int count = platformChannelMapper.addChannels(platformId, channelReducesToAdd.subList(i, toIndex)); - result = result || count < 0; - allCount += count; - logger.info("[关联通道]国标通道 平台:{}, 共需关联通道数:{}, 已关联:{}", platformId, channelReducesToAdd.size(), toIndex); - } - }else { - allCount = platformChannelMapper.addChannels(platformId, channelReducesToAdd); - result = result || allCount < 0; - logger.info("[关联通道]国标通道 平台:{}, 关联通道数:{}", platformId, channelReducesToAdd.size()); - } - - if (result) { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - allCount = 0; - }else { - logger.info("[关联通道]国标通道 平台:{}, 正在存入数据库", platformId); - dataSourceTransactionManager.commit(transactionStatus); - - } - SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(platformId); - if (catalogSubscribe != null) { - List deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId, platform); - if (deviceChannelList != null) { - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD); - } - } - logger.info("[关联通道]国标通道 平台:{}, 存入数据库成功", platformId); - } - return allCount; - } - - private List getDeviceChannelListByChannelReduceList(List channelReduces, String catalogId, ParentPlatform platform) { - List deviceChannelList = new ArrayList<>(); - if (channelReduces.size() > 0){ - PlatformCatalog catalog = catalogManager.selectByPlatFormAndCatalogId(platform.getServerGBId(),catalogId); - if (catalog == null && catalogId.equals(platform.getDeviceGBId())) { - for (ChannelReduce channelReduce : channelReduces) { - DeviceChannel deviceChannel = deviceChannelService.getByDeviceIdAndChannelId(channelReduce.getDeviceId(), channelReduce.getChannelId()); - deviceChannel.setParental(0); - deviceChannel.setCivilCode(platform.getServerGBDomain()); - deviceChannelList.add(deviceChannel); - } - return deviceChannelList; - } else if (catalog == null || !catalogId.equals(platform.getDeviceGBId())) { - logger.warn("未查询到目录{}的信息", catalogId); - return null; - } - for (ChannelReduce channelReduce : channelReduces) { - DeviceChannel deviceChannel = deviceChannelService.getByDeviceIdAndChannelId(channelReduce.getDeviceId(), channelReduce.getChannelId()); - deviceChannel.setParental(0); - deviceChannel.setCivilCode(catalog.getCivilCode()); - deviceChannel.setParentId(catalog.getParentId()); - deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId()); - deviceChannelList.add(deviceChannel); - } - } - return deviceChannelList; - } - - @Override - public int delAllChannelForGB(String platformId, String catalogId) { - - int result; - if (platformId == null) { - return 0; - } - ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId); - if (platform == null) { - return 0; - } - if (ObjectUtils.isEmpty(catalogId)) { - catalogId = null; - } - - if ((result = platformChannelMapper.delChannelForGBByCatalogId(platformId, catalogId)) > 0) { - List deviceChannels = platformChannelMapper.queryAllChannelInCatalog(platformId, catalogId); - eventPublisher.catalogEventPublish(platformId, deviceChannels, CatalogEvent.DEL); - } - return result; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java deleted file mode 100644 index b7bb076c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java +++ /dev/null @@ -1,423 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.session.SSRCFactory; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.dao.*; -import com.genersoft.iot.vmp.utils.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; - -/** - * @author lin - */ -@Service -public class PlatformServiceImpl implements IPlatformService { - - private final static String REGISTER_KEY_PREFIX = "platform_register_"; - - private final static String REGISTER_FAIL_AGAIN_KEY_PREFIX = "platform_register_fail_again_"; - private final static String KEEPALIVE_KEY_PREFIX = "platform_keepalive_"; - - private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class); - - @Autowired - private ParentPlatformMapper platformMapper; - - @Autowired - private PlatformCatalogMapper catalogMapper; - - @Autowired - private PlatformChannelMapper platformChannelMapper; - - @Autowired - private PlatformGbStreamMapper platformGbStreamMapper; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private SSRCFactory ssrcFactory; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private SIPCommanderFroPlatform commanderForPlatform; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private SubscribeHolder subscribeHolder; - - @Autowired - private GbStreamMapper gbStreamMapper; - - @Autowired - private UserSetting userSetting; - - - - @Override - public ParentPlatform queryPlatformByServerGBId(String platformGbId) { - return platformMapper.getParentPlatByServerGBId(platformGbId); - } - - @Override - public Page parentPlatformByPage(Page page, ParentPlatform entity) { - return platformMapper.parentPlatformByPage(page, entity); - } - - @Override - public boolean add(ParentPlatform parentPlatform) { - - if (parentPlatform.getCatalogGroup() == 0) { - // 每次发送目录的数量默认为1 - parentPlatform.setCatalogGroup(1); - } - if (parentPlatform.getAdministrativeDivision() == null) { - // 行政区划默认去编号的前6位 - parentPlatform.setAdministrativeDivision(parentPlatform.getServerGBId().substring(0,6)); - } - parentPlatform.setCatalogId(parentPlatform.getDeviceGBId()); - int result = platformMapper.insert(parentPlatform); - // 添加缓存 - ParentPlatformCatch parentPlatformCatch = new ParentPlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - parentPlatformCatch.setParentPlatform(parentPlatform); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - if (parentPlatform.isEnable()) { - // 保存时启用就发送注册 - // 注册成功时由程序直接调用了online方法 - try { - commanderForPlatform.register(parentPlatform, eventResult -> { - logger.info("[国标级联] {},添加向上级注册失败,请确定上级平台可用时重新保存", parentPlatform.getServerGBId()); - }, null); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 国标级联: {}", e.getMessage()); - } - } - return result > 0; - } - - @Override - public boolean update(ParentPlatform parentPlatform) { - logger.info("[国标级联]更新平台 {}", parentPlatform.getDeviceGBId()); - parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase()); - ParentPlatform parentPlatformOld = platformMapper.selectById(parentPlatform.getId()); - ParentPlatformCatch parentPlatformCatchOld = redisCatchStorage.queryPlatformCatchInfo(parentPlatformOld.getServerGBId()); - parentPlatform.setUpdateTime(DateUtil.getNow()); - - // 停止心跳定时 - final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatformOld.getServerGBId(); - dynamicTask.stop(keepaliveTaskKey); - // 停止注册定时 - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatformOld.getServerGBId(); - dynamicTask.stop(registerTaskKey); - // 注销旧的 - try { - if (parentPlatformOld.isStatus()) { - logger.info("保存平台{}时发现旧平台在线,发送注销命令", parentPlatformOld.getServerGBId()); - commanderForPlatform.unregister(parentPlatformOld, parentPlatformCatchOld.getSipTransactionInfo(), null, eventResult -> { - logger.info("[国标级联] 注销成功, 平台:{}", parentPlatformOld.getServerGBId()); - }); - } - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); - } - - // 更新数据库 - if (parentPlatform.getCatalogGroup() == 0) { - parentPlatform.setCatalogGroup(1); - } - if (parentPlatform.getAdministrativeDivision() == null) { - parentPlatform.setAdministrativeDivision(parentPlatform.getAdministrativeDivision()); - } - - platformMapper.updateById(parentPlatform); - - // 更新redis - redisCatchStorage.delPlatformCatchInfo(parentPlatformOld.getServerGBId()); - ParentPlatformCatch parentPlatformCatch = new ParentPlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - // 注册 - if (parentPlatform.isEnable()) { - // 保存时启用就发送注册 - // 注册成功时由程序直接调用了online方法 - try { - logger.info("[国标级联] 平台注册 {}", parentPlatform.getDeviceGBId()); - commanderForPlatform.register(parentPlatform, eventResult -> { - logger.info("[国标级联] {},添加向上级注册失败,请确定上级平台可用时重新保存", parentPlatform.getServerGBId()); - }, null); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 国标级联: {}", e.getMessage()); - } - } - - - return false; - } - - - @Override - public void online(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo) { - logger.info("[国标级联]:{}, 平台上线", parentPlatform.getServerGBId()); - final String registerFailAgainTaskKey = REGISTER_FAIL_AGAIN_KEY_PREFIX + parentPlatform.getServerGBId(); - dynamicTask.stop(registerFailAgainTaskKey); - - platformMapper.updateParentPlatformStatus(parentPlatform.getServerGBId(), true); - ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); - if (parentPlatformCatch == null) { - parentPlatformCatch = new ParentPlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - parentPlatform.setStatus(true); - parentPlatformCatch.setParentPlatform(parentPlatform); - } - - parentPlatformCatch.getParentPlatform().setStatus(true); - parentPlatformCatch.setSipTransactionInfo(sipTransactionInfo); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); - if (!dynamicTask.isAlive(registerTaskKey)) { - logger.info("[国标级联]:{}, 添加定时注册任务", parentPlatform.getServerGBId()); - // 添加注册任务 - dynamicTask.startCron(registerTaskKey, - // 注册失败(注册成功时由程序直接调用了online方法) - ()-> registerTask(parentPlatform, sipTransactionInfo), - parentPlatform.getExpires() * 1000); - } - - - final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId(); - if (!dynamicTask.contains(keepaliveTaskKey)) { - logger.info("[国标级联]:{}, 添加定时心跳任务", parentPlatform.getServerGBId()); - // 添加心跳任务 - dynamicTask.startCron(keepaliveTaskKey, - ()-> { - try { - commanderForPlatform.keepalive(parentPlatform, eventResult -> { - // 心跳失败 - if (eventResult.type != SipSubscribe.EventResultType.timeout) { - logger.warn("[国标级联]发送心跳收到错误,code: {}, msg: {}", eventResult.statusCode, eventResult.msg); - } - // 心跳失败 - ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); - // 此时是第三次心跳超时, 平台离线 - if (platformCatch.getKeepAliveReply() == 2) { - // 设置平台离线,并重新注册 - logger.info("[国标级联] 三次心跳失败, 平台{}({})离线", parentPlatform.getName(), parentPlatform.getServerGBId()); - offline(parentPlatform, false); - }else { - platformCatch.setKeepAliveReply(platformCatch.getKeepAliveReply() + 1); - redisCatchStorage.updatePlatformCatchInfo(platformCatch); - } - - }, eventResult -> { - // 心跳成功 - // 清空之前的心跳超时计数 - ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); - if (platformCatch != null && platformCatch.getKeepAliveReply() > 0) { - platformCatch.setKeepAliveReply(0); - redisCatchStorage.updatePlatformCatchInfo(platformCatch); - } - logger.info("[发送心跳] 国标级联 发送心跳, code: {}, msg: {}", eventResult.statusCode, eventResult.msg); - }); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送心跳: {}", e.getMessage()); - } - }, - (parentPlatform.getKeepTimeout())*1000); - } - if (parentPlatform.isAutoPushChannel()) { - if (subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()) == null) { - addSimulatedSubscribeInfo(parentPlatform); - } - }else { - SubscribeInfo catalogSubscribe = subscribeHolder.getCatalogSubscribe(parentPlatform.getServerGBId()); - if (catalogSubscribe != null && catalogSubscribe.getExpires() == -1) { - subscribeHolder.removeCatalogSubscribe(parentPlatform.getServerGBId()); - } - } - } - - @Override - public void addSimulatedSubscribeInfo(ParentPlatform parentPlatform) { - // 自动添加一条模拟的订阅信息 - SubscribeInfo subscribeInfo = new SubscribeInfo(); - subscribeInfo.setId(parentPlatform.getServerGBId()); - subscribeInfo.setExpires(-1); - subscribeInfo.setEventType("Catalog"); - int random = (int) Math.floor(Math.random() * 10000); - subscribeInfo.setEventId(random + ""); - subscribeInfo.setSimulatedCallId(UUID.randomUUID().toString().replace("-", "") + "@" + parentPlatform.getServerIp()); - subscribeInfo.setSimulatedFromTag(UUID.randomUUID().toString().replace("-", "")); - subscribeInfo.setSimulatedToTag(UUID.randomUUID().toString().replace("-", "")); - subscribeHolder.putCatalogSubscribe(parentPlatform.getServerGBId(), subscribeInfo); - } - - private void registerTask(ParentPlatform parentPlatform, SipTransactionInfo sipTransactionInfo){ - try { - // 不在同一个会话中续订则每次全新注册 - if (!userSetting.isRegisterKeepIntDialog()) { - sipTransactionInfo = null; - } - - if (sipTransactionInfo == null) { - logger.info("[国标级联] 平台:{}注册即将到期,开始重新注册", parentPlatform.getServerGBId()); - }else { - logger.info("[国标级联] 平台:{}注册即将到期,开始续订", parentPlatform.getServerGBId()); - } - - commanderForPlatform.register(parentPlatform, sipTransactionInfo, eventResult -> { - logger.info("[国标级联] 平台:{}注册失败,{}:{}", parentPlatform.getServerGBId(), - eventResult.statusCode, eventResult.msg); - offline(parentPlatform, false); - }, null); - } catch (Exception e) { - logger.error("[命令发送失败] 国标级联定时注册: {}", e.getMessage()); - } - } - - @Override - public void offline(ParentPlatform parentPlatform, boolean stopRegister) { - logger.info("[平台离线]:{}", parentPlatform.getServerGBId()); - ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); - parentPlatformCatch.setKeepAliveReply(0); - parentPlatformCatch.setRegisterAliveReply(0); - ParentPlatform parentPlatformInCatch = parentPlatformCatch.getParentPlatform(); - parentPlatformInCatch.setStatus(false); - parentPlatformCatch.setParentPlatform(parentPlatformInCatch); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - platformMapper.updateParentPlatformStatus(parentPlatform.getServerGBId(), false); - - // 停止所有推流 - logger.info("[平台离线] {}, 停止所有推流", parentPlatform.getServerGBId()); - stopAllPush(parentPlatform.getServerGBId()); - - // 清除注册定时 - logger.info("[平台离线] {}, 停止定时注册任务", parentPlatform.getServerGBId()); - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); - if (dynamicTask.contains(registerTaskKey)) { - dynamicTask.stop(registerTaskKey); - } - // 清除心跳定时 - logger.info("[平台离线] {}, 停止定时发送心跳任务", parentPlatform.getServerGBId()); - final String keepaliveTaskKey = KEEPALIVE_KEY_PREFIX + parentPlatform.getServerGBId(); - if (dynamicTask.contains(keepaliveTaskKey)) { - // 清除心跳任务 - dynamicTask.stop(keepaliveTaskKey); - } - // 停止目录订阅回复 - logger.info("[平台离线] {}, 停止订阅回复", parentPlatform.getServerGBId()); - subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); - // 发起定时自动重新注册 - if (!stopRegister) { - // 设置为60秒自动尝试重新注册 - final String registerFailAgainTaskKey = REGISTER_FAIL_AGAIN_KEY_PREFIX + parentPlatform.getServerGBId(); - ParentPlatform platform = platformMapper.selectById(parentPlatform.getId()); - if (platform.isEnable()) { - dynamicTask.startCron(registerFailAgainTaskKey, - ()-> registerTask(platform, null), - userSetting.getRegisterAgainAfterTime() * 1000); - } - - } - } - - private void stopAllPush(String platformId) { - List sendRtpItems = redisCatchStorage.querySendRTPServer(platformId); - if (sendRtpItems != null && sendRtpItems.size() > 0) { - for (SendRtpItem sendRtpItem : sendRtpItems) { - ssrcFactory.releaseSsrc(sendRtpItem.getMediaServerId(), sendRtpItem.getSsrc()); - redisCatchStorage.deleteSendRTPServer(platformId, sendRtpItem.getChannelId(), null, null); - MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - Map param = new HashMap<>(3); - param.put("vhost", "__defaultVhost__"); - param.put("app", sendRtpItem.getApp()); - param.put("stream", sendRtpItem.getStreamId()); - zlmServerFactory.stopSendRtpStream(mediaInfo, param); - } - } - } - - @Override - public void login(ParentPlatform parentPlatform) { - final String registerTaskKey = REGISTER_KEY_PREFIX + parentPlatform.getServerGBId(); - try { - commanderForPlatform.register(parentPlatform, eventResult1 -> { - logger.info("[国标级联] {},开始定时发起注册,间隔为1分钟", parentPlatform.getServerGBId()); - // 添加注册任务 - dynamicTask.startCron(registerTaskKey, - // 注册失败(注册成功时由程序直接调用了online方法) - ()->logger.info("[国标级联] {},平台离线后持续发起注册,失败", parentPlatform.getServerGBId()), - 60*1000); - }, null); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 国标级联注册: {}", e.getMessage()); - } - } - - @Override - public void sendNotifyMobilePosition(String platformId) { - ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId); - if (platform == null) { - return; - } - SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()); - if (subscribe != null) { - - // TODO 暂时只处理视频流的回复,后续增加对国标设备的支持 - List gbStreams = gbStreamMapper.queryGbStreamListInPlatform(platform.getServerGBId(), userSetting.isUsePushingAsStatus()); - if (gbStreams.size() == 0) { - return; - } - for (DeviceChannel deviceChannel : gbStreams) { - String gbId = deviceChannel.getChannelId(); - GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); - // 无最新位置不发送 - if (gpsMsgInfo != null) { - // 经纬度都为0不发送 - if (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0) { - continue; - } - // 发送GPS消息 - try { - commanderForPlatform.sendNotifyMobilePosition(platform, gpsMsgInfo, subscribe); - } catch (InvalidArgumentException | ParseException | NoSuchFieldException | SipException | - IllegalAccessException e) { - logger.error("[命令发送失败] 国标级联 移动位置通知: {}", e.getMessage()); - } - } - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java deleted file mode 100644 index 7d74d529..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ /dev/null @@ -1,1011 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionStatus; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; -import com.genersoft.iot.vmp.gb28181.utils.SipUtils; -import com.genersoft.iot.vmp.media.zlm.AssistRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.hook.HookParam; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.service.*; -import com.genersoft.iot.vmp.service.bean.ErrorCallback; -import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.iteaj.framework.exception.ServiceException; -import gov.nist.javax.sip.message.SIPResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.util.ObjectUtils; - -import javax.sdp.*; -import javax.sip.InvalidArgumentException; -import javax.sip.ResponseEvent; -import javax.sip.SipException; -import java.io.File; -import java.math.BigDecimal; -import java.math.RoundingMode; -import java.text.ParseException; -import java.util.List; -import java.util.UUID; -import java.util.Vector; - -@SuppressWarnings(value = {"rawtypes", "unchecked"}) -@Service -public class PlayServiceImpl implements IPlayService { - - private final static Logger logger = LoggerFactory.getLogger(PlayServiceImpl.class); - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommander cmder; - - @Autowired - private SIPCommanderFroPlatform sipCommanderFroPlatform; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private AssistRESTfulUtils assistRESTfulUtils; - - @Autowired - private IMediaService mediaService; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private VideoStreamSessionManager streamSession; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private UserSetting userSetting; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private ZlmHttpHookSubscribe subscribe; - - - @Override - public SSRCInfo play(MediaServerItem mediaServerItem, String deviceId, String channelId, String ssrc, ErrorCallback callback) { - if (mediaServerItem == null) { - logger.warn("[点播] 未找到可用的zlm deviceId: {},channelId:{}", deviceId, channelId); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到可用的zlm"); - } - - Device device = redisCatchStorage.getDevice(deviceId); - if (device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE") && !mediaServerItem.isRtpEnable()) { - logger.warn("[点播] 单端口收流时不支持TCP主动方式收流 deviceId: {},channelId:{}", deviceId, channelId); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "单端口收流时不支持TCP主动方式收流"); - } - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - if (inviteInfo != null ) { - if (inviteInfo.getStreamInfo() == null) { - // 点播发起了但是尚未成功, 仅注册回调等待结果即可 - inviteStreamService.once(InviteSessionType.PLAY, deviceId, channelId, null, callback); - logger.info("[点播开始] 已经请求中,等待结果, deviceId: {}, channelId: {}", device.getDeviceId(), channelId); - return inviteInfo.getSsrcInfo(); - }else { - StreamInfo streamInfo = inviteInfo.getStreamInfo(); - String streamId = streamInfo.getStream(); - if (streamId == null) { - callback.run(InviteErrorCode.ERROR_FOR_CATCH_DATA.getCode(), "点播失败, redis缓存streamId等于null", null); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_CATCH_DATA.getCode(), - "点播失败, redis缓存streamId等于null", - null); - return inviteInfo.getSsrcInfo(); - } - String mediaServerId = streamInfo.getMediaServerId(); - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); - - Boolean ready = zlmServerFactory.isStreamReady(mediaInfo, "rtp", streamId); - if (ready != null && ready) { - callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.SUCCESS.getCode(), - InviteErrorCode.SUCCESS.getMsg(), - streamInfo); - logger.info("[点播已存在] 直接返回, deviceId: {}, channelId: {}", device.getDeviceId(), channelId); - return inviteInfo.getSsrcInfo(); - }else { - // 点播发起了但是尚未成功, 仅注册回调等待结果即可 - inviteStreamService.once(InviteSessionType.PLAY, deviceId, channelId, null, callback); - storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); - inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - } - } - } - String streamId = String.format("%s_%s", device.getDeviceId(), channelId);; - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, streamId, ssrc, device.isSsrcCheck(), false, 0, false, device.getStreamModeForParam()); - if (ssrcInfo == null) { - callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getMsg(), null); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), - InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getMsg(), - null); - return null; - } - play(mediaServerItem, ssrcInfo, device, channelId, callback); - return ssrcInfo; - } - - - @Override - public void play(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, Device device, String channelId, - ErrorCallback callback) { - - if (mediaServerItem == null || ssrcInfo == null) { - callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), - InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(), - null); - return; - } - logger.info("[点播开始] deviceId: {}, channelId: {},码流类型:{}, 收流端口: {}, STREAM:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}", - device.getDeviceId(), channelId, device.isSwitchPrimarySubStream() ? "辅码流" : "主码流", ssrcInfo.getPort(), ssrcInfo.getStream(), - device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck()); - //端口获取失败的ssrcInfo 没有必要发送点播指令 - if (ssrcInfo.getPort() <= 0) { - logger.info("[点播端口分配异常],deviceId={},channelId={},ssrcInfo={}", device.getDeviceId(), channelId, ssrcInfo); - // 释放ssrc - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - - callback.run(InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_RESOURCE_EXHAUSTION.getCode(), "点播端口分配异常", null); - return; - } - - // 初始化redis中的invite消息状态 - InviteInfo inviteInfo = InviteInfo.getInviteInfo(device.getDeviceId(), channelId, ssrcInfo.getStream(), ssrcInfo, - mediaServerItem.getSdpIp(), ssrcInfo.getPort(), device.getStreamMode(), InviteSessionType.PLAY, - InviteSessionStatus.ready); - inviteInfo.setSubStream(device.isSwitchPrimarySubStream()); - inviteStreamService.updateInviteInfo(inviteInfo); - // 超时处理 - String timeOutTaskKey = UUID.randomUUID().toString(); - dynamicTask.startDelay(timeOutTaskKey, () -> { - // 执行超时任务时查询是否已经成功,成功了则不执行超时任务,防止超时任务取消失败的情况 - InviteInfo inviteInfoForTimeOut = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channelId); - if (inviteInfoForTimeOut == null || inviteInfoForTimeOut.getStreamInfo() == null) { - logger.info("[点播超时] 收流超时 deviceId: {}, channelId: {},码流类型:{},端口:{}, SSRC: {}", - device.getDeviceId(), channelId, device.isSwitchPrimarySubStream() ? "辅码流" : "主码流", - ssrcInfo.getPort(), ssrcInfo.getSsrc()); - - callback.run(InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_STREAM_TIMEOUT.getMsg(), null); - inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channelId); - - try { - cmder.streamByeCmd(device, channelId, ssrcInfo.getStream(), null); - } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { - logger.error("[点播超时], 发送BYE失败 {}", e.getMessage()); - } finally { - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); - // 取消订阅消息监听 - HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed("rtp", ssrcInfo.getStream(), true, "rtsp", mediaServerItem.getId()); - subscribe.removeSubscribe(hookSubscribe); - } - } else { - logger.info("[点播超时] 收流超时 deviceId: {}, channelId: {},码流类型:{},端口:{}, SSRC: {}", - device.getDeviceId(), channelId, device.isSwitchPrimarySubStream() ? "辅码流" : "主码流", - ssrcInfo.getPort(), ssrcInfo.getSsrc()); - - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - - mediaServerService.closeRTPServer(mediaServerItem.getId(), ssrcInfo.getStream()); - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - } - }, userSetting.getPlayTimeout()); - - try { - cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (mediaServerItemInuse, hookParam ) -> { - logger.info("收到订阅消息: " + hookParam); - dynamicTask.stop(timeOutTaskKey); - // hook响应 - StreamInfo streamInfo = onPublishHandlerForPlay(mediaServerItemInuse, hookParam, device.getDeviceId(), channelId); - if (streamInfo == null){ - callback.run(InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(), - InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(), - InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null); - return; - } - callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.SUCCESS.getCode(), - InviteErrorCode.SUCCESS.getMsg(), - streamInfo); - logger.info("[点播成功] deviceId: {}, channelId:{}, 码流类型:{}", device.getDeviceId(), channelId, - device.isSwitchPrimarySubStream() ? "辅码流" : "主码流"); - snapOnPlay(mediaServerItemInuse, device.getDeviceId(), channelId, ssrcInfo.getStream()); - }, (eventResult) -> { - // 处理收到200ok后的TCP主动连接以及SSRC不一致的问题 - InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId, - timeOutTaskKey, callback, inviteInfo, InviteSessionType.PLAY); - }, (event) -> { - dynamicTask.stop(timeOutTaskKey); - mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); - // 释放ssrc - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - - callback.run(InviteErrorCode.ERROR_FOR_SIGNALLING_ERROR.getCode(), - String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg), null); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_RESET_SSRC.getCode(), - String.format("点播失败, 错误码: %s, %s", event.statusCode, event.msg), null); - - inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channelId); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - - logger.error("[命令发送失败] 点播消息: {}", e.getMessage()); - dynamicTask.stop(timeOutTaskKey); - mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); - // 释放ssrc - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - - callback.run(InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(), - InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getCode(), - InviteErrorCode.ERROR_FOR_SIP_SENDING_FAILED.getMsg(), null); - - inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, device.getDeviceId(), channelId); - } - } - - private void tcpActiveHandler(Device device, String channelId, String contentString, - MediaServerItem mediaServerItem, - String timeOutTaskKey, SSRCInfo ssrcInfo, ErrorCallback callback){ - if (!device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE")) { - return; - } - - String substring; - if (contentString.indexOf("y=") > 0) { - substring = contentString.substring(0, contentString.indexOf("y=")); - }else { - substring = contentString; - } - - try { - SessionDescription sdp = SdpFactory.getInstance().createSessionDescription(substring); - int port = -1; - Vector mediaDescriptions = sdp.getMediaDescriptions(true); - for (Object description : mediaDescriptions) { - MediaDescription mediaDescription = (MediaDescription) description; - Media media = mediaDescription.getMedia(); - - Vector mediaFormats = media.getMediaFormats(false); - if (mediaFormats.contains("96")) { - port = media.getMediaPort(); - break; - } - } - logger.info("[TCP主动连接对方] deviceId: {}, channelId: {}, 连接对方的地址:{}:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}", device.getDeviceId(), channelId, sdp.getConnection().getAddress(), port, device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck()); - JSONObject jsonObject = zlmresTfulUtils.connectRtpServer(mediaServerItem, sdp.getConnection().getAddress(), port, ssrcInfo.getStream()); - logger.info("[TCP主动连接对方] 结果: {}", jsonObject); - } catch (SdpException e) { - logger.error("[TCP主动连接对方] deviceId: {}, channelId: {}, 解析200OK的SDP信息失败", device.getDeviceId(), channelId, e); - dynamicTask.stop(timeOutTaskKey); - mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); - // 释放ssrc - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - - callback.run(InviteErrorCode.ERROR_FOR_SDP_PARSING_EXCEPTIONS.getCode(), - InviteErrorCode.ERROR_FOR_SDP_PARSING_EXCEPTIONS.getMsg(), null); - inviteStreamService.call(InviteSessionType.PLAY, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_SDP_PARSING_EXCEPTIONS.getCode(), - InviteErrorCode.ERROR_FOR_SDP_PARSING_EXCEPTIONS.getMsg(), null); - } - } - - /** - * 点播成功时调用截图. - * - * @param mediaServerItemInuse media - * @param deviceId 设备 ID - * @param channelId 通道 ID - * @param stream ssrc - */ - private void snapOnPlay(MediaServerItem mediaServerItemInuse, String deviceId, String channelId, String stream) { - String streamUrl; - if (mediaServerItemInuse.getRtspPort() != 0) { - streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", stream); - } else { - streamUrl = String.format("http://127.0.0.1:%s/%s/%s.live.mp4", mediaServerItemInuse.getHttpPort(), "rtp", stream); - } - String path = "snap"; - String fileName = deviceId + "_" + channelId + ".jpg"; - // 请求截图 - logger.info("[请求截图]: " + fileName); - zlmresTfulUtils.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); - } - - private StreamInfo onPublishHandlerForPlay(MediaServerItem mediaServerItem, HookParam hookParam, String deviceId, String channelId) { - StreamInfo streamInfo = null; - Device device = redisCatchStorage.getDevice(deviceId); - OnStreamChangedHookParam streamChangedHookParam = (OnStreamChangedHookParam)hookParam; - streamInfo = onPublishHandler(mediaServerItem, streamChangedHookParam, deviceId, channelId); - if (streamInfo != null) { - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); - if (deviceChannel != null) { - deviceChannel.setStreamId(streamInfo.getStream()); - storager.startPlay(deviceId, channelId, streamInfo.getStream()); - } - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - if (inviteInfo != null) { - inviteInfo.setStatus(InviteSessionStatus.ok); - inviteInfo.setStreamInfo(streamInfo); - inviteStreamService.updateInviteInfo(inviteInfo); - } - } - return streamInfo; - - } - - private StreamInfo onPublishHandlerForPlayback(MediaServerItem mediaServerItem, HookParam param, String deviceId, String channelId, String startTime, String endTime) { - OnStreamChangedHookParam streamChangedHookParam = (OnStreamChangedHookParam) param; - StreamInfo streamInfo = onPublishHandler(mediaServerItem, streamChangedHookParam, deviceId, channelId); - if (streamInfo != null) { - streamInfo.setStartTime(startTime); - streamInfo.setEndTime(endTime); - DeviceChannel deviceChannel = storager.queryChannel(deviceId, channelId); - if (deviceChannel != null) { - deviceChannel.setStreamId(streamInfo.getStream()); - storager.startPlay(deviceId, channelId, streamInfo.getStream()); - } - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, ((OnStreamChangedHookParam) param).getStream()); - if (inviteInfo != null) { - inviteInfo.setStatus(InviteSessionStatus.ok); - - inviteInfo.setStreamInfo(streamInfo); - inviteStreamService.updateInviteInfo(inviteInfo); - } - - } - return streamInfo; - } - - @Override - public MediaServerItem getNewMediaServerItem(Device device) { - if (device == null) { - return null; - } - MediaServerItem mediaServerItem; - if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) { - mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null); - } else { - mediaServerItem = mediaServerService.getOne(device.getMediaServerId()); - } - if (mediaServerItem == null) { - logger.warn("点播时未找到可使用的ZLM..."); - } - return mediaServerItem; - } - - @Override - public MediaServerItem getNewMediaServerItemHasAssist(Device device) { - if (device == null) { - return null; - } - MediaServerItem mediaServerItem; - if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) { - mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(true); - } else { - mediaServerItem = mediaServerService.getOne(device.getMediaServerId()); - } - if (mediaServerItem == null) { - logger.warn("[获取可用的ZLM节点]未找到可使用的ZLM..."); - } - return mediaServerItem; - } - - @Override - public void playBack(String deviceId, String channelId, String startTime, - String endTime, ErrorCallback callback) { - Device device = storager.queryVideoDevice(deviceId); - if (device == null) { - logger.warn("[录像回放] 未找到设备 deviceId: {},channelId:{}", deviceId, channelId); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备:" + deviceId); - } - - MediaServerItem newMediaServerItem = getNewMediaServerItem(device); - if (device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE") && ! newMediaServerItem.isRtpEnable()) { - logger.warn("[录像回放] 单端口收流时不支持TCP主动方式收流 deviceId: {},channelId:{}", deviceId, channelId); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "单端口收流时不支持TCP主动方式收流"); - } - String startTimeStr = startTime.replace("-", "") - .replace(":", "") - .replace(" ", ""); - String endTimeTimeStr = endTime.replace("-", "") - .replace(":", "") - .replace(" ", ""); - String stream = deviceId + "_" + channelId + "_" + startTimeStr + "_" + endTimeTimeStr; - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, stream, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam()); - playBack(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, callback); - } - - @Override - public void playBack(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, - String deviceId, String channelId, String startTime, - String endTime, ErrorCallback callback) { - if (mediaServerItem == null || ssrcInfo == null) { - callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), - InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(), - null); - return; - } - - Device device = storager.queryVideoDevice(deviceId); - if (device == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备: " + deviceId + "不存在"); - } - logger.info("[录像回放] deviceId: {}, channelId: {}, 开始时间: {}, 结束时间: {}, 收流端口:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}", - device.getDeviceId(), channelId, startTime, endTime, ssrcInfo.getPort(), device.getStreamMode(), - ssrcInfo.getSsrc(), device.isSsrcCheck()); - // 初始化redis中的invite消息状态 - InviteInfo inviteInfo = InviteInfo.getInviteInfo(device.getDeviceId(), channelId, ssrcInfo.getStream(), ssrcInfo, - mediaServerItem.getSdpIp(), ssrcInfo.getPort(), device.getStreamMode(), InviteSessionType.PLAYBACK, - InviteSessionStatus.ready); - inviteStreamService.updateInviteInfo(inviteInfo); - String playBackTimeOutTaskKey = UUID.randomUUID().toString(); - dynamicTask.startDelay(playBackTimeOutTaskKey, () -> { - logger.warn("[录像回放] 超时,deviceId:{} ,channelId:{}", deviceId, channelId); - inviteStreamService.removeInviteInfo(inviteInfo); - callback.run(InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode(), InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getMsg(), null); - - try { - cmder.streamByeCmd(device, channelId, ssrcInfo.getStream(), null); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[录像回放] 超时 发送BYE失败 {}", e.getMessage()); - } catch (SsrcTransactionNotFoundException e) { - // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); - streamSession.remove(deviceId, channelId, ssrcInfo.getStream()); - } - }, userSetting.getPlayTimeout()); - - SipSubscribe.Event errorEvent = event -> { - logger.info("[录像回放] 失败,{} {}", event.statusCode, event.msg); - dynamicTask.stop(playBackTimeOutTaskKey); - callback.run(InviteErrorCode.ERROR_FOR_SIGNALLING_ERROR.getCode(), - String.format("回放失败, 错误码: %s, %s", event.statusCode, event.msg), null); - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - inviteStreamService.removeInviteInfo(inviteInfo); - }; - - ZlmHttpHookSubscribe.Event hookEvent = (mediaServerItemInuse, hookParam) -> { - logger.info("收到回放订阅消息: " + hookParam); - dynamicTask.stop(playBackTimeOutTaskKey); - StreamInfo streamInfo = onPublishHandlerForPlayback(mediaServerItemInuse, hookParam, deviceId, channelId, startTime, endTime); - if (streamInfo == null) { - logger.warn("设备回放API调用失败!"); - callback.run(InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(), - InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null); - return; - } - callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); - logger.info("[录像回放] 成功 deviceId: {}, channelId: {}, 开始时间: {}, 结束时间: {}", device.getDeviceId(), channelId, startTime, endTime); - }; - - try { - cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, - hookEvent, eventResult -> { - // 处理收到200ok后的TCP主动连接以及SSRC不一致的问题 - InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId, - playBackTimeOutTaskKey, callback, inviteInfo, InviteSessionType.PLAYBACK); - - }, errorEvent); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 录像回放: {}", e.getMessage()); - - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(); - eventResult.type = SipSubscribe.EventResultType.cmdSendFailEvent; - eventResult.statusCode = -1; - eventResult.msg = "命令发送失败"; - errorEvent.response(eventResult); - } - } - - - private void InviteOKHandler(SipSubscribe.EventResult eventResult, SSRCInfo ssrcInfo, MediaServerItem mediaServerItem, - Device device, String channelId, String timeOutTaskKey, ErrorCallback callback, - InviteInfo inviteInfo, InviteSessionType inviteSessionType){ - inviteInfo.setStatus(InviteSessionStatus.ok); - ResponseEvent responseEvent = (ResponseEvent) eventResult.event; - String contentString = new String(responseEvent.getResponse().getRawContent()); - String ssrcInResponse = SipUtils.getSsrcFromSdp(contentString); - // 兼容回复的消息中缺少ssrc(y字段)的情况 - if (ssrcInResponse == null) { - ssrcInResponse = ssrcInfo.getSsrc(); - } - if (ssrcInfo.getSsrc().equals(ssrcInResponse)) { - // ssrc 一致 - if (mediaServerItem.isRtpEnable()) { - // 多端口 - if (device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE")) { - tcpActiveHandler(device, channelId, contentString, mediaServerItem, timeOutTaskKey, ssrcInfo, callback); - } - }else { - // 单端口 - if (device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE")) { - logger.warn("[Invite 200OK] 单端口收流模式不支持tcp主动模式收流"); - } - - } - }else { - logger.info("[Invite 200OK] 收到invite 200, 发现下级自定义了ssrc: {}", ssrcInResponse); - // ssrc 不一致 - if (mediaServerItem.isRtpEnable()) { - // 多端口 - if (device.isSsrcCheck()) { - // ssrc检验 - // 更新ssrc - logger.info("[Invite 200OK] SSRC修正 {}->{}", ssrcInfo.getSsrc(), ssrcInResponse); - // 释放ssrc - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - Boolean result = mediaServerService.updateRtpServerSSRC(mediaServerItem, ssrcInfo.getStream(), ssrcInResponse); - if (!result) { - try { - logger.warn("[Invite 200OK] 更新ssrc失败,停止点播 {}/{}", device.getDeviceId(), channelId); - cmder.streamByeCmd(device, channelId, ssrcInfo.getStream(), null, null); - } catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) { - logger.error("[命令发送失败] 停止播放, 发送BYE: {}", e.getMessage()); - } - - dynamicTask.stop(timeOutTaskKey); - // 释放ssrc - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - - callback.run(InviteErrorCode.ERROR_FOR_RESET_SSRC.getCode(), - "下级自定义了ssrc,重新设置收流信息失败", null); - inviteStreamService.call(inviteSessionType, device.getDeviceId(), channelId, null, - InviteErrorCode.ERROR_FOR_RESET_SSRC.getCode(), - "下级自定义了ssrc,重新设置收流信息失败", null); - - }else { - ssrcInfo.setSsrc(ssrcInResponse); - inviteInfo.setSsrcInfo(ssrcInfo); - inviteInfo.setStream(ssrcInfo.getStream()); - if (device.getStreamMode().equalsIgnoreCase("TCP-ACTIVE")) { - if (mediaServerItem.isRtpEnable()) { - tcpActiveHandler(device, channelId, contentString, mediaServerItem, timeOutTaskKey, ssrcInfo, callback); - }else { - logger.warn("[Invite 200OK] 单端口收流模式不支持tcp主动模式收流"); - } - } - inviteStreamService.updateInviteInfo(inviteInfo); - } - } - }else { - if (ssrcInResponse != null) { - // 单端口 - // 重新订阅流上线 - SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(inviteInfo.getDeviceId(), - inviteInfo.getChannelId(), null, inviteInfo.getStream()); - streamSession.remove(inviteInfo.getDeviceId(), - inviteInfo.getChannelId(), inviteInfo.getStream()); - inviteStreamService.updateInviteInfoForSSRC(inviteInfo, ssrcInResponse); - streamSession.put(device.getDeviceId(), channelId, ssrcTransaction.getCallId(), - inviteInfo.getStream(), ssrcInResponse, mediaServerItem.getId(), (SIPResponse) responseEvent.getResponse(), inviteSessionType); - } - } - } - } - - - - @Override - public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback callback) { - Device device = storager.queryVideoDevice(deviceId); - if (device == null) { - return; - } - MediaServerItem newMediaServerItem = getNewMediaServerItemHasAssist(device); - if (newMediaServerItem == null) { - callback.run(InviteErrorCode.ERROR_FOR_ASSIST_NOT_READY.getCode(), - InviteErrorCode.ERROR_FOR_ASSIST_NOT_READY.getMsg(), - null); - return; - } - // 录像下载不使用固定流地址,固定流地址会导致如果开始时间与结束时间一致时文件错误的叠加在一起 - SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, null, device.isSsrcCheck(), true, 0, false, device.getStreamModeForParam()); - download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, callback); - } - - - @Override - public void download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, ErrorCallback callback) { - if (mediaServerItem == null || ssrcInfo == null) { - callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), - InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(), - null); - return; - } - Device device = storager.queryVideoDevice(deviceId); - if (device == null) { - callback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), - "设备:" + deviceId + "不存在", - null); - return; - } - logger.info("[录像下载] deviceId: {}, channelId: {}, 下载速度:{}, 收流端口:{}, 收流模式:{}, SSRC: {}, SSRC校验:{}", device.getDeviceId(), channelId, downloadSpeed, ssrcInfo.getPort(), device.getStreamMode(), ssrcInfo.getSsrc(), device.isSsrcCheck()); - // 初始化redis中的invite消息状态 - InviteInfo inviteInfo = InviteInfo.getInviteInfo(device.getDeviceId(), channelId, ssrcInfo.getStream(), ssrcInfo, - mediaServerItem.getSdpIp(), ssrcInfo.getPort(), device.getStreamMode(), InviteSessionType.DOWNLOAD, - InviteSessionStatus.ready); - inviteStreamService.updateInviteInfo(inviteInfo); - String downLoadTimeOutTaskKey = UUID.randomUUID().toString(); - dynamicTask.startDelay(downLoadTimeOutTaskKey, () -> { - logger.warn(String.format("录像下载请求超时,deviceId:%s ,channelId:%s", deviceId, channelId)); - inviteStreamService.removeInviteInfo(inviteInfo); - callback.run(InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode(), - InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getMsg(), null); - - // 点播超时回复BYE 同时释放ssrc以及此次点播的资源 - try { - cmder.streamByeCmd(device, channelId, ssrcInfo.getStream(), null); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[录像流]录像下载请求超时, 发送BYE失败 {}", e.getMessage()); - } catch (SsrcTransactionNotFoundException e) { - mediaServerService.releaseSsrc(mediaServerItem.getId(), ssrcInfo.getSsrc()); - mediaServerService.closeRTPServer(mediaServerItem, ssrcInfo.getStream()); - streamSession.remove(deviceId, channelId, ssrcInfo.getStream()); - } - }, userSetting.getPlayTimeout()); - - SipSubscribe.Event errorEvent = event -> { - dynamicTask.stop(downLoadTimeOutTaskKey); - callback.run(InviteErrorCode.ERROR_FOR_SIGNALLING_TIMEOUT.getCode(), - String.format("录像下载失败, 错误码: %s, %s", event.statusCode, event.msg), null); - streamSession.remove(device.getDeviceId(), channelId, ssrcInfo.getStream()); - inviteStreamService.removeInviteInfo(inviteInfo); - }; - ZlmHttpHookSubscribe.Event hookEvent = (mediaServerItemInuse, hookParam) -> { - logger.info("[录像下载]收到订阅消息: " + hookParam); - dynamicTask.stop(downLoadTimeOutTaskKey); - StreamInfo streamInfo = onPublishHandlerForDownload(mediaServerItemInuse, hookParam, deviceId, channelId, startTime, endTime); - if (streamInfo == null) { - logger.warn("[录像下载] 获取流地址信息失败"); - callback.run(InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getCode(), - InviteErrorCode.ERROR_FOR_STREAM_PARSING_EXCEPTIONS.getMsg(), null); - return; - } - callback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), streamInfo); - logger.info("[录像下载] 调用成功 deviceId: {}, channelId: {}, 开始时间: {}, 结束时间: {}", device.getDeviceId(), channelId, startTime, endTime); - }; - try { - cmder.downloadStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, - hookEvent, errorEvent, eventResult ->{ - // 处理收到200ok后的TCP主动连接以及SSRC不一致的问题 - InviteOKHandler(eventResult, ssrcInfo, mediaServerItem, device, channelId, - downLoadTimeOutTaskKey, callback, inviteInfo, InviteSessionType.DOWNLOAD); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 录像下载: {}", e.getMessage()); - - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(); - eventResult.type = SipSubscribe.EventResultType.cmdSendFailEvent; - eventResult.statusCode = -1; - eventResult.msg = "命令发送失败"; - errorEvent.response(eventResult); - } - } - - @Override - public StreamInfo getDownLoadInfo(String deviceId, String channelId, String stream) { - InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, deviceId, channelId, stream); - - if (inviteInfo != null && inviteInfo.getStreamInfo() != null) { - if (inviteInfo.getStreamInfo().getProgress() == 1) { - return inviteInfo.getStreamInfo(); - } - - // 获取当前已下载时长 - String mediaServerId = inviteInfo.getStreamInfo().getMediaServerId(); - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); - if (mediaServerItem == null) { - logger.warn("查询录像信息时发现节点已离线"); - return null; - } - if (mediaServerItem.getRecordAssistPort() > 0) { - JSONObject jsonObject = assistRESTfulUtils.fileDuration(mediaServerItem, inviteInfo.getStreamInfo().getApp(), inviteInfo.getStreamInfo().getStream(), null); - if (jsonObject == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "连接Assist服务失败"); - } - if (jsonObject.getInteger("code") == 0) { - long duration = jsonObject.getLong("data"); - - if (duration == 0) { - inviteInfo.getStreamInfo().setProgress(0); - } else { - String startTime = inviteInfo.getStreamInfo().getStartTime(); - String endTime = inviteInfo.getStreamInfo().getEndTime(); - long start = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime); - long end = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime); - - BigDecimal currentCount = new BigDecimal(duration / 1000); - BigDecimal totalCount = new BigDecimal(end - start); - BigDecimal divide = currentCount.divide(totalCount, 2, RoundingMode.HALF_UP); - double process = divide.doubleValue(); - inviteInfo.getStreamInfo().setProgress(process); - } - inviteStreamService.updateInviteInfo(inviteInfo); - } - } - return inviteInfo.getStreamInfo(); - } - return null; - } - - private StreamInfo onPublishHandlerForDownload(MediaServerItem mediaServerItemInuse, HookParam hookParam, String deviceId, String channelId, String startTime, String endTime) { - OnStreamChangedHookParam streamChangedHookParam = (OnStreamChangedHookParam) hookParam; - StreamInfo streamInfo = onPublishHandler(mediaServerItemInuse, streamChangedHookParam, deviceId, channelId); - if (streamInfo != null) { - streamInfo.setProgress(0); - streamInfo.setStartTime(startTime); - streamInfo.setEndTime(endTime); - InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, deviceId, channelId, streamInfo.getStream()); - if (inviteInfo != null) { - logger.info("[录像下载] 更新invite消息中的stream信息"); - inviteInfo.setStatus(InviteSessionStatus.ok); - inviteInfo.setStreamInfo(streamInfo); - inviteStreamService.updateInviteInfo(inviteInfo); - } - } - return streamInfo; - } - - - public StreamInfo onPublishHandler(MediaServerItem mediaServerItem, OnStreamChangedHookParam hookParam, String deviceId, String channelId) { - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream(mediaServerItem, "rtp", hookParam.getStream(), hookParam.getTracks(), null); - streamInfo.setDeviceID(deviceId); - streamInfo.setChannelId(channelId); - return streamInfo; - } - - - @Override - public void zlmServerOffline(String mediaServerId) { - // 处理正在向上推流的上级平台 - List sendRtpItems = redisCatchStorage.querySendRTPServer(null); - if (sendRtpItems.size() > 0) { - for (SendRtpItem sendRtpItem : sendRtpItems) { - if (sendRtpItem.getMediaServerId().equals(mediaServerId)) { - ParentPlatform platform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); - try { - sipCommanderFroPlatform.streamByeCmd(platform, sendRtpItem.getCallId()); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - } - } - } - } - // 处理正在观看的国标设备 - List allSsrc = streamSession.getAllSsrc(); - if (allSsrc.size() > 0) { - for (SsrcTransaction ssrcTransaction : allSsrc) { - if (ssrcTransaction.getMediaServerId().equals(mediaServerId)) { - Device device = deviceService.getDevice(ssrcTransaction.getDeviceId()); - if (device == null) { - continue; - } - try { - cmder.streamByeCmd(device, ssrcTransaction.getChannelId(), - ssrcTransaction.getStream(), null); - } catch (InvalidArgumentException | ParseException | SipException | - SsrcTransactionNotFoundException e) { - logger.error("[zlm离线]为正在使用此zlm的设备, 发送BYE失败 {}", e.getMessage()); - } - } - } - } - } - - @Override - public void zlmServerOnline(String mediaServerId) { - // TODO 查找之前的点播,流如果不存在则给下级发送bye -// MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); -// zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ -// Integer code = mediaList.getInteger("code"); -// if (code == 0) { -// JSONArray data = mediaList.getJSONArray("data"); -// if (data == null || data.size() == 0) { -// zlmServerOffline(mediaServerId); -// }else { -// Map mediaListMap = new HashMap<>(); -// for (int i = 0; i < data.size(); i++) { -// JSONObject json = data.getJSONObject(i); -// String app = json.getString("app"); -// if ("rtp".equals(app)) { -// String stream = json.getString("stream"); -// if (mediaListMap.get(stream) != null) { -// continue; -// } -// mediaListMap.put(stream, json); -// // 处理正在观看的国标设备 -// List ssrcTransactions = streamSession.getSsrcTransactionForAll(null, null, null, stream); -// if (ssrcTransactions.size() > 0) { -// for (SsrcTransaction ssrcTransaction : ssrcTransactions) { -// if(ssrcTransaction.getMediaServerId().equals(mediaServerId)) { -// cmder.streamByeCmd(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), -// ssrcTransaction.getStream(), null); -// } -// } -// } -// } -// } -// if (mediaListMap.size() > 0 ) { -// // 处理正在向上推流的上级平台 -// List sendRtpItems = redisCatchStorage.querySendRTPServer(null); -// if (sendRtpItems.size() > 0) { -// for (SendRtpItem sendRtpItem : sendRtpItems) { -// if (sendRtpItem.getMediaServerId().equals(mediaServerId)) { -// if (mediaListMap.get(sendRtpItem.getStreamId()) == null) { -// ParentPlatform platform = storager.queryPlatformByServerGBId(sendRtpItem.getPlatformId()); -// sipCommanderFroPlatform.streamByeCmd(platform, sendRtpItem.getCallId()); -// } -// } -// } -// } -// } -// } -// } -// })); - } - - @Override - public void pauseRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException { - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId); - if (null == inviteInfo || inviteInfo.getStreamInfo() == null) { - logger.warn("streamId不存在!"); - throw new ServiceException("streamId不存在"); - } - inviteInfo.getStreamInfo().setPause(true); - inviteStreamService.updateInviteInfo(inviteInfo); - MediaServerItem mediaServerItem = mediaServerService.getOne(inviteInfo.getStreamInfo().getMediaServerId()); - if (null == mediaServerItem) { - logger.warn("mediaServer 不存在!"); - throw new ServiceException("mediaServer不存在"); - } - // zlm 暂停RTP超时检查 - JSONObject jsonObject = zlmresTfulUtils.pauseRtpCheck(mediaServerItem, streamId); - if (jsonObject == null || jsonObject.getInteger("code") != 0) { - throw new ServiceException("暂停RTP接收失败"); - } - Device device = storager.queryVideoDevice(inviteInfo.getDeviceId()); - cmder.playPauseCmd(device, inviteInfo.getStreamInfo()); - } - - @Override - public void resumeRtp(String streamId) throws ServiceException, InvalidArgumentException, ParseException, SipException { - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId); - if (null == inviteInfo || inviteInfo.getStreamInfo() == null) { - logger.warn("streamId不存在!"); - throw new ServiceException("streamId不存在"); - } - inviteInfo.getStreamInfo().setPause(false); - inviteStreamService.updateInviteInfo(inviteInfo); - MediaServerItem mediaServerItem = mediaServerService.getOne(inviteInfo.getStreamInfo().getMediaServerId()); - if (null == mediaServerItem) { - logger.warn("mediaServer 不存在!"); - throw new ServiceException("mediaServer不存在"); - } - // zlm 暂停RTP超时检查 - JSONObject jsonObject = zlmresTfulUtils.resumeRtpCheck(mediaServerItem, streamId); - if (jsonObject == null || jsonObject.getInteger("code") != 0) { - throw new ServiceException("继续RTP接收失败"); - } - Device device = storager.queryVideoDevice(inviteInfo.getDeviceId()); - cmder.playResumeCmd(device, inviteInfo.getStreamInfo()); - } - - @Override - public void getSnap(String deviceId, String channelId, String fileName, ErrorCallback errorCallback) { - Device device = deviceService.getDevice(deviceId); - if (device == null) { - errorCallback.run(InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getCode(), InviteErrorCode.ERROR_FOR_PARAMETER_ERROR.getMsg(), null); - return; - } - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - if (inviteInfo != null) { - if (inviteInfo.getStreamInfo() != null) { - // 已存在线直接截图 - MediaServerItem mediaServerItemInuse = mediaServerService.getOne(inviteInfo.getStreamInfo().getMediaServerId()); - String streamUrl; - if (mediaServerItemInuse.getRtspPort() != 0) { - streamUrl = String.format("rtsp://127.0.0.1:%s/%s/%s", mediaServerItemInuse.getRtspPort(), "rtp", inviteInfo.getStreamInfo().getStream()); - }else { - streamUrl = String.format("http://127.0.0.1:%s/%s/%s.live.mp4", mediaServerItemInuse.getHttpPort(), "rtp", inviteInfo.getStreamInfo().getStream()); - } - String path = "snap"; - // 请求截图 - logger.info("[请求截图]: " + fileName); - zlmresTfulUtils.getSnap(mediaServerItemInuse, streamUrl, 15, 1, path, fileName); - File snapFile = new File(path + File.separator + fileName); - if (snapFile.exists()) { - errorCallback.run(InviteErrorCode.SUCCESS.getCode(), InviteErrorCode.SUCCESS.getMsg(), snapFile.getAbsoluteFile()); - }else { - errorCallback.run(InviteErrorCode.FAIL.getCode(), InviteErrorCode.FAIL.getMsg(), null); - } - return; - } - } - - MediaServerItem newMediaServerItem = getNewMediaServerItem(device); - play(newMediaServerItem, deviceId, channelId, null, (code, msg, data)->{ - if (code == InviteErrorCode.SUCCESS.getCode()) { - InviteInfo inviteInfoForPlay = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - if (inviteInfoForPlay != null && inviteInfoForPlay.getStreamInfo() != null) { - getSnap(deviceId, channelId, fileName, errorCallback); - }else { - errorCallback.run(InviteErrorCode.FAIL.getCode(), InviteErrorCode.FAIL.getMsg(), null); - } - }else { - errorCallback.run(InviteErrorCode.FAIL.getCode(), InviteErrorCode.FAIL.getMsg(), null); - } - }); - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java deleted file mode 100644 index 4708223a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ /dev/null @@ -1,580 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.common.GeneralCallback; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IMediaService; -import com.genersoft.iot.vmp.service.IStreamProxyService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; -import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; -import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; -import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Service; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.util.CollectionUtils; -import org.springframework.util.ObjectUtils; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.function.Function; -import java.util.stream.Collectors; - -/** - * 视频代理业务 - */ -@Service -public class StreamProxyServiceImpl implements IStreamProxyService { - - private final static Logger logger = LoggerFactory.getLogger(StreamProxyServiceImpl.class); - - @Autowired - private IVideoManagerStorage videoManagerStorager; - - @Autowired - private IMediaService mediaService; - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private StreamProxyMapper streamProxyMapper; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private UserSetting userSetting; - - @Autowired - private GbStreamMapper gbStreamMapper; - - @Autowired - private PlatformGbStreamMapper platformGbStreamMapper; - - @Autowired - private EventPublisher eventPublisher; - - @Autowired - private ParentPlatformMapper parentPlatformMapper; - - @Autowired - private IGbStreamService gbStreamService; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private ZlmHttpHookSubscribe hookSubscribe; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - DataSourceTransactionManager dataSourceTransactionManager; - - @Autowired - TransactionDefinition transactionDefinition; - - - @Override - public void save(StreamProxyItem param, GeneralCallback callback) { - MediaServerItem mediaInfo; - if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){ - mediaInfo = mediaServerService.getMediaServerForMinimumLoad(null); - }else { - mediaInfo = mediaServerService.getOne(param.getMediaServerId()); - } - if (mediaInfo == null) { - logger.warn("保存代理未找到在线的ZLM..."); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "保存代理未找到在线的ZLM"); - } - String dstUrl; - if ("ffmpeg".equalsIgnoreCase(param.getType())) { - JSONObject jsonObject = zlmresTfulUtils.getMediaServerConfig(mediaInfo); - if (jsonObject.getInteger("code") != 0) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "获取流媒体配置失败"); - } - JSONArray dataArray = jsonObject.getJSONArray("data"); - JSONObject mediaServerConfig = dataArray.getJSONObject(0); - String ffmpegCmd = mediaServerConfig.getString(param.getFfmpegCmdKey()); - String schema = getSchemaFromFFmpegCmd(ffmpegCmd); - if (schema == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "ffmpeg拉流代理无法从ffmpeg cmd中获取到输出格式"); - } - int port; - String schemaForUri; - if (schema.equalsIgnoreCase("rtsp")) { - port = mediaInfo.getRtspPort(); - schemaForUri = schema; - }else if (schema.equalsIgnoreCase("flv")) { - port = mediaInfo.getRtmpPort(); - schemaForUri = schema; - }else { - port = mediaInfo.getRtmpPort(); - schemaForUri = schema; - } - - dstUrl = String.format("%s://%s:%s/%s/%s", schemaForUri, "127.0.0.1", port, param.getApp(), - param.getStream()); - }else { - dstUrl = String.format("rtsp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtspPort(), param.getApp(), - param.getStream()); - } - param.setDstUrl(dstUrl); - logger.info("[拉流代理] 输出地址为:{}", dstUrl); - param.setMediaServerId(mediaInfo.getId()); - boolean saveResult; - // 更新 - if (videoManagerStorager.queryStreamProxy(param.getApp(), param.getStream()) != null) { - saveResult = updateStreamProxy(param); - }else { // 新增 - saveResult = addStreamProxy(param); - } - if (!saveResult) { - callback.run(ErrorCode.ERROR100.getCode(), "保存失败", null); - return; - } - HookSubscribeForStreamChange hookSubscribeForStreamChange = HookSubscribeFactory.on_stream_changed(param.getApp(), param.getStream(), true, "rtsp", mediaInfo.getId()); - hookSubscribe.addSubscribe(hookSubscribeForStreamChange, (mediaServerItem, response) -> { - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream( - mediaInfo, param.getApp(), param.getStream(), null, null); - callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); - }); - if (param.isEnable()) { - String talkKey = UUID.randomUUID().toString(); - String delayTalkKey = UUID.randomUUID().toString(); - dynamicTask.startDelay(delayTalkKey, ()->{ - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(param.getApp(), param.getStream(), mediaInfo.getId(), false); - if (streamInfo != null) { - callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); - }else { - dynamicTask.stop(talkKey); - callback.run(ErrorCode.ERROR100.getCode(), "超时", null); - } - }, 7000); - JSONObject jsonObject = addStreamProxyToZlm(param); - if (jsonObject != null && jsonObject.getInteger("code") == 0) { - hookSubscribe.removeSubscribe(hookSubscribeForStreamChange); - dynamicTask.stop(talkKey); - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream( - mediaInfo, param.getApp(), param.getStream(), null, null); - callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); - }else { - param.setEnable(false); - // 直接移除 - if (param.isEnableRemoveNoneReader()) { - del(param.getApp(), param.getStream()); - }else { - updateStreamProxy(param); - } - if (jsonObject == null){ - callback.run(ErrorCode.ERROR100.getCode(), "记录已保存,启用失败", null); - }else { - callback.run(ErrorCode.ERROR100.getCode(), jsonObject.getString("msg"), null); - } - } - } - else{ - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStream( - mediaInfo, param.getApp(), param.getStream(), null, null); - callback.run(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), streamInfo); - } - } - - private String getSchemaFromFFmpegCmd(String ffmpegCmd) { - ffmpegCmd = ffmpegCmd.replaceAll(" + ", " "); - String[] paramArray = ffmpegCmd.split(" "); - if (paramArray.length == 0) { - return null; - } - for (int i = 0; i < paramArray.length; i++) { - if (paramArray[i].equalsIgnoreCase("-f")) { - if (i + 1 < paramArray.length - 1) { - return paramArray[i+1]; - }else { - return null; - } - - } - } - return null; - } - - /** - * 新增代理流 - * @param streamProxyItem - * @return - */ - private boolean addStreamProxy(StreamProxyItem streamProxyItem) { - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - boolean result = false; - streamProxyItem.setStreamType("proxy"); - streamProxyItem.setStatus(true); - String now = DateUtil.getNow(); - streamProxyItem.setCreateTime(now); - try { - if (streamProxyMapper.insert(streamProxyItem) > 0) { - if (!ObjectUtils.isEmpty(streamProxyItem.getGbId())) { - if (gbStreamMapper.insert(streamProxyItem) < 0) { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - } - }else { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - result = true; - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - }catch (Exception e) { - logger.error("向数据库添加流代理失败:", e); - dataSourceTransactionManager.rollback(transactionStatus); - } - - - return result; - } - - /** - * 更新代理流 - * @param streamProxyItem - * @return - */ - @Override - public boolean updateStreamProxy(StreamProxyItem streamProxyItem) { - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - boolean result = false; - streamProxyItem.setStreamType("proxy"); - try { - if (this.updateByAppAndStream(streamProxyItem)) { - if (!ObjectUtils.isEmpty(streamProxyItem.getGbId())) { - if (!gbStreamService.updateByAppAndStream(streamProxyItem)) { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - } - } else { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - result = true; - }catch (Exception e) { - logger.error("未处理的异常 ", e); - dataSourceTransactionManager.rollback(transactionStatus); - } - return result; - } - - @Override - public JSONObject addStreamProxyToZlm(StreamProxyItem param) { - JSONObject result = null; - MediaServerItem mediaServerItem = null; - if (param.getMediaServerId() == null) { - logger.warn("添加代理时MediaServerId 为null"); - return null; - }else { - mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); - } - if (mediaServerItem == null) { - return null; - } - if (zlmServerFactory.isStreamReady(mediaServerItem, param.getApp(), param.getStream())) { - zlmresTfulUtils.closeStreams(mediaServerItem, param.getApp(), param.getStream()); - } - if ("ffmpeg".equalsIgnoreCase(param.getType())){ - result = zlmresTfulUtils.addFFmpegSource(mediaServerItem, param.getSrcUrl().trim(), param.getDstUrl(), - param.getTimeoutMs() + "", param.isEnableAudio(), param.isEnableMp4(), - param.getFfmpegCmdKey()); - }else { - result = zlmresTfulUtils.addStreamProxy(mediaServerItem, param.getApp(), param.getStream(), param.getUrl().trim(), - param.isEnableAudio(), param.isEnableMp4(), param.getRtpType()); - } - System.out.println("addStreamProxyToZlm===="); - System.out.println(result); - if (result != null && result.getInteger("code") == 0) { - JSONObject data = result.getJSONObject("data"); - if (data == null) { - logger.warn("[获取拉流代理的结果数据Data] 失败: {}", result ); - return result; - } - String key = data.getString("key"); - if (key == null) { - logger.warn("[获取拉流代理的结果数据Data中的KEY] 失败: {}", result ); - return result; - } - param.setStreamKey(key); - this.updateByAppAndStream(param); - } - return result; - } - - @Override - public JSONObject removeStreamProxyFromZlm(StreamProxyItem param) { - if (param ==null) { - return null; - } - MediaServerItem mediaServerItem = mediaServerService.getOne(param.getMediaServerId()); - JSONObject result = null; - if ("ffmpeg".equalsIgnoreCase(param.getType())){ - result = zlmresTfulUtils.delFFmpegSource(mediaServerItem, param.getStreamKey()); - }else { - result = zlmresTfulUtils.delStreamProxy(mediaServerItem, param.getStreamKey()); - } - return result; - } - - @Override - public Page getAll(Page page, StreamProxyItem entity) { - return videoManagerStorager.queryStreamProxyList(page, entity); - } - - @Override - public void del(String app, String stream) { - StreamProxyItem streamProxyItem = videoManagerStorager.queryStreamProxy(app, stream); - if (streamProxyItem != null) { - gbStreamService.sendCatalogMsg(streamProxyItem, CatalogEvent.DEL); - - // 如果关联了国标那么移除关联 - platformGbStreamMapper.delByAppAndStream(app, stream); - gbStreamService.del(app, stream); - videoManagerStorager.deleteStreamProxy(app, stream); - redisCatchStorage.removeStream(streamProxyItem.getMediaServerId(), "PULL", app, stream); - JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyItem); - if (jsonObject != null && jsonObject.getInteger("code") == 0) { - logger.info("[移除代理]: 代理: {}/{}, 从zlm移除成功", app, stream); - }else { - logger.info("[移除代理]: 代理: {}/{}, 从zlm移除失败", app, stream); - } - } - } - - @Override - public boolean start(String app, String stream) { - boolean result = false; - StreamProxyItem streamProxy = videoManagerStorager.queryStreamProxy(app, stream); - if (streamProxy != null && !streamProxy.isEnable() ) { - JSONObject jsonObject = addStreamProxyToZlm(streamProxy); - if (jsonObject == null) { - return false; - } - if (jsonObject.getInteger("code") == 0) { - result = true; - streamProxy.setEnable(true); - updateStreamProxy(streamProxy); - }else { - logger.info("启用代理失败: {}/{}->{}({})", app, stream, jsonObject.getString("msg"), - streamProxy.getSrcUrl() == null? streamProxy.getUrl():streamProxy.getSrcUrl()); - } - } else if (streamProxy != null && streamProxy.isEnable()) { - return true ; - } - return result; - } - - @Override - public boolean stop(String app, String stream) { - boolean result = false; - StreamProxyItem streamProxyDto = videoManagerStorager.queryStreamProxy(app, stream); - if (streamProxyDto != null && streamProxyDto.isEnable()) { - JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyDto); - if (jsonObject != null && jsonObject.getInteger("code") == 0) { - streamProxyDto.setEnable(false); - result = updateStreamProxy(streamProxyDto); - } - } - return result; - } - - @Override - public JSONObject getFFmpegCMDs(MediaServerItem mediaServerItem) { - JSONObject result = new JSONObject(); - JSONObject mediaServerConfigResuly = zlmresTfulUtils.getMediaServerConfig(mediaServerItem); - if (mediaServerConfigResuly != null && mediaServerConfigResuly.getInteger("code") == 0 - && mediaServerConfigResuly.getJSONArray("data").size() > 0){ - JSONObject mediaServerConfig = mediaServerConfigResuly.getJSONArray("data").getJSONObject(0); - - for (String key : mediaServerConfig.keySet()) { - if (key.startsWith("ffmpeg.cmd")){ - result.put(key, mediaServerConfig.getString(key)); - } - } - } - return result; - } - - - @Override - public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) { - return videoManagerStorager.getStreamProxyByAppAndStream(app, streamId); - } - - @Override - public void zlmServerOnline(String mediaServerId) { - // 移除开启了无人观看自动移除的流 - List streamProxyItemList = streamProxyMapper.selectAutoRemoveItemByMediaServerId(mediaServerId); - if (streamProxyItemList.size() > 0) { - gbStreamMapper.batchDel(streamProxyItemList); - } - streamProxyMapper.deleteAutoRemoveItemByMediaServerId(mediaServerId); - - // 移除拉流代理生成的流信息 -// syncPullStream(mediaServerId); - - // 恢复流代理, 只查找这个这个流媒体 - List streamProxyListForEnable = storager.getStreamProxyListForEnableInMediaServer( - mediaServerId, true); - for (StreamProxyItem streamProxyDto : streamProxyListForEnable) { - logger.info("恢复流代理," + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); - JSONObject jsonObject = addStreamProxyToZlm(streamProxyDto); - if (jsonObject == null) { - // 设置为离线 - logger.info("恢复流代理失败" + streamProxyDto.getApp() + "/" + streamProxyDto.getStream()); - updateStatus(false, streamProxyDto.getApp(), streamProxyDto.getStream()); - }else { - updateStatus(true, streamProxyDto.getApp(), streamProxyDto.getStream()); - } - } - } - - @Override - public void zlmServerOffline(String mediaServerId) { - // 移除开启了无人观看自动移除的流 - List streamProxyItemList = streamProxyMapper.selectAutoRemoveItemByMediaServerId(mediaServerId); - if (streamProxyItemList.size() > 0) { - gbStreamMapper.batchDel(streamProxyItemList); - } - streamProxyMapper.deleteAutoRemoveItemByMediaServerId(mediaServerId); - // 其他的流设置离线 - streamProxyMapper.updateStatusByMediaServerId(mediaServerId, false); - String type = "PULL"; - - // 发送redis消息 - List onStreamChangedHookParams = redisCatchStorage.getStreams(mediaServerId, type); - if (onStreamChangedHookParams.size() > 0) { - for (OnStreamChangedHookParam onStreamChangedHookParam : onStreamChangedHookParams) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("serverId", userSetting.getServerId()); - jsonObject.put("app", onStreamChangedHookParam.getApp()); - jsonObject.put("stream", onStreamChangedHookParam.getStream()); - jsonObject.put("register", false); - jsonObject.put("mediaServerId", mediaServerId); - redisCatchStorage.sendStreamChangeMsg(type, jsonObject); - // 移除redis内流的信息 - redisCatchStorage.removeStream(mediaServerId, type, onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream()); - } - } - } - - @Override - public void clean() { - - } - - @Override - public int updateStatus(boolean status, String app, String stream) { - return streamProxyMapper.updateStatus(app, stream, status); - } - - private void syncPullStream(String mediaServerId){ - MediaServerItem mediaServer = mediaServerService.getOne(mediaServerId); - if (mediaServer != null) { - List allPullStream = redisCatchStorage.getStreams(mediaServerId, "PULL"); - if (allPullStream.size() > 0) { - zlmresTfulUtils.getMediaList(mediaServer, jsonObject->{ - Map stringStreamInfoMap = new HashMap<>(); - if (jsonObject.getInteger("code") == 0) { - JSONArray data = jsonObject.getJSONArray("data"); - if(data != null && data.size() > 0) { - for (int i = 0; i < data.size(); i++) { - JSONObject streamJSONObj = data.getJSONObject(i); - if ("rtsp".equals(streamJSONObj.getString("schema"))) { - StreamInfo streamInfo = new StreamInfo(); - String app = streamJSONObj.getString("app"); - String stream = streamJSONObj.getString("stream"); - streamInfo.setApp(app); - streamInfo.setStream(stream); - stringStreamInfoMap.put(app+stream, streamInfo); - } - } - } - } - if (stringStreamInfoMap.size() == 0) { - redisCatchStorage.removeStream(mediaServerId, "PULL"); - }else { - for (String key : stringStreamInfoMap.keySet()) { - StreamInfo streamInfo = stringStreamInfoMap.get(key); - if (stringStreamInfoMap.get(streamInfo.getApp() + streamInfo.getStream()) == null) { - redisCatchStorage.removeStream(mediaServerId, "PULL", streamInfo.getApp(), - streamInfo.getStream()); - } - } - } - }); - } - - } - - } - - @Override - public ResourceBaseInfo getOverview() { - return streamProxyMapper.getOverview(); - } - - @Override - public boolean updateByAppAndStream(StreamProxyItem streamProxyItem) { - return this.streamProxyMapper.update(streamProxyItem, Wrappers.lambdaUpdate() - .eq(StreamProxyItem::getApp, streamProxyItem.getApp()) - .eq(StreamProxyItem::getStream, streamProxyItem.getStream())) > 0; - } - - @Override - public int deleteByAppAndStream(String app, String stream) { - return this.streamProxyMapper.delete(Wrappers.lambdaQuery() - .eq(StreamProxyItem::getApp, app) - .eq(StreamProxyItem::getStream, stream)); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java deleted file mode 100644 index 0357e8b0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ /dev/null @@ -1,546 +0,0 @@ -package com.genersoft.iot.vmp.service.impl; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.alibaba.fastjson2.TypeReference; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.genersoft.iot.vmp.conf.MediaConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OriginType; -import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IStreamPushService; -import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.dao.*; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.stereotype.Service; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.util.ObjectUtils; - -import java.util.*; -import java.util.stream.Collectors; - -@Service -public class StreamPushServiceImpl extends ServiceImpl implements IStreamPushService { - - private final static Logger logger = LoggerFactory.getLogger(StreamPushServiceImpl.class); - - @Autowired - private GbStreamMapper gbStreamMapper; - - @Autowired - private StreamPushMapper streamPushMapper; - - @Autowired - private IStreamPushService streamPushService; - - @Autowired - private StreamProxyMapper streamProxyMapper; - - @Autowired - private ParentPlatformMapper parentPlatformMapper; - - @Autowired - private PlatformCatalogMapper platformCatalogMapper; - - @Autowired - private PlatformGbStreamMapper platformGbStreamMapper; - - @Autowired - private IGbStreamService gbStreamService; - - @Autowired - private EventPublisher eventPublisher; - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private UserSetting userSetting; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - DataSourceTransactionManager dataSourceTransactionManager; - - @Autowired - TransactionDefinition transactionDefinition; - - @Autowired - private MediaConfig mediaConfig; - - - @Override - public List handleJSON(String jsonData, MediaServerItem mediaServerItem) { - if (jsonData == null) { - return null; - } - - Map result = new HashMap<>(); - - List onStreamChangedHookParams = JSON.parseObject(jsonData, new TypeReference>() {}); - for (OnStreamChangedHookParam item : onStreamChangedHookParams) { - - // 不保存国标推理以及拉流代理的流 - if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() - || item.getOriginType() == OriginType.RTMP_PUSH.ordinal() - || item.getOriginType() == OriginType.RTC_PUSH.ordinal() ) { - String key = item.getApp() + "_" + item.getStream(); - StreamPushItem streamPushItem = result.get(key); - if (streamPushItem == null) { - streamPushItem = transform(item); - result.put(key, streamPushItem); - } - } - } - - return new ArrayList<>(result.values()); - } - @Override - public StreamPushItem transform(OnStreamChangedHookParam item) { - StreamPushItem streamPushItem = new StreamPushItem(); - streamPushItem.setApp(item.getApp()); - streamPushItem.setMediaServerId(item.getMediaServerId()); - streamPushItem.setStream(item.getStream()); - streamPushItem.setAliveSecond(item.getAliveSecond()); - streamPushItem.setOriginSock(item.getOriginSock()); - streamPushItem.setTotalReaderCount(item.getTotalReaderCount()); - streamPushItem.setOriginType(item.getOriginType()); - streamPushItem.setOriginTypeStr(item.getOriginTypeStr()); - streamPushItem.setOriginUrl(item.getOriginUrl()); - streamPushItem.setCreateTime(DateUtil.getNow()); - streamPushItem.setAliveSecond(item.getAliveSecond()); - streamPushItem.setStatus(true); - streamPushItem.setStreamType("push"); - streamPushItem.setVhost(item.getVhost()); - streamPushItem.setServerId(item.getSeverId()); - return streamPushItem; - } - - @Override - public Page getPushList(Page page, String query, Boolean pushing, String mediaServerId) { - return streamPushMapper.selectAllForList(page, query, pushing, mediaServerId); - } - - @Override - public List getPushList(String mediaServerId) { - return streamPushMapper.selectAllByMediaServerIdWithOutGbID(mediaServerId); - } - - @Override - public boolean saveToGB(GbStream stream) { - stream.setStreamType("push"); - stream.setStatus(true); - stream.setCreateTime(DateUtil.getNow()); - stream.setStreamType("push"); - stream.setMediaServerId(mediaConfig.getId()); - int add = gbStreamMapper.insert(stream); - return add > 0; - } - - @Override - public boolean removeFromGB(GbStream stream) { - // 判断是否需要发送事件 - gbStreamService.sendCatalogMsg(stream, CatalogEvent.DEL); - platformGbStreamMapper.delByAppAndStream(stream.getApp(), stream.getStream()); - int del = gbStreamService.del(stream.getApp(), stream.getStream()); - MediaServerItem mediaInfo = mediaServerService.getOne(stream.getMediaServerId()); - JSONObject mediaList = zlmresTfulUtils.getMediaList(mediaInfo, stream.getApp(), stream.getStream()); - if (mediaList != null) { - if (mediaList.getInteger("code") == 0) { - JSONArray data = mediaList.getJSONArray("data"); - if (data == null) { - this.deleteByAppAndStream(stream.getApp(), stream.getStream()); - } - } - } - return del > 0; - } - - - @Override - public StreamPushItem getPush(String app, String streamId) { - return streamPushMapper.getByAppAndStream(app, streamId); - } - - @Override - public boolean stop(String app, String streamId) { - logger.info("[推流 ] 停止流: {}/{}", app, streamId); - StreamPushItem streamPushItem = streamPushMapper.getByAppAndStream(app, streamId); - if (streamPushItem != null) { - gbStreamService.sendCatalogMsg(streamPushItem, CatalogEvent.DEL); - } - - platformGbStreamMapper.delByAppAndStream(app, streamId); - gbStreamService.del(app, streamId); - - if (this.deleteByAppAndStream(app, streamId)) { - MediaServerItem mediaServerItem = mediaServerService.getOne(streamPushItem.getMediaServerId()); - zlmresTfulUtils.closeStreams(mediaServerItem,app, streamId); - } - return true; - } - - @Override - public void zlmServerOnline(String mediaServerId) { - // 同步zlm推流信息 - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); - if (mediaServerItem == null) { - return; - } - // 数据库记录 - List pushList = getPushList(mediaServerId); - Map pushItemMap = new HashMap<>(); - // redis记录 - List onStreamChangedHookParams = redisCatchStorage.getStreams(mediaServerId, "PUSH"); - Map streamInfoPushItemMap = new HashMap<>(); - if (pushList.size() > 0) { - for (StreamPushItem streamPushItem : pushList) { - if (ObjectUtils.isEmpty(streamPushItem.getGbId())) { - pushItemMap.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem); - } - } - } - if (onStreamChangedHookParams.size() > 0) { - for (OnStreamChangedHookParam onStreamChangedHookParam : onStreamChangedHookParams) { - streamInfoPushItemMap.put(onStreamChangedHookParam.getApp() + onStreamChangedHookParam.getStream(), onStreamChangedHookParam); - } - } - // 获取所有推流鉴权信息,清理过期的 - List allStreamAuthorityInfo = redisCatchStorage.getAllStreamAuthorityInfo(); - Map streamAuthorityInfoInfoMap = new HashMap<>(); - for (StreamAuthorityInfo streamAuthorityInfo : allStreamAuthorityInfo) { - streamAuthorityInfoInfoMap.put(streamAuthorityInfo.getApp() + streamAuthorityInfo.getStream(), streamAuthorityInfo); - } - zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{ - if (mediaList == null) { - return; - } - String dataStr = mediaList.getString("data"); - - Integer code = mediaList.getInteger("code"); - List streamPushItems = null; - if (code == 0 ) { - if (dataStr != null) { - streamPushItems = handleJSON(dataStr, mediaServerItem); - } - } - - if (streamPushItems != null) { - for (StreamPushItem streamPushItem : streamPushItems) { - pushItemMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); - streamInfoPushItemMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); - streamAuthorityInfoInfoMap.remove(streamPushItem.getApp() + streamPushItem.getStream()); - } - } - List offlinePushItems = new ArrayList<>(pushItemMap.values()); - if (offlinePushItems.size() > 0) { - String type = "PUSH"; - int runLimit = 300; - if (offlinePushItems.size() > runLimit) { - for (int i = 0; i < offlinePushItems.size(); i += runLimit) { - int toIndex = i + runLimit; - if (i + runLimit > offlinePushItems.size()) { - toIndex = offlinePushItems.size(); - } - List streamPushItemsSub = offlinePushItems.subList(i, toIndex); - streamPushMapper.delAll(streamPushItemsSub); - } - }else { - streamPushMapper.delAll(offlinePushItems); - } - - } - Collection offlineOnStreamChangedHookParamList = streamInfoPushItemMap.values(); - if (offlineOnStreamChangedHookParamList.size() > 0) { - String type = "PUSH"; - for (OnStreamChangedHookParam offlineOnStreamChangedHookParam : offlineOnStreamChangedHookParamList) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("serverId", userSetting.getServerId()); - jsonObject.put("app", offlineOnStreamChangedHookParam.getApp()); - jsonObject.put("stream", offlineOnStreamChangedHookParam.getStream()); - jsonObject.put("register", false); - jsonObject.put("mediaServerId", mediaServerId); - redisCatchStorage.sendStreamChangeMsg(type, jsonObject); - // 移除redis内流的信息 - redisCatchStorage.removeStream(mediaServerItem.getId(), "PUSH", offlineOnStreamChangedHookParam.getApp(), offlineOnStreamChangedHookParam.getStream()); - } - } - - Collection streamAuthorityInfos = streamAuthorityInfoInfoMap.values(); - if (streamAuthorityInfos.size() > 0) { - for (StreamAuthorityInfo streamAuthorityInfo : streamAuthorityInfos) { - // 移除redis内流的信息 - redisCatchStorage.removeStreamAuthorityInfo(streamAuthorityInfo.getApp(), streamAuthorityInfo.getStream()); - } - } - })); - } - - @Override - public void zlmServerOffline(String mediaServerId) { - List streamPushItems = streamPushMapper.selectAllByMediaServerIdWithOutGbID(mediaServerId); - // 移除没有GBId的推流 - streamPushMapper.deleteWithoutGBId(mediaServerId); - gbStreamService.deleteWithoutGBId("push", mediaServerId); - // 其他的流设置未启用 - streamPushMapper.updateStatusByMediaServerId(mediaServerId, false); - streamProxyMapper.updateStatusByMediaServerId(mediaServerId, false); - // 发送流停止消息 - String type = "PUSH"; - // 发送redis消息 - List streamInfoList = redisCatchStorage.getStreams(mediaServerId, type); - if (streamInfoList.size() > 0) { - for (OnStreamChangedHookParam onStreamChangedHookParam : streamInfoList) { - // 移除redis内流的信息 - redisCatchStorage.removeStream(mediaServerId, type, onStreamChangedHookParam.getApp(), onStreamChangedHookParam.getStream()); - JSONObject jsonObject = new JSONObject(); - jsonObject.put("serverId", userSetting.getServerId()); - jsonObject.put("app", onStreamChangedHookParam.getApp()); - jsonObject.put("stream", onStreamChangedHookParam.getStream()); - jsonObject.put("register", false); - jsonObject.put("mediaServerId", mediaServerId); - redisCatchStorage.sendStreamChangeMsg(type, jsonObject); - } - } - } - - @Override - public void clean() { - - } - - @Override - public boolean saveToRandomGB() { - List streamPushItems = streamPushMapper.selectAll(); - long gbId = 100001; - for (StreamPushItem streamPushItem : streamPushItems) { - streamPushItem.setStreamType("push"); - streamPushItem.setStatus(true); - streamPushItem.setGbId("34020000004111" + gbId); - streamPushItem.setCreateTime(DateUtil.getNow()); - gbId ++; - } - - gbStreamMapper.batchAdd(streamPushItems); - - return true; - } - - @Override - public void batchAdd(List streamPushItems) { - streamPushMapper.addAll(streamPushItems); - gbStreamMapper.batchAdd(streamPushItems); - } - - @Override - public void batchAddForUpload(List streamPushItems, Map> streamPushItemsForAll ) { - // 存储数据到stream_push表 - streamPushMapper.addAll(streamPushItems); - List streamPushItemForGbStream = streamPushItems.stream() - .filter(streamPushItem-> streamPushItem.getGbId() != null) - .collect(Collectors.toList()); - // 存储数据到gb_stream表, id会返回到streamPushItemForGbStream里 - if (streamPushItemForGbStream.size() > 0) { - gbStreamMapper.batchAdd(streamPushItemForGbStream); - } - // 去除没有ID也就是没有存储到数据库的数据 - List streamPushItemsForPlatform = streamPushItemForGbStream.stream() - .filter(streamPushItem-> streamPushItem.getGbStreamId() != null) - .collect(Collectors.toList()); - - if (streamPushItemsForPlatform.size() > 0) { - // 获取所有平台,平台和目录信息一般不会特别大量。 - List parentPlatformList = parentPlatformMapper.getParentPlatformList(); - Map> platformInfoMap = new HashMap<>(); - if (parentPlatformList.size() == 0) { - return; - } - for (ParentPlatform platform : parentPlatformList) { - Map catalogMap = new HashMap<>(); - - // 创建根节点 - PlatformCatalog platformCatalog = new PlatformCatalog(); - platformCatalog.setId(platform.getServerGBId()); - catalogMap.put(platform.getServerGBId(), platformCatalog); - - // 查询所有节点信息 - List platformCatalogs = platformCatalogMapper.selectByPlatForm(platform.getServerGBId()); - if (platformCatalogs.size() > 0) { - for (PlatformCatalog catalog : platformCatalogs) { - catalogMap.put(catalog.getId(), catalog); - } - } - platformInfoMap.put(platform.getServerGBId(), catalogMap); - } - List streamPushItemListFroPlatform = new ArrayList<>(); - Map> platformForEvent = new HashMap<>(); - // 遍历存储结果,查找app+Stream->platformId+catalogId的对应关系,然后执行批量写入 - for (StreamPushItem streamPushItem : streamPushItemsForPlatform) { - List platFormInfoList = streamPushItemsForAll.get(streamPushItem.getApp() + streamPushItem.getStream()); - if (platFormInfoList != null && platFormInfoList.size() > 0) { - for (String[] platFormInfoArray : platFormInfoList) { - StreamPushItem streamPushItemForPlatform = new StreamPushItem(); - streamPushItemForPlatform.setGbStreamId(streamPushItem.getGbStreamId()); - if (platFormInfoArray.length > 0) { - // 数组 platFormInfoArray 0 为平台ID。 1为目录ID - // 不存在这个平台,则忽略导入此关联关系 - if (platformInfoMap.get(platFormInfoArray[0]) == null - || platformInfoMap.get(platFormInfoArray[0]).get(platFormInfoArray[1]) == null) { - logger.info("导入数据时不存在平台或目录{}/{},已导入未分配", platFormInfoArray[0], platFormInfoArray[1] ); - continue; - } - streamPushItemForPlatform.setPlatformId(platFormInfoArray[0]); - List gbStreamList = platformForEvent.get(platFormInfoArray[0]); - if (gbStreamList == null) { - gbStreamList = new ArrayList<>(); - platformForEvent.put(platFormInfoArray[0], gbStreamList); - } - // 为发送通知整理数据 - streamPushItemForPlatform.setName(streamPushItem.getName()); - streamPushItemForPlatform.setApp(streamPushItem.getApp()); - streamPushItemForPlatform.setStream(streamPushItem.getStream()); - streamPushItemForPlatform.setGbId(streamPushItem.getGbId()); - gbStreamList.add(streamPushItemForPlatform); - } - if (platFormInfoArray.length > 1) { - streamPushItemForPlatform.setCatalogId(platFormInfoArray[1]); - } - streamPushItemListFroPlatform.add(streamPushItemForPlatform); - } - - } - } - if (!streamPushItemListFroPlatform.isEmpty()) { - platformGbStreamMapper.batchAdd(streamPushItemListFroPlatform); - // 发送通知 - for (String platformId : platformForEvent.keySet()) { - eventPublisher.catalogEventPublishForStream( - platformId, platformForEvent.get(platformId), CatalogEvent.ADD); - } - } - } - } - - @Override - public boolean batchStop(List gbStreams) { - if (gbStreams == null || gbStreams.size() == 0) { - return false; - } - gbStreamService.sendCatalogMsgs(gbStreams, CatalogEvent.DEL); - - platformGbStreamMapper.delByGbStreams(gbStreams); - gbStreamMapper.batchDelForGbStream(gbStreams); - int delStream = streamPushMapper.delAllForGbStream(gbStreams); - if (delStream > 0) { - for (GbStream gbStream : gbStreams) { - MediaServerItem mediaServerItem = mediaServerService.getOne(gbStream.getMediaServerId()); - zlmresTfulUtils.closeStreams(mediaServerItem, gbStream.getApp(), gbStream.getStream()); - } - - } - return true; - } - - @Override - public void allStreamOffline() { - List onlinePushers = streamPushMapper.getOnlinePusherForGb(); - if (onlinePushers.size() == 0) { - return; - } - streamPushMapper.setAllStreamOffline(); - - // 发送通知 - eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.OFF); - } - - @Override - public void offline(List offlineStreams) { - // 更新部分设备离线 - List onlinePushers = streamPushMapper.getOnlinePusherForGbInList(offlineStreams); - streamPushMapper.offline(offlineStreams); - // 发送通知 - eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.OFF); - } - - @Override - public void online(List onlineStreams) { - // 更新部分设备上线streamPushService - List onlinePushers = streamPushMapper.getOfflinePusherForGbInList(onlineStreams); - streamPushMapper.online(onlineStreams); - // 发送通知 - eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.ON); - } - - @Override - public boolean add(StreamPushItem stream) { - stream.setUpdateTime(DateUtil.getNow()); - stream.setCreateTime(DateUtil.getNow()); - stream.setServerId(userSetting.getServerId()); - stream.setMediaServerId(mediaConfig.getId()); - stream.setSelf(true); - stream.setPushIng(true); - - // 放在事务内执行 - boolean result = false; - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - try { - int addStreamResult = streamPushMapper.insert(stream); - if (!ObjectUtils.isEmpty(stream.getGbId())) { - stream.setStreamType("push"); - gbStreamMapper.insert(stream); - } - dataSourceTransactionManager.commit(transactionStatus); - result = true; - }catch (Exception e) { - logger.error("批量移除流与平台的关系时错误", e); - dataSourceTransactionManager.rollback(transactionStatus); - } - return result; - } - - @Override - public List getAllAppAndStream() { - - return streamPushMapper.getAllAppAndStream(); - } - - @Override - public ResourceBaseInfo getOverview() { - int total = streamPushMapper.getAllCount(); - int online = streamPushMapper.getAllOnline(userSetting.isUsePushingAsStatus()); - - return new ResourceBaseInfo(total, online); - } - - @Override - public boolean deleteByAppAndStream(String app, String stream) { - return streamPushMapper.delete(Wrappers.lambdaQuery() - .eq(StreamPushItem::getApp, app) - .eq(StreamPushItem::getStream, stream)) > 0; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java deleted file mode 100644 index 194e90fb..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisAlarmMsgListener.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import javax.validation.constraints.NotNull; -import java.text.ParseException; -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; - - -@Component -public class RedisAlarmMsgListener implements MessageListener { - - private final static Logger logger = LoggerFactory.getLogger(RedisAlarmMsgListener.class); - - @Autowired - private ISIPCommander commander; - - @Autowired - private ISIPCommanderForPlatform commanderForPlatform; - - @Autowired - private IVideoManagerStorage storage; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Autowired - private UserSetting userSetting; - - @Override - public void onMessage(@NotNull Message message, byte[] bytes) { - // 消息示例: PUBLISH alarm_receive '{ "gbId": "", "alarmSn": 1, "alarmType": "111", "alarmDescription": "222", }' - logger.info("收到来自REDIS的ALARM通知: {}", new String(message.getBody())); - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(message); - if (isEmpty) { -// logger.info("[线程池信息]活动线程数:{}, 最大线程数: {}", taskExecutor.getActiveCount(), taskExecutor.getMaxPoolSize()); - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - Message msg = taskQueue.poll(); - try { - AlarmChannelMessage alarmChannelMessage = JSON.parseObject(msg.getBody(), AlarmChannelMessage.class); - if (alarmChannelMessage == null) { - logger.warn("[REDIS的ALARM通知]消息解析失败"); - continue; - } - String gbId = alarmChannelMessage.getGbId(); - - DeviceAlarm deviceAlarm = new DeviceAlarm(); - deviceAlarm.setCreateTime(DateUtil.getNow()); - deviceAlarm.setChannelId(gbId); - deviceAlarm.setAlarmDescription(alarmChannelMessage.getAlarmDescription()); - deviceAlarm.setAlarmMethod("" + alarmChannelMessage.getAlarmSn()); - deviceAlarm.setAlarmType("" + alarmChannelMessage.getAlarmType()); - deviceAlarm.setAlarmPriority("1"); - deviceAlarm.setAlarmTime(DateUtil.getNow()); - deviceAlarm.setLongitude(0); - deviceAlarm.setLatitude(0); - - if (ObjectUtils.isEmpty(gbId)) { - if (userSetting.getSendToPlatformsWhenIdLost()) { - // 发送给所有的上级 - List parentPlatforms = storage.queryEnableParentPlatformList(true); - if (parentPlatforms.size() > 0) { - for (ParentPlatform parentPlatform : parentPlatforms) { - try { - deviceAlarm.setChannelId(parentPlatform.getDeviceGBId()); - commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送报警: {}", e.getMessage()); - } - } - } - }else { - // 获取开启了消息推送的设备和平台 - List parentPlatforms = storage.queryEnablePlatformListWithAsMessageChannel(); - if (parentPlatforms.size() > 0) { - for (ParentPlatform parentPlatform : parentPlatforms) { - try { - deviceAlarm.setChannelId(parentPlatform.getDeviceGBId()); - commanderForPlatform.sendAlarmMessage(parentPlatform, deviceAlarm); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送报警: {}", e.getMessage()); - } - } - } - - } - // 获取开启了消息推送的设备和平台 - List devices = storage.queryDeviceWithAsMessageChannel(); - if (devices.size() > 0) { - for (Device device : devices) { - try { - deviceAlarm.setChannelId(device.getDeviceId()); - commander.sendAlarmMessage(device, deviceAlarm); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 发送报警: {}", e.getMessage()); - } - } - } - - }else { - Device device = storage.queryVideoDevice(gbId); - ParentPlatform platform = storage.queryParentPlatByServerGBId(gbId); - if (device != null && platform == null) { - try { - commander.sendAlarmMessage(device, deviceAlarm); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 发送报警: {}", e.getMessage()); - } - }else if (device == null && platform != null){ - try { - commanderForPlatform.sendAlarmMessage(platform, deviceAlarm); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 发送报警: {}", e.getMessage()); - } - }else { - logger.warn("无法确定" + gbId + "是平台还是设备"); - } - } - }catch (Exception e) { - logger.error("未处理的异常 ", e); - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, {}",e.getMessage()); - } - } - }); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisCloseStreamMsgListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisCloseStreamMsgListener.java deleted file mode 100644 index d0104756..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisCloseStreamMsgListener.java +++ /dev/null @@ -1,59 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.service.IStreamPushService; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; - -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * 接收来自redis的关闭流更新通知 - * @author lin - */ -@Component -public class RedisCloseStreamMsgListener implements MessageListener { - - private final static Logger logger = LoggerFactory.getLogger(RedisCloseStreamMsgListener.class); - - - @Autowired - private IStreamPushService pushService; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Override - public void onMessage(@NotNull Message message, byte[] bytes) { - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(message); - if (isEmpty) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - Message msg = taskQueue.poll(); - try { - JSONObject jsonObject = JSON.parseObject(msg.getBody()); - String app = jsonObject.getString("app"); - String stream = jsonObject.getString("stream"); - pushService.stop(app, stream); - - }catch (Exception e) { - logger.warn("[REDIS的关闭推流通知] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS的关闭推流通知] 异常内容: ", e); - } - } - }); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java deleted file mode 100644 index 2b0f366b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGbPlayMsgListener.java +++ /dev/null @@ -1,421 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.bean.*; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; - -import java.text.ParseException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; - - -/** - * 监听下级发送推送信息,并发送国标推流消息上级 - * @author lin - */ -@Component -public class RedisGbPlayMsgListener implements MessageListener { - - private final static Logger logger = LoggerFactory.getLogger(RedisGbPlayMsgListener.class); - - public static final String WVP_PUSH_STREAM_KEY = "WVP_PUSH_STREAM"; - - /** - * 流媒体不存在的错误玛 - */ - public static final int ERROR_CODE_MEDIA_SERVER_NOT_FOUND = -1; - - /** - * 离线的错误玛 - */ - public static final int ERROR_CODE_OFFLINE = -2; - - /** - * 超时的错误玛 - */ - public static final int ERROR_CODE_TIMEOUT = -3; - - private Map callbacks = new ConcurrentHashMap<>(); - private Map callbacksForStartSendRtpStream = new ConcurrentHashMap<>(); - private Map callbacksForError = new ConcurrentHashMap<>(); - - @Autowired - private UserSetting userSetting; - - - @Autowired - private RedisTemplate redisTemplate; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private IMediaServerService mediaServerService; - - - @Autowired - private DynamicTask dynamicTask; - - - @Autowired - private ZlmHttpHookSubscribe subscribe; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - - public interface PlayMsgCallback{ - void handler(ResponseSendItemMsg responseSendItemMsg) throws ParseException; - } - - public interface PlayMsgCallbackForStartSendRtpStream{ - void handler(JSONObject jsonObject); - } - - public interface PlayMsgErrorCallback{ - void handler(WVPResult wvpResult); - } - - @Override - public void onMessage(Message message, byte[] bytes) { - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(message); - if (isEmpty) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - Message msg = taskQueue.poll(); - try { - JSONObject msgJSON = JSON.parseObject(msg.getBody(), JSONObject.class); - WvpRedisMsg wvpRedisMsg = JSON.to(WvpRedisMsg.class, msgJSON); - if (!userSetting.getServerId().equals(wvpRedisMsg.getToId())) { - continue; - } - if (WvpRedisMsg.isRequest(wvpRedisMsg)) { - logger.info("[收到REDIS通知] 请求: {}", new String(msg.getBody())); - - switch (wvpRedisMsg.getCmd()){ - case WvpRedisMsgCmd.GET_SEND_ITEM: - RequestSendItemMsg content = JSON.to(RequestSendItemMsg.class, wvpRedisMsg.getContent()); - requestSendItemMsgHand(content, wvpRedisMsg.getFromId(), wvpRedisMsg.getSerial()); - break; - case WvpRedisMsgCmd.REQUEST_PUSH_STREAM: - RequestPushStreamMsg param = JSON.to(RequestPushStreamMsg.class, wvpRedisMsg.getContent()); - requestPushStreamMsgHand(param, wvpRedisMsg.getFromId(), wvpRedisMsg.getSerial()); - - break; - default: - break; - } - - }else { - logger.info("[收到REDIS通知] 回复: {}", new String(msg.getBody())); - switch (wvpRedisMsg.getCmd()){ - case WvpRedisMsgCmd.GET_SEND_ITEM: - - WVPResult content = JSON.to(WVPResult.class, wvpRedisMsg.getContent()); - - String key = wvpRedisMsg.getSerial(); - switch (content.getCode()) { - case 0: - ResponseSendItemMsg responseSendItemMsg =JSON.to(ResponseSendItemMsg.class, content.getData()); - PlayMsgCallback playMsgCallback = callbacks.get(key); - if (playMsgCallback != null) { - callbacksForError.remove(key); - try { - playMsgCallback.handler(responseSendItemMsg); - } catch (ParseException e) { - logger.error("[REDIS消息处理异常] ", e); - } - } - break; - case ERROR_CODE_MEDIA_SERVER_NOT_FOUND: - case ERROR_CODE_OFFLINE: - case ERROR_CODE_TIMEOUT: - PlayMsgErrorCallback errorCallback = callbacksForError.get(key); - if (errorCallback != null) { - callbacks.remove(key); - errorCallback.handler(content); - } - break; - default: - break; - } - break; - case WvpRedisMsgCmd.REQUEST_PUSH_STREAM: - WVPResult wvpResult = JSON.to(WVPResult.class, wvpRedisMsg.getContent()); - String serial = wvpRedisMsg.getSerial(); - switch (wvpResult.getCode()) { - case 0: - JSONObject jsonObject = (JSONObject)wvpResult.getData(); - PlayMsgCallbackForStartSendRtpStream playMsgCallback = callbacksForStartSendRtpStream.get(serial); - if (playMsgCallback != null) { - callbacksForError.remove(serial); - playMsgCallback.handler(jsonObject); - } - break; - case ERROR_CODE_MEDIA_SERVER_NOT_FOUND: - case ERROR_CODE_OFFLINE: - case ERROR_CODE_TIMEOUT: - PlayMsgErrorCallback errorCallback = callbacksForError.get(serial); - if (errorCallback != null) { - callbacks.remove(serial); - errorCallback.handler(wvpResult); - } - break; - default: - break; - } - break; - default: - break; - } - - } - }catch (Exception e) { - logger.warn("[RedisGbPlayMsg] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[RedisGbPlayMsg] 异常内容: ", e); - } - } - }); - } - } - - /** - * 处理收到的请求推流的请求 - */ - private void requestPushStreamMsgHand(RequestPushStreamMsg requestPushStreamMsg, String fromId, String serial) { - MediaServerItem mediaInfo = mediaServerService.getOne(requestPushStreamMsg.getMediaServerId()); - if (mediaInfo == null) { - // TODO 回复错误 - return; - } - String is_Udp = requestPushStreamMsg.isTcp() ? "0" : "1"; - Map param = new HashMap<>(); - param.put("vhost","__defaultVhost__"); - param.put("app",requestPushStreamMsg.getApp()); - param.put("stream",requestPushStreamMsg.getStream()); - param.put("ssrc", requestPushStreamMsg.getSsrc()); - param.put("dst_url",requestPushStreamMsg.getIp()); - param.put("dst_port", requestPushStreamMsg.getPort()); - param.put("is_udp", is_Udp); - param.put("src_port", requestPushStreamMsg.getSrcPort()); - param.put("pt", requestPushStreamMsg.getPt()); - param.put("use_ps", requestPushStreamMsg.isPs() ? "1" : "0"); - param.put("only_audio", requestPushStreamMsg.isOnlyAudio() ? "1" : "0"); - JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaInfo, param); - // 回复消息 - responsePushStream(jsonObject, fromId, serial); - } - - private void responsePushStream(JSONObject content, String toId, String serial) { - - WVPResult result = new WVPResult<>(); - result.setCode(0); - result.setData(content); - - WvpRedisMsg response = WvpRedisMsg.getResponseInstance(userSetting.getServerId(), toId, - WvpRedisMsgCmd.REQUEST_PUSH_STREAM, serial, result); - JSONObject jsonObject = (JSONObject)JSON.toJSON(response); - redisTemplate.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); - } - - /** - * 处理收到的请求sendItem的请求 - */ - private void requestSendItemMsgHand(RequestSendItemMsg content, String toId, String serial) { - MediaServerItem mediaServerItem = mediaServerService.getOne(content.getMediaServerId()); - if (mediaServerItem == null) { - logger.info("[回复推流信息] 流媒体{}不存在 ", content.getMediaServerId()); - - WVPResult result = new WVPResult<>(); - result.setCode(ERROR_CODE_MEDIA_SERVER_NOT_FOUND); - result.setMsg("流媒体不存在"); - - WvpRedisMsg response = WvpRedisMsg.getResponseInstance(userSetting.getServerId(), toId, - WvpRedisMsgCmd.GET_SEND_ITEM, serial, result); - - JSONObject jsonObject = (JSONObject)JSON.toJSON(response); - redisTemplate.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); - return; - } - // 确定流是否在线 - Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, content.getApp(), content.getStream()); - if (streamReady != null && streamReady) { - logger.info("[回复推流信息] {}/{}", content.getApp(), content.getStream()); - responseSendItem(mediaServerItem, content, toId, serial); - }else { - // 流已经离线 - // 发送redis消息以使设备上线 - logger.info("[ app={}, stream={} ]通道离线,发送redis信息控制设备开始推流",content.getApp(), content.getStream()); - - String taskKey = UUID.randomUUID().toString(); - // 设置超时 - dynamicTask.startDelay(taskKey, ()->{ - logger.info("[ app={}, stream={} ] 等待设备开始推流超时", content.getApp(), content.getStream()); - WVPResult result = new WVPResult<>(); - result.setCode(ERROR_CODE_TIMEOUT); - WvpRedisMsg response = WvpRedisMsg.getResponseInstance( - userSetting.getServerId(), toId, WvpRedisMsgCmd.GET_SEND_ITEM, serial, result - ); - JSONObject jsonObject = (JSONObject)JSON.toJSON(response); - redisTemplate.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); - }, userSetting.getPlatformPlayTimeout()); - - // 添加订阅 - HookSubscribeForStreamChange hookSubscribe = HookSubscribeFactory.on_stream_changed(content.getApp(), content.getStream(), true, "rtsp", mediaServerItem.getId()); - - subscribe.addSubscribe(hookSubscribe, (mediaServerItemInUse, hookParam)->{ - dynamicTask.stop(taskKey); - responseSendItem(mediaServerItem, content, toId, serial); - }); - - MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(1, content.getApp(), content.getStream(), - content.getChannelId(), content.getPlatformId(), content.getPlatformName(), content.getServerId(), - content.getMediaServerId()); - - String key = VideoManagerConstants.VM_MSG_STREAM_PUSH_REQUESTED; - logger.info("[redis发送通知] 推流被请求 {}: {}/{}", key, messageForPushChannel.getApp(), messageForPushChannel.getStream()); - redisTemplate.convertAndSend(key, JSON.toJSON(messageForPushChannel)); - } - } - - /** - * 将获取到的sendItem发送出去 - */ - private void responseSendItem(MediaServerItem mediaServerItem, RequestSendItemMsg content, String toId, String serial) { - SendRtpItem sendRtpItem = zlmServerFactory.createSendRtpItem(mediaServerItem, content.getIp(), - content.getPort(), content.getSsrc(), content.getPlatformId(), - content.getApp(), content.getStream(), content.getChannelId(), - content.getTcp(), content.getRtcp()); - - WVPResult result = new WVPResult<>(); - result.setCode(0); - ResponseSendItemMsg responseSendItemMsg = new ResponseSendItemMsg(); - responseSendItemMsg.setSendRtpItem(sendRtpItem); - responseSendItemMsg.setMediaServerItem(mediaServerItem); - result.setData(responseSendItemMsg); - - WvpRedisMsg response = WvpRedisMsg.getResponseInstance( - userSetting.getServerId(), toId, WvpRedisMsgCmd.GET_SEND_ITEM, serial, result - ); - JSONObject jsonObject = (JSONObject)JSON.toJSON(response); - redisTemplate.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); - } - - /** - * 发送消息要求下级生成推流信息 - * @param serverId 下级服务ID - * @param app 应用名 - * @param stream 流ID - * @param ip 目标IP - * @param port 目标端口 - * @param ssrc ssrc - * @param platformId 平台国标编号 - * @param channelId 通道ID - * @param isTcp 是否使用TCP - * @param callback 得到信息的回调 - */ - public void sendMsg(String serverId, String mediaServerId, String app, String stream, String ip, int port, String ssrc, - String platformId, String channelId, boolean isTcp, boolean rtcp, String platformName, PlayMsgCallback callback, PlayMsgErrorCallback errorCallback) { - RequestSendItemMsg requestSendItemMsg = RequestSendItemMsg.getInstance( - serverId, mediaServerId, app, stream, ip, port, ssrc, platformId, channelId, isTcp, rtcp, platformName); - requestSendItemMsg.setServerId(serverId); - String key = UUID.randomUUID().toString(); - WvpRedisMsg redisMsg = WvpRedisMsg.getRequestInstance(userSetting.getServerId(), serverId, WvpRedisMsgCmd.GET_SEND_ITEM, - key, requestSendItemMsg); - - JSONObject jsonObject = (JSONObject)JSON.toJSON(redisMsg); - logger.info("[请求推流SendItem] {}: {}", serverId, jsonObject); - callbacks.put(key, callback); - callbacksForError.put(key, errorCallback); - dynamicTask.startDelay(key, ()->{ - callbacks.remove(key); - callbacksForError.remove(key); - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(ERROR_CODE_TIMEOUT); - wvpResult.setMsg("timeout"); - errorCallback.handler(wvpResult); - }, userSetting.getPlatformPlayTimeout()); - redisTemplate.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); - } - - /** - * 发送请求推流的消息 - * @param param 推流参数 - * @param callback 回调 - */ - public void sendMsgForStartSendRtpStream(String serverId, RequestPushStreamMsg param, PlayMsgCallbackForStartSendRtpStream callback) { - String key = UUID.randomUUID().toString(); - WvpRedisMsg redisMsg = WvpRedisMsg.getRequestInstance(userSetting.getServerId(), serverId, - WvpRedisMsgCmd.REQUEST_PUSH_STREAM, key, param); - - JSONObject jsonObject = (JSONObject)JSON.toJSON(redisMsg); - logger.info("[REDIS 请求其他平台推流] {}: {}", serverId, jsonObject); - dynamicTask.startDelay(key, ()->{ - callbacksForStartSendRtpStream.remove(key); - callbacksForError.remove(key); - }, userSetting.getPlatformPlayTimeout()); - callbacksForStartSendRtpStream.put(key, callback); - callbacksForError.put(key, (wvpResult)->{ - logger.info("[REDIS 请求其他平台推流] 失败: {}", wvpResult.getMsg()); - callbacksForStartSendRtpStream.remove(key); - callbacksForError.remove(key); - }); - redisTemplate.convertAndSend(WVP_PUSH_STREAM_KEY, jsonObject); - } - - private SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId) { - if (platformGbId == null) { - platformGbId = "*"; - } - if (channelId == null) { - channelId = "*"; - } - if (streamId == null) { - streamId = "*"; - } - if (callId == null) { - callId = "*"; - } - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*_" - + platformGbId + "_" - + channelId + "_" - + streamId + "_" - + callId; - List scan = RedisUtil.scan(redisTemplate, key); - if (scan.size() > 0) { - return (SendRtpItem)redisTemplate.opsForValue().get(scan.get(0)); - }else { - return null; - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java deleted file mode 100644 index 4e81a591..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisGpsMsgListener.java +++ /dev/null @@ -1,78 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.jetbrains.annotations.NotNull; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; - -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * 接收来自redis的GPS更新通知 - * @author lin - */ -@Component -public class RedisGpsMsgListener implements MessageListener { - - private final static Logger logger = LoggerFactory.getLogger(RedisGpsMsgListener.class); - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IVideoManagerStorage storager; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - - @Override - public void onMessage(@NotNull Message message, byte[] bytes) { - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(message); - if (isEmpty) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - Message msg = taskQueue.poll(); - try { - GPSMsgInfo gpsMsgInfo = JSON.parseObject(msg.getBody(), GPSMsgInfo.class); - // 只是放入redis缓存起来 - redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); - }catch (Exception e) { - logger.warn("[REDIS的ALARM通知] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS的ALARM通知] 异常内容: ", e); - } - } - }); - } - } - - /** - * 定时将经纬度更新到数据库 - */ - @Scheduled(fixedRate = 2 * 1000) //每2秒执行一次 - public void execute(){ - List gpsMsgInfo = redisCatchStorage.getAllGpsMsgInfo(); - if (gpsMsgInfo.size() > 0) { - storager.updateStreamGPS(gpsMsgInfo); - for (GPSMsgInfo msgInfo : gpsMsgInfo) { - msgInfo.setStored(true); - redisCatchStorage.updateGpsMsgInfo(msgInfo); - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamCloseResponseListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamCloseResponseListener.java deleted file mode 100644 index ad00baf7..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamCloseResponseListener.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.InviteStreamType; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IStreamPushService; -import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; -import com.genersoft.iot.vmp.service.bean.MessageForPushChannelResponse; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.stereotype.Component; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -/** - * 接收redis发送的结束推流请求 - * @author lin - */ -@Component -public class RedisPushStreamCloseResponseListener implements MessageListener { - - private final static Logger logger = LoggerFactory.getLogger(RedisPushStreamCloseResponseListener.class); - - @Autowired - private IStreamPushService streamPushService; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private ISIPCommanderForPlatform commanderFroPlatform; - - @Autowired - private UserSetting userSetting; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private ZLMServerFactory zlmServerFactory; - - - private Map responseEvents = new ConcurrentHashMap<>(); - - public interface PushStreamResponseEvent{ - void run(MessageForPushChannelResponse response); - } - - @Override - public void onMessage(Message message, byte[] bytes) { - logger.info("[REDIS消息-推流结束]: {}", new String(message.getBody())); - MessageForPushChannel pushChannel = JSON.parseObject(message.getBody(), MessageForPushChannel.class); - StreamPushItem push = streamPushService.getPush(pushChannel.getApp(), pushChannel.getStream()); - if (push != null) { - if (redisCatchStorage.isChannelSendingRTP(push.getGbId())) { - List sendRtpItems = redisCatchStorage.querySendRTPServerByChnnelId( - push.getGbId()); - if (sendRtpItems.size() > 0) { - for (SendRtpItem sendRtpItem : sendRtpItems) { - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId()); - // 停止向上级推流 - String streamId = sendRtpItem.getStreamId(); - Map param = new HashMap<>(); - param.put("vhost","__defaultVhost__"); - param.put("app",sendRtpItem.getApp()); - param.put("stream",streamId); - param.put("ssrc",sendRtpItem.getSsrc()); - logger.info("[REDIS消息-推流结束] 停止向上级推流:{}", streamId); - MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId()); - redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), sendRtpItem.getCallId(), sendRtpItem.getStreamId()); - zlmServerFactory.stopSendRtpStream(mediaInfo, param); - - try { - commanderFroPlatform.streamByeCmd(parentPlatform, sendRtpItem); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - } - if (InviteStreamType.PUSH == sendRtpItem.getPlayType()) { - MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0, - sendRtpItem.getApp(), sendRtpItem.getStreamId(), sendRtpItem.getChannelId(), - sendRtpItem.getPlatformId(), parentPlatform.getName(), userSetting.getServerId(), sendRtpItem.getMediaServerId()); - messageForPushChannel.setPlatFormIndex(parentPlatform.getId()); - redisCatchStorage.sendPlatformStopPlayMsg(messageForPushChannel); - } - } - } - } - } - - } - - public void addEvent(String app, String stream, PushStreamResponseEvent callback) { - responseEvents.put(app + stream, callback); - } - - public void removeEvent(String app, String stream) { - responseEvents.remove(app + stream); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java deleted file mode 100644 index c90771be..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamResponseListener.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.genersoft.iot.vmp.service.bean.MessageForPushChannelResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; -import org.springframework.util.ObjectUtils; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * 接收redis返回的推流结果 - * @author lin - */ -@Component -public class RedisPushStreamResponseListener implements MessageListener { - - private final static Logger logger = LoggerFactory.getLogger(RedisPushStreamResponseListener.class); - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - - private Map responseEvents = new ConcurrentHashMap<>(); - - public interface PushStreamResponseEvent{ - void run(MessageForPushChannelResponse response); - } - - @Override - public void onMessage(Message message, byte[] bytes) { - logger.info("[REDIS消息-请求推流结果]: {}", new String(message.getBody())); - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(message); - if (isEmpty) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - Message msg = taskQueue.poll(); - try { - MessageForPushChannelResponse response = JSON.parseObject(new String(msg.getBody()), MessageForPushChannelResponse.class); - if (response == null || ObjectUtils.isEmpty(response.getApp()) || ObjectUtils.isEmpty(response.getStream())){ - logger.info("[REDIS消息-请求推流结果]:参数不全"); - continue; - } - // 查看正在等待的invite消息 - if (responseEvents.get(response.getApp() + response.getStream()) != null) { - responseEvents.get(response.getApp() + response.getStream()).run(response); - } - }catch (Exception e) { - logger.warn("[REDIS消息-请求推流结果] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS消息-请求推流结果] 异常内容: ", e); - } - } - }); - } - } - - public void addEvent(String app, String stream, PushStreamResponseEvent callback) { - responseEvents.put(app + stream, callback); - } - - public void removeEvent(String app, String stream) { - responseEvents.remove(app + stream); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java deleted file mode 100644 index cb34ff59..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusListMsgListener.java +++ /dev/null @@ -1,105 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IStreamPushService; -import com.genersoft.iot.vmp.utils.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; - -import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.ConcurrentLinkedQueue; - -/** - * @Auther: JiangFeng - * @Date: 2022/8/16 11:32 - * @Description: 接收redis发送的推流设备列表更新通知 - */ -@Component -public class RedisPushStreamStatusListMsgListener implements MessageListener { - - private final static Logger logger = LoggerFactory.getLogger(RedisPushStreamStatusListMsgListener.class); - @Resource - private IMediaServerService mediaServerService; - - @Resource - private IStreamPushService streamPushService; - @Resource - private IGbStreamService gbStreamService; - - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Override - public void onMessage(Message message, byte[] bytes) { - logger.info("[REDIS消息-推流设备列表更新]: {}", new String(message.getBody())); - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(message); - if (isEmpty) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - Message msg = taskQueue.poll(); - try { - List streamPushItems = JSON.parseArray(new String(msg.getBody()), StreamPushItem.class); - //查询全部的app+stream 用于判断是添加还是修改 - List allAppAndStream = streamPushService.getAllAppAndStream(); - - /** - * 用于存储更具APP+Stream过滤后的数据,可以直接存入stream_push表与gb_stream表 - */ - List streamPushItemForSave = new ArrayList<>(); - List streamPushItemForUpdate = new ArrayList<>(); - for (StreamPushItem streamPushItem : streamPushItems) { - String app = streamPushItem.getApp(); - String stream = streamPushItem.getStream(); - boolean contains = allAppAndStream.contains(app + stream); - //不存在就添加 - if (!contains) { - streamPushItem.setStreamType("push"); - streamPushItem.setCreateTime(DateUtil.getNow()); - streamPushItem.setMediaServerId(mediaServerService.getDefaultMediaServer().getId()); - streamPushItem.setOriginType(2); - streamPushItem.setOriginTypeStr("rtsp_push"); - streamPushItem.setTotalReaderCount("0"); - streamPushItemForSave.add(streamPushItem); - } else { - //存在就只修改 name和gbId - streamPushItemForUpdate.add(streamPushItem); - } - } - if (streamPushItemForSave.size() > 0) { - - logger.info("添加{}条",streamPushItemForSave.size()); - logger.info(JSONObject.toJSONString(streamPushItemForSave)); - streamPushService.batchAdd(streamPushItemForSave); - - } - if(streamPushItemForUpdate.size()>0){ - logger.info("修改{}条",streamPushItemForUpdate.size()); - logger.info(JSONObject.toJSONString(streamPushItemForUpdate)); - gbStreamService.updateGbIdOrName(streamPushItemForUpdate); - } - }catch (Exception e) { - logger.warn("[REDIS消息-推流设备列表更新] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS消息-推流设备列表更新] 异常内容: ", e); - } - } - }); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java deleted file mode 100644 index c8f4b2ae..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisPushStreamStatusMsgListener.java +++ /dev/null @@ -1,107 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.service.IStreamPushService; -import com.genersoft.iot.vmp.service.bean.PushStreamStatusChangeFromRedisDto; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.ApplicationArguments; -import org.springframework.boot.ApplicationRunner; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; - -import java.util.concurrent.ConcurrentLinkedQueue; - - -/** - * 接收redis发送的推流设备上线下线通知 - * @author lin - */ -@Component -public class RedisPushStreamStatusMsgListener implements MessageListener, ApplicationRunner { - - private final static Logger logger = LoggerFactory.getLogger(RedisPushStreamStatusMsgListener.class); - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IStreamPushService streamPushService; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private UserSetting userSetting; - - - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Override - public void onMessage(Message message, byte[] bytes) { - boolean isEmpty = taskQueue.isEmpty(); - logger.warn("[REDIS消息-推流设备状态变化]: {}", new String(message.getBody())); - taskQueue.offer(message); - - if (isEmpty) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - Message msg = taskQueue.poll(); - try { - PushStreamStatusChangeFromRedisDto statusChangeFromPushStream = JSON.parseObject(msg.getBody(), PushStreamStatusChangeFromRedisDto.class); - if (statusChangeFromPushStream == null) { - logger.warn("[REDIS消息]推流设备状态变化消息解析失败"); - continue; - } - // 取消定时任务 - dynamicTask.stop(VideoManagerConstants.VM_MSG_GET_ALL_ONLINE_REQUESTED); - if (statusChangeFromPushStream.isSetAllOffline()) { - // 所有设备离线 - streamPushService.allStreamOffline(); - } - if (statusChangeFromPushStream.getOfflineStreams() != null - && statusChangeFromPushStream.getOfflineStreams().size() > 0) { - // 更新部分设备离线 - streamPushService.offline(statusChangeFromPushStream.getOfflineStreams()); - } - if (statusChangeFromPushStream.getOnlineStreams() != null && - statusChangeFromPushStream.getOnlineStreams().size() > 0) { - // 更新部分设备上线 - streamPushService.online(statusChangeFromPushStream.getOnlineStreams()); - } - }catch (Exception e) { - logger.warn("[REDIS消息-推流设备状态变化] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS消息-推流设备状态变化] 异常内容: ", e); - } - } - }); - } - } - - @Override - public void run(ApplicationArguments args) throws Exception { - if (!userSetting.isUsePushingAsStatus()) { - // 启动时设置所有推流通道离线,发起查询请求 - redisCatchStorage.sendStreamPushRequestedMsgForStatus(); - dynamicTask.startDelay(VideoManagerConstants.VM_MSG_GET_ALL_ONLINE_REQUESTED, ()->{ - logger.info("[REDIS消息]未收到redis回复推流设备状态,执行推流设备离线"); - // 五秒收不到请求就设置通道离线,然后通知上级离线 - streamPushService.allStreamOffline(); - }, 5000); - } - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java deleted file mode 100644 index f5f29487..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/service/redisMsg/RedisStreamMsgListener.java +++ /dev/null @@ -1,92 +0,0 @@ -package com.genersoft.iot.vmp.service.redisMsg; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.UserSetting; - -import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.MessageListener; -import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; -import org.springframework.stereotype.Component; - -import java.util.concurrent.ConcurrentLinkedQueue; - - -/** - * 接收其他wvp发送流变化通知 - * @author lin - */ -@Component -public class RedisStreamMsgListener implements MessageListener { - - private final static Logger logger = LoggerFactory.getLogger(RedisStreamMsgListener.class); - - @Autowired - private UserSetting userSetting; - - @Autowired - private ZLMMediaListManager zlmMediaListManager; - - private ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); - - @Qualifier("taskExecutor") - @Autowired - private ThreadPoolTaskExecutor taskExecutor; - - @Override - public void onMessage(Message message, byte[] bytes) { - boolean isEmpty = taskQueue.isEmpty(); - taskQueue.offer(message); - if (isEmpty) { - taskExecutor.execute(() -> { - while (!taskQueue.isEmpty()) { - Message msg = taskQueue.poll(); - try { - JSONObject steamMsgJson = JSON.parseObject(msg.getBody(), JSONObject.class); - if (steamMsgJson == null) { - logger.warn("[收到redis 流变化]消息解析失败"); - continue; - } - String serverId = steamMsgJson.getString("serverId"); - - if (userSetting.getServerId().equals(serverId)) { - // 自己发送的消息忽略即可 - continue; - } - logger.info("[收到redis 流变化]: {}", new String(message.getBody())); - String app = steamMsgJson.getString("app"); - String stream = steamMsgJson.getString("stream"); - boolean register = steamMsgJson.getBoolean("register"); - String mediaServerId = steamMsgJson.getString("mediaServerId"); - OnStreamChangedHookParam onStreamChangedHookParam = new OnStreamChangedHookParam(); - onStreamChangedHookParam.setSeverId(serverId); - onStreamChangedHookParam.setApp(app); - onStreamChangedHookParam.setStream(stream); - onStreamChangedHookParam.setRegist(register); - onStreamChangedHookParam.setMediaServerId(mediaServerId); - onStreamChangedHookParam.setCreateStamp(System.currentTimeMillis()/1000); - onStreamChangedHookParam.setAliveSecond(0L); - onStreamChangedHookParam.setTotalReaderCount("0"); - onStreamChangedHookParam.setOriginType(0); - onStreamChangedHookParam.setOriginTypeStr("0"); - onStreamChangedHookParam.setOriginTypeStr("unknown"); - if (register) { - zlmMediaListManager.addPush(onStreamChangedHookParam); - }else { - zlmMediaListManager.removeMedia(app, stream); - } - }catch (Exception e) { - logger.warn("[REDIS消息-流变化] 发现未处理的异常, \r\n{}", JSON.toJSONString(message)); - logger.error("[REDIS消息-流变化] 异常内容: ", e); - } - } - }); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java deleted file mode 100644 index 6ef8d88a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ /dev/null @@ -1,201 +0,0 @@ -package com.genersoft.iot.vmp.storager; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.SystemAllInfo; -import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; -import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; - -import java.util.List; -import java.util.Map; - -public interface IRedisCatchStorage { - - /** - * 计数器。为cseq进行计数 - * - * @return - */ - Long getCSEQ(); - - void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch); - - ParentPlatformCatch queryPlatformCatchInfo(String platformGbId); - - void delPlatformCatchInfo(String platformGbId); - - void delPlatformKeepalive(String platformGbId); - - void delPlatformRegister(String platformGbId); - - void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo); - - PlatformRegisterInfo queryPlatformRegisterInfo(String callId); - - void delPlatformRegisterInfo(String callId); - - void updateSendRTPSever(SendRtpItem sendRtpItem); - - /** - * 查询RTP推送信息缓存 - * @param platformGbId - * @param channelId - * @return sendRtpItem - */ - SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId); - - List querySendRTPServer(String platformGbId); - - /** - * 删除RTP推送信息缓存 - * @param platformGbId - * @param channelId - */ - void deleteSendRTPServer(String platformGbId, String channelId, String callId, String streamId); - - /** - * 查询某个通道是否存在上级点播(RTP推送) - * @param channelId - */ - boolean isChannelSendingRTP(String channelId); - - /** - * 在redis添加wvp的信息 - */ - void updateWVPInfo(JSONObject jsonObject, int time); - - /** - * 发送推流生成与推流消失消息 - * @param jsonObject 消息内容 - */ - void sendStreamChangeMsg(String type, JSONObject jsonObject); - - /** - * 发送报警消息 - * @param msg 消息内容 - */ - void sendAlarmMsg(AlarmChannelMessage msg); - - /** - * 添加流信息到redis - * @param mediaServerItem - * @param app - * @param streamId - */ - void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, OnStreamChangedHookParam item); - - /** - * 移除流信息从redis - * @param mediaServerId - * @param app - * @param streamId - */ - void removeStream(String mediaServerId, String type, String app, String streamId); - - - /** - * 移除流信息从redis - * @param mediaServerId - */ - void removeStream(String mediaServerId, String type); - - List getStreams(String mediaServerId, String pull); - - /** - * 将device信息写入redis - * @param device - */ - void updateDevice(Device device); - - void removeDevice(String deviceId); - - /** - * 获取Device - */ - Device getDevice(String deviceId); - - void resetAllCSEQ(); - - void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo); - - GPSMsgInfo getGpsMsgInfo(String gbId); - List getAllGpsMsgInfo(); - - Long getSN(String method); - - void resetAllSN(); - - OnStreamChangedHookParam getStreamInfo(String app, String streamId, String mediaServerId); - - void sendMobilePositionMsg(JSONObject jsonObject); - - void sendStreamPushRequestedMsg(MessageForPushChannel messageForPushChannel); - - /** - * 判断设备状态 - * @param deviceId 设备ID - * @return - */ - public boolean deviceIsOnline(String deviceId); - - /** - * 存储推流的鉴权信息 - * @param app 应用名 - * @param stream 流 - * @param streamAuthorityInfo 鉴权信息 - */ - void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo); - - /** - * 移除推流的鉴权信息 - * @param app 应用名 - * @param streamId 流 - */ - void removeStreamAuthorityInfo(String app, String streamId); - - /** - * 获取推流的鉴权信息 - * @param app 应用名 - * @param stream 流 - * @return - */ - StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream); - - List getAllStreamAuthorityInfo(); - - /** - * 发送redis消息 查询所有推流设备的状态 - */ - void sendStreamPushRequestedMsgForStatus(); - - List querySendRTPServerByChnnelId(String channelId); - - List querySendRTPServerByStream(String stream); - - int getPushStreamCount(String id); - - int getProxyStreamCount(String id); - - int getGbSendCount(String id); - - List queryAllSendRTPServer(); - - List getAllDevices(); - - void removeAllDevice(); - - void sendDeviceOrChannelStatus(String deviceId, String channelId, boolean online); - - void sendChannelAddOrDelete(String deviceId, String channelId, boolean add); - - void sendPlatformStartPlayMsg(MessageForPushChannel messageForPushChannel); - - void sendPlatformStopPlayMsg(MessageForPushChannel messageForPushChannel); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java deleted file mode 100644 index 8d66f1b0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ /dev/null @@ -1,370 +0,0 @@ -package com.genersoft.iot.vmp.storager; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; - -import java.util.List; - -/** - * @description:视频设备数据存储接口 - * @author: swwheihei - * @date: 2020年5月6日 下午2:14:31 - */ -@SuppressWarnings("rawtypes") -public interface IVideoManagerStorage { - - /** - * 根据设备ID判断设备是否存在 - * - * @param deviceId 设备ID - * @return true:存在 false:不存在 - */ - boolean exists(String deviceId); - - /** - * 开始播放 - * @param deviceId 设备id - * @param channelId 通道ID - * @param streamId 流地址 - */ - void startPlay(String deviceId, String channelId, String streamId); - - /** - * 停止播放 - * @param deviceId 设备id - * @param channelId 通道ID - */ - void stopPlay(String deviceId, String channelId); - - /** - * 获取设备 - * - * @param deviceId 设备ID - * @return DShadow 设备对象 - */ - Device queryVideoDevice(String deviceId); - - /** - * 获取某个设备的通道列表 - * - * @param deviceId 设备ID - * @param page 分页 - * @return - */ - Page queryChannelsByDeviceId(Page page, String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice); - - List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit); - - - /** - * 获取某个设备的通道列表 - * - * @param deviceId 设备ID - * @return - */ - List queryChannelsByDeviceId(String deviceId,Boolean online,List channelIds); - - /** - * 获取某个设备的通道 - * @param deviceId 设备ID - * @param channelId 通道ID - */ - DeviceChannel queryChannel(String deviceId, String channelId); - - /** - * 删除通道 - * @param deviceId 设备ID - * @param channelId 通道ID - */ - int delChannel(String deviceId, String channelId); - - /** - * 获取多个设备 - * @param page 当前页数 - * @param online 每页数量 - * @return List 设备对象数组 - */ - Page queryVideoDeviceList(Page page,Boolean online); - - /** - * 查询子设备 - * - * @param deviceId - * @param channelId - * @return - */ - Page querySubChannels(Page page, String deviceId, String channelId, String query, Boolean hasSubChannel, Boolean online); - - - /** - * 清空通道 - * @param deviceId - */ - void cleanChannelsForDevice(String deviceId); - - - /** - * 更新上级平台 - * @param parentPlatform - */ - boolean updateParentPlatform(ParentPlatform parentPlatform); - - - /** - * 添加上级平台 - * @param parentPlatform - */ - boolean addParentPlatform(ParentPlatform parentPlatform); - - /** - * 删除上级平台 - * @param parentPlatform - */ - boolean deleteParentPlatform(ParentPlatform parentPlatform); - - /** - * 获取所有已启用的平台 - * @return - */ - List queryEnableParentPlatformList(boolean enable); - - /** - * 获取上级平台 - * @param platformGbId - * @return - */ - ParentPlatform queryParentPlatByServerGBId(String platformGbId); - - /** - * 所有平台离线 - */ - void outlineForAllParentPlatform(); - - /** - * 查询通道信息,不区分设备(已关联平台或全部) - */ - Page queryAllChannelList(Page page, String query, Boolean online, Boolean channelType, String platformId, String catalogId); - - /** - * 查询设备的通道信息 - */ - List queryChannelListInParentPlatform(String platformId); - - - - /** - * 移除上级平台的通道信息 - * @param platformId - * @param channelReduces - * @return - */ - int delChannelForGB(String platformId, List channelReduces); - - - DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); - - List queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); - List queryStreamInParentPlatformAndCatalog(String platformId, String catalogId); - - Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); - - /** - * 针对deviceinfo指令的查询接口 - * @param platformId 平台id - * @param channelId 通道id - * @return 设备信息 - */ - Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId); - /** - * 添加Mobile Position设备移动位置 - * @param mobilePosition - * @return - */ - boolean insertMobilePosition(MobilePosition mobilePosition); - - /** - * 查询移动位置轨迹 - * @param deviceId - * @param startTime - * @param endTime - */ - List queryMobilePositions(String deviceId, String channelId, String startTime, String endTime); - - /** - * 查询最新移动位置 - * @param deviceId - */ - MobilePosition queryLatestPosition(String deviceId); - - /** - * 删除指定设备的所有移动位置 - * @param deviceId - */ - int clearMobilePositionsByDeviceId(String deviceId); - - /** - * 移除代理流 - * @param app - * @param stream - * @return - */ - int deleteStreamProxy(String app, String stream); - - /** - * 按照是否启用获取代理流 - * @param enable - * @return - */ - List getStreamProxyListForEnable(boolean enable); - - /** - * 按照是app和stream获取代理流 - * @param app - * @param stream - * @return - */ - StreamProxyItem queryStreamProxy(String app, String stream); - - /** - * 获取代理流 - * @param page - * @return - */ - Page queryStreamProxyList(Page page, StreamProxyItem entity); - - /** - * 根据国标ID获取平台关联的直播流 - * @param platformId - * @param channelId - * @return - */ - GbStream queryStreamInParentPlatform(String platformId, String channelId); - - /** - * 获取平台关联的直播流 - * @param platformId - * @return - */ - List queryGbStreamListInPlatform(String platformId); - - /** - * 移除单个推流 - * @param app - * @param stream - */ - int removeMedia(String app, String stream); - - /** - * 设置流离线 - */ - int mediaOffline(String app, String streamId); - - /** - * 设置流上线 - */ - int mediaOnline(String app, String streamId); - - /** - * 设置平台在线/离线 - */ - void updateParentPlatformStatus(String platformGbID, boolean online); - - /** - * 根据媒体ID获取启用/不启用的代理列表 - * @param id 媒体ID - * @param enable 启用/不启用 - * @return - */ - List getStreamProxyListForEnableInMediaServer(String id, boolean enable); - - /** - * 根据通道ID获取其所在设备 - * @param channelId 通道ID - * @return - */ - Device queryVideoDeviceByChannelId(String channelId); - - /** - * 通道上线 - * @param channelId 通道ID - */ - void deviceChannelOnline(String deviceId, String channelId); - - /** - * 通道离线 - * @param channelId 通道ID - */ - void deviceChannelOffline(String deviceId, String channelId); - - /** - * 通过app与stream获取StreamProxy - * @param app - * @param streamId - * @return - */ - StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); - - /** - * catlog查询结束后完全重写通道信息 - * @param deviceId - * @param deviceChannelList - */ - boolean resetChannels(String deviceId, List deviceChannelList); - - boolean updateChannels(String deviceId, List deviceChannelList); - - /** - * 获取目录信息 - * @param platformId - * @param parentId - * @return - */ - List getChildrenCatalogByPlatform(String platformId, String parentId); - - int addCatalog(PlatformCatalog platformCatalog); - - PlatformCatalog getCatalog(String platformId, String id); - - int delCatalog(String platformId, String id); - - int updateCatalog(PlatformCatalog platformCatalog); - - int setDefaultCatalog(String platformId, String catalogId); - - List queryCatalogInPlatform(String serverGBId); - - int delRelation(PlatformCatalog platformCatalog); - - int updateStreamGPS(List gpsMsgInfo); - - List queryPlatFormListForGBWithGBId(String channelId, List platforms); - - List queryPlatFormListForStreamWithGBId(String app, String stream, List platforms); - - GbStream getGbStream(String app, String streamId); - - void delCatalogByPlatformId(String serverGBId); - - void delRelationByPlatformId(String serverGBId); - - PlatformCatalog queryDefaultCatalogInPlatform(String platformId); - - List getChannelSource(String platformId, String gbId); - - void updateChannelPosition(DeviceChannel deviceChannel); - - void cleanContentForPlatform(String serverGBId); - - List queryChannelWithCatalog(String serverGBId); - - List queryChannelsByDeviceId(String serial, List channelIds, Boolean online); - - List queryEnablePlatformListWithAsMessageChannel(); - - List queryDeviceWithAsMessageChannel(); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java deleted file mode 100644 index 0fb01582..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceAlarmMapper.java +++ /dev/null @@ -1,20 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 用于存储设备的报警信息 - */ -@Mapper -public interface DeviceAlarmMapper extends BaseMapper { - - List query(@Param("deviceId") String deviceId, @Param("alarmPriority") String alarmPriority, @Param("alarmMethod") String alarmMethod, - @Param("alarmType") String alarmType, @Param("startTime") String startTime, @Param("endTime") String endTime); - - int clearAlarmBeforeTime(@Param("id") Integer id, @Param("deviceIdList") List deviceIdList, @Param("time") String time); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java deleted file mode 100644 index 4d6bcc4a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ /dev/null @@ -1,82 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannelInPlatform; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 用于存储设备通道信息 - */ -@Mapper -public interface DeviceChannelMapper extends BaseMapper { - - List queryChannels(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId - , @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online - , @Param("channelIds") List channelIds); - - Page queryChannelsByPage(Page page, @Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId - , @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online); - - List queryChannelsWithDeviceInfo(@Param("deviceId") String deviceId, @Param("parentChannelId") String parentChannelId - , @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online - , @Param("channelIds") List channelIds); - - List queryChannelsByDeviceIdWithStartAndLimit(@Param("deviceId") String deviceId, @Param("channelIds") List channelIds - , @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel - , @Param("online") Boolean online, @Param("start") int start, @Param("limit") int limit); - - int cleanChannelsByDeviceId(@Param("deviceId") String deviceId); - - void stopPlay(@Param("deviceId") String deviceId, @Param("channelId") String channelId); - - void startPlay(@Param("deviceId") String deviceId, @Param("channelId") String channelId, @Param("streamId") String streamId); - - List queryChannelListInAll(@Param("query") String query, @Param("online") Boolean online - , @Param("hasSubChannel") Boolean hasSubChannel, @Param("platformId") String platformId, @Param("catalogId") String catalogId); - - Page queryChannelListByPage(Page page, @Param("query") String query, @Param("online") Boolean online - , @Param("hasSubChannel") Boolean hasSubChannel, @Param("platformId") String platformId, @Param("catalogId") String catalogId); - - List queryChannelByPlatformId(String platformId); - - int batchAdd(@Param("addChannels") List addChannels); - - int batchUpdate(@Param("updateChannels") List updateChannels); - - int updateChannelSubCount(@Param("deviceId") String deviceId, @Param("channelId") String channelId); - - List getAllChannelInPlay(); - - List queryChannelWithCatalog(String serverGBId); - - /** - * 是否有通道 - * @param deviceId - * @return - */ - boolean isChannel(String deviceId); - - List getChannelsWithoutTransform(String deviceId); - - List getDeviceByChannelId(String channelId); - - int batchDel(@Param("deleteChannelList") List deleteChannelList); - - int batchOnline(@Param("channels") List channels); - - int batchOffline(@Param("channels") List channels); - - int getOnlineCount(); - - // 设备主子码流逻辑END - List getSubChannelsByDeviceId(@Param("deviceId") String deviceId, @Param("parentId") String parentId, @Param("onlyCatalog") boolean onlyCatalog); - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java deleted file mode 100644 index 3dfa2efa..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import org.apache.ibatis.annotations.Mapper; -import org.springframework.stereotype.Repository; - -/** - * 用于存储设备信息 - */ -@Mapper -@Repository("wvpDeviceMapper") -public interface DeviceMapper extends BaseMapper { - - Device getDeviceByDeviceId(String deviceId); - - Page getDevices(Page page, Boolean onLine); - - Page detailByPage(Page page, Device entity); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMobilePositionMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMobilePositionMapper.java deleted file mode 100644 index d2dff677..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMobilePositionMapper.java +++ /dev/null @@ -1,10 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; -import org.apache.ibatis.annotations.Mapper; - -@Mapper -public interface DeviceMobilePositionMapper extends BaseMapper { - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java deleted file mode 100644 index 6b67c728..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -@Mapper -public interface GbStreamMapper extends BaseMapper { - - List selectAll(GbStream entity); - - Page selectAllByPage(Page page, GbStream entity); - - GbStream queryStreamInPlatform(@Param("platformId") String platformId, @Param("gbId") String gbId); - - List queryGbStreamListInPlatform(String platformId, @Param("usPushingAsStatus") boolean usPushingAsStatus); - - void batchDel(List streamProxyItemList); - - void batchDelForGbStream(List gbStreams); - - void batchAdd(@Param("subList") List subList); - - int updateStreamGPS(List gpsMsgInfos); - - List selectAllForAppAndStream(List streamPushItems); - - default void updateMediaServer(String app, String stream, String mediaServerId) { - this.update(null, Wrappers.lambdaUpdate() - .set(GbStream::getMediaServerId, mediaServerId) - .eq(GbStream::getApp, app) - .eq(GbStream::getStream, stream)); - } - - int updateGbIdOrName(List streamPushItemForUpdate); - - Boolean selectStatusForProxy(@Param("app") String app, @Param("stream") String stream); - - Boolean selectStatusForPush(@Param("app") String app, @Param("stream") String stream); - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerItemMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerItemMapper.java deleted file mode 100644 index 990bf80a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/MediaServerItemMapper.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import org.apache.ibatis.annotations.Mapper; - - -@Mapper -public interface MediaServerItemMapper extends BaseMapper { - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java deleted file mode 100644 index f99d38c4..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -/** - * 用于存储上级平台 - */ -@Mapper -public interface ParentPlatformMapper extends BaseMapper { - - List getParentPlatformList(); - - Page parentPlatformByPage(Page page, ParentPlatform entity); - - default ParentPlatform getParentPlatByServerGBId(String platformGbId) { - return selectOne(Wrappers.lambdaQuery().eq(ParentPlatform::getServerGBId, platformGbId)); - } - - default int updateParentPlatformStatus(@Param("platformGbID") String platformGbID, @Param("online") boolean online) { - return this.update(null, Wrappers.lambdaUpdate() - .set(ParentPlatform::isStatus, online) - .eq(ParentPlatform::getServerGBId, platformGbID)); - } - - List getChannelSource(@Param("platform_id") String platform_id, @Param("gbId") String gbId); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java deleted file mode 100644 index 1751676e..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -@Mapper -public interface PlatformCatalogMapper extends BaseMapper { - - int del(@Param("platformId") String platformId, @Param("id") String id); - - int delByPlatformId(@Param("platformId") String platformId); - - List selectByParentId(@Param("platformId") String platformId, @Param("parentId") String parentId); - - List selectByPlatForm(@Param("platformId") String platformId); - - PlatformCatalog selectDefaultByPlatFormId(@Param("platformId") String platformId); - - List queryCatalogInPlatform(@Param("platformId") String platformId); - - PlatformCatalog selectByPlatFormAndCatalogId(@Param("platformId") String platformId, @Param("id") String id); - - int deleteAll(String platformId, List ids); - - List queryCatalogFromParent(@Param("id") String id, @Param("platformId") String platformId); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java deleted file mode 100644 index 9d336cf5..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -@Mapper -public interface PlatformChannelMapper { - - /** - * 查询列表里已经关联的 - */ - List findChannelRelatedPlatform(@Param("platformId") String platformId, @Param("channelReduces") List channelReduces); - - int addChannels(@Param("platformId") String platformId, @Param("channelReducesToAdd") List channelReducesToAdd); - - int delChannelForGB(@Param("platformId") String platformId, @Param("channelReducesToDel") List channelReducesToDel); - - int delChannelForDeviceId(String deviceId); - - int cleanChannelForGB(String platformId); - - List queryChannelInParentPlatform(@Param("platformId") String platformId, @Param("channelId") String channelId); - - List queryAllChannelInCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId); - - List queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId); - - List queryVideoDeviceByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId); - - int delByCatalogId(@Param("platformId") String platformId, @Param("id") String id); - - int delByCatalogIdAndChannelIdAndPlatformId(PlatformCatalog platformCatalog); - - List queryPlatFormListForGBWithGBId(@Param("channelId") String channelId, @Param("platforms") List platforms); - - void delByPlatformId(String serverGBId); - - int delChannelForGBByCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId); - - List queryDeviceInfoByPlatformIdAndChannelId(@Param("platformId") String platformId, @Param("channelId") String channelId); - - List queryParentPlatformByChannelId(String channelId); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java deleted file mode 100644 index f02577e8..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; -import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -@Mapper -public interface PlatformGbStreamMapper extends BaseMapper { - - int batchAdd(List streamPushItems); - - int delByAppAndStream(@Param("app") String app, @Param("stream") String stream); - - int delByPlatformId(String platformId); - - List selectByAppAndStream(@Param("app") String app, @Param("stream") String stream); - - StreamProxyItem selectOne(@Param("app") String app, @Param("stream") String stream, @Param("platformId") String platformId); - - List queryChannelInParentPlatformAndCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId); - - List queryChannelInParentPlatformAndCatalogForCatalog(@Param("platformId") String platformId, @Param("catalogId") String catalogId); - - List queryPlatFormListForGBWithGBId(@Param("app") String app, @Param("stream") String stream, @Param("platforms") List platforms); - - void delByGbStreams(List gbStreams); - - void delByAppAndStreamsByPlatformId(@Param("gbStreams") List gbStreams, @Param("platformId") String platformId); - - int delByPlatformAndCatalogId(@Param("platformId") String platformId, @Param("catalogId") String catalogId); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java deleted file mode 100644 index 73cf3b46..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamProxyMapper.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -@Mapper -public interface StreamProxyMapper extends BaseMapper { - - Page listDetailByPage(Page page, StreamProxyItem entity); - - List selectForEnable(boolean enable); - - StreamProxyItem getByAppAndStream(@Param("app") String app, @Param("stream") String stream); - - List selectForEnableInMediaServer( @Param("id") String id, @Param("enable") boolean enable); - - List selectInMediaServer(String id); - - void updateStatusByMediaServerId(@Param("mediaServerId") String mediaServerId, @Param("status") boolean status); - - int updateStatus(@Param("app") String app, @Param("stream") String stream, @Param("status") boolean status); - - void deleteAutoRemoveItemByMediaServerId(String mediaServerId); - - List selectAutoRemoveItemByMediaServerId(String mediaServerId); - - ResourceBaseInfo getOverview(); - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java deleted file mode 100644 index db02af67..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; - -import java.util.List; - -@Mapper -public interface StreamPushMapper extends BaseMapper { - - int delAll(List streamPushItems); - - int delAllForGbStream(List gbStreams); - - Page selectAllForList(Page page, @Param("query") String query, @Param("pushing") Boolean pushing, @Param("mediaServerId") String mediaServerId); - - List selectAll(); - - StreamPushItem getByAppAndStream(@Param("app") String app, @Param("stream") String stream); - - int addAll(List streamPushItems); - - void deleteWithoutGBId(String mediaServerId); - - List selectAllByMediaServerIdWithOutGbID(String mediaServerId); - - int updatePushStatus(@Param("app") String app, @Param("stream") String stream, @Param("pushIng") boolean pushIng); - - void updateStatusByMediaServerId(@Param("mediaServerId") String mediaServerId, @Param("status") boolean status); - - List getOnlinePusherForGbInList(List offlineStreams); - - void offline(List offlineStreams); - - List getOfflinePusherForGbInList(List onlineStreams); - - void online(List onlineStreams); - - List getOnlinePusherForGb(); - - void setAllStreamOffline(); - - List getAllAppAndStream(); - - int getAllCount(); - - int getAllOnline(Boolean usePushingAsStatus); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/ChannelSourceInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/ChannelSourceInfo.java deleted file mode 100644 index e8b91e7c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/ChannelSourceInfo.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao.dto; - -public class ChannelSourceInfo { - private String name; - private int count; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public int getCount() { - return count; - } - - public void setCount(int count) { - this.count = count; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/PlatformRegisterInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/PlatformRegisterInfo.java deleted file mode 100644 index 16f66363..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/PlatformRegisterInfo.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao.dto; - -/** - * 平台发送注册/注销消息时缓存此消息 - * @author lin - */ -public class PlatformRegisterInfo { - - /** - * 平台Id - */ - private String platformId; - - /** - * 是否时注册,false为注销 - */ - private boolean register; - - public static PlatformRegisterInfo getInstance(String platformId, boolean register) { - PlatformRegisterInfo platformRegisterInfo = new PlatformRegisterInfo(); - platformRegisterInfo.setPlatformId(platformId); - platformRegisterInfo.setRegister(register); - return platformRegisterInfo; - } - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public boolean isRegister() { - return register; - } - - public void setRegister(boolean register) { - this.register = register; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/RecordInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/RecordInfo.java deleted file mode 100644 index 278e3e43..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/dao/dto/RecordInfo.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.genersoft.iot.vmp.storager.dao.dto; - -/** - * 录像记录 - */ -public class RecordInfo { - - /** - * ID - */ - private int id; - - /** - * 应用名 - */ - private String app; - - /** - * 流ID - */ - private String stream; - - /** - * 对应的zlm流媒体的ID - */ - private String mediaServerId; - - /** - * 创建时间 - */ - private String createTime; - - /** - * 类型 对应zlm的 originType - * unknown = 0, - * rtmp_push=1, - * rtsp_push=2, - * rtp_push=3, - * pull=4, - * ffmpeg_pull=5, - * mp4_vod=6, - * device_chn=7, - * rtc_push=8 - */ - private int type; - - /** - * 国标录像时的设备ID - */ - private String deviceId; - - /** - * 国标录像时的通道ID - */ - private String channelId; - - /** - * 拉流代理录像时的名称 - */ - private String name; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java deleted file mode 100644 index de8382a4..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ /dev/null @@ -1,579 +0,0 @@ -package com.genersoft.iot.vmp.storager.impl; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; -import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnStreamChangedHookParam; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; -import com.genersoft.iot.vmp.storager.dao.DeviceMapper; -import com.genersoft.iot.vmp.storager.dao.dto.PlatformRegisterInfo; -import com.genersoft.iot.vmp.utils.JsonUtil; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.StringRedisTemplate; -import org.springframework.stereotype.Component; - -import java.time.Duration; -import java.util.ArrayList; -import java.util.List; -import java.util.Objects; - -@SuppressWarnings("rawtypes") -@Component -public class RedisCatchStorageImpl implements IRedisCatchStorage { - - private final Logger logger = LoggerFactory.getLogger(RedisCatchStorageImpl.class); - - @Autowired - private DeviceChannelMapper deviceChannelMapper; - - @Autowired - private DeviceMapper deviceMapper; - - @Autowired - private UserSetting userSetting; - - @Autowired - private RedisTemplate redisTemplate; - - @Autowired - private StringRedisTemplate stringRedisTemplate; - - @Override - public Long getCSEQ() { - String key = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetting.getServerId(); - - Long result = redisTemplate.opsForValue().increment(key, 1L); - if (result != null && result > Integer.MAX_VALUE) { - redisTemplate.opsForValue().set(key, 1); - result = 1L; - } - return result; - } - - @Override - public Long getSN(String method) { - String key = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_" + method; - - Long result = redisTemplate.opsForValue().increment(key, 1L); - if (result != null && result > Integer.MAX_VALUE) { - redisTemplate.opsForValue().set(key, 1); - result = 1L; - } - return result; - } - - @Override - public void resetAllCSEQ() { - String scanKey = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetting.getServerId() + "_*"; - List keys = RedisUtil.scan(redisTemplate, scanKey); - for (Object o : keys) { - String key = (String) o; - redisTemplate.opsForValue().set(key, 1); - } - } - - @Override - public void resetAllSN() { - String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_*"; - List keys = RedisUtil.scan(redisTemplate, scanKey); - for (Object o : keys) { - String key = (String) o; - redisTemplate.opsForValue().set(key, 1); - } - } - - @Override - public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) { - String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + parentPlatformCatch.getId(); - redisTemplate.opsForValue().set(key, parentPlatformCatch); - } - - @Override - public ParentPlatformCatch queryPlatformCatchInfo(String platformGbId) { - return (ParentPlatformCatch)redisTemplate.opsForValue().get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId); - } - - @Override - public void delPlatformCatchInfo(String platformGbId) { - redisTemplate.delete(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId); - } - - @Override - public void delPlatformKeepalive(String platformGbId) { - redisTemplate.delete(VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + platformGbId); - } - - @Override - public void delPlatformRegister(String platformGbId) { - redisTemplate.delete(VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_" + platformGbId); - } - - - @Override - public void updatePlatformRegisterInfo(String callId, PlatformRegisterInfo platformRegisterInfo) { - String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId; - Duration duration = Duration.ofSeconds(30L); - redisTemplate.opsForValue().set(key, platformRegisterInfo, duration); - } - - - @Override - public PlatformRegisterInfo queryPlatformRegisterInfo(String callId) { - return (PlatformRegisterInfo)redisTemplate.opsForValue().get(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId); - } - - @Override - public void delPlatformRegisterInfo(String callId) { - redisTemplate.delete(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId); - } - - @Override - public void updateSendRTPSever(SendRtpItem sendRtpItem) { - - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + - userSetting.getServerId() + "_" - + sendRtpItem.getMediaServerId() + "_" - + sendRtpItem.getPlatformId() + "_" - + sendRtpItem.getChannelId() + "_" - + sendRtpItem.getStreamId() + "_" - + sendRtpItem.getCallId(); - redisTemplate.opsForValue().set(key, sendRtpItem); - } - - @Override - public SendRtpItem querySendRTPServer(String platformGbId, String channelId, String streamId, String callId) { - if (platformGbId == null) { - platformGbId = "*"; - } - if (channelId == null) { - channelId = "*"; - } - if (streamId == null) { - streamId = "*"; - } - if (callId == null) { - callId = "*"; - } - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*_" - + platformGbId + "_" - + channelId + "_" - + streamId + "_" - + callId; - List scan = RedisUtil.scan(redisTemplate, key); - if (scan.size() > 0) { - return (SendRtpItem)redisTemplate.opsForValue().get(scan.get(0)); - }else { - return null; - } - } - - @Override - public List querySendRTPServerByChnnelId(String channelId) { - if (channelId == null) { - return null; - } - String platformGbId = "*"; - String callId = "*"; - String streamId = "*"; - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*_" - + platformGbId + "_" - + channelId + "_" - + streamId + "_" - + callId; - List scan = RedisUtil.scan(redisTemplate, key); - List result = new ArrayList<>(); - for (Object o : scan) { - result.add((SendRtpItem) redisTemplate.opsForValue().get(o)); - } - return result; - } - - @Override - public List querySendRTPServerByStream(String stream) { - if (stream == null) { - return null; - } - String platformGbId = "*"; - String callId = "*"; - String channelId = "*"; - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*_" - + platformGbId + "_" - + channelId + "_" - + stream + "_" - + callId; - List scan = RedisUtil.scan(redisTemplate, key); - List result = new ArrayList<>(); - for (Object o : scan) { - result.add((SendRtpItem) redisTemplate.opsForValue().get(o)); - } - return result; - } - - @Override - public List querySendRTPServer(String platformGbId) { - if (platformGbId == null) { - platformGbId = "*"; - } - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*_" - + platformGbId + "_*" + "_*" + "_*"; - List queryResult = RedisUtil.scan(redisTemplate, key); - List result= new ArrayList<>(); - - for (Object o : queryResult) { - String keyItem = (String) o; - result.add((SendRtpItem) redisTemplate.opsForValue().get(keyItem)); - } - - return result; - } - - /** - * 删除RTP推送信息缓存 - */ - @Override - public void deleteSendRTPServer(String platformGbId, String channelId, String callId, String streamId) { - if (streamId == null) { - streamId = "*"; - } - if (callId == null) { - callId = "*"; - } - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*_" - + platformGbId + "_" - + channelId + "_" - + streamId + "_" - + callId; - List scan = RedisUtil.scan(redisTemplate, key); - if (scan.size() > 0) { - for (Object keyStr : scan) { - redisTemplate.delete(keyStr); - } - } - } - - @Override - public List queryAllSendRTPServer() { - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*"; - List queryResult = RedisUtil.scan(redisTemplate, key); - List result= new ArrayList<>(); - - for (Object o : queryResult) { - String keyItem = (String) o; - result.add((SendRtpItem) redisTemplate.opsForValue().get(keyItem)); - } - - return result; - } - - /** - * 查询某个通道是否存在上级点播(RTP推送) - */ - @Override - public boolean isChannelSendingRTP(String channelId) { - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*_*_" - + channelId + "*_" + "*_"; - List RtpStreams = RedisUtil.scan(redisTemplate, key); - return RtpStreams.size() > 0; - } - - @Override - public void updateWVPInfo(JSONObject jsonObject, int time) { - String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId(); - Duration duration = Duration.ofSeconds(time); - redisTemplate.opsForValue().set(key, jsonObject, duration); - } - - @Override - public void sendStreamChangeMsg(String type, JSONObject jsonObject) { - String key = VideoManagerConstants.WVP_MSG_STREAM_CHANGE_PREFIX + type; - logger.info("[redis 流变化事件] 发送 {}: {}", key, jsonObject.toString()); - redisTemplate.convertAndSend(key, jsonObject); - } - - @Override - public void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, OnStreamChangedHookParam onStreamChangedHookParam) { - // 查找是否使用了callID - StreamAuthorityInfo streamAuthorityInfo = getStreamAuthorityInfo(app, streamId); - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId(); - if (streamAuthorityInfo != null) { - onStreamChangedHookParam.setCallId(streamAuthorityInfo.getCallId()); - } - redisTemplate.opsForValue().set(key, onStreamChangedHookParam); - } - - @Override - public void removeStream(String mediaServerId, String type, String app, String streamId) { - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerId; - redisTemplate.delete(key); - } - - @Override - public void removeStream(String mediaServerId, String type) { - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId; - List streams = RedisUtil.scan(redisTemplate, key); - for (Object stream : streams) { - redisTemplate.delete(stream); - } - } - - @Override - public List getStreams(String mediaServerId, String type) { - List result = new ArrayList<>(); - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId; - List streams = RedisUtil.scan(redisTemplate, key); - for (Object stream : streams) { - OnStreamChangedHookParam onStreamChangedHookParam = (OnStreamChangedHookParam)redisTemplate.opsForValue().get(stream); - result.add(onStreamChangedHookParam); - } - return result; - } - - @Override - public void updateDevice(Device device) { - String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + device.getDeviceId(); - redisTemplate.opsForValue().set(key, device); - } - - @Override - public void removeDevice(String deviceId) { - String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId; - redisTemplate.delete(key); - } - - @Override - public void removeAllDevice() { - String scanKey = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_*"; - List keys = RedisUtil.scan(redisTemplate, scanKey); - for (Object key : keys) { - redisTemplate.delete(key); - } - } - - @Override - public List getAllDevices() { - String scanKey = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_*"; - List result = new ArrayList<>(); - List keys = RedisUtil.scan(redisTemplate, scanKey); - for (Object o : keys) { - String key = (String) o; - Device device = JsonUtil.redisJsonToObject(redisTemplate, key, Device.class); - if (Objects.nonNull(device)) { - // 只取没有存过得 - result.add(JsonUtil.redisJsonToObject(redisTemplate, key, Device.class)); - } - } - - return result; - } - - @Override - public Device getDevice(String deviceId) { - String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId; - Device device = JsonUtil.redisJsonToObject(redisTemplate, key, Device.class); - if (device == null){ - device = deviceMapper.getDeviceByDeviceId(deviceId); - if (device != null) { - updateDevice(device); - } - } - return device; - } - - @Override - public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) { - String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gpsMsgInfo.getId(); - Duration duration = Duration.ofSeconds(60L); - redisTemplate.opsForValue().set(key, gpsMsgInfo, duration); - // 默认GPS消息保存1分钟 - } - - @Override - public GPSMsgInfo getGpsMsgInfo(String gbId) { - String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gbId; - return JsonUtil.redisJsonToObject(redisTemplate, key, GPSMsgInfo.class); - } - - @Override - public List getAllGpsMsgInfo() { - String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_*"; - List result = new ArrayList<>(); - List keys = RedisUtil.scan(redisTemplate, scanKey); - for (Object o : keys) { - String key = (String) o; - GPSMsgInfo gpsMsgInfo = JsonUtil.redisJsonToObject(redisTemplate, key, GPSMsgInfo.class); - if (Objects.nonNull(gpsMsgInfo) && !gpsMsgInfo.isStored()) { // 只取没有存过得 - result.add(JsonUtil.redisJsonToObject(redisTemplate, key, GPSMsgInfo.class)); - } - } - - return result; - } - - @Override - public void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo) { - String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream; - redisTemplate.opsForValue().set(key, streamAuthorityInfo); - } - - @Override - public void removeStreamAuthorityInfo(String app, String stream) { - String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ; - redisTemplate.delete(key); - } - - @Override - public StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream) { - String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ; - return JsonUtil.redisJsonToObject(redisTemplate, key, StreamAuthorityInfo.class); - - } - - @Override - public List getAllStreamAuthorityInfo() { - String scanKey = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_*_*" ; - List result = new ArrayList<>(); - List keys = RedisUtil.scan(redisTemplate, scanKey); - for (Object o : keys) { - String key = (String) o; - result.add(JsonUtil.redisJsonToObject(redisTemplate, key, StreamAuthorityInfo.class)); - } - return result; - } - - - @Override - public OnStreamChangedHookParam getStreamInfo(String app, String streamId, String mediaServerId) { - String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId; - - OnStreamChangedHookParam result = null; - List keys = RedisUtil.scan(redisTemplate, scanKey); - if (keys.size() > 0) { - String key = (String) keys.get(0); - result = JsonUtil.redisJsonToObject(redisTemplate, key, OnStreamChangedHookParam.class); - } - - return result; - } - - @Override - public void sendMobilePositionMsg(JSONObject jsonObject) { - String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_MOBILE_POSITION; - logger.info("[redis发送通知] 发送 移动位置 {}: {}", key, jsonObject.toString()); - redisTemplate.convertAndSend(key, jsonObject); - } - - @Override - public void sendStreamPushRequestedMsg(MessageForPushChannel msg) { - String key = VideoManagerConstants.VM_MSG_STREAM_PUSH_REQUESTED; - logger.info("[redis发送通知] 发送 推流被请求 {}: {}/{}", key, msg.getApp(), msg.getStream()); - redisTemplate.convertAndSend(key, JSON.toJSON(msg)); - } - - @Override - public void sendAlarmMsg(AlarmChannelMessage msg) { - // 此消息用于对接第三方服务下级来的消息内容 - String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM; - logger.info("[redis发送通知] 发送 报警{}: {}", key, JSON.toJSON(msg)); - redisTemplate.convertAndSend(key, JSON.toJSON(msg)); - } - - @Override - public boolean deviceIsOnline(String deviceId) { - return getDevice(deviceId).isOnLine(); - } - - - @Override - public void sendStreamPushRequestedMsgForStatus() { - String key = VideoManagerConstants.VM_MSG_GET_ALL_ONLINE_REQUESTED; - logger.info("[redis通知] 发送 获取所有推流设备的状态"); - JSONObject jsonObject = new JSONObject(); - jsonObject.put(key, key); - redisTemplate.convertAndSend(key, jsonObject); - } - - @Override - public int getPushStreamCount(String id) { - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_PUSH_*_*_" + id; - return RedisUtil.scan(redisTemplate, key).size(); - } - - @Override - public int getProxyStreamCount(String id) { - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_PULL_*_*_" + id; - return RedisUtil.scan(redisTemplate, key).size(); - } - - @Override - public int getGbSendCount(String id) { - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX - + userSetting.getServerId() + "_*_" + id + "_*"; - return RedisUtil.scan(redisTemplate, key).size(); - } - - @Override - public void sendDeviceOrChannelStatus(String deviceId, String channelId, boolean online) { - String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_DEVICE_STATUS; - logger.info("[redis通知] 发送 推送设备/通道状态, {}/{}-{}", deviceId, channelId, online); - StringBuilder msg = new StringBuilder(); - msg.append(deviceId); - if (channelId != null) { - msg.append(":").append(channelId); - } - msg.append(" ").append(online? "ON":"OFF"); - logger.info("[redis通知] 推送状态-> {} ", msg); - // 使用 RedisTemplate 发送字符串消息会导致发送的消息多带了双引号 - stringRedisTemplate.convertAndSend(key, msg.toString()); - } - - @Override - public void sendChannelAddOrDelete(String deviceId, String channelId, boolean add) { - String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_DEVICE_STATUS; - - - StringBuilder msg = new StringBuilder(); - msg.append(deviceId); - if (channelId != null) { - msg.append(":").append(channelId); - } - msg.append(" ").append(add? "ADD":"DELETE"); - logger.info("[redis通知] 推送通道-> {}", msg); - // 使用 RedisTemplate 发送字符串消息会导致发送的消息多带了双引号 - stringRedisTemplate.convertAndSend(key, msg.toString()); - } - - @Override - public void sendPlatformStartPlayMsg(MessageForPushChannel msg) { - String key = VideoManagerConstants.VM_MSG_STREAM_START_PLAY_NOTIFY; - logger.info("[redis发送通知] 发送 推流被上级平台观看 {}: {}/{}->{}", key, msg.getApp(), msg.getStream(), msg.getPlatFormId()); - redisTemplate.convertAndSend(key, JSON.toJSON(msg)); - } - - @Override - public void sendPlatformStopPlayMsg(MessageForPushChannel msg) { - String key = VideoManagerConstants.VM_MSG_STREAM_STOP_PLAY_NOTIFY; - logger.info("[redis发送通知] 发送 上级平台停止观看 {}: {}/{}->{}", key, msg.getApp(), msg.getStream(), msg.getPlatFormId()); - redisTemplate.convertAndSend(key, JSON.toJSON(msg)); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java deleted file mode 100644 index fbedf1d9..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ /dev/null @@ -1,1066 +0,0 @@ -package com.genersoft.iot.vmp.storager.impl; - -import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.*; -import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; -import com.genersoft.iot.vmp.service.*; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.storager.dao.*; -import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.stereotype.Component; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; -import org.springframework.transaction.annotation.Transactional; -import org.springframework.util.CollectionUtils; -import org.springframework.util.ObjectUtils; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -/** - * 视频设备数据存储-jdbc实现 - * swwheihei - * 2020年5月6日 下午2:31:42 - */ -@SuppressWarnings("rawtypes") -@Component -public class VideoManagerStorageImpl implements IVideoManagerStorage { - - private final Logger logger = LoggerFactory.getLogger(VideoManagerStorageImpl.class); - - @Autowired - EventPublisher eventPublisher; - - @Autowired - SipConfig sipConfig; - - @Autowired - TransactionDefinition transactionDefinition; - - @Autowired - DataSourceTransactionManager dataSourceTransactionManager; - -// @Autowired -// private DeviceMapper deviceMapper; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private DeviceChannelMapper deviceChannelMapper; - - @Autowired - private IDeviceChannelService deviceChannelService; - - @Autowired - private DeviceMobilePositionMapper deviceMobilePositionMapper; - - @Autowired - private ParentPlatformMapper platformMapper; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private PlatformChannelMapper platformChannelMapper; - - @Autowired - private PlatformCatalogMapper platformCatalogMapper; - - @Autowired - private StreamProxyMapper streamProxyMapper; - - @Autowired - private IStreamProxyService streamProxyService; - - @Autowired - private StreamPushMapper streamPushMapper; - - @Autowired - private IStreamPushService streamPushService; - - @Autowired - private GbStreamMapper gbStreamMapper; - - @Autowired - private UserSetting userSetting; - - @Autowired - private PlatformCatalogMapper catalogMapper; - - @Autowired - private PlatformGbStreamMapper platformGbStreamMapper; - - @Autowired - private IGbStreamService gbStreamService; - - @Autowired - private ParentPlatformMapper parentPlatformMapper; - - /** - * 根据设备ID判断设备是否存在 - * - * @param deviceId 设备ID - * @return true:存在 false:不存在 - */ - @Override - public boolean exists(String deviceId) { - return deviceService.getDeviceMapper().getDeviceByDeviceId(deviceId) != null; - } - - @Override - @Transactional - public boolean resetChannels(String deviceId, List deviceChannelList) { - if (CollectionUtils.isEmpty(deviceChannelList)) { - return false; - } - - List allChannels = deviceChannelService.selectChannelsByDeviceId(deviceId); - Map allChannelMap = Optional.ofNullable(allChannels).orElse(Collections.emptyList()) - .stream().collect(Collectors.toConcurrentMap(DeviceChannel::getChannelId, Function.identity())); - - // 数据去重 - List channels = new ArrayList<>(); - - List updateChannels = new ArrayList<>(); - List addChannels = new ArrayList<>(); - StringBuilder stringBuilder = new StringBuilder(); - Map subContMap = new HashMap<>(); - - String now = DateUtil.getNow(); - - // 数据去重 - Set gbIdSet = new HashSet<>(); - for (DeviceChannel deviceChannel : deviceChannelList) { - if (gbIdSet.contains(deviceChannel.getChannelId())) { - stringBuilder.append(deviceChannel.getChannelId()).append(","); - continue; - } - gbIdSet.add(deviceChannel.getChannelId()); - DeviceChannel existsChannel = allChannelMap.get(deviceChannel.getChannelId()); - if (existsChannel != null) { - - deviceChannel.setUpdateTime(now); - deviceChannel.setId(existsChannel.getId()); - deviceChannel.setName(existsChannel.getName()); - deviceChannel.setHasAudio(existsChannel.isHasAudio()); - deviceChannel.setStreamId(existsChannel.getStreamId()); - - if (!existsChannel.isStatus().equals(deviceChannel.isStatus())){ - List strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId()); - if (!CollectionUtils.isEmpty(strings)){ - strings.forEach(platformId->{ - eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.isStatus()?CatalogEvent.ON:CatalogEvent.OFF); - }); - } - } - - updateChannels.add(deviceChannel); - }else { - deviceChannel.setCreateTime(now); - deviceChannel.setUpdateTime(now); - addChannels.add(deviceChannel); - } - allChannelMap.remove(deviceChannel.getChannelId()); - channels.add(deviceChannel); - if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { - if (subContMap.get(deviceChannel.getParentId()) == null) { - subContMap.put(deviceChannel.getParentId(), 1); - }else { - Integer count = subContMap.get(deviceChannel.getParentId()); - subContMap.put(deviceChannel.getParentId(), count++); - } - } - } - - if (!channels.isEmpty()) { - for (DeviceChannel channel : channels) { - if (subContMap.get(channel.getChannelId()) != null){ - Integer count = subContMap.get(channel.getChannelId()); - if (count > 0) { - channel.setSubCount(count); - channel.setParental(1); - } - } - } - } - - if (stringBuilder.length() > 0) { - logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder); - } - if(CollectionUtils.isEmpty(channels)){ - logger.info("通道重设,数据为空={}" , deviceChannelList); - return false; - } - - if (!addChannels.isEmpty()) { - deviceChannelService.saveBatch(addChannels); - } - - if (!updateChannels.isEmpty()) { - deviceChannelService.saveOrUpdateBatch(updateChannels); - } - - if (!allChannelMap.isEmpty()) { - List collect = allChannelMap.values().stream() - .map(DeviceChannel::getId).collect(Collectors.toList()); - deviceChannelService.removeByIds(collect); - } - - return true; - } - - - @Override - @Transactional - public boolean updateChannels(String deviceId, List deviceChannelList) { - if (CollectionUtils.isEmpty(deviceChannelList)) { - return false; - } - - String now = DateUtil.getNow(); - List allChannels = deviceChannelService.selectChannelsByDeviceId(deviceId); - Map allChannelMap = new ConcurrentHashMap<>(); - if (allChannels.size() > 0) { - for (DeviceChannel deviceChannel : allChannels) { - allChannelMap.put(deviceChannel.getChannelId(), deviceChannel); - } - } - - // 数据去重 - List channels = new ArrayList<>(); - - List updateChannels = new ArrayList<>(); - List addChannels = new ArrayList<>(); - StringBuilder stringBuilder = new StringBuilder(); - Map subContMap = new HashMap<>(); - if (deviceChannelList.size() > 0) { - // 数据去重 - Set gbIdSet = new HashSet<>(); - for (DeviceChannel deviceChannel : deviceChannelList) { - if (!gbIdSet.contains(deviceChannel.getChannelId())) { - gbIdSet.add(deviceChannel.getChannelId()); - deviceChannel.setUpdateTime(now); - DeviceChannel existsChannel = allChannelMap.get(deviceChannel.getChannelId()); - if (existsChannel != null) { - deviceChannel.setId(existsChannel.getId()); - deviceChannel.setName(existsChannel.getName()); - deviceChannel.setStreamId(existsChannel.getStreamId()); - deviceChannel.setHasAudio(existsChannel.isHasAudio()); - if (!existsChannel.isStatus().equals(deviceChannel.isStatus())){ - List strings = platformChannelMapper.queryParentPlatformByChannelId(deviceChannel.getChannelId()); - if (!CollectionUtils.isEmpty(strings)){ - strings.forEach(platformId->{ - eventPublisher.catalogEventPublish(platformId, deviceChannel, deviceChannel.isStatus()?CatalogEvent.ON:CatalogEvent.OFF); - }); - } - } - updateChannels.add(deviceChannel); - }else { - deviceChannel.setCreateTime(now); - addChannels.add(deviceChannel); - } - - channels.add(deviceChannel); - if (!ObjectUtils.isEmpty(deviceChannel.getParentId())) { - if (subContMap.get(deviceChannel.getParentId()) == null) { - subContMap.put(deviceChannel.getParentId(), 1); - }else { - Integer count = subContMap.get(deviceChannel.getParentId()); - subContMap.put(deviceChannel.getParentId(), count++); - } - } - }else { - stringBuilder.append(deviceChannel.getChannelId()).append(","); - } - } - - if (channels.size() > 0) { - for (DeviceChannel channel : channels) { - if (subContMap.get(channel.getChannelId()) != null){ - channel.setSubCount(subContMap.get(channel.getChannelId())); - } - } - } - - } - if (stringBuilder.length() > 0) { - logger.info("[目录查询]收到的数据存在重复: {}" , stringBuilder); - } - if(CollectionUtils.isEmpty(channels)){ - logger.info("通道重设,数据为空={}" , deviceChannelList); - return false; - } - - if (addChannels.size() > 0) { - deviceChannelService.saveBatch(addChannels); - } - - if (updateChannels.size() > 0) { - deviceChannelService.saveOrUpdateBatch(updateChannels); - } - - return true; - } - - @Override - public void deviceChannelOnline(String deviceId, String channelId) { - deviceChannelMapper.update(null, Wrappers.lambdaUpdate() - .set(DeviceChannel::isStatus, true) - .eq(DeviceChannel::getDeviceId, deviceId) - .eq(DeviceChannel::getChannelId, channelId)); - } - - @Override - public void deviceChannelOffline(String deviceId, String channelId) { - deviceChannelMapper.update(null, Wrappers.lambdaUpdate() - .set(DeviceChannel::isStatus, false) - .eq(DeviceChannel::getDeviceId, deviceId) - .eq(DeviceChannel::getChannelId, channelId)); - } - - @Override - public void startPlay(String deviceId, String channelId, String streamId) { - deviceChannelMapper.startPlay(deviceId, channelId, streamId); - } - - @Override - public void stopPlay(String deviceId, String channelId) { - deviceChannelMapper.stopPlay(deviceId, channelId); - } - - /** - * 获取设备 - * - * @param deviceId 设备ID - * @return Device 设备对象 - */ - @Override - public Device queryVideoDevice(String deviceId) { - return deviceService.getDeviceMapper().getDeviceByDeviceId(deviceId); - } - - @Override - public Page queryChannelsByDeviceId(Page page, String deviceId, String query, Boolean hasSubChannel, Boolean online, Boolean catalogUnderDevice) { - // 获取到所有正在播放的流 - if (catalogUnderDevice != null && catalogUnderDevice) { -// all = deviceChannelMapper.queryChannels(deviceId, deviceId, query, hasSubChannel, online,null); -// // 海康设备的parentId是SIP id -// List deviceChannels = deviceChannelMapper.queryChannels(deviceId, sipConfig.getId(), query, hasSubChannel, online,null); -// all.addAll(deviceChannels); - // 海康设备的parentId是SIP id - deviceChannelMapper.queryChannelsByPage(page, deviceId, sipConfig.getId(), query, hasSubChannel, online); - }else { - deviceChannelMapper.queryChannelsByPage(page, deviceId, null, query, hasSubChannel, online); - } - - return page; - } - - @Override - public List queryChannelsByDeviceIdWithStartAndLimit(String deviceId, List channelIds, String query, Boolean hasSubChannel, Boolean online, int start, int limit) { - return deviceChannelMapper.queryChannelsByDeviceIdWithStartAndLimit(deviceId, channelIds, null, query, hasSubChannel, online, start, limit); - } - - - @Override - public List queryChannelsByDeviceId(String deviceId,Boolean online,List channelIds) { - return deviceChannelMapper.queryChannels(deviceId, null,null, null, online,channelIds); - } - - @Override - public List queryChannelsByDeviceId(String deviceId, List channelIds, Boolean online) { - return deviceChannelMapper.queryChannelsWithDeviceInfo(deviceId, null,null, null, online,channelIds); - } - - @Override - public Page querySubChannels(Page page, String deviceId, String parentChannelId, String query, Boolean hasSubChannel, Boolean online) { - return deviceChannelMapper.queryChannelsByPage(page, deviceId, parentChannelId, query, hasSubChannel, online); - } - - @Override - public DeviceChannel queryChannel(String deviceId, String channelId) { - return deviceChannelMapper.selectOne(Wrappers.lambdaQuery() - .eq(DeviceChannel::getDeviceId, deviceId) - .eq(DeviceChannel::getChannelId, channelId)); - } - - - @Override - public int delChannel(String deviceId, String channelId) { - return deviceChannelMapper.delete(Wrappers.lambdaQuery() - .eq(DeviceChannel::getDeviceId, deviceId) - .eq(DeviceChannel::getChannelId, channelId)); - } - - /** - * 获取多个设备 - * - * @param page 当前页数 - * @param online 每页数量 - * @return Page 分页设备对象数组 - */ - @Override - public Page queryVideoDeviceList(Page page, Boolean online) { - return deviceService.getDeviceMapper().getDevices(page, online); - } - - /** - * 清空通道 - * @param deviceId - */ - @Override - public void cleanChannelsForDevice(String deviceId) { - deviceChannelMapper.cleanChannelsByDeviceId(deviceId); - } - - /** - * 添加Mobile Position设备移动位置 - * @param mobilePosition - */ - @Override - public synchronized boolean insertMobilePosition(MobilePosition mobilePosition) { - return deviceMobilePositionMapper.insert(mobilePosition) > 0; - } - - /** - * 查询移动位置轨迹 - * @param deviceId - * @param startTime - * @param endTime - */ - @Override - public synchronized List queryMobilePositions(String deviceId, String channelId, String startTime, String endTime) { - return deviceMobilePositionMapper.selectList(Wrappers.lambdaQuery() - .eq(MobilePosition::getDeviceId, deviceId) - .eq(StrUtil.isNotBlank(channelId), MobilePosition::getChannelId, channelId) - .ge(StrUtil.isNotBlank(startTime), MobilePosition::getTime, startTime) - .le(StrUtil.isNotBlank(endTime), MobilePosition::getTime, endTime) - .orderByAsc(MobilePosition::getTime)); - } - - @Override - public boolean addParentPlatform(ParentPlatform parentPlatform) { - if (parentPlatform.getCatalogId() == null) { - parentPlatform.setCatalogId(parentPlatform.getServerGBId()); - } - - return platformMapper.insert(parentPlatform) > 0; - } - - @Override - public boolean updateParentPlatform(ParentPlatform parentPlatform) { - int result = 0; - if (parentPlatform.getCatalogGroup() == 0) { - parentPlatform.setCatalogGroup(1); - } - if (parentPlatform.getAdministrativeDivision() == null) { - parentPlatform.setAdministrativeDivision(parentPlatform.getAdministrativeDivision()); - } - ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId()); - if (parentPlatform.getId() == null ) { - if (parentPlatform.getCatalogId() == null) { - parentPlatform.setCatalogId(parentPlatform.getServerGBId()); - } - - result = platformMapper.insert(parentPlatform); - if (parentPlatformCatch == null) { - parentPlatformCatch = new ParentPlatformCatch(); - parentPlatformCatch.setParentPlatform(parentPlatform); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - } - }else { - if (parentPlatformCatch == null) { // serverGBId 已变化 - ParentPlatform parentPlatById = platformMapper.selectById(parentPlatform.getId()); - // 使用旧的查出缓存ID - parentPlatformCatch = new ParentPlatformCatch(); - parentPlatformCatch.setId(parentPlatform.getServerGBId()); - redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId()); - } - - result = platformMapper.updateById(parentPlatform); - } - // 更新缓存 - parentPlatformCatch.setParentPlatform(parentPlatform); - redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - - return result > 0; - } - - @Transactional - @Override - public boolean deleteParentPlatform(ParentPlatform parentPlatform) { - int result = platformMapper.delete(Wrappers.lambdaQuery() - .eq(ParentPlatform::getServerGBId, parentPlatform.getServerGBId())); - - // 删除关联的通道 - platformChannelMapper.cleanChannelForGB(parentPlatform.getServerGBId()); - return result > 0; - } - - @Override - public ParentPlatform queryParentPlatByServerGBId(String platformGbId) { - return platformMapper.getParentPlatByServerGBId(platformGbId); - } - - @Override - public List queryEnableParentPlatformList(boolean enable) { - return platformMapper.selectList(Wrappers.lambdaQuery().eq(ParentPlatform::isEnable, enable)); - } - - @Override - public List queryEnablePlatformListWithAsMessageChannel() { - return platformMapper.selectList(Wrappers.lambdaQuery() - .eq(ParentPlatform::isEnable, true) - .eq(ParentPlatform::isAsMessageChannel, true)); - } - - @Override - public List queryDeviceWithAsMessageChannel() { - return deviceService.getDeviceMapper().selectList(Wrappers.lambdaQuery().eq(Device::isAsMessageChannel, true)); - } - - @Override - public void outlineForAllParentPlatform() { - platformMapper.update(null, Wrappers.lambdaUpdate().eq(ParentPlatform::isStatus, false)); - } - - - @Override - public Page queryAllChannelList(Page page, String query, Boolean online, Boolean channelType, String platformId, String catalogId) { - return deviceChannelMapper.queryChannelListByPage(page, query, online, channelType, platformId, catalogId); - } - - @Override - public List queryChannelListInParentPlatform(String platformId) { - - return deviceChannelMapper.queryChannelByPlatformId(platformId); - } - - - @Override - public int delChannelForGB(String platformId, List channelReduces) { - - int result = platformChannelMapper.delChannelForGB(platformId, channelReduces); - List deviceChannelList = new ArrayList<>(); - for (ChannelReduce channelReduce : channelReduces) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(channelReduce.getChannelId()); - deviceChannelList.add(deviceChannel); - } - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); - return result; - } - - @Override - public DeviceChannel queryChannelInParentPlatform(String platformId, String channelId) { - List channels = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId); - if (channels.size() > 1) { - // 出现长度大于0的时候肯定是国标通道的ID重复了 - logger.warn("国标ID存在重复:{}", channelId); - } - if (channels.size() == 0) { - return null; - }else { - return channels.get(0); - } - } - - @Override - public List queryChannelInParentPlatformAndCatalog(String platformId, String catalogId) { - List catalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId); - return catalogs; - } - - @Override - public List queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) { - List catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatalog(platformId, catalogId); - return catalogs; - } - - @Override - public Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId) { - List devices = platformChannelMapper.queryVideoDeviceByPlatformIdAndChannelId(platformId, channelId); - if (devices.size() > 1) { - // 出现长度大于0的时候肯定是国标通道的ID重复了 - logger.warn("国标ID存在重复:{}", channelId); - } - if (devices.size() == 0) { - return null; - }else { - return devices.get(0); - } - - - } - - @Override - public Device queryDeviceInfoByPlatformIdAndChannelId(String platformId, String channelId) { - List devices = platformChannelMapper.queryDeviceInfoByPlatformIdAndChannelId(platformId, channelId); - if (devices.size() > 1) { - // 出现长度大于0的时候肯定是国标通道的ID重复了 - logger.warn("国标ID存在重复:{}", channelId); - } - if (devices.size() == 0) { - return null; - }else { - return devices.get(0); - } - } - - /** - * 查询最新移动位置 - * @param deviceId - */ - @Override - public MobilePosition queryLatestPosition(String deviceId) { - return deviceMobilePositionMapper.selectOne(Wrappers.lambdaQuery() - .eq(MobilePosition::getDeviceId, deviceId) - .orderByDesc(MobilePosition::getTime).last("limit 1")); - } - - /** - * 删除指定设备的所有移动位置 - * @param deviceId - */ - @Override - public int clearMobilePositionsByDeviceId(String deviceId) { - return deviceMobilePositionMapper.delete(Wrappers.lambdaQuery().eq(MobilePosition::getDeviceId, deviceId)); - } - - - /** - * 移除代理流 - * @param app - * @param stream - * @return - */ - @Override - public int deleteStreamProxy(String app, String stream) { - return streamProxyService.deleteByAppAndStream(app, stream); - } - - /** - * 根据是否启用获取代理流列表 - * @param enable - * @return - */ - @Override - public List getStreamProxyListForEnable(boolean enable) { - return streamProxyMapper.selectForEnable(enable); - } - - /** - * 分页查询代理流列表 - * @param page - * @return - */ - @Override - public Page queryStreamProxyList(Page page, StreamProxyItem entity) { - return streamProxyMapper.listDetailByPage(page, entity); - } - - /** - * 根据国标ID获取平台关联的直播流 - * @param platformId - * @param gbId - * @return - */ - @Override - public GbStream queryStreamInParentPlatform(String platformId, String gbId) { - return gbStreamMapper.queryStreamInPlatform(platformId, gbId); - } - - /** - * 获取平台关联的直播流 - * @param platformId - * @return - */ - @Override - public List queryGbStreamListInPlatform(String platformId) { - return gbStreamMapper.queryGbStreamListInPlatform(platformId, userSetting.isUsePushingAsStatus()); - } - - /** - * 按照是app和stream获取代理流 - * @param app - * @param stream - * @return - */ - @Override - public StreamProxyItem queryStreamProxy(String app, String stream){ - return streamProxyMapper.getByAppAndStream(app, stream); - } - - @Override - public int removeMedia(String app, String stream) { - return streamPushService.getBaseMapper().delete(Wrappers.lambdaQuery() - .eq(StreamPushItem::getApp, app) - .eq(StreamPushItem::getStream, stream)); - } - - @Override - public int mediaOffline(String app, String stream) { - GbStream gbStream = gbStreamService.selectByAppAndStream(app, stream); - int result; - if ("proxy".equals(gbStream.getStreamType())) { - result = streamProxyMapper.updateStatus(app, stream, false); - }else { - result = streamPushMapper.updatePushStatus(app, stream, false); - } - return result; - } - - @Override - public int mediaOnline(String app, String stream) { - GbStream gbStream = gbStreamService.selectByAppAndStream(app, stream); - int result; - if ("proxy".equals(gbStream.getStreamType())) { - result = streamProxyMapper.updateStatus(app, stream, true); - }else { - result = streamPushMapper.updatePushStatus(app, stream, true); - } - return result; - } - - @Override - public void updateParentPlatformStatus(String platformGbID, boolean online) { - platformMapper.updateParentPlatformStatus(platformGbID, online); - } - - @Override - public List getStreamProxyListForEnableInMediaServer(String id, boolean enable) { - return streamProxyMapper.selectForEnableInMediaServer(id, enable); - } - - - @Override - public Device queryVideoDeviceByChannelId( String channelId) { - Device result = null; - List channelList = deviceChannelService.list(Wrappers.lambdaQuery() - .eq(DeviceChannel::getChannelId, channelId)).getData(); - if (channelList.size() == 1) { - result = deviceService.getDeviceMapper().getDeviceByDeviceId(channelList.get(0).getDeviceId()); - } - return result; - } - - @Override - public StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId) { - return streamProxyMapper.getByAppAndStream(app, streamId); - } - - @Override - public List getChildrenCatalogByPlatform(String platformId, String parentId) { - return catalogMapper.selectByParentId(platformId, parentId); - } - - @Override - public int addCatalog(PlatformCatalog platformCatalog) { - ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformCatalog.getPlatformId()); - if (platform == null) { - return 0; - } - if (platformCatalog.getId().length() <= 8) { - platformCatalog.setCivilCode(platformCatalog.getParentId()); - }else { - if (platformCatalog.getId().length() != 20) { - return 0; - } - if (platformCatalog.getParentId() != null) { - switch (Integer.parseInt(platformCatalog.getId().substring(10, 13))){ - case 200: - case 215: - if (platformCatalog.getParentId().length() <= 8) { - platformCatalog.setCivilCode(platformCatalog.getParentId()); - }else { - PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(), platformCatalog.getParentId()); - if (catalog != null) { - platformCatalog.setCivilCode(catalog.getCivilCode()); - } - } - break; - case 216: - if (platformCatalog.getParentId().length() <= 8) { - platformCatalog.setCivilCode(platformCatalog.getParentId()); - }else { - PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformCatalog.getPlatformId(),platformCatalog.getParentId()); - if (catalog == null) { - logger.warn("[添加目录] 无法获取目录{}的CivilCode和BusinessGroupId", platformCatalog.getPlatformId()); - break; - } - platformCatalog.setCivilCode(catalog.getCivilCode()); - if (Integer.parseInt(platformCatalog.getParentId().substring(10, 13)) == 215) { - platformCatalog.setBusinessGroupId(platformCatalog.getParentId()); - }else { - if (Integer.parseInt(platformCatalog.getParentId().substring(10, 13)) == 216) { - platformCatalog.setBusinessGroupId(catalog.getBusinessGroupId()); - } - } - } - break; - default: - break; - } - } - } - int result = catalogMapper.insert(platformCatalog); - if (result > 0) { - DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog); - eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.ADD); - } - return result; - } - - private PlatformCatalog getTopCatalog(String id, String platformId) { - PlatformCatalog catalog = catalogMapper.selectByPlatFormAndCatalogId(platformId, id); - if (catalog.getParentId().equals(platformId)) { - return catalog; - }else { - return getTopCatalog(catalog.getParentId(), platformId); - } - } - - @Override - public PlatformCatalog getCatalog(String platformId, String id) { - return catalogMapper.selectByPlatFormAndCatalogId(platformId, id); - } - - @Override - public int delCatalog(String platformId, String id) { - return delCatalogExecute(id, platformId); - } - private int delCatalogExecute(String id, String platformId) { - int delresult = catalogMapper.del(platformId, id); - DeviceChannel deviceChannelForCatalog = new DeviceChannel(); - if (delresult > 0){ - deviceChannelForCatalog.setChannelId(id); - eventPublisher.catalogEventPublish(platformId, deviceChannelForCatalog, CatalogEvent.DEL); - } - - List gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformId, id); - if (gbStreams.size() > 0){ - List deviceChannelList = new ArrayList<>(); - for (GbStream gbStream : gbStreams) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); - deviceChannelList.add(deviceChannel); - } - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); - } - int delStreamresult = platformGbStreamMapper.delByPlatformAndCatalogId(platformId,id); - List platformCatalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, id); - if (platformCatalogs.size() > 0){ - List deviceChannelList = new ArrayList<>(); - for (PlatformCatalog platformCatalog : platformCatalogs) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(platformCatalog.getId()); - deviceChannelList.add(deviceChannel); - } - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.DEL); - } - int delChannelresult = platformChannelMapper.delByCatalogId(platformId, id); - // 查看是否存在子目录,如果存在一并删除 - List allChildCatalog = getAllChildCatalog(id, platformId); - if (!allChildCatalog.isEmpty()) { - int limitCount = 50; - if (allChildCatalog.size() > limitCount) { - for (int i = 0; i < allChildCatalog.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > allChildCatalog.size()) { - toIndex = allChildCatalog.size(); - } - delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog.subList(i, toIndex)); - } - }else { - delChannelresult += platformCatalogMapper.deleteAll(platformId, allChildCatalog); - } - } - return delresult + delChannelresult + delStreamresult; - } - - private List getAllChildCatalog(String id, String platformId) { - List catalogList = platformCatalogMapper.queryCatalogFromParent(id, platformId); - List catalogListChild = new ArrayList<>(); - if (catalogList != null && !catalogList.isEmpty()) { - for (String childId : catalogList) { - List allChildCatalog = getAllChildCatalog(childId, platformId); - if (allChildCatalog != null && !allChildCatalog.isEmpty()) { - catalogListChild.addAll(allChildCatalog); - } - - } - } - if (!catalogListChild.isEmpty()) { - catalogList.addAll(catalogListChild); - } - return catalogList; - } - - - @Override - public int updateCatalog(PlatformCatalog platformCatalog) { - int result = catalogMapper.update(platformCatalog, Wrappers.lambdaUpdate() - .eq(PlatformCatalog::getId, platformCatalog.getId()) - .eq(PlatformCatalog::getPlatformId, platformCatalog.getPlatformId())); - - if (result > 0) { - DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog); - eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.UPDATE); - } - return result; - } - - @Override - public int setDefaultCatalog(String platformId, String catalogId) { - return platformMapper.update(null, Wrappers.lambdaUpdate() - .set(ParentPlatform::getCatalogId, catalogId) - .set(ParentPlatform::getUpdateTime, DateUtil.getNow()) - .eq(ParentPlatform::getServerGBId, platformId)); - } - - @Override - public List queryCatalogInPlatform(String platformId) { - return catalogMapper.queryCatalogInPlatform(platformId); - } - - @Override - public int delRelation(PlatformCatalog platformCatalog) { - if (platformCatalog.getType() == 1) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(platformCatalog.getId()); - eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL); - return platformChannelMapper.delByCatalogIdAndChannelIdAndPlatformId(platformCatalog); - }else if (platformCatalog.getType() == 2) { - List gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformCatalog.getPlatformId(), platformCatalog.getParentId()); - for (GbStream gbStream : gbStreams) { - if (gbStream.getGbId().equals(platformCatalog.getId())) { - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); - eventPublisher.catalogEventPublish(platformCatalog.getPlatformId(), deviceChannel, CatalogEvent.DEL); - return platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream()); - } - } - } - return 0; - } - - @Override - public int updateStreamGPS(List gpsMsgInfos) { - return gbStreamMapper.updateStreamGPS(gpsMsgInfos); - } - - - private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) { - ParentPlatform platform = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId()); - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(catalog.getId()); - deviceChannel.setName(catalog.getName()); - deviceChannel.setDeviceId(platform.getDeviceGBId()); - deviceChannel.setManufacture("wvp-pro"); - deviceChannel.setStatus(true); - deviceChannel.setParental(1); - - deviceChannel.setRegisterWay(1); - deviceChannel.setParentId(catalog.getParentId()); - deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId()); - - deviceChannel.setModel("live"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setSecrecy("0"); - return deviceChannel; - } - - @Override - public List queryPlatFormListForGBWithGBId(String channelId, List platforms) { - return platformChannelMapper.queryPlatFormListForGBWithGBId(channelId, platforms); - } - - @Override - public List queryPlatFormListForStreamWithGBId(String app, String stream, List platforms) { - if (platforms == null || platforms.size() == 0) { - return new ArrayList<>(); - } - return platformGbStreamMapper.queryPlatFormListForGBWithGBId(app, stream, platforms); - } - - @Override - public GbStream getGbStream(String app, String streamId) { - return gbStreamService.selectByAppAndStream(app, streamId); - } - - @Override - public void delCatalogByPlatformId(String serverGBId) { - catalogMapper.delByPlatformId(serverGBId); - } - - @Override - public void delRelationByPlatformId(String serverGBId) { - platformGbStreamMapper.delByPlatformId(serverGBId); - platformChannelMapper.delByPlatformId(serverGBId); - } - - @Override - public PlatformCatalog queryDefaultCatalogInPlatform(String platformId) { - return catalogMapper.selectDefaultByPlatFormId(platformId); - } - - @Override - public List getChannelSource(String platformId, String gbId) { - return platformMapper.getChannelSource(platformId, gbId); - } - - @Override - public void updateChannelPosition(DeviceChannel deviceChannel) { - if (deviceChannel.getChannelId().equals(deviceChannel.getDeviceId())) { - deviceChannel.setChannelId(null); - } - if (deviceChannel.getGpsTime() == null) { - deviceChannel.setGpsTime(DateUtil.getNow()); - } - - deviceChannelService.updatePosition(deviceChannel); - } - - @Override - public void cleanContentForPlatform(String serverGBId) { -// List catalogList = catalogMapper.selectByPlatForm(serverGBId); -// if (catalogList.size() > 0) { -// int result = catalogMapper.delByPlatformId(serverGBId); -// if (result > 0) { -// List deviceChannels = new ArrayList<>(); -// for (PlatformCatalog catalog : catalogList) { -// deviceChannels.add(getDeviceChannelByCatalog(catalog)); -// } -// eventPublisher.catalogEventPublish(serverGBId, deviceChannels, CatalogEvent.DEL); -// } -// } - catalogMapper.delByPlatformId(serverGBId); - platformChannelMapper.delByPlatformId(serverGBId); - platformGbStreamMapper.delByPlatformId(serverGBId); - } - - @Override - public List queryChannelWithCatalog(String serverGBId) { - return deviceChannelMapper.queryChannelWithCatalog(serverGBId); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/task/StreamProxyScheduledTask.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/task/StreamProxyScheduledTask.java deleted file mode 100644 index 64217ce0..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/task/StreamProxyScheduledTask.java +++ /dev/null @@ -1,72 +0,0 @@ -package com.genersoft.iot.vmp.task; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IStreamProxyService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.util.CollectionUtils; - -import java.util.List; -import java.util.Map; -import java.util.function.Function; -import java.util.stream.Collectors; - -//@Component -public class StreamProxyScheduledTask { - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private IStreamProxyService streamProxyService; - - @Autowired - private IVideoManagerStorage videoManagerStorage; - - @Scheduled(cron = "* 0/10 * * * ?") - public void asyncCheckStreamProxyStatus() { - - List all = mediaServerService.getAllOnline(); - - if (CollectionUtils.isEmpty(all)){ - return; - } - - Map serverItemMap = all.stream().collect(Collectors.toMap(MediaServerItem::getId, Function.identity(), (m1, m2) -> m1)); - - List list = videoManagerStorage.getStreamProxyListForEnable(true); - - if (CollectionUtils.isEmpty(list)){ - return; - } - - for (StreamProxyItem streamProxyItem : list) { - - MediaServerItem mediaServerItem = serverItemMap.get(streamProxyItem.getMediaServerId()); - - // TODO 支持其他 schema - JSONObject mediaInfo = zlmresTfulUtils.isMediaOnline(mediaServerItem, streamProxyItem.getApp(), streamProxyItem.getStream(), "rtsp"); - - if (mediaInfo == null){ - streamProxyItem.setStatus(false); - } else { - if (mediaInfo.getInteger("code") == 0 && mediaInfo.getBoolean("online")) { - streamProxyItem.setStatus(true); - } else { - streamProxyItem.setStatus(false); - } - } - - streamProxyService.updateStreamProxy(streamProxyItem); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/Coordtransform.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/Coordtransform.java deleted file mode 100644 index c10357c5..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/Coordtransform.java +++ /dev/null @@ -1,126 +0,0 @@ -package com.genersoft.iot.vmp.utils; - -/** - * 坐标转换 - * 一个提供了百度坐标(BD09)、国测局坐标(火星坐标,GCJ02)、和WGS84坐标系之间的转换的工具类 - * 参考https://github.com/wandergis/coordtransform 写的Java版本 - * @author Xinconan - * @date 2016-03-18 - * @url https://github.com/xinconan/coordtransform - */ -public class Coordtransform { - - private static double x_PI = 3.14159265358979324 * 3000.0 / 180.0; - private static double PI = 3.1415926535897932384626; - private static double a = 6378245.0; - private static double ee = 0.00669342162296594323; - - /** - * 百度坐标系 (BD-09) 与 火星坐标系 (GCJ-02)的转换 - * 即 百度 转 谷歌、高德 - * @param bd_lon - * @param bd_lat - * @return Double[lon,lat] - */ - public static Double[] BD09ToGCJ02(Double bd_lon,Double bd_lat){ - double x = bd_lon - 0.0065; - double y = bd_lat - 0.006; - double z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * x_PI); - double theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * x_PI); - Double[] arr = new Double[2]; - arr[0] = z * Math.cos(theta); - arr[1] = z * Math.sin(theta); - return arr; - } - - /** - * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换 - * 即谷歌、高德 转 百度 - * @param gcj_lon - * @param gcj_lat - * @return Double[lon,lat] - */ - public static Double[] GCJ02ToBD09(Double gcj_lon,Double gcj_lat){ - double z = Math.sqrt(gcj_lon * gcj_lon + gcj_lat * gcj_lat) + 0.00002 * Math.sin(gcj_lat * x_PI); - double theta = Math.atan2(gcj_lat, gcj_lon) + 0.000003 * Math.cos(gcj_lon * x_PI); - Double[] arr = new Double[2]; - arr[0] = z * Math.cos(theta) + 0.0065; - arr[1] = z * Math.sin(theta) + 0.006; - return arr; - } - - /** - * WGS84转GCJ02 - * @param wgs_lon - * @param wgs_lat - * @return Double[lon,lat] - */ - public static Double[] WGS84ToGCJ02(Double wgs_lon,Double wgs_lat){ - if(outOfChina(wgs_lon, wgs_lat)){ - return new Double[]{wgs_lon,wgs_lat}; - } - double dlat = transformlat(wgs_lon - 105.0, wgs_lat - 35.0); - double dlng = transformlng(wgs_lon - 105.0, wgs_lat - 35.0); - double radlat = wgs_lat / 180.0 * PI; - double magic = Math.sin(radlat); - magic = 1 - ee * magic * magic; - double sqrtmagic = Math.sqrt(magic); - dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); - dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); - Double[] arr = new Double[2]; - arr[0] = wgs_lon + dlng; - arr[1] = wgs_lat + dlat; - return arr; - } - - /** - * GCJ02转WGS84 - * @param gcj_lon - * @param gcj_lat - * @return Double[lon,lat] - */ - public static Double[] GCJ02ToWGS84(Double gcj_lon,Double gcj_lat){ - if(outOfChina(gcj_lon, gcj_lat)){ - return new Double[]{gcj_lon,gcj_lat}; - } - double dlat = transformlat(gcj_lon - 105.0, gcj_lat - 35.0); - double dlng = transformlng(gcj_lon - 105.0, gcj_lat - 35.0); - double radlat = gcj_lat / 180.0 * PI; - double magic = Math.sin(radlat); - magic = 1 - ee * magic * magic; - double sqrtmagic = Math.sqrt(magic); - dlat = (dlat * 180.0) / ((a * (1 - ee)) / (magic * sqrtmagic) * PI); - dlng = (dlng * 180.0) / (a / sqrtmagic * Math.cos(radlat) * PI); - double mglat = gcj_lat + dlat; - double mglng = gcj_lon + dlng; - return new Double[]{gcj_lon * 2 - mglng, gcj_lat * 2 - mglat}; - } - - private static Double transformlat(double lng, double lat) { - double ret = -100.0 + 2.0 * lng + 3.0 * lat + 0.2 * lat * lat + 0.1 * lng * lat + 0.2 * Math.sqrt(Math.abs(lng)); - ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; - ret += (20.0 * Math.sin(lat * PI) + 40.0 * Math.sin(lat / 3.0 * PI)) * 2.0 / 3.0; - ret += (160.0 * Math.sin(lat / 12.0 * PI) + 320 * Math.sin(lat * PI / 30.0)) * 2.0 / 3.0; - return ret; - } - - private static Double transformlng(double lng,double lat) { - double ret = 300.0 + lng + 2.0 * lat + 0.1 * lng * lng + 0.1 * lng * lat + 0.1 * Math.sqrt(Math.abs(lng)); - ret += (20.0 * Math.sin(6.0 * lng * PI) + 20.0 * Math.sin(2.0 * lng * PI)) * 2.0 / 3.0; - ret += (20.0 * Math.sin(lng * PI) + 40.0 * Math.sin(lng / 3.0 * PI)) * 2.0 / 3.0; - ret += (150.0 * Math.sin(lng / 12.0 * PI) + 300.0 * Math.sin(lng / 30.0 * PI)) * 2.0 / 3.0; - return ret; - } - - /** - * outOfChina - * @描述: 判断是否在国内,不在国内则不做偏移 - * @param lng - * @param lat - * @return {boolean} - */ - private static boolean outOfChina(Double lng,Double lat) { - return (lng < 72.004 || lng > 137.8347) || ((lat < 0.8293 || lat > 55.8271) || false); - }; - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java deleted file mode 100644 index 1abf2c6c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/DateUtil.java +++ /dev/null @@ -1,120 +0,0 @@ -package com.genersoft.iot.vmp.utils; - - -import org.apache.commons.lang3.ObjectUtils; - -import java.time.Instant; -import java.time.LocalDate; -import java.time.LocalDateTime; -import java.time.ZoneId; -import java.time.format.DateTimeFormatter; -import java.time.format.DateTimeParseException; -import java.time.temporal.ChronoUnit; -import java.time.temporal.TemporalAccessor; - -import java.util.Locale; - -/** - * 全局时间工具类 - * @author lin - */ -public class DateUtil { - - /** - * 兼容不规范的iso8601时间格式 - */ - private static final String ISO8601_COMPATIBLE_PATTERN = "yyyy-M-d'T'H:m:s"; - - /** - * 用以输出标准的iso8601时间格式 - */ - private static final String ISO8601_PATTERN = "yyyy-MM-dd'T'HH:mm:ss"; - - /** - * wvp内部统一时间格式 - */ - public static final String PATTERN = "yyyy-MM-dd HH:mm:ss"; - - /** - * wvp内部统一时间格式 - */ - public static final String URL_PATTERN = "yyyyMMddHHmmss"; - - public static final String zoneStr = "Asia/Shanghai"; - - public static final DateTimeFormatter formatterCompatibleISO8601 = DateTimeFormatter.ofPattern(ISO8601_COMPATIBLE_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); - public static final DateTimeFormatter formatterISO8601 = DateTimeFormatter.ofPattern(ISO8601_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); - public static final DateTimeFormatter formatter = DateTimeFormatter.ofPattern(PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); - public static final DateTimeFormatter urlFormatter = DateTimeFormatter.ofPattern(URL_PATTERN, Locale.getDefault()).withZone(ZoneId.of(zoneStr)); - - public static String yyyy_MM_dd_HH_mm_ssToISO8601(String formatTime) { - - return formatterISO8601.format(formatter.parse(formatTime)); - } - - public static String ISO8601Toyyyy_MM_dd_HH_mm_ss(String formatTime) { - return formatter.format(formatterCompatibleISO8601.parse(formatTime)); - } - - public static String urlToyyyy_MM_dd_HH_mm_ss(String formatTime) { - return formatter.format(urlFormatter.parse(formatTime)); - } - - /** - * yyyy_MM_dd_HH_mm_ss 转时间戳 - * @param formatTime - * @return - */ - public static long yyyy_MM_dd_HH_mm_ssToTimestamp(String formatTime) { - TemporalAccessor temporalAccessor = formatter.parse(formatTime); - Instant instant = Instant.from(temporalAccessor); - return instant.getEpochSecond(); - } - - /** - * 获取当前时间 - * @return - */ - public static String getNow() { - LocalDateTime nowDateTime = LocalDateTime.now(); - return formatter.format(nowDateTime); - } - - /** - * 获取当前时间 - * @return - */ - public static String getNowForUrl() { - LocalDateTime nowDateTime = LocalDateTime.now(); - return urlFormatter.format(nowDateTime); - } - - - /** - * 格式校验 - * @param timeStr 时间字符串 - * @param dateTimeFormatter 待校验的格式 - * @return - */ - public static boolean verification(String timeStr, DateTimeFormatter dateTimeFormatter) { - try { - LocalDate.parse(timeStr, dateTimeFormatter); - return true; - }catch (DateTimeParseException exception) { - return false; - } - } - - public static String getNowForISO8601() { - LocalDateTime nowDateTime = LocalDateTime.now(); - return formatterISO8601.format(nowDateTime); - } - - public static long getDifferenceForNow(String keepaliveTime) { - if (ObjectUtils.isEmpty(keepaliveTime)) { - return 0; - } - Instant beforeInstant = Instant.from(formatter.parse(keepaliveTime)); - return ChronoUnit.MILLIS.between(beforeInstant, Instant.now()); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java deleted file mode 100644 index 40bd0d5f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/GitUtil.java +++ /dev/null @@ -1,58 +0,0 @@ -package com.genersoft.iot.vmp.utils; - -import org.springframework.beans.factory.annotation.Value; -import org.springframework.context.annotation.PropertySource; -import org.springframework.stereotype.Component; - -/** - * 一个优秀的颓废程序猿(CSDN) - */ -@Component -public class GitUtil { - - @Value("${git.branch:}") - private String branch; - @Value("${git.commit.id:}") - private String gitCommitId; - @Value("${git.remote.origin.url:}") - private String gitUrl; - @Value("${git.build.time:}") - private String buildDate; - - @Value("${git.build.version:${framework.version}}") - private String buildVersion; - - @Value("${git.commit.id.abbrev:}") - private String commitIdShort; - - @Value("${git.commit.time:}") - private String commitTime; - - public String getGitCommitId() { - return gitCommitId; - } - - public String getBranch() { - return branch; - } - - public String getGitUrl() { - return gitUrl; - } - - public String getBuildDate() { - return buildDate; - } - - public String getCommitIdShort() { - return commitIdShort; - } - - public String getBuildVersion() { - return buildVersion; - } - - public String getCommitTime() { - return commitTime; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/GpsUtil.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/GpsUtil.java deleted file mode 100644 index 2d9bd39b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/GpsUtil.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.genersoft.iot.vmp.utils; - -import java.io.BufferedReader; -import java.io.InputStreamReader; -import java.io.OutputStream; -import java.net.Socket; -import java.util.Base64; - -import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class GpsUtil { - - private static Logger logger = LoggerFactory.getLogger(GpsUtil.class); - - public static BaiduPoint Wgs84ToBd09(String xx, String yy) { - - - double lng = Double.parseDouble(xx); - double lat = Double.parseDouble(yy); - Double[] gcj02 = Coordtransform.WGS84ToGCJ02(lng, lat); - Double[] doubles = Coordtransform.GCJ02ToBD09(gcj02[0], gcj02[1]); - BaiduPoint bdPoint= new BaiduPoint(); - bdPoint.setBdLng(doubles[0] + ""); - bdPoint.setBdLat(doubles[1] + ""); - return bdPoint; - } - - /** - * BASE64解码 - * @param str - * @return string - */ - public static byte[] decode(String str) { - byte[] bt = null; - final Base64.Decoder decoder = Base64.getDecoder(); - bt = decoder.decode(str); // .decodeBuffer(str); - return bt; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/JsonUtil.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/JsonUtil.java deleted file mode 100644 index de8675f1..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/JsonUtil.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.genersoft.iot.vmp.utils; - -import org.springframework.data.redis.core.RedisTemplate; - -import java.util.Objects; - -/** - * JsonUtil - * - * @author KunLong-Luo - * @version 1.0.0 - * @since 2023/2/2 15:24 - */ -public final class JsonUtil { - - private JsonUtil() { - } - - /** - * safe json type conversion - * - * @param key redis key - * @param clazz cast type - * @param - * @return result type - */ - public static T redisJsonToObject(RedisTemplate redisTemplate, String key, Class clazz) { - Object jsonObject = redisTemplate.opsForValue().get(key); - if (Objects.isNull(jsonObject)) { - return null; - } - return clazz.cast(jsonObject); - } -} \ No newline at end of file diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java deleted file mode 100644 index 18065242..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/SpringBeanFactory.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.genersoft.iot.vmp.utils; - -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; -import org.springframework.stereotype.Component; - -/** - * @description:spring bean获取工厂,获取spring中的已初始化的bean - * @author: swwheihei - * @date: 2019年6月25日 下午4:51:52 - * - */ -@Component -public class SpringBeanFactory implements ApplicationContextAware { - - // Spring应用上下文环境 - private static ApplicationContext applicationContext; - - /** - * 实现ApplicationContextAware接口的回调方法,设置上下文环境 - */ - @Override - public void setApplicationContext(ApplicationContext applicationContext) - throws BeansException { - SpringBeanFactory.applicationContext = applicationContext; - } - - public static ApplicationContext getApplicationContext() { - return applicationContext; - } - - /** - * 获取对象 这里重写了bean方法,起主要作用 - */ - public static T getBean(String beanId) throws BeansException { - if (applicationContext == null) { - return null; - } - return (T) applicationContext.getBean(beanId); - } - - /** - * 获取当前环境 - */ - public static String getActiveProfile() { - return applicationContext.getEnvironment().getActiveProfiles()[0]; - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/UJson.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/UJson.java deleted file mode 100644 index a2d40339..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/UJson.java +++ /dev/null @@ -1,150 +0,0 @@ -package com.genersoft.iot.vmp.utils; - -import com.fasterxml.jackson.databind.DeserializationFeature; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Iterator; -import java.util.Map; -import java.util.Objects; - -/** - * @author gaofuwang - * @version 1.0 - * @date 2022/3/11 10:17 - */ -public class UJson { - - private static Logger logger = LoggerFactory.getLogger(UJson.class); - public static final ObjectMapper JSON_MAPPER = new ObjectMapper(); - - static { - JSON_MAPPER.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES,false); - } - - private ObjectNode node; - - public UJson(){ - this.node = JSON_MAPPER.createObjectNode(); - } - - public UJson(String json){ - if(StringUtils.isBlank(json)){ - this.node = JSON_MAPPER.createObjectNode(); - }else{ - try { - this.node = JSON_MAPPER.readValue(json, ObjectNode.class); - }catch (Exception e){ - logger.error(e.getMessage(), e); - this.node = JSON_MAPPER.createObjectNode(); - } - } - } - - public UJson(ObjectNode node){ - this.node = node; - } - - public String asText(String key){ - JsonNode jsonNode = node.get(key); - if(Objects.isNull(jsonNode)){ - return ""; - } - return jsonNode.asText(); - } - - public String asText(String key, String defaultVal){ - JsonNode jsonNode = node.get(key); - if(Objects.isNull(jsonNode)){ - return ""; - } - return jsonNode.asText(defaultVal); - } - - public UJson put(String key, String value){ - this.node.put(key, value); - return this; - } - - public UJson put(String key, Integer value){ - this.node.put(key, value); - return this; - } - - public static UJson json(){ - return new UJson(); - } - - public static UJson json(String json){ - return new UJson(json); - } - - public static T readJson(String json, Class clazz){ - if(StringUtils.isBlank(json)){ - return null; - } - try { - return JSON_MAPPER.readValue(json, clazz); - }catch (Exception e){ - logger.error(e.getMessage(), e); - return null; - } - } - - public static String writeJson(Object object) { - try{ - return JSON_MAPPER.writeValueAsString(object); - }catch (Exception e){ - logger.error(e.getMessage(), e); - return ""; - } - } - - @Override - public String toString() { - return node.toString(); - } - - public int asInt(String key, int defValue) { - JsonNode jsonNode = this.node.get(key); - if(Objects.isNull(jsonNode)){ - return defValue; - } - return jsonNode.asInt(defValue); - } - - public UJson getSon(String key) { - JsonNode sonNode = this.node.get(key); - if(Objects.isNull(sonNode)){ - return new UJson(); - } - return new UJson((ObjectNode) sonNode); - } - - public UJson set(String key, ObjectNode sonNode) { - this.node.set(key, sonNode); - return this; - } - - public UJson set(String key, UJson sonNode) { - this.node.set(key, sonNode.node); - return this; - } - - public Iterator> fields() { - return this.node.fields(); - } - - public ObjectNode getNode() { - return this.node; - } - - public UJson setAll(UJson json) { - this.node.setAll(json.node); - return this; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/redis/FastJsonRedisSerializer.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/redis/FastJsonRedisSerializer.java deleted file mode 100644 index 86b7dce1..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/redis/FastJsonRedisSerializer.java +++ /dev/null @@ -1,45 +0,0 @@ -package com.genersoft.iot.vmp.utils.redis; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONReader; -import com.alibaba.fastjson2.JSONWriter; -import org.springframework.data.redis.serializer.RedisSerializer; -import org.springframework.data.redis.serializer.SerializationException; - -import java.nio.charset.Charset; - -/** - * @description:使用fastjson实现redis的序列化 - * @author: swwheihei - * @date: 2020年5月6日 下午8:40:11 - */ -public class FastJsonRedisSerializer implements RedisSerializer { - - public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8"); - - private Class clazz; - - public FastJsonRedisSerializer(Class clazz) { - super(); - this.clazz = clazz; - } - - @Override - public byte[] serialize(T t) throws SerializationException { - if (t == null) { - return new byte[0]; - } - return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName, JSONWriter.Feature.WritePairAsJavaBean).getBytes(DEFAULT_CHARSET); - } - - @Override - public T deserialize(byte[] bytes) throws SerializationException { - if (bytes == null || bytes.length <= 0) { - return null; - } - String str = new String(bytes, DEFAULT_CHARSET); - return JSON.parseObject(str, clazz, JSONReader.Feature.SupportAutoType); - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java deleted file mode 100644 index 101a3b30..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java +++ /dev/null @@ -1,47 +0,0 @@ -package com.genersoft.iot.vmp.utils.redis; - -import com.google.common.collect.Lists; -import org.springframework.data.redis.core.Cursor; -import org.springframework.data.redis.core.RedisCallback; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ScanOptions; - -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -/** - * Redis工具类 - * - * @author swwheihei - * @date 2020年5月6日 下午8:27:29 - */ -@SuppressWarnings(value = {"rawtypes", "unchecked"}) -public class RedisUtil { - - /** - * 模糊查询 - * - * @param query 查询参数 - * @return - */ - public static List scan(RedisTemplate redisTemplate, String query) { - - Set resultKeys = (Set) redisTemplate.execute((RedisCallback>) connection -> { - ScanOptions scanOptions = ScanOptions.scanOptions().match("*" + query + "*").count(1000).build(); - Cursor scan = connection.scan(scanOptions); - Set keys = new HashSet<>(); - while (scan.hasNext()) { - byte[] next = scan.next(); - keys.add(new String(next)); - } - return keys; - }); - - return Lists.newArrayList(resultKeys); - } -} - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/BaseTree.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/BaseTree.java deleted file mode 100644 index 23690e54..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/BaseTree.java +++ /dev/null @@ -1,87 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -import org.jetbrains.annotations.NotNull; - -import java.text.Collator; -import java.util.Comparator; - -/** - * @author lin - */ -public class BaseTree implements Comparable{ - private String id; - - private String deviceId; - private String pid; - private String name; - private boolean parent; - - private T basicData; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getPid() { - return pid; - } - - public void setPid(String pid) { - this.pid = pid; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public T getBasicData() { - return basicData; - } - - public void setBasicData(T basicData) { - this.basicData = basicData; - } - - public boolean isParent() { - return parent; - } - - public void setParent(boolean parent) { - this.parent = parent; - } - - @Override - public int compareTo(@NotNull BaseTree treeNode) { - if (this.parent || treeNode.isParent()) { - if (!this.parent && !treeNode.isParent()) { - Comparator cmp = Collator.getInstance(java.util.Locale.CHINA); - return cmp.compare(treeNode.getName(), this.getName()); - }else { - if (this.isParent()) { - return 1; - }else { - return -1; - } - } - }else{ - Comparator cmp = Collator.getInstance(java.util.Locale.CHINA); - return cmp.compare(treeNode.getName(), this.getName()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/BatchGBStreamParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/BatchGBStreamParam.java deleted file mode 100644 index 00904889..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/BatchGBStreamParam.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import io.swagger.v3.oas.annotations.media.Schema; - -import java.util.List; - -/** - * @author lin - */ -@Schema(description = "多个推流信息") -public class BatchGBStreamParam { - @Schema(description = "推流信息列表") - private List gbStreams; - - public List getGbStreams() { - return gbStreams; - } - - public void setGbStreams(List gbStreams) { - this.gbStreams = gbStreams; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultEx.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultEx.java deleted file mode 100644 index 0b9d3d9a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultEx.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -import org.springframework.web.context.request.async.DeferredResult; - -public class DeferredResultEx { - - private DeferredResult deferredResult; - - private DeferredResultFilter filter; - - public DeferredResultEx(DeferredResult result) { - this.deferredResult = result; - } - - - public DeferredResult getDeferredResult() { - return deferredResult; - } - - public void setDeferredResult(DeferredResult deferredResult) { - this.deferredResult = deferredResult; - } - - public DeferredResultFilter getFilter() { - return filter; - } - - public void setFilter(DeferredResultFilter filter) { - this.filter = filter; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultFilter.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultFilter.java deleted file mode 100644 index 18c22407..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeferredResultFilter.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -public interface DeferredResultFilter { - - Object handler(Object o); -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ErrorCode.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ErrorCode.java deleted file mode 100644 index e2e3879b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ErrorCode.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -/** - * 全局错误码 - */ -public enum ErrorCode { - SUCCESS(0, "成功"), - ERROR100(100, "失败"), - ERROR400(400, "参数或方法错误"), - ERROR404(404, "资源未找到"), - ERROR403(403, "无权限操作"), - ERROR401(401, "请登录后重新请求"), - ERROR500(500, "系统异常"); - - private final int code; - private final String msg; - - ErrorCode(int code, String msg) { - this.code = code; - this.msg = msg; - } - - public int getCode() { - return code; - } - - public String getMsg() { - return msg; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/OtherPsSendInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/OtherPsSendInfo.java deleted file mode 100644 index ac984092..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/OtherPsSendInfo.java +++ /dev/null @@ -1,137 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -public class OtherPsSendInfo { - - /** - * 发流IP - */ - private String sendLocalIp; - - /** - * 发流端口 - */ - private int sendLocalPort; - - /** - * 收流IP - */ - private String receiveIp; - - /** - * 收流端口 - */ - private int receivePort; - - - /** - * 会话ID - */ - private String callId; - - /** - * 流ID - */ - private String stream; - - /** - * 推流应用名 - */ - private String pushApp; - - /** - * 推流流ID - */ - private String pushStream; - - /** - * 推流SSRC - */ - private String pushSSRC; - - public String getSendLocalIp() { - return sendLocalIp; - } - - public void setSendLocalIp(String sendLocalIp) { - this.sendLocalIp = sendLocalIp; - } - - public int getSendLocalPort() { - return sendLocalPort; - } - - public void setSendLocalPort(int sendLocalPort) { - this.sendLocalPort = sendLocalPort; - } - - public String getReceiveIp() { - return receiveIp; - } - - public void setReceiveIp(String receiveIp) { - this.receiveIp = receiveIp; - } - - public int getReceivePort() { - return receivePort; - } - - public void setReceivePort(int receivePort) { - this.receivePort = receivePort; - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getPushApp() { - return pushApp; - } - - public void setPushApp(String pushApp) { - this.pushApp = pushApp; - } - - public String getPushStream() { - return pushStream; - } - - public void setPushStream(String pushStream) { - this.pushStream = pushStream; - } - - public String getPushSSRC() { - return pushSSRC; - } - - public void setPushSSRC(String pushSSRC) { - this.pushSSRC = pushSSRC; - } - - @Override - public String toString() { - return "OtherPsSendInfo{" + - "sendLocalIp='" + sendLocalIp + '\'' + - ", sendLocalPort=" + sendLocalPort + - ", receiveIp='" + receiveIp + '\'' + - ", receivePort=" + receivePort + - ", callId='" + callId + '\'' + - ", stream='" + stream + '\'' + - ", pushApp='" + pushApp + '\'' + - ", pushStream='" + pushStream + '\'' + - ", pushSSRC='" + pushSSRC + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/OtherRtpSendInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/OtherRtpSendInfo.java deleted file mode 100644 index 75c05d3b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/OtherRtpSendInfo.java +++ /dev/null @@ -1,166 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -public class OtherRtpSendInfo { - - /** - * 发流IP - */ - private String sendLocalIp; - - /** - * 音频发流端口 - */ - private int sendLocalPortForAudio; - - /** - * 视频发流端口 - */ - private int sendLocalPortForVideo; - - /** - * 收流IP - */ - private String receiveIp; - - /** - * 音频收流端口 - */ - private int receivePortForAudio; - - /** - * 视频收流端口 - */ - private int receivePortForVideo; - - /** - * 会话ID - */ - private String callId; - - /** - * 流ID - */ - private String stream; - - /** - * 推流应用名 - */ - private String pushApp; - - /** - * 推流流ID - */ - private String pushStream; - - /** - * 推流SSRC - */ - private String pushSSRC; - - - public String getReceiveIp() { - return receiveIp; - } - - public void setReceiveIp(String receiveIp) { - this.receiveIp = receiveIp; - } - - public int getReceivePortForAudio() { - return receivePortForAudio; - } - - public void setReceivePortForAudio(int receivePortForAudio) { - this.receivePortForAudio = receivePortForAudio; - } - - public int getReceivePortForVideo() { - return receivePortForVideo; - } - - public void setReceivePortForVideo(int receivePortForVideo) { - this.receivePortForVideo = receivePortForVideo; - } - - public String getCallId() { - return callId; - } - - public void setCallId(String callId) { - this.callId = callId; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getPushApp() { - return pushApp; - } - - public void setPushApp(String pushApp) { - this.pushApp = pushApp; - } - - public String getPushStream() { - return pushStream; - } - - public void setPushStream(String pushStream) { - this.pushStream = pushStream; - } - - public String getPushSSRC() { - return pushSSRC; - } - - public void setPushSSRC(String pushSSRC) { - this.pushSSRC = pushSSRC; - } - - - public String getSendLocalIp() { - return sendLocalIp; - } - - public void setSendLocalIp(String sendLocalIp) { - this.sendLocalIp = sendLocalIp; - } - - public int getSendLocalPortForAudio() { - return sendLocalPortForAudio; - } - - public void setSendLocalPortForAudio(int sendLocalPortForAudio) { - this.sendLocalPortForAudio = sendLocalPortForAudio; - } - - public int getSendLocalPortForVideo() { - return sendLocalPortForVideo; - } - - public void setSendLocalPortForVideo(int sendLocalPortForVideo) { - this.sendLocalPortForVideo = sendLocalPortForVideo; - } - - @Override - public String toString() { - return "OtherRtpSendInfo{" + - "sendLocalIp='" + sendLocalIp + '\'' + - ", sendLocalPortForAudio=" + sendLocalPortForAudio + - ", sendLocalPortForVideo=" + sendLocalPortForVideo + - ", receiveIp='" + receiveIp + '\'' + - ", receivePortForAudio=" + receivePortForAudio + - ", receivePortForVideo=" + receivePortForVideo + - ", callId='" + callId + '\'' + - ", stream='" + stream + '\'' + - ", pushApp='" + pushApp + '\'' + - ", pushStream='" + pushStream + '\'' + - ", pushSSRC='" + pushSSRC + '\'' + - '}'; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java deleted file mode 100644 index 8894191a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PageInfo.java +++ /dev/null @@ -1,99 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -import java.util.ArrayList; -import java.util.List; - -public class PageInfo { - //当前页 - private int pageNum; - //每页的数量 - private int pageSize; - //当前页的数量 - private int size; - //总页数 - private int pages; - //总数 - private int total; - - private List resultData; - - private List list; - - public PageInfo(List resultData) { - this.resultData = resultData; - } - - public PageInfo() { - } - - public void startPage(int page, int count) { - if (count <= 0) count = 10; - if (page <= 0) page = 1; - this.pageNum = page; - this.pageSize = count; - this.total = resultData.size(); - - this.pages = total % count == 0 ? total / count : total / count + 1; - int fromIndx = (page - 1) * count; - if (fromIndx > this.total - 1) { - this.list = new ArrayList<>(); - this.size = 0; - return; - } - - int toIndx = page * count; - if (toIndx > this.total) { - toIndx = this.total; - } - this.list = this.resultData.subList(fromIndx, toIndx); - this.size = this.list.size(); - } - - public int getPageNum() { - return pageNum; - } - - public void setPageNum(int pageNum) { - this.pageNum = pageNum; - } - - public int getPageSize() { - return pageSize; - } - - public void setPageSize(int pageSize) { - this.pageSize = pageSize; - } - - public int getSize() { - return size; - } - - public void setSize(int size) { - this.size = size; - } - - public int getPages() { - return pages; - } - - public void setPages(int pages) { - this.pages = pages; - } - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public List getList() { - return list; - } - - public void setList(List list) { - this.list = list; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PlayTypeEnum.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PlayTypeEnum.java deleted file mode 100644 index d2ee56bf..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/PlayTypeEnum.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -public enum PlayTypeEnum { - - PLAY("0", "直播"), - PLAY_BACK("1", "回放"); - - private String value; - private String name; - - PlayTypeEnum(String value, String name) { - this.value = value; - this.name = name; - } - - public String getValue() { - return value; - } - - public String getName() { - return name; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/RecordFile.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/RecordFile.java deleted file mode 100644 index 72d6561f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/RecordFile.java +++ /dev/null @@ -1,53 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -public class RecordFile { - private String app; - private String stream; - - private String fileName; - - private String mediaServerId; - - private String date; - - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getFileName() { - return fileName; - } - - public void setFileName(String fileName) { - this.fileName = fileName; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public String getDate() { - return date; - } - - public void setDate(String date) { - this.date = date; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaseInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaseInfo.java deleted file mode 100644 index dab9b0ae..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceBaseInfo.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -public class ResourceBaseInfo { - private int total; - private int online; - - public ResourceBaseInfo() { - } - - public ResourceBaseInfo(int total, int online) { - this.total = total; - this.online = online; - } - - public int getTotal() { - return total; - } - - public void setTotal(int total) { - this.total = total; - } - - public int getOnline() { - return online; - } - - public void setOnline(int online) { - this.online = online; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceInfo.java deleted file mode 100644 index 3b0ee0d3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/ResourceInfo.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -public class ResourceInfo { - - private ResourceBaseInfo device; - private ResourceBaseInfo channel; - private ResourceBaseInfo push; - private ResourceBaseInfo proxy; - - public ResourceBaseInfo getDevice() { - return device; - } - - public void setDevice(ResourceBaseInfo device) { - this.device = device; - } - - public ResourceBaseInfo getChannel() { - return channel; - } - - public void setChannel(ResourceBaseInfo channel) { - this.channel = channel; - } - - public ResourceBaseInfo getPush() { - return push; - } - - public void setPush(ResourceBaseInfo push) { - this.push = push; - } - - public ResourceBaseInfo getProxy() { - return proxy; - } - - public void setProxy(ResourceBaseInfo proxy) { - this.proxy = proxy; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/SnapPath.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/SnapPath.java deleted file mode 100644 index ce34d72c..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/SnapPath.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "截图地址信息") -public class SnapPath { - - @Schema(description = "相对地址") - private String path; - - @Schema(description = "绝对地址") - private String absoluteFilePath; - - @Schema(description = "请求地址") - private String url; - - - public static SnapPath getInstance(String path, String absoluteFilePath, String url) { - SnapPath snapPath = new SnapPath(); - snapPath.setPath(path); - snapPath.setAbsoluteFilePath(absoluteFilePath); - snapPath.setUrl(url); - return snapPath; - } - - - public String getPath() { - return path; - } - - public void setPath(String path) { - this.path = path; - } - - public String getAbsoluteFilePath() { - return absoluteFilePath; - } - - public void setAbsoluteFilePath(String absoluteFilePath) { - this.absoluteFilePath = absoluteFilePath; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamContent.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamContent.java deleted file mode 100644 index abf6df44..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/StreamContent.java +++ /dev/null @@ -1,414 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -import com.genersoft.iot.vmp.common.StreamInfo; -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "流信息") -public class StreamContent { - - @Schema(description = "应用名") - private String app; - - @Schema(description = "流ID") - private String stream; - - @Schema(description = "IP") - private String ip; - - @Schema(description = "HTTP-FLV流地址") - private String flv; - - @Schema(description = "HTTPS-FLV流地址") - private String https_flv; - - @Schema(description = "Websocket-FLV流地址") - private String ws_flv; - - @Schema(description = "Websockets-FLV流地址") - private String wss_flv; - - @Schema(description = "HTTP-FMP4流地址") - private String fmp4; - - @Schema(description = "HTTPS-FMP4流地址") - private String https_fmp4; - - @Schema(description = "Websocket-FMP4流地址") - private String ws_fmp4; - - @Schema(description = "Websockets-FMP4流地址") - private String wss_fmp4; - - @Schema(description = "HLS流地址") - private String hls; - - @Schema(description = "HTTPS-HLS流地址") - private String https_hls; - - @Schema(description = "Websocket-HLS流地址") - private String ws_hls; - - @Schema(description = "Websockets-HLS流地址") - private String wss_hls; - - @Schema(description = "HTTP-TS流地址") - private String ts; - - @Schema(description = "HTTPS-TS流地址") - private String https_ts; - - @Schema(description = "Websocket-TS流地址") - private String ws_ts; - - @Schema(description = "Websockets-TS流地址") - private String wss_ts; - - @Schema(description = "RTMP流地址") - private String rtmp; - - @Schema(description = "RTMPS流地址") - private String rtmps; - - @Schema(description = "RTSP流地址") - private String rtsp; - - @Schema(description = "RTSPS流地址") - private String rtsps; - - @Schema(description = "RTC流地址") - private String rtc; - - @Schema(description = "RTCS流地址") - private String rtcs; - - @Schema(description = "流媒体ID") - private String mediaServerId; - - @Schema(description = "流编码信息") - private Object tracks; - - @Schema(description = "开始时间") - private String startTime; - - @Schema(description = "结束时间") - private String endTime; - - private double progress; - - public StreamContent(StreamInfo streamInfo) { - if (streamInfo == null) { - return; - } - this.app = streamInfo.getApp(); - this.stream = streamInfo.getStream(); - if (streamInfo.getFlv() != null) { - this.flv = streamInfo.getFlv().getUrl(); - } - if (streamInfo.getHttps_flv() != null) { - this.https_flv = streamInfo.getHttps_flv().getUrl(); - } - if (streamInfo.getWs_flv() != null) { - this.ws_flv = streamInfo.getWs_flv().getUrl(); - } - if (streamInfo.getWss_flv() != null) { - this.wss_flv = streamInfo.getWss_flv().getUrl(); - } - if (streamInfo.getFmp4() != null) { - this.fmp4 = streamInfo.getFmp4().getUrl(); - } - if (streamInfo.getHttps_fmp4() != null) { - this.https_fmp4 = streamInfo.getHttps_fmp4().getUrl(); - } - if (streamInfo.getWs_fmp4() != null) { - this.ws_fmp4 = streamInfo.getWs_fmp4().getUrl(); - } - if (streamInfo.getWss_fmp4() != null) { - this.wss_fmp4 = streamInfo.getWss_fmp4().getUrl(); - } - if (streamInfo.getHls() != null) { - this.hls = streamInfo.getHls().getUrl(); - } - if (streamInfo.getHttps_hls() != null) { - this.https_hls = streamInfo.getHttps_hls().getUrl(); - } - if (streamInfo.getWs_hls() != null) { - this.ws_hls = streamInfo.getWs_hls().getUrl(); - } - if (streamInfo.getWss_hls() != null) { - this.wss_hls = streamInfo.getWss_hls().getUrl(); - } - if (streamInfo.getTs() != null) { - this.ts = streamInfo.getTs().getUrl(); - } - if (streamInfo.getHttps_ts() != null) { - this.https_ts = streamInfo.getHttps_ts().getUrl(); - } - if (streamInfo.getWs_ts() != null) { - this.ws_ts = streamInfo.getWs_ts().getUrl(); - } - if (streamInfo.getRtmp() != null) { - this.rtmp = streamInfo.getRtmp().getUrl(); - } - if (streamInfo.getRtmps() != null) { - this.rtmps = streamInfo.getRtmps().getUrl(); - } - if (streamInfo.getRtsp() != null) { - this.rtsp = streamInfo.getRtsp().getUrl(); - } - if (streamInfo.getRtsps() != null) { - this.rtsps = streamInfo.getRtsps().getUrl(); - } - if (streamInfo.getRtc() != null) { - this.rtc = streamInfo.getRtc().getUrl(); - } - if (streamInfo.getRtcs() != null) { - this.rtcs = streamInfo.getRtcs().getUrl(); - } - - this.mediaServerId = streamInfo.getMediaServerId(); - this.tracks = streamInfo.getTracks(); - this.startTime = streamInfo.getStartTime(); - this.endTime = streamInfo.getEndTime(); - this.progress = streamInfo.getProgress(); - } - - public String getApp() { - return app; - } - - public void setApp(String app) { - this.app = app; - } - - public String getStream() { - return stream; - } - - public void setStream(String stream) { - this.stream = stream; - } - - public String getIp() { - return ip; - } - - public void setIp(String ip) { - this.ip = ip; - } - - public String getFlv() { - return flv; - } - - public void setFlv(String flv) { - this.flv = flv; - } - - public String getHttps_flv() { - return https_flv; - } - - public void setHttps_flv(String https_flv) { - this.https_flv = https_flv; - } - - public String getWs_flv() { - return ws_flv; - } - - public void setWs_flv(String ws_flv) { - this.ws_flv = ws_flv; - } - - public String getWss_flv() { - return wss_flv; - } - - public void setWss_flv(String wss_flv) { - this.wss_flv = wss_flv; - } - - public String getFmp4() { - return fmp4; - } - - public void setFmp4(String fmp4) { - this.fmp4 = fmp4; - } - - public String getHttps_fmp4() { - return https_fmp4; - } - - public void setHttps_fmp4(String https_fmp4) { - this.https_fmp4 = https_fmp4; - } - - public String getWs_fmp4() { - return ws_fmp4; - } - - public void setWs_fmp4(String ws_fmp4) { - this.ws_fmp4 = ws_fmp4; - } - - public String getWss_fmp4() { - return wss_fmp4; - } - - public void setWss_fmp4(String wss_fmp4) { - this.wss_fmp4 = wss_fmp4; - } - - public String getHls() { - return hls; - } - - public void setHls(String hls) { - this.hls = hls; - } - - public String getHttps_hls() { - return https_hls; - } - - public void setHttps_hls(String https_hls) { - this.https_hls = https_hls; - } - - public String getWs_hls() { - return ws_hls; - } - - public void setWs_hls(String ws_hls) { - this.ws_hls = ws_hls; - } - - public String getWss_hls() { - return wss_hls; - } - - public void setWss_hls(String wss_hls) { - this.wss_hls = wss_hls; - } - - public String getTs() { - return ts; - } - - public void setTs(String ts) { - this.ts = ts; - } - - public String getHttps_ts() { - return https_ts; - } - - public void setHttps_ts(String https_ts) { - this.https_ts = https_ts; - } - - public String getWs_ts() { - return ws_ts; - } - - public void setWs_ts(String ws_ts) { - this.ws_ts = ws_ts; - } - - public String getWss_ts() { - return wss_ts; - } - - public void setWss_ts(String wss_ts) { - this.wss_ts = wss_ts; - } - - public String getRtmp() { - return rtmp; - } - - public void setRtmp(String rtmp) { - this.rtmp = rtmp; - } - - public String getRtmps() { - return rtmps; - } - - public void setRtmps(String rtmps) { - this.rtmps = rtmps; - } - - public String getRtsp() { - return rtsp; - } - - public void setRtsp(String rtsp) { - this.rtsp = rtsp; - } - - public String getRtsps() { - return rtsps; - } - - public void setRtsps(String rtsps) { - this.rtsps = rtsps; - } - - public String getRtc() { - return rtc; - } - - public void setRtc(String rtc) { - this.rtc = rtc; - } - - public String getRtcs() { - return rtcs; - } - - public void setRtcs(String rtcs) { - this.rtcs = rtcs; - } - - public String getMediaServerId() { - return mediaServerId; - } - - public void setMediaServerId(String mediaServerId) { - this.mediaServerId = mediaServerId; - } - - public Object getTracks() { - return tracks; - } - - public void setTracks(Object tracks) { - this.tracks = tracks; - } - - public String getStartTime() { - return startTime; - } - - public void setStartTime(String startTime) { - this.startTime = startTime; - } - - public String getEndTime() { - return endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public double getProgress() { - return progress; - } - - public void setProgress(double progress) { - this.progress = progress; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/SystemConfigInfo.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/SystemConfigInfo.java deleted file mode 100644 index 8d107790..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/SystemConfigInfo.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - -import com.genersoft.iot.vmp.common.VersionPo; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; - -public class SystemConfigInfo { - - private int serverPort; - private SipConfig sip; - private UserSetting addOn; - private VersionPo version; - - public int getServerPort() { - return serverPort; - } - - public void setServerPort(int serverPort) { - this.serverPort = serverPort; - } - - public SipConfig getSip() { - return sip; - } - - public void setSip(SipConfig sip) { - this.sip = sip; - } - - public UserSetting getAddOn() { - return addOn; - } - - public void setAddOn(UserSetting addOn) { - this.addOn = addOn; - } - - public VersionPo getVersion() { - return version; - } - - public void setVersion(VersionPo version) { - this.version = version; - } -} - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java deleted file mode 100644 index d293b8d4..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/bean/WVPResult.java +++ /dev/null @@ -1,75 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.bean; - - -import io.swagger.v3.oas.annotations.media.Schema; - -@Schema(description = "统一返回结果") -public class WVPResult implements Cloneable{ - - public WVPResult() { - } - - public WVPResult(int code, String msg, T data) { - this.code = code; - this.msg = msg; - this.data = data; - } - - - @Schema(description = "错误码,0为成功") - private int code; - @Schema(description = "描述,错误时描述错误原因") - private String msg; - @Schema(description = "数据") - private T data; - - - public static WVPResult success(T t, String msg) { - return new WVPResult<>(ErrorCode.SUCCESS.getCode(), msg, t); - } - - public static WVPResult success() { - return new WVPResult<>(ErrorCode.SUCCESS.getCode(), ErrorCode.SUCCESS.getMsg(), null); - } - - public static WVPResult success(T t) { - return success(t, ErrorCode.SUCCESS.getMsg()); - } - - public static WVPResult fail(int code, String msg) { - return new WVPResult<>(code, msg, null); - } - - public static WVPResult fail(ErrorCode errorCode) { - return fail(errorCode.getCode(), errorCode.getMsg()); - } - - public int getCode() { - return code; - } - - public void setCode(int code) { - this.code = code; - } - - public String getMsg() { - return msg; - } - - public void setMsg(String msg) { - this.msg = msg; - } - - public T getData() { - return data; - } - - public void setData(T data) { - this.data = data; - } - - @Override - public Object clone() throws CloneNotSupportedException { - return super.clone(); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java deleted file mode 100644 index b3485392..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/cloudRecord/CloudRecordController.java +++ /dev/null @@ -1,145 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.cloudRecord; - -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.PageInfo; -import com.genersoft.iot.vmp.vmanager.bean.RecordFile; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.apache.commons.lang3.ObjectUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.Calendar; -import java.util.List; - -@SuppressWarnings("rawtypes") -@Tag(name = "云端录像接口") - -@RestController -@RequestMapping("/gbs/cloud/record") -public class CloudRecordController { - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private SendRtpPortManager sendRtpPortManager; - - private final static Logger logger = LoggerFactory.getLogger(CloudRecordController.class); - - @Autowired - private ZlmHttpHookSubscribe hookSubscribe; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private UserSetting userSetting; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private RedisTemplate redisTemplate; - - @ResponseBody - @GetMapping("/date/list") - @Operation(summary = "查询存在云端录像的日期") - @Parameter(name = "app", description = "应用名", required = true) - @Parameter(name = "stream", description = "流ID", required = true) - @Parameter(name = "year", description = "年,置空则查询当年", required = false) - @Parameter(name = "month", description = "月,置空则查询当月", required = false) - @Parameter(name = "mediaServerId", description = "流媒体ID,置空则查询全部", required = false) - public List openRtpServer( - @RequestParam String app, - @RequestParam String stream, - @RequestParam(required = false) int year, - @RequestParam(required = false) int month, - @RequestParam(required = false) String mediaServerId - - ) { - logger.info("[云端录像] 查询存在云端录像的日期 app->{}, stream->{}, mediaServerId->{}, year->{}, month->{}", - app, stream, mediaServerId, year, month); - Calendar calendar = Calendar.getInstance(); - if (ObjectUtils.isEmpty(year)) { - year = calendar.get(Calendar.YEAR); - } - if (ObjectUtils.isEmpty(month)) { - month = calendar.get(Calendar.MONTH) + 1; - } - List mediaServerItems; - if (!ObjectUtils.isEmpty(mediaServerId)) { - mediaServerItems = new ArrayList<>(); - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); - if (mediaServerItem == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体: " + mediaServerId); - } - mediaServerItems.add(mediaServerItem); - } else { - mediaServerItems = mediaServerService.getAll(); - } - if (mediaServerItems.isEmpty()) { - return new ArrayList<>(); - } - - return mediaServerService.getRecordDates(app, stream, year, month, mediaServerItems); - } - - @ResponseBody - @GetMapping("/list") - @Operation(summary = "分页查询云端录像") - @Parameter(name = "app", description = "应用名", required = true) - @Parameter(name = "stream", description = "流ID", required = true) - @Parameter(name = "page", description = "当前页", required = false) - @Parameter(name = "count", description = "每页查询数量", required = false) - @Parameter(name = "startTime", description = "开始时间(yyyy-MM-dd HH:mm:ss)", required = true) - @Parameter(name = "endTime", description = "结束时间(yyyy-MM-dd HH:mm:ss)", required = true) - @Parameter(name = "mediaServerId", description = "流媒体ID,置空则查询全部流媒体", required = false) - public PageInfo openRtpServer( - @RequestParam String app, - @RequestParam String stream, - @RequestParam int page, - @RequestParam int count, - @RequestParam String startTime, - @RequestParam String endTime, - @RequestParam(required = false) String mediaServerId - - ) { - logger.info("[云端录像] 查询 app->{}, stream->{}, mediaServerId->{}, page->{}, count->{}, startTime->{}, endTime->{}", - app, stream, mediaServerId, page, count, startTime, endTime); - - List mediaServerItems; - if (!ObjectUtils.isEmpty(mediaServerId)) { - mediaServerItems = new ArrayList<>(); - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); - if (mediaServerItem == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到流媒体: " + mediaServerId); - } - mediaServerItems.add(mediaServerItem); - } else { - mediaServerItems = mediaServerService.getAll(); - } - if (mediaServerItems.isEmpty()) { - return new PageInfo<>(); - } - List records = mediaServerService.getRecords(app, stream, startTime, endTime, mediaServerItems); - PageInfo pageInfo = new PageInfo<>(records); - pageInfo.startPage(page, count); - return pageInfo; - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java deleted file mode 100644 index 2b93fb4b..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java +++ /dev/null @@ -1,177 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.MobilePosition; - -import cn.hutool.core.util.StrUtil; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.List; -import java.util.UUID; - -/** - * 位置信息管理 - */ -@Tag(name = "位置信息管理") - -@RestController -@RequestMapping("/api/position") -public class MobilePositionController { - - private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class); - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommander cmder; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private IDeviceChannelService deviceChannelService; - - /** - * 查询历史轨迹 - * @param deviceId 设备ID - * @param start 开始时间 - * @param end 结束时间 - * @return - */ - @Operation(summary = "查询历史轨迹") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号") - @Parameter(name = "start", description = "开始时间") - @Parameter(name = "end", description = "结束时间") - @GetMapping("/history/{deviceId}") - public List positions(@PathVariable String deviceId, @RequestParam(required = false) String channelId - , @RequestParam(required = false) String start, @RequestParam(required = false) String end) { - - if (StrUtil.isEmpty(start)) { - start = null; - } - if (StrUtil.isEmpty(end)) { - end = null; - } - return storager.queryMobilePositions(deviceId, channelId, start, end); - } - - /** - * 查询设备最新位置 - * @param deviceId 设备ID - * @return - */ - @Operation(summary = "查询设备最新位置") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @GetMapping("/latest/{deviceId}") - public MobilePosition latestPosition(@PathVariable String deviceId) { - return storager.queryLatestPosition(deviceId); - } - - /** - * 获取移动位置信息 - * @param deviceId 设备ID - * @return - */ - @Operation(summary = "获取移动位置信息") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @GetMapping("/realtime/{deviceId}") - public DeferredResult realTimePosition(@PathVariable String deviceId) { - Device device = storager.queryVideoDevice(deviceId); - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_MOBILE_POSITION + deviceId; - try { - cmder.mobilePostitionQuery(device, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("获取移动位置信息失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 获取移动位置信息: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - DeferredResult result = new DeferredResult(5*1000L); - result.onTimeout(()->{ - logger.warn(String.format("获取移动位置信息超时")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData("Timeout"); - resultHolder.invokeResult(msg); - }); - resultHolder.put(key, uuid, result); - return result; - } - - /** - * 订阅位置信息 - * @param deviceId 设备ID - * @param expires 订阅超时时间 - * @param interval 上报时间间隔 - * @return true = 命令发送成功 - */ - @Operation(summary = "订阅位置信息") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "expires", description = "订阅超时时间", required = true) - @Parameter(name = "interval", description = "上报时间间隔", required = true) - @GetMapping("/subscribe/{deviceId}") - public void positionSubscribe(@PathVariable String deviceId, - @RequestParam String expires, - @RequestParam String interval) { - if (StrUtil.isEmpty(interval)) { - interval = "5"; - } - - Device device = storager.queryVideoDevice(deviceId); - device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); - device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); - deviceService.updateDevice(device); - if (!deviceService.removeMobilePositionSubscribe(device)) { - throw new ControllerException(ErrorCode.ERROR100); - } - } - - /** - * 数据位置信息格式处理 - * @param deviceId 设备ID - * @return true = 命令发送成功 - */ - @Operation(summary = "数据位置信息格式处理") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @GetMapping("/transform/{deviceId}") - public void positionTransform(@PathVariable String deviceId) { - - Device device = deviceService.getDevice(deviceId); - if (device == null) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "未找到设备: " + deviceId); - } - boolean result = deviceChannelService.updateAllGps(device); - if (!result) { - throw new ControllerException(ErrorCode.ERROR100); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java deleted file mode 100644 index a46d2fdf..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/alarm/AlarmController.java +++ /dev/null @@ -1,151 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.alarm; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.service.IDeviceAlarmService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.Arrays; -import java.util.List; - -@Tag(name = "报警信息管理") - -@RestController -@RequestMapping("/gbs/alarm") -public class AlarmController { - - private final static Logger logger = LoggerFactory.getLogger(AlarmController.class); - - @Autowired - private IDeviceAlarmService deviceAlarmService; - - @Autowired - private ISIPCommander commander; - - @Autowired - private ISIPCommanderForPlatform commanderForPlatform; - - @Autowired - private IVideoManagerStorage storage; - - - /** - * 删除报警 - * - * @param id 报警id - * @param deviceIds 多个设备id,逗号分隔 - * @param time 结束时间(这个时间之前的报警会被删除) - * @return - */ - @DeleteMapping("/delete") - @Operation(summary = "删除报警") - @Parameter(name = "id", description = "ID") - @Parameter(name = "deviceIds", description = "多个设备id,逗号分隔") - @Parameter(name = "time", description = "结束时间") - public Integer delete( - @RequestParam(required = false) Integer id, - @RequestParam(required = false) String deviceIds, - @RequestParam(required = false) String time - ) { - if (ObjectUtils.isEmpty(id)) { - id = null; - } - if (ObjectUtils.isEmpty(deviceIds)) { - deviceIds = null; - } - - if (ObjectUtils.isEmpty(time)) { - time = null; - }else if (!DateUtil.verification(time, DateUtil.formatter) ){ - throw new ControllerException(ErrorCode.ERROR400.getCode(), "time格式为" + DateUtil.PATTERN); - } - List deviceIdList = null; - if (deviceIds != null) { - String[] deviceIdArray = deviceIds.split(","); - deviceIdList = Arrays.asList(deviceIdArray); - } - - return deviceAlarmService.clearAlarmBeforeTime(id, deviceIdList, time); - } - - /** - * 测试向上级/设备发送模拟报警通知 - * - * @param deviceId 报警id - * @return - */ - @GetMapping("/test/notify/alarm") - @Operation(summary = "测试向上级/设备发送模拟报警通知") - @Parameter(name = "deviceId", description = "设备国标编号") - public void delete(@RequestParam String deviceId) { - Device device = storage.queryVideoDevice(deviceId); - ParentPlatform platform = storage.queryParentPlatByServerGBId(deviceId); - DeviceAlarm deviceAlarm = new DeviceAlarm(); - deviceAlarm.setChannelId(deviceId); - deviceAlarm.setAlarmDescription("test"); - deviceAlarm.setAlarmMethod("1"); - deviceAlarm.setAlarmPriority("1"); - deviceAlarm.setAlarmTime(DateUtil.getNow()); - deviceAlarm.setAlarmType("1"); - deviceAlarm.setLongitude(115.33333); - deviceAlarm.setLatitude(39.33333); - - if (device != null && platform == null) { - - try { - commander.sendAlarmMessage(device, deviceAlarm); - } catch (InvalidArgumentException | SipException | ParseException e) { - - } - }else if (device == null && platform != null){ - try { - commanderForPlatform.sendAlarmMessage(platform, deviceAlarm); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - }else { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"无法确定" + deviceId + "是平台还是设备"); - } - - } - - /** - * 分页查询报警 - * - * @param entity 设备id - * @param page 当前页 - * @return - */ - @Operation(summary = "分页查询报警") - @Parameter(name = "page",description = "当前页",required = true) - @Parameter(name = "count",description = "每页查询数量",required = true) - @Parameter(name = "deviceId",description = "设备id") - @Parameter(name = "alarmPriority",description = "查询内容") - @Parameter(name = "alarmMethod",description = "查询内容") - @Parameter(name = "alarmType",description = "每页查询数量") - @Parameter(name = "startTime",description = "开始时间") - @Parameter(name = "endTime",description = "结束时间") - @GetMapping("/all") - public Page getAll(Page page, DeviceAlarm entity) { - return deviceAlarmService.listByPage(page, entity); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java deleted file mode 100644 index 45ce48ce..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java +++ /dev/null @@ -1,156 +0,0 @@ -/** - * 设备设置命令API接口 - * - * @author lawrencehj - * @date 2021年2月2日 - */ - -package com.genersoft.iot.vmp.vmanager.gb28181.device; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.UUID; - -@Tag(name = "国标设备配置") -@RestController -@RequestMapping("/gbs/device/config") -public class DeviceConfig { - - private final static Logger logger = LoggerFactory.getLogger(GbsDeviceManagerController.class); - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommander cmder; - - @Autowired - private DeferredResultHolder resultHolder; - - /** - * 看守位控制命令API接口 - * @param deviceId 设备ID - * @param channelId 通道ID - * @param name 名称 - * @param expiration 到期时间 - * @param heartBeatInterval 心跳间隔 - * @param heartBeatCount 心跳计数 - * @return - */ - @GetMapping("/basicParam/{deviceId}") - @Operation(summary = "基本配置设置命令") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "name", description = "名称") - @Parameter(name = "expiration", description = "到期时间") - @Parameter(name = "heartBeatInterval", description = "心跳间隔") - @Parameter(name = "heartBeatCount", description = "心跳计数") - public DeferredResult homePositionApi(@PathVariable String deviceId, - String channelId, - @RequestParam(required = false) String name, - @RequestParam(required = false) String expiration, - @RequestParam(required = false) String heartBeatInterval, - @RequestParam(required = false) String heartBeatCount) { - if (logger.isDebugEnabled()) { - logger.debug("报警复位API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONFIG + deviceId + channelId; - try { - cmder.deviceBasicConfigCmd(device, channelId, name, expiration, heartBeatInterval, heartBeatCount, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("设备配置操作失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 设备配置: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - DeferredResult result = new DeferredResult(3 * 1000L); - result.onTimeout(() -> { - logger.warn(String.format("设备配置操作超时, 设备未返回应答指令")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - JSONObject json = new JSONObject(); - json.put("DeviceID", deviceId); - json.put("Status", "Timeout"); - json.put("Description", "设备配置操作超时, 设备未返回应答指令"); - msg.setData(json); //("看守位控制操作超时, 设备未返回应答指令"); - resultHolder.invokeResult(msg); - }); - resultHolder.put(key, uuid, result); - return result; - } - - /** - * 设备配置查询请求API接口 - * @param deviceId 设备ID - * @param configType 配置类型 - * @param channelId 通道ID - * @return - */ - @Operation(summary = "设备配置查询请求") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "configType", description = "配置类型") - @GetMapping("/query/{deviceId}/{configType}") - public DeferredResult configDownloadApi(@PathVariable String deviceId, - @PathVariable String configType, - @RequestParam(required = false) String channelId) { - if (logger.isDebugEnabled()) { - logger.debug("设备状态查询API调用"); - } - String key = DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); - String uuid = UUID.randomUUID().toString(); - Device device = storager.queryVideoDevice(deviceId); - try { - cmder.deviceConfigQuery(device, channelId, configType, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("获取设备配置失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 获取设备配置: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - DeferredResult result = new DeferredResult (3 * 1000L); - result.onTimeout(()->{ - logger.warn(String.format("获取设备配置超时")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData("Timeout. Device did not response to this command."); - resultHolder.invokeResult(msg); - }); - resultHolder.put(key, uuid, result); - return result; - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java deleted file mode 100644 index 1b952ae3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java +++ /dev/null @@ -1,401 +0,0 @@ -/** - * 设备控制命令API接口 - * - * @author lawrencehj - * @date 2021年2月1日 - */ - -package com.genersoft.iot.vmp.vmanager.gb28181.device; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.UUID; - -@Tag(name = "国标设备控制") - -@RestController -@RequestMapping("/gbs/device/control") -public class DeviceControl { - - private final static Logger logger = LoggerFactory.getLogger(GbsDeviceManagerController.class); - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommander cmder; - - @Autowired - private DeferredResultHolder resultHolder; - - /** - * 远程启动控制命令API接口 - * - * @param deviceId 设备ID - */ - @Operation(summary = "远程启动控制命令") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @GetMapping("/teleboot/{deviceId}") - public void teleBootApi(@PathVariable String deviceId) { - if (logger.isDebugEnabled()) { - logger.debug("设备远程启动API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - try { - cmder.teleBootCmd(device); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 远程启动: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - } - - /** - * 录像控制命令API接口 - * - * @param deviceId 设备ID - * @param recordCmdStr Record:手动录像,StopRecord:停止手动录像 - * @param channelId 通道编码(可选) - */ - @Operation(summary = "录像控制") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "recordCmdStr", description = "命令, 可选值:Record(手动录像),StopRecord(停止手动录像)", required = true) - @GetMapping("/record/{deviceId}/{recordCmdStr}") - public DeferredResult> recordApi(@PathVariable String deviceId, - @PathVariable String recordCmdStr, String channelId) { - if (logger.isDebugEnabled()) { - logger.debug("开始/停止录像API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId; - DeferredResult> result = new DeferredResult>(3 * 1000L); - result.onTimeout(() -> { - logger.warn(String.format("开始/停止录像操作超时, 设备未返回应答指令")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setId(uuid); - msg.setData("Timeout. Device did not response to this command."); - resultHolder.invokeAllResult(msg); - }); - if (resultHolder.exist(key, null)){ - return result; - } - resultHolder.put(key, uuid, result); - try { - cmder.recordCmd(device, channelId, recordCmdStr, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("开始/停止录像操作失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeAllResult(msg); - },null); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 开始/停止录像: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - - return result; - } - - /** - * 报警布防/撤防命令API接口 - * - * @param deviceId 设备ID - * @param guardCmdStr SetGuard:布防,ResetGuard:撤防 - */ - @Operation(summary = "布防/撤防命令") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "guardCmdStr", description = "命令, 可选值:SetGuard(布防),ResetGuard(撤防)", required = true) - @GetMapping("/guard/{deviceId}/{guardCmdStr}") - public DeferredResult guardApi(@PathVariable String deviceId, @PathVariable String guardCmdStr) { - if (logger.isDebugEnabled()) { - logger.debug("布防/撤防API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + deviceId; - String uuid =UUID.randomUUID().toString(); - try { - cmder.guardCmd(device, guardCmdStr, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("布防/撤防操作失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - },null); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage()); - } - DeferredResult result = new DeferredResult<>(3 * 1000L); - resultHolder.put(key, uuid, result); - result.onTimeout(() -> { - logger.warn(String.format("布防/撤防操作超时, 设备未返回应答指令")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setId(uuid); - msg.setData("Timeout. Device did not response to this command."); - resultHolder.invokeResult(msg); - }); - - return result; - } - - /** - * 报警复位API接口 - * - * @param deviceId 设备ID - * @param alarmMethod 报警方式(可选) - * @param alarmType 报警类型(可选) - */ - @Operation(summary = "报警复位") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "alarmMethod", description = "报警方式") - @Parameter(name = "alarmType", description = "报警类型") - @GetMapping("/reset_alarm/{deviceId}") - public DeferredResult> resetAlarmApi(@PathVariable String deviceId, String channelId, - @RequestParam(required = false) String alarmMethod, - @RequestParam(required = false) String alarmType) { - if (logger.isDebugEnabled()) { - logger.debug("报警复位API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + deviceId + channelId; - try { - cmder.alarmCmd(device, alarmMethod, alarmType, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("报警复位操作失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - },null); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 报警复位: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - DeferredResult> result = new DeferredResult>(3 * 1000L); - result.onTimeout(() -> { - logger.warn(String.format("报警复位操作超时, 设备未返回应答指令")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData("Timeout. Device did not response to this command."); - resultHolder.invokeResult(msg); - }); - resultHolder.put(key, uuid, result); - return result; - } - - /** - * 强制关键帧API接口 - * - * @param deviceId 设备ID - * @param channelId 通道ID - */ - @Operation(summary = "强制关键帧") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号") - @GetMapping("/i_frame/{deviceId}") - public JSONObject iFrame(@PathVariable String deviceId, - @RequestParam(required = false) String channelId) { - if (logger.isDebugEnabled()) { - logger.debug("强制关键帧API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - try { - cmder.iFrameCmd(device, channelId); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - JSONObject json = new JSONObject(); - json.put("DeviceID", deviceId); - json.put("ChannelID", channelId); - json.put("Result", "OK"); - return json; - } - - /** - * 看守位控制命令API接口 - * - * @param deviceId 设备ID - * @param enabled 看守位使能1:开启,0:关闭 - * @param resetTime 自动归位时间间隔(可选) - * @param presetIndex 调用预置位编号(可选) - * @param channelId 通道编码(可选) - */ - @Operation(summary = "看守位控制") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "enabled", description = "是否开启看守位 1:开启,0:关闭", required = true) - @Parameter(name = "presetIndex", description = "调用预置位编号") - @Parameter(name = "resetTime", description = "自动归位时间间隔") - @GetMapping("/home_position/{deviceId}/{enabled}") - public DeferredResult homePositionApi(@PathVariable String deviceId, - @PathVariable String enabled, - @RequestParam(required = false) String resetTime, - @RequestParam(required = false) String presetIndex, - String channelId) { - if (logger.isDebugEnabled()) { - logger.debug("报警复位API调用"); - } - String key = DeferredResultHolder.CALLBACK_CMD_DEVICECONTROL + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); - String uuid = UUID.randomUUID().toString(); - Device device = storager.queryVideoDevice(deviceId); - try { - cmder.homePositionCmd(device, channelId, enabled, resetTime, presetIndex, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("看守位控制操作失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - },null); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 看守位控制: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - DeferredResult result = new DeferredResult<>(3 * 1000L); - result.onTimeout(() -> { - logger.warn(String.format("看守位控制操作超时, 设备未返回应答指令")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - JSONObject json = new JSONObject(); - json.put("DeviceID", deviceId); - json.put("Status", "Timeout"); - json.put("Description", "看守位控制操作超时, 设备未返回应答指令"); - msg.setData(json); //("看守位控制操作超时, 设备未返回应答指令"); - resultHolder.invokeResult(msg); - }); - resultHolder.put(key, uuid, result); - return result; - } - - /** - * 拉框放大 - * @param deviceId 设备id - * @param channelId 通道id - * @param length 播放窗口长度像素值 - * @param width 播放窗口宽度像素值 - * @param midpointx 拉框中心的横轴坐标像素值 - * @param midpointy 拉框中心的纵轴坐标像素值 - * @param lengthx 拉框长度像素值 - * @param lengthy 拉框宽度像素值 - * @return - */ - @Operation(summary = "拉框放大") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "length", description = "播放窗口长度像素值", required = true) - @Parameter(name = "midpointx", description = "拉框中心的横轴坐标像素值", required = true) - @Parameter(name = "midpointy", description = "拉框中心的纵轴坐标像素值", required = true) - @Parameter(name = "lengthx", description = "拉框长度像素值", required = true) - @Parameter(name = "lengthy", description = "lengthy", required = true) - @GetMapping("drag_zoom/zoom_in") - public void dragZoomIn(@RequestParam String deviceId, - @RequestParam(required = false) String channelId, - @RequestParam int length, - @RequestParam int width, - @RequestParam int midpointx, - @RequestParam int midpointy, - @RequestParam int lengthx, - @RequestParam int lengthy) throws RuntimeException { - if (logger.isDebugEnabled()) { - logger.debug(String.format("设备拉框放大 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy)); - } - Device device = storager.queryVideoDevice(deviceId); - StringBuffer cmdXml = new StringBuffer(200); - cmdXml.append("\r\n"); - cmdXml.append("" + length+ "\r\n"); - cmdXml.append("" + width+ "\r\n"); - cmdXml.append("" + midpointx+ "\r\n"); - cmdXml.append("" + midpointy+ "\r\n"); - cmdXml.append("" + lengthx+ "\r\n"); - cmdXml.append("" + lengthy+ "\r\n"); - cmdXml.append("\r\n"); - try { - cmder.dragZoomCmd(device, channelId, cmdXml.toString()); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 拉框放大: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - } - - /** - * 拉框缩小 - * @param deviceId 设备id - * @param channelId 通道id - * @param length 播放窗口长度像素值 - * @param width 播放窗口宽度像素值 - * @param midpointx 拉框中心的横轴坐标像素值 - * @param midpointy 拉框中心的纵轴坐标像素值 - * @param lengthx 拉框长度像素值 - * @param lengthy 拉框宽度像素值 - * @return - */ - @Operation(summary = "拉框放大") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号") - @Parameter(name = "length", description = "播放窗口长度像素值", required = true) - @Parameter(name = "width", description = "拉框中心的横轴坐标像素值", required = true) - @Parameter(name = "midpointx", description = "拉框中心的横轴坐标像素值", required = true) - @Parameter(name = "midpointy", description = "拉框中心的纵轴坐标像素值", required = true) - @Parameter(name = "lengthx", description = "拉框长度像素值", required = true) - @Parameter(name = "lengthy", description = "拉框宽度像素值", required = true) - @GetMapping("/drag_zoom/zoom_out") - public void dragZoomOut(@RequestParam String deviceId, - @RequestParam(required = false) String channelId, - @RequestParam int length, - @RequestParam int width, - @RequestParam int midpointx, - @RequestParam int midpointy, - @RequestParam int lengthx, - @RequestParam int lengthy){ - - if (logger.isDebugEnabled()) { - logger.debug(String.format("设备拉框缩小 API调用,deviceId:%s ,channelId:%s ,length:%d ,width:%d ,midpointx:%d ,midpointy:%d ,lengthx:%d ,lengthy:%d",deviceId, channelId, length, width, midpointx, midpointy,lengthx, lengthy)); - } - Device device = storager.queryVideoDevice(deviceId); - StringBuffer cmdXml = new StringBuffer(200); - cmdXml.append("\r\n"); - cmdXml.append("" + length+ "\r\n"); - cmdXml.append("" + width+ "\r\n"); - cmdXml.append("" + midpointx+ "\r\n"); - cmdXml.append("" + midpointy+ "\r\n"); - cmdXml.append("" + lengthx+ "\r\n"); - cmdXml.append("" + lengthy+ "\r\n"); - cmdXml.append("\r\n"); - try { - cmder.dragZoomCmd(device, channelId, cmdXml.toString()); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 拉框缩小: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/GbsDeviceManagerController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/GbsDeviceManagerController.java deleted file mode 100644 index a3722df1..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/GbsDeviceManagerController.java +++ /dev/null @@ -1,509 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.device; - -import cn.hutool.core.util.StrUtil; -import com.alibaba.fastjson2.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.SyncStatus; -import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; -import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; -import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.vmanager.bean.BaseTree; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.iteaj.framework.spi.gbs.GbsRealtimeTree; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import com.iteaj.framework.BaseController; -import com.iteaj.framework.result.Result; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import org.apache.tomcat.util.http.fileupload.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; -import org.springframework.util.CollectionUtils; -import org.springframework.util.ObjectUtils; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.nio.file.Files; -import java.text.ParseException; -import java.util.*; -import java.util.stream.Collectors; - -/** - * 国标(GB28181)设备管理 - */ -@RestController -//@RequestMapping("/gbs/device") -public class GbsDeviceManagerController extends BaseController { - - private final static Logger logger = LoggerFactory.getLogger(GbsDeviceManagerController.class); - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IDeviceChannelService deviceChannelService; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private SIPCommander cmder; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private DynamicTask dynamicTask; - - /** - * 使用ID查询国标设备 - * @param deviceId 国标ID - * @return 国标设备 - */ - @GetMapping("/edit") - public Result edit(String deviceId){ - Device device = deviceService.getDevice(deviceId); - return success(device); - } - - /** - * 分页查询国标设备 - * @param page 当前页 - * @param device 设备参数 - * @return 分页国标列表 - */ - @GetMapping("/view") - public Result> view(Page page, Device device){ - deviceService.detailByPage(page, device); - return success(page); - } - - /** - * 树形结构的设备-通道列表 - * @param deviceId 设备id 用于获取下面的通道列表 - * @return - */ - @GetMapping("/trees") - public Result> trees(String deviceId) { - if(StrUtil.isBlank(deviceId)) { - List devices = deviceService.getAll(); - if(!CollectionUtils.isEmpty(devices)) { - List realtimeTrees = devices.stream() - .map(item -> GbsRealtimeTree.buildDevice(item.getDeviceId(), item.getName(), item.isOnLine(), item.getChannelCount())) - .collect(Collectors.toList()); - return success(realtimeTrees); - } - } else { - List deviceChannels = deviceService.queryVideoDeviceInTreeNode(deviceId, null); - if(!CollectionUtils.isEmpty(deviceChannels)) { - List realtimeTrees = deviceChannels.stream() - .map(item -> GbsRealtimeTree.buildChannel(item.getDeviceId(), item.getChannelId(), item.getName(), item.isStatus())) - .collect(Collectors.toList()); - return success(realtimeTrees); - } - } - - return success(); - } - - /** - * 分页查询通道数 - * - * @param deviceId 设备id - * @param page 当前页 - * @param query 查询内容 - * @param status 是否在线 在线 true / 离线 false - * @param channelType 设备 false/子目录 true - * @param catalogUnderDevice 是否直属与设备的目录 - * @return 通道列表 - */ - @GetMapping("/channels") - public Result> channels(Page page, String deviceId, String query, Boolean status, Boolean channelType, Boolean catalogUnderDevice) { - if (ObjectUtils.isEmpty(query)) { - query = null; - } - - Page channelPage = storager.queryChannelsByDeviceId(page, deviceId, query, channelType, status, catalogUnderDevice); - return success(channelPage); - } - - /** - * 同步设备通道 - * @param deviceId 设备id - * @return - */ - @GetMapping("/sync") - public WVPResult devicesSync(String deviceId){ - - if (logger.isDebugEnabled()) { - logger.debug("设备通道信息同步API调用,deviceId:" + deviceId); - } - Device device = storager.queryVideoDevice(deviceId); - boolean status = deviceService.isSyncRunning(deviceId); - // 已存在则返回进度 - if (status) { - SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId); - return WVPResult.success(channelSyncStatus); - } - deviceService.sync(device); - - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(0); - wvpResult.setMsg("开始同步"); - return wvpResult; - } - - /** - * 移除设备 - * @param deviceId 设备id - * @return - */ - @Operation(summary = "移除设备") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @DeleteMapping("/devices/{deviceId}/delete") - public String delete(@PathVariable String deviceId){ - - if (logger.isDebugEnabled()) { - logger.debug("设备信息删除API调用,deviceId:" + deviceId); - } - - // 清除redis记录 - boolean isSuccess = deviceService.delete(deviceId); - if (isSuccess) { - inviteStreamService.clearInviteInfo(deviceId); - // 停止此设备的订阅更新 - Set allKeys = dynamicTask.getAllKeys(); - for (String key : allKeys) { - if (key.startsWith(deviceId)) { - Runnable runnable = dynamicTask.get(key); - if (runnable instanceof ISubscribeTask) { - ISubscribeTask subscribeTask = (ISubscribeTask) runnable; - subscribeTask.stop(); - } - dynamicTask.stop(key); - } - } - JSONObject json = new JSONObject(); - json.put("deviceId", deviceId); - return json.toString(); - } else { - logger.warn("设备信息删除API调用失败!"); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备信息删除API调用失败!"); - } - } - - /** - * 分页查询子目录通道 - * @param deviceId 通道id - * @param channelId 通道id - * @param page 当前页 - * @param query 查询内容 - * @param online 是否在线 - * @param channelType 通道类型 - * @return 子通道列表 - */ - @Operation(summary = "分页查询子目录通道") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "page", description = "当前页", required = true) - @Parameter(name = "count", description = "每页查询数量", required = true) - @Parameter(name = "query", description = "查询内容") - @Parameter(name = "online", description = "是否在线") - @Parameter(name = "channelType", description = "设备/子目录-> false/true") - @GetMapping("/sub_channels/{deviceId}/{channelId}/channels") - public Page subChannels(Page page, @PathVariable String deviceId, @PathVariable String channelId - , @RequestParam(required = false) String query, @RequestParam(required = false) Boolean online - , @RequestParam(required = false) Boolean channelType){ - - DeviceChannel deviceChannel = storager.queryChannel(deviceId,channelId); - if (deviceChannel == null) { - return page; - } - - return storager.querySubChannels(page, deviceId, channelId, query, channelType, online); - } - - /** - * 更新通道信息 - * @param deviceId 设备id - * @param channel 通道 - * @return - */ - @Operation(summary = "更新通道信息") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channel", description = "通道信息", required = true) - @PostMapping("/channel/update/{deviceId}") - public void updateChannel(@PathVariable String deviceId,DeviceChannel channel){ - deviceChannelService.updateChannel(deviceId, channel); - } - - /** - * 修改数据流传输模式 - * @param deviceId 设备id - * @param streamMode 数据流传输模式 - * @return - */ - @Operation(summary = "修改数据流传输模式") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "streamMode", description = "数据流传输模式, 取值:" + - "UDP(udp传输),TCP-ACTIVE(tcp主动模式,暂不支持),TCP-PASSIVE(tcp被动模式)", required = true) - @PostMapping("/transport/{deviceId}/{streamMode}") - public void updateTransport(@PathVariable String deviceId, @PathVariable String streamMode){ - Device device = deviceService.getDevice(deviceId); - device.setStreamMode(streamMode); - deviceService.updateCustomDevice(device); - } - - /** - * 添加设备信息 - * @param device 设备信息 - * @return - */ - @Operation(summary = "添加设备信息") - @Parameter(name = "device", description = "设备", required = true) - @PostMapping("/device/add/") - public void addDevice(Device device){ - - if (device == null || device.getDeviceId() == null) { - throw new ControllerException(ErrorCode.ERROR400); - } - - // 查看deviceId是否存在 - boolean exist = deviceService.isExist(device.getDeviceId()); - if (exist) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备编号已存在"); - } - deviceService.addDevice(device); - } - - /** - * 新增或更新设备信息 - * @param device 设备信息 - * @return - */ - @PostMapping("/saveOrUpdate") - public Result saveOrUpdate(@Validated @RequestBody Device device){ - if(device.getId() == null) { - deviceService.addDevice(device); - } else { - deviceService.updateDevice(device); - } - - return success(); - } - - /** - * 设备状态查询请求API接口 - * - * @param deviceId 设备id - */ - @Operation(summary = "设备状态查询") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @GetMapping("/devices/{deviceId}/status") - public DeferredResult> deviceStatusApi(@PathVariable String deviceId) { - if (logger.isDebugEnabled()) { - logger.debug("设备状态查询API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_DEVICESTATUS + deviceId; - DeferredResult> result = new DeferredResult>(2*1000L); - if(device == null) { - result.setResult(new ResponseEntity(String.format("设备%s不存在", deviceId),HttpStatus.OK)); - return result; - } - try { - cmder.deviceStatusQuery(device, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("获取设备状态失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 获取设备状态: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - result.onTimeout(()->{ - logger.warn(String.format("获取设备状态超时")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData("Timeout. Device did not response to this command."); - resultHolder.invokeResult(msg); - }); - resultHolder.put(DeferredResultHolder.CALLBACK_CMD_DEVICESTATUS + deviceId, uuid, result); - return result; - } - - /** - * 设备报警查询请求API接口 - * @param deviceId 设备id - * @param startPriority 报警起始级别(可选) - * @param endPriority 报警终止级别(可选) - * @param alarmMethod 报警方式条件(可选) - * @param alarmType 报警类型 - * @param startTime 报警发生起始时间(可选) - * @param endTime 报警发生终止时间(可选) - * @return true = 命令发送成功 - */ - @Operation(summary = "设备状态查询") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "startPriority", description = "报警起始级别") - @Parameter(name = "endPriority", description = "报警终止级别") - @Parameter(name = "alarmMethod", description = "报警方式条件") - @Parameter(name = "alarmType", description = "报警类型") - @Parameter(name = "startTime", description = "报警发生起始时间") - @Parameter(name = "endTime", description = "报警发生终止时间") - @GetMapping("/alarm/{deviceId}") - public DeferredResult> alarmApi(@PathVariable String deviceId, - @RequestParam(required = false) String startPriority, - @RequestParam(required = false) String endPriority, - @RequestParam(required = false) String alarmMethod, - @RequestParam(required = false) String alarmType, - @RequestParam(required = false) String startTime, - @RequestParam(required = false) String endTime) { - if (logger.isDebugEnabled()) { - logger.debug("设备报警查询API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - String key = DeferredResultHolder.CALLBACK_CMD_ALARM + deviceId; - String uuid = UUID.randomUUID().toString(); - try { - cmder.alarmInfoQuery(device, startPriority, endPriority, alarmMethod, alarmType, startTime, endTime, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("设备报警查询失败,错误码: %s, %s",event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 设备报警查询: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - DeferredResult> result = new DeferredResult> (3 * 1000L); - result.onTimeout(()->{ - logger.warn(String.format("设备报警查询超时")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData("设备报警查询超时"); - resultHolder.invokeResult(msg); - }); - resultHolder.put(DeferredResultHolder.CALLBACK_CMD_ALARM + deviceId, uuid, result); - return result; - } - - - @GetMapping("/{deviceId}/sync_status") - @Operation(summary = "获取通道同步进度") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - public WVPResult getSyncStatus(@PathVariable String deviceId) { - SyncStatus channelSyncStatus = deviceService.getChannelSyncStatus(deviceId); - WVPResult wvpResult = new WVPResult<>(); - if (channelSyncStatus == null) { - wvpResult.setCode(-1); - wvpResult.setMsg("同步尚未开始"); - }else { - wvpResult.setCode(ErrorCode.SUCCESS.getCode()); - wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); - wvpResult.setData(channelSyncStatus); - if (channelSyncStatus.getErrorMsg() != null) { - wvpResult.setMsg(channelSyncStatus.getErrorMsg()); - } - } - return wvpResult; - } - - @GetMapping("/{deviceId}/subscribe_info") - @Operation(summary = "获取设备的订阅状态") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - public WVPResult> getSubscribeInfo(@PathVariable String deviceId) { - Set allKeys = dynamicTask.getAllKeys(); - Map dialogStateMap = new HashMap<>(); - for (String key : allKeys) { - if (key.startsWith(deviceId)) { - ISubscribeTask subscribeTask = (ISubscribeTask)dynamicTask.get(key); - if (subscribeTask instanceof CatalogSubscribeTask) { - dialogStateMap.put("catalog", 1); - }else if (subscribeTask instanceof MobilePositionSubscribeTask) { - dialogStateMap.put("mobilePosition", 1); - } - } - } - WVPResult> wvpResult = new WVPResult<>(); - wvpResult.setCode(0); - wvpResult.setData(dialogStateMap); - return wvpResult; - } - - @GetMapping("/snap/{deviceId}/{channelId}") - @Operation(summary = "请求截图") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "mark", description = "标识", required = false) - public void getSnap(HttpServletResponse resp, @PathVariable String deviceId, @PathVariable String channelId, @RequestParam(required = false) String mark) { - - try { - final InputStream in = Files.newInputStream(new File("snap" + File.separator + deviceId + "_" + channelId + (mark == null? ".jpg": ("_" + mark + ".jpg"))).toPath()); - resp.setContentType(MediaType.IMAGE_PNG_VALUE); - ServletOutputStream outputStream = resp.getOutputStream(); - IOUtils.copy(in, resp.getOutputStream()); - in.close(); - outputStream.close(); - } catch (IOException e) { - resp.setStatus(HttpServletResponse.SC_NOT_FOUND); - } - } - - /** - * 查询国标树 - * @param deviceId 设备ID - * @param parentId 父ID - * @return 国标设备 - */ - @Operation(summary = "查询国标树") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "parentId", description = "父级国标编号") - @Parameter(name = "onlyCatalog", description = "只获取目录") - @Parameter(name = "page", description = "当前页", required = true) - @Parameter(name = "count", description = "每页条数", required = true) - @GetMapping("/tree/{deviceId}") - public ResponseEntity>> getTree(@PathVariable String deviceId, - @RequestParam(required = false) String parentId, - @RequestParam(required = false) Boolean onlyCatalog){ - - List> treeData = deviceService.queryVideoDeviceTree(deviceId, parentId, onlyCatalog); - - return new ResponseEntity<>(treeData, HttpStatus.OK); - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java deleted file mode 100644 index 71e470da..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java +++ /dev/null @@ -1,110 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.gbStream; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean.GbStreamParam; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; - -import java.util.List; - -@Tag(name = "视频流关联到级联平台") - -@RestController -@RequestMapping("/gbs/gbStream") -public class GbStreamController { - - private final static Logger logger = LoggerFactory.getLogger(GbStreamController.class); - - @Autowired - private IGbStreamService gbStreamService; - - @Autowired - private IPlatformService platformService; - - - /** - * 查询国标通道 - * @param page 当前页 - * @return - */ - @Operation(summary = "查询国标通道") - @Parameter(name = "page", description = "当前页", required = true) - @Parameter(name = "count", description = "每页条数", required = true) - @Parameter(name = "platformId", description = "平台ID", required = true) - @Parameter(name = "catalogId", description = "目录ID") - @Parameter(name = "query", description = "查询内容") - @Parameter(name = "mediaServerId", description = "流媒体ID") - @GetMapping(value = "/list") - @ResponseBody - public Page list(Page page, GbStream entity){ - // catalogId 为null 查询未在平台下分配的数据 - // catalogId 不为null 查询平台下这个,目录下的通道 - return gbStreamService.getAll(page, entity); - } - - - /** - * 移除国标关联 - * @param gbStreamParam - * @return - */ - @Operation(summary = "移除国标关联") - @DeleteMapping(value = "/del") - @ResponseBody - public void del(@RequestBody GbStreamParam gbStreamParam){ - - if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().size() == 0) { - if (gbStreamParam.isAll()) { - gbStreamService.delAllPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId()); - } - }else { - gbStreamService.delPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getGbStreams()); - } - - } - - /** - * 保存国标关联 - * @param gbStreamParam - * @return - */ - @Operation(summary = "保存国标关联") - @PostMapping(value = "/add") - @ResponseBody - public void add(@RequestBody GbStreamParam gbStreamParam){ - if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().size() == 0) { - if (gbStreamParam.isAll()) { - List allGBChannels = gbStreamService.getAllGBChannels(gbStreamParam.getPlatformId()); - gbStreamService.addPlatformInfo(allGBChannels, gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId()); - } - }else { - gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId()); - } - } - - /** - * 保存国标关联 - * @param gbId - * @return - */ - @Operation(summary = "保存国标关联") - @GetMapping(value = "/addWithGbid") - @ResponseBody - public void add(String gbId, String platformGbId, @RequestParam(required = false) String catalogGbId){ - List gbStreams = gbStreamService.getGbChannelWithGbid(gbId); - if (gbStreams.isEmpty()) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "gbId的信息未找到"); - } - gbStreamService.addPlatformInfo(gbStreams, platformGbId, catalogGbId); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java deleted file mode 100644 index 3705c709..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java +++ /dev/null @@ -1,54 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean; - -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import io.swagger.v3.oas.annotations.media.Schema; - -import java.util.List; - -@Schema(description = "国标关联参数") -public class GbStreamParam { - - @Schema(description = "平台ID") - private String platformId; - - @Schema(description = "目录ID") - private String catalogId; - - @Schema(description = "关联所有通道") - private boolean all; - - @Schema(description = "流国标信息列表") - private List gbStreams; - - public String getPlatformId() { - return platformId; - } - - public String getCatalogId() { - return catalogId; - } - - public void setCatalogId(String catalogId) { - this.catalogId = catalogId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public List getGbStreams() { - return gbStreams; - } - - public void setGbStreams(List gbStreams) { - this.gbStreams = gbStreams; - } - - public boolean isAll() { - return all; - } - - public void setAll(boolean all) { - this.all = all; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java deleted file mode 100644 index 466a3cb2..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java +++ /dev/null @@ -1,118 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.media; - -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; -import com.genersoft.iot.vmp.service.IMediaService; -import com.genersoft.iot.vmp.service.IStreamProxyService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.StreamContent; -import com.iteaj.framework.security.SecurityUtil; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.servlet.http.HttpServletRequest; - - -@Tag(name = "媒体流相关") -@Controller - -@RequestMapping(value = "/api/media") -public class MediaController { - - private final static Logger logger = LoggerFactory.getLogger(MediaController.class); - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IMediaService mediaService; - @Autowired - private IStreamProxyService streamProxyService; - - - /** - * 根据应用名和流id获取播放地址 - * @param app 应用名 - * @param stream 流id - * @return - */ - @Operation(summary = "根据应用名和流id获取播放地址") - @Parameter(name = "app", description = "应用名", required = true) - @Parameter(name = "stream", description = "流id", required = true) - @Parameter(name = "mediaServerId", description = "媒体服务器id") - @Parameter(name = "callId", description = "推流时携带的自定义鉴权ID") - @Parameter(name = "useSourceIpAsStreamIp", description = "是否使用请求IP作为返回的地址IP") - @GetMapping(value = "/stream_info_by_app_and_stream") - @ResponseBody - public StreamContent getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app, - @RequestParam String stream, - @RequestParam(required = false) String mediaServerId, - @RequestParam(required = false) String callId, - @RequestParam(required = false) Boolean useSourceIpAsStreamIp){ - boolean authority = false; - if (callId != null) { - // 权限校验 - StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); - if (streamAuthorityInfo != null - && streamAuthorityInfo.getCallId() != null - && streamAuthorityInfo.getCallId().equals(callId)) { - authority = true; - }else { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "获取播放地址鉴权失败"); - } - }else { - // 是否登陆用户, 登陆用户返回完整信息 - if (SecurityUtil.isLogin()) { - authority = true; - } - } - - StreamInfo streamInfo; - - if (useSourceIpAsStreamIp != null && useSourceIpAsStreamIp) { - String host = request.getHeader("Host"); - String localAddr = host.split(":")[0]; - logger.info("使用{}作为返回流的ip", localAddr); - streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority); - }else { - streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority); - } - - if (streamInfo != null){ - return new StreamContent(streamInfo); - }else { - //获取流失败,重启拉流后重试一次 - streamProxyService.stop(app,stream); - boolean start = streamProxyService.start(app, stream); - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - logger.error("[线程休眠失败], {}", e.getMessage()); - } - if (useSourceIpAsStreamIp != null && useSourceIpAsStreamIp) { - String host = request.getHeader("Host"); - String localAddr = host.split(":")[0]; - logger.info("使用{}作为返回流的ip", localAddr); - streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority); - }else { - streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority); - } - if (streamInfo != null){ - return new StreamContent(streamInfo); - }else { - throw new ControllerException(ErrorCode.ERROR100); - } - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java deleted file mode 100644 index 55a01368..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ /dev/null @@ -1,553 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.platform; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; -import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; -import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.service.IDeviceChannelService; -import com.genersoft.iot.vmp.service.IGbStreamService; -import com.genersoft.iot.vmp.service.IPlatformChannelService; -import com.genersoft.iot.vmp.service.IPlatformService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.List; - -/** - * 级联平台管理 - */ -@Tag(name = "级联平台管理") - -@RestController -@RequestMapping("/gbs/platform") -public class PlatformController { - - private final static Logger logger = LoggerFactory.getLogger(PlatformController.class); - - @Autowired - private UserSetting userSetting; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IPlatformChannelService platformChannelService; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private SubscribeHolder subscribeHolder; - - @Autowired - private ISIPCommanderForPlatform commanderForPlatform; - - @Autowired - private SipConfig sipConfig; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private IPlatformService platformService; - - @Autowired - private IDeviceChannelService deviceChannelService; - - @Autowired - private IGbStreamService gbStreamService; - - /** - * 获取国标服务的配置 - * - * @return - */ - @Operation(summary = "获取国标服务的配置") - @GetMapping("/server_config") - public JSONObject serverConfig() { - JSONObject result = new JSONObject(); - result.put("deviceIp", sipConfig.getIp()); - result.put("devicePort", sipConfig.getPort()); - result.put("username", sipConfig.getId()); - result.put("password", sipConfig.getPassword()); - return result; - } - - /** - * 获取级联服务器信息 - * - * @return - */ - @Operation(summary = "获取级联服务器信息") - @Parameter(name = "id", description = "平台国标编号", required = true) - @GetMapping("/info/{id}") - public ParentPlatform getPlatform(@PathVariable String id) { - ParentPlatform parentPlatform = platformService.queryPlatformByServerGBId(id); - if (parentPlatform != null) { - return parentPlatform; - } else { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未查询到此平台"); - } - } - - /** - * 分页查询级联平台 - * - * @param page 分页信息 - * @param entity 参数 - * @return - */ - @GetMapping("/query/{count}/{page}") - @Operation(summary = "分页查询级联平台") - @Parameter(name = "page", description = "当前页", required = true) - @Parameter(name = "count", description = "每页条数", required = true) - public Page platforms(Page page, ParentPlatform entity) { - - Page parentPlatformPageInfo = platformService.parentPlatformByPage(page, entity); - if (parentPlatformPageInfo.getRecords().size() > 0) { - for (ParentPlatform platform : parentPlatformPageInfo.getRecords()) { - platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null); - platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) != null); - } - } - return parentPlatformPageInfo; - } - - /** - * 添加上级平台信息 - * - * @param parentPlatform - * @return - */ - @Operation(summary = "添加上级平台信息") - @PostMapping("/add") - @ResponseBody - public void addPlatform(@RequestBody ParentPlatform parentPlatform) { - - if (logger.isDebugEnabled()) { - logger.debug("保存上级平台信息API调用"); - } - if (ObjectUtils.isEmpty(parentPlatform.getName()) - || ObjectUtils.isEmpty(parentPlatform.getServerGBId()) - || ObjectUtils.isEmpty(parentPlatform.getServerGBDomain()) - || ObjectUtils.isEmpty(parentPlatform.getServerIp()) - || ObjectUtils.isEmpty(parentPlatform.getServerPort()) - || ObjectUtils.isEmpty(parentPlatform.getDeviceGBId()) - || ObjectUtils.isEmpty(parentPlatform.getExpires()) - || ObjectUtils.isEmpty(parentPlatform.getKeepTimeout()) - || ObjectUtils.isEmpty(parentPlatform.getTransport()) - || ObjectUtils.isEmpty(parentPlatform.getCharacterSet()) - ) { - throw new ControllerException(ErrorCode.ERROR400); - } - if (parentPlatform.getServerPort() < 0 || parentPlatform.getServerPort() > 65535) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "error severPort"); - } - - - ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId()); - if (parentPlatformOld != null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台 " + parentPlatform.getServerGBId() + " 已存在"); - } - parentPlatform.setCreateTime(DateUtil.getNow()); - parentPlatform.setUpdateTime(DateUtil.getNow()); - boolean updateResult = platformService.add(parentPlatform); - - if (!updateResult) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"写入数据库失败"); - } - } - - /** - * 保存上级平台信息 - * - * @param parentPlatform - * @return - */ - @Operation(summary = "保存上级平台信息") - @PostMapping("/save") - @ResponseBody - public void savePlatform(@RequestBody ParentPlatform parentPlatform) { - - if (logger.isDebugEnabled()) { - logger.debug("保存上级平台信息API调用"); - } - if (ObjectUtils.isEmpty(parentPlatform.getName()) - || ObjectUtils.isEmpty(parentPlatform.getServerGBId()) - || ObjectUtils.isEmpty(parentPlatform.getServerGBDomain()) - || ObjectUtils.isEmpty(parentPlatform.getServerIp()) - || ObjectUtils.isEmpty(parentPlatform.getServerPort()) - || ObjectUtils.isEmpty(parentPlatform.getDeviceGBId()) - || ObjectUtils.isEmpty(parentPlatform.getExpires()) - || ObjectUtils.isEmpty(parentPlatform.getKeepTimeout()) - || ObjectUtils.isEmpty(parentPlatform.getTransport()) - || ObjectUtils.isEmpty(parentPlatform.getCharacterSet()) - ) { - throw new ControllerException(ErrorCode.ERROR400); - } - - platformService.update(parentPlatform); - } - - /** - * 删除上级平台 - * - * @param serverGBId 上级平台国标ID - * @return - */ - @Operation(summary = "删除上级平台") - @Parameter(name = "serverGBId", description = "上级平台的国标编号") - @DeleteMapping("/delete/{serverGBId}") - @ResponseBody - public void deletePlatform(@PathVariable String serverGBId) { - - if (logger.isDebugEnabled()) { - logger.debug("删除上级平台API调用"); - } - if (ObjectUtils.isEmpty(serverGBId) - ) { - throw new ControllerException(ErrorCode.ERROR400); - } - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId); - ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(serverGBId); - if (parentPlatform == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在"); - } - if (parentPlatformCatch == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台不存在"); - } - // 发送离线消息,无论是否成功都删除缓存 - try { - commanderForPlatform.unregister(parentPlatform, parentPlatformCatch.getSipTransactionInfo(), (event -> { - // 清空redis缓存 - redisCatchStorage.delPlatformCatchInfo(parentPlatform.getServerGBId()); - redisCatchStorage.delPlatformKeepalive(parentPlatform.getServerGBId()); - redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId()); - }), (event -> { - // 清空redis缓存 - redisCatchStorage.delPlatformCatchInfo(parentPlatform.getServerGBId()); - redisCatchStorage.delPlatformKeepalive(parentPlatform.getServerGBId()); - redisCatchStorage.delPlatformRegister(parentPlatform.getServerGBId()); - })); - } catch (InvalidArgumentException | ParseException | SipException e) { - logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage()); - } - - boolean deleteResult = storager.deleteParentPlatform(parentPlatform); - storager.delCatalogByPlatformId(parentPlatform.getServerGBId()); - storager.delRelationByPlatformId(parentPlatform.getServerGBId()); - // 停止发送位置订阅定时任务 - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_MobilePosition_" + parentPlatform.getServerGBId(); - dynamicTask.stop(key); - // 删除缓存的订阅信息 - subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); - if (!deleteResult) { - throw new ControllerException(ErrorCode.ERROR100); - } - } - - /** - * 查询上级平台是否存在 - * - * @param serverGBId 上级平台国标ID - * @return - */ - @Operation(summary = "查询上级平台是否存在") - @Parameter(name = "serverGBId", description = "上级平台的国标编号") - @GetMapping("/exit/{serverGBId}") - @ResponseBody - public Boolean exitPlatform(@PathVariable String serverGBId) { - - ParentPlatform parentPlatform = storager.queryParentPlatByServerGBId(serverGBId); - return parentPlatform != null; - } - - /** - * 分页查询级联平台的所有所有通道 - * - * @param page 当前页 - * @param count 每页条数 - * @param platformId 上级平台ID - * @param query 查询内容 - * @param online 是否在线 - * @param channelType 通道类型 - * @return - */ - @Operation(summary = "查询上级平台是否存在") - @Parameter(name = "page", description = "当前页", required = true) - @Parameter(name = "count", description = "每页条数", required = true) - @Parameter(name = "platformId", description = "上级平台的国标编号") - @Parameter(name = "catalogId", description = "目录ID") - @Parameter(name = "query", description = "查询内容") - @Parameter(name = "online", description = "是否在线") - @Parameter(name = "channelType", description = "通道类型") - @GetMapping("/channel_list") - @ResponseBody - public Page channelList(Page page, - @RequestParam(required = false) String platformId, - @RequestParam(required = false) String catalogId, - @RequestParam(required = false) String query, - @RequestParam(required = false) Boolean online, - @RequestParam(required = false) Boolean channelType) { - - if (ObjectUtils.isEmpty(platformId)) { - platformId = null; - } - if (ObjectUtils.isEmpty(query)) { - query = null; - } - if (ObjectUtils.isEmpty(platformId) || ObjectUtils.isEmpty(catalogId)) { - catalogId = null; - } - Page channelReduces = storager.queryAllChannelList(page, query, online, channelType, platformId, catalogId); - - return channelReduces; - } - - /** - * 向上级平台添加国标通道 - * - * @param param 通道关联参数 - * @return - */ - @Operation(summary = "向上级平台添加国标通道") - @PostMapping("/update_channel_for_gb") - @ResponseBody - public void updateChannelForGB(@RequestBody UpdateChannelParam param) { - - if (logger.isDebugEnabled()) { - logger.debug("给上级平台添加国标通道API调用"); - } - int result = 0; - if (param.getChannelReduces() == null || param.getChannelReduces().size() == 0) { - if (param.isAll()) { - logger.info("[国标级联]添加所有通道到上级平台, {}", param.getPlatformId()); - List allChannelForDevice = deviceChannelService.queryAllChannelList(param.getPlatformId()); - result = platformChannelService.updateChannelForGB(param.getPlatformId(), allChannelForDevice, param.getCatalogId()); - } - }else { - result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); - } - if (result <= 0) { - throw new ControllerException(ErrorCode.ERROR100); - } - } - - /** - * 从上级平台移除国标通道 - * - * @param param 通道关联参数 - * @return - */ - @Operation(summary = "从上级平台移除国标通道") - @DeleteMapping("/del_channel_for_gb") - @ResponseBody - public void delChannelForGB(@RequestBody UpdateChannelParam param) { - - if (logger.isDebugEnabled()) { - logger.debug("给上级平台删除国标通道API调用"); - } - int result = 0; - if (param.getChannelReduces() == null || param.getChannelReduces().size() == 0) { - if (param.isAll()) { - logger.info("[国标级联]移除所有通道,上级平台, {}", param.getPlatformId()); - result = platformChannelService.delAllChannelForGB(param.getPlatformId(), param.getCatalogId()); - } - }else { - result = storager.delChannelForGB(param.getPlatformId(), param.getChannelReduces()); - } - if (result <= 0) { - throw new ControllerException(ErrorCode.ERROR100); - } - } - - /** - * 获取目录 - * - * @param platformId 平台ID - * @param parentId 目录父ID - * @return - */ - @Operation(summary = "获取目录") - @Parameter(name = "platformId", description = "上级平台的国标编号", required = true) - @Parameter(name = "parentId", description = "父级目录的国标编号", required = true) - @GetMapping("/catalog") - @ResponseBody - public List getCatalogByPlatform(String platformId, String parentId) { - - if (logger.isDebugEnabled()) { - logger.debug("查询目录,platformId: {}, parentId: {}", platformId, parentId); - } - ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); - if (platform == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "平台未找到"); - } -// if (platformId.equals(parentId)) { -// parentId = platform.getDeviceGBId(); -// } - - if (platformId.equals(platform.getDeviceGBId())) { - parentId = null; - } - - return storager.getChildrenCatalogByPlatform(platformId, parentId); - } - - /** - * 添加目录 - * - * @param platformCatalog 目录 - * @return - */ - @Operation(summary = "添加目录") - @PostMapping("/catalog/add") - @ResponseBody - public void addCatalog(@RequestBody PlatformCatalog platformCatalog) { - - if (logger.isDebugEnabled()) { - logger.debug("添加目录,{}", JSON.toJSONString(platformCatalog)); - } - PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId()); - - if (platformCatalogInStore != null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " already exists"); - } - int addResult = storager.addCatalog(platformCatalog); - if (addResult <= 0) { - throw new ControllerException(ErrorCode.ERROR100); - } - } - - /** - * 编辑目录 - * - * @param platformCatalog 目录 - * @return - */ - @Operation(summary = "编辑目录") - @PostMapping("/catalog/edit") - @ResponseBody - public void editCatalog(@RequestBody PlatformCatalog platformCatalog) { - - if (logger.isDebugEnabled()) { - logger.debug("编辑目录,{}", JSON.toJSONString(platformCatalog)); - } - PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getPlatformId(), platformCatalog.getId()); - - if (platformCatalogInStore == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), platformCatalog.getId() + " not exists"); - } - int addResult = storager.updateCatalog(platformCatalog); - if (addResult <= 0) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败"); - } - } - - /** - * 删除目录 - * - * @param id 目录Id - * @param platformId 平台Id - * @return - */ - @Operation(summary = "删除目录") - @Parameter(name = "id", description = "目录Id", required = true) - @Parameter(name = "platformId", description = "平台Id", required = true) - @DeleteMapping("/catalog/del") - @ResponseBody - public void delCatalog(String id, String platformId) { - - if (logger.isDebugEnabled()) { - logger.debug("删除目录,{}", id); - } - - if (ObjectUtils.isEmpty(id) || ObjectUtils.isEmpty(platformId)) { - throw new ControllerException(ErrorCode.ERROR400); - } - - int delResult = storager.delCatalog(platformId, id); - // 如果删除的是默认目录则根目录设置为默认目录 - PlatformCatalog parentPlatform = storager.queryDefaultCatalogInPlatform(platformId); - - // 默认节点被移除 - if (parentPlatform == null) { - storager.setDefaultCatalog(platformId, platformId); - } - - if (delResult <= 0) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败"); - } - } - - /** - * 删除关联 - * - * @param platformCatalog 关联的信息 - * @return - */ - @Operation(summary = "删除关联") - @DeleteMapping("/catalog/relation/del") - @ResponseBody - public void delRelation(@RequestBody PlatformCatalog platformCatalog) { - - if (logger.isDebugEnabled()) { - logger.debug("删除关联,{}", JSON.toJSONString(platformCatalog)); - } - int delResult = storager.delRelation(platformCatalog); - - if (delResult <= 0) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败"); - } - } - - - /** - * 修改默认目录 - * - * @param platformId 平台Id - * @param catalogId 目录Id - * @return - */ - @Operation(summary = "修改默认目录") - @Parameter(name = "catalogId", description = "目录Id", required = true) - @Parameter(name = "platformId", description = "平台Id", required = true) - @PostMapping("/catalog/default/update") - @ResponseBody - public void setDefaultCatalog(String platformId, String catalogId) { - - if (logger.isDebugEnabled()) { - logger.debug("修改默认目录,{},{}", platformId, catalogId); - } - int updateResult = storager.setDefaultCatalog(platformId, catalogId); - - if (updateResult <= 0) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "写入数据库失败"); - } - } - - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java deleted file mode 100644 index 23310951..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.platform.bean; - -import com.baomidou.mybatisplus.annotation.TableField; -import com.baomidou.mybatisplus.annotation.TableName; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import io.swagger.v3.oas.annotations.media.Schema; - -/** - * 精简的channel信息展示,主要是选择通道的时候展示列表使用 - */ -@TableName("wvp_platform_gb_channel") -@Schema(description = "精简的channel信息展示") -public class ChannelReduce { - - /** - * deviceChannel的数据库自增ID - */ - @Schema(description = "deviceChannel的数据库自增ID") - private int id; - - /** - * 通道id - */ - @TableField(exist = false) - @Schema(description = "通道国标编号") - private String channelId; - - /** - * 设备id - */ - @TableField(exist = false) - @Schema(description = "设备国标编号") - private String deviceId; - - /** - * 通道名 - */ - @TableField(exist = false) - @Schema(description = "通道名") - private String name; - - /** - * 生产厂商 - */ - @TableField(exist = false) - @Schema(description = "生产厂商") - private String manufacturer; - - /** - * wan地址 - */ - @TableField(exist = false) - @Schema(description = "wan地址") - private String hostAddress; - - /** - * 子节点数 - */ - @TableField(exist = false) - @Schema(description = "子节点数") - private int subCount; - - /** - * 平台Id - */ - @Schema(description = "平台上级国标编号") - private String platformId; - - /** - * 目录Id - */ - @Schema(description = "目录国标编号") - private String catalogId; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getManufacturer() { - return manufacturer; - } - - public void setManufacturer(String manufacturer) { - this.manufacturer = manufacturer; - } - - public String getHostAddress() { - return hostAddress; - } - - public void setHostAddress(String hostAddress) { - this.hostAddress = hostAddress; - } - - public int getSubCount() { - return subCount; - } - - public void setSubCount(int subCount) { - this.subCount = subCount; - } - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public String getCatalogId() { - return catalogId; - } - - public void setCatalogId(String catalogId) { - this.catalogId = catalogId; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java deleted file mode 100644 index 2d598e44..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java +++ /dev/null @@ -1,57 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.platform.bean; - -import io.swagger.v3.oas.annotations.media.Schema; - -import java.util.List; - -/** - * 通道关联参数 - * @author lin - */ -@Schema(description = "通道关联参数") -public class UpdateChannelParam { - - @Schema(description = "上级平台的国标编号") - private String platformId; - - @Schema(description = "目录的国标编号") - private String catalogId; - - @Schema(description = "处理所有通道") - private boolean all; - - @Schema(description = "") - private List channelReduces; - - public String getPlatformId() { - return platformId; - } - - public void setPlatformId(String platformId) { - this.platformId = platformId; - } - - public List getChannelReduces() { - return channelReduces; - } - - public void setChannelReduces(List channelReduces) { - this.channelReduces = channelReduces; - } - - public String getCatalogId() { - return catalogId; - } - - public void setCatalogId(String catalogId) { - this.catalogId = catalogId; - } - - public boolean isAll() { - return all; - } - - public void setAll(boolean all) { - this.all = all; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java deleted file mode 100644 index 89bcf9a7..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ /dev/null @@ -1,392 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.play; - -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionStatus; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; -import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IInviteStreamService; -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.bean.InviteErrorCode; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.StreamContent; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import com.iteaj.framework.BaseController; -import com.iteaj.framework.result.HttpResult; -import com.iteaj.framework.result.Result; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.servlet.http.HttpServletRequest; -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.ParseException; -import java.util.List; -import java.util.UUID; - -@Tag(name = "国标设备点播") - -@RestController -@RequestMapping("/gbs/play") -public class PlayController extends BaseController { - - private final static Logger logger = LoggerFactory.getLogger(PlayController.class); - - @Autowired - private SIPCommander cmder; - - @Autowired - private VideoStreamSessionManager streamSession; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private ZLMRESTfulUtils zlmresTfulUtils; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private IPlayService playService; - - @Autowired - private IMediaService mediaService; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private UserSetting userSetting; - - /** - * 开始点播 - * @param request - * @param deviceId - * @param channelId - * @return - */ - @GetMapping("/start") - public DeferredResult> play(HttpServletRequest request, String deviceId, String channelId) { - - logger.info("[开始点播] deviceId:{}, channelId:{}, ", deviceId, channelId); - // 获取可用的zlm - Device device = storager.queryVideoDevice(deviceId); - MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); - - RequestMessage requestMessage = new RequestMessage(); - String key = DeferredResultHolder.CALLBACK_CMD_PLAY + deviceId + channelId; - requestMessage.setKey(key); - String uuid = UUID.randomUUID().toString(); - requestMessage.setId(uuid); - DeferredResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); - - result.onTimeout(()->{ - logger.info("[点播等待超时] deviceId:{}, channelId:{}, ", deviceId, channelId); - // 释放rtpserver - HttpResult wvpResult = HttpResult.Success(); - wvpResult.setCode(ErrorCode.ERROR100.getCode()); - wvpResult.setMessage("点播超时"); - requestMessage.setData(wvpResult); - resultHolder.invokeAllResult(requestMessage); - inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - storager.stopPlay(deviceId, channelId); - }); - - // 录像查询以channelId作为deviceId查询 - resultHolder.put(key, uuid, result); - - playService.play(newMediaServerItem, deviceId, channelId, null, (code, msg, data) -> { - HttpResult wvpResult = HttpResult.Success(); - if (code == InviteErrorCode.SUCCESS.getCode()) { - if (data != null) { - StreamInfo streamInfo = (StreamInfo)data; - if (userSetting.getUseSourceIpAsStreamIp()) { - streamInfo=streamInfo.clone();//深拷贝 - String host; - try { - URL url=new URL(request.getRequestURL().toString()); - host=url.getHost(); - } catch (MalformedURLException e) { - host=request.getLocalAddr(); - } - streamInfo.channgeStreamIp(host); - } - wvpResult.setData(new StreamContent(streamInfo)); - } - }else { - wvpResult.setCode(code); - wvpResult.setMessage(msg); - } - requestMessage.setData(wvpResult); - resultHolder.invokeResult(requestMessage); - }); - - return result; - } - - @Operation(summary = "停止点播") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "isSubStream", description = "是否子码流(true-子码流,false-主码流),默认为false", required = true) - @GetMapping("/stop/{deviceId}/{channelId}") - public JSONObject playStop(@PathVariable String deviceId, @PathVariable String channelId,boolean isSubStream) { - - logger.debug(String.format("设备预览/回放停止API调用,streamId:%s_%s", deviceId, channelId )); - - if (deviceId == null || channelId == null) { - throw new ControllerException(ErrorCode.ERROR400); - } - - Device device = storager.queryVideoDevice(deviceId); - if (device == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "设备[" + deviceId + "]不存在"); - } - - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - if (inviteInfo == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "点播未找到"); - } - if (InviteSessionStatus.ok == inviteInfo.getStatus()) { - try { - logger.info("[停止点播] {}/{}", device.getDeviceId(), channelId); - cmder.streamByeCmd(device, channelId, inviteInfo.getStream(), null, null); - } catch (InvalidArgumentException | SipException | ParseException | SsrcTransactionNotFoundException e) { - logger.error("[命令发送失败] 停止点播, 发送BYE: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - } - inviteStreamService.removeInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, deviceId, channelId); - storager.stopPlay(deviceId, channelId); - - JSONObject json = new JSONObject(); - json.put("deviceId", deviceId); - json.put("channelId", channelId); - json.put("isSubStream", isSubStream); - return json; - } - - /** - * 将不是h264的视频通过ffmpeg 转码为h264 + aac - * @param streamId 流ID - */ - @Operation(summary = "将不是h264的视频通过ffmpeg 转码为h264 + aac") - @Parameter(name = "streamId", description = "视频流ID", required = true) - @PostMapping("/convert/{streamId}") - public JSONObject playConvert(@PathVariable String streamId) { -// StreamInfo streamInfo = redisCatchStorage.queryPlayByStreamId(streamId); - - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(null, streamId); - if (inviteInfo == null || inviteInfo.getStreamInfo() == null) { - logger.warn("视频转码API调用失败!, 视频流已经停止!"); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到视频流信息, 视频流可能已经停止"); - } - MediaServerItem mediaInfo = mediaServerService.getOne(inviteInfo.getStreamInfo().getMediaServerId()); - JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaInfo, streamId); - if (!rtpInfo.getBoolean("exist")) { - logger.warn("视频转码API调用失败!, 视频流已停止推流!"); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到视频流信息, 视频流可能已停止推流"); - } else { - String dstUrl = String.format("rtmp://%s:%s/convert/%s", "127.0.0.1", mediaInfo.getRtmpPort(), - streamId ); - String srcUrl = String.format("rtsp://%s:%s/rtp/%s", "127.0.0.1", mediaInfo.getRtspPort(), streamId); - JSONObject jsonObject = zlmresTfulUtils.addFFmpegSource(mediaInfo, srcUrl, dstUrl, "1000000", true, false, null); - logger.info(jsonObject.toJSONString()); - if (jsonObject != null && jsonObject.getInteger("code") == 0) { - JSONObject data = jsonObject.getJSONObject("data"); - if (data != null) { - JSONObject result = new JSONObject(); - result.put("key", data.getString("key")); - StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId(), false); - result.put("StreamInfo", streamInfoResult); - return result; - }else { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "转码失败"); - } - }else { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "转码失败"); - } - } - } - - /** - * 结束转码 - */ - @Operation(summary = "结束转码") - @Parameter(name = "key", description = "视频流key", required = true) - @Parameter(name = "mediaServerId", description = "流媒体服务ID", required = true) - @PostMapping("/convertStop/{key}") - public void playConvertStop(@PathVariable String key, String mediaServerId) { - if (mediaServerId == null) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "流媒体:" + mediaServerId + "不存在" ); - } - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); - if (mediaInfo == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "使用的流媒体已经停止运行" ); - }else { - JSONObject jsonObject = zlmresTfulUtils.delFFmpegSource(mediaInfo, key); - logger.info(jsonObject.toJSONString()); - if (jsonObject != null && jsonObject.getInteger("code") == 0) { - JSONObject data = jsonObject.getJSONObject("data"); - if (data == null || data.getBoolean("flag") == null || !data.getBoolean("flag")) { - throw new ControllerException(ErrorCode.ERROR100 ); - } - }else { - throw new ControllerException(ErrorCode.ERROR100 ); - } - } - } - - @Operation(summary = "语音广播命令") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @GetMapping("/broadcast/{deviceId}") - @PostMapping("/broadcast/{deviceId}") - public DeferredResult broadcastApi(@PathVariable String deviceId) { - if (logger.isDebugEnabled()) { - logger.debug("语音广播API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - DeferredResult result = new DeferredResult<>(3 * 1000L); - String key = DeferredResultHolder.CALLBACK_CMD_BROADCAST + deviceId; - if (resultHolder.exist(key, null)) { - result.setResult("设备使用中"); - return result; - } - String uuid = UUID.randomUUID().toString(); - if (device == null) { - - resultHolder.put(key, key, result); - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setId(uuid); - JSONObject json = new JSONObject(); - json.put("DeviceID", deviceId); - json.put("CmdType", "Broadcast"); - json.put("Result", "Failed"); - json.put("Description", "Device 不存在"); - msg.setData(json); - resultHolder.invokeResult(msg); - return result; - } - try { - cmder.audioBroadcastCmd(device, (event) -> { - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setId(uuid); - JSONObject json = new JSONObject(); - json.put("DeviceID", deviceId); - json.put("CmdType", "Broadcast"); - json.put("Result", "Failed"); - json.put("Description", String.format("语音广播操作失败,错误码: %s, %s", event.statusCode, event.msg)); - msg.setData(json); - resultHolder.invokeResult(msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 语音广播: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - - result.onTimeout(() -> { - logger.warn("语音广播操作超时, 设备未返回应答指令"); - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - msg.setId(uuid); - JSONObject json = new JSONObject(); - json.put("DeviceID", deviceId); - json.put("CmdType", "Broadcast"); - json.put("Result", "Failed"); - json.put("Error", "Timeout. Device did not response to broadcast command."); - msg.setData(json); - resultHolder.invokeResult(msg); - }); - resultHolder.put(key, uuid, result); - return result; - } - - @Operation(summary = "获取所有的ssrc") - @GetMapping("/ssrc") - public JSONObject getSSRC() { - if (logger.isDebugEnabled()) { - logger.debug("获取所有的ssrc"); - } - JSONArray objects = new JSONArray(); - List allSsrc = streamSession.getAllSsrc(); - for (SsrcTransaction transaction : allSsrc) { - JSONObject jsonObject = new JSONObject(); - jsonObject.put("deviceId", transaction.getDeviceId()); - jsonObject.put("channelId", transaction.getChannelId()); - jsonObject.put("ssrc", transaction.getSsrc()); - jsonObject.put("streamId", transaction.getStream()); - objects.add(jsonObject); - } - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("data", objects); - jsonObject.put("count", objects.size()); - return jsonObject; - } - - @Operation(summary = "获取截图") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "isSubStream", description = "是否子码流(true-子码流,false-主码流),默认为false", required = true) - @GetMapping("/snap") - public DeferredResult getSnap(String deviceId, String channelId,boolean isSubStream) { - if (logger.isDebugEnabled()) { - logger.debug("获取截图: {}/{}", deviceId, channelId); - } - - DeferredResult result = new DeferredResult<>(3 * 1000L); - String key = DeferredResultHolder.CALLBACK_CMD_SNAP + deviceId; - String uuid = UUID.randomUUID().toString(); - resultHolder.put(key, uuid, result); - - RequestMessage message = new RequestMessage(); - message.setKey(key); - message.setId(uuid); - - String fileName = deviceId + "_" + channelId + "_" + DateUtil.getNowForUrl() + ".jpg"; - playService.getSnap(deviceId, channelId, fileName, (code, msg, data) -> { - if (code == InviteErrorCode.SUCCESS.getCode()) { - message.setData(data); - }else { - message.setData(WVPResult.fail(code, msg)); - } - resultHolder.invokeResult(message); - }); - return result; - } - -} - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/bean/PlayResult.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/bean/PlayResult.java deleted file mode 100644 index 58d4ce20..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/bean/PlayResult.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.play.bean; - -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import org.springframework.http.ResponseEntity; -import org.springframework.web.context.request.async.DeferredResult; - -public class PlayResult { - - private DeferredResult> result; - private String uuid; - - private Device device; - - public DeferredResult> getResult() { - return result; - } - - public void setResult(DeferredResult> result) { - this.result = result; - } - - public String getUuid() { - return uuid; - } - - public void setUuid(String uuid) { - this.uuid = uuid; - } - - public Device getDevice() { - return device; - } - - public void setDevice(Device device) { - this.device = device; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java deleted file mode 100644 index caed6f28..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java +++ /dev/null @@ -1,226 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.playback; - -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.service.IPlayService; -import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.StreamContent; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import com.iteaj.framework.exception.ServiceException; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.servlet.http.HttpServletRequest; -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.net.MalformedURLException; -import java.net.URL; -import java.text.ParseException; -import java.util.UUID; - -/** - * @author lin - */ -@Tag(name = "视频回放") - -@RestController -@RequestMapping("/gbs/playback") -public class PlaybackController { - - private final static Logger logger = LoggerFactory.getLogger(PlaybackController.class); - - @Autowired - private SIPCommander cmder; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private IInviteStreamService inviteStreamService; - - @Autowired - private IPlayService playService; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private UserSetting userSetting; - - @Operation(summary = "开始视频回放") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "startTime", description = "开始时间", required = true) - @Parameter(name = "endTime", description = "结束时间", required = true) - @GetMapping("/start/{deviceId}/{channelId}") - public DeferredResult> start(HttpServletRequest request, @PathVariable String deviceId, @PathVariable String channelId, - String startTime, String endTime) { - - if (logger.isDebugEnabled()) { - logger.debug(String.format("设备回放 API调用,deviceId:%s ,channelId:%s", deviceId, channelId)); - } - - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_PLAYBACK + deviceId + channelId; - DeferredResult> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); - resultHolder.put(key, uuid, result); - - RequestMessage requestMessage = new RequestMessage(); - requestMessage.setKey(key); - requestMessage.setId(uuid); - - playService.playBack(deviceId, channelId, startTime, endTime, - (code, msg, data)->{ - - WVPResult wvpResult = new WVPResult<>(); - if (code == InviteErrorCode.SUCCESS.getCode()) { - wvpResult.setCode(ErrorCode.SUCCESS.getCode()); - wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); - - if (data != null) { - StreamInfo streamInfo = (StreamInfo)data; - if (userSetting.getUseSourceIpAsStreamIp()) { - streamInfo=streamInfo.clone();//深拷贝 - String host; - try { - URL url=new URL(request.getRequestURL().toString()); - host=url.getHost(); - } catch (MalformedURLException e) { - host=request.getLocalAddr(); - } - streamInfo.channgeStreamIp(host); - } - wvpResult.setData(new StreamContent(streamInfo)); - } - }else { - wvpResult.setCode(code); - wvpResult.setMsg(msg); - } - requestMessage.setData(wvpResult); - resultHolder.invokeResult(requestMessage); - }); - - return result; - } - - - @Operation(summary = "停止视频回放") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "stream", description = "流ID", required = true) - @GetMapping("/stop/{deviceId}/{channelId}/{stream}") - public void playStop( - @PathVariable String deviceId, - @PathVariable String channelId, - @PathVariable String stream) { - if (ObjectUtils.isEmpty(deviceId) || ObjectUtils.isEmpty(channelId) || ObjectUtils.isEmpty(stream)) { - throw new ControllerException(ErrorCode.ERROR400); - } - Device device = storager.queryVideoDevice(deviceId); - if (device == null) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + " 未找到"); - } - try { - cmder.streamByeCmd(device, channelId, stream, null); - } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "发送bye失败: " + e.getMessage()); - } - } - - - @Operation(summary = "回放暂停") - @Parameter(name = "streamId", description = "回放流ID", required = true) - @GetMapping("/pause/{streamId}") - public void playPause(@PathVariable String streamId) { - logger.info("playPause: "+streamId); - - try { - playService.pauseRtp(streamId); - } catch (ServiceException e) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), e.getMessage()); - } catch (InvalidArgumentException | ParseException | SipException e) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); - } - } - - - @Operation(summary = "回放恢复") - @Parameter(name = "streamId", description = "回放流ID", required = true) - @GetMapping("/resume/{streamId}") - public void playResume(@PathVariable String streamId) { - logger.info("playResume: "+streamId); - try { - playService.resumeRtp(streamId); - } catch (ServiceException e) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), e.getMessage()); - } catch (InvalidArgumentException | ParseException | SipException e) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); - } - } - - - @Operation(summary = "回放拖动播放") - @Parameter(name = "streamId", description = "回放流ID", required = true) - @Parameter(name = "seekTime", description = "拖动偏移量,单位s", required = true) - @GetMapping("/seek/{streamId}/{seekTime}") - public void playSeek(@PathVariable String streamId, @PathVariable long seekTime) { - logger.info("playSeek: "+streamId+", "+seekTime); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId); - - if (null == inviteInfo || inviteInfo.getStreamInfo() == null) { - logger.warn("streamId不存在!"); - throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在"); - } - Device device = storager.queryVideoDevice(inviteInfo.getDeviceId()); - try { - cmder.playSeekCmd(device, inviteInfo.getStreamInfo(), seekTime); - } catch (InvalidArgumentException | ParseException | SipException e) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); - } - } - - @Operation(summary = "回放倍速播放") - @Parameter(name = "streamId", description = "回放流ID", required = true) - @Parameter(name = "speed", description = "倍速0.25 0.5 1、2、4", required = true) - @GetMapping("/speed/{streamId}/{speed}") - public void playSpeed(@PathVariable String streamId, @PathVariable Double speed) { - logger.info("playSpeed: "+streamId+", "+speed); - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByStream(InviteSessionType.PLAYBACK, streamId); - - if (null == inviteInfo || inviteInfo.getStreamInfo() == null) { - logger.warn("streamId不存在!"); - throw new ControllerException(ErrorCode.ERROR400.getCode(), "streamId不存在"); - } - if(speed != 0.25 && speed != 0.5 && speed != 1 && speed != 2.0 && speed != 4.0) { - logger.warn("不支持的speed: " + speed); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持的speed(0.25 0.5 1、2、4)"); - } - Device device = storager.queryVideoDevice(inviteInfo.getDeviceId()); - try { - cmder.playSpeedCmd(device, inviteInfo.getStreamInfo(), speed); - } catch (InvalidArgumentException | ParseException | SipException e) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java deleted file mode 100644 index 878c5366..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java +++ /dev/null @@ -1,179 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.ptz; - - -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.UUID; - -@Tag(name = "云台控制") - -@RestController -@RequestMapping("/gbs/ptz") -public class PtzController { - - private final static Logger logger = LoggerFactory.getLogger(PtzController.class); - - @Autowired - private SIPCommander cmder; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private DeferredResultHolder resultHolder; - - /*** - * 云台控制 - * @param deviceId 设备id - * @param channelId 通道id - * @param command 控制指令 - * @param horizonSpeed 水平移动速度 - * @param verticalSpeed 垂直移动速度 - * @param zoomSpeed 缩放速度 - */ - - @Operation(summary = "云台控制") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "command", description = "控制指令,允许值: left, right, up, down, upleft, upright, downleft, downright, zoomin, zoomout, stop", required = true) - @Parameter(name = "horizonSpeed", description = "水平速度", required = true) - @Parameter(name = "verticalSpeed", description = "垂直速度", required = true) - @Parameter(name = "zoomSpeed", description = "缩放速度", required = true) - @PostMapping("/control/{deviceId}/{channelId}") - public void ptz(@PathVariable String deviceId,@PathVariable String channelId, String command, int horizonSpeed, int verticalSpeed, int zoomSpeed){ - - if (logger.isDebugEnabled()) { - logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,command:%s ,horizonSpeed:%d ,verticalSpeed:%d ,zoomSpeed:%d",deviceId, channelId, command, horizonSpeed, verticalSpeed, zoomSpeed)); - } - Device device = storager.queryVideoDevice(deviceId); - int cmdCode = 0; - switch (command){ - case "left": - cmdCode = 2; - break; - case "right": - cmdCode = 1; - break; - case "up": - cmdCode = 8; - break; - case "down": - cmdCode = 4; - break; - case "upleft": - cmdCode = 10; - break; - case "upright": - cmdCode = 9; - break; - case "downleft": - cmdCode = 6; - break; - case "downright": - cmdCode = 5; - break; - case "zoomin": - cmdCode = 16; - break; - case "zoomout": - cmdCode = 32; - break; - case "stop": - horizonSpeed = 0; - verticalSpeed = 0; - zoomSpeed = 0; - break; - default: - break; - } - try { - cmder.frontEndCmd(device, channelId, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 云台控制: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - } - - - @Operation(summary = "通用前端控制命令") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "cmdCode", description = "指令码", required = true) - @Parameter(name = "parameter1", description = "数据一", required = true) - @Parameter(name = "parameter2", description = "数据二", required = true) - @Parameter(name = "combindCode2", description = "组合码二", required = true) - @PostMapping("/front_end_command/{deviceId}/{channelId}") - public void frontEndCommand(@PathVariable String deviceId,@PathVariable String channelId,int cmdCode, int parameter1, int parameter2, int combindCode2){ - - if (logger.isDebugEnabled()) { - logger.debug(String.format("设备云台控制 API调用,deviceId:%s ,channelId:%s ,cmdCode:%d parameter1:%d parameter2:%d",deviceId, channelId, cmdCode, parameter1, parameter2)); - } - Device device = storager.queryVideoDevice(deviceId); - - try { - cmder.frontEndCmd(device, channelId, cmdCode, parameter1, parameter2, combindCode2); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 前端控制: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - } - - - @Operation(summary = "预置位查询") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @GetMapping("/preset/query/{deviceId}/{channelId}") - public DeferredResult presetQueryApi(@PathVariable String deviceId, @PathVariable String channelId) { - if (logger.isDebugEnabled()) { - logger.debug("设备预置位查询API调用"); - } - Device device = storager.queryVideoDevice(deviceId); - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(channelId) ? deviceId : channelId); - DeferredResult result = new DeferredResult (3 * 1000L); - result.onTimeout(()->{ - logger.warn(String.format("获取设备预置位超时")); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData("获取设备预置位超时"); - resultHolder.invokeResult(msg); - }); - if (resultHolder.exist(key, null)) { - return result; - } - resultHolder.put(key, uuid, result); - try { - cmder.presetQuery(device, channelId, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("获取设备预置位失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 获取设备预置位: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - return result; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java deleted file mode 100644 index 6385d28a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java +++ /dev/null @@ -1,207 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.record; - -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.service.IPlayService; -import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.StreamContent; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.servlet.http.HttpServletRequest; -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.UUID; - -@Tag(name = "国标录像") - -@RestController -@RequestMapping("/gbs/gb_record") -public class GBRecordController { - - private final static Logger logger = LoggerFactory.getLogger(GBRecordController.class); - - @Autowired - private SIPCommander cmder; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private IPlayService playService; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private UserSetting userSetting; - - @Operation(summary = "录像查询") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "startTime", description = "开始时间", required = true) - @Parameter(name = "endTime", description = "结束时间", required = true) - @GetMapping("/query/{deviceId}/{channelId}") - public DeferredResult> recordinfo(@PathVariable String deviceId, @PathVariable String channelId, String startTime, String endTime){ - - if (logger.isDebugEnabled()) { - logger.debug(String.format("录像信息查询 API调用,deviceId:%s ,startTime:%s, endTime:%s",deviceId, startTime, endTime)); - } - DeferredResult> result = new DeferredResult<>(); - if (!DateUtil.verification(startTime, DateUtil.formatter)){ - throw new ControllerException(ErrorCode.ERROR100.getCode(), "startTime格式为" + DateUtil.PATTERN); - } - if (!DateUtil.verification(endTime, DateUtil.formatter)){ - throw new ControllerException(ErrorCode.ERROR100.getCode(), "endTime格式为" + DateUtil.PATTERN); - } - - Device device = storager.queryVideoDevice(deviceId); - // 指定超时时间 1分钟30秒 - String uuid = UUID.randomUUID().toString(); - int sn = (int)((Math.random()*9+1)*100000); - String key = DeferredResultHolder.CALLBACK_CMD_RECORDINFO + deviceId + sn; - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - try { - cmder.recordInfoQuery(device, channelId, startTime, endTime, sn, null, null, null, (eventResult -> { - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(ErrorCode.ERROR100.getCode()); - wvpResult.setMsg("查询录像失败, status: " + eventResult.statusCode + ", message: " + eventResult.msg); - msg.setData(wvpResult); - resultHolder.invokeResult(msg); - })); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 查询录像: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - - // 录像查询以channelId作为deviceId查询 - resultHolder.put(key, uuid, result); - result.onTimeout(()->{ - msg.setData("timeout"); - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(ErrorCode.ERROR100.getCode()); - wvpResult.setMsg("timeout"); - msg.setData(wvpResult); - resultHolder.invokeResult(msg); - }); - return result; - } - - - @Operation(summary = "开始历史媒体下载") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "startTime", description = "开始时间", required = true) - @Parameter(name = "endTime", description = "结束时间", required = true) - @Parameter(name = "downloadSpeed", description = "下载倍速", required = true) - @GetMapping("/download/start/{deviceId}/{channelId}") - public DeferredResult> download(HttpServletRequest request, @PathVariable String deviceId, @PathVariable String channelId, - String startTime, String endTime, String downloadSpeed) { - - if (logger.isDebugEnabled()) { - logger.debug(String.format("历史媒体下载 API调用,deviceId:%s,channelId:%s,downloadSpeed:%s", deviceId, channelId, downloadSpeed)); - } - - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_DOWNLOAD + deviceId + channelId; - DeferredResult> result = new DeferredResult<>(30000L); - resultHolder.put(key, uuid, result); - RequestMessage requestMessage = new RequestMessage(); - requestMessage.setId(uuid); - requestMessage.setKey(key); - - - playService.download(deviceId, channelId, startTime, endTime, Integer.parseInt(downloadSpeed), - (code, msg, data)->{ - - WVPResult wvpResult = new WVPResult<>(); - if (code == InviteErrorCode.SUCCESS.getCode()) { - wvpResult.setCode(ErrorCode.SUCCESS.getCode()); - wvpResult.setMsg(ErrorCode.SUCCESS.getMsg()); - - if (data != null) { - StreamInfo streamInfo = (StreamInfo)data; - if (userSetting.getUseSourceIpAsStreamIp()) { - streamInfo.channgeStreamIp(request.getLocalAddr()); - } - wvpResult.setData(new StreamContent(streamInfo)); - } - }else { - wvpResult.setCode(code); - wvpResult.setMsg(msg); - } - requestMessage.setData(wvpResult); - resultHolder.invokeResult(requestMessage); - }); - - return result; - } - - @Operation(summary = "停止历史媒体下载") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "stream", description = "流ID", required = true) - @GetMapping("/download/stop/{deviceId}/{channelId}/{stream}") - public void playStop(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) { - - if (logger.isDebugEnabled()) { - logger.debug(String.format("设备历史媒体下载停止 API调用,deviceId/channelId:%s_%s", deviceId, channelId)); - } - - if (deviceId == null || channelId == null) { - throw new ControllerException(ErrorCode.ERROR400); - } - - Device device = deviceService.getDevice(deviceId); - if (device == null) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "设备:" + deviceId + "未找到"); - } - - try { - cmder.streamByeCmd(device, channelId, stream, null); - } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { - logger.error("[停止历史媒体下载]停止历史媒体下载,发送BYE失败 {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); - } - } - - @Operation(summary = "获取历史媒体下载进度") - @Parameter(name = "deviceId", description = "设备国标编号", required = true) - @Parameter(name = "channelId", description = "通道国标编号", required = true) - @Parameter(name = "stream", description = "流ID", required = true) - @GetMapping("/download/progress/{deviceId}/{channelId}/{stream}") - public StreamContent getProgress(@PathVariable String deviceId, @PathVariable String channelId, @PathVariable String stream) { - StreamInfo downLoadInfo = playService.getDownLoadInfo(deviceId, channelId, stream); - if (downLoadInfo == null) { - throw new ControllerException(ErrorCode.ERROR404); - } - return new StreamContent(downLoadInfo); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/sse/SseController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/sse/SseController.java deleted file mode 100644 index 575f22b3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/sse/SseController.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.gb28181.sse; - -import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEventListener; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.io.PrintWriter; - - -/** - * SSE 推送. - * - * @author lawrencehj - * @author xiaoQQya - * @since 2021/01/20 - */ -@Tag(name = "SSE 推送") -@RestController -@RequestMapping("/api") -public class SseController { - - @Resource - private AlarmEventListener alarmEventListener; - - /** - * SSE 推送. - * - * @param response 响应 - * @param browserId 浏览器ID - * @throws IOException IOEXCEPTION - * @author xiaoQQya - * @since 2023/11/06 - */ - @GetMapping("/emit") - public void emit(HttpServletResponse response, @RequestParam String browserId) throws IOException, InterruptedException { - response.setContentType("text/event-stream"); - response.setCharacterEncoding("utf-8"); - - PrintWriter writer = response.getWriter(); - alarmEventListener.addSseEmitter(browserId, writer); - - while (!writer.checkError()) { - Thread.sleep(1000); - writer.write(":keep alive\n\n"); - writer.flush(); - } - alarmEventListener.removeSseEmitter(browserId, writer); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/ps/PsController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/ps/PsController.java deleted file mode 100644 index d5fbf43a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/ps/PsController.java +++ /dev/null @@ -1,322 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.ps; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRtpServerTimeout; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRtpServerTimeoutHookParam; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.OtherPsSendInfo; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -@SuppressWarnings("rawtypes") -@Tag(name = "第三方PS服务对接") - -@RestController -@RequestMapping("/api/ps") -public class PsController { - - private final static Logger logger = LoggerFactory.getLogger(PsController.class); - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private ZlmHttpHookSubscribe hookSubscribe; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private SendRtpPortManager sendRtpPortManager; - - @Autowired - private UserSetting userSetting; - - @Autowired - private DynamicTask dynamicTask; - - - @Autowired - private RedisTemplate redisTemplate; - - - @GetMapping(value = "/receive/open") - @ResponseBody - @Operation(summary = "开启收流和获取发流信息") - @Parameter(name = "isSend", description = "是否发送,false时只开启收流, true同时返回推流信息", required = true) - @Parameter(name = "callId", description = "整个过程的唯一标识,为了与后续接口关联", required = true) - @Parameter(name = "ssrc", description = "来源流的SSRC,不传则不校验来源ssrc", required = false) - @Parameter(name = "stream", description = "形成的流的ID", required = true) - @Parameter(name = "tcpMode", description = "收流模式, 0为UDP, 1为TCP被动", required = true) - @Parameter(name = "callBack", description = "回调地址,如果收流超时会通道回调通知,回调为get请求,参数为callId", required = true) - public OtherPsSendInfo openRtpServer(Boolean isSend, @RequestParam(required = false)String ssrc, String callId, String stream, Integer tcpMode, String callBack) { - - logger.info("[第三方PS服务对接->开启收流和获取发流信息] isSend->{}, ssrc->{}, callId->{}, stream->{}, tcpMode->{}, callBack->{}", - isSend, ssrc, callId, stream, tcpMode==0?"UDP":"TCP被动", callBack); - - MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); - if (mediaServerItem == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"没有可用的MediaServer"); - } - if (stream == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"stream参数不可为空"); - } - if (isSend != null && isSend && callId == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"isSend为true时,CallID不能为空"); - } - long ssrcInt = 0; - if (ssrc != null) { - try { - ssrcInt = Long.parseLong(ssrc); - }catch (NumberFormatException e) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"ssrc格式错误"); - } - } - String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_" + callId + "_" + stream; - int localPort = zlmServerFactory.createRTPServer(mediaServerItem, stream, ssrcInt, null, false, tcpMode); - if (localPort == 0) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "获取端口失败"); - } - // 注册回调如果rtp收流超时则通过回调发送通知 - if (callBack != null) { - HookSubscribeForRtpServerTimeout hookSubscribeForRtpServerTimeout = HookSubscribeFactory.on_rtp_server_timeout(stream, String.valueOf(ssrcInt), mediaServerItem.getId()); - // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 - hookSubscribe.addSubscribe(hookSubscribeForRtpServerTimeout, - (mediaServerItemInUse, hookParam)->{ - OnRtpServerTimeoutHookParam serverTimeoutHookParam = (OnRtpServerTimeoutHookParam) hookParam; - if (stream.equals(serverTimeoutHookParam.getStream_id())) { - logger.info("[第三方PS服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调", callId); - // 将信息写入redis中,以备后用 - redisTemplate.delete(receiveKey); - OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); - OkHttpClient client = httpClientBuilder.build(); - String url = callBack + "?callId=" + callId; - Request request = new Request.Builder().get().url(url).build(); - try { - client.newCall(request).execute(); - } catch (IOException e) { - logger.error("[第三方PS服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调失败", callId, e); - } - hookSubscribe.removeSubscribe(hookSubscribeForRtpServerTimeout); - } - }); - } - OtherPsSendInfo otherPsSendInfo = new OtherPsSendInfo(); - otherPsSendInfo.setReceiveIp(mediaServerItem.getSdpIp()); - otherPsSendInfo.setReceivePort(localPort); - otherPsSendInfo.setCallId(callId); - otherPsSendInfo.setStream(stream); - - // 将信息写入redis中,以备后用 - redisTemplate.opsForValue().set(receiveKey, otherPsSendInfo); - if (isSend != null && isSend) { - String key = VideoManagerConstants.WVP_OTHER_SEND_PS_INFO + userSetting.getServerId() + "_" + callId; - // 预创建发流信息 - int port = sendRtpPortManager.getNextPort(mediaServerItem); - - otherPsSendInfo.setSendLocalIp(mediaServerItem.getSdpIp()); - otherPsSendInfo.setSendLocalPort(port); - // 将信息写入redis中,以备后用 - redisTemplate.opsForValue().set(key, otherPsSendInfo, 300, TimeUnit.SECONDS); - logger.info("[第三方PS服务对接->开启收流和获取发流信息] 结果,callId->{}, {}", callId, otherPsSendInfo); - } - return otherPsSendInfo; - } - - @GetMapping(value = "/receive/close") - @ResponseBody - @Operation(summary = "关闭收流") - @Parameter(name = "stream", description = "流的ID", required = true) - public void closeRtpServer(String stream) { - logger.info("[第三方PS服务对接->关闭收流] stream->{}", stream); - MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); - zlmServerFactory.closeRtpServer(mediaServerItem,stream); - String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_PS_INFO + userSetting.getServerId() + "_*_" + stream; - List scan = RedisUtil.scan(redisTemplate, receiveKey); - if (!scan.isEmpty()) { - for (Object key : scan) { - // 将信息写入redis中,以备后用 - redisTemplate.delete(key); - } - } - } - - @GetMapping(value = "/send/start") - @ResponseBody - @Operation(summary = "发送流") - @Parameter(name = "ssrc", description = "发送流的SSRC", required = true) - @Parameter(name = "dstIp", description = "目标收流IP", required = true) - @Parameter(name = "dstPort", description = "目标收流端口", required = true) - @Parameter(name = "app", description = "待发送应用名", required = true) - @Parameter(name = "stream", description = "待发送流Id", required = true) - @Parameter(name = "callId", description = "整个过程的唯一标识,不传则使用随机端口发流", required = true) - @Parameter(name = "isUdp", description = "是否为UDP", required = true) - public void sendRTP(String ssrc, - String dstIp, - Integer dstPort, - String app, - String stream, - String callId, - Boolean isUdp - ) { - logger.info("[第三方PS服务对接->发送流] " + - "ssrc->{}, \r\n" + - "dstIp->{}, \n" + - "dstPort->{}, \n" + - "app->{}, \n" + - "stream->{}, \n" + - "callId->{} \n", - ssrc, - dstIp, - dstPort, - app, - stream, - callId); - MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); - String key = VideoManagerConstants.WVP_OTHER_SEND_PS_INFO + userSetting.getServerId() + "_" + callId; - OtherPsSendInfo sendInfo = (OtherPsSendInfo)redisTemplate.opsForValue().get(key); - if (sendInfo == null) { - sendInfo = new OtherPsSendInfo(); - } - sendInfo.setPushApp(app); - sendInfo.setPushStream(stream); - sendInfo.setPushSSRC(ssrc); - - Map param; - - - param = new HashMap<>(); - param.put("vhost","__defaultVhost__"); - param.put("app",app); - param.put("stream",stream); - param.put("ssrc", ssrc); - - param.put("dst_url", dstIp); - param.put("dst_port", dstPort); - String is_Udp = isUdp ? "1" : "0"; - param.put("is_udp", is_Udp); - param.put("src_port", sendInfo.getSendLocalPort()); - - - Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, app, stream); - if (streamReady) { - JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServerItem, param); - if (jsonObject.getInteger("code") == 0) { - logger.info("[第三方PS服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, param); - redisTemplate.opsForValue().set(key, sendInfo); - }else { - redisTemplate.delete(key); - logger.info("[第三方PS服务对接->发送流] 视频流发流失败,callId->{}, {}", callId, jsonObject.getString("msg")); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "[视频流发流失败] " + jsonObject.getString("msg")); - } - }else { - logger.info("[第三方PS服务对接->发送流] 流不存在,等待流上线,callId->{}", callId); - String uuid = UUID.randomUUID().toString(); - HookSubscribeForStreamChange hookSubscribeForStreamChange = HookSubscribeFactory.on_stream_changed(app, stream, true, "rtsp", mediaServerItem.getId()); - dynamicTask.startDelay(uuid, ()->{ - logger.info("[第三方PS服务对接->发送流] 等待流上线超时 callId->{}", callId); - redisTemplate.delete(key); - hookSubscribe.removeSubscribe(hookSubscribeForStreamChange); - }, 10000); - - // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 - OtherPsSendInfo finalSendInfo = sendInfo; - hookSubscribe.removeSubscribe(hookSubscribeForStreamChange); - hookSubscribe.addSubscribe(hookSubscribeForStreamChange, - (mediaServerItemInUse, response)->{ - dynamicTask.stop(uuid); - logger.info("[第三方PS服务对接->发送流] 流上线,开始发流 callId->{}", callId); - try { - Thread.sleep(400); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServerItem, param); - if (jsonObject.getInteger("code") == 0) { - logger.info("[第三方PS服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, param); - redisTemplate.opsForValue().set(key, finalSendInfo); - }else { - redisTemplate.delete(key); - logger.info("[第三方PS服务对接->发送流] 视频流发流失败,callId->{}, {}", callId, jsonObject.getString("msg")); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "[视频流发流失败] " + jsonObject.getString("msg")); - } - hookSubscribe.removeSubscribe(hookSubscribeForStreamChange); - }); - } - } - - @GetMapping(value = "/send/stop") - @ResponseBody - @Operation(summary = "关闭发送流") - @Parameter(name = "callId", description = "整个过程的唯一标识,不传则使用随机端口发流", required = true) - public void closeSendRTP(String callId) { - logger.info("[第三方PS服务对接->关闭发送流] callId->{}", callId); - String key = VideoManagerConstants.WVP_OTHER_SEND_PS_INFO + userSetting.getServerId() + "_" + callId; - OtherPsSendInfo sendInfo = (OtherPsSendInfo)redisTemplate.opsForValue().get(key); - if (sendInfo == null){ - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未开启发流"); - } - Map param = new HashMap<>(); - param.put("vhost","__defaultVhost__"); - param.put("app",sendInfo.getPushApp()); - param.put("stream",sendInfo.getPushStream()); - param.put("ssrc",sendInfo.getPushSSRC()); - MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); - Boolean result = zlmServerFactory.stopSendRtpStream(mediaServerItem, param); - if (!result) { - logger.info("[第三方PS服务对接->关闭发送流] 失败 callId->{}", callId); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "停止发流失败"); - }else { - logger.info("[第三方PS服务对接->关闭发送流] 成功 callId->{}", callId); - } - redisTemplate.delete(key); - } - - - @GetMapping(value = "/getTestPort") - @ResponseBody - public int getTestPort() { - MediaServerItem defaultMediaServer = mediaServerService.getDefaultMediaServer(); - -// for (int i = 0; i <300; i++) { -// new Thread(() -> { -// int nextPort = sendRtpPortManager.getNextPort(defaultMediaServer); -// try { -// Thread.sleep((int)Math.random()*10); -// } catch (InterruptedException e) { -// throw new RuntimeException(e); -// } -// System.out.println(nextPort); -// }).start(); -// } - - return sendRtpPortManager.getNextPort(defaultMediaServer); - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/rtp/RtpController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/rtp/RtpController.java deleted file mode 100644 index d1edb1a3..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/rtp/RtpController.java +++ /dev/null @@ -1,379 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.rtp; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager; -import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForRtpServerTimeout; -import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRtpServerTimeoutHookParam; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.utils.redis.RedisUtil; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.OtherRtpSendInfo; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import okhttp3.OkHttpClient; -import okhttp3.Request; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.TimeUnit; - -@SuppressWarnings("rawtypes") -@Tag(name = "第三方服务对接") - -@RestController -@RequestMapping("/gbs/rtp") -public class RtpController { - - @Autowired - private ZLMServerFactory zlmServerFactory; - - @Autowired - private SendRtpPortManager sendRtpPortManager; - - private final static Logger logger = LoggerFactory.getLogger(RtpController.class); - - @Autowired - private ZlmHttpHookSubscribe hookSubscribe; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private UserSetting userSetting; - - @Autowired - private DynamicTask dynamicTask; - - @Autowired - private RedisTemplate redisTemplate; - - - @GetMapping(value = "/receive/open") - @ResponseBody - @Operation(summary = "开启收流和获取发流信息") - @Parameter(name = "isSend", description = "是否发送,false时只开启收流, true同时返回推流信息", required = true) - @Parameter(name = "callId", description = "整个过程的唯一标识,为了与后续接口关联", required = true) - @Parameter(name = "ssrc", description = "来源流的SSRC,不传则不校验来源ssrc", required = false) - @Parameter(name = "stream", description = "形成的流的ID", required = true) - @Parameter(name = "tcpMode", description = "收流模式, 0为UDP, 1为TCP被动", required = true) - @Parameter(name = "callBack", description = "回调地址,如果收流超时会通道回调通知,回调为get请求,参数为callId", required = true) - public OtherRtpSendInfo openRtpServer(Boolean isSend, @RequestParam(required = false)String ssrc, String callId, String stream, Integer tcpMode, String callBack) { - - logger.info("[第三方服务对接->开启收流和获取发流信息] isSend->{}, ssrc->{}, callId->{}, stream->{}, tcpMode->{}, callBack->{}", - isSend, ssrc, callId, stream, tcpMode==0?"UDP":"TCP被动", callBack); - - MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); - if (mediaServerItem == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"没有可用的MediaServer"); - } - if (stream == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"stream参数不可为空"); - } - if (isSend != null && isSend && callId == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"isSend为true时,CallID不能为空"); - } - long ssrcInt = 0; - if (ssrc != null) { - try { - ssrcInt = Long.parseLong(ssrc); - }catch (NumberFormatException e) { - throw new ControllerException(ErrorCode.ERROR100.getCode(),"ssrc格式错误"); - } - } - String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_" + callId + "_" + stream; - int localPortForVideo = zlmServerFactory.createRTPServer(mediaServerItem, stream, ssrcInt, null, false, tcpMode); - int localPortForAudio = zlmServerFactory.createRTPServer(mediaServerItem, stream + "_a" , ssrcInt, null, false, tcpMode); - if (localPortForVideo == 0 || localPortForAudio == 0) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "获取端口失败"); - } - // 注册回调如果rtp收流超时则通过回调发送通知 - if (callBack != null) { - HookSubscribeForRtpServerTimeout hookSubscribeForRtpServerTimeout = HookSubscribeFactory.on_rtp_server_timeout(stream, String.valueOf(ssrcInt), mediaServerItem.getId()); - // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 - hookSubscribe.addSubscribe(hookSubscribeForRtpServerTimeout, - (mediaServerItemInUse, hookParam)->{ - OnRtpServerTimeoutHookParam serverTimeoutHookParam = (OnRtpServerTimeoutHookParam) hookParam; - if (stream.equals(serverTimeoutHookParam.getStream_id())) { - logger.info("[开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调", callId); - OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); - OkHttpClient client = httpClientBuilder.build(); - String url = callBack + "?callId=" + callId; - Request request = new Request.Builder().get().url(url).build(); - try { - client.newCall(request).execute(); - } catch (IOException e) { - logger.error("[第三方服务对接->开启收流和获取发流信息] 等待收流超时 callId->{}, 发送回调失败", callId, e); - } - hookSubscribe.removeSubscribe(hookSubscribeForRtpServerTimeout); - } - }); - } - String key = VideoManagerConstants.WVP_OTHER_SEND_RTP_INFO + userSetting.getServerId() + "_" + callId; - OtherRtpSendInfo otherRtpSendInfo = new OtherRtpSendInfo(); - otherRtpSendInfo.setReceiveIp(mediaServerItem.getSdpIp()); - otherRtpSendInfo.setReceivePortForVideo(localPortForVideo); - otherRtpSendInfo.setReceivePortForAudio(localPortForAudio); - otherRtpSendInfo.setCallId(callId); - otherRtpSendInfo.setStream(stream); - - // 将信息写入redis中,以备后用 - redisTemplate.opsForValue().set(receiveKey, otherRtpSendInfo); - if (isSend != null && isSend) { - // 预创建发流信息 - int portForVideo = sendRtpPortManager.getNextPort(mediaServerItem); - int portForAudio = sendRtpPortManager.getNextPort(mediaServerItem); - - otherRtpSendInfo.setSendLocalIp(mediaServerItem.getSdpIp()); - otherRtpSendInfo.setSendLocalPortForVideo(portForVideo); - otherRtpSendInfo.setSendLocalPortForAudio(portForAudio); - // 将信息写入redis中,以备后用 - redisTemplate.opsForValue().set(key, otherRtpSendInfo, 300, TimeUnit.SECONDS); - logger.info("[第三方服务对接->开启收流和获取发流信息] 结果,callId->{}, {}", callId, otherRtpSendInfo); - } - // 将信息写入redis中,以备后用 - redisTemplate.opsForValue().set(key, otherRtpSendInfo, 300, TimeUnit.SECONDS); - return otherRtpSendInfo; - } - - @GetMapping(value = "/receive/close") - @ResponseBody - @Operation(summary = "关闭收流") - @Parameter(name = "stream", description = "流的ID", required = true) - public void closeRtpServer(String stream) { - logger.info("[第三方服务对接->关闭收流] stream->{}", stream); - MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); - zlmServerFactory.closeRtpServer(mediaServerItem,stream); - zlmServerFactory.closeRtpServer(mediaServerItem,stream + "_a"); - String receiveKey = VideoManagerConstants.WVP_OTHER_RECEIVE_RTP_INFO + userSetting.getServerId() + "_*_" + stream; - List scan = RedisUtil.scan(redisTemplate, receiveKey); - if (scan.size() > 0) { - for (Object key : scan) { - // 将信息写入redis中,以备后用 - redisTemplate.delete(key); - } - } - } - - @GetMapping(value = "/send/start") - @ResponseBody - @Operation(summary = "发送流") - @Parameter(name = "ssrc", description = "发送流的SSRC", required = true) - @Parameter(name = "dstIpForAudio", description = "目标音频收流IP", required = false) - @Parameter(name = "dstIpForVideo", description = "目标视频收流IP", required = false) - @Parameter(name = "dstPortForAudio", description = "目标音频收流端口", required = false) - @Parameter(name = "dstPortForVideo", description = "目标视频收流端口", required = false) - @Parameter(name = "app", description = "待发送应用名", required = true) - @Parameter(name = "stream", description = "待发送流Id", required = true) - @Parameter(name = "callId", description = "整个过程的唯一标识,不传则使用随机端口发流", required = true) - @Parameter(name = "isUdp", description = "是否为UDP", required = true) - @Parameter(name = "ptForAudio", description = "rtp的音频pt", required = false) - @Parameter(name = "ptForVideo", description = "rtp的视频pt", required = false) - public void sendRTP(String ssrc, - @RequestParam(required = false)String dstIpForAudio, - @RequestParam(required = false)String dstIpForVideo, - @RequestParam(required = false)Integer dstPortForAudio, - @RequestParam(required = false)Integer dstPortForVideo, - String app, - String stream, - String callId, - Boolean isUdp, - @RequestParam(required = false)Integer ptForAudio, - @RequestParam(required = false)Integer ptForVideo - ) { - logger.info("[第三方服务对接->发送流] " + - "ssrc->{}, \r\n" + - "dstIpForAudio->{}, \n" + - "dstIpForAudio->{}, \n" + - "dstPortForAudio->{}, \n" + - "dstPortForVideo->{}, \n" + - "app->{}, \n" + - "stream->{}, \n" + - "callId->{}, \n" + - "ptForAudio->{}, \n" + - "ptForVideo->{}", - ssrc, - dstIpForAudio, - dstIpForVideo, - dstPortForAudio, - dstPortForVideo, - app, - stream, - callId, - ptForAudio, - ptForVideo); - if (!((dstPortForAudio > 0 && !ObjectUtils.isEmpty(dstPortForAudio) || (dstPortForVideo > 0 && !ObjectUtils.isEmpty(dstIpForVideo))))) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "至少应该存在一组音频或视频发送参数"); - } - MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); - String key = VideoManagerConstants.WVP_OTHER_SEND_RTP_INFO + userSetting.getServerId() + "_" + callId; - OtherRtpSendInfo sendInfo = (OtherRtpSendInfo)redisTemplate.opsForValue().get(key); - if (sendInfo == null) { - sendInfo = new OtherRtpSendInfo(); - } - sendInfo.setPushApp(app); - sendInfo.setPushStream(stream); - sendInfo.setPushSSRC(ssrc); - - Map paramForAudio; - Map paramForVideo; - if (!ObjectUtils.isEmpty(dstIpForAudio) && dstPortForAudio > 0) { - paramForAudio = new HashMap<>(); - paramForAudio.put("vhost","__defaultVhost__"); - paramForAudio.put("app",app); - paramForAudio.put("stream",stream); - paramForAudio.put("ssrc", ssrc); - - paramForAudio.put("dst_url", dstIpForAudio); - paramForAudio.put("dst_port", dstPortForAudio); - String is_Udp = isUdp ? "1" : "0"; - paramForAudio.put("is_udp", is_Udp); - paramForAudio.put("src_port", sendInfo.getSendLocalPortForAudio()); - paramForAudio.put("only_audio", "1"); - if (ptForAudio != null) { - paramForAudio.put("pt", ptForAudio); - } - - } else { - paramForAudio = null; - } - if (!ObjectUtils.isEmpty(dstIpForVideo) && dstPortForVideo > 0) { - paramForVideo = new HashMap<>(); - paramForVideo.put("vhost","__defaultVhost__"); - paramForVideo.put("app",app); - paramForVideo.put("stream",stream); - paramForVideo.put("ssrc", ssrc); - - paramForVideo.put("dst_url", dstIpForVideo); - paramForVideo.put("dst_port", dstPortForVideo); - String is_Udp = isUdp ? "1" : "0"; - paramForVideo.put("is_udp", is_Udp); - paramForVideo.put("src_port", sendInfo.getSendLocalPortForVideo()); - paramForVideo.put("only_audio", "0"); - if (ptForVideo != null) { - paramForVideo.put("pt", ptForVideo); - } - - } else { - paramForVideo = null; - } - - Boolean streamReady = zlmServerFactory.isStreamReady(mediaServerItem, app, stream); - if (streamReady) { - if (paramForVideo != null) { - JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServerItem, paramForVideo); - if (jsonObject.getInteger("code") == 0) { - logger.info("[第三方服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, paramForVideo); - redisTemplate.opsForValue().set(key, sendInfo); - }else { - redisTemplate.delete(key); - logger.info("[第三方服务对接->发送流] 视频流发流失败,callId->{}, {}", callId, jsonObject.getString("msg")); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "[视频流发流失败] " + jsonObject.getString("msg")); - } - } - if(paramForAudio != null) { - JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServerItem, paramForAudio); - if (jsonObject.getInteger("code") == 0) { - logger.info("[第三方服务对接->发送流] 音频流发流成功,callId->{},param->{}", callId, paramForAudio); - redisTemplate.opsForValue().set(key, sendInfo); - }else { - redisTemplate.delete(key); - logger.info("[第三方服务对接->发送流] 音频流发流失败,callId->{}, {}", callId, jsonObject.getString("msg")); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "[音频流发流失败] " + jsonObject.getString("msg")); - } - } - }else { - logger.info("[第三方服务对接->发送流] 流不存在,等待流上线,callId->{}", callId); - String uuid = UUID.randomUUID().toString(); - HookSubscribeForStreamChange hookSubscribeForStreamChange = HookSubscribeFactory.on_stream_changed(app, stream, true, "rtsp", mediaServerItem.getId()); - dynamicTask.startDelay(uuid, ()->{ - logger.info("[第三方服务对接->发送流] 等待流上线超时 callId->{}", callId); - redisTemplate.delete(key); - hookSubscribe.removeSubscribe(hookSubscribeForStreamChange); - }, 10000); - - // 订阅 zlm启动事件, 新的zlm也会从这里进入系统 - OtherRtpSendInfo finalSendInfo = sendInfo; - hookSubscribe.removeSubscribe(hookSubscribeForStreamChange); - hookSubscribe.addSubscribe(hookSubscribeForStreamChange, - (mediaServerItemInUse, response)->{ - dynamicTask.stop(uuid); - logger.info("[第三方服务对接->发送流] 流上线,开始发流 callId->{}", callId); - try { - Thread.sleep(400); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - if (paramForVideo != null) { - JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServerItem, paramForVideo); - if (jsonObject.getInteger("code") == 0) { - logger.info("[第三方服务对接->发送流] 视频流发流成功,callId->{},param->{}", callId, paramForVideo); - redisTemplate.opsForValue().set(key, finalSendInfo); - }else { - redisTemplate.delete(key); - logger.info("[第三方服务对接->发送流] 视频流发流失败,callId->{}, {}", callId, jsonObject.getString("msg")); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "[视频流发流失败] " + jsonObject.getString("msg")); - } - } - if(paramForAudio != null) { - JSONObject jsonObject = zlmServerFactory.startSendRtpStream(mediaServerItem, paramForAudio); - if (jsonObject.getInteger("code") == 0) { - logger.info("[第三方服务对接->发送流] 音频流发流成功,callId->{},param->{}", callId, paramForAudio); - redisTemplate.opsForValue().set(key, finalSendInfo); - }else { - redisTemplate.delete(key); - logger.info("[第三方服务对接->发送流] 音频流发流失败,callId->{}, {}", callId, jsonObject.getString("msg")); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "[音频流发流失败] " + jsonObject.getString("msg")); - } - } - hookSubscribe.removeSubscribe(hookSubscribeForStreamChange); - }); - } - } - - @GetMapping(value = "/send/stop") - @ResponseBody - @Operation(summary = "关闭发送流") - @Parameter(name = "callId", description = "整个过程的唯一标识,不传则使用随机端口发流", required = true) - public void closeSendRTP(String callId) { - logger.info("[第三方服务对接->关闭发送流] callId->{}", callId); - String key = VideoManagerConstants.WVP_OTHER_SEND_RTP_INFO + userSetting.getServerId() + "_" + callId; - OtherRtpSendInfo sendInfo = (OtherRtpSendInfo)redisTemplate.opsForValue().get(key); - if (sendInfo == null){ - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未开启发流"); - } - Map param = new HashMap<>(); - param.put("vhost","__defaultVhost__"); - param.put("app",sendInfo.getPushApp()); - param.put("stream",sendInfo.getPushStream()); - param.put("ssrc",sendInfo.getPushSSRC()); - MediaServerItem mediaServerItem = mediaServerService.getDefaultMediaServer(); - Boolean result = zlmServerFactory.stopSendRtpStream(mediaServerItem, param); - if (!result) { - logger.info("[第三方服务对接->关闭发送流] 失败 callId->{}", callId); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "停止发流失败"); - }else { - logger.info("[第三方服务对接->关闭发送流] 成功 callId->{}", callId); - } - redisTemplate.delete(key); - } - -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java deleted file mode 100644 index ff1d2a19..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ /dev/null @@ -1,248 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.server; - -import com.alibaba.fastjson2.JSON; -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.SystemAllInfo; -import com.genersoft.iot.vmp.common.VersionPo; -import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.media.zlm.SendRtpPortManager; -import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.IHookSubscribe; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.*; -import com.genersoft.iot.vmp.service.bean.MediaServerLoad; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.ResourceBaseInfo; -import com.genersoft.iot.vmp.vmanager.bean.ResourceInfo; -import com.genersoft.iot.vmp.vmanager.bean.SystemConfigInfo; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; - -import java.util.ArrayList; -import java.util.List; - -@SuppressWarnings("rawtypes") -@Tag(name = "服务控制") - -@RestController -@RequestMapping("/gbs/server") -public class ServerController { - - @Autowired - private ZlmHttpHookSubscribe zlmHttpHookSubscribe; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private SipConfig sipConfig; - - @Autowired - private UserSetting userSetting; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private IDeviceChannelService channelService; - - @Autowired - private IStreamPushService pushService; - - - @Autowired - private IStreamProxyService proxyService; - - - @Value("${server.port}") - private int serverPort; - - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private SendRtpPortManager sendRtpPortManager; - - - @GetMapping(value = "/media_server/list") - @ResponseBody - @Operation(summary = "流媒体服务列表") - public List getMediaServerList() { - return mediaServerService.getAll(); - } - - @GetMapping(value = "/media_server/online/list") - @ResponseBody - @Operation(summary = "在线流媒体服务列表") - public List getOnlineMediaServerList() { - return mediaServerService.getAllOnline(); - } - - @GetMapping(value = "/media_server/one/{id}") - @ResponseBody - @Operation(summary = "停止视频回放") - @Parameter(name = "id", description = "流媒体服务ID", required = true) - public MediaServerItem getMediaServer(@PathVariable String id) { - return mediaServerService.getOne(id); - } - - @Operation(summary = "测试流媒体服务") - @Parameter(name = "ip", description = "流媒体服务IP", required = true) - @Parameter(name = "port", description = "流媒体服务HTT端口", required = true) - @Parameter(name = "secret", description = "流媒体服务secret", required = true) - @GetMapping(value = "/media_server/check") - @ResponseBody - public MediaServerItem checkMediaServer(@RequestParam String ip, @RequestParam int port, @RequestParam String secret) { - return mediaServerService.checkMediaServer(ip, port, secret); - } - - @Operation(summary = "测试流媒体录像管理服务") - @Parameter(name = "ip", description = "流媒体服务IP", required = true) - @Parameter(name = "port", description = "流媒体服务HTT端口", required = true) - @GetMapping(value = "/media_server/record/check") - @ResponseBody - public void checkMediaRecordServer(@RequestParam String ip, @RequestParam int port) { - boolean checkResult = mediaServerService.checkMediaRecordServer(ip, port); - if (!checkResult) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "连接失败"); - } - } - - @Operation(summary = "保存流媒体服务") - @Parameter(name = "mediaServerItem", description = "流媒体信息", required = true) - @PostMapping(value = "/media_server/save") - @ResponseBody - public void saveMediaServer(@RequestBody MediaServerItem mediaServerItem) { - MediaServerItem mediaServerItemInDatabase = mediaServerService.getOne(mediaServerItem.getId()); - - if (mediaServerItemInDatabase != null) { - mediaServerService.update(mediaServerItem); - } else { - mediaServerService.add(mediaServerItem); - } - } - - @Operation(summary = "移除流媒体服务") - @Parameter(name = "id", description = "流媒体ID", required = true) - @DeleteMapping(value = "/media_server/delete") - @ResponseBody - public void deleteMediaServer(@RequestParam String id) { - if (mediaServerService.getOne(id) == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到此节点"); - } - mediaServerService.delete(id); - mediaServerService.deleteDb(id); - } - - - @Operation(summary = "重启服务") - @GetMapping(value = "/restart") - @ResponseBody - public void restart() { -// taskExecutor.execute(()-> { -// try { -// Thread.sleep(3000); -// SipProvider up = (SipProvider) SpringBeanFactory.getBean("udpSipProvider"); -// SipStackImpl stack = (SipStackImpl) up.getSipStack(); -// stack.stop(); -// Iterator listener = stack.getListeningPoints(); -// while (listener.hasNext()) { -// stack.deleteListeningPoint((ListeningPoint) listener.next()); -// } -// Iterator providers = stack.getSipProviders(); -// while (providers.hasNext()) { -// stack.deleteSipProvider((SipProvider) providers.next()); -// } -// VManageBootstrap.restart(); -// } catch (InterruptedException | ObjectInUseException e) { -// throw new ControllerException(ErrorCode.ERROR100.getCode(), e.getMessage()); -// } -// }); - }; - - @Operation(summary = "获取系统信息信息") - @GetMapping(value = "/system/configInfo") - @ResponseBody - public SystemConfigInfo getConfigInfo() { - SystemConfigInfo systemConfigInfo = new SystemConfigInfo(); - systemConfigInfo.setSip(sipConfig); - systemConfigInfo.setAddOn(userSetting); - systemConfigInfo.setServerPort(serverPort); - return systemConfigInfo; - } - - @GetMapping(value = "/config") - @Operation(summary = "获取配置信息") - @Parameter(name = "type", description = "配置类型(sip, base)", required = true) - @ResponseBody - public JSONObject getVersion(String type) { - - JSONObject jsonObject = new JSONObject(); - jsonObject.put("server.port", serverPort); - if (ObjectUtils.isEmpty(type)) { - jsonObject.put("sip", JSON.toJSON(sipConfig)); - jsonObject.put("base", JSON.toJSON(userSetting)); - } else { - switch (type) { - case "sip": - jsonObject.put("sip", sipConfig); - break; - case "base": - jsonObject.put("base", userSetting); - break; - default: - break; - } - } - return jsonObject; - } - - @GetMapping(value = "/hooks") - @ResponseBody - @Operation(summary = "获取当前所有hook") - public List getHooks() { - return zlmHttpHookSubscribe.getAll(); - } - - @GetMapping(value = "/media_server/load") - @ResponseBody - @Operation(summary = "获取负载信息") - public List getMediaLoad() { - List result = new ArrayList<>(); - List allOnline = mediaServerService.getAllOnline(); - if (allOnline.size() == 0) { - return result; - }else { - for (MediaServerItem mediaServerItem : allOnline) { - result.add(mediaServerService.getLoad(mediaServerItem)); - } - } - return result; - } - - @GetMapping(value = "/resource/info") - @ResponseBody - @Operation(summary = "获取负载信息") - public ResourceInfo getResourceInfo() { - ResourceInfo result = new ResourceInfo(); - ResourceBaseInfo deviceInfo = deviceService.getOverview(); - result.setDevice(deviceInfo); - ResourceBaseInfo channelInfo = channelService.getOverview(); - result.setChannel(channelInfo); - ResourceBaseInfo pushInfo = pushService.getOverview(); - result.setPush(pushInfo); - ResourceBaseInfo proxyInfo = proxyService.getOverview(); - result.setProxy(proxyInfo); - - return result; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java deleted file mode 100644 index 67666a38..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/streamProxy/StreamProxyController.java +++ /dev/null @@ -1,182 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.streamProxy; - -import com.alibaba.fastjson2.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; -import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.IStreamProxyService; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.StreamContent; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; - -import java.util.UUID; - -@SuppressWarnings("rawtypes") -/** - * 拉流代理接口 - */ -@Tag(name = "拉流代理", description = "") -@Controller - -@RequestMapping(value = "/gbs/proxy") -public class StreamProxyController { - - private final static Logger logger = LoggerFactory.getLogger(StreamProxyController.class); - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private IStreamProxyService streamProxyService; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private UserSetting userSetting; - - - @Operation(summary = "分页查询流代理") - @Parameter(name = "page", description = "当前页") - @Parameter(name = "count", description = "每页查询数量") - @Parameter(name = "query", description = "查询内容") - @Parameter(name = "online", description = "是否在线") - @GetMapping(value = "/list") - @ResponseBody - public Page list(Page page, StreamProxyItem entity ){ - return streamProxyService.getAll(page, entity); - } - - @Operation(summary = "查询流代理") - @Parameter(name = "app", description = "应用名") - @Parameter(name = "stream", description = "流Id") - @GetMapping(value = "/one") - @ResponseBody - public StreamProxyItem one(String app, String stream){ - - return streamProxyService.getStreamProxyByAppAndStream(app, stream); - } - - @Operation(summary = "保存代理", parameters = { - @Parameter(name = "param", description = "代理参数", required = true), - }) - @PostMapping(value = "/save") - @ResponseBody - public DeferredResult save(@RequestBody StreamProxyItem param){ - logger.info("添加代理: " + JSONObject.toJSONString(param)); - if (ObjectUtils.isEmpty(param.getMediaServerId())) { - param.setMediaServerId("auto"); - } - if (ObjectUtils.isEmpty(param.getType())) { - param.setType("default"); - } - if (ObjectUtils.isEmpty(param.getRtpType())) { - param.setRtpType("1"); - } - if (ObjectUtils.isEmpty(param.getGbId())) { - param.setGbId(null); - } - StreamProxyItem streamProxyItem = streamProxyService.getStreamProxyByAppAndStream(param.getApp(), param.getStream()); - if (streamProxyItem != null) { - streamProxyService.del(param.getApp(), param.getStream()); - } - - RequestMessage requestMessage = new RequestMessage(); - String key = DeferredResultHolder.CALLBACK_CMD_PROXY + param.getApp() + param.getStream(); - requestMessage.setKey(key); - String uuid = UUID.randomUUID().toString(); - requestMessage.setId(uuid); - DeferredResult result = new DeferredResult<>(userSetting.getPlayTimeout().longValue()); - // 录像查询以channelId作为deviceId查询 - resultHolder.put(key, uuid, result); - result.onTimeout(()->{ - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(ErrorCode.ERROR100.getCode()); - wvpResult.setMsg("超时"); - requestMessage.setData(wvpResult); - resultHolder.invokeAllResult(requestMessage); - }); - - streamProxyService.save(param, (code, msg, streamInfo) -> { - logger.info("[拉流代理] {}", code == ErrorCode.SUCCESS.getCode()? "成功":"失败: " + msg); - if (code == ErrorCode.SUCCESS.getCode()) { - requestMessage.setData(new StreamContent(streamInfo)); - }else { - requestMessage.setData(WVPResult.fail(code, msg)); - } - resultHolder.invokeAllResult(requestMessage); - }); - return result; - } - - @GetMapping(value = "/ffmpeg_cmd/list") - @ResponseBody - @Operation(summary = "获取ffmpeg.cmd模板") - @Parameter(name = "mediaServerId", description = "流媒体ID", required = true) - public JSONObject getFFmpegCMDs(@RequestParam String mediaServerId){ - logger.debug("获取节点[ {} ]ffmpeg.cmd模板", mediaServerId ); - - MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId); - if (mediaServerItem == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "流媒体: " + mediaServerId + "未找到"); - } - return streamProxyService.getFFmpegCMDs(mediaServerItem); - } - - @DeleteMapping(value = "/del") - @ResponseBody - @Operation(summary = "移除代理") - @Parameter(name = "app", description = "应用名", required = true) - @Parameter(name = "stream", description = "流id", required = true) - public void del(@RequestParam String app, @RequestParam String stream){ - logger.info("移除代理: " + app + "/" + stream); - if (app == null || stream == null) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), app == null ?"app不能为null":"stream不能为null"); - }else { - streamProxyService.del(app, stream); - } - } - - @GetMapping(value = "/start") - @ResponseBody - @Operation(summary = "启用代理") - @Parameter(name = "app", description = "应用名", required = true) - @Parameter(name = "stream", description = "流id", required = true) - public void start(String app, String stream){ - logger.info("启用代理: " + app + "/" + stream); - boolean result = streamProxyService.start(app, stream); - if (!result) { - throw new ControllerException(ErrorCode.ERROR100); - } - } - - @GetMapping(value = "/stop") - @ResponseBody - @Operation(summary = "停用代理") - @Parameter(name = "app", description = "应用名", required = true) - @Parameter(name = "stream", description = "流id", required = true) - public void stop(String app, String stream){ - logger.info("停用代理: " + app + "/" + stream); - boolean result = streamProxyService.stop(app, stream); - if (!result) { - logger.info("停用代理失败: " + app + "/" + stream); - throw new ControllerException(ErrorCode.ERROR100); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java deleted file mode 100644 index 6b9878c7..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java +++ /dev/null @@ -1,272 +0,0 @@ -package com.genersoft.iot.vmp.vmanager.streamPush; - -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -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.IStreamPushService; -import com.genersoft.iot.vmp.vmanager.bean.BatchGBStreamParam; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.vmanager.bean.StreamContent; -import com.genersoft.iot.vmp.vmanager.bean.WVPResult; -import com.iteaj.framework.security.SecurityUtil; -import io.swagger.v3.oas.annotations.Operation; -import io.swagger.v3.oas.annotations.Parameter; -import io.swagger.v3.oas.annotations.tags.Tag; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; -import org.springframework.stereotype.Controller; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.*; -import org.springframework.web.context.request.async.DeferredResult; -import org.springframework.web.multipart.MultipartFile; - -import java.io.IOException; -import java.io.InputStream; -import java.util.UUID; - -@Tag(name = "推流信息管理") -@Controller - -@RequestMapping(value = "/gbs/push") -public class StreamPushController { - - private final static Logger logger = LoggerFactory.getLogger(StreamPushController.class); - - @Autowired - private IStreamPushService streamPushService; - - @Autowired - private IMediaServerService mediaServerService; - - @Autowired - private DeferredResultHolder resultHolder; - - @Autowired - private IMediaService mediaService; - - @Autowired - private UserSetting userSetting; - - @GetMapping(value = "/list") - @ResponseBody - @Operation(summary = "推流列表查询") - @Parameter(name = "page", description = "当前页") - @Parameter(name = "count", description = "每页查询数量") - @Parameter(name = "query", description = "查询内容") - @Parameter(name = "pushing", description = "是否正在推流") - @Parameter(name = "mediaServerId", description = "流媒体ID") - public Page list(Page page, - @RequestParam(required = false)String query, - @RequestParam(required = false)Boolean pushing, - @RequestParam(required = false)String mediaServerId ){ - - if (ObjectUtils.isEmpty(query)) { - query = null; - } - if (ObjectUtils.isEmpty(mediaServerId)) { - mediaServerId = null; - } - return streamPushService.getPushList(page, query, pushing, mediaServerId); - } - - @PostMapping(value = "/save_to_gb") - @ResponseBody - @Operation(summary = "将推流添加到国标") - public void saveToGB(@RequestBody GbStream stream){ - if (!streamPushService.saveToGB(stream)){ - throw new ControllerException(ErrorCode.ERROR100); - } - } - - - @DeleteMapping(value = "/remove_form_gb") - @ResponseBody - @Operation(summary = "将推流移出到国标") - public void removeFormGB(@RequestBody GbStream stream){ - if (!streamPushService.removeFromGB(stream)){ - throw new ControllerException(ErrorCode.ERROR100); - } - } - - - @PostMapping(value = "/stop") - @ResponseBody - @Operation(summary = "中止一个推流") - @Parameter(name = "app", description = "应用名", required = true) - @Parameter(name = "stream", description = "流id", required = true) - public void stop(String app, String streamId){ - if (!streamPushService.stop(app, streamId)){ - throw new ControllerException(ErrorCode.ERROR100); - } - } - - @DeleteMapping(value = "/batchStop") - @ResponseBody - @Operation(summary = "中止多个推流") - public void batchStop(@RequestBody BatchGBStreamParam batchGBStreamParam){ - if (batchGBStreamParam.getGbStreams().size() == 0) { - throw new ControllerException(ErrorCode.ERROR100); - } - if (!streamPushService.batchStop(batchGBStreamParam.getGbStreams())){ - throw new ControllerException(ErrorCode.ERROR100); - } - } - - @PostMapping(value = "upload") - @ResponseBody - public DeferredResult>> uploadChannelFile(@RequestParam(value = "file") MultipartFile file){ - - // 最多处理文件一个小时 - DeferredResult>> result = new DeferredResult<>(60*60*1000L); - // 录像查询以channelId作为deviceId查询 - String key = DeferredResultHolder.UPLOAD_FILE_CHANNEL; - String uuid = UUID.randomUUID().toString(); - logger.info("通道导入文件类型: {}",file.getContentType() ); - if (file.isEmpty()) { - logger.warn("通道导入文件为空"); - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(-1); - wvpResult.setMsg("文件为空"); - result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult)); - return result; - } - if (file.getContentType() == null) { - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(-1); - wvpResult.setMsg("无法识别文件类型"); - result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult)); - return result; - } - // 同时只处理一个文件 - if (resultHolder.exist(key, null)) { - logger.warn("已有导入任务正在执行"); - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(-1); - wvpResult.setMsg("已有导入任务正在执行"); - result.setResult(ResponseEntity.status(HttpStatus.TOO_MANY_REQUESTS).body(wvpResult)); - return result; - } - - resultHolder.put(key, uuid, result); - result.onTimeout(()->{ - logger.warn("通道导入超时,可能文件过大"); - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(-1); - wvpResult.setMsg("导入超时,可能文件过大"); - msg.setData(wvpResult); - resultHolder.invokeAllResult(msg); - }); - //获取文件流 - InputStream inputStream = null; - try { - String name = file.getName(); - inputStream = file.getInputStream(); - } catch (IOException e) { - logger.error("未处理的异常 ", e); - } - try { - //传入参数 -// ExcelReader excelReader = EasyExcel.read(inputStream, StreamPushExcelDto.class, -// new StreamPushUploadFileHandler(streamPushService, mediaServerService.getDefaultMediaServer().getId(), (errorStreams, errorGBs)->{ -// logger.info("通道导入成功,存在重复App+Stream为{}个,存在国标ID为{}个", errorStreams.size(), errorGBs.size()); -// RequestMessage msg = new RequestMessage(); -// msg.setKey(key); -// WVPResult>> wvpResult = new WVPResult<>(); -// if (errorStreams.size() == 0 && errorGBs.size() == 0) { -// wvpResult.setCode(0); -// wvpResult.setMsg("成功"); -// }else { -// wvpResult.setCode(1); -// wvpResult.setMsg("导入成功。但是存在重复数据"); -// Map> errorData = new HashMap<>(); -// errorData.put("gbId", errorGBs); -// errorData.put("stream", errorStreams); -// wvpResult.setData(errorData); -// } -// msg.setData(wvpResult); -// resultHolder.invokeAllResult(msg); -// })).build(); -// ReadSheet readSheet = EasyExcel.readSheet(0).build(); -// excelReader.read(readSheet); -// excelReader.finish(); - }catch (Exception e) { - logger.warn("通道导入失败:", e); - RequestMessage msg = new RequestMessage(); - msg.setKey(key); - WVPResult wvpResult = new WVPResult<>(); - wvpResult.setCode(-1); - wvpResult.setMsg("通道导入失败: " + e.getMessage() ); - msg.setData(wvpResult); - resultHolder.invokeAllResult(msg); - } - - - return result; - } - - /** - * 获取推流播放地址 - * @param app 应用名 - * @param stream 流id - * @return - */ - @GetMapping(value = "/getPlayUrl") - @ResponseBody - @Operation(summary = "获取推流播放地址") - @Parameter(name = "app", description = "应用名", required = true) - @Parameter(name = "stream", description = "流id", required = true) - @Parameter(name = "mediaServerId", description = "媒体服务器id") - public StreamContent getPlayUrl(@RequestParam String app, @RequestParam String stream, - @RequestParam(required = false) String mediaServerId){ - boolean authority = false; - // 是否登陆用户, 登陆用户返回完整信息 - if (SecurityUtil.isLogin()) { - authority = true; - } - StreamPushItem push = streamPushService.getPush(app, stream); - if (push != null && !push.isSelf()) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "来自其他平台的推流信息"); - } - StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority); - if (streamInfo == null){ - throw new ControllerException(ErrorCode.ERROR100.getCode(), "获取播放地址失败"); - } - return new StreamContent(streamInfo); - } - - /** - * 添加推流信息 - * @param stream 推流信息 - * @return - */ - @PostMapping(value = "/add") - @ResponseBody - @Operation(summary = "添加推流信息") - public void add(@RequestBody StreamPushItem stream){ - if (ObjectUtils.isEmpty(stream.getGbId())) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "国标ID不可为空"); - } - if (ObjectUtils.isEmpty(stream.getApp()) && ObjectUtils.isEmpty(stream.getStream())) { - throw new ControllerException(ErrorCode.ERROR400.getCode(), "app或stream不可为空"); - } - stream.setStatus(false); - stream.setPushIng(false); - stream.setAliveSecond(0L); - stream.setTotalReaderCount("0"); - if (!streamPushService.add(stream)) { - throw new ControllerException(ErrorCode.ERROR100); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java deleted file mode 100644 index 286c8d57..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java +++ /dev/null @@ -1,155 +0,0 @@ -package com.genersoft.iot.vmp.web.gb28181; - -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; - -/** - * API兼容:设备控制 - */ - -@RestController -@RequestMapping(value = "/api/v1/control") -public class ApiControlController { - - private final static Logger logger = LoggerFactory.getLogger(ApiControlController.class); - - @Autowired - private SIPCommander cmder; - - @Autowired - private IVideoManagerStorage storager; - - /** - * 设备控制 - 云台控制 - * @param serial 设备编号 - * @param command 控制指令 允许值: left, right, up, down, upleft, upright, downleft, downright, zoomin, zoomout, stop - * @param channel 通道序号 - * @param code 通道编号 - * @param speed 速度(0~255) 默认值: 129 - * @return - */ - @RequestMapping(value = "/ptz") - private void list(String serial,String command, - @RequestParam(required = false)Integer channel, - @RequestParam(required = false)String code, - @RequestParam(required = false)Integer speed){ - - if (logger.isDebugEnabled()) { - logger.debug("模拟接口> 设备云台控制 API调用,deviceId:{} ,channelId:{} ,command:{} ,speed:{} ", - serial, code, command, speed); - } - if (channel == null) {channel = 0;} - if (speed == null) {speed = 0;} - Device device = storager.queryVideoDevice(serial); - if (device == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到"); - } - int cmdCode = 0; - switch (command){ - case "left": - cmdCode = 2; - break; - case "right": - cmdCode = 1; - break; - case "up": - cmdCode = 8; - break; - case "down": - cmdCode = 4; - break; - case "upleft": - cmdCode = 10; - break; - case "upright": - cmdCode = 9; - break; - case "downleft": - cmdCode = 6; - break; - case "downright": - cmdCode = 5; - break; - case "zoomin": - cmdCode = 16; - break; - case "zoomout": - cmdCode = 32; - break; - case "stop": - cmdCode = 0; - break; - default: - break; - } - // 默认值 50 - try { - cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 云台控制: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - } - - /** - * 设备控制 - 预置位控制 - * @param serial 设备编号 - * @param code 通道编号,通过 /api/v1/device/channellist 获取的 ChannelList.ID, 该参数和 channel 二选一传递即可 - * @param channel 通道序号, 默认值: 1 - * @param command 控制指令 允许值: set, goto, remove - * @param preset 预置位编号(1~255) - * @param name 预置位名称, command=set 时有效 - * @return - */ - @RequestMapping(value = "/preset") - private void list(String serial,String command, - @RequestParam(required = false)Integer channel, - @RequestParam(required = false)String code, - @RequestParam(required = false)String name, - @RequestParam(required = false)Integer preset){ - - if (logger.isDebugEnabled()) { - logger.debug("模拟接口> 预置位控制 API调用,deviceId:{} ,channelId:{} ,command:{} ,name:{} ,preset:{} ", - serial, code, command, name, preset); - } - - if (channel == null) {channel = 0;} - Device device = storager.queryVideoDevice(serial); - if (device == null) { - throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到"); - } - int cmdCode = 0; - switch (command){ - case "set": - cmdCode = 129; - break; - case "goto": - cmdCode = 130; - break; - case "remove": - cmdCode = 131; - break; - default: - break; - } - try { - cmder.frontEndCmd(device, code, cmdCode, 0, preset, 0); - } catch (SipException | InvalidArgumentException | ParseException e) { - logger.error("[命令发送失败] 预置位控制: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java deleted file mode 100644 index d3ea9651..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ /dev/null @@ -1,241 +0,0 @@ -package com.genersoft.iot.vmp.web.gb28181; - -import com.alibaba.fastjson2.JSONArray; -import com.alibaba.fastjson2.JSONObject; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.genersoft.iot.vmp.conf.exception.ControllerException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; -import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.vmanager.bean.DeferredResultEx; -import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; -import com.genersoft.iot.vmp.web.gb28181.dto.DeviceChannelExtend; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.util.ObjectUtils; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; -import java.util.*; - -/** - * API兼容:设备信息 - */ -@SuppressWarnings("unchecked") - -@RestController -@RequestMapping(value = "/api/v1/device") -public class ApiDeviceController { - - private final static Logger logger = LoggerFactory.getLogger(ApiDeviceController.class); - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private SIPCommander cmder; - @Autowired - private IDeviceService deviceService; - - @Autowired - private DeferredResultHolder resultHolder; - - - /** - * 分页获取设备列表 现在直接返回,尚未实现分页 - * @param page - * @param q - * @param online - * @return - */ - @RequestMapping(value = "/list") - public JSONObject list(Page page, - @RequestParam(required = false)String q, - @RequestParam(required = false)Boolean online ){ - -// if (logger.isDebugEnabled()) { -// logger.debug("查询所有视频设备API调用"); -// } - JSONObject result = new JSONObject(); - - Page deviceList = storager.queryVideoDeviceList(page, online); - result.put("DeviceCount", deviceList.getTotal()); - List devices = deviceList.getRecords(); - - - JSONArray deviceJSONList = new JSONArray(); - for (Device device : devices) { - JSONObject deviceJsonObject = new JSONObject(); - deviceJsonObject.put("ID", device.getDeviceId()); - deviceJsonObject.put("Name", device.getName()); - deviceJsonObject.put("Type", "GB"); - deviceJsonObject.put("ChannelCount", device.getChannelCount()); - deviceJsonObject.put("RecvStreamIP", ""); - deviceJsonObject.put("CatalogInterval", 3600); // 通道目录抓取周期 - deviceJsonObject.put("SubscribeInterval", device.getSubscribeCycleForCatalog()); // 订阅周期(秒), 0 表示后台不周期订阅 - deviceJsonObject.put("Online", device.isOnLine()); - deviceJsonObject.put("Password", ""); - deviceJsonObject.put("MediaTransport", device.getTransport()); - deviceJsonObject.put("RemoteIP", device.getIp()); - deviceJsonObject.put("RemotePort", device.getPort()); - deviceJsonObject.put("LastRegisterAt", ""); - deviceJsonObject.put("LastKeepaliveAt", ""); - deviceJsonObject.put("UpdatedAt", ""); - deviceJsonObject.put("CreatedAt", ""); - deviceJSONList.add(deviceJsonObject); - } - result.put("DeviceList",deviceJSONList); - return result; - } - - @RequestMapping(value = "/channellist") - public JSONObject channellist( String serial, - @RequestParam(required = false)String channel_type, - @RequestParam(required = false)String code , - @RequestParam(required = false)String dir_serial , - @RequestParam(required = false)Integer start, - @RequestParam(required = false)Integer limit, - @RequestParam(required = false)String q, - @RequestParam(required = false)Boolean online ){ - - - JSONObject result = new JSONObject(); - List deviceChannels; - List channelIds = null; - if (!ObjectUtils.isEmpty(code)) { - String[] split = code.trim().split(","); - channelIds = Arrays.asList(split); - } - List allDeviceChannelList = storager.queryChannelsByDeviceId(serial ,channelIds, online); - if (start == null || limit ==null) { - deviceChannels = allDeviceChannelList; - result.put("ChannelCount", deviceChannels.size()); - }else { - deviceChannels = storager.queryChannelsByDeviceIdWithStartAndLimit(serial, channelIds, null, null, online, start, limit); - int total = allDeviceChannelList.size(); - result.put("ChannelCount", total); - } - - JSONArray channleJSONList = new JSONArray(); - for (DeviceChannelExtend deviceChannelExtend : deviceChannels) { - JSONObject deviceJOSNChannel = new JSONObject(); - deviceJOSNChannel.put("ID", deviceChannelExtend.getChannelId()); - deviceJOSNChannel.put("DeviceID", deviceChannelExtend.getDeviceId()); - deviceJOSNChannel.put("DeviceName", deviceChannelExtend.getDeviceName()); - deviceJOSNChannel.put("DeviceOnline", deviceChannelExtend.isDeviceOnline()); - deviceJOSNChannel.put("Channel", 0); // TODO 自定义序号 - deviceJOSNChannel.put("Name", deviceChannelExtend.getName()); - deviceJOSNChannel.put("Custom", false); - deviceJOSNChannel.put("CustomName", ""); - deviceJOSNChannel.put("SubCount", deviceChannelExtend.getSubCount()); // TODO ? 子节点数, SubCount > 0 表示该通道为子目录 - deviceJOSNChannel.put("SnapURL", ""); - deviceJOSNChannel.put("Manufacturer ", deviceChannelExtend.getManufacture()); - deviceJOSNChannel.put("Model", deviceChannelExtend.getModel()); - deviceJOSNChannel.put("Owner", deviceChannelExtend.getOwner()); - deviceJOSNChannel.put("CivilCode", deviceChannelExtend.getCivilCode()); - deviceJOSNChannel.put("Address", deviceChannelExtend.getAddress()); - deviceJOSNChannel.put("Parental", deviceChannelExtend.getParental()); // 当为通道设备时, 是否有通道子设备, 1-有,0-没有 - deviceJOSNChannel.put("ParentID", deviceChannelExtend.getParentId()); // 直接上级编号 - deviceJOSNChannel.put("Secrecy", deviceChannelExtend.getSecrecy()); - deviceJOSNChannel.put("RegisterWay", 1); // 注册方式, 缺省为1, 允许值: 1, 2, 3 - // 1-IETF RFC3261, - // 2-基于口令的双向认证, - // 3-基于数字证书的双向认证 - deviceJOSNChannel.put("Status", deviceChannelExtend.isStatus() ? "ON":"OFF"); - deviceJOSNChannel.put("Longitude", deviceChannelExtend.getLongitude()); - deviceJOSNChannel.put("Latitude", deviceChannelExtend.getLatitude()); - deviceJOSNChannel.put("PTZType ", deviceChannelExtend.getPTZType()); // 云台类型, 0 - 未知, 1 - 球机, 2 - 半球, - // 3 - 固定枪机, 4 - 遥控枪机 - deviceJOSNChannel.put("CustomPTZType", ""); - deviceJOSNChannel.put("StreamID", deviceChannelExtend.getStreamId()); // StreamID 直播流ID, 有值表示正在直播 - deviceJOSNChannel.put("NumOutputs ", -1); // 直播在线人数 - channleJSONList.add(deviceJOSNChannel); - } - result.put("ChannelList", channleJSONList); - return result; - } - - /** - * 设备信息 - 获取下级通道预置位 - * @param serial 设备编号 - * @param code 通道编号,通过 /api/v1/device/channellist 获取的 ChannelList.ID, 该参数和 channel 二选一传递即可 - * @param channel 通道序号, 默认值: 1 - * @param fill 是否填充空置预置位,当下级返回预置位,但不够255个时,自动填充空置预置位到255个, 默认值: true, 允许值: true, false - * @param timeout 超时时间(秒) 默认值: 15 - * @return - */ - @RequestMapping(value = "/fetchpreset") - private DeferredResult list(String serial, - @RequestParam(required = false)Integer channel, - @RequestParam(required = false)String code, - @RequestParam(required = false)Boolean fill, - @RequestParam(required = false)Integer timeout){ - - if (logger.isDebugEnabled()) { - logger.debug("<模拟接口> 获取下级通道预置位 API调用,deviceId:{} ,channel:{} ,code:{} ,fill:{} ,timeout:{} ", - serial, channel, code, fill, timeout); - } - - Device device = storager.queryVideoDevice(serial); - String uuid = UUID.randomUUID().toString(); - String key = DeferredResultHolder.CALLBACK_CMD_PRESETQUERY + (ObjectUtils.isEmpty(code) ? serial : code); - DeferredResult result = new DeferredResult<> (timeout * 1000L); - DeferredResultEx deferredResultEx = new DeferredResultEx<>(result); - result.onTimeout(()->{ - logger.warn("<模拟接口> 获取设备预置位超时"); - // 释放rtpserver - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData("wait for presetquery timeout["+timeout+"s]"); - resultHolder.invokeResult(msg); - }); - if (resultHolder.exist(key, null)) { - return result; - } - - deferredResultEx.setFilter(filterResult->{ - List presetQuerySipReqList = (List)filterResult; - HashMap resultMap = new HashMap<>(); - resultMap.put("DeviceID", code); - resultMap.put("Result", "OK"); - resultMap.put("SumNum", presetQuerySipReqList.size()); - ArrayList> presetItemList = new ArrayList<>(presetQuerySipReqList.size()); - for (PresetQuerySipReq presetQuerySipReq : presetQuerySipReqList) { - Map item = new HashMap<>(); - item.put("PresetID", presetQuerySipReq.getPresetId()); - item.put("PresetName", presetQuerySipReq.getPresetName()); - item.put("PresetEnable", true); - presetItemList.add(item); - } - resultMap.put("PresetItemList",presetItemList ); - return resultMap; - }); - - resultHolder.put(key, uuid, deferredResultEx); - - try { - cmder.presetQuery(device, code, event -> { - RequestMessage msg = new RequestMessage(); - msg.setId(uuid); - msg.setKey(key); - msg.setData(String.format("获取设备预置位失败,错误码: %s, %s", event.statusCode, event.msg)); - resultHolder.invokeResult(msg); - }); - } catch (InvalidArgumentException | SipException | ParseException e) { - logger.error("[命令发送失败] 获取设备预置位: {}", e.getMessage()); - throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); - } - return result; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java deleted file mode 100644 index ddf677ce..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java +++ /dev/null @@ -1,250 +0,0 @@ -package com.genersoft.iot.vmp.web.gb28181; - -import com.alibaba.fastjson2.JSONObject; -import com.genersoft.iot.vmp.common.InviteInfo; -import com.genersoft.iot.vmp.common.InviteSessionType; -import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; -import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.service.IInviteStreamService; -import com.genersoft.iot.vmp.service.IPlayService; -import com.genersoft.iot.vmp.service.bean.InviteErrorCode; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.context.request.async.DeferredResult; - -import javax.sip.InvalidArgumentException; -import javax.sip.SipException; -import java.text.ParseException; - -/** - * API兼容:实时直播 - */ -@SuppressWarnings(value = {"rawtypes", "unchecked"}) - -@RestController -@RequestMapping(value = "/api/v1/stream") -public class ApiStreamController { - - private final static Logger logger = LoggerFactory.getLogger(ApiStreamController.class); - - @Autowired - private SIPCommander cmder; - - @Autowired - private IVideoManagerStorage storager; - - @Autowired - private UserSetting userSetting; - - @Autowired - private IRedisCatchStorage redisCatchStorage; - - @Autowired - private IDeviceService deviceService; - - @Autowired - private IPlayService playService; - - @Autowired - private IInviteStreamService inviteStreamService; - - /** - * 实时直播 - 开始直播 - * @param serial 设备编号 - * @param channel 通道序号 默认值: 1 - * @param code 通道编号,通过 /api/v1/device/channellist 获取的 ChannelList.ID, 该参数和 channel 二选一传递即可 - * @param cdn 转推 CDN 地址, 形如: [rtmp|rtsp]://xxx, encodeURIComponent - * @param audio 是否开启音频, 默认 开启 - * @param transport 流传输模式, 默认 UDP - * @param checkchannelstatus 是否检查通道状态, 默认 false, 表示 拉流前不检查通道状态是否在线 - * @param transportmode 当 transport=TCP 时有效, 指示流传输主被动模式, 默认被动 - * @param timeout 拉流超时(秒), - * @return - */ - @RequestMapping(value = "/start") - private DeferredResult start(String serial , - @RequestParam(required = false)Integer channel , - @RequestParam(required = false)String code, - @RequestParam(required = false)String cdn, - @RequestParam(required = false)String audio, - @RequestParam(required = false)String transport, - @RequestParam(required = false)String checkchannelstatus , - @RequestParam(required = false)String transportmode, - @RequestParam(required = false)String timeout - - ){ - DeferredResult resultDeferredResult = new DeferredResult<>(userSetting.getPlayTimeout().longValue() + 10); - Device device = storager.queryVideoDevice(serial); - if (device == null ) { - JSONObject result = new JSONObject(); - result.put("error","device[ " + serial + " ]未找到"); - resultDeferredResult.setResult(result); - return resultDeferredResult; - }else if (device.isOnLine()) { - JSONObject result = new JSONObject(); - result.put("error","device[ " + code + " ]offline"); - resultDeferredResult.setResult(result); - return resultDeferredResult; - } - resultDeferredResult.onTimeout(()->{ - logger.info("播放等待超时"); - JSONObject result = new JSONObject(); - result.put("error","timeout"); - resultDeferredResult.setResult(result); - - // 清理RTP server - }); - - DeviceChannel deviceChannel = storager.queryChannel(serial, code); - if (deviceChannel == null) { - JSONObject result = new JSONObject(); - result.put("error","channel[ " + code + " ]未找到"); - resultDeferredResult.setResult(result); - return resultDeferredResult; - }else if (!deviceChannel.isStatus()) { - JSONObject result = new JSONObject(); - result.put("error","channel[ " + code + " ]offline"); - resultDeferredResult.setResult(result); - return resultDeferredResult; - } - MediaServerItem newMediaServerItem = playService.getNewMediaServerItem(device); - - - playService.play(newMediaServerItem, serial, code, null, (errorCode, msg, data) -> { - if (errorCode == InviteErrorCode.SUCCESS.getCode()) { - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code); - if (inviteInfo != null && inviteInfo.getStreamInfo() != null) { - JSONObject result = new JSONObject(); - result.put("StreamID", inviteInfo.getStreamInfo().getStream()); - result.put("DeviceID", device.getDeviceId()); - result.put("ChannelID", code); - result.put("ChannelName", deviceChannel.getName()); - result.put("ChannelCustomName", ""); - result.put("FLV", inviteInfo.getStreamInfo().getFlv().getUrl()); - if(inviteInfo.getStreamInfo().getHttps_flv() != null) { - result.put("HTTPS_FLV", inviteInfo.getStreamInfo().getHttps_flv().getUrl()); - } - result.put("WS_FLV", inviteInfo.getStreamInfo().getWs_flv().getUrl()); - if(inviteInfo.getStreamInfo().getWss_flv() != null) { - result.put("WSS_FLV", inviteInfo.getStreamInfo().getWss_flv().getUrl()); - } - result.put("RTMP", inviteInfo.getStreamInfo().getRtmp().getUrl()); - if (inviteInfo.getStreamInfo().getRtmps() != null) { - result.put("RTMPS", inviteInfo.getStreamInfo().getRtmps().getUrl()); - } - result.put("HLS", inviteInfo.getStreamInfo().getHls().getUrl()); - if (inviteInfo.getStreamInfo().getHttps_hls() != null) { - result.put("HTTPS_HLS", inviteInfo.getStreamInfo().getHttps_hls().getUrl()); - } - result.put("RTSP", inviteInfo.getStreamInfo().getRtsp().getUrl()); - if (inviteInfo.getStreamInfo().getRtsps() != null) { - result.put("RTSPS", inviteInfo.getStreamInfo().getRtsps().getUrl()); - } - result.put("WEBRTC", inviteInfo.getStreamInfo().getRtc().getUrl()); - if (inviteInfo.getStreamInfo().getRtcs() != null) { - result.put("HTTPS_WEBRTC", inviteInfo.getStreamInfo().getRtcs().getUrl()); - } - result.put("CDN", ""); - result.put("SnapURL", ""); - result.put("Transport", device.getTransport()); - result.put("StartAt", ""); - result.put("Duration", ""); - result.put("SourceVideoCodecName", ""); - result.put("SourceVideoWidth", ""); - result.put("SourceVideoHeight", ""); - result.put("SourceVideoFrameRate", ""); - result.put("SourceAudioCodecName", ""); - result.put("SourceAudioSampleRate", ""); - result.put("AudioEnable", ""); - result.put("Ondemand", ""); - result.put("InBytes", ""); - result.put("InBitRate", ""); - result.put("OutBytes", ""); - result.put("NumOutputs", ""); - result.put("CascadeSize", ""); - result.put("RelaySize", ""); - result.put("ChannelPTZType", "0"); - resultDeferredResult.setResult(result); - } - }else { - JSONObject result = new JSONObject(); - result.put("error", "channel[ " + code + " ] " + msg); - resultDeferredResult.setResult(result); - } - }); - - return resultDeferredResult; - } - - /** - * 实时直播 - 直播流停止 - * @param serial 设备编号 - * @param channel 通道序号 - * @param code 通道国标编号 - * @param check_outputs - * @return - */ - @RequestMapping(value = "/stop") - @ResponseBody - private JSONObject stop(String serial , - @RequestParam(required = false)Integer channel , - @RequestParam(required = false)String code, - @RequestParam(required = false)String check_outputs - - ){ - - InviteInfo inviteInfo = inviteStreamService.getInviteInfoByDeviceAndChannel(InviteSessionType.PLAY, serial, code); - if (inviteInfo == null) { - JSONObject result = new JSONObject(); - result.put("error","未找到流信息"); - return result; - } - Device device = deviceService.getDevice(serial); - if (device == null) { - JSONObject result = new JSONObject(); - result.put("error","未找到设备"); - return result; - } - try { - cmder.streamByeCmd(device, code, inviteInfo.getStream(), null); - } catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) { - JSONObject result = new JSONObject(); - result.put("error","发送BYE失败:" + e.getMessage()); - return result; - } - inviteStreamService.removeInviteInfo(inviteInfo); - storager.stopPlay(inviteInfo.getDeviceId(), inviteInfo.getChannelId()); - return null; - } - - /** - * 实时直播 - 直播流保活 - * @param serial 设备编号 - * @param channel 通道序号 - * @param code 通道国标编号 - * @return - */ - @RequestMapping(value = "/touch") - @ResponseBody - private JSONObject touch(String serial ,String t, - @RequestParam(required = false)Integer channel , - @RequestParam(required = false)String code, - @RequestParam(required = false)String autorestart, - @RequestParam(required = false)String audio, - @RequestParam(required = false)String cdn - ){ - return null; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java b/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java deleted file mode 100644 index 5e76cb70..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/java/com/genersoft/iot/vmp/web/gb28181/dto/DeviceChannelExtend.java +++ /dev/null @@ -1,555 +0,0 @@ -package com.genersoft.iot.vmp.web.gb28181.dto; - -public class DeviceChannelExtend { - - - /** - * 数据库自增ID - */ - private int id; - - /** - * 通道id - */ - private String channelId; - - /** - * 设备id - */ - private String deviceId; - - /** - * 通道名 - */ - private String name; - - private String deviceName; - - private boolean deviceOnline; - - /** - * 生产厂商 - */ - private String manufacture; - - /** - * 型号 - */ - private String model; - - /** - * 设备归属 - */ - private String owner; - - /** - * 行政区域 - */ - private String civilCode; - - /** - * 警区 - */ - private String block; - - /** - * 安装地址 - */ - private String address; - - /** - * 是否有子设备 1有, 0没有 - */ - private int parental; - - /** - * 父级id - */ - private String parentId; - - /** - * 信令安全模式 缺省为0; 0:不采用; 2: S/MIME签名方式; 3: S/ MIME加密签名同时采用方式; 4:数字摘要方式 - */ - private int safetyWay; - - /** - * 注册方式 缺省为1;1:符合IETFRFC3261标准的认证注册模 式; 2:基于口令的双向认证注册模式; 3:基于数字证书的双向认证注册模式 - */ - private int registerWay; - - /** - * 证书序列号 - */ - private String certNum; - - /** - * 证书有效标识 缺省为0;证书有效标识:0:无效1: 有效 - */ - private int certifiable; - - /** - * 证书无效原因码 - */ - private int errCode; - - /** - * 证书终止有效期 - */ - private String endTime; - - /** - * 保密属性 缺省为0; 0:不涉密, 1:涉密 - */ - private String secrecy; - - /** - * IP地址 - */ - private String ipAddress; - - /** - * 端口号 - */ - private int port; - - /** - * 密码 - */ - private String password; - - /** - * 云台类型 - */ - private int PTZType; - - /** - * 云台类型描述字符串 - */ - private String PTZTypeText; - - /** - * 创建时间 - */ - private String createTime; - - /** - * 更新时间 - */ - private String updateTime; - - /** - * 在线/离线 - * 1在线,0离线 - * 默认在线 - * 信令: - * ON - * OFF - * 遇到过NVR下的IPC下发信令可以推流, 但是 Status 响应 OFF - */ - private boolean status; - - /** - * 经度 - */ - private double longitude; - - /** - * 纬度 - */ - private double latitude; - - /** - * 经度 GCJ02 - */ - private double longitudeGcj02; - - /** - * 纬度 GCJ02 - */ - private double latitudeGcj02; - - /** - * 经度 WGS84 - */ - private double longitudeWgs84; - - /** - * 纬度 WGS84 - */ - private double latitudeWgs84; - - /** - * 子设备数 - */ - private int subCount; - - /** - * 流唯一编号,存在表示正在直播 - */ - private String streamId; - - /** - * 是否含有音频 - */ - private boolean hasAudio; - - /** - * 标记通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划 - */ - private int channelType; - - /** - * 业务分组 - */ - private String businessGroupId; - - /** - * GPS的更新时间 - */ - private String gpsTime; - - public int getId() { - return id; - } - - public void setId(int id) { - this.id = id; - } - - public String getDeviceId() { - return deviceId; - } - - public void setDeviceId(String deviceId) { - this.deviceId = deviceId; - } - - public void setPTZType(int PTZType) { - this.PTZType = PTZType; - switch (PTZType) { - case 0: - this.PTZTypeText = "未知"; - break; - case 1: - this.PTZTypeText = "球机"; - break; - case 2: - this.PTZTypeText = "半球"; - break; - case 3: - this.PTZTypeText = "固定枪机"; - break; - case 4: - this.PTZTypeText = "遥控枪机"; - break; - } - } - - public String getChannelId() { - return channelId; - } - - public void setChannelId(String channelId) { - this.channelId = channelId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getManufacture() { - return manufacture; - } - - public void setManufacture(String manufacture) { - this.manufacture = manufacture; - } - - public String getModel() { - return model; - } - - public void setModel(String model) { - this.model = model; - } - - public String getOwner() { - return owner; - } - - public void setOwner(String owner) { - this.owner = owner; - } - - public String getCivilCode() { - return civilCode; - } - - public void setCivilCode(String civilCode) { - this.civilCode = civilCode; - } - - public String getBlock() { - return block; - } - - public void setBlock(String block) { - this.block = block; - } - - public String getAddress() { - return address; - } - - public void setAddress(String address) { - this.address = address; - } - - public int getParental() { - return parental; - } - - public void setParental(int parental) { - this.parental = parental; - } - - public String getParentId() { - return parentId; - } - - public void setParentId(String parentId) { - this.parentId = parentId; - } - - public int getSafetyWay() { - return safetyWay; - } - - public void setSafetyWay(int safetyWay) { - this.safetyWay = safetyWay; - } - - public int getRegisterWay() { - return registerWay; - } - - public void setRegisterWay(int registerWay) { - this.registerWay = registerWay; - } - - public String getCertNum() { - return certNum; - } - - public void setCertNum(String certNum) { - this.certNum = certNum; - } - - public int getCertifiable() { - return certifiable; - } - - public void setCertifiable(int certifiable) { - this.certifiable = certifiable; - } - - public int getErrCode() { - return errCode; - } - - public void setErrCode(int errCode) { - this.errCode = errCode; - } - - public String getEndTime() { - return endTime; - } - - public void setEndTime(String endTime) { - this.endTime = endTime; - } - - public String getSecrecy() { - return secrecy; - } - - public void setSecrecy(String secrecy) { - this.secrecy = secrecy; - } - - public String getIpAddress() { - return ipAddress; - } - - public void setIpAddress(String ipAddress) { - this.ipAddress = ipAddress; - } - - public int getPort() { - return port; - } - - public void setPort(int port) { - this.port = port; - } - - public String getPassword() { - return password; - } - - public void setPassword(String password) { - this.password = password; - } - - public int getPTZType() { - return PTZType; - } - - public String getPTZTypeText() { - return PTZTypeText; - } - - public void setPTZTypeText(String PTZTypeText) { - this.PTZTypeText = PTZTypeText; - } - - public boolean isStatus() { - return status; - } - - public void setStatus(boolean status) { - this.status = status; - } - - public double getLongitude() { - return longitude; - } - - public void setLongitude(double longitude) { - this.longitude = longitude; - } - - public double getLatitude() { - return latitude; - } - - public void setLatitude(double latitude) { - this.latitude = latitude; - } - - public double getLongitudeGcj02() { - return longitudeGcj02; - } - - public void setLongitudeGcj02(double longitudeGcj02) { - this.longitudeGcj02 = longitudeGcj02; - } - - public double getLatitudeGcj02() { - return latitudeGcj02; - } - - public void setLatitudeGcj02(double latitudeGcj02) { - this.latitudeGcj02 = latitudeGcj02; - } - - public double getLongitudeWgs84() { - return longitudeWgs84; - } - - public void setLongitudeWgs84(double longitudeWgs84) { - this.longitudeWgs84 = longitudeWgs84; - } - - public double getLatitudeWgs84() { - return latitudeWgs84; - } - - public void setLatitudeWgs84(double latitudeWgs84) { - this.latitudeWgs84 = latitudeWgs84; - } - - public int getSubCount() { - return subCount; - } - - public void setSubCount(int subCount) { - this.subCount = subCount; - } - - public boolean isHasAudio() { - return hasAudio; - } - - public void setHasAudio(boolean hasAudio) { - this.hasAudio = hasAudio; - } - - public String getStreamId() { - return streamId; - } - - public void setStreamId(String streamId) { - this.streamId = streamId; - } - - public String getCreateTime() { - return createTime; - } - - public void setCreateTime(String createTime) { - this.createTime = createTime; - } - - public String getUpdateTime() { - return updateTime; - } - - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } - - public int getChannelType() { - return channelType; - } - - public void setChannelType(int channelType) { - this.channelType = channelType; - } - - public String getBusinessGroupId() { - return businessGroupId; - } - - public void setBusinessGroupId(String businessGroupId) { - this.businessGroupId = businessGroupId; - } - - public String getGpsTime() { - return gpsTime; - } - - public void setGpsTime(String gpsTime) { - this.gpsTime = gpsTime; - } - - public String getDeviceName() { - return deviceName; - } - - public void setDeviceName(String deviceName) { - this.deviceName = deviceName; - } - - public boolean isDeviceOnline() { - return deviceOnline; - } - - public void setDeviceOnline(boolean deviceOnline) { - this.deviceOnline = deviceOnline; - } -} diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/application-docker.yml b/iboot-tos/wvp-GB28181-pro/src/main/resources/application-docker.yml deleted file mode 100644 index f6f6f348..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/application-docker.yml +++ /dev/null @@ -1,79 +0,0 @@ -spring: - # 上传文件大小限制 - servlet: - multipart: - max-file-size: 10MB - max-request-size: 100MB - # REDIS数据库配置 - redis: - # [必须修改] Redis服务器IP, REDIS安装在本机的,使用127.0.0.1 - host: ${REDIS_HOST:127.0.0.1} - # [必须修改] 端口号 - port: ${REDIS_PORT:6379} - # [可选] 数据库 DB - database: ${REDIS_DB:6} - # [可选] 访问密码,若你的redis服务器没有设置密码,就不需要用密码去连接 - password: ${REDIS_PWD:root} - # [可选] 超时时间 - timeout: 10000 - # [必选] jdbc数据库配置 - datasource: - # 使用mysql 打开23-28行注释, 删除29-36行 - name: wvp - url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true&useSSL=false&allowMultiQueries=true - username: root - password: root - type: com.zaxxer.hikari.HikariDataSource - driver-class-name: com.mysql.cj.jdbc.Driver - -# [可选] WVP监听的HTTP端口, 网页和接口调用都是这个端口 -server: - port: 18080 - -# 作为28181服务器的配置 -sip: - # [必须修改] 本机的IP,对应你的网卡,监听什么ip就是使用什么网卡, - # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4 - # 如果不明白,就使用0.0.0.0,大部分情况都是可以的 - # 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。 - ip: ${WVP_HOST:127.0.0.1} - # [可选] 28181服务监听的端口 - port: ${WVP_PORT:5060} - # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) - # 后两位为行业编码,定义参照附录D.3 - # 3701020049标识山东济南历下区 信息行业接入 - # [可选] - domain: ${WVP_DOMAIN:4401020049} - # [可选] - id: ${WVP_ID:44010200492000000001} - # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 - password: ${WVP_PWD:admin123} - -#zlm 默认服务器配置 -media: - # [必须修改] zlm服务器唯一id,用于触发hook时区别是哪台服务器,general.mediaServerId - id: - # [必须修改] zlm服务器的内网IP - ip: ${ZLM_HOST:127.0.0.1} - # [必须修改] zlm服务器的http.port - http-port: ${ZLM_PORT:80} - # [可选] zlm服务器的hook.admin_params=secret - secret: 035c73f7-bb6b-4889-a715-d9eb2d1925cc - # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 - rtp: - # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 - enable: true - # [可选] 在此范围内选择端口用于媒体流传输, - port-range: 30000,30500 # 端口范围 - # [可选] 国标级联在此范围内选择端口发送媒体流, - send-port-range: 30000,30500 # 端口范围 - # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 - record-assist-port: 18081 - sdp-ip: ${sip.ip} - stream-ip: ${sip.ip} - -# [根据业务需求配置] -user-settings: - # 推流直播是否录制 - record-push-live: true - auto-apply-play: true diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/application-wvp.yml b/iboot-tos/wvp-GB28181-pro/src/main/resources/application-wvp.yml deleted file mode 100644 index c4bb6da8..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/application-wvp.yml +++ /dev/null @@ -1,170 +0,0 @@ -# [根据业务需求配置] -user-settings: - # 点播/录像回放 等待超时时间,单位:毫秒 - play-timeout: 15000 - # [可选] 自动点播, 使用固定流地址进行播放时,如果未点播则自动进行点播, 需要rtp.enable=true - auto-apply-play: true - # 设备/通道状态变化时发送消息 - device-status-notify: true - # 跨域配置,配置你访问前端页面的地址即可, 可以配置多个 - allowed-origins: - - http://localhost:8080 - - http://127.0.0.1:8080 -spring: - config: - activate: - on-profile: dev #开发环境 -# 作为28181服务器的配置 -sip: - # [必须修改] 本机的IP,对应你的网卡,监听什么ip就是使用什么网卡, - # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4 - # 如果不明白,就使用0.0.0.0,大部分情况都是可以的 - # 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。 - ip: 192.168.20.168 - # [可选] 28181服务监听的端口 - port: 5060 - # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) - # 后两位为行业编码,定义参照附录D.3 - # 3701020049标识山东济南历下区 信息行业接入 - # [可选] - domain: 3402000000 - # [可选] - id: 34020000002000000001 - # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 - password: - # 是否存储alarm信息 - alarm: true - -#zlm 默认服务器配置 -media: - id: ZOc7Cq1of1AyEnQ3 - # [必须修改] zlm服务器的内网IP - ip: 192.168.20.199 - # [必须修改] zlm服务器的http.port - http-port: 8080 - # [可选] 返回流地址时的ip,默认使用 media.ip - stream-ip: ${media.ip} - # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 默认使用 media.ip - sdp-ip: ${media.ip} - # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip - hook-ip: ${sip.ip} - # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 - http-ssl-port: 1443 - # [可选] zlm服务器的hook.admin_params=secret - secret: wSD1pGgF13RKh7xvftySuqyIZjSY2W1x - # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 - rtp: - # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 - enable: false - # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功 - port-range: 50000,50300 # 端口范围 - # [可选] 国标级联在此范围内选择端口发送媒体流, - send-port-range: 50000,50300 # 端口范围 - # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 - record-assist-port: 0 ---- -spring: - config: - activate: - on-profile: test #测试环境 -# 作为28181服务器的配置 -sip: - # [必须修改] 本机的IP,对应你的网卡,监听什么ip就是使用什么网卡, - # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4 - # 如果不明白,就使用0.0.0.0,大部分情况都是可以的 - # 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。 - ip: 192.168.20.168 - # [可选] 28181服务监听的端口 - port: 5060 - # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) - # 后两位为行业编码,定义参照附录D.3 - # 3701020049标识山东济南历下区 信息行业接入 - # [可选] - domain: 3506000049 - # [可选] - id: 41010500002000000001 - # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 - password: - # 是否存储alarm信息 - alarm: true - -#zlm 默认服务器配置 -media: - id: ZOc7Cq1of1AyEnQ3 - # [必须修改] zlm服务器的内网IP - ip: 192.168.20.199 - # [必须修改] zlm服务器的http.port - http-port: 8080 - # [可选] 返回流地址时的ip,默认使用 media.ip - stream-ip: ${media.ip} - # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 默认使用 media.ip - sdp-ip: ${media.ip} - # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip - hook-ip: ${sip.ip} - # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 - http-ssl-port: 1443 - # [可选] zlm服务器的hook.admin_params=secret - secret: wSD1pGgF13RKh7xvftySuqyIZjSY2W1x - # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 - rtp: - # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 - enable: false - # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功 - port-range: 50000,50300 # 端口范围 - # [可选] 国标级联在此范围内选择端口发送媒体流, - send-port-range: 50000,50300 # 端口范围 - # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 - record-assist-port: 0 ---- -spring: - config: - activate: - on-profile: test #正式环境 -# 作为28181服务器的配置 -sip: - # [必须修改] 本机的IP,对应你的网卡,监听什么ip就是使用什么网卡, - # 如果要监听多张网卡,可以使用逗号分隔多个IP, 例如: 192.168.1.4,10.0.0.4 - # 如果不明白,就使用0.0.0.0,大部分情况都是可以的 - # 请不要使用127.0.0.1,任何包括localhost在内的域名都是不可以的。 - ip: 192.168.20.168 - # [可选] 28181服务监听的端口 - port: 5060 - # 根据国标6.1.2中规定,domain宜采用ID统一编码的前十位编码。国标附录D中定义前8位为中心编码(由省级、市级、区级、基层编号组成,参照GB/T 2260-2007) - # 后两位为行业编码,定义参照附录D.3 - # 3701020049标识山东济南历下区 信息行业接入 - # [可选] - domain: 3506000049 - # [可选] - id: 41010500002000000001 - # [可选] 默认设备认证密码,后续扩展使用设备单独密码, 移除密码将不进行校验 - password: - # 是否存储alarm信息 - alarm: true - -#zlm 默认服务器配置 -media: - id: ZOc7Cq1of1AyEnQ3 - # [必须修改] zlm服务器的内网IP - ip: 192.168.20.199 - # [必须修改] zlm服务器的http.port - http-port: 8080 - # [可选] 返回流地址时的ip,默认使用 media.ip - stream-ip: ${media.ip} - # [可选] wvp在国标信令中使用的ip,此ip为摄像机可以访问到的ip, 默认使用 media.ip - sdp-ip: ${media.ip} - # [可选] zlm服务器的hook所使用的IP, 默认使用sip.ip - hook-ip: ${sip.ip} - # [可选] zlm服务器的http.sslport, 置空使用zlm配置文件配置 - http-ssl-port: 1443 - # [可选] zlm服务器的hook.admin_params=secret - secret: wSD1pGgF13RKh7xvftySuqyIZjSY2W1x - # 启用多端口模式, 多端口模式使用端口区分每路流,兼容性更好。 单端口使用流的ssrc区分, 点播超时建议使用多端口测试 - rtp: - # [可选] 是否启用多端口模式, 开启后会在portRange范围内选择端口用于媒体流传输 - enable: false - # [可选] 在此范围内选择端口用于媒体流传输, 必须提前在zlm上配置该属性,不然自动配置此属性可能不成功 - port-range: 50000,50300 # 端口范围 - # [可选] 国标级联在此范围内选择端口发送媒体流, - send-port-range: 50000,50300 # 端口范围 - # 录像辅助服务, 部署此服务可以实现zlm录像的管理与下载, 0 表示不使用 - record-assist-port: 0 diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/civilCode.csv b/iboot-tos/wvp-GB28181-pro/src/main/resources/civilCode.csv deleted file mode 100644 index 7785924f..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/civilCode.csv +++ /dev/null @@ -1,3220 +0,0 @@ -编号,名称,上级 -11,北京市, -110101,东城区,11 -110102,西城区,11 -110105,朝阳区,11 -110106,丰台区,11 -110107,石景山区,11 -110108,海淀区,11 -110109,门头沟区,11 -110111,房山区,11 -110112,通州区,11 -110113,顺义区,11 -110114,昌平区,11 -110115,大兴区,11 -110116,怀柔区,11 -110117,平谷区,11 -110118,密云区,11 -110119,延庆区,11 -12,天津市, -120101,和平区,12 -120102,河东区,12 -120103,河西区,12 -120104,南开区,12 -120105,河北区,12 -120106,红桥区,12 -120110,东丽区,12 -120111,西青区,12 -120112,津南区,12 -120113,北辰区,12 -120114,武清区,12 -120115,宝坻区,12 -120116,滨海新区,12 -120117,宁河区,12 -120118,静海区,12 -120119,蓟州区,12 -13,河北省, -1301,石家庄市,13 -130102,长安区,1301 -130104,桥西区,1301 -130105,新华区,1301 -130107,井陉矿区,1301 -130108,裕华区,1301 -130109,藁城区,1301 -130110,鹿泉区,1301 -130111,栾城区,1301 -130121,井陉县,1301 -130123,正定县,1301 -130125,行唐县,1301 -130126,灵寿县,1301 -130127,高邑县,1301 -130128,深泽县,1301 -130129,赞皇县,1301 -130130,无极县,1301 -130131,平山县,1301 -130132,元氏县,1301 -130133,赵县,1301 -130181,辛集市,1301 -130183,晋州市,1301 -130184,新乐市,1301 -1302,唐山市,13 -130202,路南区,1302 -130203,路北区,1302 -130204,古冶区,1302 -130205,开平区,1302 -130207,丰南区,1302 -130208,丰润区,1302 -130209,曹妃甸区,1302 -130224,滦南县,1302 -130225,乐亭县,1302 -130227,迁西县,1302 -130229,玉田县,1302 -130281,遵化市,1302 -130283,迁安市,1302 -130284,滦州市,1302 -1303,秦皇岛市,13 -130302,海港区,1303 -130303,山海关区,1303 -130304,北戴河区,1303 -130306,抚宁区,1303 -130321,青龙满族自治县,1303 -130322,昌黎县,1303 -130324,卢龙县,1303 -1304,邯郸市,13 -130402,邯山区,1304 -130403,丛台区,1304 -130404,复兴区,1304 -130406,峰峰矿区,1304 -130407,肥乡区,1304 -130408,永年区,1304 -130423,临漳县,1304 -130424,成安县,1304 -130425,大名县,1304 -130426,涉县,1304 -130427,磁县,1304 -130430,邱县,1304 -130431,鸡泽县,1304 -130432,广平县,1304 -130433,馆陶县,1304 -130434,魏县,1304 -130435,曲周县,1304 -130481,武安市,1304 -1305,邢台市,13 -130502,桥东区,1305 -130503,桥西区,1305 -130521,邢台县,1305 -130522,临城县,1305 -130523,内丘县,1305 -130524,柏乡县,1305 -130525,隆尧县,1305 -130526,任县,1305 -130527,南和县,1305 -130528,宁晋县,1305 -130529,巨鹿县,1305 -130530,新河县,1305 -130531,广宗县,1305 -130532,平乡县,1305 -130533,威县,1305 -130534,清河县,1305 -130535,临西县,1305 -130581,南宫市,1305 -130582,沙河市,1305 -1306,保定市,13 -130602,竞秀区,1306 -130606,莲池区,1306 -130607,满城区,1306 -130608,清苑区,1306 -130609,徐水区,1306 -130623,涞水县,1306 -130624,阜平县,1306 -130626,定兴县,1306 -130627,唐县,1306 -130628,高阳县,1306 -130629,容城县,1306 -130630,涞源县,1306 -130631,望都县,1306 -130632,安新县,1306 -130633,易县,1306 -130634,曲阳县,1306 -130635,蠡县,1306 -130636,顺平县,1306 -130637,博野县,1306 -130638,雄县,1306 -130681,涿州市,1306 -130682,定州市,1306 -130683,安国市,1306 -130684,高碑店市,1306 -1307,张家口市,13 -130702,桥东区,1307 -130703,桥西区,1307 -130705,宣化区,1307 -130706,下花园区,1307 -130708,万全区,1307 -130709,崇礼区,1307 -130722,张北县,1307 -130723,康保县,1307 -130724,沽源县,1307 -130725,尚义县,1307 -130726,蔚县,1307 -130727,阳原县,1307 -130728,怀安县,1307 -130730,怀来县,1307 -130731,涿鹿县,1307 -130732,赤城县,1307 -1308,承德市,13 -130802,双桥区,1308 -130803,双滦区,1308 -130804,鹰手营子矿区,1308 -130821,承德县,1308 -130822,兴隆县,1308 -130824,滦平县,1308 -130825,隆化县,1308 -130826,丰宁满族自治县,1308 -130827,宽城满族自治县,1308 -130828,围场满族蒙古族自治县,1308 -130881,平泉市,1308 -1309,沧州市,13 -130902,新华区,1309 -130903,运河区,1309 -130921,沧县,1309 -130922,青县,1309 -130923,东光县,1309 -130924,海兴县,1309 -130925,盐山县,1309 -130926,肃宁县,1309 -130927,南皮县,1309 -130928,吴桥县,1309 -130929,献县,1309 -130930,孟村回族自治县,1309 -130981,泊头市,1309 -130982,任丘市,1309 -130983,黄骅市,1309 -130984,河间市,1309 -1310,廊坊市,13 -131002,安次区,1310 -131003,广阳区,1310 -131022,固安县,1310 -131023,永清县,1310 -131024,香河县,1310 -131025,大城县,1310 -131026,文安县,1310 -131028,大厂回族自治县,1310 -131081,霸州市,1310 -131082,三河市,1310 -1311,衡水市,13 -131102,桃城区,1311 -131103,冀州区,1311 -131121,枣强县,1311 -131122,武邑县,1311 -131123,武强县,1311 -131124,饶阳县,1311 -131125,安平县,1311 -131126,故城县,1311 -131127,景县,1311 -131128,阜城县,1311 -131182,深州市,1311 -14,山西省, -1401,太原市,14 -140105,小店区,1401 -140106,迎泽区,1401 -140107,杏花岭区,1401 -140108,尖草坪区,1401 -140109,万柏林区,1401 -140110,晋源区,1401 -140121,清徐县,1401 -140122,阳曲县,1401 -140123,娄烦县,1401 -140181,古交市,1401 -1402,大同市,14 -140212,新荣区,1402 -140213,平城区,1402 -140214,云冈区,1402 -140215,云州区,1402 -140221,阳高县,1402 -140222,天镇县,1402 -140223,广灵县,1402 -140224,灵丘县,1402 -140225,浑源县,1402 -140226,左云县,1402 -1403,阳泉市,14 -140302,城区,1403 -140303,矿区,1403 -140311,郊区,1403 -140321,平定县,1403 -140322,盂县,1403 -1404,长治市,14 -140403,潞州区,1404 -140404,上党区,1404 -140405,屯留区,1404 -140406,潞城区,1404 -140423,襄垣县,1404 -140425,平顺县,1404 -140426,黎城县,1404 -140427,壶关县,1404 -140428,长子县,1404 -140429,武乡县,1404 -140430,沁县,1404 -140431,沁源县,1404 -1405,晋城市,14 -140502,城区,1405 -140521,沁水县,1405 -140522,阳城县,1405 -140524,陵川县,1405 -140525,泽州县,1405 -140581,高平市,1405 -1406,朔州市,14 -140602,朔城区,1406 -140603,平鲁区,1406 -140621,山阴县,1406 -140622,应县,1406 -140623,右玉县,1406 -140681,怀仁市,1406 -1407,晋中市,14 -140702,榆次区,1407 -140721,榆社县,1407 -140722,左权县,1407 -140723,和顺县,1407 -140724,昔阳县,1407 -140725,寿阳县,1407 -140726,太谷县,1407 -140727,祁县,1407 -140728,平遥县,1407 -140729,灵石县,1407 -140781,介休市,1407 -1408,运城市,14 -140802,盐湖区,1408 -140821,临猗县,1408 -140822,万荣县,1408 -140823,闻喜县,1408 -140824,稷山县,1408 -140825,新绛县,1408 -140826,绛县,1408 -140827,垣曲县,1408 -140828,夏县,1408 -140829,平陆县,1408 -140830,芮城县,1408 -140881,永济市,1408 -140882,河津市,1408 -1409,忻州市,14 -140902,忻府区,1409 -140921,定襄县,1409 -140922,五台县,1409 -140923,代县,1409 -140924,繁峙县,1409 -140925,宁武县,1409 -140926,静乐县,1409 -140927,神池县,1409 -140928,五寨县,1409 -140929,岢岚县,1409 -140930,河曲县,1409 -140931,保德县,1409 -140932,偏关县,1409 -140981,原平市,1409 -1410,临汾市,14 -141002,尧都区,1410 -141021,曲沃县,1410 -141022,翼城县,1410 -141023,襄汾县,1410 -141024,洪洞县,1410 -141025,古县,1410 -141026,安泽县,1410 -141027,浮山县,1410 -141028,吉县,1410 -141029,乡宁县,1410 -141030,大宁县,1410 -141031,隰县,1410 -141032,永和县,1410 -141033,蒲县,1410 -141034,汾西县,1410 -141081,侯马市,1410 -141082,霍州市,1410 -1411,吕梁市,14 -141102,离石区,1411 -141121,文水县,1411 -141122,交城县,1411 -141123,兴县,1411 -141124,临县,1411 -141125,柳林县,1411 -141126,石楼县,1411 -141127,岚县,1411 -141128,方山县,1411 -141129,中阳县,1411 -141130,交口县,1411 -141181,孝义市,1411 -141182,汾阳市,1411 -15,内蒙古自治区, -1501,呼和浩特市,15 -150102,新城区,1501 -150103,回民区,1501 -150104,玉泉区,1501 -150105,赛罕区,1501 -150121,土默特左旗,1501 -150122,托克托县,1501 -150123,和林格尔县,1501 -150124,清水河县,1501 -150125,武川县,1501 -1502,包头市,15 -150202,东河区,1502 -150203,昆都仑区,1502 -150204,青山区,1502 -150205,石拐区,1502 -150206,白云鄂博矿区,1502 -150207,九原区,1502 -150221,土默特右旗,1502 -150222,固阳县,1502 -150223,达尔罕茂明安联合旗,1502 -1503,乌海市,15 -150302,海勃湾区,1503 -150303,海南区,1503 -150304,乌达区,1503 -1504,赤峰市,15 -150402,红山区,1504 -150403,元宝山区,1504 -150404,松山区,1504 -150421,阿鲁科尔沁旗,1504 -150422,巴林左旗,1504 -150423,巴林右旗,1504 -150424,林西县,1504 -150425,克什克腾旗,1504 -150426,翁牛特旗,1504 -150428,喀喇沁旗,1504 -150429,宁城县,1504 -150430,敖汉旗,1504 -1505,通辽市,15 -150502,科尔沁区,1505 -150521,科尔沁左翼中旗,1505 -150522,科尔沁左翼后旗,1505 -150523,开鲁县,1505 -150524,库伦旗,1505 -150525,奈曼旗,1505 -150526,扎鲁特旗,1505 -150581,霍林郭勒市,1505 -1506,鄂尔多斯市,15 -150602,东胜区,1506 -150603,康巴什区,1506 -150621,达拉特旗,1506 -150622,准格尔旗,1506 -150623,鄂托克前旗,1506 -150624,鄂托克旗,1506 -150625,杭锦旗,1506 -150626,乌审旗,1506 -150627,伊金霍洛旗,1506 -1507,呼伦贝尔市,15 -150702,海拉尔区,1507 -150703,扎赉诺尔区,1507 -150721,阿荣旗,1507 -150722,莫力达瓦达斡尔族自治旗,1507 -150723,鄂伦春自治旗,1507 -150724,鄂温克族自治旗,1507 -150725,陈巴尔虎旗,1507 -150726,新巴尔虎左旗,1507 -150727,新巴尔虎右旗,1507 -150781,满洲里市,1507 -150782,牙克石市,1507 -150783,扎兰屯市,1507 -150784,额尔古纳市,1507 -150785,根河市,1507 -1508,巴彦淖尔市,15 -150802,临河区,1508 -150821,五原县,1508 -150822,磴口县,1508 -150823,乌拉特前旗,1508 -150824,乌拉特中旗,1508 -150825,乌拉特后旗,1508 -150826,杭锦后旗,1508 -1509,乌兰察布市,15 -150902,集宁区,1509 -150921,卓资县,1509 -150922,化德县,1509 -150923,商都县,1509 -150924,兴和县,1509 -150925,凉城县,1509 -150926,察哈尔右翼前旗,1509 -150927,察哈尔右翼中旗,1509 -150928,察哈尔右翼后旗,1509 -150929,四子王旗,1509 -150981,丰镇市,1509 -1522,兴安盟,15 -152201,乌兰浩特市,1522 -152202,阿尔山市,1522 -152221,科尔沁右翼前旗,1522 -152222,科尔沁右翼中旗,1522 -152223,扎赉特旗,1522 -152224,突泉县,1522 -1525,锡林郭勒盟,15 -152501,二连浩特市,1525 -152502,锡林浩特市,1525 -152522,阿巴嘎旗,1525 -152523,苏尼特左旗,1525 -152524,苏尼特右旗,1525 -152525,东乌珠穆沁旗,1525 -152526,西乌珠穆沁旗,1525 -152527,太仆寺旗,1525 -152528,镶黄旗,1525 -152529,正镶白旗,1525 -152530,正蓝旗,1525 -152531,多伦县,1525 -1529,阿拉善盟,15 -152921,阿拉善左旗,1529 -152922,阿拉善右旗,1529 -152923,额济纳旗,1529 -21,辽宁省, -2101,沈阳市,21 -210102,和平区,2101 -210103,沈河区,2101 -210104,大东区,2101 -210105,皇姑区,2101 -210106,铁西区,2101 -210111,苏家屯区,2101 -210112,浑南区,2101 -210113,沈北新区,2101 -210114,于洪区,2101 -210115,辽中区,2101 -210123,康平县,2101 -210124,法库县,2101 -210181,新民市,2101 -2102,大连市,21 -210202,中山区,2102 -210203,西岗区,2102 -210204,沙河口区,2102 -210211,甘井子区,2102 -210212,旅顺口区,2102 -210213,金州区,2102 -210214,普兰店区,2102 -210224,长海县,2102 -210281,瓦房店市,2102 -210283,庄河市,2102 -2103,鞍山市,21 -210302,铁东区,2103 -210303,铁西区,2103 -210304,立山区,2103 -210311,千山区,2103 -210321,台安县,2103 -210323,岫岩满族自治县,2103 -210381,海城市,2103 -2104,抚顺市,21 -210402,新抚区,2104 -210403,东洲区,2104 -210404,望花区,2104 -210411,顺城区,2104 -210421,抚顺县,2104 -210422,新宾满族自治县,2104 -210423,清原满族自治县,2104 -2105,本溪市,21 -210502,平山区,2105 -210503,溪湖区,2105 -210504,明山区,2105 -210505,南芬区,2105 -210521,本溪满族自治县,2105 -210522,桓仁满族自治县,2105 -2106,丹东市,21 -210602,元宝区,2106 -210603,振兴区,2106 -210604,振安区,2106 -210624,宽甸满族自治县,2106 -210681,东港市,2106 -210682,凤城市,2106 -2107,锦州市,21 -210702,古塔区,2107 -210703,凌河区,2107 -210711,太和区,2107 -210726,黑山县,2107 -210727,义县,2107 -210781,凌海市,2107 -210782,北镇市,2107 -2108,营口市,21 -210802,站前区,2108 -210803,西市区,2108 -210804,鲅鱼圈区,2108 -210811,老边区,2108 -210881,盖州市,2108 -210882,大石桥市,2108 -2109,阜新市,21 -210902,海州区,2109 -210903,新邱区,2109 -210904,太平区,2109 -210905,清河门区,2109 -210911,细河区,2109 -210921,阜新蒙古族自治县,2109 -210922,彰武县,2109 -2110,辽阳市,21 -211002,白塔区,2110 -211003,文圣区,2110 -211004,宏伟区,2110 -211005,弓长岭区,2110 -211011,太子河区,2110 -211021,辽阳县,2110 -211081,灯塔市,2110 -2111,盘锦市,21 -211102,双台子区,2111 -211103,兴隆台区,2111 -211104,大洼区,2111 -211122,盘山县,2111 -2112,铁岭市,21 -211202,银州区,2112 -211204,清河区,2112 -211221,铁岭县,2112 -211223,西丰县,2112 -211224,昌图县,2112 -211281,调兵山市,2112 -211282,开原市,2112 -2113,朝阳市,21 -211302,双塔区,2113 -211303,龙城区,2113 -211321,朝阳县,2113 -211322,建平县,2113 -211324,喀喇沁左翼蒙古族自治县,2113 -211381,北票市,2113 -211382,凌源市,2113 -2114,葫芦岛市,21 -211402,连山区,2114 -211403,龙港区,2114 -211404,南票区,2114 -211421,绥中县,2114 -211422,建昌县,2114 -211481,兴城市,2114 -22,吉林省, -2201,长春市,22 -220102,南关区,2201 -220103,宽城区,2201 -220104,朝阳区,2201 -220105,二道区,2201 -220106,绿园区,2201 -220112,双阳区,2201 -220113,九台区,2201 -220122,农安县,2201 -220182,榆树市,2201 -220183,德惠市,2201 -2202,吉林市,22 -220202,昌邑区,2202 -220203,龙潭区,2202 -220204,船营区,2202 -220211,丰满区,2202 -220221,永吉县,2202 -220281,蛟河市,2202 -220282,桦甸市,2202 -220283,舒兰市,2202 -220284,磐石市,2202 -2203,四平市,22 -220302,铁西区,2203 -220303,铁东区,2203 -220322,梨树县,2203 -220323,伊通满族自治县,2203 -220381,公主岭市,2203 -220382,双辽市,2203 -2204,辽源市,22 -220402,龙山区,2204 -220403,西安区,2204 -220421,东丰县,2204 -220422,东辽县,2204 -2205,通化市,22 -220502,东昌区,2205 -220503,二道江区,2205 -220521,通化县,2205 -220523,辉南县,2205 -220524,柳河县,2205 -220581,梅河口市,2205 -220582,集安市,2205 -2206,白山市,22 -220602,浑江区,2206 -220605,江源区,2206 -220621,抚松县,2206 -220622,靖宇县,2206 -220623,长白朝鲜族自治县,2206 -220681,临江市,2206 -2207,松原市,22 -220702,宁江区,2207 -220721,前郭尔罗斯蒙古族自治县,2207 -220722,长岭县,2207 -220723,乾安县,2207 -220781,扶余市,2207 -2208,白城市,22 -220802,洮北区,2208 -220821,镇赉县,2208 -220822,通榆县,2208 -220881,洮南市,2208 -220882,大安市,2208 -2224,延边朝鲜族自治州,22 -222401,延吉市,2224 -222402,图们市,2224 -222403,敦化市,2224 -222404,珲春市,2224 -222405,龙井市,2224 -222406,和龙市,2224 -222424,汪清县,2224 -222426,安图县,2224 -23,黑龙江省, -2301,哈尔滨市,23 -230102,道里区,2301 -230103,南岗区,2301 -230104,道外区,2301 -230108,平房区,2301 -230109,松北区,2301 -230110,香坊区,2301 -230111,呼兰区,2301 -230112,阿城区,2301 -230113,双城区,2301 -230123,依兰县,2301 -230124,方正县,2301 -230125,宾县,2301 -230126,巴彦县,2301 -230127,木兰县,2301 -230128,通河县,2301 -230129,延寿县,2301 -230183,尚志市,2301 -230184,五常市,2301 -2302,齐齐哈尔市,23 -230202,龙沙区,2302 -230203,建华区,2302 -230204,铁锋区,2302 -230205,昂昂溪区,2302 -230206,富拉尔基区,2302 -230207,碾子山区,2302 -230208,梅里斯达斡尔族区,2302 -230221,龙江县,2302 -230223,依安县,2302 -230224,泰来县,2302 -230225,甘南县,2302 -230227,富裕县,2302 -230229,克山县,2302 -230230,克东县,2302 -230231,拜泉县,2302 -230281,讷河市,2302 -2303,鸡西市,23 -230302,鸡冠区,2303 -230303,恒山区,2303 -230304,滴道区,2303 -230305,梨树区,2303 -230306,城子河区,2303 -230307,麻山区,2303 -230321,鸡东县,2303 -230381,虎林市,2303 -230382,密山市,2303 -2304,鹤岗市,23 -230402,向阳区,2304 -230403,工农区,2304 -230404,南山区,2304 -230405,兴安区,2304 -230406,东山区,2304 -230407,兴山区,2304 -230421,萝北县,2304 -230422,绥滨县,2304 -2305,双鸭山市,23 -230502,尖山区,2305 -230503,岭东区,2305 -230505,四方台区,2305 -230506,宝山区,2305 -230521,集贤县,2305 -230522,友谊县,2305 -230523,宝清县,2305 -230524,饶河县,2305 -2306,大庆市,23 -230602,萨尔图区,2306 -230603,龙凤区,2306 -230604,让胡路区,2306 -230605,红岗区,2306 -230606,大同区,2306 -230621,肇州县,2306 -230622,肇源县,2306 -230623,林甸县,2306 -230624,杜尔伯特蒙古族自治县,2306 -2307,伊春市,23 -230702,伊春区,2307 -230703,南岔区,2307 -230704,友好区,2307 -230705,西林区,2307 -230706,翠峦区,2307 -230707,新青区,2307 -230708,美溪区,2307 -230709,金山屯区,2307 -230710,五营区,2307 -230711,乌马河区,2307 -230712,汤旺河区,2307 -230713,带岭区,2307 -230714,乌伊岭区,2307 -230715,红星区,2307 -230716,上甘岭区,2307 -230722,嘉荫县,2307 -230781,铁力市,2307 -2308,佳木斯市,23 -230803,向阳区,2308 -230804,前进区,2308 -230805,东风区,2308 -230811,郊区,2308 -230822,桦南县,2308 -230826,桦川县,2308 -230828,汤原县,2308 -230881,同江市,2308 -230882,富锦市,2308 -230883,抚远市,2308 -2309,七台河市,23 -230902,新兴区,2309 -230903,桃山区,2309 -230904,茄子河区,2309 -230921,勃利县,2309 -2310,牡丹江市,23 -231002,东安区,2310 -231003,阳明区,2310 -231004,爱民区,2310 -231005,西安区,2310 -231025,林口县,2310 -231081,绥芬河市,2310 -231083,海林市,2310 -231084,宁安市,2310 -231085,穆棱市,2310 -231086,东宁市,2310 -2311,黑河市,23 -231102,爱辉区,2311 -231121,嫩江县,2311 -231123,逊克县,2311 -231124,孙吴县,2311 -231181,北安市,2311 -231182,五大连池市,2311 -2312,绥化市,23 -231202,北林区,2312 -231221,望奎县,2312 -231222,兰西县,2312 -231223,青冈县,2312 -231224,庆安县,2312 -231225,明水县,2312 -231226,绥棱县,2312 -231281,安达市,2312 -231282,肇东市,2312 -231283,海伦市,2312 -2327,大兴安岭地区,23 -232701,漠河市,2327 -232721,呼玛县,2327 -232722,塔河县,2327 -31,上海市, -310101,黄浦区,31 -310104,徐汇区,31 -310105,长宁区,31 -310106,静安区,31 -310107,普陀区,31 -310109,虹口区,31 -310110,杨浦区,31 -310112,闵行区,31 -310113,宝山区,31 -310114,嘉定区,31 -310115,浦东新区,31 -310116,金山区,31 -310117,松江区,31 -310118,青浦区,31 -310120,奉贤区,31 -310151,崇明区,31 -32,江苏省, -3201,南京市,32 -320102,玄武区,3201 -320104,秦淮区,3201 -320105,建邺区,3201 -320106,鼓楼区,3201 -320111,浦口区,3201 -320113,栖霞区,3201 -320114,雨花台区,3201 -320115,江宁区,3201 -320116,六合区,3201 -320117,溧水区,3201 -320118,高淳区,3201 -3202,无锡市,32 -320205,锡山区,3202 -320206,惠山区,3202 -320211,滨湖区,3202 -320213,梁溪区,3202 -320214,新吴区,3202 -320281,江阴市,3202 -320282,宜兴市,3202 -3203,徐州市,32 -320302,鼓楼区,3203 -320303,云龙区,3203 -320305,贾汪区,3203 -320311,泉山区,3203 -320312,铜山区,3203 -320321,丰县,3203 -320322,沛县,3203 -320324,睢宁县,3203 -320381,新沂市,3203 -320382,邳州市,3203 -3204,常州市,32 -320402,天宁区,3204 -320404,钟楼区,3204 -320411,新北区,3204 -320412,武进区,3204 -320413,金坛区,3204 -320481,溧阳市,3204 -3205,苏州市,32 -320505,虎丘区,3205 -320506,吴中区,3205 -320507,相城区,3205 -320508,姑苏区,3205 -320509,吴江区,3205 -320581,常熟市,3205 -320582,张家港市,3205 -320583,昆山市,3205 -320585,太仓市,3205 -3206,南通市,32 -320602,崇川区,3206 -320611,港闸区,3206 -320612,通州区,3206 -320623,如东县,3206 -320681,启东市,3206 -320682,如皋市,3206 -320684,海门市,3206 -320685,海安市,3206 -3207,连云港市,32 -320703,连云区,3207 -320706,海州区,3207 -320707,赣榆区,3207 -320722,东海县,3207 -320723,灌云县,3207 -320724,灌南县,3207 -3208,淮安市,32 -320803,淮安区,3208 -320804,淮阴区,3208 -320812,清江浦区,3208 -320813,洪泽区,3208 -320826,涟水县,3208 -320830,盱眙县,3208 -320831,金湖县,3208 -3209,盐城市,32 -320902,亭湖区,3209 -320903,盐都区,3209 -320904,大丰区,3209 -320921,响水县,3209 -320922,滨海县,3209 -320923,阜宁县,3209 -320924,射阳县,3209 -320925,建湖县,3209 -320981,东台市,3209 -3210,扬州市,32 -321002,广陵区,3210 -321003,邗江区,3210 -321012,江都区,3210 -321023,宝应县,3210 -321081,仪征市,3210 -321084,高邮市,3210 -3211,镇江市,32 -321102,京口区,3211 -321111,润州区,3211 -321112,丹徒区,3211 -321181,丹阳市,3211 -321182,扬中市,3211 -321183,句容市,3211 -3212,泰州市,32 -321202,海陵区,3212 -321203,高港区,3212 -321204,姜堰区,3212 -321281,兴化市,3212 -321282,靖江市,3212 -321283,泰兴市,3212 -3213,宿迁市,32 -321302,宿城区,3213 -321311,宿豫区,3213 -321322,沭阳县,3213 -321323,泗阳县,3213 -321324,泗洪县,3213 -33,浙江省, -3301,杭州市,33 -330102,上城区,3301 -330103,下城区,3301 -330104,江干区,3301 -330105,拱墅区,3301 -330106,西湖区,3301 -330108,滨江区,3301 -330109,萧山区,3301 -330110,余杭区,3301 -330111,富阳区,3301 -330112,临安区,3301 -330122,桐庐县,3301 -330127,淳安县,3301 -330182,建德市,3301 -3302,宁波市,33 -330203,海曙区,3302 -330205,江北区,3302 -330206,北仑区,3302 -330211,镇海区,3302 -330212,鄞州区,3302 -330213,奉化区,3302 -330225,象山县,3302 -330226,宁海县,3302 -330281,余姚市,3302 -330282,慈溪市,3302 -3303,温州市,33 -330302,鹿城区,3303 -330303,龙湾区,3303 -330304,瓯海区,3303 -330305,洞头区,3303 -330324,永嘉县,3303 -330326,平阳县,3303 -330327,苍南县,3303 -330328,文成县,3303 -330329,泰顺县,3303 -330381,瑞安市,3303 -330382,乐清市,3303 -3304,嘉兴市,33 -330402,南湖区,3304 -330411,秀洲区,3304 -330421,嘉善县,3304 -330424,海盐县,3304 -330481,海宁市,3304 -330482,平湖市,3304 -330483,桐乡市,3304 -3305,湖州市,33 -330502,吴兴区,3305 -330503,南浔区,3305 -330521,德清县,3305 -330522,长兴县,3305 -330523,安吉县,3305 -3306,绍兴市,33 -330602,越城区,3306 -330603,柯桥区,3306 -330604,上虞区,3306 -330624,新昌县,3306 -330681,诸暨市,3306 -330683,嵊州市,3306 -3307,金华市,33 -330702,婺城区,3307 -330703,金东区,3307 -330723,武义县,3307 -330726,浦江县,3307 -330727,磐安县,3307 -330781,兰溪市,3307 -330782,义乌市,3307 -330783,东阳市,3307 -330784,永康市,3307 -3308,衢州市,33 -330802,柯城区,3308 -330803,衢江区,3308 -330822,常山县,3308 -330824,开化县,3308 -330825,龙游县,3308 -330881,江山市,3308 -3309,舟山市,33 -330902,定海区,3309 -330903,普陀区,3309 -330921,岱山县,3309 -330922,嵊泗县,3309 -3310,台州市,33 -331002,椒江区,3310 -331003,黄岩区,3310 -331004,路桥区,3310 -331022,三门县,3310 -331023,天台县,3310 -331024,仙居县,3310 -331081,温岭市,3310 -331082,临海市,3310 -331083,玉环市,3310 -3311,丽水市,33 -331102,莲都区,3311 -331121,青田县,3311 -331122,缙云县,3311 -331123,遂昌县,3311 -331124,松阳县,3311 -331125,云和县,3311 -331126,庆元县,3311 -331127,景宁畲族自治县,3311 -331181,龙泉市,3311 -34,安徽省, -3401,合肥市,34 -340102,瑶海区,3401 -340103,庐阳区,3401 -340104,蜀山区,3401 -340111,包河区,3401 -340121,长丰县,3401 -340122,肥东县,3401 -340123,肥西县,3401 -340124,庐江县,3401 -340181,巢湖市,3401 -3402,芜湖市,34 -340202,镜湖区,3402 -340203,弋江区,3402 -340207,鸠江区,3402 -340208,三山区,3402 -340221,芜湖县,3402 -340222,繁昌县,3402 -340223,南陵县,3402 -340225,无为县,3402 -3403,蚌埠市,34 -340302,龙子湖区,3403 -340303,蚌山区,3403 -340304,禹会区,3403 -340311,淮上区,3403 -340321,怀远县,3403 -340322,五河县,3403 -340323,固镇县,3403 -3404,淮南市,34 -340402,大通区,3404 -340403,田家庵区,3404 -340404,谢家集区,3404 -340405,八公山区,3404 -340406,潘集区,3404 -340421,凤台县,3404 -340422,寿县,3404 -3405,马鞍山市,34 -340503,花山区,3405 -340504,雨山区,3405 -340506,博望区,3405 -340521,当涂县,3405 -340522,含山县,3405 -340523,和县,3405 -3406,淮北市,34 -340602,杜集区,3406 -340603,相山区,3406 -340604,烈山区,3406 -340621,濉溪县,3406 -3407,铜陵市,34 -340705,铜官区,3407 -340706,义安区,3407 -340711,郊区,3407 -340722,枞阳县,3407 -3408,安庆市,34 -340802,迎江区,3408 -340803,大观区,3408 -340811,宜秀区,3408 -340822,怀宁县,3408 -340825,太湖县,3408 -340826,宿松县,3408 -340827,望江县,3408 -340828,岳西县,3408 -340881,桐城市,3408 -340882,潜山市,3408 -3410,黄山市,34 -341002,屯溪区,3410 -341003,黄山区,3410 -341004,徽州区,3410 -341021,歙县,3410 -341022,休宁县,3410 -341023,黟县,3410 -341024,祁门县,3410 -3411,滁州市,34 -341102,琅琊区,3411 -341103,南谯区,3411 -341122,来安县,3411 -341124,全椒县,3411 -341125,定远县,3411 -341126,凤阳县,3411 -341181,天长市,3411 -341182,明光市,3411 -3412,阜阳市,34 -341202,颍州区,3412 -341203,颍东区,3412 -341204,颍泉区,3412 -341221,临泉县,3412 -341222,太和县,3412 -341225,阜南县,3412 -341226,颍上县,3412 -341282,界首市,3412 -3413,宿州市,34 -341302,埇桥区,3413 -341321,砀山县,3413 -341322,萧县,3413 -341323,灵璧县,3413 -341324,泗县,3413 -3415,六安市,34 -341502,金安区,3415 -341503,裕安区,3415 -341504,叶集区,3415 -341522,霍邱县,3415 -341523,舒城县,3415 -341524,金寨县,3415 -341525,霍山县,3415 -3416,亳州市,34 -341602,谯城区,3416 -341621,涡阳县,3416 -341622,蒙城县,3416 -341623,利辛县,3416 -3417,池州市,34 -341702,贵池区,3417 -341721,东至县,3417 -341722,石台县,3417 -341723,青阳县,3417 -3418,宣城市,34 -341802,宣州区,3418 -341821,郎溪县,3418 -341822,广德县,3418 -341823,泾县,3418 -341824,绩溪县,3418 -341825,旌德县,3418 -341881,宁国市,3418 -35,福建省, -3501,福州市,35 -350102,鼓楼区,3501 -350103,台江区,3501 -350104,仓山区,3501 -350105,马尾区,3501 -350111,晋安区,3501 -350112,长乐区,3501 -350121,闽侯县,3501 -350122,连江县,3501 -350123,罗源县,3501 -350124,闽清县,3501 -350125,永泰县,3501 -350128,平潭县,3501 -350181,福清市,3501 -3502,厦门市,35 -350203,思明区,3502 -350205,海沧区,3502 -350206,湖里区,3502 -350211,集美区,3502 -350212,同安区,3502 -350213,翔安区,3502 -3503,莆田市,35 -350302,城厢区,3503 -350303,涵江区,3503 -350304,荔城区,3503 -350305,秀屿区,3503 -350322,仙游县,3503 -3504,三明市,35 -350402,梅列区,3504 -350403,三元区,3504 -350421,明溪县,3504 -350423,清流县,3504 -350424,宁化县,3504 -350425,大田县,3504 -350426,尤溪县,3504 -350427,沙县,3504 -350428,将乐县,3504 -350429,泰宁县,3504 -350430,建宁县,3504 -350481,永安市,3504 -3505,泉州市,35 -350502,鲤城区,3505 -350503,丰泽区,3505 -350504,洛江区,3505 -350505,泉港区,3505 -350521,惠安县,3505 -350524,安溪县,3505 -350525,永春县,3505 -350526,德化县,3505 -350527,金门县,3505 -350581,石狮市,3505 -350582,晋江市,3505 -350583,南安市,3505 -3506,漳州市,35 -350602,芗城区,3506 -350603,龙文区,3506 -350622,云霄县,3506 -350623,漳浦县,3506 -350624,诏安县,3506 -350625,长泰县,3506 -350626,东山县,3506 -350627,南靖县,3506 -350628,平和县,3506 -350629,华安县,3506 -350681,龙海市,3506 -3507,南平市,35 -350702,延平区,3507 -350703,建阳区,3507 -350721,顺昌县,3507 -350722,浦城县,3507 -350723,光泽县,3507 -350724,松溪县,3507 -350725,政和县,3507 -350781,邵武市,3507 -350782,武夷山市,3507 -350783,建瓯市,3507 -3508,龙岩市,35 -350802,新罗区,3508 -350803,永定区,3508 -350821,长汀县,3508 -350823,上杭县,3508 -350824,武平县,3508 -350825,连城县,3508 -350881,漳平市,3508 -3509,宁德市,35 -350902,蕉城区,3509 -350921,霞浦县,3509 -350922,古田县,3509 -350923,屏南县,3509 -350924,寿宁县,3509 -350925,周宁县,3509 -350926,柘荣县,3509 -350981,福安市,3509 -350982,福鼎市,3509 -36,江西省, -3601,南昌市,36 -360102,东湖区,3601 -360103,西湖区,3601 -360104,青云谱区,3601 -360105,湾里区,3601 -360111,青山湖区,3601 -360112,新建区,3601 -360121,南昌县,3601 -360123,安义县,3601 -360124,进贤县,3601 -3602,景德镇市,36 -360202,昌江区,3602 -360203,珠山区,3602 -360222,浮梁县,3602 -360281,乐平市,3602 -3603,萍乡市,36 -360302,安源区,3603 -360313,湘东区,3603 -360321,莲花县,3603 -360322,上栗县,3603 -360323,芦溪县,3603 -3604,九江市,36 -360402,濂溪区,3604 -360403,浔阳区,3604 -360404,柴桑区,3604 -360423,武宁县,3604 -360424,修水县,3604 -360425,永修县,3604 -360426,德安县,3604 -360428,都昌县,3604 -360429,湖口县,3604 -360430,彭泽县,3604 -360481,瑞昌市,3604 -360482,共青城市,3604 -360483,庐山市,3604 -3605,新余市,36 -360502,渝水区,3605 -360521,分宜县,3605 -3606,鹰潭市,36 -360602,月湖区,3606 -360603,余江区,3606 -360681,贵溪市,3606 -3607,赣州市,36 -360702,章贡区,3607 -360703,南康区,3607 -360704,赣县区,3607 -360722,信丰县,3607 -360723,大余县,3607 -360724,上犹县,3607 -360725,崇义县,3607 -360726,安远县,3607 -360727,龙南县,3607 -360728,定南县,3607 -360729,全南县,3607 -360730,宁都县,3607 -360731,于都县,3607 -360732,兴国县,3607 -360733,会昌县,3607 -360734,寻乌县,3607 -360735,石城县,3607 -360781,瑞金市,3607 -3608,吉安市,36 -360802,吉州区,3608 -360803,青原区,3608 -360821,吉安县,3608 -360822,吉水县,3608 -360823,峡江县,3608 -360824,新干县,3608 -360825,永丰县,3608 -360826,泰和县,3608 -360827,遂川县,3608 -360828,万安县,3608 -360829,安福县,3608 -360830,永新县,3608 -360881,井冈山市,3608 -3609,宜春市,36 -360902,袁州区,3609 -360921,奉新县,3609 -360922,万载县,3609 -360923,上高县,3609 -360924,宜丰县,3609 -360925,靖安县,3609 -360926,铜鼓县,3609 -360981,丰城市,3609 -360982,樟树市,3609 -360983,高安市,3609 -3610,抚州市,36 -361002,临川区,3610 -361003,东乡区,3610 -361021,南城县,3610 -361022,黎川县,3610 -361023,南丰县,3610 -361024,崇仁县,3610 -361025,乐安县,3610 -361026,宜黄县,3610 -361027,金溪县,3610 -361028,资溪县,3610 -361030,广昌县,3610 -3611,上饶市,36 -361102,信州区,3611 -361103,广丰区,3611 -361121,上饶县,3611 -361123,玉山县,3611 -361124,铅山县,3611 -361125,横峰县,3611 -361126,弋阳县,3611 -361127,余干县,3611 -361128,鄱阳县,3611 -361129,万年县,3611 -361130,婺源县,3611 -361181,德兴市,3611 -37,山东省, -3701,济南市,37 -370102,历下区,3701 -370103,市中区,3701 -370104,槐荫区,3701 -370105,天桥区,3701 -370112,历城区,3701 -370113,长清区,3701 -370114,章丘区,3701 -370115,济阳区,3701 -370124,平阴县,3701 -370126,商河县,3701 -3702,青岛市,37 -370202,市南区,3702 -370203,市北区,3702 -370211,黄岛区,3702 -370212,崂山区,3702 -370213,李沧区,3702 -370214,城阳区,3702 -370215,即墨区,3702 -370281,胶州市,3702 -370283,平度市,3702 -370285,莱西市,3702 -3703,淄博市,37 -370302,淄川区,3703 -370303,张店区,3703 -370304,博山区,3703 -370305,临淄区,3703 -370306,周村区,3703 -370321,桓台县,3703 -370322,高青县,3703 -370323,沂源县,3703 -3704,枣庄市,37 -370402,市中区,3704 -370403,薛城区,3704 -370404,峄城区,3704 -370405,台儿庄区,3704 -370406,山亭区,3704 -370481,滕州市,3704 -3705,东营市,37 -370502,东营区,3705 -370503,河口区,3705 -370505,垦利区,3705 -370522,利津县,3705 -370523,广饶县,3705 -3706,烟台市,37 -370602,芝罘区,3706 -370611,福山区,3706 -370612,牟平区,3706 -370613,莱山区,3706 -370634,长岛县,3706 -370681,龙口市,3706 -370682,莱阳市,3706 -370683,莱州市,3706 -370684,蓬莱市,3706 -370685,招远市,3706 -370686,栖霞市,3706 -370687,海阳市,3706 -3707,潍坊市,37 -370702,潍城区,3707 -370703,寒亭区,3707 -370704,坊子区,3707 -370705,奎文区,3707 -370724,临朐县,3707 -370725,昌乐县,3707 -370781,青州市,3707 -370782,诸城市,3707 -370783,寿光市,3707 -370784,安丘市,3707 -370785,高密市,3707 -370786,昌邑市,3707 -3708,济宁市,37 -370811,任城区,3708 -370812,兖州区,3708 -370826,微山县,3708 -370827,鱼台县,3708 -370828,金乡县,3708 -370829,嘉祥县,3708 -370830,汶上县,3708 -370831,泗水县,3708 -370832,梁山县,3708 -370881,曲阜市,3708 -370883,邹城市,3708 -3709,泰安市,37 -370902,泰山区,3709 -370911,岱岳区,3709 -370921,宁阳县,3709 -370923,东平县,3709 -370982,新泰市,3709 -370983,肥城市,3709 -3710,威海市,37 -371002,环翠区,3710 -371003,文登区,3710 -371082,荣成市,3710 -371083,乳山市,3710 -3711,日照市,37 -371102,东港区,3711 -371103,岚山区,3711 -371121,五莲县,3711 -371122,莒县,3711 -3712,莱芜市,37 -371202,莱城区,3712 -371203,钢城区,3712 -3713,临沂市,37 -371302,兰山区,3713 -371311,罗庄区,3713 -371312,河东区,3713 -371321,沂南县,3713 -371322,郯城县,3713 -371323,沂水县,3713 -371324,兰陵县,3713 -371325,费县,3713 -371326,平邑县,3713 -371327,莒南县,3713 -371328,蒙阴县,3713 -371329,临沭县,3713 -3714,德州市,37 -371402,德城区,3714 -371403,陵城区,3714 -371422,宁津县,3714 -371423,庆云县,3714 -371424,临邑县,3714 -371425,齐河县,3714 -371426,平原县,3714 -371427,夏津县,3714 -371428,武城县,3714 -371481,乐陵市,3714 -371482,禹城市,3714 -3715,聊城市,37 -371502,东昌府区,3715 -371521,阳谷县,3715 -371522,莘县,3715 -371523,茌平县,3715 -371524,东阿县,3715 -371525,冠县,3715 -371526,高唐县,3715 -371581,临清市,3715 -3716,滨州市,37 -371602,滨城区,3716 -371603,沾化区,3716 -371621,惠民县,3716 -371622,阳信县,3716 -371623,无棣县,3716 -371625,博兴县,3716 -371681,邹平市,3716 -3717,菏泽市,37 -371702,牡丹区,3717 -371703,定陶区,3717 -371721,曹县,3717 -371722,单县,3717 -371723,成武县,3717 -371724,巨野县,3717 -371725,郓城县,3717 -371726,鄄城县,3717 -371728,东明县,3717 -41,河南省, -4101,郑州市,41 -410102,中原区,4101 -410103,二七区,4101 -410104,管城回族区,4101 -410105,金水区,4101 -410106,上街区,4101 -410108,惠济区,4101 -410122,中牟县,4101 -410181,巩义市,4101 -410182,荥阳市,4101 -410183,新密市,4101 -410184,新郑市,4101 -410185,登封市,4101 -4102,开封市,41 -410202,龙亭区,4102 -410203,顺河回族区,4102 -410204,鼓楼区,4102 -410205,禹王台区,4102 -410212,祥符区,4102 -410221,杞县,4102 -410222,通许县,4102 -410223,尉氏县,4102 -410225,兰考县,4102 -4103,洛阳市,41 -410302,老城区,4103 -410303,西工区,4103 -410304,瀍河回族区,4103 -410305,涧西区,4103 -410306,吉利区,4103 -410311,洛龙区,4103 -410322,孟津县,4103 -410323,新安县,4103 -410324,栾川县,4103 -410325,嵩县,4103 -410326,汝阳县,4103 -410327,宜阳县,4103 -410328,洛宁县,4103 -410329,伊川县,4103 -410381,偃师市,4103 -4104,平顶山市,41 -410402,新华区,4104 -410403,卫东区,4104 -410404,石龙区,4104 -410411,湛河区,4104 -410421,宝丰县,4104 -410422,叶县,4104 -410423,鲁山县,4104 -410425,郏县,4104 -410481,舞钢市,4104 -410482,汝州市,4104 -4105,安阳市,41 -410502,文峰区,4105 -410503,北关区,4105 -410505,殷都区,4105 -410506,龙安区,4105 -410522,安阳县,4105 -410523,汤阴县,4105 -410526,滑县,4105 -410527,内黄县,4105 -410581,林州市,4105 -4106,鹤壁市,41 -410602,鹤山区,4106 -410603,山城区,4106 -410611,淇滨区,4106 -410621,浚县,4106 -410622,淇县,4106 -4107,新乡市,41 -410702,红旗区,4107 -410703,卫滨区,4107 -410704,凤泉区,4107 -410711,牧野区,4107 -410721,新乡县,4107 -410724,获嘉县,4107 -410725,原阳县,4107 -410726,延津县,4107 -410727,封丘县,4107 -410728,长垣县,4107 -410781,卫辉市,4107 -410782,辉县市,4107 -4108,焦作市,41 -410802,解放区,4108 -410803,中站区,4108 -410804,马村区,4108 -410811,山阳区,4108 -410821,修武县,4108 -410822,博爱县,4108 -410823,武陟县,4108 -410825,温县,4108 -410882,沁阳市,4108 -410883,孟州市,4108 -4109,濮阳市,41 -410902,华龙区,4109 -410922,清丰县,4109 -410923,南乐县,4109 -410926,范县,4109 -410927,台前县,4109 -410928,濮阳县,4109 -4110,许昌市,41 -411002,魏都区,4110 -411003,建安区,4110 -411024,鄢陵县,4110 -411025,襄城县,4110 -411081,禹州市,4110 -411082,长葛市,4110 -4111,漯河市,41 -411102,源汇区,4111 -411103,郾城区,4111 -411104,召陵区,4111 -411121,舞阳县,4111 -411122,临颍县,4111 -4112,三门峡市,41 -411202,湖滨区,4112 -411203,陕州区,4112 -411221,渑池县,4112 -411224,卢氏县,4112 -411281,义马市,4112 -411282,灵宝市,4112 -4113,南阳市,41 -411302,宛城区,4113 -411303,卧龙区,4113 -411321,南召县,4113 -411322,方城县,4113 -411323,西峡县,4113 -411324,镇平县,4113 -411325,内乡县,4113 -411326,淅川县,4113 -411327,社旗县,4113 -411328,唐河县,4113 -411329,新野县,4113 -411330,桐柏县,4113 -411381,邓州市,4113 -4114,商丘市,41 -411402,梁园区,4114 -411403,睢阳区,4114 -411421,民权县,4114 -411422,睢县,4114 -411423,宁陵县,4114 -411424,柘城县,4114 -411425,虞城县,4114 -411426,夏邑县,4114 -411481,永城市,4114 -4115,信阳市,41 -411502,浉河区,4115 -411503,平桥区,4115 -411521,罗山县,4115 -411522,光山县,4115 -411523,新县,4115 -411524,商城县,4115 -411525,固始县,4115 -411526,潢川县,4115 -411527,淮滨县,4115 -411528,息县,4115 -4116,周口市,41 -411602,川汇区,4116 -411621,扶沟县,4116 -411622,西华县,4116 -411623,商水县,4116 -411624,沈丘县,4116 -411625,郸城县,4116 -411626,淮阳县,4116 -411627,太康县,4116 -411628,鹿邑县,4116 -411681,项城市,4116 -4117,驻马店市,41 -411702,驿城区,4117 -411721,西平县,4117 -411722,上蔡县,4117 -411723,平舆县,4117 -411724,正阳县,4117 -411725,确山县,4117 -411726,泌阳县,4117 -411727,汝南县,4117 -411728,遂平县,4117 -411729,新蔡县,4117 -419001,济源市,41 -42,湖北省, -4201,武汉市,42 -420102,江岸区,4201 -420103,江汉区,4201 -420104,硚口区,4201 -420105,汉阳区,4201 -420106,武昌区,4201 -420107,青山区,4201 -420111,洪山区,4201 -420112,东西湖区,4201 -420113,汉南区,4201 -420114,蔡甸区,4201 -420115,江夏区,4201 -420116,黄陂区,4201 -420117,新洲区,4201 -4202,黄石市,42 -420202,黄石港区,4202 -420203,西塞山区,4202 -420204,下陆区,4202 -420205,铁山区,4202 -420222,阳新县,4202 -420281,大冶市,4202 -4203,十堰市,42 -420302,茅箭区,4203 -420303,张湾区,4203 -420304,郧阳区,4203 -420322,郧西县,4203 -420323,竹山县,4203 -420324,竹溪县,4203 -420325,房县,4203 -420381,丹江口市,4203 -4205,宜昌市,42 -420502,西陵区,4205 -420503,伍家岗区,4205 -420504,点军区,4205 -420505,猇亭区,4205 -420506,夷陵区,4205 -420525,远安县,4205 -420526,兴山县,4205 -420527,秭归县,4205 -420528,长阳土家族自治县,4205 -420529,五峰土家族自治县,4205 -420581,宜都市,4205 -420582,当阳市,4205 -420583,枝江市,4205 -4206,襄阳市,42 -420602,襄城区,4206 -420606,樊城区,4206 -420607,襄州区,4206 -420624,南漳县,4206 -420625,谷城县,4206 -420626,保康县,4206 -420682,老河口市,4206 -420683,枣阳市,4206 -420684,宜城市,4206 -4207,鄂州市,42 -420702,梁子湖区,4207 -420703,华容区,4207 -420704,鄂城区,4207 -4208,荆门市,42 -420802,东宝区,4208 -420804,掇刀区,4208 -420822,沙洋县,4208 -420881,钟祥市,4208 -420882,京山市,4208 -4209,孝感市,42 -420902,孝南区,4209 -420921,孝昌县,4209 -420922,大悟县,4209 -420923,云梦县,4209 -420981,应城市,4209 -420982,安陆市,4209 -420984,汉川市,4209 -4210,荆州市,42 -421002,沙市区,4210 -421003,荆州区,4210 -421022,公安县,4210 -421023,监利县,4210 -421024,江陵县,4210 -421081,石首市,4210 -421083,洪湖市,4210 -421087,松滋市,4210 -4211,黄冈市,42 -421102,黄州区,4211 -421121,团风县,4211 -421122,红安县,4211 -421123,罗田县,4211 -421124,英山县,4211 -421125,浠水县,4211 -421126,蕲春县,4211 -421127,黄梅县,4211 -421181,麻城市,4211 -421182,武穴市,4211 -4212,咸宁市,42 -421202,咸安区,4212 -421221,嘉鱼县,4212 -421222,通城县,4212 -421223,崇阳县,4212 -421224,通山县,4212 -421281,赤壁市,4212 -4213,随州市,42 -421303,曾都区,4213 -421321,随县,4213 -421381,广水市,4213 -4228,恩施土家族苗族自治州,42 -422801,恩施市,4228 -422802,利川市,4228 -422822,建始县,4228 -422823,巴东县,4228 -422825,宣恩县,4228 -422826,咸丰县,4228 -422827,来凤县,4228 -422828,鹤峰县,4228 -429004,仙桃市,42 -429005,潜江市,42 -429006,天门市,42 -429021,神农架林区,42 -43,湖南省, -4301,长沙市,43 -430102,芙蓉区,4301 -430103,天心区,4301 -430104,岳麓区,4301 -430105,开福区,4301 -430111,雨花区,4301 -430112,望城区,4301 -430121,长沙县,4301 -430181,浏阳市,4301 -430182,宁乡市,4301 -4302,株洲市,43 -430202,荷塘区,4302 -430203,芦淞区,4302 -430204,石峰区,4302 -430211,天元区,4302 -430212,渌口区,4302 -430223,攸县,4302 -430224,茶陵县,4302 -430225,炎陵县,4302 -430281,醴陵市,4302 -4303,湘潭市,43 -430302,雨湖区,4303 -430304,岳塘区,4303 -430321,湘潭县,4303 -430381,湘乡市,4303 -430382,韶山市,4303 -4304,衡阳市,43 -430405,珠晖区,4304 -430406,雁峰区,4304 -430407,石鼓区,4304 -430408,蒸湘区,4304 -430412,南岳区,4304 -430421,衡阳县,4304 -430422,衡南县,4304 -430423,衡山县,4304 -430424,衡东县,4304 -430426,祁东县,4304 -430481,耒阳市,4304 -430482,常宁市,4304 -4305,邵阳市,43 -430502,双清区,4305 -430503,大祥区,4305 -430511,北塔区,4305 -430521,邵东县,4305 -430522,新邵县,4305 -430523,邵阳县,4305 -430524,隆回县,4305 -430525,洞口县,4305 -430527,绥宁县,4305 -430528,新宁县,4305 -430529,城步苗族自治县,4305 -430581,武冈市,4305 -4306,岳阳市,43 -430602,岳阳楼区,4306 -430603,云溪区,4306 -430611,君山区,4306 -430621,岳阳县,4306 -430623,华容县,4306 -430624,湘阴县,4306 -430626,平江县,4306 -430681,汨罗市,4306 -430682,临湘市,4306 -4307,常德市,43 -430702,武陵区,4307 -430703,鼎城区,4307 -430721,安乡县,4307 -430722,汉寿县,4307 -430723,澧县,4307 -430724,临澧县,4307 -430725,桃源县,4307 -430726,石门县,4307 -430781,津市市,4307 -4308,张家界市,43 -430802,永定区,4308 -430811,武陵源区,4308 -430821,慈利县,4308 -430822,桑植县,4308 -4309,益阳市,43 -430902,资阳区,4309 -430903,赫山区,4309 -430921,南县,4309 -430922,桃江县,4309 -430923,安化县,4309 -430981,沅江市,4309 -4310,郴州市,43 -431002,北湖区,4310 -431003,苏仙区,4310 -431021,桂阳县,4310 -431022,宜章县,4310 -431023,永兴县,4310 -431024,嘉禾县,4310 -431025,临武县,4310 -431026,汝城县,4310 -431027,桂东县,4310 -431028,安仁县,4310 -431081,资兴市,4310 -4311,永州市,43 -431102,零陵区,4311 -431103,冷水滩区,4311 -431121,祁阳县,4311 -431122,东安县,4311 -431123,双牌县,4311 -431124,道县,4311 -431125,江永县,4311 -431126,宁远县,4311 -431127,蓝山县,4311 -431128,新田县,4311 -431129,江华瑶族自治县,4311 -4312,怀化市,43 -431202,鹤城区,4312 -431221,中方县,4312 -431222,沅陵县,4312 -431223,辰溪县,4312 -431224,溆浦县,4312 -431225,会同县,4312 -431226,麻阳苗族自治县,4312 -431227,新晃侗族自治县,4312 -431228,芷江侗族自治县,4312 -431229,靖州苗族侗族自治县,4312 -431230,通道侗族自治县,4312 -431281,洪江市,4312 -4313,娄底市,43 -431302,娄星区,4313 -431321,双峰县,4313 -431322,新化县,4313 -431381,冷水江市,4313 -431382,涟源市,4313 -4331,湘西土家族苗族自治州,43 -433101,吉首市,4331 -433122,泸溪县,4331 -433123,凤凰县,4331 -433124,花垣县,4331 -433125,保靖县,4331 -433126,古丈县,4331 -433127,永顺县,4331 -433130,龙山县,4331 -44,广东省, -4401,广州市,44 -440103,荔湾区,4401 -440104,越秀区,4401 -440105,海珠区,4401 -440106,天河区,4401 -440111,白云区,4401 -440112,黄埔区,4401 -440113,番禺区,4401 -440114,花都区,4401 -440115,南沙区,4401 -440117,从化区,4401 -440118,增城区,4401 -4402,韶关市,44 -440203,武江区,4402 -440204,浈江区,4402 -440205,曲江区,4402 -440222,始兴县,4402 -440224,仁化县,4402 -440229,翁源县,4402 -440232,乳源瑶族自治县,4402 -440233,新丰县,4402 -440281,乐昌市,4402 -440282,南雄市,4402 -4403,深圳市,44 -440303,罗湖区,4403 -440304,福田区,4403 -440305,南山区,4403 -440306,宝安区,4403 -440307,龙岗区,4403 -440308,盐田区,4403 -440309,龙华区,4403 -440310,坪山区,4403 -440311,光明区,4403 -4404,珠海市,44 -440402,香洲区,4404 -440403,斗门区,4404 -440404,金湾区,4404 -4405,汕头市,44 -440507,龙湖区,4405 -440511,金平区,4405 -440512,濠江区,4405 -440513,潮阳区,4405 -440514,潮南区,4405 -440515,澄海区,4405 -440523,南澳县,4405 -4406,佛山市,44 -440604,禅城区,4406 -440605,南海区,4406 -440606,顺德区,4406 -440607,三水区,4406 -440608,高明区,4406 -4407,江门市,44 -440703,蓬江区,4407 -440704,江海区,4407 -440705,新会区,4407 -440781,台山市,4407 -440783,开平市,4407 -440784,鹤山市,4407 -440785,恩平市,4407 -4408,湛江市,44 -440802,赤坎区,4408 -440803,霞山区,4408 -440804,坡头区,4408 -440811,麻章区,4408 -440823,遂溪县,4408 -440825,徐闻县,4408 -440881,廉江市,4408 -440882,雷州市,4408 -440883,吴川市,4408 -4409,茂名市,44 -440902,茂南区,4409 -440904,电白区,4409 -440981,高州市,4409 -440982,化州市,4409 -440983,信宜市,4409 -4412,肇庆市,44 -441202,端州区,4412 -441203,鼎湖区,4412 -441204,高要区,4412 -441223,广宁县,4412 -441224,怀集县,4412 -441225,封开县,4412 -441226,德庆县,4412 -441284,四会市,4412 -4413,惠州市,44 -441302,惠城区,4413 -441303,惠阳区,4413 -441322,博罗县,4413 -441323,惠东县,4413 -441324,龙门县,4413 -4414,梅州市,44 -441402,梅江区,4414 -441403,梅县区,4414 -441422,大埔县,4414 -441423,丰顺县,4414 -441424,五华县,4414 -441426,平远县,4414 -441427,蕉岭县,4414 -441481,兴宁市,4414 -4415,汕尾市,44 -441502,城区,4415 -441521,海丰县,4415 -441523,陆河县,4415 -441581,陆丰市,4415 -4416,河源市,44 -441602,源城区,4416 -441621,紫金县,4416 -441622,龙川县,4416 -441623,连平县,4416 -441624,和平县,4416 -441625,东源县,4416 -4417,阳江市,44 -441702,江城区,4417 -441704,阳东区,4417 -441721,阳西县,4417 -441781,阳春市,4417 -4418,清远市,44 -441802,清城区,4418 -441803,清新区,4418 -441821,佛冈县,4418 -441823,阳山县,4418 -441825,连山壮族瑶族自治县,4418 -441826,连南瑶族自治县,4418 -441881,英德市,4418 -441882,连州市,4418 -4419,东莞市,44 -4420,中山市,44 -4451,潮州市,44 -445102,湘桥区,4451 -445103,潮安区,4451 -445122,饶平县,4451 -4452,揭阳市,44 -445202,榕城区,4452 -445203,揭东区,4452 -445222,揭西县,4452 -445224,惠来县,4452 -445281,普宁市,4452 -4453,云浮市,44 -445302,云城区,4453 -445303,云安区,4453 -445321,新兴县,4453 -445322,郁南县,4453 -445381,罗定市,4453 -45,广西壮族自治区, -4501,南宁市,45 -450102,兴宁区,4501 -450103,青秀区,4501 -450105,江南区,4501 -450107,西乡塘区,4501 -450108,良庆区,4501 -450109,邕宁区,4501 -450110,武鸣区,4501 -450123,隆安县,4501 -450124,马山县,4501 -450125,上林县,4501 -450126,宾阳县,4501 -450127,横县,4501 -4502,柳州市,45 -450202,城中区,4502 -450203,鱼峰区,4502 -450204,柳南区,4502 -450205,柳北区,4502 -450206,柳江区,4502 -450222,柳城县,4502 -450223,鹿寨县,4502 -450224,融安县,4502 -450225,融水苗族自治县,4502 -450226,三江侗族自治县,4502 -4503,桂林市,45 -450302,秀峰区,4503 -450303,叠彩区,4503 -450304,象山区,4503 -450305,七星区,4503 -450311,雁山区,4503 -450312,临桂区,4503 -450321,阳朔县,4503 -450323,灵川县,4503 -450324,全州县,4503 -450325,兴安县,4503 -450326,永福县,4503 -450327,灌阳县,4503 -450328,龙胜各族自治县,4503 -450329,资源县,4503 -450330,平乐县,4503 -450332,恭城瑶族自治县,4503 -450381,荔浦市,4503 -4504,梧州市,45 -450403,万秀区,4504 -450405,长洲区,4504 -450406,龙圩区,4504 -450421,苍梧县,4504 -450422,藤县,4504 -450423,蒙山县,4504 -450481,岑溪市,4504 -4505,北海市,45 -450502,海城区,4505 -450503,银海区,4505 -450512,铁山港区,4505 -450521,合浦县,4505 -4506,防城港市,45 -450602,港口区,4506 -450603,防城区,4506 -450621,上思县,4506 -450681,东兴市,4506 -4507,钦州市,45 -450702,钦南区,4507 -450703,钦北区,4507 -450721,灵山县,4507 -450722,浦北县,4507 -4508,贵港市,45 -450802,港北区,4508 -450803,港南区,4508 -450804,覃塘区,4508 -450821,平南县,4508 -450881,桂平市,4508 -4509,玉林市,45 -450902,玉州区,4509 -450903,福绵区,4509 -450921,容县,4509 -450922,陆川县,4509 -450923,博白县,4509 -450924,兴业县,4509 -450981,北流市,4509 -4510,百色市,45 -451002,右江区,4510 -451021,田阳县,4510 -451022,田东县,4510 -451023,平果县,4510 -451024,德保县,4510 -451026,那坡县,4510 -451027,凌云县,4510 -451028,乐业县,4510 -451029,田林县,4510 -451030,西林县,4510 -451031,隆林各族自治县,4510 -451081,靖西市,4510 -4511,贺州市,45 -451102,八步区,4511 -451103,平桂区,4511 -451121,昭平县,4511 -451122,钟山县,4511 -451123,富川瑶族自治县,4511 -4512,河池市,45 -451202,金城江区,4512 -451203,宜州区,4512 -451221,南丹县,4512 -451222,天峨县,4512 -451223,凤山县,4512 -451224,东兰县,4512 -451225,罗城仫佬族自治县,4512 -451226,环江毛南族自治县,4512 -451227,巴马瑶族自治县,4512 -451228,都安瑶族自治县,4512 -451229,大化瑶族自治县,4512 -4513,来宾市,45 -451302,兴宾区,4513 -451321,忻城县,4513 -451322,象州县,4513 -451323,武宣县,4513 -451324,金秀瑶族自治县,4513 -451381,合山市,4513 -4514,崇左市,45 -451402,江州区,4514 -451421,扶绥县,4514 -451422,宁明县,4514 -451423,龙州县,4514 -451424,大新县,4514 -451425,天等县,4514 -451481,凭祥市,4514 -46,海南省, -4601,海口市,46 -460105,秀英区,4601 -460106,龙华区,4601 -460107,琼山区,4601 -460108,美兰区,4601 -4602,三亚市,46 -460202,海棠区,4602 -460203,吉阳区,4602 -460204,天涯区,4602 -460205,崖州区,4602 -4603,三沙市,46 -4604,儋州市,46 -469001,五指山市,46 -469002,琼海市,46 -469005,文昌市,46 -469006,万宁市,46 -469007,东方市,46 -469021,定安县,46 -469022,屯昌县,46 -469023,澄迈县,46 -469024,临高县,46 -469025,白沙黎族自治县,46 -469026,昌江黎族自治县,46 -469027,乐东黎族自治县,46 -469028,陵水黎族自治县,46 -469029,保亭黎族苗族自治县,46 -469030,琼中黎族苗族自治县,46 -50,重庆市, -500101,万州区,50 -500102,涪陵区,50 -500103,渝中区,50 -500104,大渡口区,50 -500105,江北区,50 -500106,沙坪坝区,50 -500107,九龙坡区,50 -500108,南岸区,50 -500109,北碚区,50 -500110,綦江区,50 -500111,大足区,50 -500112,渝北区,50 -500113,巴南区,50 -500114,黔江区,50 -500115,长寿区,50 -500116,江津区,50 -500117,合川区,50 -500118,永川区,50 -500119,南川区,50 -500120,璧山区,50 -500151,铜梁区,50 -500152,潼南区,50 -500153,荣昌区,50 -500154,开州区,50 -500155,梁平区,50 -500156,武隆区,50 -500229,城口县,50 -500230,丰都县,50 -500231,垫江县,50 -500233,忠县,50 -500235,云阳县,50 -500236,奉节县,50 -500237,巫山县,50 -500238,巫溪县,50 -500240,石柱土家族自治县,50 -500241,秀山土家族苗族自治县,50 -500242,酉阳土家族苗族自治县,50 -500243,彭水苗族土家族自治县,50 -51,四川省, -5101,成都市,51 -510104,锦江区,5101 -510105,青羊区,5101 -510106,金牛区,5101 -510107,武侯区,5101 -510108,成华区,5101 -510112,龙泉驿区,5101 -510113,青白江区,5101 -510114,新都区,5101 -510115,温江区,5101 -510116,双流区,5101 -510117,郫都区,5101 -510121,金堂县,5101 -510129,大邑县,5101 -510131,蒲江县,5101 -510132,新津县,5101 -510181,都江堰市,5101 -510182,彭州市,5101 -510183,邛崃市,5101 -510184,崇州市,5101 -510185,简阳市,5101 -5103,自贡市,51 -510302,自流井区,5103 -510303,贡井区,5103 -510304,大安区,5103 -510311,沿滩区,5103 -510321,荣县,5103 -510322,富顺县,5103 -5104,攀枝花市,51 -510402,东区,5104 -510403,西区,5104 -510411,仁和区,5104 -510421,米易县,5104 -510422,盐边县,5104 -5105,泸州市,51 -510502,江阳区,5105 -510503,纳溪区,5105 -510504,龙马潭区,5105 -510521,泸县,5105 -510522,合江县,5105 -510524,叙永县,5105 -510525,古蔺县,5105 -5106,德阳市,51 -510603,旌阳区,5106 -510604,罗江区,5106 -510623,中江县,5106 -510681,广汉市,5106 -510682,什邡市,5106 -510683,绵竹市,5106 -5107,绵阳市,51 -510703,涪城区,5107 -510704,游仙区,5107 -510705,安州区,5107 -510722,三台县,5107 -510723,盐亭县,5107 -510725,梓潼县,5107 -510726,北川羌族自治县,5107 -510727,平武县,5107 -510781,江油市,5107 -5108,广元市,51 -510802,利州区,5108 -510811,昭化区,5108 -510812,朝天区,5108 -510821,旺苍县,5108 -510822,青川县,5108 -510823,剑阁县,5108 -510824,苍溪县,5108 -5109,遂宁市,51 -510903,船山区,5109 -510904,安居区,5109 -510921,蓬溪县,5109 -510922,射洪县,5109 -510923,大英县,5109 -5110,内江市,51 -511002,市中区,5110 -511011,东兴区,5110 -511024,威远县,5110 -511025,资中县,5110 -511083,隆昌市,5110 -5111,乐山市,51 -511102,市中区,5111 -511111,沙湾区,5111 -511112,五通桥区,5111 -511113,金口河区,5111 -511123,犍为县,5111 -511124,井研县,5111 -511126,夹江县,5111 -511129,沐川县,5111 -511132,峨边彝族自治县,5111 -511133,马边彝族自治县,5111 -511181,峨眉山市,5111 -5113,南充市,51 -511302,顺庆区,5113 -511303,高坪区,5113 -511304,嘉陵区,5113 -511321,南部县,5113 -511322,营山县,5113 -511323,蓬安县,5113 -511324,仪陇县,5113 -511325,西充县,5113 -511381,阆中市,5113 -5114,眉山市,51 -511402,东坡区,5114 -511403,彭山区,5114 -511421,仁寿县,5114 -511423,洪雅县,5114 -511424,丹棱县,5114 -511425,青神县,5114 -5115,宜宾市,51 -511502,翠屏区,5115 -511503,南溪区,5115 -511504,叙州区,5115 -511523,江安县,5115 -511524,长宁县,5115 -511525,高县,5115 -511526,珙县,5115 -511527,筠连县,5115 -511528,兴文县,5115 -511529,屏山县,5115 -5116,广安市,51 -511602,广安区,5116 -511603,前锋区,5116 -511621,岳池县,5116 -511622,武胜县,5116 -511623,邻水县,5116 -511681,华蓥市,5116 -5117,达州市,51 -511702,通川区,5117 -511703,达川区,5117 -511722,宣汉县,5117 -511723,开江县,5117 -511724,大竹县,5117 -511725,渠县,5117 -511781,万源市,5117 -5118,雅安市,51 -511802,雨城区,5118 -511803,名山区,5118 -511822,荥经县,5118 -511823,汉源县,5118 -511824,石棉县,5118 -511825,天全县,5118 -511826,芦山县,5118 -511827,宝兴县,5118 -5119,巴中市,51 -511902,巴州区,5119 -511903,恩阳区,5119 -511921,通江县,5119 -511922,南江县,5119 -511923,平昌县,5119 -5120,资阳市,51 -512002,雁江区,5120 -512021,安岳县,5120 -512022,乐至县,5120 -5132,阿坝藏族羌族自治州,51 -513201,马尔康市,5132 -513221,汶川县,5132 -513222,理县,5132 -513223,茂县,5132 -513224,松潘县,5132 -513225,九寨沟县,5132 -513226,金川县,5132 -513227,小金县,5132 -513228,黑水县,5132 -513230,壤塘县,5132 -513231,阿坝县,5132 -513232,若尔盖县,5132 -513233,红原县,5132 -5133,甘孜藏族自治州,51 -513301,康定市,5133 -513322,泸定县,5133 -513323,丹巴县,5133 -513324,九龙县,5133 -513325,雅江县,5133 -513326,道孚县,5133 -513327,炉霍县,5133 -513328,甘孜县,5133 -513329,新龙县,5133 -513330,德格县,5133 -513331,白玉县,5133 -513332,石渠县,5133 -513333,色达县,5133 -513334,理塘县,5133 -513335,巴塘县,5133 -513336,乡城县,5133 -513337,稻城县,5133 -513338,得荣县,5133 -5134,凉山彝族自治州,51 -513401,西昌市,5134 -513422,木里藏族自治县,5134 -513423,盐源县,5134 -513424,德昌县,5134 -513425,会理县,5134 -513426,会东县,5134 -513427,宁南县,5134 -513428,普格县,5134 -513429,布拖县,5134 -513430,金阳县,5134 -513431,昭觉县,5134 -513432,喜德县,5134 -513433,冕宁县,5134 -513434,越西县,5134 -513435,甘洛县,5134 -513436,美姑县,5134 -513437,雷波县,5134 -52,贵州省, -5201,贵阳市,52 -520102,南明区,5201 -520103,云岩区,5201 -520111,花溪区,5201 -520112,乌当区,5201 -520113,白云区,5201 -520115,观山湖区,5201 -520121,开阳县,5201 -520122,息烽县,5201 -520123,修文县,5201 -520181,清镇市,5201 -5202,六盘水市,52 -520201,钟山区,5202 -520203,六枝特区,5202 -520221,水城县,5202 -520281,盘州市,5202 -5203,遵义市,52 -520302,红花岗区,5203 -520303,汇川区,5203 -520304,播州区,5203 -520322,桐梓县,5203 -520323,绥阳县,5203 -520324,正安县,5203 -520325,道真仡佬族苗族自治县,5203 -520326,务川仡佬族苗族自治县,5203 -520327,凤冈县,5203 -520328,湄潭县,5203 -520329,余庆县,5203 -520330,习水县,5203 -520381,赤水市,5203 -520382,仁怀市,5203 -5204,安顺市,52 -520402,西秀区,5204 -520403,平坝区,5204 -520422,普定县,5204 -520423,镇宁布依族苗族自治县,5204 -520424,关岭布依族苗族自治县,5204 -520425,紫云苗族布依族自治县,5204 -5205,毕节市,52 -520502,七星关区,5205 -520521,大方县,5205 -520522,黔西县,5205 -520523,金沙县,5205 -520524,织金县,5205 -520525,纳雍县,5205 -520526,威宁彝族回族苗族自治县,5205 -520527,赫章县,5205 -5206,铜仁市,52 -520602,碧江区,5206 -520603,万山区,5206 -520621,江口县,5206 -520622,玉屏侗族自治县,5206 -520623,石阡县,5206 -520624,思南县,5206 -520625,印江土家族苗族自治县,5206 -520626,德江县,5206 -520627,沿河土家族自治县,5206 -520628,松桃苗族自治县,5206 -5223,黔西南布依族苗族自治州,52 -522301,兴义市,5223 -522302,兴仁市,5223 -522323,普安县,5223 -522324,晴隆县,5223 -522325,贞丰县,5223 -522326,望谟县,5223 -522327,册亨县,5223 -522328,安龙县,5223 -5226,黔东南苗族侗族自治州,52 -522601,凯里市,5226 -522622,黄平县,5226 -522623,施秉县,5226 -522624,三穗县,5226 -522625,镇远县,5226 -522626,岑巩县,5226 -522627,天柱县,5226 -522628,锦屏县,5226 -522629,剑河县,5226 -522630,台江县,5226 -522631,黎平县,5226 -522632,榕江县,5226 -522633,从江县,5226 -522634,雷山县,5226 -522635,麻江县,5226 -522636,丹寨县,5226 -5227,黔南布依族苗族自治州,52 -522701,都匀市,5227 -522702,福泉市,5227 -522722,荔波县,5227 -522723,贵定县,5227 -522725,瓮安县,5227 -522726,独山县,5227 -522727,平塘县,5227 -522728,罗甸县,5227 -522729,长顺县,5227 -522730,龙里县,5227 -522731,惠水县,5227 -522732,三都水族自治县,5227 -53,云南省, -5301,昆明市,53 -530102,五华区,5301 -530103,盘龙区,5301 -530111,官渡区,5301 -530112,西山区,5301 -530113,东川区,5301 -530114,呈贡区,5301 -530115,晋宁区,5301 -530124,富民县,5301 -530125,宜良县,5301 -530126,石林彝族自治县,5301 -530127,嵩明县,5301 -530128,禄劝彝族苗族自治县,5301 -530129,寻甸回族彝族自治县,5301 -530181,安宁市,5301 -5303,曲靖市,53 -530302,麒麟区,5303 -530303,沾益区,5303 -530304,马龙区,5303 -530322,陆良县,5303 -530323,师宗县,5303 -530324,罗平县,5303 -530325,富源县,5303 -530326,会泽县,5303 -530381,宣威市,5303 -5304,玉溪市,53 -530402,红塔区,5304 -530403,江川区,5304 -530422,澄江县,5304 -530423,通海县,5304 -530424,华宁县,5304 -530425,易门县,5304 -530426,峨山彝族自治县,5304 -530427,新平彝族傣族自治县,5304 -530428,元江哈尼族彝族傣族自治县,5304 -5305,保山市,53 -530502,隆阳区,5305 -530521,施甸县,5305 -530523,龙陵县,5305 -530524,昌宁县,5305 -530581,腾冲市,5305 -5306,昭通市,53 -530602,昭阳区,5306 -530621,鲁甸县,5306 -530622,巧家县,5306 -530623,盐津县,5306 -530624,大关县,5306 -530625,永善县,5306 -530626,绥江县,5306 -530627,镇雄县,5306 -530628,彝良县,5306 -530629,威信县,5306 -530681,水富市,5306 -5307,丽江市,53 -530702,古城区,5307 -530721,玉龙纳西族自治县,5307 -530722,永胜县,5307 -530723,华坪县,5307 -530724,宁蒗彝族自治县,5307 -5308,普洱市,53 -530802,思茅区,5308 -530821,宁洱哈尼族彝族自治县,5308 -530822,墨江哈尼族自治县,5308 -530823,景东彝族自治县,5308 -530824,景谷傣族彝族自治县,5308 -530825,镇沅彝族哈尼族拉祜族自治县,5308 -530826,江城哈尼族彝族自治县,5308 -530827,孟连傣族拉祜族佤族自治县,5308 -530828,澜沧拉祜族自治县,5308 -530829,西盟佤族自治县,5308 -5309,临沧市,53 -530902,临翔区,5309 -530921,凤庆县,5309 -530922,云县,5309 -530923,永德县,5309 -530924,镇康县,5309 -530925,双江拉祜族佤族布朗族傣族自治县,5309 -530926,耿马傣族佤族自治县,5309 -530927,沧源佤族自治县,5309 -5323,楚雄彝族自治州,53 -532301,楚雄市,5323 -532322,双柏县,5323 -532323,牟定县,5323 -532324,南华县,5323 -532325,姚安县,5323 -532326,大姚县,5323 -532327,永仁县,5323 -532328,元谋县,5323 -532329,武定县,5323 -532331,禄丰县,5323 -5325,红河哈尼族彝族自治州,53 -532501,个旧市,5325 -532502,开远市,5325 -532503,蒙自市,5325 -532504,弥勒市,5325 -532523,屏边苗族自治县,5325 -532524,建水县,5325 -532525,石屏县,5325 -532527,泸西县,5325 -532528,元阳县,5325 -532529,红河县,5325 -532530,金平苗族瑶族傣族自治县,5325 -532531,绿春县,5325 -532532,河口瑶族自治县,5325 -5326,文山壮族苗族自治州,53 -532601,文山市,5326 -532622,砚山县,5326 -532623,西畴县,5326 -532624,麻栗坡县,5326 -532625,马关县,5326 -532626,丘北县,5326 -532627,广南县,5326 -532628,富宁县,5326 -5328,西双版纳傣族自治州,53 -532801,景洪市,5328 -532822,勐海县,5328 -532823,勐腊县,5328 -5329,大理白族自治州,53 -532901,大理市,5329 -532922,漾濞彝族自治县,5329 -532923,祥云县,5329 -532924,宾川县,5329 -532925,弥渡县,5329 -532926,南涧彝族自治县,5329 -532927,巍山彝族回族自治县,5329 -532928,永平县,5329 -532929,云龙县,5329 -532930,洱源县,5329 -532931,剑川县,5329 -532932,鹤庆县,5329 -5331,德宏傣族景颇族自治州,53 -533102,瑞丽市,5331 -533103,芒市,5331 -533122,梁河县,5331 -533123,盈江县,5331 -533124,陇川县,5331 -5333,怒江傈僳族自治州,53 -533301,泸水市,5333 -533323,福贡县,5333 -533324,贡山独龙族怒族自治县,5333 -533325,兰坪白族普米族自治县,5333 -5334,迪庆藏族自治州,53 -533401,香格里拉市,5334 -533422,德钦县,5334 -533423,维西傈僳族自治县,5334 -54,西藏自治区, -5401,拉萨市,54 -540102,城关区,5401 -540103,堆龙德庆区,5401 -540104,达孜区,5401 -540121,林周县,5401 -540122,当雄县,5401 -540123,尼木县,5401 -540124,曲水县,5401 -540127,墨竹工卡县,5401 -5402,日喀则市,54 -540202,桑珠孜区,5402 -540221,南木林县,5402 -540222,江孜县,5402 -540223,定日县,5402 -540224,萨迦县,5402 -540225,拉孜县,5402 -540226,昂仁县,5402 -540227,谢通门县,5402 -540228,白朗县,5402 -540229,仁布县,5402 -540230,康马县,5402 -540231,定结县,5402 -540232,仲巴县,5402 -540233,亚东县,5402 -540234,吉隆县,5402 -540235,聂拉木县,5402 -540236,萨嘎县,5402 -540237,岗巴县,5402 -5403,昌都市,54 -540302,卡若区,5403 -540321,江达县,5403 -540322,贡觉县,5403 -540323,类乌齐县,5403 -540324,丁青县,5403 -540325,察雅县,5403 -540326,八宿县,5403 -540327,左贡县,5403 -540328,芒康县,5403 -540329,洛隆县,5403 -540330,边坝县,5403 -5404,林芝市,54 -540402,巴宜区,5404 -540421,工布江达县,5404 -540422,米林县,5404 -540423,墨脱县,5404 -540424,波密县,5404 -540425,察隅县,5404 -540426,朗县,5404 -5405,山南市,54 -540502,乃东区,5405 -540521,扎囊县,5405 -540522,贡嘎县,5405 -540523,桑日县,5405 -540524,琼结县,5405 -540525,曲松县,5405 -540526,措美县,5405 -540527,洛扎县,5405 -540528,加查县,5405 -540529,隆子县,5405 -540530,错那县,5405 -540531,浪卡子县,5405 -5406,那曲市,54 -540602,色尼区,5406 -540621,嘉黎县,5406 -540622,比如县,5406 -540623,聂荣县,5406 -540624,安多县,5406 -540625,申扎县,5406 -540626,索县,5406 -540627,班戈县,5406 -540628,巴青县,5406 -540629,尼玛县,5406 -540630,双湖县,5406 -5425,阿里地区,54 -542521,普兰县,5425 -542522,札达县,5425 -542523,噶尔县,5425 -542524,日土县,5425 -542525,革吉县,5425 -542526,改则县,5425 -542527,措勤县,5425 -61,陕西省, -6101,西安市,61 -610102,新城区,6101 -610103,碑林区,6101 -610104,莲湖区,6101 -610111,灞桥区,6101 -610112,未央区,6101 -610113,雁塔区,6101 -610114,阎良区,6101 -610115,临潼区,6101 -610116,长安区,6101 -610117,高陵区,6101 -610118,鄠邑区,6101 -610122,蓝田县,6101 -610124,周至县,6101 -6102,铜川市,61 -610202,王益区,6102 -610203,印台区,6102 -610204,耀州区,6102 -610222,宜君县,6102 -6103,宝鸡市,61 -610302,渭滨区,6103 -610303,金台区,6103 -610304,陈仓区,6103 -610322,凤翔县,6103 -610323,岐山县,6103 -610324,扶风县,6103 -610326,眉县,6103 -610327,陇县,6103 -610328,千阳县,6103 -610329,麟游县,6103 -610330,凤县,6103 -610331,太白县,6103 -6104,咸阳市,61 -610402,秦都区,6104 -610403,杨陵区,6104 -610404,渭城区,6104 -610422,三原县,6104 -610423,泾阳县,6104 -610424,乾县,6104 -610425,礼泉县,6104 -610426,永寿县,6104 -610428,长武县,6104 -610429,旬邑县,6104 -610430,淳化县,6104 -610431,武功县,6104 -610481,兴平市,6104 -610482,彬州市,6104 -6105,渭南市,61 -610502,临渭区,6105 -610503,华州区,6105 -610522,潼关县,6105 -610523,大荔县,6105 -610524,合阳县,6105 -610525,澄城县,6105 -610526,蒲城县,6105 -610527,白水县,6105 -610528,富平县,6105 -610581,韩城市,6105 -610582,华阴市,6105 -6106,延安市,61 -610602,宝塔区,6106 -610603,安塞区,6106 -610621,延长县,6106 -610622,延川县,6106 -610623,子长县,6106 -610625,志丹县,6106 -610626,吴起县,6106 -610627,甘泉县,6106 -610628,富县,6106 -610629,洛川县,6106 -610630,宜川县,6106 -610631,黄龙县,6106 -610632,黄陵县,6106 -6107,汉中市,61 -610702,汉台区,6107 -610703,南郑区,6107 -610722,城固县,6107 -610723,洋县,6107 -610724,西乡县,6107 -610725,勉县,6107 -610726,宁强县,6107 -610727,略阳县,6107 -610728,镇巴县,6107 -610729,留坝县,6107 -610730,佛坪县,6107 -6108,榆林市,61 -610802,榆阳区,6108 -610803,横山区,6108 -610822,府谷县,6108 -610824,靖边县,6108 -610825,定边县,6108 -610826,绥德县,6108 -610827,米脂县,6108 -610828,佳县,6108 -610829,吴堡县,6108 -610830,清涧县,6108 -610831,子洲县,6108 -610881,神木市,6108 -6109,安康市,61 -610902,汉滨区,6109 -610921,汉阴县,6109 -610922,石泉县,6109 -610923,宁陕县,6109 -610924,紫阳县,6109 -610925,岚皋县,6109 -610926,平利县,6109 -610927,镇坪县,6109 -610928,旬阳县,6109 -610929,白河县,6109 -6110,商洛市,61 -611002,商州区,6110 -611021,洛南县,6110 -611022,丹凤县,6110 -611023,商南县,6110 -611024,山阳县,6110 -611025,镇安县,6110 -611026,柞水县,6110 -62,甘肃省, -6201,兰州市,62 -620102,城关区,6201 -620103,七里河区,6201 -620104,西固区,6201 -620105,安宁区,6201 -620111,红古区,6201 -620121,永登县,6201 -620122,皋兰县,6201 -620123,榆中县,6201 -6202,嘉峪关市,62 -6203,金昌市,62 -620302,金川区,6203 -620321,永昌县,6203 -6204,白银市,62 -620402,白银区,6204 -620403,平川区,6204 -620421,靖远县,6204 -620422,会宁县,6204 -620423,景泰县,6204 -6205,天水市,62 -620502,秦州区,6205 -620503,麦积区,6205 -620521,清水县,6205 -620522,秦安县,6205 -620523,甘谷县,6205 -620524,武山县,6205 -620525,张家川回族自治县,6205 -6206,武威市,62 -620602,凉州区,6206 -620621,民勤县,6206 -620622,古浪县,6206 -620623,天祝藏族自治县,6206 -6207,张掖市,62 -620702,甘州区,6207 -620721,肃南裕固族自治县,6207 -620722,民乐县,6207 -620723,临泽县,6207 -620724,高台县,6207 -620725,山丹县,6207 -6208,平凉市,62 -620802,崆峒区,6208 -620821,泾川县,6208 -620822,灵台县,6208 -620823,崇信县,6208 -620825,庄浪县,6208 -620826,静宁县,6208 -620881,华亭市,6208 -6209,酒泉市,62 -620902,肃州区,6209 -620921,金塔县,6209 -620922,瓜州县,6209 -620923,肃北蒙古族自治县,6209 -620924,阿克塞哈萨克族自治县,6209 -620981,玉门市,6209 -620982,敦煌市,6209 -6210,庆阳市,62 -621002,西峰区,6210 -621021,庆城县,6210 -621022,环县,6210 -621023,华池县,6210 -621024,合水县,6210 -621025,正宁县,6210 -621026,宁县,6210 -621027,镇原县,6210 -6211,定西市,62 -621102,安定区,6211 -621121,通渭县,6211 -621122,陇西县,6211 -621123,渭源县,6211 -621124,临洮县,6211 -621125,漳县,6211 -621126,岷县,6211 -6212,陇南市,62 -621202,武都区,6212 -621221,成县,6212 -621222,文县,6212 -621223,宕昌县,6212 -621224,康县,6212 -621225,西和县,6212 -621226,礼县,6212 -621227,徽县,6212 -621228,两当县,6212 -6229,临夏回族自治州,62 -622901,临夏市,6229 -622921,临夏县,6229 -622922,康乐县,6229 -622923,永靖县,6229 -622924,广河县,6229 -622925,和政县,6229 -622926,东乡族自治县,6229 -622927,积石山保安族东乡族撒拉族自治县,6229 -6230,甘南藏族自治州,62 -623001,合作市,6230 -623021,临潭县,6230 -623022,卓尼县,6230 -623023,舟曲县,6230 -623024,迭部县,6230 -623025,玛曲县,6230 -623026,碌曲县,6230 -623027,夏河县,6230 -63,青海省, -6301,西宁市,63 -630102,城东区,6301 -630103,城中区,6301 -630104,城西区,6301 -630105,城北区,6301 -630121,大通回族土族自治县,6301 -630122,湟中县,6301 -630123,湟源县,6301 -6302,海东市,63 -630202,乐都区,6302 -630203,平安区,6302 -630222,民和回族土族自治县,6302 -630223,互助土族自治县,6302 -630224,化隆回族自治县,6302 -630225,循化撒拉族自治县,6302 -6322,海北藏族自治州,63 -632221,门源回族自治县,6322 -632222,祁连县,6322 -632223,海晏县,6322 -632224,刚察县,6322 -6323,黄南藏族自治州,63 -632321,同仁县,6323 -632322,尖扎县,6323 -632323,泽库县,6323 -632324,河南蒙古族自治县,6323 -6325,海南藏族自治州,63 -632521,共和县,6325 -632522,同德县,6325 -632523,贵德县,6325 -632524,兴海县,6325 -632525,贵南县,6325 -6326,果洛藏族自治州,63 -632621,玛沁县,6326 -632622,班玛县,6326 -632623,甘德县,6326 -632624,达日县,6326 -632625,久治县,6326 -632626,玛多县,6326 -6327,玉树藏族自治州,63 -632701,玉树市,6327 -632722,杂多县,6327 -632723,称多县,6327 -632724,治多县,6327 -632725,囊谦县,6327 -632726,曲麻莱县,6327 -6328,海西蒙古族藏族自治州,63 -632801,格尔木市,6328 -632802,德令哈市,6328 -632803,茫崖市,6328 -632821,乌兰县,6328 -632822,都兰县,6328 -632823,天峻县,6328 -64,宁夏回族自治区, -6401,银川市,64 -640104,兴庆区,6401 -640105,西夏区,6401 -640106,金凤区,6401 -640121,永宁县,6401 -640122,贺兰县,6401 -640181,灵武市,6401 -6402,石嘴山市,64 -640202,大武口区,6402 -640205,惠农区,6402 -640221,平罗县,6402 -6403,吴忠市,64 -640302,利通区,6403 -640303,红寺堡区,6403 -640323,盐池县,6403 -640324,同心县,6403 -640381,青铜峡市,6403 -6404,固原市,64 -640402,原州区,6404 -640422,西吉县,6404 -640423,隆德县,6404 -640424,泾源县,6404 -640425,彭阳县,6404 -6405,中卫市,64 -640502,沙坡头区,6405 -640521,中宁县,6405 -640522,海原县,6405 -65,新疆维吾尔自治区, -6501,乌鲁木齐市,65 -650102,天山区,6501 -650103,沙依巴克区,6501 -650104,新市区,6501 -650105,水磨沟区,6501 -650106,头屯河区,6501 -650107,达坂城区,6501 -650109,米东区,6501 -650121,乌鲁木齐县,6501 -6502,克拉玛依市,65 -650202,独山子区,6502 -650203,克拉玛依区,6502 -650204,白碱滩区,6502 -650205,乌尔禾区,6502 -6504,吐鲁番市,65 -650402,高昌区,6504 -650421,鄯善县,6504 -650422,托克逊县,6504 -6505,哈密市,65 -650502,伊州区,6505 -650521,巴里坤哈萨克自治县,6505 -650522,伊吾县,6505 -6523,昌吉回族自治州,65 -652301,昌吉市,6523 -652302,阜康市,6523 -652323,呼图壁县,6523 -652324,玛纳斯县,6523 -652325,奇台县,6523 -652327,吉木萨尔县,6523 -652328,木垒哈萨克自治县,6523 -6527,博尔塔拉蒙古自治州,65 -652701,博乐市,6527 -652702,阿拉山口市,6527 -652722,精河县,6527 -652723,温泉县,6527 -6528,巴音郭楞蒙古自治州,65 -652801,库尔勒市,6528 -652822,轮台县,6528 -652823,尉犁县,6528 -652824,若羌县,6528 -652825,且末县,6528 -652826,焉耆回族自治县,6528 -652827,和静县,6528 -652828,和硕县,6528 -652829,博湖县,6528 -6529,阿克苏地区,65 -652901,阿克苏市,6529 -652922,温宿县,6529 -652923,库车县,6529 -652924,沙雅县,6529 -652925,新和县,6529 -652926,拜城县,6529 -652927,乌什县,6529 -652928,阿瓦提县,6529 -652929,柯坪县,6529 -6530,克孜勒苏柯尔克孜自治州,65 -653001,阿图什市,6530 -653022,阿克陶县,6530 -653023,阿合奇县,6530 -653024,乌恰县,6530 -6531,喀什地区,65 -653101,喀什市,6531 -653121,疏附县,6531 -653122,疏勒县,6531 -653123,英吉沙县,6531 -653124,泽普县,6531 -653125,莎车县,6531 -653126,叶城县,6531 -653127,麦盖提县,6531 -653128,岳普湖县,6531 -653129,伽师县,6531 -653130,巴楚县,6531 -653131,塔什库尔干塔吉克自治县,6531 -6532,和田地区,65 -653201,和田市,6532 -653221,和田县,6532 -653222,墨玉县,6532 -653223,皮山县,6532 -653224,洛浦县,6532 -653225,策勒县,6532 -653226,于田县,6532 -653227,民丰县,6532 -6540,伊犁哈萨克自治州,65 -654002,伊宁市,6540 -654003,奎屯市,6540 -654004,霍尔果斯市,6540 -654021,伊宁县,6540 -654022,察布查尔锡伯自治县,6540 -654023,霍城县,6540 -654024,巩留县,6540 -654025,新源县,6540 -654026,昭苏县,6540 -654027,特克斯县,6540 -654028,尼勒克县,6540 -6542,塔城地区,65 -654201,塔城市,6542 -654202,乌苏市,6542 -654221,额敏县,6542 -654223,沙湾县,6542 -654224,托里县,6542 -654225,裕民县,6542 -654226,和布克赛尔蒙古自治县,6542 -6543,阿勒泰地区,65 -654301,阿勒泰市,6543 -654321,布尔津县,6543 -654322,富蕴县,6543 -654323,福海县,6543 -654324,哈巴河县,6543 -654325,青河县,6543 -654326,吉木乃县,6543 -659001,石河子市,65 -659002,阿拉尔市,65 -659003,图木舒克市,65 -659004,五家渠市,65 -659005,北屯市,65 -659006,铁门关市,65 -659007,双河市,65 -659008,可克达拉市,65 -659009,昆玉市,65 -71,台湾省, -81,香港特别行政区, -82,澳门特别行政区, \ No newline at end of file diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/logback-wvp.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/logback-wvp.xml deleted file mode 100644 index 0426c790..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/logback-wvp.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - ${LOGGER_PATH_ROOT}/wvp/info/%d{yyyy-MM-dd}.%i.log - - 30 - 20MB - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n - UTF-8 - - - - - INFO - - - - - - - - - ${LOGGER_PATH_ROOT}/wvp/error/%d{yyyy-MM-dd}.%i.log - - 30 - 20MB - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n - UTF-8 - - - - WARN - - - - - - - - ${LOGGER_PATH_ROOT}/wvp/sip/%d{yyyy-MM-dd}.%i.log - - 30 - 50MB - - - - %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50}:%L - %msg%n - UTF-8 - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceAlarmMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceAlarmMapper.xml deleted file mode 100644 index 92994f92..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceAlarmMapper.xml +++ /dev/null @@ -1,43 +0,0 @@ - - - - - - - - - - - - - - - - - - - - DELETE FROM wvp_device_alarm - - AND device_id in - #{item} - - AND alarm_time <= #{time} - AND id = #{id} - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceChannelMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceChannelMapper.xml deleted file mode 100644 index 25beaa6d..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceChannelMapper.xml +++ /dev/null @@ -1,285 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - insert into wvp_device_channel - (channel_id, device_id, name, manufacture, model, owner, civil_code, block, sub_count, - address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, secrecy, - ip_address,port,password,ptz_type,status,stream_id,longitude,latitude,longitude_gcj02,latitude_gcj02, - longitude_wgs84,latitude_wgs84,has_audio,create_time,update_time,business_group_id,gps_time) values - - (#{item.channelId}, #{item.deviceId}, #{item.name}, #{item.manufacture}, #{item.model}, - #{item.owner}, #{item.civilCode}, #{item.block},#{item.subCount}, - #{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, - #{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.secrecy}, - #{item.ipAddress}, #{item.port}, #{item.password}, #{item.PTZType}, #{item.status}, - #{item.streamId}, #{item.longitude}, #{item.latitude},#{item.longitudeGcj02}, - #{item.latitudeGcj02},#{item.longitudeWgs84}, #{item.latitudeWgs84}, #{item.hasAudio}, now(), now(), - #{item.businessGroupId}, #{item.gpsTime}) - - - - - UPDATE wvp_device_channel SET stream_id=null WHERE device_id=#{deviceId} AND channel_id=#{channelId} - - - UPDATE wvp_device_channel SET stream_id=#{streamId} WHERE device_id=#{deviceId} AND channel_id=#{channelId} - - - UPDATE wvp_device_channel SET status=true WHERE - - (device_id=#{item.deviceId} AND channel_id=#{item.channelId}) - - - - - UPDATE wvp_device_channel SET status=false WHERE - - (device_id=#{item.deviceId} AND channel_id=#{item.channelId}) - - - - update wvp_device_channel - set sub_count = ( - select * from (select count(0) from wvp_device_channel where device_id = #{deviceId} and parent_id = #{channelId}) as temp - ) - where device_id = #{deviceId} and channel_id = #{channelId} - - - - DELETE FROM wvp_device_channel WHERE device_id=#{deviceId} - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceMapper.xml deleted file mode 100644 index 8c3cc457..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceMapper.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceMobilePositionMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceMobilePositionMapper.xml deleted file mode 100644 index 4f484e66..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/DeviceMobilePositionMapper.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/GbStreamMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/GbStreamMapper.xml deleted file mode 100644 index d2e3ea35..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/GbStreamMapper.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - INSERT into wvp_gb_stream (app, stream, gb_id, name, longitude, latitude, stream_type,media_server_id,create_time) values - - (#{item.app}, #{item.stream}, #{item.gbId}, #{item.name}, #{item.longitude}, #{item.latitude}, #{item.streamType}, #{item.mediaServerId}, #{item.createTime}) - - - - - UPDATE wvp_gb_stream SET longitude=#{item.lng}, latitude=#{item.lat} WHERE gb_id=#{item.id} - - - - - UPDATE wvp_gb_stream SET name=#{item.name}, gb_id=#{item.gb_id} WHERE app=#{item.app} and stream=#{item.stream} - - - - DELETE FROM wvp_gb_stream where - - (app=#{item.app} and stream=#{item.stream}) - - - - DELETE FROM wvp_gb_stream where - - (app=#{item.app} and stream=#{item.stream}) - - - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/MediaServerItemMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/MediaServerItemMapper.xml deleted file mode 100644 index 5bbea217..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/MediaServerItemMapper.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/ParentPlatformMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/ParentPlatformMapper.xml deleted file mode 100644 index 4d6d862a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/ParentPlatformMapper.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformCatalogMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformCatalogMapper.xml deleted file mode 100644 index 925db09e..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformCatalogMapper.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - - - - - - - - - - - - - - - - DELETE from wvp_platform_catalog WHERE platform_id=#{platformId} and id=#{id} - - - - DELETE from wvp_platform_catalog WHERE platform_id=#{platformId} - - - - DELETE from wvp_platform_catalog where platform_id=#{platformId} and id in - - #{item} - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformChannelMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformChannelMapper.xml deleted file mode 100644 index 5cfcfe31..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformChannelMapper.xml +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - INSERT INTO wvp_platform_gb_channel (platform_id, device_channel_id, catalog_id) VALUES - - (#{platformId}, #{item.id} , #{item.catalogId}) - - - - - DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} AND device_channel_id in - #{item.id} - - - - DELETE from wvp_platform_gb_channel WHERE device_channel_id in - ( select temp.device_channel_id from - (select pgc.device_channel_id from wvp_platform_gb_channel pgc - left join wvp_device_channel dc on dc.id = pgc.device_channel_id where dc.device_id =#{deviceId} - ) temp) - - - - DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} - - - - DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} and catalog_id=#{id} - - - - DELETE from wvp_platform_gb_channel WHERE catalog_id=#{parentId} AND platform_id=#{platformId} AND channel_id=#{id} - - - - DELETE from wvp_platform_gb_channel WHERE platform_id=#{serverGBId} - - - - DELETE from wvp_platform_gb_channel WHERE platform_id=#{platformId} - and catalog_id=#{catalogId} - - - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformStreamMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformStreamMapper.xml deleted file mode 100644 index ef26323a..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/PlatformStreamMapper.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - INSERT into wvp_platform_gb_stream (gb_stream_id, platform_id, catalog_id) values - - (#{item.gbStreamId}, #{item.platform_id}, #{item.catalogId}) - - - - - DELETE from wvp_platform_gb_stream WHERE gb_stream_id = (select gb_stream_id from wvp_gb_stream where app=#{app} AND stream=#{stream}) - - - - DELETE from wvp_platform_gb_stream WHERE platform_id=#{platformId} - - - - DELETE from wvp_platform_gb_stream where gb_stream_id in - - #{item.gbStreamId} - - - - - DELETE from wvp_platform_gb_stream where platform_id=#{platformId} and gb_stream_id in - - #{item.gbStreamId} - - - - - DELETE from wvp_platform_gb_stream WHERE platform_id=#{platformId} and catalog_id=#{catalogId} - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/StreamProxyMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/StreamProxyMapper.xml deleted file mode 100644 index cc082c85..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/StreamProxyMapper.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - UPDATE wvp_stream_proxy SET status=#{status} WHERE media_server_id=#{mediaServerId} - - - - UPDATE wvp_stream_proxy SET status=#{status} WHERE app=#{app} AND stream=#{stream} - - - DELETE FROM wvp_stream_proxy WHERE enable_remove_none_reader=true AND media_server_id=#{mediaServerId} - - - - - - - - - - - - - - - - - diff --git a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/StreamPushMapper.xml b/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/StreamPushMapper.xml deleted file mode 100644 index 3cdc4b55..00000000 --- a/iboot-tos/wvp-GB28181-pro/src/main/resources/mapper/wvp/StreamPushMapper.xml +++ /dev/null @@ -1,141 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - Insert INTO wvp_stream_push (app, stream, total_reader_count, origin_type, origin_type_str, create_time, alive_second, media_server_id, status, push_ing) - VALUES - (#{item.app}, #{item.stream}, #{item.totalReaderCount}, #{item.originType} - , #{item.originTypeStr},#{item.createTime}, #{item.aliveSecond} - , #{item.mediaServerId}, #{item.status}, #{item.pushIng}) - - - - - UPDATE wvp_stream_push SET push_ing=#{pushIng} WHERE app=#{app} AND stream=#{stream} - - - - UPDATE wvp_stream_push SET status=#{status} WHERE media_server_id=#{mediaServerId} - - - - UPDATE wvp_stream_push SET status=0 where (app, stream) in ( - - (#{item.app}, #{item.stream}) - ) - - - - UPDATE wvp_stream_push SET status=1 where (app, stream) in ( - - (#{item.app}, #{item.stream}) - ) - - - UPDATE wvp_stream_push SET status=0 - - - - DELETE FROM wvp_stream_push where - - (app=#{item.app} and stream=#{item.stream}) - - - - - DELETE FROM wvp_stream_push where - - (app=#{item.app} and stream=#{item.stream}) - - - - delete from wvp_stream_push where id in ( - select temp.id from ( - select wgs.gb_stream_id as id from wvp_gb_stream wgs - left join wvp_stream_push sp on sp.id = wgs.gb_stream_id - where wgs.gb_id is null and wgs.media_server_id = #{mediaServerId}) temp - ) - - - - - - - - - - - - - - - - - - - -