From 7e755f405dd1112a201b9dbde7e2d6cff8abc8f4 Mon Sep 17 00:00:00 2001 From: 648540858 <456panlinlin> Date: Fri, 1 Apr 2022 16:45:29 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E5=9B=BD=E6=A0=87=E7=A7=BB?= =?UTF-8?q?=E5=8A=A8=E4=BD=8D=E7=BD=AE=E8=AE=A2=E9=98=85=EF=BC=8C=E6=94=B6?= =?UTF-8?q?=E5=88=B0=E6=96=B0=E4=BD=8D=E7=BD=AE=E5=8F=91=E9=80=81redis?= =?UTF-8?q?=E6=B6=88=E6=81=AF;=E6=94=AF=E6=8C=81=E9=80=9A=E9=81=93redis?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8B=89=E8=B5=B7=E7=AC=AC=E4=B8=89=E6=96=B9?= =?UTF-8?q?=E6=8E=A8=E6=B5=81;=E4=BA=91=E5=8F=B0=E6=8E=A7=E5=88=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0ControlPriority=E5=AD=97=E6=AE=B5;=E5=A4=84?= =?UTF-8?q?=E7=90=86sql=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/update.sql | 8 + .../iot/vmp/common/VideoManagerConstants.java | 18 +- .../iot/vmp/conf/ApiAccessFilter.java | 4 +- .../genersoft/iot/vmp/conf/DynamicTask.java | 9 +- .../genersoft/iot/vmp/conf/RedisConfig.java | 2 +- ...edisKeyExpirationEventMessageListener.java | 9 +- .../iot/vmp/conf/SipPlatformRunner.java | 5 +- .../conf/{UserSetup.java => UserSetting.java} | 16 +- .../iot/vmp/conf/runner/SipDeviceRunner.java | 9 +- .../vmp/conf/security/WebSecurityConfig.java | 8 +- .../gb28181/auth/RegisterLogicHandler.java | 4 +- .../iot/vmp/gb28181/bean/Device.java | 40 +- .../vmp/gb28181/bean/InviteStreamType.java | 8 + .../iot/vmp/gb28181/bean/ParentPlatform.java | 12 +- .../iot/vmp/gb28181/bean/SendRtpItem.java | 12 +- .../gb28181/event/DeviceOffLineDetector.java | 6 +- .../KeepaliveTimeoutListenerForPlatform.java | 41 +- .../offline/KeepliveTimeoutListener.java | 15 +- .../event/offline/OfflineEventListener.java | 13 +- .../event/online/OnlineEventListener.java | 12 +- .../PlatformKeepaliveExpireEventLister.java | 5 +- .../PlatformCycleRegisterEventLister.java | 4 +- .../PlatformNotRegisterEventLister.java | 4 +- .../SubscribeListenerForPlatform.java | 10 +- .../subscribe/catalog/CatalogEventLister.java | 13 +- .../vmp/gb28181/session/CatalogDataCatch.java | 4 +- .../session/VideoStreamSessionManager.java | 18 +- .../vmp/gb28181/task/GPSSubscribeTask.java | 32 +- .../gb28181/transmit/cmd/ISIPCommander.java | 4 +- .../transmit/cmd/impl/SIPCommander.java | 29 +- .../cmd/impl/SIPCommanderFroPlatform.java | 1 - .../request/impl/ByeRequestProcessor.java | 21 +- .../request/impl/InviteRequestProcessor.java | 219 ++-- .../request/impl/NotifyRequestProcessor.java | 40 +- .../impl/RegisterRequestProcessor.java | 4 +- .../impl/SubscribeRequestProcessor.java | 25 +- .../impl/message/MessageRequestProcessor.java | 4 +- .../cmd/DeviceControlQueryMessageHandler.java | 5 +- .../notify/cmd/AlarmNotifyMessageHandler.java | 10 +- .../cmd/CatalogNotifyMessageHandler.java | 29 +- .../cmd/KeepaliveNotifyMessageHandler.java | 6 +- .../MobilePositionNotifyMessageHandler.java | 10 +- .../query/cmd/AlarmQueryMessageHandler.java | 10 +- .../query/cmd/CatalogQueryMessageHandler.java | 5 +- .../cmd/DeviceStatusQueryMessageHandler.java | 4 +- .../cmd/RecordInfoQueryMessageHandler.java | 6 +- .../cmd/CatalogResponseMessageHandler.java | 13 +- .../cmd/DeviceInfoResponseMessageHandler.java | 4 +- .../MobilePositionResponseMessageHandler.java | 10 +- .../impl/RegisterResponseProcessor.java | 4 +- .../vmp/media/zlm/ZLMHttpHookListener.java | 25 +- .../vmp/media/zlm/ZLMMediaListManager.java | 35 +- .../vmp/media/zlm/dto/ChannelOnlineEvent.java | 6 + .../zlm/event/ZLMKeepliveTimeoutListener.java | 11 +- .../iot/vmp/service/IDeviceService.java | 13 + .../vmp/service/StreamGPSSubscribeTask.java | 4 +- .../service/bean/CatalogSubscribeTask.java | 4 +- .../service/bean/MessageForPushChannel.java | 112 ++ .../bean/MobilePositionSubscribeTask.java | 38 + .../vmp/service/impl/DeviceServiceImpl.java | 43 +- .../service/impl/MediaServerServiceImpl.java | 59 +- .../vmp/service/impl/MediaServiceImpl.java | 5 +- .../iot/vmp/service/impl/PlayServiceImpl.java | 16 +- .../vmp/service/impl/RedisGPSMsgListener.java | 2 +- .../service/impl/StreamProxyServiceImpl.java | 15 +- .../service/impl/StreamPushServiceImpl.java | 12 +- .../iot/vmp/storager/IRedisCatchStorage.java | 4 + ...torager.java => IVideoManagerStorage.java} | 963 +++++++++--------- .../vmp/storager/dao/DeviceChannelMapper.java | 5 +- .../iot/vmp/storager/dao/DeviceMapper.java | 9 + .../storager/impl/RedisCatchStorageImpl.java | 154 +-- ...Impl.java => VideoManagerStorageImpl.java} | 25 +- .../MobilePositionController.java | 12 +- .../vmanager/gb28181/device/DeviceConfig.java | 6 +- .../gb28181/device/DeviceControl.java | 6 +- .../vmanager/gb28181/device/DeviceQuery.java | 32 +- .../gb28181/gbStream/GbStreamController.java | 4 +- .../gb28181/media/MediaController.java | 5 +- .../gb28181/platform/PlatformController.java | 13 +- .../vmanager/gb28181/play/PlayController.java | 6 +- .../gb28181/playback/PlaybackController.java | 9 +- .../vmanager/gb28181/ptz/PtzController.java | 6 +- .../gb28181/record/GBRecordController.java | 7 +- .../iot/vmp/vmanager/log/LogController.java | 7 +- .../vmp/vmanager/server/ServerController.java | 8 +- .../vmp/web/gb28181/ApiControlController.java | 4 +- .../vmp/web/gb28181/ApiDeviceController.java | 4 +- .../vmp/web/gb28181/ApiStreamController.java | 11 +- src/main/resources/all-application.yml | 2 + src/main/resources/logback-spring-local.xml | 12 +- web_src/src/components/ParentPlatformList.vue | 4 +- web_src/src/components/dialog/deviceEdit.vue | 6 + 92 files changed, 1460 insertions(+), 1068 deletions(-) create mode 100644 sql/update.sql rename src/main/java/com/genersoft/iot/vmp/conf/{UserSetup.java => UserSetting.java} (90%) create mode 100644 src/main/java/com/genersoft/iot/vmp/gb28181/bean/InviteStreamType.java create mode 100644 src/main/java/com/genersoft/iot/vmp/media/zlm/dto/ChannelOnlineEvent.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/MessageForPushChannel.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/bean/MobilePositionSubscribeTask.java rename src/main/java/com/genersoft/iot/vmp/storager/{IVideoManagerStorager.java => IVideoManagerStorage.java} (95%) rename src/main/java/com/genersoft/iot/vmp/storager/impl/{VideoManagerStoragerImpl.java => VideoManagerStorageImpl.java} (98%) diff --git a/sql/update.sql b/sql/update.sql new file mode 100644 index 00000000..58045180 --- /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 0d638435..c4d49a84 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 class VideoManagerConstants { 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"; + + // 接收推流设备的GPS变化通知 + 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 08d030a8..61809743 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 @@ public class ApiAccessFilter extends OncePerRequestFilter { 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 @@ public class ApiAccessFilter extends OncePerRequestFilter { 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 80e39f5f..bbe0e819 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 org.springframework.stereotype.Component; 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 @@ public class DynamicTask { * 延时任务 * @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 必须等待上一个任务结束才开始计时period, cycleForCatalog表示执行的间隔 ScheduledFuture future = threadPoolTaskScheduler.schedule(task, starTime); futureMap.put(key, future); @@ -67,4 +68,8 @@ public class DynamicTask { return futureMap.get(key) != null; } + public Set 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 5f04a083..d46a8ea9 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 @@ public class RedisConfig extends CachingConfigurerSupport { 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 a2281ab0..18483800 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 @@ package com.genersoft.iot.vmp.conf; 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为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 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 7f9f8476..cf16f864 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.ParentPlatform; 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 @@ import java.util.List; 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 d1d0e20b..47765517 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 org.springframework.stereotype.Component; 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; @@ -19,6 +21,8 @@ public class UserSetup { private Long playTimeout = 18000L; + private int platformPlayTimeout = 60000; + private Boolean interfaceAuthentication = Boolean.TRUE; private Boolean recordPushLive = Boolean.TRUE; @@ -134,4 +138,12 @@ public class UserSetup { 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 da4e2eda..2c2ea6d7 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 @@ import java.util.List; 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 @@ public class SipDeviceRunner implements CommandLineRunner { if (device != null && device.getSubscribeCycleForCatalog() > 0) { // 查询在线设备那些开启了订阅,为设备开启定时的目录订阅 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 f0eca856..47cfdaba 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 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { private final static Logger logger = LoggerFactory.getLogger(WebSecurityConfig.class); @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private DefaultUserDetailsServiceImpl userDetailsService; @@ -77,7 +77,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Override public void configure(WebSecurity web) { - if (!userSetup.isInterfaceAuthentication()) { + if (!userSetting.isInterfaceAuthentication()) { web.ignoring().antMatchers("**"); }else { // 可以直接访问的静态数据 @@ -91,7 +91,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter { .antMatchers("/swagger-resources/**") .antMatchers("/v3/api-docs/**") .antMatchers("/js/**"); - List interfaceAuthenticationExcludes = userSetup.getInterfaceAuthenticationExcludes(); + List 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 82390709..8731228a 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 @@ public class RegisterLogicHandler { 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 01d340c1..d50ffb77 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 @@ public class Device { /** * 目录订阅周期,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 class Device { 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 00000000..24d509fd --- /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 8df79394..8aa7b37a 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 @@ public class ParentPlatform { private boolean alarmSubscribe; /** - * 已被订阅GPS信息 + * 已被订阅移动位置信息 */ - private boolean gpsSubscribe; + private boolean mobilePositionSubscribe; public Integer getId() { return id; @@ -322,11 +322,11 @@ public class ParentPlatform { 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 a2c38acb..4b63ec53 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 @@ public class SendRtpItem { private String CallId; /** - * 是否是play, false是playback + * 播放类型 */ - private boolean isPlay; + private InviteStreamType playType; private byte[] transaction; @@ -197,12 +197,12 @@ public class SendRtpItem { 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 ea2fa6c2..5513ba28 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 @@ public class DeviceOffLineDetector { 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 3b611b5b..e0e4a270 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 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent 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 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent 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 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent 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 151b68dc..9e8c6471 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 @@ public class KeepliveTimeoutListener extends RedisKeyExpirationEventMessageListe 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为空,即不让应用去修改redis的默认配置,因为Redis服务出于安全会禁用CONFIG命令给远程用户使用 setKeyspaceNotificationsConfigParameter(""); } @@ -54,7 +51,7 @@ public class KeepliveTimeoutListener extends RedisKeyExpirationEventMessageListe public void onMessage(Message message, byte[] pattern) { // 获取失效的key 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 9e67191b..b7992e4d 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 @@ public class OfflineEventListener implements ApplicationListener { private final static Logger logger = LoggerFactory.getLogger(OfflineEventListener.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private VideoStreamSessionManager streamSession; @@ -45,7 +42,7 @@ public class OfflineEventListener implements ApplicationListener { private RedisUtil redis; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private EventPublisher eventPublisher; @@ -65,7 +62,7 @@ public class OfflineEventListener implements ApplicationListener { logger.debug("设备离线事件触发,deviceId:" + 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 d3580d35..755967be 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.context.ApplicationListener; 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 @@ public class OnlineEventListener implements ApplicationListener { private final static Logger logger = LoggerFactory.getLogger(OnlineEventListener.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IDeviceService deviceService; @@ -47,7 +46,7 @@ public class OnlineEventListener implements ApplicationListener { private SipConfig sipConfig; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private EventPublisher eventPublisher; @@ -65,7 +64,7 @@ public class OnlineEventListener implements ApplicationListener { } 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 @@ public class OnlineEventListener implements ApplicationListener { // 上线添加订阅 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 00926574..67b297c3 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.EventPublisher; 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.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationListener; import org.springframework.stereotype.Component; -import javax.sip.ResponseEvent; import javax.sip.message.Response; /** @@ -29,7 +28,7 @@ public class PlatformKeepaliveExpireEventLister implements ApplicationListener

{ 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 @@ public class CatalogEventLister implements ApplicationListener { private SipConfig config; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IGbStreamService gbStreamService; @@ -64,7 +61,7 @@ public class CatalogEventLister implements ApplicationListener { 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 e3b39749..8a3bc842 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.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.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 @@ public class CatalogDataCatch { private DeferredResultHolder deferredResultHolder; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; public void put(String key, int total, Device device, List 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 6eed17eb..0051b030 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.ClientTransaction; 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 @@ public class VideoStreamSessionManager { private RedisUtil redisUtil; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; public enum SessionType { play, @@ -58,9 +58,9 @@ public class VideoStreamSessionManager { 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 @@ public class VideoStreamSessionManager { 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 class VideoStreamSessionManager { 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 scanResult = redisUtil.scan(key); if (scanResult.size() == 0) return null; return (SsrcTransaction)redisUtil.get((String) scanResult.get(0)); @@ -116,7 +116,7 @@ public class VideoStreamSessionManager { 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 scanResult = redisUtil.scan(key); if (scanResult.size() == 0) return null; List result = new ArrayList<>(); @@ -141,13 +141,13 @@ public class VideoStreamSessionManager { 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 getAllSsrc() { - List ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetup.getServerId() + "_" )); + List ssrcTransactionKeys = redisUtil.scan(String.format("%s_*_*_*_*", VideoManagerConstants.MEDIA_TRANSACTION_USED_PREFIX+ userSetting.getServerId() + "_" )); List 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 4b21638c..a2716e3e 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.bean.SubscribeInfo; 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 @@ import java.util.List; 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 @@ public class GPSSubscribeTask implements Runnable{ 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 @@ public class GPSSubscribeTask implements Runnable{ for (GbStream gbStream : gbStreams) { String gbId = gbStream.getGbId(); GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); - if (gbStream.isStatus()) { - if (gpsMsgInfo != null) { - // 发送GPS消息 - sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); - }else { - // 没有在redis找到新的消息就使用数据库的消息 - gpsMsgInfo = new GPSMsgInfo(); - gpsMsgInfo.setId(gbId); - gpsMsgInfo.setLat(gbStream.getLongitude()); - gpsMsgInfo.setLng(gbStream.getLongitude()); - // 发送GPS消息 - sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); - } + if (gpsMsgInfo != null) { + // 发送GPS消息 + sipCommanderForPlatform.sendNotifyMobilePosition(parentPlatform, gpsMsgInfo, subscribe); + }else { + // 没有在redis找到新的消息就使用数据库的消息 + gpsMsgInfo = new GPSMsgInfo(); + gpsMsgInfo.setId(gbId); + gpsMsgInfo.setLat(gbStream.getLongitude()); + gpsMsgInfo.setLng(gbStream.getLongitude()); + // 发送GPS消息 + 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 9cd89e0e..a33640d4 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 @@ public interface ISIPCommander { * 订阅、取消订阅移动位置 * * @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 0f2242cc..25a2f259 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.alibaba.fastjson.JSONObject; 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.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.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 @@ public class SIPCommander implements ISIPCommander { 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 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("" + channelId + "\r\n"); ptzXml.append("" + cmdStr + "\r\n"); ptzXml.append("\r\n"); + ptzXml.append("5\r\n"); ptzXml.append("\r\n"); ptzXml.append("\r\n"); @@ -277,6 +278,7 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("" + channelId + "\r\n"); ptzXml.append("" + cmdStr + "\r\n"); ptzXml.append("\r\n"); + ptzXml.append("5\r\n"); ptzXml.append("\r\n"); ptzXml.append("\r\n"); @@ -311,6 +313,7 @@ public class SIPCommander implements ISIPCommander { ptzXml.append("" + channelId + "\r\n"); ptzXml.append("" + cmdString + "\r\n"); ptzXml.append("\r\n"); + ptzXml.append("5\r\n"); ptzXml.append("\r\n"); ptzXml.append("\r\n"); @@ -365,7 +368,7 @@ public class SIPCommander implements ISIPCommander { 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 @@ public class SIPCommander implements ISIPCommander { 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 @@ public class SIPCommander implements ISIPCommander { 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 @@ public class SIPCommander implements ISIPCommander { * 订阅、取消订阅移动位置 * * @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 @@ public class SIPCommander implements ISIPCommander { subscribePostitionXml.append("MobilePosition\r\n"); subscribePostitionXml.append("" + (int)((Math.random()*9+1)*100000) + "\r\n"); subscribePostitionXml.append("" + device.getDeviceId() + "\r\n"); - if (expires > 0) { - subscribePostitionXml.append("" + String.valueOf(interval) + "\r\n"); + if (device.getSubscribeCycleForMobilePosition() > 0) { + subscribePostitionXml.append("" + String.valueOf(device.getMobilePositionSubmissionInterval()) + "\r\n"); } subscribePostitionXml.append("\r\n"); @@ -1456,8 +1457,8 @@ public class SIPCommander implements ISIPCommander { 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 a67bbbd4..0edbae42 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 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { : udpSipProvider.getNewCallId(); callIdHeader.setCallId(subscribeInfo.getCallId()); -// sendNotify(parentPlatform, deviceStatusXml.toString(), subscribeInfo, eventResult -> { logger.error("发送NOTIFY通知消息失败。错误:{} {}", 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 e487447a..bdea90f6 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 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; 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.gb28181.transmit.event.request.SIPRequestProcessorP 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 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private ZLMRTPServerFactory zlmrtpServerFactory; @@ -99,10 +100,20 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In 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 b1c7a31c..5580a9eb 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.ISIPRequestProcessor import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.media.zlm.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.beans.factory.annotation.Autowired; 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 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements private SIPCommanderFroPlatform cmderFroPlatform; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -97,6 +88,12 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @Autowired private VideoStreamSessionManager sessionManager; + @Autowired + private UserSetting userSetting; + + @Autowired + private ZLMMediaListManager mediaListManager; + @Override public void afterPropertiesSet() throws Exception { @@ -153,12 +150,6 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements 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,呼叫转接中 }else if (catalog != null) { responseAck(evt, Response.BAD_REQUEST, "catalog channel can not play"); // 目录不支持点播 @@ -273,13 +264,11 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements 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 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements 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 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements }); 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 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } }); }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 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } } }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("服务器端口资源不足"); - 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())) { + // 发送redis消息以使设备上线 + logger.info("[ app={}, stream={} ]通道离线,发送redis信息控制设备开始推流",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); + + if (sendRtpItem == null) { + logger.warn("服务器端口资源不足"); + 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); - // 写入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"); + }); } + }else { + SendRtpItem sendRtpItem = zlmrtpServerFactory.createSendRtpItem(mediaServerItem, addressStr, port, ssrc, requesterId, + gbStream.getApp(), gbStream.getStream(), channelId, + mediaTransmissionTCP); + + + if (sendRtpItem == null) { + logger.warn("服务器端口资源不足"); + 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); } - content.append("y="+ ssrc + "\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(); - } + + } } @@ -466,6 +504,39 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } } + 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 3961eeab..1270202e 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.NumericUtil; 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 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements 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 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements */ 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 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements } } 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 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements 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() ); + // 发送redis消息。 通知位置信息的变化 + 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 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements 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 class NotifyRequestProcessor extends SIPRequestProcessorParent implements 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 cb8b723a..54a52044 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.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.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 @@ public class RegisterRequestProcessor extends SIPRequestProcessorParent implemen 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 4acec149..2cd5b002 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 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl; 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.transmit.event.request.SIPRequestProcessorP 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 org.springframework.stereotype.Component; 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 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme private ISIPCommanderForPlatform sipCommanderForPlatform; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Lazy @Autowired @@ -70,7 +68,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme private DynamicTask dynamicTask; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired @@ -135,12 +133,21 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme /** * 处理移动位置订阅消息 */ - 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("接收到{}的MobilePosition订阅", platformId); StringBuilder resultXml = new StringBuilder(200); resultXml.append("\r\n") @@ -193,7 +200,7 @@ public class SubscribeRequestProcessor extends SIPRequestProcessorParent impleme 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("接收到{}的Catalog订阅", platformId); StringBuilder resultXml = new StringBuilder(200); resultXml.append("\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 a0c1a38f..4f1249ab 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.ISIPRequestProcessor import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.dom4j.DocumentException; import org.dom4j.Element; import org.slf4j.Logger; @@ -43,7 +43,7 @@ public class MessageRequestProcessor extends SIPRequestProcessorParent implement 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 980ec5d7..089cbc91 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.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler; -import com.genersoft.iot.vmp.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 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent 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 8f412f7d..302ceda1 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.IMessag 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 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme 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 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme 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 a77179c7..fc7e2332 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,21 +23,17 @@ import java.util.List; @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 { notifyMessageHandler.addHandler(cmdType, this); @@ -64,12 +55,12 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple Element snElement = rootElement.element("SN"); String sn = snElement.getText(); // 准备回复通道信息 - List deviceChannels = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); + List deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); // 查询关联的直播通道 - List gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); + List gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); int size = deviceChannels.size() + gbStreams.size(); // 回复目录信息 - List catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); + List catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId()); if (catalogs.size() > 0) { for (PlatformCatalog catalog : catalogs) { if (catalog.getParentId().equals(catalog.getPlatformId())) { @@ -101,7 +92,7 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple 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 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple // 回复无通道 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 edd9fe86..ccb8039f 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.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; -import com.genersoft.iot.vmp.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.InitializingBean; 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 @@ public class KeepaliveNotifyMessageHandler extends SIPRequestProcessorParent imp 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 ab7e5f63..471b2d7e 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.SIPRequestProcessorP 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 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen 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 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen 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 60cf4d07..8c884d5a 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 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query. 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 org.springframework.stereotype.Component; import javax.sip.InvalidArgumentException; import javax.sip.RequestEvent; import javax.sip.SipException; -import javax.sip.header.FromHeader; import javax.sip.message.Response; import java.text.ParseException; -import java.util.List; @Component public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler { @@ -38,7 +32,7 @@ public class AlarmQueryMessageHandler extends SIPRequestProcessorParent implemen 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 40e5297b..a953bd96 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.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; @@ -35,7 +34,7 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem 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 c56151cd..64df786a 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.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.storager.IVideoManagerStorage; import org.dom4j.Element; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -33,7 +33,7 @@ public class DeviceStatusQueryMessageHandler extends SIPRequestProcessorParent i 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 460f0f93..efd6ffdf 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.conf.SipConfig; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; -import com.genersoft.iot.vmp.gb28181.transmit.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 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp 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 47ef6faa..cc54ec95 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 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.respon 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.transmit.event.request.impl.message.respons 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,12 +34,9 @@ import javax.sip.message.Response; 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 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp private ResponseMessageHandler responseMessageHandler; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private DeferredResultHolder deferredResultHolder; @@ -71,7 +68,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp //by brewswang @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -224,7 +221,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp 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 78fc9361..855797e3 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.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; -import com.genersoft.iot.vmp.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 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent 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 b456386f..dca28660 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.SIPRequestProcessorP 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 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar 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 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar 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 6c33406f..ed937744 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.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.response.SIPResponseProcessorAbstract; import com.genersoft.iot.vmp.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 @@ public class RegisterResponseProcessor extends SIPResponseProcessorAbstract { 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 c3c30a6a..94ea4e36 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 @@ package com.genersoft.iot.vmp.media.zlm; 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.event.subscribe.catalog.CatalogEvent; 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 @@ public class ZLMHttpHookListener { private IPlayService playService; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -81,7 +78,7 @@ public class ZLMHttpHookListener { private ZLMHttpHookSubscribe subscribe; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private VideoStreamSessionManager sessionManager; @@ -189,6 +186,12 @@ public class ZLMHttpHookListener { 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 @@ public class ZLMHttpHookListener { 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 ssrcTransactionForAll = sessionManager.getSsrcTransactionForAll(null, null, null, stream); if (ssrcTransactionForAll != null && ssrcTransactionForAll.size() == 1) { @@ -412,7 +415,7 @@ public class ZLMHttpHookListener { 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 @@ public class ZLMHttpHookListener { } 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 fa4aa35f..579842da 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.stereotype.Component; 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 @@ public class ZLMMediaListManager { private IRedisCatchStorage redisCatchStorage; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private GbStreamMapper gbStreamMapper; @@ -58,7 +57,9 @@ public class ZLMMediaListManager { private ZLMHttpHookSubscribe subscribe; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; + + private Map channelOnlineEvents = new ConcurrentHashMap<>(); public void updateMediaList(MediaServerItem mediaServerItem) { @@ -109,7 +110,7 @@ public class ZLMMediaListManager { // 查找此直播流是否存在redis预设gbId StreamPushItem transform = streamPushService.transform(mediaItem); // 从streamId取出查询关键值 - 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 @@ public class ZLMMediaListManager { 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 @@ public class ZLMMediaListManager { 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 00000000..ba7daecd --- /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 042b2d12..dd1f69e8 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 @@ package com.genersoft.iot.vmp.media.zlm.event; 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.Logger; 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 @@ public class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi 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 class ZLMKeepliveTimeoutListener extends RedisKeyExpirationEventMessageLi public void onMessage(Message message, byte[] pattern) { // 获取失效的key 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 0cb84136..68a2af39 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 @@ public interface IDeviceService { */ 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 fd5bb060..5bdd9f5d 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 @@ package com.genersoft.iot.vmp.service; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.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 @@ public class StreamGPSSubscribeTask { 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 cb027c82..68419bfc 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 org.slf4j.LoggerFactory; 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 class CatalogSubscribeTask implements Runnable{ 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 00000000..3ab1b80d --- /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; + + /** + * 流Id + */ + private String stream; + + /** + * 国标ID + */ + private String gbId; + + /** + * 请求的平台ID + */ + private String platFormId; + + /** + * 请求平台名称 + */ + private String platFormName; + + /** + * WVP服务ID + */ + private String serverId; + + /** + * 目标流媒体节点ID + */ + 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 00000000..df4bc6cc --- /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 0fc6f4cf..384bf7f2 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.bean.Device; 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 @@ public class DeviceServiceImpl implements IDeviceService { @Autowired private DynamicTask dynamicTask; -; @Autowired private ISIPCommander sipCommander; @@ -30,9 +30,9 @@ public class DeviceServiceImpl implements IDeviceService { 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 @@ public class DeviceServiceImpl implements IDeviceService { 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 @@ public class DeviceServiceImpl implements IDeviceService { 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 43312a8f..a667bab5 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.JSON; 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.ZLMRESTfulUtils; 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.Logger; 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 @@ public class MediaServerServiceImpl implements IMediaServerService { private Integer serverPort; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private ZLMRESTfulUtils zlmresTfulUtils; @@ -84,7 +78,7 @@ public class MediaServerServiceImpl implements IMediaServerService { private RedisUtil redisUtil; @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IStreamProxyService streamProxyService; @@ -111,10 +105,10 @@ public class MediaServerServiceImpl implements IMediaServerService { 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是否存在此mediaServer - 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 @@ public class MediaServerServiceImpl implements IMediaServerService { return null; } // 获取mediaServer可用的ssrc - 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 @@ public class MediaServerServiceImpl implements IMediaServerService { 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 @@ public class MediaServerServiceImpl implements IMediaServerService { @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 @@ public class MediaServerServiceImpl implements IMediaServerService { ) ); } - 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 getAll() { List result = new ArrayList<>(); - List mediaServerKeys = redisUtil.scan(String.format("%S*", VideoManagerConstants.MEDIA_SERVER_PREFIX+ userSetup.getServerId() + "_" )); - String onlineKey = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + List 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 @@ public class MediaServerServiceImpl implements IMediaServerService { @Override public List getAllOnline() { - String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId(); Set mediaServerIdSet = redisUtil.zRevRange(key, 0, -1); List 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 @@ public class MediaServerServiceImpl implements IMediaServerService { 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 @@ public class MediaServerServiceImpl implements IMediaServerService { @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 @@ public class MediaServerServiceImpl implements IMediaServerService { 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 @@ public class MediaServerServiceImpl implements IMediaServerService { 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 @@ public class MediaServerServiceImpl implements IMediaServerService { @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 @@ public class MediaServerServiceImpl implements IMediaServerService { 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 @@ public class MediaServerServiceImpl implements IMediaServerService { */ @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 @@ public class MediaServerServiceImpl implements IMediaServerService { @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 @@ public class MediaServerServiceImpl implements IMediaServerService { 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 3c776b49..9253b517 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.alibaba.fastjson.JSONObject; 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 @@ public class MediaServiceImpl implements IMediaService { 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 7334184f..61c37a81 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.JSON; 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.PlayBackCallback; 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 @@ public class PlayServiceImpl implements IPlayService { private final static Logger logger = LoggerFactory.getLogger(PlayServiceImpl.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommander cmder; @@ -83,7 +83,7 @@ public class PlayServiceImpl implements IPlayService { private VideoStreamSessionManager streamSession; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @@ -99,7 +99,7 @@ public class PlayServiceImpl implements IPlayService { String uuid = UUID.randomUUID().toString(); msg.setId(uuid); playResult.setUuid(uuid); - DeferredResult> result = new DeferredResult<>(userSetup.getPlayTimeout()); + DeferredResult> result = new DeferredResult<>(userSetting.getPlayTimeout()); playResult.setResult(result); // 录像查询以channelId作为deviceId查询 resultHolder.put(key, uuid, result); @@ -255,7 +255,7 @@ public class PlayServiceImpl implements IPlayService { 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 @@ public class PlayServiceImpl implements IPlayService { // 回复之前所有的点播请求 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 @@ public class PlayServiceImpl implements IPlayService { // 回复之前所有的点播请求 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 92bcd5e8..c688d13f 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 @@ public class RedisGPSMsgListener implements MessageListener { @Override public void onMessage(Message message, byte[] bytes) { - logger.debug("收到来自REDIS的GPS通知: {}", new String(message.getBody())); + logger.info("收到来自REDIS的GPS通知: {}", 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 3e82e8d8..aca30825 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 @@ package com.genersoft.iot.vmp.service.impl; 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 @@ public class StreamProxyServiceImpl implements IStreamProxyService { private final static Logger logger = LoggerFactory.getLogger(StreamProxyServiceImpl.class); @Autowired - private IVideoManagerStorager videoManagerStorager; + private IVideoManagerStorage videoManagerStorager; @Autowired private IMediaService mediaService; @@ -59,10 +56,10 @@ public class StreamProxyServiceImpl implements IStreamProxyService { 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 @@ public class StreamProxyServiceImpl implements IStreamProxyService { 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 aab22822..3aaa7353 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.JSON; 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 @@ public class StreamPushServiceImpl implements IStreamPushService { private IRedisCatchStorage redisCatchStorage; @Autowired - private UserSetup userSetup; + private UserSetting userSetting; @Autowired private IMediaServerService mediaServerService; @@ -263,7 +259,7 @@ public class StreamPushServiceImpl implements IStreamPushService { 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 @@ public class StreamPushServiceImpl implements IStreamPushService { // 移除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 e669ab45..e66dfa0b 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.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.MessageForPushChannel; import com.genersoft.iot.vmp.service.bean.SSRCInfo; import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; @@ -212,4 +213,7 @@ public interface IRedisCatchStorage { void addNetInfo(Map 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 95% 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 abbe2033..11d8b840 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 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 queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit); - - /** - * 获取某个设备的通道树 - * @param deviceId 设备ID - * @return - */ - List tree(String deviceId); - - /** - * 获取某个设备的通道列表 - * - * @param deviceId 设备ID - * @return - */ - public List queryChannelsByDeviceId(String deviceId); - public List 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 设备对象数组 - */ - public PageInfo queryVideoDeviceList(int page, int count); - - /** - * 获取多个设备 - * - * @return List 设备对象数组 - */ - public List 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 queryParentPlatformList(int page, int count); - - /** - * 获取所有已启用的平台 - * @return - */ - List queryEnableParentPlatformList(boolean enable); - - /** - * 获取上级平台 - * @param platformGbId - * @return - */ - ParentPlatform queryParentPlatByServerGBId(String platformGbId); - - /** - * 所有平台离线 - */ - void outlineForAllParentPlatform(); - - /** - * 查询通道信息,不区分设备(已关联平台或全部) - */ - PageInfo queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId); - - /** - * 查询设备的通道信息 - */ - List queryChannelListInParentPlatform(String platformId); - - - /** - * 更新上级平台的通道信息 - * @param platformId - * @param channelReduces - * @return - */ - int updateChannelForGB(String platformId, List channelReduces, String catalogId); - - /** - * 移除上级平台的通道信息 - * @param platformId - * @param channelReduces - * @return - */ - int delChannelForGB(String platformId, List channelReduces); - - - DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); - - List queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); - List queryStreamInParentPlatformAndCatalog(String platformId, String catalogId); - - Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); - - - /** - * 添加Mobile Position设备移动位置 - * @param mobilePosition - * @return - */ - public boolean insertMobilePosition(MobilePosition mobilePosition); - - /** - * 查询移动位置轨迹 - * @param deviceId - * @param startTime - * @param endTime - */ - public List queryMobilePositions(String deviceId, String startTime, String endTime); - - /** - * 查询最新移动位置 - * @param deviceId - */ - public MobilePosition queryLatestPosition(String deviceId); - - /** - * 删除指定设备的所有移动位置 - * @param deviceId - */ - public int clearMobilePositionsByDeviceId(String deviceId); - - /** - * 新增代理流 - * @param streamProxyDto - * @return - */ - public boolean addStreamProxy(StreamProxyItem streamProxyDto); - - /** - * 更新代理流 - * @param streamProxyDto - * @return - */ - public boolean updateStreamProxy(StreamProxyItem streamProxyDto); - - /** - * 移除代理流 - * @param app - * @param stream - * @return - */ - public int deleteStreamProxy(String app, String stream); - - /** - * 按照是否启用获取代理流 - * @param enable - * @return - */ - public List getStreamProxyListForEnable(boolean enable); - - /** - * 按照是app和stream获取代理流 - * @param app - * @param stream - * @return - */ - public StreamProxyItem queryStreamProxy(String app, String stream); - - /** - * 获取代理流 - * @param page - * @param count - * @return - */ - PageInfo queryStreamProxyList(Integer page, Integer count); - - /** - * 根据国标ID获取平台关联的直播流 - * @param platformId - * @param channelId - * @return - */ - GbStream queryStreamInParentPlatform(String platformId, String channelId); - - /** - * 获取平台关联的直播流 - * @param platformId - * @return - */ - List queryGbStreamListInPlatform(String platformId); - - /** - * 批量更新推流列表 - * @param streamPushItems - */ - void updateMediaList(List 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获取启用/不启用的代理列表 - * @param id 媒体ID - * @param enable 启用/不启用 - * @param status 状态 - * @return - */ - List 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与stream获取StreamProxy - * @param app - * @param streamId - * @return - */ - StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); - - /** - * catlog查询结束后完全重写通道信息 - * @param deviceId - * @param deviceChannelList - */ - boolean resetChannels(String deviceId, List deviceChannelList); - - /** - * 获取目录信息 - * @param platformId - * @param parentId - * @return - */ - List 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 queryCatalogInPlatform(String serverGBId); - - int delRelation(PlatformCatalog platformCatalog); - - int updateStreamGPS(List gpsMsgInfo); - - List queryPlatFormListForGBWithGBId(String channelId, List platforms); - - List queryPlatFormListForStreamWithGBId(String app, String stream, List platforms); - - GbStream getGbStream(String app, String streamId); - - void delCatalogByPlatformId(String serverGBId); - - void delRelationByPlatformId(String serverGBId); - - PlatformCatalog queryDefaultCatalogInPlatform(String platformId); - - List getChannelSource(String platformId, String gbId); -} +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 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 queryChannelsByDeviceIdWithStartAndLimit(String deviceId, String query, Boolean hasSubChannel, Boolean online, int start, int limit); + + /** + * 获取某个设备的通道树 + * @param deviceId 设备ID + * @return + */ + List tree(String deviceId); + + /** + * 获取某个设备的通道列表 + * + * @param deviceId 设备ID + * @return + */ + public List queryChannelsByDeviceId(String deviceId); + public List 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 设备对象数组 + */ + public PageInfo queryVideoDeviceList(int page, int count); + + /** + * 获取多个设备 + * + * @return List 设备对象数组 + */ + public List 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 queryParentPlatformList(int page, int count); + + /** + * 获取所有已启用的平台 + * @return + */ + List queryEnableParentPlatformList(boolean enable); + + /** + * 获取上级平台 + * @param platformGbId + * @return + */ + ParentPlatform queryParentPlatByServerGBId(String platformGbId); + + /** + * 所有平台离线 + */ + void outlineForAllParentPlatform(); + + /** + * 查询通道信息,不区分设备(已关联平台或全部) + */ + PageInfo queryAllChannelList(int page, int count, String query, Boolean online, Boolean channelType, String platformId, String catalogId); + + /** + * 查询设备的通道信息 + */ + List queryChannelListInParentPlatform(String platformId); + + + /** + * 更新上级平台的通道信息 + * @param platformId + * @param channelReduces + * @return + */ + int updateChannelForGB(String platformId, List channelReduces, String catalogId); + + /** + * 移除上级平台的通道信息 + * @param platformId + * @param channelReduces + * @return + */ + int delChannelForGB(String platformId, List channelReduces); + + + DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); + + List queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); + List queryStreamInParentPlatformAndCatalog(String platformId, String catalogId); + + Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); + + + /** + * 添加Mobile Position设备移动位置 + * @param mobilePosition + * @return + */ + public boolean insertMobilePosition(MobilePosition mobilePosition); + + /** + * 查询移动位置轨迹 + * @param deviceId + * @param startTime + * @param endTime + */ + public List queryMobilePositions(String deviceId, String startTime, String endTime); + + /** + * 查询最新移动位置 + * @param deviceId + */ + public MobilePosition queryLatestPosition(String deviceId); + + /** + * 删除指定设备的所有移动位置 + * @param deviceId + */ + public int clearMobilePositionsByDeviceId(String deviceId); + + /** + * 新增代理流 + * @param streamProxyDto + * @return + */ + public boolean addStreamProxy(StreamProxyItem streamProxyDto); + + /** + * 更新代理流 + * @param streamProxyDto + * @return + */ + public boolean updateStreamProxy(StreamProxyItem streamProxyDto); + + /** + * 移除代理流 + * @param app + * @param stream + * @return + */ + public int deleteStreamProxy(String app, String stream); + + /** + * 按照是否启用获取代理流 + * @param enable + * @return + */ + public List getStreamProxyListForEnable(boolean enable); + + /** + * 按照是app和stream获取代理流 + * @param app + * @param stream + * @return + */ + public StreamProxyItem queryStreamProxy(String app, String stream); + + /** + * 获取代理流 + * @param page + * @param count + * @return + */ + PageInfo queryStreamProxyList(Integer page, Integer count); + + /** + * 根据国标ID获取平台关联的直播流 + * @param platformId + * @param channelId + * @return + */ + GbStream queryStreamInParentPlatform(String platformId, String channelId); + + /** + * 获取平台关联的直播流 + * @param platformId + * @return + */ + List queryGbStreamListInPlatform(String platformId); + + /** + * 批量更新推流列表 + * @param streamPushItems + */ + void updateMediaList(List 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获取启用/不启用的代理列表 + * @param id 媒体ID + * @param enable 启用/不启用 + * @param status 状态 + * @return + */ + List 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与stream获取StreamProxy + * @param app + * @param streamId + * @return + */ + StreamProxyItem getStreamProxyByAppAndStream(String app, String streamId); + + /** + * catlog查询结束后完全重写通道信息 + * @param deviceId + * @param deviceChannelList + */ + boolean resetChannels(String deviceId, List deviceChannelList); + + /** + * 获取目录信息 + * @param platformId + * @param parentId + * @return + */ + List 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 queryCatalogInPlatform(String serverGBId); + + int delRelation(PlatformCatalog platformCatalog); + + int updateStreamGPS(List gpsMsgInfo); + + List queryPlatFormListForGBWithGBId(String channelId, List platforms); + + List queryPlatFormListForStreamWithGBId(String app, String stream, List platforms); + + GbStream getGbStream(String app, String streamId); + + void delCatalogByPlatformId(String serverGBId); + + void delRelationByPlatformId(String serverGBId); + + PlatformCatalog queryDefaultCatalogInPlatform(String platformId); + + List getChannelSource(String platformId, String gbId); + + void 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 e1327997..42e46e10 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 @@ public interface DeviceChannelMapper { " AND dc.status=1 " + " AND dc.status=0 " + " AND dc.subCount > 0 " + - " AND dc.subCount == 0 " + + " AND dc.subCount = 0 " + " AND dc.id not in (select deviceChannelId from platform_gb_channel where platformId=#{platformId} ) " + " AND pgc.platformId = #{platformId} and pgc.catalogId=#{catalogId} " + " ORDER BY dc.deviceId, dc.channelId ASC" + @@ -270,4 +270,7 @@ public interface DeviceChannelMapper { " 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 28f79f18..aab8d773 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 @@ public interface DeviceMapper { "updateTime," + "charset," + "subscribeCycleForCatalog," + + "subscribeCycleForMobilePosition," + + "mobilePositionSubmissionInterval," + + "subscribeCycleForAlarm," + "online" + ") VALUES (" + "#{deviceId}," + @@ -53,6 +56,9 @@ public interface DeviceMapper { "#{updateTime}," + "#{charset}," + "#{subscribeCycleForCatalog}," + + "#{subscribeCycleForMobilePosition}," + + "#{mobilePositionSubmissionInterval}," + + "#{subscribeCycleForAlarm}," + "#{online}" + ")") int add(Device device); @@ -75,6 +81,9 @@ public interface DeviceMapper { ", expires=${expires}" + ", charset='${charset}'" + ", subscribeCycleForCatalog=${subscribeCycleForCatalog}" + + ", subscribeCycleForMobilePosition=${subscribeCycleForMobilePosition}" + + ", mobilePositionSubmissionInterval=${mobilePositionSubmissionInterval}" + + ", subscribeCycleForAlarm=${subscribeCycleForAlarm}" + "WHERE deviceId='${deviceId}'"+ " "}) 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 4840446f..d72576b8 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 com.genersoft.iot.vmp.utils.redis.RedisUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.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 @@ import java.util.*; @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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void resetAllCSEQ() { - String scanKey = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetup.getServerId() + "_*"; + String scanKey = VideoManagerConstants.SIP_CSEQ_PREFIX + userSetting.getServerId() + "_*"; List 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 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { */ @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 class RedisCatchStorageImpl implements IRedisCatchStorage { 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 class RedisCatchStorageImpl implements IRedisCatchStorage { 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 playLeys = redis.scan(String.format("%S_%s_%s_*", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(), streamId)); + List 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public StreamInfo queryPlayByDevice(String deviceId, String channelId) { List 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 class RedisCatchStorageImpl implements IRedisCatchStorage { public Map queryPlayByDeviceId(String deviceId) { Map streamInfos = new HashMap<>(); // List playLeys = redis.keys(String.format("%S_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, deviceId)); - List players = redis.scan(String.format("%S_%s_*_%S_*", VideoManagerConstants.PLAYER_PREFIX, userSetup.getServerId(),deviceId)); + List 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { 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 scan = redis.scan(key); if (scan.size() > 0) { @@ -347,13 +345,13 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public List 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 queryResult = redis.scan(key); List 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 class RedisCatchStorageImpl implements IRedisCatchStorage { 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 scan = redis.scan(key); if (scan.size() > 0) { @@ -386,7 +384,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { */ @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 RtpStreams = redis.scan(key); if (RtpStreams.size() > 0) { return true; @@ -398,7 +396,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void clearCatchByDeviceId(String deviceId) { List 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } List 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } List 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void outlineForAll() { - List onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + "*" ); + List 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public List getOnlineForAll() { List result = new ArrayList<>(); - List onlineDevices = redis.scan(VideoManagerConstants.KEEPLIVEKEY_PREFIX + userSetup.getServerId() + "_" + "*" ); + List 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { 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 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 streams = redis.scan(key); for (Object stream : streams) { redis.del((String) stream); @@ -513,7 +511,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public List getStreams(String mediaServerId, String type) { List 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 streams = redis.scan(key); for (Object stream : streams) { MediaItem mediaItem = (MediaItem)redis.get((String) stream); @@ -524,37 +522,37 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 getAllGpsMsgInfo() { - String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetup.getServerId() + "_*"; + String scanKey = VideoManagerConstants.WVP_STREAM_GPS_MSG_PREFIX + userSetting.getServerId() + "_*"; List result = new ArrayList<>(); List keys = redis.scan(scanKey); for (int i = 0; i < keys.size(); i++) { @@ -570,7 +568,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 keys = redis.scan(scanKey); @@ -584,7 +582,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 systemInfoDto = new SystemInfoDto<>(); systemInfoDto.setTime(format.format(System.currentTimeMillis())); systemInfoDto.setData(cpuInfo); @@ -599,7 +597,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @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 systemInfoDto = new SystemInfoDto<>(); systemInfoDto.setTime(format.format(System.currentTimeMillis())); systemInfoDto.setData(memInfo); @@ -614,7 +612,7 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void addNetInfo(Map networkInterfaces) { - String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetup.getServerId(); + String key = VideoManagerConstants.SYSTEM_INFO_NET_PREFIX + userSetting.getServerId(); SystemInfoDto> systemInfoDto = new SystemInfoDto<>(); systemInfoDto.setTime(format.format(System.currentTimeMillis())); systemInfoDto.setData(networkInterfaces); @@ -626,4 +624,18 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } } } + + @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 98% 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 cd8141fb..16655735 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.conf.SipConfig; 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 @@ import java.util.*; */ @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 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { @Autowired private PlatformCatalogMapper catalogMapper; -; @Autowired private PlatformGbStreamMapper platformGbStreamMapper; @@ -96,13 +93,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { @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 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { } } }else { - stringBuilder.append(deviceChannel.getChannelId() + ","); + stringBuilder.append(deviceChannel.getChannelId()).append(","); } } if (channels.size() > 0) { @@ -286,7 +277,6 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { 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 class VideoManagerStoragerImpl implements IVideoManagerStorager { public List 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 860f6a38..365903c2 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 @@ package com.genersoft.iot.vmp.vmanager.gb28181.MobilePosition; 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 @@ public class MobilePositionController { private final static Logger logger = LoggerFactory.getLogger(MobilePositionController.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private SIPCommander cmder; @@ -161,9 +159,11 @@ public class MobilePositionController { 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 b3de5af8..88c15a45 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 @@ public class DeviceConfig { 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 183561ae..4db11e30 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 @@ public class DeviceControl { 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 178ad9bf..5e9cd609 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.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.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.bind.annotation.*; 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 @@ public class DeviceQuery { private final static Logger logger = LoggerFactory.getLogger(DeviceQuery.class); @Autowired - private IVideoManagerStorager storager; + private IVideoManagerStorage storager; @Autowired private IRedisCatchStorage redisCatchStorage; @@ -213,7 +214,12 @@ public class DeviceQuery { if (isSuccess) { redisCatchStorage.clearCatchByDeviceId(deviceId); // 停止此设备的订阅更新 - dynamicTask.stop(deviceId); + Set 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 @@ public class DeviceQuery { 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 46be6816..300546f9 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 @@ public class GbStreamController { 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 e07c81d8..a2619fad 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.common.StreamInfo; 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 @@ public class MediaController { 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 b26ae76f..ff424a05 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.JSON; 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 org.springframework.web.bind.annotation.*; import com.genersoft.iot.vmp.conf.SipConfig; import java.util.List; -import java.util.Locale; /** * 级联平台管理 @@ -43,10 +42,10 @@ public class PlatformController { 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 @@ public class PlatformController { PageInfo 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 @@ public class PlatformController { 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 930bb33e..20ffc000 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,14 +33,12 @@ import org.springframework.web.bind.annotation.RestController; 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 @RestController @@ -56,7 +54,7 @@ public class PlayController { 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 2fccaa8c..e095a6a5 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 @@ package com.genersoft.iot.vmp.vmanager.gb28181.playback; 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,11 +25,9 @@ import org.springframework.web.bind.annotation.RestController; 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 @RestController @@ -45,7 +40,7 @@ public class PlaybackController { 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 95d1aefa..4a29f8ea 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.util.StringUtils; 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 @@ public class PtzController { 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 d33dd2ac..9d6b8fcf 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 @@ package com.genersoft.iot.vmp.vmanager.gb28181.record; 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.Device; import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.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 @@ public class GBRecordController { 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 650dbe03..c147a9d6 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 @@ public class LogController { 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 @@ public class LogController { 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 1500f351..a0e7a737 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.alibaba.fastjson.JSONObject; 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 @@ public class ServerController { SipConfig sipConfig; @Autowired - UserSetup userSetup; + UserSetting userSetting; @Value("${server.port}") private int serverPort; @@ -232,14 +232,14 @@ public class ServerController { 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 eac742c8..9bbe1d7e 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 @@ package com.genersoft.iot.vmp.web.gb28181; 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 @@ public class ApiControlController { 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 2e96fbe2..d4928ec7 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.JSONArray; 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 @@ public class ApiDeviceController { 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 dfc2c442..9362db10 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 @@ package com.genersoft.iot.vmp.web.gb28181; 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 @@ public class ApiStreamController { 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 @@ public class ApiStreamController { @RequestParam(required = false)String timeout ){ - DeferredResult resultDeferredResult = new DeferredResult<>(userSetup.getPlayTimeout() + 10); + DeferredResult 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 f7f86041..3f148d6f 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -170,6 +170,8 @@ user-settings: save-position-history: false # 点播等待超时时间,单位:毫秒 play-timeout: 3000 + # 上级点播等待超时时间,单位:毫秒 + platform-play-timeout: 60000 # 是否开启接口鉴权 interface-authentication: true # 自动配置redis 可以过期事件 diff --git a/src/main/resources/logback-spring-local.xml b/src/main/resources/logback-spring-local.xml index 9951c696..ec80d2dd 100644 --- a/src/main/resources/logback-spring-local.xml +++ b/src/main/resources/logback-spring-local.xml @@ -80,12 +80,12 @@ - - - - - - + + + + + + diff --git a/web_src/src/components/ParentPlatformList.vue b/web_src/src/components/ParentPlatformList.vue index c001071e..5becea5e 100644 --- a/web_src/src/components/ParentPlatformList.vue +++ b/web_src/src/components/ParentPlatformList.vue @@ -47,8 +47,8 @@ - - + + diff --git a/web_src/src/components/dialog/deviceEdit.vue b/web_src/src/components/dialog/deviceEdit.vue index 4f868511..1150d21a 100644 --- a/web_src/src/components/dialog/deviceEdit.vue +++ b/web_src/src/components/dialog/deviceEdit.vue @@ -39,6 +39,12 @@ + + + + + +
确认