From 7e755f405dd1112a201b9dbde7e2d6cff8abc8f4 Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: 星期五, 01 四月 2022 16:45:29 +0800 Subject: [PATCH] 支持国标移动位置订阅,收到新位置发送redis消息;支持通道redis消息拉起第三方推流;云台控制添加ControlPriority字段;处理sql的bug --- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java | 10 src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java | 4 src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java | 2 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java | 6 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java | 5 src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java | 10 src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java | 4 src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java | 9 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java | 10 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java | 32 src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java | 7 src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java | 5 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java | 25 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java | 29 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java | 4 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java | 9 src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java | 8 src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java | 4 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java | 4 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java | 21 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java | 5 src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java | 13 src/main/java/com/genersoft/iot/vmp/service/bean/MobilePositionSubscribeTask.java | 38 src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java | 4 src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java | 16 src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java | 11 src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java | 41 src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java | 59 src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java | 9 src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java | 13 src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java | 6 src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java | 4 src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java | 5 src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java | 16 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java | 6 src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java | 2 src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java | 4 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java | 4 src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java | 18 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java | 217 +++- src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java | 13 src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java | 963 +++++++++++----------- src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java | 13 src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java | 18 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java | 6 src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java | 4 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java | 35 sql/update.sql | 8 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java | 40 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java | 6 src/main/java/com/genersoft/iot/vmp/gb28181/task/GPSSubscribeTask.java | 32 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java | 10 src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java | 12 src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java | 12 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java | 9 src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java | 40 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java | 10 src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java | 12 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java | 29 src/main/java/com/genersoft/iot/vmp/service/StreamGPSSubscribeTask.java | 4 src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java | 11 src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java | 5 src/main/resources/logback-spring-local.xml | 12 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java | 6 src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java | 6 src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java | 15 src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java | 25 web_src/src/components/dialog/deviceEdit.vue | 6 src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java | 154 +- src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java | 4 src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java | 9 src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java | 8 src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java | 112 ++ src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java | 4 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java | 4 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java | 5 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java | 43 src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java | 12 src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java | 4 web_src/src/components/ParentPlatformList.vue | 4 src/main/resources/all-application.yml | 2 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java | 13 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java | 4 src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java | 8 src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java | 4 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 25 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java | 1 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java | 6 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java | 7 src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 15 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java | 12 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java | 5 92 files changed, 1,459 insertions(+), 1,067 deletions(-) diff --git a/sql/update.sql b/sql/update.sql new file mode 100644 index 0000000..5804518 --- /dev/null +++ b/sql/update.sql @@ -0,0 +1,8 @@ +alter table device + add subscribeCycleForMobilePosition int null; + +alter table device + add mobilePositionSubmissionInterval int default 5 null; + +alter table device + add subscribeCycleForAlarm int null; \ No newline at end of file diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java index 0d63843..c4d49a8 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java +++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java @@ -70,8 +70,24 @@ public static final String SYSTEM_INFO_NET_PREFIX = "VMP_SYSTEM_INFO_NET_"; //************************** redis 娑堟伅********************************* + + // 娴佸彉鍖栫殑閫氱煡 public static final String WVP_MSG_STREAM_CHANGE_PREFIX = "WVP_MSG_STREAM_CHANGE_"; - public static final String WVP_MSG_GPS_PREFIX = "VM_MSG_GPS"; + + // 鎺ユ敹鎺ㄦ祦璁惧鐨凣PS鍙樺寲閫氱煡 + public static final String VM_MSG_GPS = "VM_MSG_GPS"; + + // redis 娑堟伅閫氱煡璁惧鎺ㄦ祦鍒板钩鍙� + public static final String VM_MSG_STREAM_PUSH_REQUESTED = "VM_MSG_STREAM_PUSH_REQUESTED"; + + // 绉诲姩浣嶇疆璁㈤槄閫氱煡 + public static final String VM_MSG_SUBSCRIBE_MOBILE_POSITION = "mobileposition"; + + // 鎶ヨ璁㈤槄鐨勯�氱煡 + public static final String VM_MSG_SUBSCRIBE_ALARM = "alarm"; + + // 璁惧鐘舵�佽闃呯殑閫氱煡 + public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device"; //************************** 绗笁鏂� **************************************** public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_"; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java b/src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java index 08d030a..6180974 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/ApiAccessFilter.java @@ -29,7 +29,7 @@ private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private ILogService logService; @@ -48,7 +48,7 @@ filterChain.doFilter(servletRequest, servletResponse); - if (uriName != null && userSetup.getLogInDatebase()) { + if (uriName != null && userSetting.getLogInDatebase()) { LogDto logDto = new LogDto(); logDto.setName(uriName); diff --git a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java index 80e39f5..bbe0e81 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java @@ -7,6 +7,7 @@ import java.util.Date; import java.util.Map; +import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ScheduledFuture; @@ -45,12 +46,12 @@ * 寤舵椂浠诲姟 * @param key 浠诲姟ID * @param task 浠诲姟 - * @param delay 寤舵椂 /绉� + * @param delay 寤舵椂 /姣 * @return */ public String startDelay(String key, Runnable task, int delay) { stop(key); - Date starTime = new Date(System.currentTimeMillis() + delay * 1000); + Date starTime = new Date(System.currentTimeMillis() + delay); // scheduleWithFixedDelay 蹇呴』绛夊緟涓婁竴涓换鍔$粨鏉熸墠寮�濮嬭鏃秔eriod锛� cycleForCatalog琛ㄧず鎵ц鐨勯棿闅� ScheduledFuture future = threadPoolTaskScheduler.schedule(task, starTime); futureMap.put(key, future); @@ -67,4 +68,8 @@ return futureMap.get(key) != null; } + public Set<String> getAllKeys() { + return futureMap.keySet(); + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java index 5f04a08..d46a8ea 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java @@ -92,7 +92,7 @@ RedisMessageListenerContainer container = new RedisMessageListenerContainer(); container.setConnectionFactory(connectionFactory); - container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.WVP_MSG_GPS_PREFIX)); + container.addMessageListener(redisGPSMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_GPS)); return container; } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java b/src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java index a2281ab..1848380 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/RedisKeyExpirationEventMessageListener.java @@ -3,25 +3,24 @@ import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.RedisMessageListenerContainer; -import org.springframework.util.StringUtils; import java.util.Properties; public class RedisKeyExpirationEventMessageListener extends KeyExpirationEventMessageListener { - private UserSetup userSetup; + private UserSetting userSetting; private RedisMessageListenerContainer listenerContainer; private String keyspaceNotificationsConfigParameter = "EA"; - public RedisKeyExpirationEventMessageListener(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) { + public RedisKeyExpirationEventMessageListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) { super(listenerContainer); this.listenerContainer = listenerContainer; - this.userSetup = userSetup; + this.userSetting = userSetting; } @Override public void init() { - if (!userSetup.getRedisConfig()) { + if (!userSetting.getRedisConfig()) { // 閰嶇疆springboot榛樿Config涓虹┖锛屽嵆涓嶈搴旂敤鍘讳慨鏀箁edis鐨勯粯璁ら厤缃紝鍥犱负Redis鏈嶅姟鍑轰簬瀹夊叏浼氱鐢–ONFIG鍛戒护缁欒繙绋嬬敤鎴蜂娇鐢� setKeyspaceNotificationsConfigParameter(""); }else { diff --git a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java index 7f9f847..cf16f86 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java @@ -4,9 +4,8 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; @@ -22,7 +21,7 @@ public class SipPlatformRunner implements CommandLineRunner { @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java similarity index 90% rename from src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java rename to src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java index d1d0e20..4776551 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/UserSetup.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/UserSetting.java @@ -6,10 +6,12 @@ import java.util.ArrayList; import java.util.List; - +/** + * 閰嶇疆鏂囦欢 user-settings 鏄犲皠鐨勯厤缃俊鎭� + */ @Component @ConfigurationProperties(prefix = "user-settings", ignoreInvalidFields = true) -public class UserSetup { +public class UserSetting { private Boolean savePositionHistory = Boolean.FALSE; @@ -18,6 +20,8 @@ private Boolean seniorSdp = Boolean.FALSE; private Long playTimeout = 18000L; + + private int platformPlayTimeout = 60000; private Boolean interfaceAuthentication = Boolean.TRUE; @@ -134,4 +138,12 @@ public void setRecordSip(Boolean recordSip) { this.recordSip = recordSip; } + + public int getPlatformPlayTimeout() { + return platformPlayTimeout; + } + + public void setPlatformPlayTimeout(int platformPlayTimeout) { + this.platformPlayTimeout = platformPlayTimeout; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java b/src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java index da4e2ed..2c2ea6d 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/runner/SipDeviceRunner.java @@ -1,10 +1,10 @@ package com.genersoft.iot.vmp.conf.runner; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.core.annotation.Order; @@ -21,13 +21,13 @@ public class SipDeviceRunner implements CommandLineRunner { @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IDeviceService deviceService; @@ -44,6 +44,7 @@ if (device != null && device.getSubscribeCycleForCatalog() > 0) { // 鏌ヨ鍦ㄧ嚎璁惧閭d簺寮�鍚簡璁㈤槄锛屼负璁惧寮�鍚畾鏃剁殑鐩綍璁㈤槄 deviceService.addCatalogSubscribe(device); + deviceService.addMobilePositionSubscribe(device); } } // 閲嶇疆cseq璁℃暟 diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java index f0eca85..47cfdab 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/WebSecurityConfig.java @@ -1,6 +1,6 @@ package com.genersoft.iot.vmp.conf.security; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -29,7 +29,7 @@ private final static Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class); @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private DefaultUserDetailsServiceImpl userDetailsService; @@ -77,7 +77,7 @@ @Override public void configure(WebSecurity web) { - if (!userSetup.isInterfaceAuthentication()) { + if (!userSetting.isInterfaceAuthentication()) { web.ignoring().antMatchers("**"); }else { // 鍙互鐩存帴璁块棶鐨勯潤鎬佹暟鎹� @@ -91,7 +91,7 @@ .antMatchers("/swagger-resources/**") .antMatchers("/v3/api-docs/**") .antMatchers("/js/**"); - List<String> interfaceAuthenticationExcludes = userSetup.getInterfaceAuthenticationExcludes(); + List<String> interfaceAuthenticationExcludes = userSetting.getInterfaceAuthenticationExcludes(); for (String interfaceAuthenticationExclude : interfaceAuthenticationExcludes) { if (interfaceAuthenticationExclude.split("/").length < 4 ) { logger.warn("{}涓嶆弧瓒充袱绾х洰褰曪紝宸插拷鐣�", interfaceAuthenticationExclude); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java index 8239070..8731228 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/auth/RegisterLogicHandler.java @@ -1,6 +1,6 @@ package com.genersoft.iot.vmp.gb28181.auth; -import com.genersoft.iot.vmp.storager.impl.VideoManagerStoragerImpl; +import com.genersoft.iot.vmp.storager.impl.VideoManagerStorageImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +23,7 @@ private SIPCommander cmder; @Autowired - private VideoManagerStoragerImpl storager; + private VideoManagerStorageImpl storager; public void onRegister(Device device) { // 鍙湁绗竴娆℃敞鍐屾椂璋冪敤鏌ヨ璁惧淇℃伅锛屽闇�鏇存柊璋冪敤鏇存柊API鎺ュ彛 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java index 01d340c..d50ffb7 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java @@ -112,8 +112,22 @@ /** * 鐩綍璁㈤槄鍛ㄦ湡锛�0涓轰笉璁㈤槄 */ - private int subscribeCycleForCatalog ; + private int subscribeCycleForCatalog; + /** + * 绉诲姩璁惧浣嶇疆璁㈤槄鍛ㄦ湡锛�0涓轰笉璁㈤槄 + */ + private int subscribeCycleForMobilePosition; + + /** + * 绉诲姩璁惧浣嶇疆淇℃伅涓婃姤鏃堕棿闂撮殧,鍗曚綅:绉�,榛樿鍊�5 + */ + private int mobilePositionSubmissionInterval = 5; + + /** + * 鎶ヨ璁㈤槄鍛ㄦ湡锛�0涓轰笉璁㈤槄 + */ + private int subscribeCycleForAlarm; public String getDeviceId() { @@ -283,4 +297,28 @@ public void setSubscribeCycleForCatalog(int subscribeCycleForCatalog) { this.subscribeCycleForCatalog = subscribeCycleForCatalog; } + + public int getSubscribeCycleForMobilePosition() { + return subscribeCycleForMobilePosition; + } + + public void setSubscribeCycleForMobilePosition(int subscribeCycleForMobilePosition) { + this.subscribeCycleForMobilePosition = subscribeCycleForMobilePosition; + } + + public int getMobilePositionSubmissionInterval() { + return mobilePositionSubmissionInterval; + } + + public void setMobilePositionSubmissionInterval(int mobilePositionSubmissionInterval) { + this.mobilePositionSubmissionInterval = mobilePositionSubmissionInterval; + } + + public int getSubscribeCycleForAlarm() { + return subscribeCycleForAlarm; + } + + public void setSubscribeCycleForAlarm(int subscribeCycleForAlarm) { + this.subscribeCycleForAlarm = subscribeCycleForAlarm; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java new file mode 100644 index 0000000..24d509f --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java @@ -0,0 +1,8 @@ +package com.genersoft.iot.vmp.gb28181.bean; + +public enum InviteStreamType { + + PLAY,PLAYBACK,PUSH,PROXY,CLOUD_RECORD_PUSH,CLOUD_RECORD_PROXY + + +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java index 8df7939..8aa7b37 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java @@ -125,9 +125,9 @@ private boolean alarmSubscribe; /** - * 宸茶璁㈤槄GPS淇℃伅 + * 宸茶璁㈤槄绉诲姩浣嶇疆淇℃伅 */ - private boolean gpsSubscribe; + private boolean mobilePositionSubscribe; public Integer getId() { return id; @@ -322,11 +322,11 @@ this.alarmSubscribe = alarmSubscribe; } - public boolean isGpsSubscribe() { - return gpsSubscribe; + public boolean isMobilePositionSubscribe() { + return mobilePositionSubscribe; } - public void setGpsSubscribe(boolean gpsSubscribe) { - this.gpsSubscribe = gpsSubscribe; + public void setMobilePositionSubscribe(boolean mobilePositionSubscribe) { + this.mobilePositionSubscribe = mobilePositionSubscribe; } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java index a2c38ac..4b63ec5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/SendRtpItem.java @@ -77,9 +77,9 @@ private String CallId; /** - * 鏄惁鏄痯lay锛� false鏄痯layback + * 鎾斁绫诲瀷 */ - private boolean isPlay; + private InviteStreamType playType; private byte[] transaction; @@ -197,12 +197,12 @@ CallId = callId; } - public boolean isPlay() { - return isPlay; + public InviteStreamType getPlayType() { + return playType; } - public void setPlay(boolean play) { - isPlay = play; + public void setPlayType(InviteStreamType playType) { + this.playType = playType; } public byte[] getTransaction() { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java index ea2fa6c..5513ba2 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/DeviceOffLineDetector.java @@ -1,6 +1,6 @@ package com.genersoft.iot.vmp.gb28181.event; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; @@ -19,10 +19,10 @@ private RedisUtil redis; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; public boolean isOnline(String deviceId) { - String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + deviceId; + String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + deviceId; return redis.hasKey(key); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java index 3b611b5..e0e4a27 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java @@ -1,27 +1,20 @@ package com.genersoft.iot.vmp.gb28181.event.offline; import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener; -import com.genersoft.iot.vmp.conf.UserSetup; +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.event.SipSubscribe; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.DependsOn; import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.connection.RedisConnection; -import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.stereotype.Component; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; -import org.springframework.util.StringUtils; - -import java.util.Properties; /** * @description:璁惧蹇冭烦瓒呮椂鐩戝惉,鍊熷姪redis杩囨湡鐗规�э紝杩涜鐩戝惉锛岀洃鍚埌璇存槑璁惧蹇冭烦瓒呮椂锛屽彂閫佺绾夸簨浠� @@ -37,16 +30,16 @@ private EventPublisher publisher; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private SipSubscribe sipSubscribe; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; - public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) { - super(listenerContainer, userSetup); + public KeepaliveTimeoutListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) { + super(listenerContainer, userSetting); } @@ -61,10 +54,10 @@ String expiredKey = message.toString(); logger.debug(expiredKey); // 骞冲彴蹇冭烦鍒版湡,闇�瑕侀噸鍙�, 鍒ゆ柇鏄惁宸茬粡澶氭鏈敹鍒板績璺冲洖澶�, 澶氭鏈敹鍒�,鍒欓噸鏂板彂璧锋敞鍐�, 娉ㄥ唽灏濊瘯澶氭鏈緱鍒板洖澶�,鍒欒涓哄钩鍙扮绾� - String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetup.getServerId() + "_"; - String PLATFORM_REGISTER_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetup.getServerId() + "_"; - String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_"; - String REGISTER_INFO_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_"; + String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_"; + String PLATFORM_REGISTER_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_"; + String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_"; + String REGISTER_INFO_PREFIX = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_"; if (expiredKey.startsWith(PLATFORM_KEEPLIVEKEY_PREFIX)) { String platformGBId = expiredKey.substring(PLATFORM_KEEPLIVEKEY_PREFIX.length(),expiredKey.length()); ParentPlatform platform = storager.queryParentPlatByServerGBId(platformGBId); @@ -84,12 +77,14 @@ publisher.outlineEventPublish(deviceId, KEEPLIVEKEY_PREFIX); } }else if (expiredKey.startsWith(REGISTER_INFO_PREFIX)) { - String callid = expiredKey.substring(REGISTER_INFO_PREFIX.length()); - SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(); - eventResult.callId = callid; - eventResult.msg = "娉ㄥ唽瓒呮椂"; - eventResult.type = "register timeout"; - sipSubscribe.getErrorSubscribe(callid).response(eventResult); + String callId = expiredKey.substring(REGISTER_INFO_PREFIX.length()); + if (sipSubscribe.getErrorSubscribe(callId) != null) { + SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(); + eventResult.callId = callId; + eventResult.msg = "娉ㄥ唽瓒呮椂"; + eventResult.type = "register timeout"; + sipSubscribe.getErrorSubscribe(callId).response(eventResult); + } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java index 151b68d..9e8c647 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepliveTimeoutListener.java @@ -1,14 +1,11 @@ package com.genersoft.iot.vmp.gb28181.event.offline; import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.DependsOn; -import org.springframework.context.annotation.Lazy; import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.stereotype.Component; @@ -29,15 +26,15 @@ private EventPublisher publisher; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; - public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) { - super(listenerContainer, userSetup); + public KeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) { + super(listenerContainer, userSetting); } @Override public void init() { - if (!userSetup.getRedisConfig()) { + if (!userSetting.getRedisConfig()) { // 閰嶇疆springboot榛樿Config涓虹┖锛屽嵆涓嶈搴旂敤鍘讳慨鏀箁edis鐨勯粯璁ら厤缃紝鍥犱负Redis鏈嶅姟鍑轰簬瀹夊叏浼氱鐢–ONFIG鍛戒护缁欒繙绋嬬敤鎴蜂娇鐢� setKeyspaceNotificationsConfigParameter(""); } @@ -54,7 +51,7 @@ public void onMessage(Message message, byte[] pattern) { // 鑾峰彇澶辨晥鐨刱ey String expiredKey = message.toString(); - String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_"; + String KEEPLIVEKEY_PREFIX = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_"; if(!expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){ logger.debug("鏀跺埌redis杩囨湡鐩戝惉锛屼絾寮�澶翠笉鏄�"+KEEPLIVEKEY_PREFIX+"锛屽拷鐣�"); return; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java index 9e67191..b7992e4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java @@ -1,24 +1,21 @@ package com.genersoft.iot.vmp.gb28181.event.offline; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; 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.VideoStreamSessionManager; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; 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.context.ApplicationListener; -import org.springframework.context.annotation.DependsOn; -import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Component; import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.redis.RedisUtil; import java.util.List; @@ -36,7 +33,7 @@ private final static Logger logger = LoggerFactory.getLogger(OfflineEventListener.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private VideoStreamSessionManager streamSession; @@ -45,7 +42,7 @@ private RedisUtil redis; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private EventPublisher eventPublisher; @@ -65,7 +62,7 @@ logger.debug("璁惧绂荤嚎浜嬩欢瑙﹀彂锛宒eviceId锛�" + event.getDeviceId() + ",from:" + event.getFrom()); } - String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDeviceId(); + String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDeviceId(); switch (event.getFrom()) { // 蹇冭烦瓒呮椂瑙﹀彂鐨勭绾夸簨浠讹紝璇存槑redis涓凡鍒犻櫎锛屾棤闇�澶勭悊 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java index d3580d3..755967b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEventListener.java @@ -1,14 +1,13 @@ package com.genersoft.iot.vmp.gb28181.event.online; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; +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.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.service.IDeviceService; -import com.genersoft.iot.vmp.storager.dao.dto.User; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -16,7 +15,7 @@ import org.springframework.stereotype.Component; import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.redis.RedisUtil; import java.text.SimpleDateFormat; @@ -35,7 +34,7 @@ private final static Logger logger = LoggerFactory.getLogger(OnlineEventListener.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IDeviceService deviceService; @@ -47,7 +46,7 @@ private SipConfig sipConfig; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private EventPublisher eventPublisher; @@ -65,7 +64,7 @@ } Device device = event.getDevice(); if (device == null) return; - String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + event.getDevice().getDeviceId(); + String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + event.getDevice().getDeviceId(); Device deviceInStore = storager.queryVideoDevice(device.getDeviceId()); device.setOnline(1); switch (event.getFrom()) { @@ -103,6 +102,7 @@ // 涓婄嚎娣诲姞璁㈤槄 if (device.getSubscribeCycleForCatalog() > 0) { deviceService.addCatalogSubscribe(device); + deviceService.addMobilePositionSubscribe(device); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java index 0092657..67b297c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformKeepaliveExpire/PlatformKeepaliveExpireEventLister.java @@ -6,7 +6,7 @@ import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -14,7 +14,6 @@ import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; -import javax.sip.ResponseEvent; import javax.sip.message.Response; /** @@ -29,7 +28,7 @@ private final static Logger logger = LoggerFactory.getLogger(PlatformKeepaliveExpireEventLister.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java index 4df77a0..b6f0842 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformCycleRegisterEventLister.java @@ -3,7 +3,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -19,7 +19,7 @@ private final static Logger logger = LoggerFactory.getLogger(PlatformCycleRegisterEventLister.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private ISIPCommanderForPlatform sipCommanderFroPlatform; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java index 1b8e7ae..757c00a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java @@ -9,7 +9,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,7 +31,7 @@ private final static Logger logger = LoggerFactory.getLogger(PlatformNotRegisterEventLister.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @Autowired diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java index 3b2bd23..898e51d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/SubscribeListenerForPlatform.java @@ -3,7 +3,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -20,13 +20,13 @@ private Logger logger = LoggerFactory.getLogger(SubscribeListenerForPlatform.class); @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private DynamicTask dynamicTask; - public SubscribeListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) { - super(listenerContainer, userSetup); + public SubscribeListenerForPlatform(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) { + super(listenerContainer, userSetting); } @@ -41,7 +41,7 @@ String expiredKey = message.toString(); logger.debug(expiredKey); // 璁㈤槄鍒版湡 - String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_"; + String PLATFORM_KEEPLIVEKEY_PREFIX = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_"; if (expiredKey.startsWith(PLATFORM_KEEPLIVEKEY_PREFIX)) { // 鍙栨秷瀹氭椂浠诲姟 dynamicTask.stop(expiredKey); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index 50957f6..57ca425 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -2,17 +2,14 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; +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.event.platformNotRegister.PlatformNotRegisterEvent; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,7 +28,7 @@ private final static Logger logger = LoggerFactory.getLogger(CatalogEventLister.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @Autowired @@ -47,7 +44,7 @@ private SipConfig config; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IGbStreamService gbStreamService; @@ -64,7 +61,7 @@ if (event.getPlatformId() != null) { parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); if (parentPlatform != null && !parentPlatform.isStatus())return; - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId(); + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_Catalog_" + event.getPlatformId(); // subscribe = redisCatchStorage.getSubscribe(key); subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java index e3b3974..8a3bc84 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/CatalogDataCatch.java @@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; @@ -23,7 +23,7 @@ private DeferredResultHolder deferredResultHolder; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; public void put(String key, int total, Device device, List<DeviceChannel> deviceChannelList) { CatalogData catalogData = data.get(key); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java b/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java index 6eed17e..0051b03 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/session/VideoStreamSessionManager.java @@ -7,7 +7,7 @@ import javax.sip.Dialog; import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; import com.genersoft.iot.vmp.utils.SerializeUtils; import com.genersoft.iot.vmp.utils.redis.RedisUtil; @@ -28,7 +28,7 @@ private RedisUtil redisUtil; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; public enum SessionType { play, @@ -58,9 +58,9 @@ ssrcTransaction.setMediaServerId(mediaServerId); ssrcTransaction.setType(type); - redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); - redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId + "_" + stream, ssrcTransaction); } @@ -70,7 +70,7 @@ byte[] dialogByteArray = SerializeUtils.serialize(dialog); ssrcTransaction.setDialog(dialogByteArray); } - redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + redisUtil.set(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream(), ssrcTransaction); } @@ -105,7 +105,7 @@ public SsrcTransaction getSsrcTransaction(String deviceId, String channelId, String callId, String stream){ if (StringUtils.isEmpty(callId)) callId ="*"; if (StringUtils.isEmpty(stream)) stream ="*"; - String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; + String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; List<Object> scanResult = redisUtil.scan(key); if (scanResult.size() == 0) return null; return (SsrcTransaction)redisUtil.get((String) scanResult.get(0)); @@ -116,7 +116,7 @@ if (StringUtils.isEmpty(channelId)) channelId ="*"; if (StringUtils.isEmpty(callId)) callId ="*"; if (StringUtils.isEmpty(stream)) stream ="*"; - String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; + String key = VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + callId+ "_" + stream; List<Object> scanResult = redisUtil.scan(key); if (scanResult.size() == 0) return null; List<SsrcTransaction> result = new ArrayList<>(); @@ -141,13 +141,13 @@ public void remove(String deviceId, String channelId, String stream) { SsrcTransaction ssrcTransaction = getSsrcTransaction(deviceId, channelId, null, stream); if (ssrcTransaction == null) return; - redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetup.getServerId() + "_" + redisUtil.del(VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX + userSetting.getServerId() + "_" + deviceId + "_" + channelId + "_" + ssrcTransaction.getCallId() + "_" + ssrcTransaction.getStream()); } public List<SsrcTransaction> getAllSsrc() { - List<Object> ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetup.getServerId() + "_" )); + List<Object> ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId() + "_" )); List<SsrcTransaction> result= new ArrayList<>(); for (int i = 0; i < ssrcTransactionKeys.size(); i++) { String key = (String)ssrcTransactionKeys.get(i); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/GPSSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/GPSSubscribeTask.java index 4b21638..a2716e3 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/GPSSubscribeTask.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/GPSSubscribeTask.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.task; +import com.alibaba.fastjson.JSON; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; @@ -7,7 +8,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import java.text.SimpleDateFormat; import java.util.List; @@ -15,7 +16,7 @@ public class GPSSubscribeTask implements Runnable{ private IRedisCatchStorage redisCatchStorage; - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; private ISIPCommanderForPlatform sipCommanderForPlatform; private SubscribeHolder subscribeHolder; private String platformId; @@ -24,7 +25,7 @@ private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - public GPSSubscribeTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorager storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) { + public GPSSubscribeTask(IRedisCatchStorage redisCatchStorage, ISIPCommanderForPlatform sipCommanderForPlatform, IVideoManagerStorage storager, String platformId, String sn, String key, SubscribeHolder subscribeInfo) { this.redisCatchStorage = redisCatchStorage; this.storager = storager; this.platformId = platformId; @@ -48,21 +49,18 @@ for (GbStream gbStream : gbStreams) { String gbId = gbStream.getGbId(); GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); - if (gbStream.isStatus()) { - if (gpsMsgInfo != null) { - // 鍙戦�丟PS娑堟伅 - sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); - }else { - // 娌℃湁鍦╮edis鎵惧埌鏂扮殑娑堟伅灏变娇鐢ㄦ暟鎹簱鐨勬秷鎭� - gpsMsgInfo = new GPSMsgInfo(); - gpsMsgInfo.setId(gbId); - gpsMsgInfo.setLat(gbStream.getLongitude()); - gpsMsgInfo.setLng(gbStream.getLongitude()); - // 鍙戦�丟PS娑堟伅 - sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); - } + if (gpsMsgInfo != null) { + // 鍙戦�丟PS娑堟伅 + sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); + }else { + // 娌℃湁鍦╮edis鎵惧埌鏂扮殑娑堟伅灏变娇鐢ㄦ暟鎹簱鐨勬秷鎭� + gpsMsgInfo = new GPSMsgInfo(); + gpsMsgInfo.setId(gbId); + gpsMsgInfo.setLat(gbStream.getLongitude()); + gpsMsgInfo.setLng(gbStream.getLongitude()); + // 鍙戦�丟PS娑堟伅 + sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); } - } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index 9cd89e0..a33640d 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -305,11 +305,9 @@ * 璁㈤槄銆佸彇娑堣闃呯Щ鍔ㄤ綅缃� * * @param device 瑙嗛璁惧 - * @param expires 璁㈤槄瓒呮椂鏃堕棿锛堝��=0鏃朵负鍙栨秷璁㈤槄锛� - * @param interval 涓婃姤鏃堕棿闂撮殧 * @return true = 鍛戒护鍙戦�佹垚鍔� */ - boolean mobilePositionSubscribe(Device device, int expires, int interval); + boolean mobilePositionSubscribe(Device device, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent); /** * 璁㈤槄銆佸彇娑堣闃呮姤璀︿俊鎭� diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java index 0f2242c..25a2f25 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java @@ -4,7 +4,7 @@ import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.DynamicTask; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.InviteStreamCallback; import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo; @@ -20,7 +20,7 @@ import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.SipProviderImpl; import gov.nist.javax.sip.SipStackImpl; import gov.nist.javax.sip.message.SIPRequest; @@ -71,13 +71,13 @@ private VideoStreamSessionManager streamSession; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private ZLMHttpHookSubscribe subscribe; @@ -236,6 +236,7 @@ ptzXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); ptzXml.append("<PTZCmd>" + cmdStr + "</PTZCmd>\r\n"); ptzXml.append("<Info>\r\n"); + ptzXml.append("<ControlPriority>5</ControlPriority>\r\n"); ptzXml.append("</Info>\r\n"); ptzXml.append("</Control>\r\n"); @@ -277,6 +278,7 @@ ptzXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); ptzXml.append("<PTZCmd>" + cmdStr + "</PTZCmd>\r\n"); ptzXml.append("<Info>\r\n"); + ptzXml.append("<ControlPriority>5</ControlPriority>\r\n"); ptzXml.append("</Info>\r\n"); ptzXml.append("</Control>\r\n"); @@ -311,6 +313,7 @@ ptzXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); ptzXml.append("<PTZCmd>" + cmdString + "</PTZCmd>\r\n"); ptzXml.append("<Info>\r\n"); + ptzXml.append("<ControlPriority>5</ControlPriority>\r\n"); ptzXml.append("</Info>\r\n"); ptzXml.append("</Control>\r\n"); @@ -365,7 +368,7 @@ content.append("c=IN IP4 "+ mediaServerItem.getSdpIp() +"\r\n"); content.append("t=0 0\r\n"); - if (userSetup.isSeniorSdp()) { + 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)) { @@ -465,7 +468,7 @@ String streamMode = device.getStreamMode().toUpperCase(); - if (userSetup.isSeniorSdp()) { + 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)) { @@ -575,7 +578,7 @@ String streamMode = device.getStreamMode().toUpperCase(); - if (userSetup.isSeniorSdp()) { + 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)) { @@ -1433,11 +1436,9 @@ * 璁㈤槄銆佸彇娑堣闃呯Щ鍔ㄤ綅缃� * * @param device 瑙嗛璁惧 - * @param expires 璁㈤槄瓒呮椂鏃堕棿 - * @param interval 涓婃姤鏃堕棿闂撮殧 * @return true = 鍛戒护鍙戦�佹垚鍔� */ - public boolean mobilePositionSubscribe(Device device, int expires, int interval) { + public boolean mobilePositionSubscribe(Device device, SipSubscribe.Event okEvent ,SipSubscribe.Event errorEvent) { try { StringBuffer subscribePostitionXml = new StringBuffer(200); String charset = device.getCharset(); @@ -1446,8 +1447,8 @@ subscribePostitionXml.append("<CmdType>MobilePosition</CmdType>\r\n"); subscribePostitionXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n"); subscribePostitionXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n"); - if (expires > 0) { - subscribePostitionXml.append("<Interval>" + String.valueOf(interval) + "</Interval>\r\n"); + if (device.getSubscribeCycleForMobilePosition() > 0) { + subscribePostitionXml.append("<Interval>" + String.valueOf(device.getMobilePositionSubmissionInterval()) + "</Interval>\r\n"); } subscribePostitionXml.append("</Query>\r\n"); @@ -1456,8 +1457,8 @@ CallIdHeader callIdHeader = device.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() : udpSipProvider.getNewCallId(); - Request request = headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), "z9hG4bK-viaPos-" + tm, "fromTagPos" + tm, null, expires, "presence" ,callIdHeader); //Position;id=" + tm.substring(tm.length() - 4)); - transmitRequest(device, request); + Request request = headerProvider.createSubscribeRequest(device, subscribePostitionXml.toString(), "z9hG4bK-viaPos-" + tm, "fromTagPos" + tm, null, device.getSubscribeCycleForMobilePosition(), "presence" ,callIdHeader); //Position;id=" + tm.substring(tm.length() - 4)); + transmitRequest(device, request, errorEvent, okEvent); return true; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index a67bbbd..0edbae4 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -372,7 +372,6 @@ : udpSipProvider.getNewCallId(); callIdHeader.setCallId(subscribeInfo.getCallId()); -// sendNotify(parentPlatform, deviceStatusXml.toString(), subscribeInfo, eventResult -> { logger.error("鍙戦�丯OTIFY閫氱煡娑堟伅澶辫触銆傞敊璇細{} {}", eventResult.statusCode, eventResult.msg); }, null); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java index e487447..bdea90f 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java @@ -2,7 +2,7 @@ import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.bean.InviteStreamType; import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem; import com.genersoft.iot.vmp.gb28181.bean.SsrcTransaction; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; @@ -13,8 +13,9 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; +import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.SerializeUtils; import gov.nist.javax.sip.stack.SIPDialog; import org.slf4j.Logger; @@ -50,7 +51,7 @@ private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private ZLMRTPServerFactory zlmrtpServerFactory; @@ -99,10 +100,20 @@ redisCatchStorage.deleteSendRTPServer(platformGbId, channelId, callIdHeader.getCallId(), null); int totalReaderCount = zlmrtpServerFactory.totalReaderCount(mediaInfo, sendRtpItem.getApp(), streamId); if (totalReaderCount <= 0) { - logger.info("鏀跺埌bye: {}鏃犲叾瀹冭鐪嬭�咃紝閫氱煡璁惧鍋滄鎺ㄦ祦", streamId); - if (sendRtpItem.isPlay()) { + logger.info("鏀跺埌bye: {} 鏃犲叾瀹冭鐪嬭�咃紝閫氱煡璁惧鍋滄鎺ㄦ祦", streamId); + if (sendRtpItem.getPlayType().equals(InviteStreamType.PLAY)) { cmder.streamByeCmd(sendRtpItem.getDeviceId(), channelId, streamId, null); } + if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) { + MessageForPushChannel messageForPushChannel = new MessageForPushChannel(); + messageForPushChannel.setType(0); + messageForPushChannel.setGbId(sendRtpItem.getChannelId()); + messageForPushChannel.setApp(sendRtpItem.getApp()); + messageForPushChannel.setStream(sendRtpItem.getStreamId()); + messageForPushChannel.setMediaServerId(sendRtpItem.getMediaServerId()); + messageForPushChannel.setPlatFormId(sendRtpItem.getPlatformId()); + redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel); + } } } // 鍙兘鏄澶囦富鍔ㄥ仠姝� diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index b1c7a31..5580a9e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -1,14 +1,12 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; -import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.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.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.callback.RequestMessage; 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.cmd.impl.SIPCommanderFroPlatform; @@ -16,20 +14,19 @@ 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.ZLMHttpHookSubscribe; +import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IPlayService; +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.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.SerializeUtils; -import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; import gov.nist.javax.sdp.TimeDescriptionImpl; import gov.nist.javax.sdp.fields.TimeField; -import gov.nist.javax.sip.address.AddressImpl; -import gov.nist.javax.sip.address.SipUri; -import gov.nist.javax.sip.header.Subject; +import javafx.application.Platform; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.InitializingBean; @@ -37,20 +34,14 @@ import org.springframework.stereotype.Component; import javax.sdp.*; -import javax.sip.InvalidArgumentException; -import javax.sip.RequestEvent; -import javax.sip.ServerTransaction; -import javax.sip.SipException; +import javax.sip.*; import javax.sip.address.SipURI; import javax.sip.header.CallIdHeader; -import javax.sip.header.FromHeader; -import javax.sip.header.Header; import javax.sip.message.Request; import javax.sip.message.Response; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.List; import java.util.Vector; /** @@ -68,7 +59,7 @@ private SIPCommanderFroPlatform cmderFroPlatform; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -96,6 +87,12 @@ @Autowired private VideoStreamSessionManager sessionManager; + + @Autowired + private UserSetting userSetting; + + @Autowired + private ZLMMediaListManager mediaListManager; @Override @@ -151,12 +148,6 @@ if (mediaServerItem == null) { logger.info("[ app={}, stream={} ]鎵句笉鍒皕lm {}锛岃繑鍥�410",gbStream.getApp(), gbStream.getStream(), mediaServerId); responseAck(evt, Response.GONE); - return; - } - Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, gbStream.getApp(), gbStream.getStream()); - if (!streamReady ) { - logger.info("[ app={}, stream={} ]閫氶亾绂荤嚎锛岃繑鍥�400",gbStream.getApp(), gbStream.getStream()); - responseAck(evt, Response.BAD_REQUEST, "channel [" + gbStream.getGbId() + "] offline"); return; } responseAck(evt, Response.CALL_IS_BEING_FORWARDED); // 閫氶亾瀛樺湪锛屽彂181锛屽懠鍙浆鎺ヤ腑 @@ -273,13 +264,11 @@ return; } sendRtpItem.setCallId(callIdHeader.getCallId()); - sendRtpItem.setPlay("Play".equals(sessionName)); + sendRtpItem.setPlayType("Play".equals(sessionName)?InviteStreamType.PLAY:InviteStreamType.PLAYBACK); byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog()); sendRtpItem.setDialog(dialogByteArray); byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction()); sendRtpItem.setTransaction(transactionByteArray); - - Long finalStartTime = startTime; Long finalStopTime = stopTime; ZLMHttpHookSubscribe.Event hookEvent = (mediaServerItemInUSe, responseJSON)->{ @@ -315,7 +304,7 @@ mediaServerService.releaseSsrc(mediaServerItemInUSe.getId(), ssrc); // 鍥炲bye cmderFroPlatform.streamByeCmd(platform, callIdHeader.getCallId()); - }, 60); + }, 60*1000); responseSdpAck(evt, content.toString(), platform); } catch (SipException e) { @@ -340,7 +329,7 @@ }); sendRtpItem.setApp("rtp"); if ("Playback".equals(sessionName)) { - sendRtpItem.setPlay(false); + sendRtpItem.setPlayType(InviteStreamType.PLAYBACK); SSRCInfo ssrcInfo = mediaServerService.openRTPServer(mediaServerItem, null, true); sendRtpItem.setStreamId(ssrcInfo.getStream()); // 鍐欏叆redis锛� 瓒呮椂鏃跺洖澶� @@ -370,7 +359,7 @@ } }); }else { - sendRtpItem.setPlay(true); + sendRtpItem.setPlayType(InviteStreamType.PLAY); SsrcTransaction playTransaction = sessionManager.getSsrcTransaction(device.getDeviceId(), channelId, "play", null); if (playTransaction != null) { Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, "rtp", playTransaction.getStream()); @@ -401,56 +390,105 @@ } } }else if (gbStream != null) { - SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, - gbStream.getApp(), gbStream.getStream(), channelId, - mediaTransmissionTCP); - if (tcpActive != null) { - sendRtpItem.setTcpActive(tcpActive); - } - if (sendRtpItem == null) { - logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�"); - responseAck(evt, Response.BUSY_HERE); - return; - } + Boolean streamReady = zlmrtpServerFactory.isStreamReady(mediaServerItem, gbStream.getApp(), gbStream.getStream()); + if (!streamReady ) { + if ("proxy".equals(gbStream.getStreamType())) { + // TODO 鎺у埗鍚敤浠ヤ娇璁惧涓婄嚎 + logger.info("[ app={}, stream={} ]閫氶亾绂荤嚎锛屽惎鐢ㄦ祦鍚庡紑濮嬫帹娴�",gbStream.getApp(), gbStream.getStream()); + responseAck(evt, Response.BAD_REQUEST, "channel [" + gbStream.getGbId() + "] offline"); + }else if ("push".equals(gbStream.getStreamType())) { + // 鍙戦�乺edis娑堟伅浠ヤ娇璁惧涓婄嚎 + logger.info("[ app={}, stream={} ]閫氶亾绂荤嚎锛屽彂閫乺edis淇℃伅鎺у埗璁惧寮�濮嬫帹娴�",gbStream.getApp(), gbStream.getStream()); + MessageForPushChannel messageForPushChannel = new MessageForPushChannel(); + messageForPushChannel.setType(1); + messageForPushChannel.setGbId(gbStream.getGbId()); + messageForPushChannel.setApp(gbStream.getApp()); + messageForPushChannel.setStream(gbStream.getStream()); + // TODO 鑾峰彇浣庤礋杞界殑鑺傜偣 + messageForPushChannel.setMediaServerId(gbStream.getMediaServerId()); + messageForPushChannel.setPlatFormId(platform.getServerGBId()); + messageForPushChannel.setPlatFormName(platform.getName()); + redisCatchStorage.sendStreamPushRequestedMsg(messageForPushChannel); + // 璁剧疆瓒呮椂 + dynamicTask.startDelay(callIdHeader.getCallId(), ()->{ + logger.info("[ app={}, stream={} ] 绛夊緟璁惧寮�濮嬫帹娴佽秴鏃�", gbStream.getApp(), gbStream.getStream()); + try { + mediaListManager.removedChannelOnlineEventLister(gbStream.getGbId()); + responseAck(evt, Response.REQUEST_TIMEOUT); // 瓒呮椂 + } catch (SipException e) { + e.printStackTrace(); + } catch (InvalidArgumentException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } + }, userSetting.getPlatformPlayTimeout()); + // 娣诲姞鐩戝惉 + MediaServerItem finalMediaServerItem = mediaServerItem; + int finalPort = port; + boolean finalMediaTransmissionTCP = mediaTransmissionTCP; + Boolean finalTcpActive = tcpActive; + mediaListManager.addChannelOnlineEventLister(gbStream.getGbId(), (app, stream)->{ + SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(finalMediaServerItem, addressStr, finalPort, ssrc, requesterId, + app, stream, channelId, finalMediaTransmissionTCP); - // 鍐欏叆redis锛� 瓒呮椂鏃跺洖澶� - sendRtpItem.setStatus(1); - sendRtpItem.setCallId(callIdHeader.getCallId()); - byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog()); - sendRtpItem.setDialog(dialogByteArray); - byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction()); - sendRtpItem.setTransaction(transactionByteArray); - redisCatchStorage.updateSendRTPSever(sendRtpItem); - StringBuffer content = new StringBuffer(200); - content.append("v=0\r\n"); - content.append("o="+ channelId +" 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"); - content.append("m=video "+ sendRtpItem.getLocalPort()+" 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"); + if (sendRtpItem == null) { + logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�"); + try { + responseAck(evt, Response.BUSY_HERE); + } catch (SipException e) { + e.printStackTrace(); + } catch (InvalidArgumentException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } + return; + } + if (finalTcpActive != null) { + sendRtpItem.setTcpActive(finalTcpActive); + } + sendRtpItem.setPlayType(InviteStreamType.PUSH); + // 鍐欏叆redis锛� 瓒呮椂鏃跺洖澶� + sendRtpItem.setStatus(1); + sendRtpItem.setCallId(callIdHeader.getCallId()); + byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog()); + sendRtpItem.setDialog(dialogByteArray); + byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction()); + sendRtpItem.setTransaction(transactionByteArray); + redisCatchStorage.updateSendRTPSever(sendRtpItem); + sendStreamAck(finalMediaServerItem, sendRtpItem, platform, evt); + + }); } - } - content.append("y="+ ssrc + "\r\n"); - content.append("f=\r\n"); + }else { + SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, + gbStream.getApp(), gbStream.getStream(), channelId, + mediaTransmissionTCP); - try { - responseSdpAck(evt, content.toString(), platform); - } catch (SipException e) { - e.printStackTrace(); - } catch (InvalidArgumentException e) { - e.printStackTrace(); - } catch (ParseException e) { - e.printStackTrace(); + + if (sendRtpItem == null) { + logger.warn("鏈嶅姟鍣ㄧ鍙h祫婧愪笉瓒�"); + responseAck(evt, Response.BUSY_HERE); + return; + } + if (tcpActive != null) { + sendRtpItem.setTcpActive(tcpActive); + } + sendRtpItem.setPlayType(InviteStreamType.PUSH); + // 鍐欏叆redis锛� 瓒呮椂鏃跺洖澶� + sendRtpItem.setStatus(1); + sendRtpItem.setCallId(callIdHeader.getCallId()); + byte[] dialogByteArray = SerializeUtils.serialize(evt.getDialog()); + sendRtpItem.setDialog(dialogByteArray); + byte[] transactionByteArray = SerializeUtils.serialize(evt.getServerTransaction()); + sendRtpItem.setTransaction(transactionByteArray); + redisCatchStorage.updateSendRTPSever(sendRtpItem); + sendStreamAck(mediaServerItem, sendRtpItem, platform, evt); } + + } } @@ -466,6 +504,39 @@ } } + public void sendStreamAck(MediaServerItem mediaServerItem, 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"); + content.append("m=video "+ sendRtpItem.getLocalPort()+" 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 { + responseSdpAck(evt, content.toString(), platform); + } catch (SipException e) { + e.printStackTrace(); + } catch (InvalidArgumentException e) { + e.printStackTrace(); + } catch (ParseException e) { + e.printStackTrace(); + } + } + public void inviteFromDeviceHandle(RequestEvent evt, String requesterId) throws InvalidArgumentException, ParseException, SipException, SdpException { // 闈炰笂绾у钩鍙拌姹傦紝鏌ヨ鏄惁璁惧璇锋眰锛堥�氬父涓烘帴鏀惰闊冲箍鎾殑璁惧锛� diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index 3961eea..1270202 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -1,8 +1,9 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; +import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; @@ -16,7 +17,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.GpsUtil; import com.genersoft.iot.vmp.utils.redis.RedisUtil; import org.dom4j.DocumentException; @@ -46,10 +47,10 @@ private final static Logger logger = LoggerFactory.getLogger(NotifyRequestProcessor.class); @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private EventPublisher eventPublisher; @@ -109,11 +110,15 @@ */ 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); + MobilePosition mobilePosition = new MobilePosition(); Element deviceIdElement = rootElement.element("DeviceID"); - String deviceId = deviceIdElement.getTextTrim().toString(); + String channelId = deviceIdElement.getTextTrim().toString(); Device device = redisCatchStorage.getDevice(deviceId); if (device != null) { if (!StringUtils.isEmpty(device.getName())) { @@ -121,7 +126,9 @@ } } mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID")); - mobilePosition.setTime(XmlUtil.getText(rootElement, "Time")); + mobilePosition.setChannelId(channelId); + String time = XmlUtil.getText(rootElement, "Time"); + mobilePosition.setTime(time); mobilePosition.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude"))); mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude"))); if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) { @@ -140,16 +147,27 @@ mobilePosition.setAltitude(0.0); } mobilePosition.setReportSource("Mobile Position"); - BaiduPoint bp = new BaiduPoint(); - bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude())); + BaiduPoint bp = GpsUtil.Wgs84ToBd09(String.valueOf(mobilePosition.getLongitude()), String.valueOf(mobilePosition.getLatitude())); logger.info("鐧惧害鍧愭爣锛�" + bp.getBdLng() + ", " + bp.getBdLat()); mobilePosition.setGeodeticSystem("BD-09"); mobilePosition.setCnLng(bp.getBdLng()); mobilePosition.setCnLat(bp.getBdLat()); - if (!userSetup.getSavePositionHistory()) { + if (!userSetting.getSavePositionHistory()) { storager.clearMobilePositionsByDeviceId(deviceId); } storager.insertMobilePosition(mobilePosition); + storager.updateChannelPotion(deviceId, channelId, mobilePosition.getLongitude(), mobilePosition.getLatitude() ); + // 鍙戦�乺edis娑堟伅銆� 閫氱煡浣嶇疆淇℃伅鐨勫彉鍖� + JSONObject jsonObject = new JSONObject(); + jsonObject.put("time", time); + 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); responseAck(evt, Response.OK); } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { e.printStackTrace(); @@ -209,7 +227,7 @@ mobilePosition.setGeodeticSystem("BD-09"); mobilePosition.setCnLng(bp.getBdLng()); mobilePosition.setCnLat(bp.getBdLat()); - if (!userSetup.getSavePositionHistory()) { + if (!userSetting.getSavePositionHistory()) { storager.clearMobilePositionsByDeviceId(deviceId); } storager.insertMobilePosition(mobilePosition); @@ -321,7 +339,7 @@ public void setCmder(SIPCommander cmder) { } - public void setStorager(IVideoManagerStorager storager) { + public void setStorager(IVideoManagerStorage storager) { this.storager = storager; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java index cb8b723..54a5204 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/RegisterRequestProcessor.java @@ -11,7 +11,7 @@ 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.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.RequestEventExt; import gov.nist.javax.sip.address.AddressImpl; import gov.nist.javax.sip.address.SipUri; @@ -56,7 +56,7 @@ private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private EventPublisher publisher; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java index 4acec14..2cd5b00 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/SubscribeRequestProcessor.java @@ -2,7 +2,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.CmdType; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; @@ -15,8 +15,7 @@ import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; -import com.genersoft.iot.vmp.utils.SerializeUtils; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.SipProviderImpl; import org.dom4j.DocumentException; import org.dom4j.Element; @@ -30,7 +29,6 @@ import javax.sip.*; import javax.sip.header.ExpiresHeader; -import javax.sip.header.ToHeader; import javax.sip.message.Request; import javax.sip.message.Response; import java.text.ParseException; @@ -54,7 +52,7 @@ private ISIPCommanderForPlatform sipCommanderForPlatform; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Lazy @Autowired @@ -70,7 +68,7 @@ private DynamicTask dynamicTask; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired @@ -135,12 +133,21 @@ /** * 澶勭悊绉诲姩浣嶇疆璁㈤槄娑堟伅 */ - private void processNotifyMobilePosition(RequestEvent evt, Element rootElement) { + private void processNotifyMobilePosition(RequestEvent evt, Element rootElement) throws SipException { String platformId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); String deviceID = XmlUtil.getText(rootElement, "DeviceID"); + ParentPlatform platform = storager.queryParentPlatByServerGBId(platformId); SubscribeInfo subscribeInfo = new SubscribeInfo(evt, platformId); + if (evt.getServerTransaction() == null) { + ServerTransaction serverTransaction = platform.getTransport().equals("TCP") ? tcpSipProvider.getNewServerTransaction(evt.getRequest()) + : udpSipProvider.getNewServerTransaction(evt.getRequest()); + subscribeInfo.setTransaction(serverTransaction); + Dialog dialog = serverTransaction.getDialog(); + dialog.terminateOnBye(false); + subscribeInfo.setDialog(dialog); + } String sn = XmlUtil.getText(rootElement, "SN"); - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_MobilePosition_" + platformId; + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_MobilePosition_" + platformId; logger.info("鎺ユ敹鍒皗}鐨凪obilePosition璁㈤槄", platformId); StringBuilder resultXml = new StringBuilder(200); resultXml.append("<?xml version=\"1.0\" ?>\r\n") @@ -193,7 +200,7 @@ subscribeInfo.setDialog(dialog); } String sn = XmlUtil.getText(rootElement, "SN"); - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + platformId; + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_Catalog_" + platformId; logger.info("鎺ユ敹鍒皗}鐨凜atalog璁㈤槄", platformId); StringBuilder resultXml = new StringBuilder(200); resultXml.append("<?xml version=\"1.0\" ?>\r\n") diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index a0c1a38..4f1249a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -11,7 +11,7 @@ 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.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.DocumentException; import org.dom4j.Element; import org.slf4j.Logger; @@ -43,7 +43,7 @@ private SIPProcessorObserver sipProcessorObserver; @Autowired - private IVideoManagerStorager storage; + private IVideoManagerStorage storage; @Autowired private SipSubscribe sipSubscribe; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index 980ec5d..089cbc9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -8,8 +8,7 @@ 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.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.SpringBeanFactory; import gov.nist.javax.sip.SipStackImpl; import org.dom4j.Element; @@ -41,7 +40,7 @@ private ControlMessageHandler controlMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommander cmder; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index 8f412f7..302ceda 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -1,7 +1,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; @@ -10,7 +10,7 @@ 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.service.IDeviceAlarmService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.GpsUtil; import org.dom4j.Element; import org.slf4j.Logger; @@ -37,13 +37,13 @@ private EventPublisher publisher; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private SipConfig sipConfig; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IDeviceAlarmService deviceAlarmService; @@ -99,7 +99,7 @@ mobilePosition.setGeodeticSystem("BD-09"); mobilePosition.setCnLng(bp.getBdLng()); mobilePosition.setCnLat(bp.getBdLat()); - if (!userSetup.getSavePositionHistory()) { + if (!userSetting.getSavePositionHistory()) { storager.clearMobilePositionsByDeviceId(device.getDeviceId()); } storager.insertMobilePosition(mobilePosition); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java index a77179c..fc7e233 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java @@ -1,18 +1,13 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.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.transmit.callback.DeferredResultHolder; 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.storager.IVideoManagerStorager; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; 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; @@ -28,20 +23,16 @@ @Component public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { - private Logger logger = LoggerFactory.getLogger(CatalogNotifyMessageHandler.class); private final String cmdType = "Catalog"; @Autowired private NotifyMessageHandler notifyMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storage; @Autowired private SIPCommanderFroPlatform cmderFroPlatform; - - @Autowired - private SipConfig config; @Override public void afterPropertiesSet() throws Exception { @@ -64,12 +55,12 @@ Element snElement = rootElement.element("SN"); String sn = snElement.getText(); // 鍑嗗鍥炲閫氶亾淇℃伅 - List<DeviceChannelInPlatform> deviceChannels = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); + List<DeviceChannelInPlatform> deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); // 鏌ヨ鍏宠仈鐨勭洿鎾�氶亾 - List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); + List<GbStream> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); int size = deviceChannels.size() + gbStreams.size(); // 鍥炲鐩綍淇℃伅 - List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); + List<PlatformCatalog> catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId()); if (catalogs.size() > 0) { for (PlatformCatalog catalog : catalogs) { if (catalog.getParentId().equals(catalog.getPlatformId())) { @@ -101,7 +92,7 @@ if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) { channel.setCatalogId(parentPlatform.getDeviceGBId()); } - DeviceChannel deviceChannel = storager.queryChannel(channel.getDeviceId(), channel.getChannelId()); + DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId()); deviceChannel.setParental(0); deviceChannel.setParentId(channel.getCatalogId()); deviceChannel.setCivilCode(parentPlatform.getDeviceGBId().substring(0, 6)); @@ -140,13 +131,7 @@ // 鍥炲鏃犻�氶亾 cmderFroPlatform.catalogQuery(null, parentPlatform, sn, fromHeader.getTag(), size); } - } catch (SipException e) { - e.printStackTrace(); - } catch (InvalidArgumentException e) { - e.printStackTrace(); - } catch (ParseException e) { - e.printStackTrace(); - } catch (InterruptedException e) { + } catch (SipException | InvalidArgumentException | ParseException | InterruptedException e) { e.printStackTrace(); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java index edd9fe8..ccb8039 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/KeepaliveNotifyMessageHandler.java @@ -7,9 +7,8 @@ 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.service.IDeviceService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -17,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.util.StringUtils; -import springfox.documentation.service.Header; import javax.sip.InvalidArgumentException; import javax.sip.RequestEvent; @@ -39,7 +37,7 @@ private EventPublisher publisher; @Autowired - private IVideoManagerStorager videoManagerStorager; + private IVideoManagerStorage videoManagerStorager; @Autowired private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java index ab7e5f6..471b2d7 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java @@ -1,6 +1,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; @@ -9,7 +9,7 @@ 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.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.GpsUtil; import org.dom4j.DocumentException; import org.dom4j.Element; @@ -38,10 +38,10 @@ private NotifyMessageHandler notifyMessageHandler; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Override public void afterPropertiesSet() throws Exception { @@ -85,7 +85,7 @@ mobilePosition.setGeodeticSystem("BD-09"); mobilePosition.setCnLng(bp.getBdLng()); mobilePosition.setCnLat(bp.getBdLat()); - if (!userSetup.getSavePositionHistory()) { + if (!userSetting.getSavePositionHistory()) { storager.clearMobilePositionsByDeviceId(device.getDeviceId()); } storager.insertMobilePosition(mobilePosition); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java index 60cf4d0..8c884d5 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/AlarmQueryMessageHandler.java @@ -2,17 +2,13 @@ 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.GbStream; 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.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.IVideoManagerStorager; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -23,10 +19,8 @@ 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.List; @Component public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { @@ -38,7 +32,7 @@ private QueryMessageHandler queryMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommanderFroPlatform cmderFroPlatform; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java index 40e5297..a953bd9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java @@ -8,8 +8,7 @@ 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.IVideoManagerStorager; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -35,7 +34,7 @@ private QueryMessageHandler queryMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommanderFroPlatform cmderFroPlatform; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java index c56151c..64df786 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceStatusQueryMessageHandler.java @@ -8,7 +8,7 @@ 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.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +33,7 @@ private QueryMessageHandler queryMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommanderFroPlatform cmderFroPlatform; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java index 460f0f9..efd6ffd 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java @@ -4,16 +4,14 @@ 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.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.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.gb28181.utils.DateUtil; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import org.dom4j.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +37,7 @@ private QueryMessageHandler queryMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommanderFroPlatform cmderFroPlatform; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index 47ef6fa..cc54ec9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -2,7 +2,7 @@ import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; @@ -15,7 +15,7 @@ import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.GpsUtil; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import org.dom4j.DocumentException; @@ -34,11 +34,8 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Date; import java.util.Iterator; import java.util.List; - -import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.getText; @Component public class CatalogResponseMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { @@ -52,7 +49,7 @@ private ResponseMessageHandler responseMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private DeferredResultHolder deferredResultHolder; @@ -71,7 +68,7 @@ //by brewswang @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -224,7 +221,7 @@ mobilePosition.setGeodeticSystem("BD-09"); mobilePosition.setCnLng(bp.getBdLng()); mobilePosition.setCnLat(bp.getBdLat()); - if (!userSetup.getSavePositionHistory()) { + if (!userSetting.getSavePositionHistory()) { storager.clearMobilePositionsByDeviceId(deviceId); } storager.insertMobilePosition(mobilePosition); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java index 78fc936..855797e 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java @@ -11,7 +11,7 @@ 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.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.DocumentException; import org.dom4j.Element; import org.slf4j.Logger; @@ -39,7 +39,7 @@ private ResponseMessageHandler responseMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private DeferredResultHolder deferredResultHolder; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java index b456386..dca2866 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java @@ -1,6 +1,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.BaiduPoint; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.MobilePosition; @@ -9,7 +9,7 @@ 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.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.GpsUtil; import org.dom4j.DocumentException; import org.dom4j.Element; @@ -38,10 +38,10 @@ private ResponseMessageHandler responseMessageHandler; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Override public void afterPropertiesSet() throws Exception { @@ -85,7 +85,7 @@ mobilePosition.setGeodeticSystem("BD-09"); mobilePosition.setCnLng(bp.getBdLng()); mobilePosition.setCnLat(bp.getBdLat()); - if (!userSetup.getSavePositionHistory()) { + if (!userSetting.getSavePositionHistory()) { storager.clearMobilePositionsByDeviceId(device.getDeviceId()); } storager.insertMobilePosition(mobilePosition); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java index 6c33406..ed93774 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/response/impl/RegisterResponseProcessor.java @@ -7,7 +7,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -33,7 +33,7 @@ private ISIPCommanderForPlatform sipCommanderForPlatform; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index c3c30a6..94ea4e3 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -2,12 +2,10 @@ import java.util.ArrayList; import java.util.List; -import java.util.UUID; import com.alibaba.fastjson.JSON; import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.MediaConfig; -import com.genersoft.iot.vmp.conf.UserSetup; +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.GbStream; @@ -17,9 +15,8 @@ import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; import com.genersoft.iot.vmp.media.zlm.dto.*; import com.genersoft.iot.vmp.service.*; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -54,7 +51,7 @@ private IPlayService playService; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -81,7 +78,7 @@ private ZLMHttpHookSubscribe subscribe; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private VideoStreamSessionManager sessionManager; @@ -189,6 +186,12 @@ ret.put("code", 0); ret.put("msg", "success"); ret.put("enable_hls", true); + if (json.getInteger("originType") == 1 + || json.getInteger("originType") == 2 + || json.getInteger("originType") == 3) { + ret.put("enable_audio", true); + } + String mediaServerId = json.getString("mediaServerId"); ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json); if (subscribe != null) { @@ -203,9 +206,9 @@ String app = json.getString("app"); String stream = json.getString("stream"); if ("rtp".equals(app)) { - ret.put("enable_mp4", userSetup.getRecordSip()); + ret.put("enable_mp4", userSetting.getRecordSip()); }else { - ret.put("enable_mp4", userSetup.isRecordPushLive()); + ret.put("enable_mp4", userSetting.isRecordPushLive()); } List<SsrcTransaction> ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, stream); if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) { @@ -412,7 +415,7 @@ if (type != null) { // 鍙戦�佹祦鍙樺寲redis娑堟伅 JSONObject jsonObject = new JSONObject(); - jsonObject.put("serverId", userSetup.getServerId()); + jsonObject.put("serverId", userSetting.getServerId()); jsonObject.put("app", app); jsonObject.put("stream", streamId); jsonObject.put("register", regist); @@ -506,7 +509,7 @@ } String mediaServerId = json.getString("mediaServerId"); MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); - if (userSetup.isAutoApplyPlay() && mediaInfo != null && mediaInfo.isRtpEnable()) { + if (userSetting.isAutoApplyPlay() && mediaInfo != null && mediaInfo.isRtpEnable()) { String app = json.getString("app"); String streamId = json.getString("stream"); if ("rtp".equals(app)) { diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java index fa4aa35..579842d 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java @@ -1,20 +1,18 @@ package com.genersoft.iot.vmp.media.zlm; import com.alibaba.fastjson.JSONObject; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; -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.StreamPushItem; +import com.genersoft.iot.vmp.media.zlm.dto.*; import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +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 org.checkerframework.checker.units.qual.C; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -22,6 +20,7 @@ import org.springframework.util.StringUtils; import java.util.*; +import java.util.concurrent.ConcurrentHashMap; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -37,7 +36,7 @@ private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private GbStreamMapper gbStreamMapper; @@ -58,7 +57,9 @@ private ZLMHttpHookSubscribe subscribe; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; + + private Map<String, ChannelOnlineEvent> channelOnlineEvents = new ConcurrentHashMap<>(); public void updateMediaList(MediaServerItem mediaServerItem) { @@ -109,7 +110,7 @@ // 鏌ユ壘姝ょ洿鎾祦鏄惁瀛樺湪redis棰勮gbId StreamPushItem transform = streamPushService.transform(mediaItem); // 浠巗treamId鍙栧嚭鏌ヨ鍏抽敭鍊� - Pattern pattern = Pattern.compile(userSetup.getThirdPartyGBIdReg()); + Pattern pattern = Pattern.compile(userSetting.getThirdPartyGBIdReg()); Matcher matcher = pattern.matcher(mediaItem.getStream());// 鎸囧畾瑕佸尮閰嶇殑瀛楃涓� String queryKey = null; if (matcher.find()) { //姝ゅfind锛堬級姣忔琚皟鐢ㄥ悗锛屼細鍋忕Щ鍒颁笅涓�涓尮閰� @@ -157,7 +158,15 @@ transform.setCreateStamp(System.currentTimeMillis()); gbStreamMapper.add(transform); } + if (transform != null) { + if (channelOnlineEvents.get(transform.getGbId()) != null) { + channelOnlineEvents.get(transform.getGbId()).run(transform.getApp(), transform.getStream()); + channelOnlineEvents.remove(transform.getGbId()); + } + } } + + storager.updateMedia(transform); return transform; } @@ -200,6 +209,14 @@ return result; } + public void addChannelOnlineEventLister(String key, ChannelOnlineEvent callback) { + this.channelOnlineEvents.put(key,callback); + } + + public void removedChannelOnlineEventLister(String key) { + this.channelOnlineEvents.remove(key); + } + // public void clearAllSessions() { diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java new file mode 100644 index 0000000..ba7daec --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java @@ -0,0 +1,6 @@ +package com.genersoft.iot.vmp.media.zlm.dto; + +public interface ChannelOnlineEvent { + + void run(String app, String stream); +} diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java index 042b2d1..dd1f69e 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/event/ZLMKeepliveTimeoutListener.java @@ -3,7 +3,7 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.RedisKeyExpirationEventMessageListener; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; @@ -12,7 +12,6 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.connection.Message; -import org.springframework.data.redis.listener.KeyExpirationEventMessageListener; import org.springframework.data.redis.listener.RedisMessageListenerContainer; import org.springframework.stereotype.Component; @@ -33,13 +32,13 @@ private ZLMRESTfulUtils zlmresTfulUtils; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IMediaServerService mediaServerService; - public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetup userSetup) { - super(listenerContainer, userSetup); + public ZLMKeepliveTimeoutListener(RedisMessageListenerContainer listenerContainer, UserSetting userSetting) { + super(listenerContainer, userSetting); } @@ -52,7 +51,7 @@ public void onMessage(Message message, byte[] pattern) { // 鑾峰彇澶辨晥鐨刱ey String expiredKey = message.toString(); - String KEEPLIVEKEY_PREFIX = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetup.getServerId() + "_"; + String KEEPLIVEKEY_PREFIX = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetting.getServerId() + "_"; if(!expiredKey.startsWith(KEEPLIVEKEY_PREFIX)){ return; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java index 0cb8413..68a2af3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceService.java @@ -21,4 +21,17 @@ */ boolean removeCatalogSubscribe(Device device); + /** + * 娣诲姞绉诲姩浣嶇疆璁㈤槄 + * @param device 璁惧淇℃伅 + * @return + */ + boolean addMobilePositionSubscribe(Device device); + + /** + * 绉婚櫎绉诲姩浣嶇疆璁㈤槄 + * @param device 璁惧淇℃伅 + * @return + */ + boolean removeMobilePositionSubscribe(Device device); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/StreamGPSSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/service/StreamGPSSubscribeTask.java index fd5bb06..5bdd9f5 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/StreamGPSSubscribeTask.java +++ b/src/main/java/com/genersoft/iot/vmp/service/StreamGPSSubscribeTask.java @@ -2,7 +2,7 @@ import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +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; @@ -20,7 +20,7 @@ private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java index cb027c8..68419bf 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/CatalogSubscribeTask.java @@ -10,6 +10,9 @@ import javax.sip.ResponseEvent; +/** + * 鐩綍璁㈤槄浠诲姟 + */ public class CatalogSubscribeTask implements Runnable{ private final Logger logger = LoggerFactory.getLogger(CatalogSubscribeTask.class); private Device device; @@ -24,7 +27,6 @@ public void run() { sipCommander.catalogSubscribe(device, eventResult -> { ResponseEvent event = (ResponseEvent) eventResult.event; - Element rootElement = null; if (event.getResponse().getRawContent() != null) { // 鎴愬姛 logger.info("[鐩綍璁㈤槄]鎴愬姛锛� {}", device.getDeviceId()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java b/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java new file mode 100644 index 0000000..3ab1b80 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java @@ -0,0 +1,112 @@ +package com.genersoft.iot.vmp.service.bean; + +/** + * 褰撲笂绾у钩鍙� + */ +public class MessageForPushChannel { + /** + * 娑堟伅绫诲瀷 + * 0 娴佹敞閿� 1 娴佹敞鍐� + */ + private int type; + + /** + * 娴佸簲鐢ㄥ悕 + */ + private String app; + + /** + * 娴両d + */ + private String stream; + + /** + * 鍥芥爣ID + */ + private String gbId; + + /** + * 璇锋眰鐨勫钩鍙癐D + */ + private String platFormId; + + /** + * 璇锋眰骞冲彴鍚嶇О + */ + private String platFormName; + + /** + * WVP鏈嶅姟ID + */ + private String serverId; + + /** + * 鐩爣娴佸獟浣撹妭鐐笽D + */ + private String mediaServerId; + + + 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; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/bean/MobilePositionSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/service/bean/MobilePositionSubscribeTask.java new file mode 100644 index 0000000..df4bc6c --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/bean/MobilePositionSubscribeTask.java @@ -0,0 +1,38 @@ +package com.genersoft.iot.vmp.service.bean; + +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; +import org.dom4j.Element; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.sip.ResponseEvent; + +public class MobilePositionSubscribeTask implements Runnable{ + private final Logger logger = LoggerFactory.getLogger(MobilePositionSubscribeTask.class); + private Device device; + private ISIPCommander sipCommander; + + public MobilePositionSubscribeTask(Device device, ISIPCommander sipCommander) { + this.device = device; + this.sipCommander = sipCommander; + } + + @Override + public void run() { + sipCommander.mobilePositionSubscribe(device, eventResult -> { + ResponseEvent event = (ResponseEvent) eventResult.event; + Element rootElement = null; + if (event.getResponse().getRawContent() != null) { + // 鎴愬姛 + logger.info("[绉诲姩浣嶇疆璁㈤槄]鎴愬姛锛� {}", device.getDeviceId()); + }else { + // 鎴愬姛 + logger.info("[绉诲姩浣嶇疆璁㈤槄]鎴愬姛锛� {}", device.getDeviceId()); + } + },eventResult -> { + // 澶辫触 + logger.warn("[绉诲姩浣嶇疆璁㈤槄]澶辫触锛屼俊浠ゅ彂閫佸け璐ワ細 {}-{} ", device.getDeviceId(), eventResult.msg); + }); + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 0fc6f4c..384bf7f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.bean.CatalogSubscribeTask; +import com.genersoft.iot.vmp.service.bean.MobilePositionSubscribeTask; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -20,7 +21,6 @@ @Autowired private DynamicTask dynamicTask; -; @Autowired private ISIPCommander sipCommander; @@ -30,9 +30,9 @@ if (device == null || device.getSubscribeCycleForCatalog() < 0) { return false; } - if (dynamicTask.contains(device.getDeviceId())) { + if (dynamicTask.contains(device.getDeviceId() + "catalog")) { // 瀛樺湪鍒欏仠姝㈢幇鏈夌殑锛屽紑鍚柊鐨� - dynamicTask.stop(device.getDeviceId()); + dynamicTask.stop(device.getDeviceId() + "catalog"); } logger.info("[娣诲姞鐩綍璁㈤槄] 璁惧{}", device.getDeviceId()); // 娣诲姞鐩綍璁㈤槄 @@ -42,7 +42,7 @@ int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog(); // 璁剧疆鏈�灏忓�间负30 subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30); - dynamicTask.startCron(device.getDeviceId(), catalogSubscribeTask, subscribeCycleForCatalog - 5); + dynamicTask.startCron(device.getDeviceId() + "catalog", catalogSubscribeTask, subscribeCycleForCatalog - 5); return true; } @@ -52,9 +52,42 @@ return false; } logger.info("绉婚櫎鐩綍璁㈤槄: {}", device.getDeviceId()); - dynamicTask.stop(device.getDeviceId()); + dynamicTask.stop(device.getDeviceId() + "catalog"); device.setSubscribeCycleForCatalog(0); sipCommander.catalogSubscribe(device, null, null); return true; } + + @Override + public boolean addMobilePositionSubscribe(Device device) { + if (device == null || device.getSubscribeCycleForMobilePosition() < 0) { + return false; + } + if (dynamicTask.contains(device.getDeviceId() + "mobile_position")) { + // 瀛樺湪鍒欏仠姝㈢幇鏈夌殑锛屽紑鍚柊鐨� + dynamicTask.stop(device.getDeviceId() + "mobile_position"); + } + logger.info("[娣诲姞绉诲姩浣嶇疆璁㈤槄] 璁惧{}", device.getDeviceId()); + // 娣诲姞鐩綍璁㈤槄 + MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander); + mobilePositionSubscribeTask.run(); + // 鎻愬墠寮�濮嬪埛鏂拌闃� + int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog(); + // 璁剧疆鏈�灏忓�间负30 + subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30); + dynamicTask.startCron(device.getDeviceId() + "mobile_position" , mobilePositionSubscribeTask, subscribeCycleForCatalog - 5); + return true; + } + + @Override + public boolean removeMobilePositionSubscribe(Device device) { + if (device == null || device.getSubscribeCycleForCatalog() < 0) { + return false; + } + logger.info("绉婚櫎绉诲姩浣嶇疆璁㈤槄: {}", device.getDeviceId()); + dynamicTask.stop(device.getDeviceId() + "mobile_position"); + device.setSubscribeCycleForCatalog(0); + sipCommander.mobilePositionSubscribe(device, null, null); + return true; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java index 43312a8..a667bab 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServerServiceImpl.java @@ -4,10 +4,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.MediaConfig; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; -import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.session.SsrcConfig; import com.genersoft.iot.vmp.gb28181.session.VideoStreamSessionManager; @@ -15,11 +13,10 @@ import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; 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.StreamProxyItem; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.bean.SSRCInfo; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.dao.MediaServerMapper; import com.genersoft.iot.vmp.utils.redis.JedisUtil; import com.genersoft.iot.vmp.utils.redis.RedisUtil; @@ -29,10 +26,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.CommandLineRunner; -import org.springframework.core.annotation.Order; import org.springframework.jdbc.datasource.DataSourceTransactionManager; -import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionStatus; @@ -60,7 +54,7 @@ private Integer serverPort; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private ZLMRESTfulUtils zlmresTfulUtils; @@ -84,7 +78,7 @@ private RedisUtil redisUtil; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IStreamProxyService streamProxyService; @@ -111,10 +105,10 @@ if (mediaServerItem.getSsrcConfig() == null) { SsrcConfig ssrcConfig = new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain()); mediaServerItem.setSsrcConfig(ssrcConfig); - redisUtil.set(VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItem.getId(), mediaServerItem); + redisUtil.set(VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId(), mediaServerItem); } // 鏌ヨredis鏄惁瀛樺湪姝ediaServer - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItem.getId(); + String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId(); if (!redisUtil.hasKey(key)) { redisUtil.set(key, mediaServerItem); } @@ -133,7 +127,7 @@ return null; } // 鑾峰彇mediaServer鍙敤鐨剆src - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItem.getId(); + String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId(); SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig(); if (ssrcConfig == null) { @@ -181,7 +175,7 @@ SsrcConfig ssrcConfig = mediaServerItem.getSsrcConfig(); ssrcConfig.releaseSsrc(ssrc); mediaServerItem.setSsrcConfig(ssrcConfig); - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItem.getId(); + String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItem.getId(); redisUtil.set(key, mediaServerItem); } @@ -191,7 +185,7 @@ @Override public void clearRTPServer(MediaServerItem mediaServerItem) { mediaServerItem.setSsrcConfig(new SsrcConfig(mediaServerItem.getId(), null, sipConfig.getDomain())); - redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(), mediaServerItem.getId(), 0); + redisUtil.zAdd(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), mediaServerItem.getId(), 0); } @@ -211,15 +205,15 @@ ) ); } - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerItemInDataBase.getId(); + String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerItemInDataBase.getId(); redisUtil.set(key, mediaServerItemInDataBase); } @Override public List<MediaServerItem> getAll() { List<MediaServerItem> result = new ArrayList<>(); - List<Object> mediaServerKeys = redisUtil.scan(String.format("%S*", VideoManagerConstants.MEDIA_SERVER_PREFIX+ userSetup.getServerId() + "_" )); - String onlineKey = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + List<Object> mediaServerKeys = redisUtil.scan(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 = (MediaServerItem) redisUtil.get(key); @@ -250,13 +244,13 @@ @Override public List<MediaServerItem> getAllOnline() { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); Set<String> mediaServerIdSet = redisUtil.zRevRange(key, 0, -1); List<MediaServerItem> result = new ArrayList<>(); if (mediaServerIdSet != null && mediaServerIdSet.size() > 0) { for (String mediaServerId : mediaServerIdSet) { - String serverKey = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerId; + String serverKey = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerId; result.add((MediaServerItem) redisUtil.get(serverKey)); } } @@ -274,7 +268,7 @@ if (mediaServerId == null) { return null; } - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + mediaServerId; + String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerId; return (MediaServerItem)redisUtil.get(key); } @@ -286,7 +280,7 @@ @Override public void clearMediaServerForOnline() { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); redisUtil.del(key); } @@ -393,7 +387,7 @@ return; } mediaServerMapper.update(serverItem); - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + zlmServerConfig.getGeneralMediaServerId(); + String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + zlmServerConfig.getGeneralMediaServerId(); if (redisUtil.get(key) == null) { SsrcConfig ssrcConfig = new SsrcConfig(zlmServerConfig.getGeneralMediaServerId(), null, sipConfig.getDomain()); serverItem.setSsrcConfig(ssrcConfig); @@ -404,8 +398,9 @@ redisUtil.set(key, serverItem); resetOnlineServerItem(serverItem); updateMediaServerKeepalive(serverItem.getId(), null); - setZLMConfig(serverItem, "0".equals(zlmServerConfig.getHookEnable())); - + if (serverItem.isAutoConfig()) { + setZLMConfig(serverItem, "0".equals(zlmServerConfig.getHookEnable())); + } publisher.zlmOnlineEventPublish(serverItem.getId()); logger.info("[ ZLM锛歿} ]-[ {}:{} ]杩炴帴鎴愬姛", zlmServerConfig.getGeneralMediaServerId(), zlmServerConfig.getIp(), zlmServerConfig.getHttpPort()); @@ -420,7 +415,7 @@ @Override public void resetOnlineServerItem(MediaServerItem serverItem) { // 鏇存柊缂撳瓨 - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); // 浣跨敤zset鐨勫垎鏁颁綔涓哄綋鍓嶅苟鍙戦噺锛� 榛樿鍊艰缃负0 if (redisUtil.zScore(key, serverItem.getId()) == null) { // 涓嶅瓨鍦ㄥ垯璁剧疆榛樿鍊� 宸插瓨鍦ㄥ垯閲嶇疆 redisUtil.zAdd(key, serverItem.getId(), 0L); @@ -446,14 +441,14 @@ if (mediaServerId == null) { return; } - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); redisUtil.zIncrScore(key, mediaServerId, 1); } @Override public void removeCount(String mediaServerId) { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); redisUtil.zIncrScore(key, mediaServerId, - 1); } @@ -463,7 +458,7 @@ */ @Override public MediaServerItem getMediaServerForMinimumLoad() { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); if (redisUtil.zSize(key) == null || redisUtil.zSize(key) == 0) { logger.info("鑾峰彇璐熻浇鏈�浣庣殑鑺傜偣鏃舵棤鍦ㄧ嚎鑺傜偣"); @@ -617,8 +612,8 @@ @Override public void delete(String id) { - redisUtil.zRemove(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(), id); - String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetup.getServerId() + "_" + id; + redisUtil.zRemove(VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(), id); + String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + id; redisUtil.del(key); } @Override @@ -636,7 +631,7 @@ logger.warn("[鏇存柊ZLM 淇濇椿淇℃伅]澶辫触锛屾湭鎵惧埌娴佸獟浣撲俊鎭�"); return; } - String key = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetup.getServerId() + "_" + mediaServerId; + String key = VideoManagerConstants.MEDIA_SERVER_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + mediaServerId; int hookAliveInterval = mediaServerItem.getHookAliveInterval() + 2; redisUtil.set(key, data, hookAliveInterval); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java index 3c776b4..9253b51 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java @@ -6,11 +6,10 @@ import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.MediaConfig; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +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; @@ -22,7 +21,7 @@ private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IMediaServerService mediaServerService; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 7334184..61c37a8 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.UserSetup; +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.VideoStreamSessionManager; @@ -23,7 +23,7 @@ import com.genersoft.iot.vmp.service.bean.PlayBackResult; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.redis.RedisUtil; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; @@ -50,7 +50,7 @@ private final static Logger logger = LoggerFactory.getLogger(PlayServiceImpl.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommander cmder; @@ -83,7 +83,7 @@ private VideoStreamSessionManager streamSession; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @@ -99,7 +99,7 @@ String uuid = UUID.randomUUID().toString(); msg.setId(uuid); playResult.setUuid(uuid); - DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetup.getPlayTimeout()); + DeferredResult<ResponseEntity<String>> result = new DeferredResult<>(userSetting.getPlayTimeout()); playResult.setResult(result); // 褰曞儚鏌ヨ浠hannelId浣滀负deviceId鏌ヨ resultHolder.put(key, uuid, result); @@ -255,7 +255,7 @@ streamSession.remove(device.getDeviceId(), channelId, finalSsrcInfo.getStream()); } } - }, userSetup.getPlayTimeout()); + }, userSetting.getPlayTimeout()); cmder.playStreamCmd(mediaServerItem, ssrcInfo, device, channelId, (MediaServerItem mediaServerItemInuse, JSONObject response) -> { logger.info("鏀跺埌璁㈤槄娑堟伅锛� " + response.toJSONString()); @@ -374,7 +374,7 @@ // 鍥炲涔嬪墠鎵�鏈夌殑鐐规挱璇锋眰 playBackCallback.call(playBackResult); } - }, userSetup.getPlayTimeout()); + }, userSetting.getPlayTimeout()); cmder.playbackStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, infoCallBack, (InviteStreamInfo inviteStreamInfo) -> { logger.info("鏀跺埌璁㈤槄娑堟伅锛� " + inviteStreamInfo.getResponse().toJSONString()); @@ -461,7 +461,7 @@ // 鍥炲涔嬪墠鎵�鏈夌殑鐐规挱璇锋眰 hookCallBack.call(downloadResult); } - }, userSetup.getPlayTimeout()); + }, userSetting.getPlayTimeout()); cmder.downloadStreamCmd(mediaServerItem, ssrcInfo, device, channelId, startTime, endTime, downloadSpeed, infoCallBack, inviteStreamInfo -> { logger.info("鏀跺埌璁㈤槄娑堟伅锛� " + inviteStreamInfo.getResponse().toJSONString()); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java index 92bcd5e..c688d13 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGPSMsgListener.java @@ -20,7 +20,7 @@ @Override public void onMessage(Message message, byte[] bytes) { - logger.debug("鏀跺埌鏉ヨ嚜REDIS鐨凣PS閫氱煡锛� {}", new String(message.getBody())); + logger.info("鏀跺埌鏉ヨ嚜REDIS鐨凣PS閫氱煡锛� {}", new String(message.getBody())); GPSMsgInfo gpsMsgInfo = JSON.parseObject(message.getBody(), GPSMsgInfo.class); redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index 3e82e8d..aca3082 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -3,23 +3,20 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; +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.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.ZLMServerConfig; import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; 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.StreamPushItem; 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.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +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; @@ -44,7 +41,7 @@ private final static Logger logger = LoggerFactory.getLogger(StreamProxyServiceImpl.class); @Autowired - private IVideoManagerStorager videoManagerStorager; + private IVideoManagerStorage videoManagerStorager; @Autowired private IMediaService mediaService; @@ -59,10 +56,10 @@ private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private SipConfig sipConfig; @@ -321,7 +318,7 @@ if (mediaItems.size() > 0) { for (MediaItem mediaItem : mediaItems) { JSONObject jsonObject = new JSONObject(); - jsonObject.put("serverId", userSetup.getServerId()); + jsonObject.put("serverId", userSetting.getServerId()); jsonObject.put("app", mediaItem.getApp()); jsonObject.put("stream", mediaItem.getStream()); jsonObject.put("register", false); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java index aab2282..3aaa735 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -4,21 +4,17 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.TypeReference; -import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.UserSetup; +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.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; import com.genersoft.iot.vmp.media.zlm.dto.*; 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.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.dao.*; -import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; @@ -63,7 +59,7 @@ private IRedisCatchStorage redisCatchStorage; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IMediaServerService mediaServerService; @@ -263,7 +259,7 @@ String type = "PUSH"; for (MediaItem offlineMediaItem : offlineMediaItemList) { JSONObject jsonObject = new JSONObject(); - jsonObject.put("serverId", userSetup.getServerId()); + jsonObject.put("serverId", userSetting.getServerId()); jsonObject.put("app", offlineMediaItem.getApp()); jsonObject.put("stream", offlineMediaItem.getStream()); jsonObject.put("register", false); @@ -293,7 +289,7 @@ // 绉婚櫎redis鍐呮祦鐨勪俊鎭� redisCatchStorage.removeStream(mediaServerId, type, mediaItem.getApp(), mediaItem.getStream()); JSONObject jsonObject = new JSONObject(); - jsonObject.put("serverId", userSetup.getServerId()); + jsonObject.put("serverId", userSetting.getServerId()); jsonObject.put("app", mediaItem.getApp()); jsonObject.put("stream", mediaItem.getStream()); jsonObject.put("register", false); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java index e669ab4..e66dfa0 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -7,6 +7,7 @@ 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.GPSMsgInfo; +import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; @@ -212,4 +213,7 @@ void addNetInfo(Map<String, String> networkInterfaces); + void sendMobilePositionMsg(JSONObject jsonObject); + + void sendStreamPushRequestedMsg(MessageForPushChannel messageForPushChannel); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java similarity index 98% rename from src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java rename to src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index abbe203..11d8b84 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -1,481 +1,482 @@ -package com.genersoft.iot.vmp.storager; - -import com.genersoft.iot.vmp.gb28181.bean.*; -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.StreamPushItem; -import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; -import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; -import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.github.pagehelper.PageInfo; - -import java.util.List; - -/** - * @description:瑙嗛璁惧鏁版嵁瀛樺偍鎺ュ彛 - * @author: swwheihei - * @date: 2020骞�5鏈�6鏃� 涓嬪崍2:14:31 - */ -@SuppressWarnings("rawtypes") -public interface IVideoManagerStorager { - - /** - * 鏍规嵁璁惧ID鍒ゆ柇璁惧鏄惁瀛樺湪 - * - * @param deviceId 璁惧ID - * @return true:瀛樺湪 false锛氫笉瀛樺湪 - */ - public boolean exists(String deviceId); - - /** - * 瑙嗛璁惧鍒涘缓 - * - * @param device 璁惧瀵硅薄 - * @return true锛氬垱寤烘垚鍔� false锛氬垱寤哄け璐� - */ - public boolean create(Device device); - - /** - * 瑙嗛璁惧鏇存柊 - * - * @param device 璁惧瀵硅薄 - * @return true锛氬垱寤烘垚鍔� false锛氬垱寤哄け璐� - */ - public boolean updateDevice(Device device); - - /** - * 娣诲姞璁惧閫氶亾 - * - * @param deviceId 璁惧id - * @param channel 閫氶亾 - */ - public void updateChannel(String deviceId, DeviceChannel channel); - - /** - * 鎵归噺娣诲姞璁惧閫氶亾 - * - * @param deviceId 璁惧id - * @param channels 澶氫釜閫氶亾 - */ - public int updateChannels(String deviceId, List<DeviceChannel> channels); - - /** - * 寮�濮嬫挱鏀� - * @param deviceId 璁惧id - * @param channelId 閫氶亾ID - * @param streamId 娴佸湴鍧� - */ - public void startPlay(String deviceId, String channelId, String streamId); - - /** - * 鍋滄鎾斁 - * @param deviceId 璁惧id - * @param channelId 閫氶亾ID - */ - public void stopPlay(String deviceId, String channelId); - - /** - * 鑾峰彇璁惧 - * - * @param deviceId 璁惧ID - * @return DShadow 璁惧瀵硅薄 - */ - public Device queryVideoDevice(String deviceId); - - /** - * 鑾峰彇鏌愪釜璁惧鐨勯�氶亾鍒楄〃 - * - * @param deviceId 璁惧ID - * @param page 鍒嗛〉 褰撳墠椤� - * @param count 姣忛〉鏁伴噺 - * @return - */ - public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count); - - public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit); - - /** - * 鑾峰彇鏌愪釜璁惧鐨勯�氶亾鏍� - * @param deviceId 璁惧ID - * @return - */ - List<DeviceChannelTree> tree(String deviceId); - - /** - * 鑾峰彇鏌愪釜璁惧鐨勯�氶亾鍒楄〃 - * - * @param deviceId 璁惧ID - * @return - */ - public List<DeviceChannel> queryChannelsByDeviceId(String deviceId); - public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId); - - /** - * 鑾峰彇鏌愪釜璁惧鐨勯�氶亾 - * @param deviceId 璁惧ID - * @param channelId 閫氶亾ID - */ - public DeviceChannel queryChannel(String deviceId, String channelId); - - /** - * 鍒犻櫎閫氶亾 - * @param deviceId 璁惧ID - * @param channelId 閫氶亾ID - */ - public int delChannel(String deviceId, String channelId); - - /** - * 鑾峰彇澶氫釜璁惧 - * @param page 褰撳墠椤垫暟 - * @param count 姣忛〉鏁伴噺 - * @return List<Device> 璁惧瀵硅薄鏁扮粍 - */ - public PageInfo<Device> queryVideoDeviceList(int page, int count); - - /** - * 鑾峰彇澶氫釜璁惧 - * - * @return List<Device> 璁惧瀵硅薄鏁扮粍 - */ - public List<Device> queryVideoDeviceList(); - - /** - * 鍒犻櫎璁惧 - * - * @param deviceId 璁惧ID - * @return true锛氬垹闄ゆ垚鍔� false锛氬垹闄ゅけ璐� - */ - public boolean delete(String deviceId); - - /** - * 鏇存柊璁惧鍦ㄧ嚎 - * - * @param deviceId 璁惧ID - * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� - */ - public boolean online(String deviceId); - - /** - * 鏇存柊璁惧绂荤嚎 - * - * @param deviceId 璁惧ID - * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� - */ - public boolean outline(String deviceId); - - /** - * 鏇存柊鎵�鏈夎澶囩绾� - * - * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� - */ - public boolean outlineForAll(); - - - /** - * 鏌ヨ瀛愯澶� - * - * @param deviceId - * @param channelId - * @param page - * @param count - * @return - */ - PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count); - - - /** - * 娓呯┖閫氶亾 - * @param deviceId - */ - void cleanChannelsForDevice(String deviceId); - - - /** - * 鏇存柊涓婄骇骞冲彴 - * @param parentPlatform - */ - boolean updateParentPlatform(ParentPlatform parentPlatform); - - - /** - * 娣诲姞涓婄骇骞冲彴 - * @param parentPlatform - */ - boolean addParentPlatform(ParentPlatform parentPlatform); - - /** - * 鍒犻櫎涓婄骇骞冲彴 - * @param parentPlatform - */ - boolean deleteParentPlatform(ParentPlatform parentPlatform); - - - /** - * 鍒嗛〉鑾峰彇涓婄骇骞冲彴 - * @param page - * @param count - * @return - */ - PageInfo<ParentPlatform> queryParentPlatformList(int page, int count); - - /** - * 鑾峰彇鎵�鏈夊凡鍚敤鐨勫钩鍙� - * @return - */ - List<ParentPlatform> queryEnableParentPlatformList(boolean enable); - - /** - * 鑾峰彇涓婄骇骞冲彴 - * @param platformGbId - * @return - */ - ParentPlatform queryParentPlatByServerGBId(String platformGbId); - - /** - * 鎵�鏈夊钩鍙扮绾� - */ - void outlineForAllParentPlatform(); - - /** - * 鏌ヨ閫氶亾淇℃伅锛屼笉鍖哄垎璁惧(宸插叧鑱斿钩鍙版垨鍏ㄩ儴) - */ - PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId); - - /** - * 鏌ヨ璁惧鐨勯�氶亾淇℃伅 - */ - List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId); - - - /** - * 鏇存柊涓婄骇骞冲彴鐨勯�氶亾淇℃伅 - * @param platformId - * @param channelReduces - * @return - */ - int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId); - - /** - * 绉婚櫎涓婄骇骞冲彴鐨勯�氶亾淇℃伅 - * @param platformId - * @param channelReduces - * @return - */ - int delChannelForGB(String platformId, List<ChannelReduce> channelReduces); - - - DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); - - List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); - List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId); - - Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); - - - /** - * 娣诲姞Mobile Position璁惧绉诲姩浣嶇疆 - * @param mobilePosition - * @return - */ - public boolean insertMobilePosition(MobilePosition mobilePosition); - - /** - * 鏌ヨ绉诲姩浣嶇疆杞ㄨ抗 - * @param deviceId - * @param startTime - * @param endTime - */ - public List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime); - - /** - * 鏌ヨ鏈�鏂扮Щ鍔ㄤ綅缃� - * @param deviceId - */ - public MobilePosition queryLatestPosition(String deviceId); - - /** - * 鍒犻櫎鎸囧畾璁惧鐨勬墍鏈夌Щ鍔ㄤ綅缃� - * @param deviceId - */ - public int clearMobilePositionsByDeviceId(String deviceId); - - /** - * 鏂板浠g悊娴� - * @param streamProxyDto - * @return - */ - public boolean addStreamProxy(StreamProxyItem streamProxyDto); - - /** - * 鏇存柊浠g悊娴� - * @param streamProxyDto - * @return - */ - public boolean updateStreamProxy(StreamProxyItem streamProxyDto); - - /** - * 绉婚櫎浠g悊娴� - * @param app - * @param stream - * @return - */ - public int deleteStreamProxy(String app, String stream); - - /** - * 鎸夌収鏄惁鍚敤鑾峰彇浠g悊娴� - * @param enable - * @return - */ - public List<StreamProxyItem> getStreamProxyListForEnable(boolean enable); - - /** - * 鎸夌収鏄痑pp鍜宻tream鑾峰彇浠g悊娴� - * @param app - * @param stream - * @return - */ - public StreamProxyItem queryStreamProxy(String app, String stream); - - /** - * 鑾峰彇浠g悊娴� - * @param page - * @param count - * @return - */ - PageInfo<StreamProxyItem> queryStreamProxyList(Integer page, Integer count); - - /** - * 鏍规嵁鍥芥爣ID鑾峰彇骞冲彴鍏宠仈鐨勭洿鎾祦 - * @param platformId - * @param channelId - * @return - */ - GbStream queryStreamInParentPlatform(String platformId, String channelId); - - /** - * 鑾峰彇骞冲彴鍏宠仈鐨勭洿鎾祦 - * @param platformId - * @return - */ - List<GbStream> queryGbStreamListInPlatform(String platformId); - - /** - * 鎵归噺鏇存柊鎺ㄦ祦鍒楄〃 - * @param streamPushItems - */ - void updateMediaList(List<StreamPushItem> streamPushItems); - - /** - * 鏇存柊鍗曚釜鎺ㄦ祦 - * @param streamPushItem - */ - void updateMedia(StreamPushItem streamPushItem); - - /** - * 绉婚櫎鍗曚釜鎺ㄦ祦 - * @param app - * @param stream - */ - int removeMedia(String app, String stream); - - - /** - * 娓呯┖鎺ㄦ祦鍒楄〃 - */ - void clearMediaList(); - - /** - * 璁剧疆娴佺绾� - * @param app - * @param streamId - */ - int mediaOutline(String app, String streamId); - - /** - * 璁剧疆骞冲彴鍦ㄧ嚎/绂荤嚎 - * @param online - */ - void updateParentPlatformStatus(String platformGbID, boolean online); - - /** - * 鏍规嵁濯掍綋ID鑾峰彇鍚敤/涓嶅惎鐢ㄧ殑浠g悊鍒楄〃 - * @param id 濯掍綋ID - * @param enable 鍚敤/涓嶅惎鐢� - * @param status 鐘舵�� - * @return - */ - List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable, boolean status); - - /** - * 鏍规嵁閫氶亾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涓巗tream鑾峰彇StreamProxy - * @param app - * @param streamId - * @return - */ - StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); - - /** - * catlog鏌ヨ缁撴潫鍚庡畬鍏ㄩ噸鍐欓�氶亾淇℃伅 - * @param deviceId - * @param deviceChannelList - */ - boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList); - - /** - * 鑾峰彇鐩綍淇℃伅 - * @param platformId - * @param parentId - * @return - */ - List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId); - - int addCatalog(PlatformCatalog platformCatalog); - - PlatformCatalog getCatalog(String id); - - int delCatalog(String id); - - int updateCatalog(PlatformCatalog platformCatalog); - - int setDefaultCatalog(String platformId, String catalogId); - - List<PlatformCatalog> queryCatalogInPlatform(String serverGBId); - - int delRelation(PlatformCatalog platformCatalog); - - int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfo); - - List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms); - - List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms); - - GbStream getGbStream(String app, String streamId); - - void delCatalogByPlatformId(String serverGBId); - - void delRelationByPlatformId(String serverGBId); - - PlatformCatalog queryDefaultCatalogInPlatform(String platformId); - - List<ChannelSourceInfo> getChannelSource(String platformId, String gbId); -} +package com.genersoft.iot.vmp.storager; + +import com.genersoft.iot.vmp.gb28181.bean.*; +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 com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; +import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree; +import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.github.pagehelper.PageInfo; + +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锛氫笉瀛樺湪 + */ + public boolean exists(String deviceId); + + /** + * 瑙嗛璁惧鍒涘缓 + * + * @param device 璁惧瀵硅薄 + * @return true锛氬垱寤烘垚鍔� false锛氬垱寤哄け璐� + */ + public boolean create(Device device); + + /** + * 瑙嗛璁惧鏇存柊 + * + * @param device 璁惧瀵硅薄 + * @return true锛氬垱寤烘垚鍔� false锛氬垱寤哄け璐� + */ + public boolean updateDevice(Device device); + + /** + * 娣诲姞璁惧閫氶亾 + * + * @param deviceId 璁惧id + * @param channel 閫氶亾 + */ + public void updateChannel(String deviceId, DeviceChannel channel); + + /** + * 鎵归噺娣诲姞璁惧閫氶亾 + * + * @param deviceId 璁惧id + * @param channels 澶氫釜閫氶亾 + */ + public int updateChannels(String deviceId, List<DeviceChannel> channels); + + /** + * 寮�濮嬫挱鏀� + * @param deviceId 璁惧id + * @param channelId 閫氶亾ID + * @param streamId 娴佸湴鍧� + */ + public void startPlay(String deviceId, String channelId, String streamId); + + /** + * 鍋滄鎾斁 + * @param deviceId 璁惧id + * @param channelId 閫氶亾ID + */ + public void stopPlay(String deviceId, String channelId); + + /** + * 鑾峰彇璁惧 + * + * @param deviceId 璁惧ID + * @return DShadow 璁惧瀵硅薄 + */ + public Device queryVideoDevice(String deviceId); + + /** + * 鑾峰彇鏌愪釜璁惧鐨勯�氶亾鍒楄〃 + * + * @param deviceId 璁惧ID + * @param page 鍒嗛〉 褰撳墠椤� + * @param count 姣忛〉鏁伴噺 + * @return + */ + public PageInfo queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, Boolean online, int page, int count); + + public List<DeviceChannel> queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit); + + /** + * 鑾峰彇鏌愪釜璁惧鐨勯�氶亾鏍� + * @param deviceId 璁惧ID + * @return + */ + List<DeviceChannelTree> tree(String deviceId); + + /** + * 鑾峰彇鏌愪釜璁惧鐨勯�氶亾鍒楄〃 + * + * @param deviceId 璁惧ID + * @return + */ + public List<DeviceChannel> queryChannelsByDeviceId(String deviceId); + public List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId); + + /** + * 鑾峰彇鏌愪釜璁惧鐨勯�氶亾 + * @param deviceId 璁惧ID + * @param channelId 閫氶亾ID + */ + public DeviceChannel queryChannel(String deviceId, String channelId); + + /** + * 鍒犻櫎閫氶亾 + * @param deviceId 璁惧ID + * @param channelId 閫氶亾ID + */ + public int delChannel(String deviceId, String channelId); + + /** + * 鑾峰彇澶氫釜璁惧 + * @param page 褰撳墠椤垫暟 + * @param count 姣忛〉鏁伴噺 + * @return List<Device> 璁惧瀵硅薄鏁扮粍 + */ + public PageInfo<Device> queryVideoDeviceList(int page, int count); + + /** + * 鑾峰彇澶氫釜璁惧 + * + * @return List<Device> 璁惧瀵硅薄鏁扮粍 + */ + public List<Device> queryVideoDeviceList(); + + /** + * 鍒犻櫎璁惧 + * + * @param deviceId 璁惧ID + * @return true锛氬垹闄ゆ垚鍔� false锛氬垹闄ゅけ璐� + */ + public boolean delete(String deviceId); + + /** + * 鏇存柊璁惧鍦ㄧ嚎 + * + * @param deviceId 璁惧ID + * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� + */ + public boolean online(String deviceId); + + /** + * 鏇存柊璁惧绂荤嚎 + * + * @param deviceId 璁惧ID + * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� + */ + public boolean outline(String deviceId); + + /** + * 鏇存柊鎵�鏈夎澶囩绾� + * + * @return true锛氭洿鏂版垚鍔� false锛氭洿鏂板け璐� + */ + public boolean outlineForAll(); + + + /** + * 鏌ヨ瀛愯澶� + * + * @param deviceId + * @param channelId + * @param page + * @param count + * @return + */ + PageInfo querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count); + + + /** + * 娓呯┖閫氶亾 + * @param deviceId + */ + void cleanChannelsForDevice(String deviceId); + + + /** + * 鏇存柊涓婄骇骞冲彴 + * @param parentPlatform + */ + boolean updateParentPlatform(ParentPlatform parentPlatform); + + + /** + * 娣诲姞涓婄骇骞冲彴 + * @param parentPlatform + */ + boolean addParentPlatform(ParentPlatform parentPlatform); + + /** + * 鍒犻櫎涓婄骇骞冲彴 + * @param parentPlatform + */ + boolean deleteParentPlatform(ParentPlatform parentPlatform); + + + /** + * 鍒嗛〉鑾峰彇涓婄骇骞冲彴 + * @param page + * @param count + * @return + */ + PageInfo<ParentPlatform> queryParentPlatformList(int page, int count); + + /** + * 鑾峰彇鎵�鏈夊凡鍚敤鐨勫钩鍙� + * @return + */ + List<ParentPlatform> queryEnableParentPlatformList(boolean enable); + + /** + * 鑾峰彇涓婄骇骞冲彴 + * @param platformGbId + * @return + */ + ParentPlatform queryParentPlatByServerGBId(String platformGbId); + + /** + * 鎵�鏈夊钩鍙扮绾� + */ + void outlineForAllParentPlatform(); + + /** + * 鏌ヨ閫氶亾淇℃伅锛屼笉鍖哄垎璁惧(宸插叧鑱斿钩鍙版垨鍏ㄩ儴) + */ + PageInfo<ChannelReduce> queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId); + + /** + * 鏌ヨ璁惧鐨勯�氶亾淇℃伅 + */ + List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId); + + + /** + * 鏇存柊涓婄骇骞冲彴鐨勯�氶亾淇℃伅 + * @param platformId + * @param channelReduces + * @return + */ + int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId); + + /** + * 绉婚櫎涓婄骇骞冲彴鐨勯�氶亾淇℃伅 + * @param platformId + * @param channelReduces + * @return + */ + int delChannelForGB(String platformId, List<ChannelReduce> channelReduces); + + + DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); + + List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); + List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId); + + Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); + + + /** + * 娣诲姞Mobile Position璁惧绉诲姩浣嶇疆 + * @param mobilePosition + * @return + */ + public boolean insertMobilePosition(MobilePosition mobilePosition); + + /** + * 鏌ヨ绉诲姩浣嶇疆杞ㄨ抗 + * @param deviceId + * @param startTime + * @param endTime + */ + public List<MobilePosition> queryMobilePositions(String deviceId, String startTime, String endTime); + + /** + * 鏌ヨ鏈�鏂扮Щ鍔ㄤ綅缃� + * @param deviceId + */ + public MobilePosition queryLatestPosition(String deviceId); + + /** + * 鍒犻櫎鎸囧畾璁惧鐨勬墍鏈夌Щ鍔ㄤ綅缃� + * @param deviceId + */ + public int clearMobilePositionsByDeviceId(String deviceId); + + /** + * 鏂板浠g悊娴� + * @param streamProxyDto + * @return + */ + public boolean addStreamProxy(StreamProxyItem streamProxyDto); + + /** + * 鏇存柊浠g悊娴� + * @param streamProxyDto + * @return + */ + public boolean updateStreamProxy(StreamProxyItem streamProxyDto); + + /** + * 绉婚櫎浠g悊娴� + * @param app + * @param stream + * @return + */ + public int deleteStreamProxy(String app, String stream); + + /** + * 鎸夌収鏄惁鍚敤鑾峰彇浠g悊娴� + * @param enable + * @return + */ + public List<StreamProxyItem> getStreamProxyListForEnable(boolean enable); + + /** + * 鎸夌収鏄痑pp鍜宻tream鑾峰彇浠g悊娴� + * @param app + * @param stream + * @return + */ + public StreamProxyItem queryStreamProxy(String app, String stream); + + /** + * 鑾峰彇浠g悊娴� + * @param page + * @param count + * @return + */ + PageInfo<StreamProxyItem> queryStreamProxyList(Integer page, Integer count); + + /** + * 鏍规嵁鍥芥爣ID鑾峰彇骞冲彴鍏宠仈鐨勭洿鎾祦 + * @param platformId + * @param channelId + * @return + */ + GbStream queryStreamInParentPlatform(String platformId, String channelId); + + /** + * 鑾峰彇骞冲彴鍏宠仈鐨勭洿鎾祦 + * @param platformId + * @return + */ + List<GbStream> queryGbStreamListInPlatform(String platformId); + + /** + * 鎵归噺鏇存柊鎺ㄦ祦鍒楄〃 + * @param streamPushItems + */ + void updateMediaList(List<StreamPushItem> streamPushItems); + + /** + * 鏇存柊鍗曚釜鎺ㄦ祦 + * @param streamPushItem + */ + void updateMedia(StreamPushItem streamPushItem); + + /** + * 绉婚櫎鍗曚釜鎺ㄦ祦 + * @param app + * @param stream + */ + int removeMedia(String app, String stream); + + + /** + * 娓呯┖鎺ㄦ祦鍒楄〃 + */ + void clearMediaList(); + + /** + * 璁剧疆娴佺绾� + * @param app + * @param streamId + */ + int mediaOutline(String app, String streamId); + + /** + * 璁剧疆骞冲彴鍦ㄧ嚎/绂荤嚎 + * @param online + */ + void updateParentPlatformStatus(String platformGbID, boolean online); + + /** + * 鏍规嵁濯掍綋ID鑾峰彇鍚敤/涓嶅惎鐢ㄧ殑浠g悊鍒楄〃 + * @param id 濯掍綋ID + * @param enable 鍚敤/涓嶅惎鐢� + * @param status 鐘舵�� + * @return + */ + List<StreamProxyItem> getStreamProxyListForEnableInMediaServer(String id, boolean enable, boolean status); + + /** + * 鏍规嵁閫氶亾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涓巗tream鑾峰彇StreamProxy + * @param app + * @param streamId + * @return + */ + StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); + + /** + * catlog鏌ヨ缁撴潫鍚庡畬鍏ㄩ噸鍐欓�氶亾淇℃伅 + * @param deviceId + * @param deviceChannelList + */ + boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList); + + /** + * 鑾峰彇鐩綍淇℃伅 + * @param platformId + * @param parentId + * @return + */ + List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId); + + int addCatalog(PlatformCatalog platformCatalog); + + PlatformCatalog getCatalog(String id); + + int delCatalog(String id); + + int updateCatalog(PlatformCatalog platformCatalog); + + int setDefaultCatalog(String platformId, String catalogId); + + List<PlatformCatalog> queryCatalogInPlatform(String serverGBId); + + int delRelation(PlatformCatalog platformCatalog); + + int updateStreamGPS(List<GPSMsgInfo> gpsMsgInfo); + + List<ParentPlatform> queryPlatFormListForGBWithGBId(String channelId, List<String> platforms); + + List<ParentPlatform> queryPlatFormListForStreamWithGBId(String app, String stream, List<String> platforms); + + GbStream getGbStream(String app, String streamId); + + void delCatalogByPlatformId(String serverGBId); + + void delRelationByPlatformId(String serverGBId); + + PlatformCatalog queryDefaultCatalogInPlatform(String platformId); + + List<ChannelSourceInfo> getChannelSource(String platformId, String gbId); + + void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude); +} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index e132799..42e46e1 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -106,7 +106,7 @@ " <if test='online == true' > AND dc.status=1</if> " + " <if test='online == false' > AND dc.status=0</if> " + " <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc.subCount > 0</if> " + - " <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc.subCount == 0</if> " + + " <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc.subCount = 0</if> " + " <if test='catalogId == null ' > AND dc.id not in (select deviceChannelId from platform_gb_channel where platformId=#{platformId} ) </if> " + " <if test='catalogId != null ' > AND pgc.platformId = #{platformId} and pgc.catalogId=#{catalogId} </if> " + " ORDER BY dc.deviceId, dc.channelId ASC" + @@ -270,4 +270,7 @@ " where deviceId = #{deviceId} " + " and channelId = #{channelId}") int updateChannelSubCount(String deviceId, String channelId); + + @Update(value = {"UPDATE device_channel SET latitude=${latitude}, longitude=${longitude} WHERE deviceId=#{deviceId} AND channelId=#{channelId}"}) + void updatePotion(String deviceId, String channelId, double longitude, double latitude); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java index 28f79f1..aab8d77 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java @@ -34,6 +34,9 @@ "updateTime," + "charset," + "subscribeCycleForCatalog," + + "subscribeCycleForMobilePosition," + + "mobilePositionSubmissionInterval," + + "subscribeCycleForAlarm," + "online" + ") VALUES (" + "#{deviceId}," + @@ -53,6 +56,9 @@ "#{updateTime}," + "#{charset}," + "#{subscribeCycleForCatalog}," + + "#{subscribeCycleForMobilePosition}," + + "#{mobilePositionSubmissionInterval}," + + "#{subscribeCycleForAlarm}," + "#{online}" + ")") int add(Device device); @@ -75,6 +81,9 @@ "<if test=\"expires != null\">, expires=${expires}</if>" + "<if test=\"charset != null\">, charset='${charset}'</if>" + "<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=${subscribeCycleForCatalog}</if>" + + "<if test=\"subscribeCycleForMobilePosition != null\">, subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}</if>" + + "<if test=\"mobilePositionSubmissionInterval != null\">, mobilePositionSubmissionInterval=${mobilePositionSubmissionInterval}</if>" + + "<if test=\"subscribeCycleForAlarm != null\">, subscribeCycleForAlarm=${subscribeCycleForAlarm}</if>" + "WHERE deviceId='${deviceId}'"+ " </script>"}) int update(Device device); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 4840446..d72576b 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -1,16 +1,16 @@ package com.genersoft.iot.vmp.storager.impl; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.SystemInfoDto; import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; 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.GPSMsgInfo; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; +import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; @@ -18,9 +18,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Component; -import org.springframework.util.StringUtils; import java.text.SimpleDateFormat; import java.util.*; @@ -29,7 +27,7 @@ @Component public class RedisCatchStorageImpl implements IRedisCatchStorage { - private Logger logger = LoggerFactory.getLogger(RedisCatchStorageImpl.class); + private final Logger logger = LoggerFactory.getLogger(RedisCatchStorageImpl.class); @Autowired private RedisUtil redis; @@ -38,13 +36,13 @@ private DeviceChannelMapper deviceChannelMapper; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; - private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @Override public Long getCSEQ(String method) { - String key = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetup.getServerId() + "_" + method; + String key = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetting.getServerId() + "_" + method; long result = redis.incr(key, 1L); if (result > Integer.MAX_VALUE) { @@ -56,7 +54,7 @@ @Override public Long getSN(String method) { - String key = VideoManagerConstants.SIP_SN_PREFIX + userSetup.getServerId() + "_" + method; + String key = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_" + method; long result = redis.incr(key, 1L); if (result > Integer.MAX_VALUE) { @@ -68,20 +66,20 @@ @Override public void resetAllCSEQ() { - String scanKey = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetup.getServerId() + "_*"; + String scanKey = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetting.getServerId() + "_*"; List<Object> keys = redis.scan(scanKey); - for (int i = 0; i < keys.size(); i++) { - String key = (String) keys.get(i); + for (Object o : keys) { + String key = (String) o; redis.set(key, 1); } } @Override public void resetAllSN() { - String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetup.getServerId() + "_*"; + String scanKey = VideoManagerConstants.SIP_SN_PREFIX + userSetting.getServerId() + "_*"; List<Object> keys = redis.scan(scanKey); - for (int i = 0; i < keys.size(); i++) { - String key = (String) keys.get(i); + for (Object o : keys) { + String key = (String) o; redis.set(key, 1); } } @@ -93,7 +91,7 @@ */ @Override public boolean startPlay(StreamInfo stream) { - return redis.set(String.format("%S_%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(), + return redis.set(String.format("%S_%S_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), stream.getStream(), stream.getDeviceID(), stream.getChannelId()), stream); } @@ -107,7 +105,7 @@ public boolean stopPlay(StreamInfo streamInfo) { if (streamInfo == null) return false; return redis.del(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), streamInfo.getStream(), streamInfo.getDeviceID(), streamInfo.getChannelId())); @@ -121,14 +119,14 @@ public StreamInfo queryPlay(StreamInfo streamInfo) { return (StreamInfo)redis.get(String.format("%S_%s_%s_%s_%s", VideoManagerConstants.PLAYER_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), streamInfo.getStream(), streamInfo.getDeviceID(), streamInfo.getChannelId())); } @Override public StreamInfo queryPlayByStreamId(String streamId) { - List<Object> playLeys = redis.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(), streamId)); + List<Object> playLeys = redis.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(), streamId)); if (playLeys == null || playLeys.size() == 0) return null; return (StreamInfo)redis.get(playLeys.get(0).toString()); } @@ -136,7 +134,7 @@ @Override public StreamInfo queryPlayByDevice(String deviceId, String channelId) { List<Object> playLeys = redis.scan(String.format("%S_%s_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), deviceId, channelId)); if (playLeys == null || playLeys.size() == 0) return null; @@ -147,11 +145,11 @@ public Map<String, StreamInfo> queryPlayByDeviceId(String deviceId) { Map<String, StreamInfo> streamInfos = new HashMap<>(); // List<Object> playLeys = redis.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId)); - List<Object> players = redis.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(),deviceId)); + List<Object> players = redis.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetting.getServerId(),deviceId)); if (players.size() == 0) return streamInfos; - for (int i = 0; i < players.size(); i++) { - String key = (String) players.get(i); - StreamInfo streamInfo = (StreamInfo)redis.get(key); + for (Object player : players) { + String key = (String) player; + StreamInfo streamInfo = (StreamInfo) redis.get(key); streamInfos.put(streamInfo.getDeviceID() + "_" + streamInfo.getChannelId(), streamInfo); } return streamInfos; @@ -161,7 +159,7 @@ @Override public boolean startPlayback(StreamInfo stream, String callId) { return redis.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, - userSetup.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); + userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); } @Override @@ -169,10 +167,10 @@ boolean result; if (stream.getProgress() == 1) { result = redis.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, - userSetup.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); + userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream); }else { result = redis.set(String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, - userSetup.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream, 60*60); + userSetting.getServerId(), stream.getDeviceID(), stream.getChannelId(), stream.getStream(), callId), stream, 60*60); } return result; } @@ -189,7 +187,7 @@ if (stream == null) stream = "*"; if (callId == null) callId = "*"; String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), deviceId, channelId, stream, @@ -217,7 +215,7 @@ if (stream == null) stream = "*"; if (callId == null) callId = "*"; String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), deviceId, channelId, stream, @@ -242,7 +240,7 @@ if (stream == null) stream = "*"; if (callId == null) callId = "*"; String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), deviceId, channelId, stream, @@ -258,63 +256,63 @@ @Override public void updatePlatformCatchInfo(ParentPlatformCatch parentPlatformCatch) { - String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetup.getServerId() + "_" + parentPlatformCatch.getId(); + String key = VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + parentPlatformCatch.getId(); redis.set(key, parentPlatformCatch); } @Override public void updatePlatformKeepalive(ParentPlatform parentPlatform) { - String key = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetup.getServerId() + "_" + parentPlatform.getServerGBId(); + String key = VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + parentPlatform.getServerGBId(); redis.set(key, "", Integer.parseInt(parentPlatform.getKeepTimeout())); } @Override public void updatePlatformRegister(ParentPlatform parentPlatform) { - String key = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetup.getServerId() + "_" + parentPlatform.getServerGBId(); + String key = VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_" + parentPlatform.getServerGBId(); redis.set(key, "", Integer.parseInt(parentPlatform.getExpires())); } @Override public ParentPlatformCatch queryPlatformCatchInfo(String platformGbId) { - return (ParentPlatformCatch)redis.get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetup.getServerId() + "_" + platformGbId); + return (ParentPlatformCatch)redis.get(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId); } @Override public void delPlatformCatchInfo(String platformGbId) { - redis.del(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetup.getServerId() + "_" + platformGbId); + redis.del(VideoManagerConstants.PLATFORM_CATCH_PREFIX + userSetting.getServerId() + "_" + platformGbId); } @Override public void delPlatformKeepalive(String platformGbId) { - redis.del(VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetup.getServerId() + "_" + platformGbId); + redis.del(VideoManagerConstants.PLATFORM_KEEPALIVE_PREFIX + userSetting.getServerId() + "_" + platformGbId); } @Override public void delPlatformRegister(String platformGbId) { - redis.del(VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetup.getServerId() + "_" + platformGbId); + redis.del(VideoManagerConstants.PLATFORM_REGISTER_PREFIX + userSetting.getServerId() + "_" + platformGbId); } @Override public void updatePlatformRegisterInfo(String callId, String platformGbId) { - String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + callId; + String key = VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId; redis.set(key, platformGbId, 30); } @Override public String queryPlatformRegisterInfo(String callId) { - return (String)redis.get(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + callId); + return (String)redis.get(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId); } @Override public void delPlatformRegisterInfo(String callId) { - redis.del(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + callId); + redis.del(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + callId); } @Override public void cleanPlatformRegisterInfos() { - List regInfos = redis.scan(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetup.getServerId() + "_" + "*"); + List regInfos = redis.scan(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + userSetting.getServerId() + "_" + "*"); for (Object key : regInfos) { redis.del(key.toString()); } @@ -322,7 +320,7 @@ @Override public void updateSendRTPSever(SendRtpItem sendRtpItem) { - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_" + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + sendRtpItem.getPlatformId() + "_" + sendRtpItem.getChannelId() + "_" + sendRtpItem.getStreamId() + "_" + sendRtpItem.getCallId(); redis.set(key, sendRtpItem); @@ -334,7 +332,7 @@ if (channelId == null) channelId = "*"; if (streamId == null) streamId = "*"; if (callId == null) callId = "*"; - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_" + platformGbId + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_" + channelId + "_" + streamId + "_" + callId; List<Object> scan = redis.scan(key); if (scan.size() > 0) { @@ -347,13 +345,13 @@ @Override public List<SendRtpItem> querySendRTPServer(String platformGbId) { if (platformGbId == null) platformGbId = "*"; - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*"; + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_*" + "_*" + "_*"; List<Object> queryResult = redis.scan(key); List<SendRtpItem> result= new ArrayList<>(); - for (int i = 0; i < queryResult.size(); i++) { - String keyItem = (String) queryResult.get(i); - result.add((SendRtpItem)redis.get(keyItem)); + for (Object o : queryResult) { + String keyItem = (String) o; + result.add((SendRtpItem) redis.get(keyItem)); } return result; @@ -368,7 +366,7 @@ 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 + userSetup.getServerId() + "_" + platformGbId + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + platformGbId + "_" + channelId + "_" + streamId + "_" + callId; List<Object> scan = redis.scan(key); if (scan.size() > 0) { @@ -386,7 +384,7 @@ */ @Override public boolean isChannelSendingRTP(String channelId) { - String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetup.getServerId() + "_" + "*_" + channelId + "*_" + "*_"; + String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + userSetting.getServerId() + "_" + "*_" + channelId + "*_" + "*_"; List<Object> RtpStreams = redis.scan(key); if (RtpStreams.size() > 0) { return true; @@ -398,7 +396,7 @@ @Override public void clearCatchByDeviceId(String deviceId) { List<Object> playLeys = redis.scan(String.format("%S_%s_*_%s_*", VideoManagerConstants.PLAYER_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), deviceId)); if (playLeys.size() > 0) { for (Object key : playLeys) { @@ -407,7 +405,7 @@ } List<Object> playBackers = redis.scan(String.format("%S_%s_%s_*_*_*", VideoManagerConstants.PLAY_BLACK_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), deviceId)); if (playBackers.size() > 0) { for (Object key : playBackers) { @@ -416,7 +414,7 @@ } List<Object> deviceCache = redis.scan(String.format("%S%s_%s", VideoManagerConstants.DEVICE_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), deviceId)); if (deviceCache.size() > 0) { for (Object key : deviceCache) { @@ -427,7 +425,7 @@ @Override public void outlineForAll() { - List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + "*" ); + List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + "*" ); for (int i = 0; i < onlineDevices.size(); i++) { String key = (String) onlineDevices.get(i); redis.del(key); @@ -437,7 +435,7 @@ @Override public List<String> getOnlineForAll() { List<String> result = new ArrayList<>(); - List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + "*" ); + List<Object> onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetting.getServerId() + "_" + "*" ); for (int i = 0; i < onlineDevices.size(); i++) { String key = (String) onlineDevices.get(i); result.add((String) redis.get(key)); @@ -447,7 +445,7 @@ @Override public void updateWVPInfo(JSONObject jsonObject, int time) { - String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.WVP_SERVER_PREFIX + userSetting.getServerId(); redis.set(key, jsonObject, time); } @@ -460,13 +458,13 @@ @Override public void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, MediaItem mediaItem) { - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetup.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId(); + String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId(); redis.set(key, mediaItem); } @Override public void removeStream(String mediaServerId, String type, String app, String streamId) { - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetup.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerId; + String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerId; redis.del(key); } @@ -480,7 +478,7 @@ if (stream == null) stream = "*"; if (callId == null) callId = "*"; String key = String.format("%S_%s_%s_%s_%s_%s", VideoManagerConstants.DOWNLOAD_PREFIX, - userSetup.getServerId(), + userSetting.getServerId(), deviceId, channelId, stream, @@ -503,7 +501,7 @@ @Override public void removeStream(String mediaServerId, String type) { - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetup.getServerId() + "_" + type + "_*_*_" + mediaServerId; + String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId; List<Object> streams = redis.scan(key); for (Object stream : streams) { redis.del((String) stream); @@ -513,7 +511,7 @@ @Override public List<MediaItem> getStreams(String mediaServerId, String type) { List<MediaItem> result = new ArrayList<>(); - String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetup.getServerId() + "_" + type + "_*_*_" + mediaServerId; + String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_*_*_" + mediaServerId; List<Object> streams = redis.scan(key); for (Object stream : streams) { MediaItem mediaItem = (MediaItem)redis.get((String) stream); @@ -524,37 +522,37 @@ @Override public void updateDevice(Device device) { - String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + device.getDeviceId(); + String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + device.getDeviceId(); redis.set(key, device); } @Override public void removeDevice(String deviceId) { - String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId; + String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId; redis.del(key); } @Override public Device getDevice(String deviceId) { - String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId; + String key = VideoManagerConstants.DEVICE_PREFIX + userSetting.getServerId() + "_" + deviceId; return (Device)redis.get(key); } @Override public void updateGpsMsgInfo(GPSMsgInfo gpsMsgInfo) { - String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_" + gpsMsgInfo.getId(); + String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gpsMsgInfo.getId(); redis.set(key, gpsMsgInfo, 60); // 榛樿GPS娑堟伅淇濆瓨1鍒嗛挓 } @Override public GPSMsgInfo getGpsMsgInfo(String gbId) { - String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_" + gbId; + String key = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_" + gbId; return (GPSMsgInfo)redis.get(key); } @Override public List<GPSMsgInfo> getAllGpsMsgInfo() { - String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_*"; + String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_*"; List<GPSMsgInfo> result = new ArrayList<>(); List<Object> keys = redis.scan(scanKey); for (int i = 0; i < keys.size(); i++) { @@ -570,7 +568,7 @@ @Override public MediaItem getStreamInfo(String app, String streamId, String mediaServerId) { - String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetup.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId; + String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId; MediaItem result = null; List<Object> keys = redis.scan(scanKey); @@ -584,7 +582,7 @@ @Override public void addCpuInfo(double cpuInfo) { - String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.SYSTEM_INFO_CPU_PREFIX + userSetting.getServerId(); SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>(); systemInfoDto.setTime(format.format(System.currentTimeMillis())); systemInfoDto.setData(cpuInfo); @@ -599,7 +597,7 @@ @Override public void addMemInfo(double memInfo) { - String key = VideoManagerConstants.SYSTEM_INFO_MEM_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.SYSTEM_INFO_MEM_PREFIX + userSetting.getServerId(); SystemInfoDto<Double> systemInfoDto = new SystemInfoDto<>(); systemInfoDto.setTime(format.format(System.currentTimeMillis())); systemInfoDto.setData(memInfo); @@ -614,7 +612,7 @@ @Override public void addNetInfo(Map<String, String> networkInterfaces) { - String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetting.getServerId(); SystemInfoDto<Map<String, String>> systemInfoDto = new SystemInfoDto<>(); systemInfoDto.setTime(format.format(System.currentTimeMillis())); systemInfoDto.setData(networkInterfaces); @@ -626,4 +624,18 @@ } } } + + @Override + public void sendMobilePositionMsg(JSONObject jsonObject) { + String key = VideoManagerConstants.VM_MSG_SUBSCRIBE_MOBILE_POSITION; + logger.debug("[redis 绉诲姩浣嶇疆璁㈤槄閫氱煡] {}: {}", key, jsonObject.toString()); + redis.convertAndSend(key, jsonObject); + } + + @Override + public void sendStreamPushRequestedMsg(MessageForPushChannel msg) { + String key = VideoManagerConstants.VM_MSG_STREAM_PUSH_REQUESTED; + logger.debug("[redis 鎺ㄦ祦琚姹傞�氱煡] {}: {}-{}", key, msg.getApp(), msg.getStream()); + redis.convertAndSend(key, (JSONObject)JSON.toJSON(msg)); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java similarity index 97% rename from src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java rename to src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index cd8141f..1665573 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -5,14 +5,12 @@ 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.VideoStreamSessionManager; -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.StreamPushItem; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +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.node.ForestNodeMerger; @@ -40,9 +38,9 @@ */ @SuppressWarnings("rawtypes") @Component -public class VideoManagerStoragerImpl implements IVideoManagerStorager { +public class VideoManagerStorageImpl implements IVideoManagerStorage { - private final Logger logger = LoggerFactory.getLogger(VideoManagerStoragerImpl.class); + private final Logger logger = LoggerFactory.getLogger(VideoManagerStorageImpl.class); @Autowired EventPublisher eventPublisher; @@ -85,7 +83,6 @@ @Autowired private PlatformCatalogMapper catalogMapper; -; @Autowired private PlatformGbStreamMapper platformGbStreamMapper; @@ -96,13 +93,7 @@ @Autowired private ParentPlatformMapper parentPlatformMapper; - @Autowired - private VideoStreamSessionManager streamSession; - - @Autowired - private MediaServerMapper mediaServerMapper; - - private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + private final SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); /** @@ -268,7 +259,7 @@ } } }else { - stringBuilder.append(deviceChannel.getChannelId() + ","); + stringBuilder.append(deviceChannel.getChannelId()).append(","); } } if (channels.size() > 0) { @@ -286,7 +277,6 @@ logger.debug("[鐩綍鏌ヨ]鏀跺埌鐨勬暟鎹瓨鍦ㄩ噸澶嶏細 {}" , stringBuilder); } try { -// int cleanChannelsResult = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); int cleanChannelsResult = deviceChannelMapper.cleanChannelsNotInList(deviceId, channels); int limitCount = 300; boolean result = cleanChannelsResult < 0; @@ -1133,4 +1123,9 @@ public List<ChannelSourceInfo> getChannelSource(String platformId, String gbId) { return platformMapper.getChannelSource(platformId, gbId); } + + @Override + public void updateChannelPotion(String deviceId, String channelId, double longitude, double latitude) { + deviceChannelMapper.updatePotion(deviceId, channelId, longitude, latitude); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java index 860f6a3..365903c 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/MobilePosition/MobilePositionController.java @@ -3,14 +3,12 @@ import java.util.List; import java.util.UUID; -import javax.sip.message.Response; - 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.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.github.pagehelper.util.StringUtil; import io.swagger.annotations.Api; @@ -42,7 +40,7 @@ private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommander cmder; @@ -161,9 +159,11 @@ interval = "5"; } Device device = storager.queryVideoDevice(deviceId); - + device.setSubscribeCycleForMobilePosition(Integer.parseInt(expires)); + device.setMobilePositionSubmissionInterval(Integer.parseInt(interval)); + storager.updateDevice(device); String result = msg; - if (cmder.mobilePositionSubscribe(device, Integer.parseInt(expires), Integer.parseInt(interval))) { + if (cmder.mobilePositionSubscribe(device, null, null)) { result += "锛屾垚鍔�"; } else { result += "锛屽け璐�"; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java index b3de5af..88c15a4 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceConfig.java @@ -7,14 +7,12 @@ package com.genersoft.iot.vmp.vmanager.gb28181.device; -import javax.sip.message.Response; - import com.alibaba.fastjson.JSONObject; 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.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -39,7 +37,7 @@ private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommander cmder; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java index 183561a..4db11e3 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceControl.java @@ -7,14 +7,12 @@ package com.genersoft.iot.vmp.vmanager.gb28181.device; -import javax.sip.message.Response; - import com.alibaba.fastjson.JSONObject; 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.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; @@ -40,7 +38,7 @@ private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommander cmder; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index 178ad9b..5e9cd60 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -10,7 +10,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.DeviceChannelTree; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; @@ -28,6 +28,7 @@ import org.springframework.web.context.request.async.DeferredResult; import java.util.List; +import java.util.Set; import java.util.UUID; @Api(tags = "鍥芥爣璁惧鏌ヨ", value = "鍥芥爣璁惧鏌ヨ") @@ -40,7 +41,7 @@ private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -213,7 +214,12 @@ if (isSuccess) { redisCatchStorage.clearCatchByDeviceId(deviceId); // 鍋滄姝よ澶囩殑璁㈤槄鏇存柊 - dynamicTask.stop(deviceId); + Set<String> allKeys = dynamicTask.getAllKeys(); + for (String key : allKeys) { + if (key.startsWith(deviceId)) { + dynamicTask.stop(key); + } + } JSONObject json = new JSONObject(); json.put("deviceId", deviceId); return new ResponseEntity<>(json.toString(),HttpStatus.OK); @@ -321,18 +327,38 @@ if (!StringUtils.isEmpty(device.getCharset())) deviceInStore.setCharset(device.getCharset()); if (!StringUtils.isEmpty(device.getMediaServerId())) deviceInStore.setMediaServerId(device.getMediaServerId()); + // 鐩綍璁㈤槄鐩稿叧鐨勪俊鎭� if (device.getSubscribeCycleForCatalog() > 0) { if (deviceInStore.getSubscribeCycleForCatalog() == 0 || deviceInStore.getSubscribeCycleForCatalog() != device.getSubscribeCycleForCatalog()) { + deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); // 寮�鍚闃� deviceService.addCatalogSubscribe(deviceInStore); } }else if (device.getSubscribeCycleForCatalog() == 0) { if (deviceInStore.getSubscribeCycleForCatalog() != 0) { + deviceInStore.setSubscribeCycleForCatalog(device.getSubscribeCycleForCatalog()); // 鍙栨秷璁㈤槄 deviceService.removeCatalogSubscribe(deviceInStore); } } + // 绉诲姩浣嶇疆璁㈤槄鐩稿叧鐨勪俊鎭� + if (device.getSubscribeCycleForMobilePosition() > 0) { + if (deviceInStore.getSubscribeCycleForMobilePosition() == 0 || deviceInStore.getSubscribeCycleForMobilePosition() != device.getSubscribeCycleForMobilePosition()) { + deviceInStore.setMobilePositionSubmissionInterval(device.getMobilePositionSubmissionInterval()); + deviceInStore.setSubscribeCycleForMobilePosition(device.getSubscribeCycleForMobilePosition()); + // 寮�鍚闃� + deviceService.addMobilePositionSubscribe(deviceInStore); + } + }else if (device.getSubscribeCycleForMobilePosition() == 0) { + if (deviceInStore.getSubscribeCycleForMobilePosition() != 0) { + // 鍙栨秷璁㈤槄 + deviceService.removeMobilePositionSubscribe(deviceInStore); + } + } + + // TODO 鎶ヨ璁㈤槄鐩稿叧鐨勪俊鎭� + storager.updateDevice(device); cmder.deviceInfoQuery(device); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java index 46be681..300546f 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java @@ -1,7 +1,7 @@ package com.genersoft.iot.vmp.vmanager.gb28181.gbStream; import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean.GbStreamParam; import com.genersoft.iot.vmp.service.IGbStreamService; import com.github.pagehelper.PageInfo; @@ -27,7 +27,7 @@ private IGbStreamService gbStreamService; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; /** diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java index e07c81d..a2619fa 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java @@ -4,13 +4,12 @@ import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.IMediaService; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -27,7 +26,7 @@ private final static Logger logger = LoggerFactory.getLogger(MediaController.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IStreamPushService streamPushService; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index b26ae76..ff424a0 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -4,13 +4,13 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.VideoManagerConstants; import com.genersoft.iot.vmp.conf.DynamicTask; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; 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.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam; @@ -29,7 +29,6 @@ import com.genersoft.iot.vmp.conf.SipConfig; import java.util.List; -import java.util.Locale; /** * 绾ц仈骞冲彴绠$悊 @@ -43,10 +42,10 @@ private final static Logger logger = LoggerFactory.getLogger(PlatformController.class); @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -118,7 +117,7 @@ PageInfo<ParentPlatform> parentPlatformPageInfo = storager.queryParentPlatformList(page, count); if (parentPlatformPageInfo.getList().size() > 0) { for (ParentPlatform platform : parentPlatformPageInfo.getList()) { - platform.setGpsSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null); + platform.setMobilePositionSubscribe(subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()) != null); platform.setCatalogSubscribe(subscribeHolder.getCatalogSubscribe(platform.getServerGBId()) != null); } } @@ -305,7 +304,7 @@ storager.delCatalogByPlatformId(parentPlatform.getServerGBId()); storager.delRelationByPlatformId(parentPlatform.getServerGBId()); // 鍋滄鍙戦�佷綅缃闃呭畾鏃朵换鍔� - String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_MobilePosition_" + parentPlatform.getServerGBId(); + String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetting.getServerId() + "_MobilePosition_" + parentPlatform.getServerGBId(); dynamicTask.stop(key); // 鍒犻櫎缂撳瓨鐨勮闃呬俊鎭� subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index 930bb33..20ffc00 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -33,13 +33,11 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.web.context.request.async.DeferredResult; import java.util.List; import java.util.UUID; - -import javax.sip.message.Response; @Api(tags = "鍥芥爣璁惧鐐规挱") @CrossOrigin @@ -56,7 +54,7 @@ private VideoStreamSessionManager streamSession; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java index 2fccaa8..e095a6a 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/playback/PlaybackController.java @@ -2,11 +2,8 @@ import com.genersoft.iot.vmp.common.StreamInfo; 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.ZLMRESTfulUtils; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.service.IPlayService; import io.swagger.annotations.Api; @@ -28,10 +25,8 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.springframework.web.context.request.async.DeferredResult; - -import java.util.UUID; @Api(tags = "瑙嗛鍥炴斁") @CrossOrigin @@ -45,7 +40,7 @@ private SIPCommander cmder; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java index 95d1aef..4a29f8e 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/ptz/PtzController.java @@ -13,13 +13,11 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; -import javax.sip.message.Response; - 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.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import java.util.UUID; @@ -35,7 +33,7 @@ private SIPCommander cmder; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private DeferredResultHolder resultHolder; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java index d33dd2a..9d6b8fc 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/record/GBRecordController.java @@ -2,12 +2,9 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.gb28181.bean.InviteStreamInfo; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IPlayService; -import com.genersoft.iot.vmp.service.bean.SSRCInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -28,7 +25,7 @@ import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import java.util.UUID; @@ -44,7 +41,7 @@ private SIPCommander cmder; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private DeferredResultHolder resultHolder; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java index 650dbe0..c147a9d 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/log/LogController.java @@ -1,7 +1,6 @@ package com.genersoft.iot.vmp.vmanager.log; -import com.genersoft.iot.vmp.conf.UserSetup; -import com.genersoft.iot.vmp.media.zlm.ZLMRunner; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.service.ILogService; import com.genersoft.iot.vmp.storager.dao.dto.LogDto; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; @@ -33,7 +32,7 @@ private ILogService logService; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); @@ -69,7 +68,7 @@ if (StringUtils.isEmpty(query)) query = null; if (StringUtils.isEmpty(startTime)) startTime = null; if (StringUtils.isEmpty(endTime)) endTime = null; - if (!userSetup.getLogInDatebase()) { + if (!userSetting.getLogInDatebase()) { logger.warn("鑷姩璁板綍鏃ュ織鍔熻兘宸插叧闂紝鏌ヨ缁撴灉鍙兘涓嶅畬鏁淬��"); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java index 1500f35..a0e7a73 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/server/ServerController.java @@ -5,7 +5,7 @@ import com.genersoft.iot.vmp.VManageBootstrap; import com.genersoft.iot.vmp.common.VersionPo; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.conf.UserSetup; +import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.VersionInfo; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.service.IMediaServerService; @@ -48,7 +48,7 @@ SipConfig sipConfig; @Autowired - UserSetup userSetup; + UserSetting userSetting; @Value("${server.port}") private int serverPort; @@ -232,14 +232,14 @@ jsonObject.put("server.port", serverPort); if (StringUtils.isEmpty(type)) { jsonObject.put("sip", JSON.toJSON(sipConfig)); - jsonObject.put("base", JSON.toJSON(userSetup)); + jsonObject.put("base", JSON.toJSON(userSetting)); }else { switch (type){ case "sip": jsonObject.put("sip", sipConfig); break; case "base": - jsonObject.put("base", userSetup); + jsonObject.put("base", userSetting); break; default: break; diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java index eac742c..9bbe1d7 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiControlController.java @@ -3,7 +3,7 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +23,7 @@ private SIPCommander cmder; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; /** * 璁惧鎺у埗 - 浜戝彴鎺у埗 diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java index 2e96fbe..d4928ec 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiDeviceController.java @@ -4,7 +4,7 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -25,7 +25,7 @@ private final static Logger logger = LoggerFactory.getLogger(ApiDeviceController.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; // @Autowired // private SIPCommander cmder; diff --git a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java index dfc2c44..9362db1 100644 --- a/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/web/gb28181/ApiStreamController.java @@ -2,15 +2,14 @@ import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.UserSetup; +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.transmit.callback.DeferredResultHolder; 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.IPlayService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.gb28181.play.bean.PlayResult; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,10 +32,10 @@ private SIPCommander cmder; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -69,7 +68,7 @@ @RequestParam(required = false)String timeout ){ - DeferredResult<JSONObject> resultDeferredResult = new DeferredResult<>(userSetup.getPlayTimeout() + 10); + DeferredResult<JSONObject> resultDeferredResult = new DeferredResult<>(userSetting.getPlayTimeout() + 10); Device device = storager.queryVideoDevice(serial); if (device == null ) { JSONObject result = new JSONObject(); diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index f7f8604..3f148d6 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -170,6 +170,8 @@ save-position-history: false # 鐐规挱绛夊緟瓒呮椂鏃堕棿,鍗曚綅锛氭绉� play-timeout: 3000 + # 涓婄骇鐐规挱绛夊緟瓒呮椂鏃堕棿,鍗曚綅锛氭绉� + platform-play-timeout: 60000 # 鏄惁寮�鍚帴鍙i壌鏉� interface-authentication: true # 鑷姩閰嶇疆redis 鍙互杩囨湡浜嬩欢 diff --git a/src/main/resources/logback-spring-local.xml b/src/main/resources/logback-spring-local.xml index 9951c69..ec80d2d 100644 --- a/src/main/resources/logback-spring-local.xml +++ b/src/main/resources/logback-spring-local.xml @@ -80,12 +80,12 @@ <appender-ref ref="RollingFileError" /> </root> - <logger name="com.genersoft.iot.vmp.storager.dao" level="INFO"> - <appender-ref ref="STDOUT"/> - </logger> - <logger name="com.genersoft.iot.vmp.gb28181" level="INFO"> - <appender-ref ref="STDOUT"/> - </logger> +<!-- <logger name="com.genersoft.iot.vmp.storager.dao" level="INFO">--> +<!-- <appender-ref ref="STDOUT"/>--> +<!-- </logger>--> +<!-- <logger name="com.genersoft.iot.vmp.gb28181" level="INFO">--> +<!-- <appender-ref ref="STDOUT"/>--> +<!-- </logger>--> <!--璁板綍druid-sql鐨勮褰�--> <logger name="druid.sql.Statement" level="debug" additivity="true"> diff --git a/web_src/src/components/ParentPlatformList.vue b/web_src/src/components/ParentPlatformList.vue index c001071..5becea5 100644 --- a/web_src/src/components/ParentPlatformList.vue +++ b/web_src/src/components/ParentPlatformList.vue @@ -47,8 +47,8 @@ <i v-if="!scope.row.alarmSubscribe" style="font-size: 20px" title="鎶ヨ璁㈤槄" class="iconfont icon-gbaojings subscribe-off " ></i> <i v-if="scope.row.catalogSubscribe" title="鐩綍璁㈤槄" class="iconfont icon-gjichus subscribe-on" ></i> <i v-if="!scope.row.catalogSubscribe" title="鐩綍璁㈤槄" class="iconfont icon-gjichus subscribe-off" ></i> - <i v-if="scope.row.gpsSubscribe" title="浣嶇疆璁㈤槄" class="iconfont icon-gxunjians subscribe-on" ></i> - <i v-if="!scope.row.gpsSubscribe" title="浣嶇疆璁㈤槄" class="iconfont icon-gxunjians subscribe-off" ></i> + <i v-if="scope.row.mobilePositionSubscribe" title="浣嶇疆璁㈤槄" class="iconfont icon-gxunjians subscribe-on" ></i> + <i v-if="!scope.row.mobilePositionSubscribe" title="浣嶇疆璁㈤槄" class="iconfont icon-gxunjians subscribe-off" ></i> </template> </el-table-column> diff --git a/web_src/src/components/dialog/deviceEdit.vue b/web_src/src/components/dialog/deviceEdit.vue index 4f86851..1150d21 100644 --- a/web_src/src/components/dialog/deviceEdit.vue +++ b/web_src/src/components/dialog/deviceEdit.vue @@ -39,6 +39,12 @@ <el-form-item label="鐩綍璁㈤槄鍛ㄦ湡(0涓哄仠鐢ㄨ闃�)" prop="subscribeCycleForCatalog" > <el-input v-model="form.subscribeCycleForCatalog" clearable ></el-input> </el-form-item> + <el-form-item label="绉诲姩浣嶇疆璁㈤槄鍛ㄦ湡(0涓哄仠鐢ㄨ闃�)" prop="subscribeCycleForCatalog" > + <el-input v-model="form.subscribeCycleForMobilePosition" clearable ></el-input> + </el-form-item> + <el-form-item label="绉诲姩浣嶇疆鎶ラ�侀棿闅�" prop="subscribeCycleForCatalog" > + <el-input v-model="form.mobilePositionSubmissionInterval" clearable ></el-input> + </el-form-item> <el-form-item> <div style="float: right;"> <el-button type="primary" @click="onSubmit" >纭</el-button> -- Gitblit v1.8.0