Browse Source

Merge pull request #52 from lawrencehj/master

将录像文件统计改为独立线程进行,实现超时返回已接收结果,优化代码消除编译报警项
pull/148/head
648540858 4 years ago
committed by GitHub
parent
commit
e864becace
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java
  2. 2
      src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java
  3. 2
      src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java
  4. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
  5. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java
  6. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java
  7. 5
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/WvpSipDate.java
  8. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java
  9. 5
      src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java
  10. 13
      src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEvent.java
  11. 13
      src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEvent.java
  12. 9
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
  13. 78
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/CheckForAllRecordsThread.java
  14. 4
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java
  15. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java
  16. 1
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java
  17. 1
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java
  18. 3
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  19. 115
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
  20. 57
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/NotifyRequestProcessor.java
  21. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java
  22. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/InviteResponseProcessor.java
  23. 8
      src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java
  24. 18
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHTTPProxyController.java
  25. 38
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
  26. 20
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java
  27. 1
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
  28. 10
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
  29. 1
      src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
  30. 7
      src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
  31. 9
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  32. 3
      src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java
  33. 1
      src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceConfig.java
  34. 2
      src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceQuery.java
  35. 7
      src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java
  36. 11
      src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java
  37. 1
      src/main/java/com/genersoft/iot/vmp/vmanager/service/IPlayService.java
  38. 3
      src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java
  39. 6
      src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java
  40. 3
      src/main/java/com/genersoft/iot/vmp/web/ApiControlController.java
  41. 2
      src/main/java/com/genersoft/iot/vmp/web/ApiController.java
  42. 19
      src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java
  43. 10
      src/main/java/com/genersoft/iot/vmp/web/ApiStreamController.java
  44. 3
      src/main/java/com/genersoft/iot/vmp/web/AuthController.java

1
src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java

@ -3,7 +3,6 @@ package com.genersoft.iot.vmp;
import java.util.logging.LogManager; import java.util.logging.LogManager;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication

2
src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java

@ -1,7 +1,7 @@
package com.genersoft.iot.vmp.common; package com.genersoft.iot.vmp.common;
/** /**
* @Description:TODO(这里用一句话描述这个类的作用) * @Description: 定义常量
* @author: swwheihei * @author: swwheihei
* @date: 2019年5月30日 下午3:04:04 * @date: 2019年5月30日 下午3:04:04
* *

2
src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java

@ -4,7 +4,7 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
/** /**
* @Description:TODO(这里用一句话描述这个类的作用) * @Description: 获取数据库配置
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月6日 下午2:46:00 * @date: 2020年5月6日 下午2:46:00
*/ */

2
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java

@ -149,8 +149,6 @@ public class SipLayer implements SipListener {
} }
} }
} }
// } else if (status == Response.TRYING) {
// trying不会回复
} else if ((status >= 100) && (status < 200)) { } else if ((status >= 100) && (status < 200)) {
// 增加其它无需回复的响应,如101、180等 // 增加其它无需回复的响应,如101、180等
} else { } else {

8
src/main/java/com/genersoft/iot/vmp/gb28181/auth/DigestServerAuthenticationHelper.java

@ -91,8 +91,10 @@ public class DigestServerAuthenticationHelper {
long time = date.getTime(); long time = date.getTime();
Random rand = new Random(); Random rand = new Random();
long pad = rand.nextLong(); long pad = rand.nextLong();
String nonceString = (new Long(time)).toString() // String nonceString = (new Long(time)).toString()
+ (new Long(pad)).toString(); // + (new Long(pad)).toString();
String nonceString = Long.valueOf(time).toString()
+ Long.valueOf(pad).toString();
byte mdbytes[] = messageDigest.digest(nonceString.getBytes()); byte mdbytes[] = messageDigest.digest(nonceString.getBytes());
// Convert the mdbytes array into a hex string. // Convert the mdbytes array into a hex string.
return toHexString(mdbytes); return toHexString(mdbytes);
@ -191,7 +193,7 @@ public class DigestServerAuthenticationHelper {
// 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。 // 客户端随机数,这是一个不透明的字符串值,由客户端提供,并且客户端和服务器都会使用,以避免用明文文本。
// 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护 // 这使得双方都可以查验对方的身份,并对消息的完整性提供一些保护
String cNonce = authHeader.getCNonce(); //String cNonce = authHeader.getCNonce();
// nonce计数器,是一个16进制的数值,表示同一nonce下客户端发送出请求的数量 // nonce计数器,是一个16进制的数值,表示同一nonce下客户端发送出请求的数量
int nc = authHeader.getNonceCount(); int nc = authHeader.getNonceCount();

2
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordInfo.java

@ -1,7 +1,7 @@
package com.genersoft.iot.vmp.gb28181.bean; package com.genersoft.iot.vmp.gb28181.bean;
import gov.nist.javax.sip.header.SIPDate; //import gov.nist.javax.sip.header.SIPDate;
import java.util.List; import java.util.List;

5
src/main/java/com/genersoft/iot/vmp/gb28181/bean/WvpSipDate.java

@ -10,6 +10,11 @@ import java.util.*;
*/ */
public class WvpSipDate extends SIPDate { public class WvpSipDate extends SIPDate {
/**
*
*/
private static final long serialVersionUID = 1L;
private Calendar javaCal; private Calendar javaCal;
public WvpSipDate(long timeMillis) { public WvpSipDate(long timeMillis) {

8
src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java

@ -1,22 +1,14 @@
package com.genersoft.iot.vmp.gb28181.event; package com.genersoft.iot.vmp.gb28181.event;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.sip.ResponseEvent; import javax.sip.ResponseEvent;
import javax.sip.message.Request;
import java.util.EventObject;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@Component @Component
public class SipSubscribe { public class SipSubscribe {
private final static Logger logger = LoggerFactory.getLogger(SipSubscribe.class);
private Map<String, SipSubscribe.Event> errorSubscribes = new ConcurrentHashMap<>(); private Map<String, SipSubscribe.Event> errorSubscribes = new ConcurrentHashMap<>();
private Map<String, SipSubscribe.Event> okSubscribes = new ConcurrentHashMap<>(); private Map<String, SipSubscribe.Event> okSubscribes = new ConcurrentHashMap<>();

5
src/main/java/com/genersoft/iot/vmp/gb28181/event/alarm/AlarmEvent.java

@ -10,6 +10,11 @@ import org.springframework.context.ApplicationEvent;
*/ */
public class AlarmEvent extends ApplicationEvent { public class AlarmEvent extends ApplicationEvent {
/**
*
*/
private static final long serialVersionUID = 1L;
public AlarmEvent(Object source) { public AlarmEvent(Object source) {
super(source); super(source);
} }

13
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEvent.java

@ -3,18 +3,17 @@ package com.genersoft.iot.vmp.gb28181.event.offline;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
/** /**
* @Description:TODO(这里用一句话描述这个类的作用) * @Description: 离线事件类
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月6日 上午11:33:13 * @date: 2020年5月6日 上午11:33:13
*/ */
public class OfflineEvent extends ApplicationEvent { public class OfflineEvent extends ApplicationEvent {
/** /**
* @Title: OutlineEvent *
* @Description: TODO(这里用一句话描述这个方法的作用) */
* @param: @param source private static final long serialVersionUID = 1L;
* @throws
*/
public OfflineEvent(Object source) { public OfflineEvent(Object source) {
super(source); super(source);
} }

13
src/main/java/com/genersoft/iot/vmp/gb28181/event/online/OnlineEvent.java

@ -3,18 +3,17 @@ package com.genersoft.iot.vmp.gb28181.event.online;
import org.springframework.context.ApplicationEvent; import org.springframework.context.ApplicationEvent;
/** /**
* @Description:TODO(这里用一句话描述这个类的作用) * @Description: 在线事件类
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月6日 上午11:32:56 * @date: 2020年5月6日 上午11:32:56
*/ */
public class OnlineEvent extends ApplicationEvent { public class OnlineEvent extends ApplicationEvent {
/** /**
* @Title: OnlineEvent *
* @Description: TODO(这里用一句话描述这个方法的作用) */
* @param: @param source private static final long serialVersionUID = 1L;
* @throws
*/
public OnlineEvent(Object source) { public OnlineEvent(Object source) {
super(source); super(source);
} }

9
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java

@ -8,10 +8,9 @@ import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import org.slf4j.Logger; // import org.slf4j.Logger;
import org.slf4j.LoggerFactory; // import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
@ -40,14 +39,14 @@ import com.genersoft.iot.vmp.utils.SpringBeanFactory;
import com.genersoft.iot.vmp.utils.redis.RedisUtil; import com.genersoft.iot.vmp.utils.redis.RedisUtil;
/** /**
* @Description:TODO(这里用一句话描述这个类的作用) * @Description: SIP信令处理分配
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月3日 下午4:24:37 * @date: 2020年5月3日 下午4:24:37
*/ */
@Component @Component
public class SIPProcessorFactory { public class SIPProcessorFactory {
private final static Logger logger = LoggerFactory.getLogger(SIPProcessorFactory.class); // private final static Logger logger = LoggerFactory.getLogger(SIPProcessorFactory.class);
@Autowired @Autowired
private SipConfig sipConfig; private SipConfig sipConfig;

78
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/CheckForAllRecordsThread.java

@ -0,0 +1,78 @@
package com.genersoft.iot.vmp.gb28181.transmit.callback;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
import com.genersoft.iot.vmp.gb28181.bean.RecordItem;
import com.genersoft.iot.vmp.gb28181.transmit.request.impl.MessageRequestProcessor;
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
import org.slf4j.Logger;
@SuppressWarnings("unchecked")
public class CheckForAllRecordsThread extends Thread {
private String key;
private RecordInfo recordInfo;
private RedisUtil redis;
private Logger logger;
private DeferredResultHolder deferredResultHolder;
public CheckForAllRecordsThread(String key, RecordInfo recordInfo) {
this.key = key;
this.recordInfo = recordInfo;
}
public void run() {
String cacheKey = this.key;
for (long stop = System.nanoTime() + TimeUnit.SECONDS.toNanos(10); stop > System.nanoTime();) {
List<Object> cacheKeys = redis.scan(cacheKey + "_*");
List<RecordItem> totalRecordList = new ArrayList<RecordItem>();
for (int i = 0; i < cacheKeys.size(); i++) {
totalRecordList.addAll((List<RecordItem>) redis.get(cacheKeys.get(i).toString()));
}
if (totalRecordList.size() < this.recordInfo.getSumNum()) {
logger.info("已获取" + totalRecordList.size() + "项录像数据,共" + this.recordInfo.getSumNum() + "项");
} else {
logger.info("录像数据已全部获取,共" + this.recordInfo.getSumNum() + "项");
this.recordInfo.setRecordList(totalRecordList);
for (int i = 0; i < cacheKeys.size(); i++) {
redis.del(cacheKeys.get(i).toString());
}
break;
}
}
// 自然顺序排序, 元素进行升序排列
this.recordInfo.getRecordList().sort(Comparator.naturalOrder());
RequestMessage msg = new RequestMessage();
String deviceId = recordInfo.getDeviceId();
msg.setDeviceId(deviceId);
msg.setType(DeferredResultHolder.CALLBACK_CMD_RECORDINFO);
msg.setData(recordInfo);
deferredResultHolder.invokeResult(msg);
logger.info("处理完成,返回结果");
MessageRequestProcessor.threadNameList.remove(cacheKey);
}
public void setRedis(RedisUtil redis) {
this.redis = redis;
}
public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) {
this.deferredResultHolder = deferredResultHolder;
}
public void setLogger(Logger logger) {
this.logger = logger;
}
}

4
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/DeferredResultHolder.java

@ -1,6 +1,5 @@
package com.genersoft.iot.vmp.gb28181.transmit.callback; package com.genersoft.iot.vmp.gb28181.transmit.callback;
import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -10,10 +9,11 @@ import org.springframework.stereotype.Component;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
/** /**
* @Description:TODO(这里用一句话描述这个类的作用) * @Description: 异步请求处理
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月8日 下午7:59:05 * @date: 2020年5月8日 下午7:59:05
*/ */
@SuppressWarnings(value = {"rawtypes", "unchecked"})
@Component @Component
public class DeferredResultHolder { public class DeferredResultHolder {

2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/callback/RequestMessage.java

@ -1,7 +1,7 @@
package com.genersoft.iot.vmp.gb28181.transmit.callback; package com.genersoft.iot.vmp.gb28181.transmit.callback;
/** /**
* @Description:TODO(这里用一句话描述这个类的作用) * @Description: 请求信息定义
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月8日 下午1:09:18 * @date: 2020年5月8日 下午1:09:18
*/ */

1
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java

@ -1,6 +1,5 @@
package com.genersoft.iot.vmp.gb28181.transmit.cmd; package com.genersoft.iot.vmp.gb28181.transmit.cmd;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;

1
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/SIPRequestHeaderProvider.java

@ -18,7 +18,6 @@ import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.Host;
/** /**
* @Description:摄像头命令request创造器 TODO 冗余代码太多待优化 * @Description:摄像头命令request创造器 TODO 冗余代码太多待优化

3
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java

@ -1,21 +1,18 @@
package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
import java.text.ParseException; import java.text.ParseException;
import java.util.UUID;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import javax.sip.*; import javax.sip.*;
import javax.sip.address.SipURI; import javax.sip.address.SipURI;
import javax.sip.header.CallIdHeader; import javax.sip.header.CallIdHeader;
import javax.sip.header.Header;
import javax.sip.header.ViaHeader; import javax.sip.header.ViaHeader;
import javax.sip.message.Request; import javax.sip.message.Request;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig; import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe; import com.genersoft.iot.vmp.media.zlm.ZLMHttpHookSubscribe;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory; import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;

115
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java

@ -23,6 +23,7 @@ import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
import com.genersoft.iot.vmp.gb28181.bean.RecordItem; import com.genersoft.iot.vmp.gb28181.bean.RecordItem;
import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.transmit.callback.CheckForAllRecordsThread;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; 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.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
@ -43,14 +44,17 @@ import org.dom4j.io.SAXReader;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
/** /**
* @Description:MESSAGE请求处理器 * @Description:MESSAGE请求处理器
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月3日 下午5:32:41 * @date: 2020年5月3日 下午5:32:41
*/ */
@SuppressWarnings(value={"unchecked", "rawtypes"})
public class MessageRequestProcessor extends SIPRequestAbstractProcessor { public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
public static volatile List<String> threadNameList = new ArrayList();
private UserSetup userSetup = (UserSetup) SpringBeanFactory.getBean("userSetup"); private UserSetup userSetup = (UserSetup) SpringBeanFactory.getBean("userSetup");
private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class);
@ -240,10 +244,10 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
try { try {
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
String deviceId = XmlUtil.getText(rootElement, "DeviceID"); String deviceId = XmlUtil.getText(rootElement, "DeviceID");
String result = XmlUtil.getText(rootElement, "Result"); //String result = XmlUtil.getText(rootElement, "Result");
// 回复200 OK // 回复200 OK
responseAck(evt); responseAck(evt);
if (!XmlUtil.isEmpty(result)) { if (rootElement.getName().equals("Response")) {//} !XmlUtil.isEmpty(result)) {
// 此处是对本平台发出DeviceControl指令的应答 // 此处是对本平台发出DeviceControl指令的应答
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
XmlUtil.node2Json(rootElement, json); XmlUtil.node2Json(rootElement, json);
@ -272,11 +276,10 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
try { try {
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
String deviceId = XmlUtil.getText(rootElement, "DeviceID"); String deviceId = XmlUtil.getText(rootElement, "DeviceID");
String result = XmlUtil.getText(rootElement, "Result");
// 回复200 OK // 回复200 OK
responseAck(evt); responseAck(evt);
//if (!XmlUtil.isEmpty(result)) { if (rootElement.getName().equals("Response")) {
// 此处是对本平台发出DeviceControl指令的应答 // 此处是对本平台发出DeviceControl指令的应答
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
XmlUtil.node2Json(rootElement, json); XmlUtil.node2Json(rootElement, json);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
@ -287,9 +290,9 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
msg.setType(DeferredResultHolder.CALLBACK_CMD_DEVICECONFIG); msg.setType(DeferredResultHolder.CALLBACK_CMD_DEVICECONFIG);
msg.setData(json); msg.setData(json);
deferredResultHolder.invokeResult(msg); deferredResultHolder.invokeResult(msg);
// } else { } else {
// // 此处是上级发出的DeviceConfig指令 // 此处是上级发出的DeviceConfig指令
//} }
} catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -304,11 +307,10 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
try { try {
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
String deviceId = XmlUtil.getText(rootElement, "DeviceID"); String deviceId = XmlUtil.getText(rootElement, "DeviceID");
String result = XmlUtil.getText(rootElement, "Result");
// 回复200 OK // 回复200 OK
responseAck(evt); responseAck(evt);
//if (!XmlUtil.isEmpty(result)) { if (rootElement.getName().equals("Response")) {
// 此处是对本平台发出DeviceControl指令的应答 // 此处是对本平台发出DeviceControl指令的应答
JSONObject json = new JSONObject(); JSONObject json = new JSONObject();
XmlUtil.node2Json(rootElement, json); XmlUtil.node2Json(rootElement, json);
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
@ -319,9 +321,9 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
msg.setType(DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD); msg.setType(DeferredResultHolder.CALLBACK_CMD_CONFIGDOWNLOAD);
msg.setData(json); msg.setData(json);
deferredResultHolder.invokeResult(msg); deferredResultHolder.invokeResult(msg);
// } else { } else {
// // 此处是上级发出的DeviceConfig指令 // 此处是上级发出的DeviceConfig指令
//} }
} catch (ParseException | SipException | InvalidArgumentException | DocumentException e) { } catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -336,7 +338,6 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
try { try {
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
String deviceId = XmlUtil.getText(rootElement, "DeviceID"); String deviceId = XmlUtil.getText(rootElement, "DeviceID");
String result = XmlUtil.getText(rootElement, "Result");
// 回复200 OK // 回复200 OK
responseAck(evt); responseAck(evt);
if (rootElement.getName().equals("Response")) {// !XmlUtil.isEmpty(result)) { if (rootElement.getName().equals("Response")) {// !XmlUtil.isEmpty(result)) {
@ -648,8 +649,11 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
Element recordListElement = rootElement.element("RecordList"); Element recordListElement = rootElement.element("RecordList");
if (recordListElement == null || recordInfo.getSumNum() == 0) { if (recordListElement == null || recordInfo.getSumNum() == 0) {
logger.info("无录像数据"); logger.info("无录像数据");
// responseAck(evt); RequestMessage msg = new RequestMessage();
// return; msg.setDeviceId(deviceId);
msg.setType(DeferredResultHolder.CALLBACK_CMD_RECORDINFO);
msg.setData(recordInfo);
deferredResultHolder.invokeResult(msg);
} else { } else {
Iterator<Element> recordListIterator = recordListElement.elementIterator(); Iterator<Element> recordListIterator = recordListElement.elementIterator();
List<RecordItem> recordList = new ArrayList<RecordItem>(); List<RecordItem> recordList = new ArrayList<RecordItem>();
@ -679,44 +683,63 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
record.setRecorderId(XmlUtil.getText(itemRecord, "RecorderID")); record.setRecorderId(XmlUtil.getText(itemRecord, "RecorderID"));
recordList.add(record); recordList.add(record);
} }
// recordList.sort(Comparator.naturalOrder());
recordInfo.setRecordList(recordList); recordInfo.setRecordList(recordList);
} }
// 存在录像且如果当前录像明细个数小于总条数,说明拆包返回,需要组装,暂不返回 // 改用单独线程统计已获取录像文件数量,避免多包并行分别统计不完整的问题
if (recordInfo.getSumNum() > 0 && recordList.size() > 0 && recordList.size() < recordInfo.getSumNum()) { String cacheKey = CACHE_RECORDINFO_KEY + deviceId + sn;
// 为防止连续请求该设备的录像数据,返回数据错乱,特增加sn进行区分 redis.set(cacheKey + "_" + uuid, recordList, 90);
String cacheKey = CACHE_RECORDINFO_KEY + deviceId + sn; if (!threadNameList.contains(cacheKey)) {
threadNameList.add(cacheKey);
redis.set(cacheKey + "_" + uuid, recordList, 90); CheckForAllRecordsThread chk = new CheckForAllRecordsThread(cacheKey, recordInfo);
List<Object> cacheKeys = redis.scan(cacheKey + "_*"); chk.setName(cacheKey);
List<RecordItem> totalRecordList = new ArrayList<RecordItem>(); chk.setDeferredResultHolder(deferredResultHolder);
for (int i = 0; i < cacheKeys.size(); i++) { chk.setRedis(redis);
totalRecordList.addAll((List<RecordItem>) redis.get(cacheKeys.get(i).toString())); chk.setLogger(logger);
chk.start();
if (logger.isDebugEnabled()) {
logger.debug("Start Thread " + cacheKey + ".");
} }
if (totalRecordList.size() < recordInfo.getSumNum()) { } else {
logger.info("已获取" + totalRecordList.size() + "项录像数据,共" + recordInfo.getSumNum() + "项"); if (logger.isDebugEnabled()) {
return; logger.debug("Thread " + cacheKey + " already started.");
}
logger.info("录像数据已全部获取,共" + recordInfo.getSumNum() + "项");
recordInfo.setRecordList(totalRecordList);
for (int i = 0; i < cacheKeys.size(); i++) {
redis.del(cacheKeys.get(i).toString());
} }
} }
// 自然顺序排序, 元素进行升序排列
recordInfo.getRecordList().sort(Comparator.naturalOrder()); // 存在录像且如果当前录像明细个数小于总条数,说明拆包返回,需要组装,暂不返回
// if (recordInfo.getSumNum() > 0 && recordList.size() > 0 && recordList.size() < recordInfo.getSumNum()) {
// // 为防止连续请求该设备的录像数据,返回数据错乱,特增加sn进行区分
// String cacheKey = CACHE_RECORDINFO_KEY + deviceId + sn;
// redis.set(cacheKey + "_" + uuid, recordList, 90);
// List<Object> cacheKeys = redis.scan(cacheKey + "_*");
// List<RecordItem> totalRecordList = new ArrayList<RecordItem>();
// for (int i = 0; i < cacheKeys.size(); i++) {
// totalRecordList.addAll((List<RecordItem>) redis.get(cacheKeys.get(i).toString()));
// }
// if (totalRecordList.size() < recordInfo.getSumNum()) {
// logger.info("已获取" + totalRecordList.size() + "项录像数据,共" + recordInfo.getSumNum() + "项");
// return;
// }
// logger.info("录像数据已全部获取,共" + recordInfo.getSumNum() + "项");
// recordInfo.setRecordList(totalRecordList);
// for (int i = 0; i < cacheKeys.size(); i++) {
// redis.del(cacheKeys.get(i).toString());
// }
// }
// // 自然顺序排序, 元素进行升序排列
// recordInfo.getRecordList().sort(Comparator.naturalOrder());
} }
// 走到这里,有以下可能:1、没有录像信息,第一次收到recordinfo的消息即返回响应数据,无redis操作 // 走到这里,有以下可能:1、没有录像信息,第一次收到recordinfo的消息即返回响应数据,无redis操作
// 2、有录像数据,且第一次即收到完整数据,返回响应数据,无redis操作 // 2、有录像数据,且第一次即收到完整数据,返回响应数据,无redis操作
// 3、有录像数据,在超时时间内收到多次包组装后数量足够,返回数据 // 3、有录像数据,在超时时间内收到多次包组装后数量足够,返回数据
RequestMessage msg = new RequestMessage(); // RequestMessage msg = new RequestMessage();
msg.setDeviceId(deviceId); // msg.setDeviceId(deviceId);
msg.setType(DeferredResultHolder.CALLBACK_CMD_RECORDINFO); // msg.setType(DeferredResultHolder.CALLBACK_CMD_RECORDINFO);
msg.setData(recordInfo); // msg.setData(recordInfo);
deferredResultHolder.invokeResult(msg); // deferredResultHolder.invokeResult(msg);
logger.info("处理完成,返回结果"); // logger.info("处理完成,返回结果");
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -799,4 +822,4 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
public void setRedisCatchStorage(IRedisCatchStorage redisCatchStorage) { public void setRedisCatchStorage(IRedisCatchStorage redisCatchStorage) {
this.redisCatchStorage = redisCatchStorage; this.redisCatchStorage = redisCatchStorage;
} }
} }

57
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/NotifyRequestProcessor.java

@ -50,26 +50,20 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class); private final static Logger logger = LoggerFactory.getLogger(MessageRequestProcessor.class);
private SIPCommander cmder;
private IVideoManagerStorager storager; private IVideoManagerStorager storager;
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
private EventPublisher publisher; private EventPublisher publisher;
private RedisUtil redis;
private DeferredResultHolder deferredResultHolder;
private DeviceOffLineDetector offLineDetector; private DeviceOffLineDetector offLineDetector;
private static final String NOTIFY_CATALOG = "Catalog"; private static final String NOTIFY_CATALOG = "Catalog";
private static final String NOTIFY_ALARM = "Alarm"; private static final String NOTIFY_ALARM = "Alarm";
private static final String NOTIFY_MOBILE_POSITION = "MobilePosition"; private static final String NOTIFY_MOBILE_POSITION = "MobilePosition";
@Override @Override
public void process(RequestEvent evt) { public void process(RequestEvent evt) {
try { try {
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
String cmd = XmlUtil.getText(rootElement, "CmdType"); String cmd = XmlUtil.getText(rootElement, "CmdType");
@ -87,18 +81,19 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
logger.info("接收到消息:" + cmd); logger.info("接收到消息:" + cmd);
response200Ok(evt); response200Ok(evt);
} }
} catch (DocumentException | SipException |InvalidArgumentException | ParseException e) { } catch (DocumentException | SipException | InvalidArgumentException | ParseException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
/** /**
* 处理MobilePosition移动位置Notify * 处理MobilePosition移动位置Notify
*
* @param evt * @param evt
*/ */
private void processNotifyMobilePosition(RequestEvent evt) { private void processNotifyMobilePosition(RequestEvent evt) {
try { try {
//回复 200 OK // 回复 200 OK
Element rootElement = getRootElement(evt); Element rootElement = getRootElement(evt);
MobilePosition mobilePosition = new MobilePosition(); MobilePosition mobilePosition = new MobilePosition();
Element deviceIdElement = rootElement.element("DeviceID"); Element deviceIdElement = rootElement.element("DeviceID");
@ -112,8 +107,8 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID")); mobilePosition.setDeviceId(XmlUtil.getText(rootElement, "DeviceID"));
mobilePosition.setTime(XmlUtil.getText(rootElement, "Time")); mobilePosition.setTime(XmlUtil.getText(rootElement, "Time"));
mobilePosition.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude"))); mobilePosition.setLongitude(Double.parseDouble(XmlUtil.getText(rootElement, "Longitude")));
mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude"))); mobilePosition.setLatitude(Double.parseDouble(XmlUtil.getText(rootElement, "Latitude")));
if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) { if (NumericUtil.isDouble(XmlUtil.getText(rootElement, "Speed"))) {
mobilePosition.setSpeed(Double.parseDouble(XmlUtil.getText(rootElement, "Speed"))); mobilePosition.setSpeed(Double.parseDouble(XmlUtil.getText(rootElement, "Speed")));
} else { } else {
mobilePosition.setSpeed(0.0); mobilePosition.setSpeed(0.0);
@ -147,6 +142,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
/*** /***
* 处理alarm设备报警Notify * 处理alarm设备报警Notify
*
* @param evt * @param evt
*/ */
private void processNotifyAlarm(RequestEvent evt) { private void processNotifyAlarm(RequestEvent evt) {
@ -180,7 +176,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
deviceAlarm.setLatitude(0.00); deviceAlarm.setLatitude(0.00);
} }
if ( deviceAlarm.getAlarmMethod().equals("4")) { if (deviceAlarm.getAlarmMethod().equals("4")) {
MobilePosition mobilePosition = new MobilePosition(); MobilePosition mobilePosition = new MobilePosition();
mobilePosition.setDeviceId(deviceAlarm.getDeviceId()); mobilePosition.setDeviceId(deviceAlarm.getDeviceId());
mobilePosition.setTime(deviceAlarm.getAlarmTime()); mobilePosition.setTime(deviceAlarm.getAlarmTime());
@ -245,7 +241,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setName(channelName); deviceChannel.setName(channelName);
deviceChannel.setChannelId(channelDeviceId); deviceChannel.setChannelId(channelDeviceId);
// ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) { if (status.equals("ON") || status.equals("On") || status.equals("ONLINE")) {
deviceChannel.setStatus(1); deviceChannel.setStatus(1);
} }
@ -259,29 +255,34 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode"));
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
if (XmlUtil.getText(itemDevice, "Parental") == null || XmlUtil.getText(itemDevice, "Parental") == "") { if (XmlUtil.getText(itemDevice, "Parental") == null
|| XmlUtil.getText(itemDevice, "Parental") == "") {
deviceChannel.setParental(0); deviceChannel.setParental(0);
} else { } else {
deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental"))); deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental")));
} }
deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID")); deviceChannel.setParentId(XmlUtil.getText(itemDevice, "ParentID"));
if (XmlUtil.getText(itemDevice, "SafetyWay") == null || XmlUtil.getText(itemDevice, "SafetyWay")== "") { if (XmlUtil.getText(itemDevice, "SafetyWay") == null
|| XmlUtil.getText(itemDevice, "SafetyWay") == "") {
deviceChannel.setSafetyWay(0); deviceChannel.setSafetyWay(0);
} else { } else {
deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay")));
} }
if (XmlUtil.getText(itemDevice, "RegisterWay") == null || XmlUtil.getText(itemDevice, "RegisterWay") =="") { if (XmlUtil.getText(itemDevice, "RegisterWay") == null
|| XmlUtil.getText(itemDevice, "RegisterWay") == "") {
deviceChannel.setRegisterWay(1); deviceChannel.setRegisterWay(1);
} else { } else {
deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay")));
} }
deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));
if (XmlUtil.getText(itemDevice, "Certifiable") == null || XmlUtil.getText(itemDevice, "Certifiable") == "") { if (XmlUtil.getText(itemDevice, "Certifiable") == null
|| XmlUtil.getText(itemDevice, "Certifiable") == "") {
deviceChannel.setCertifiable(0); deviceChannel.setCertifiable(0);
} else { } else {
deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable")));
} }
if (XmlUtil.getText(itemDevice, "ErrCode") == null || XmlUtil.getText(itemDevice, "ErrCode") == "") { if (XmlUtil.getText(itemDevice, "ErrCode") == null
|| XmlUtil.getText(itemDevice, "ErrCode") == "") {
deviceChannel.setErrCode(0); deviceChannel.setErrCode(0);
} else { } else {
deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode")));
@ -289,7 +290,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime"));
deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy"));
deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress"));
if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") =="") { if (XmlUtil.getText(itemDevice, "Port") == null || XmlUtil.getText(itemDevice, "Port") == "") {
deviceChannel.setPort(0); deviceChannel.setPort(0);
} else { } else {
deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port")));
@ -305,7 +306,8 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
} else { } else {
deviceChannel.setLatitude(0.00); deviceChannel.setLatitude(0.00);
} }
if (XmlUtil.getText(itemDevice, "PTZType") == null || XmlUtil.getText(itemDevice, "PTZType") == "") { if (XmlUtil.getText(itemDevice, "PTZType") == null
|| XmlUtil.getText(itemDevice, "PTZType") == "") {
deviceChannel.setPTZType(0); deviceChannel.setPTZType(0);
} else { } else {
deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType")));
@ -330,9 +332,9 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
} }
} }
/***
/***
* 回复200 OK * 回复200 OK
*
* @param evt * @param evt
* @throws SipException * @throws SipException
* @throws InvalidArgumentException * @throws InvalidArgumentException
@ -343,7 +345,7 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
getServerTransaction(evt).sendResponse(response); getServerTransaction(evt).sendResponse(response);
} }
private Element getRootElement(RequestEvent evt) throws DocumentException { private Element getRootElement(RequestEvent evt) throws DocumentException {
Request request = evt.getRequest(); Request request = evt.getRequest();
SAXReader reader = new SAXReader(); SAXReader reader = new SAXReader();
reader.setEncoding("gbk"); reader.setEncoding("gbk");
@ -352,7 +354,6 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
} }
public void setCmder(SIPCommander cmder) { public void setCmder(SIPCommander cmder) {
this.cmder = cmder;
} }
public void setStorager(IVideoManagerStorager storager) { public void setStorager(IVideoManagerStorager storager) {
@ -364,11 +365,9 @@ public class NotifyRequestProcessor extends SIPRequestAbstractProcessor {
} }
public void setRedis(RedisUtil redis) { public void setRedis(RedisUtil redis) {
this.redis = redis;
} }
public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) { public void setDeferredResultHolder(DeferredResultHolder deferredResultHolder) {
this.deferredResultHolder = deferredResultHolder;
} }
public void setOffLineDetector(DeviceOffLineDetector offLineDetector) { public void setOffLineDetector(DeviceOffLineDetector offLineDetector) {

2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/RegisterRequestProcessor.java

@ -145,7 +145,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
// 下发catelog查询目录 // 下发catelog查询目录
if (registerFlag == 1 && device != null) { if (registerFlag == 1 && device != null) {
logger.info("注册成功! deviceId:" + device.getDeviceId()); logger.info("注册成功! deviceId:" + device.getDeviceId());
boolean exists = storager.exists(device.getDeviceId()); // boolean exists = storager.exists(device.getDeviceId());
device.setRegisterTimeMillis(System.currentTimeMillis()); device.setRegisterTimeMillis(System.currentTimeMillis());
storager.updateDevice(device); storager.updateDevice(device);
publisher.onlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_ONLINE_REGISTER); publisher.onlineEventPublish(device.getDeviceId(), VideoManagerConstants.EVENT_ONLINE_REGISTER);

8
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/response/impl/InviteResponseProcessor.java

@ -12,14 +12,12 @@ import javax.sip.header.ViaHeader;
import javax.sip.message.Request; import javax.sip.message.Request;
import javax.sip.message.Response; import javax.sip.message.Response;
import gov.nist.javax.sip.header.CSeq; // import org.slf4j.Logger;
import org.slf4j.Logger; // import org.slf4j.LoggerFactory;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.SipLayer; import com.genersoft.iot.vmp.gb28181.SipLayer;
import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorFactory;
import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor; import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor;
@ -31,7 +29,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.response.ISIPResponseProcessor;
@Component @Component
public class InviteResponseProcessor implements ISIPResponseProcessor { public class InviteResponseProcessor implements ISIPResponseProcessor {
private final static Logger logger = LoggerFactory.getLogger(InviteResponseProcessor.class); // private final static Logger logger = LoggerFactory.getLogger(InviteResponseProcessor.class);
/** /**
* 处理invite响应 * 处理invite响应

8
src/main/java/com/genersoft/iot/vmp/gb28181/utils/NumericUtil.java

@ -15,10 +15,10 @@ public class NumericUtil {
public static boolean isDouble(String str) { public static boolean isDouble(String str) {
try { try {
Double num2 = Double.valueOf(str); Double num2 = Double.valueOf(str);
System.out.println(num2 + " Is an Integer!"); System.out.println(num2 + " is a valid numeric string!");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
System.out.println(str + " Is not an Integer!"); System.out.println(str + " is an invalid numeric string!");
return false; return false;
} }
} }
@ -31,10 +31,10 @@ public class NumericUtil {
public static boolean isInteger(String str) { public static boolean isInteger(String str) {
try { try {
int num2 = Integer.valueOf(str); int num2 = Integer.valueOf(str);
System.out.println(num2 + " Is Number!"); System.out.println(num2 + " is an integer!");
return true; return true;
} catch (Exception e) { } catch (Exception e) {
System.out.println(str + " Is not Number!"); System.out.println(str + " is not an integer!");
return false; return false;
} }
} }

18
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHTTPProxyController.java

@ -1,34 +1,28 @@
package com.genersoft.iot.vmp.media.zlm; package com.genersoft.iot.vmp.media.zlm;
import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.conf.MediaServerConfig; import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; // import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.slf4j.Logger; // import org.slf4j.Logger;
import org.slf4j.LoggerFactory; // import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.util.Enumeration;
@RestController @RestController
@RequestMapping("/zlm") @RequestMapping("/zlm")
public class ZLMHTTPProxyController { public class ZLMHTTPProxyController {
private final static Logger logger = LoggerFactory.getLogger(ZLMHTTPProxyController.class); // private final static Logger logger = LoggerFactory.getLogger(ZLMHTTPProxyController.class);
@Autowired // @Autowired
private IVideoManagerStorager storager; // private IVideoManagerStorager storager;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;

38
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java

@ -1,19 +1,13 @@
package com.genersoft.iot.vmp.media.zlm; package com.genersoft.iot.vmp.media.zlm;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig; import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.utils.IpUtil;
import com.genersoft.iot.vmp.vmanager.service.IPlayService; import com.genersoft.iot.vmp.vmanager.service.IPlayService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -57,8 +51,8 @@ public class ZLMHttpHookListener {
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@Autowired // @Autowired
private ZLMRESTfulUtils zlmresTfulUtils; // private ZLMRESTfulUtils zlmresTfulUtils;
@Autowired @Autowired
private ZLMHttpHookSubscribe subscribe; private ZLMHttpHookSubscribe subscribe;
@ -86,9 +80,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_flow_report API调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_flow_report API调用,参数:" + json.toString());
} }
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("msg", "success"); ret.put("msg", "success");
@ -106,8 +97,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_http_access API 调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_http_access API 调用,参数:" + json.toString());
} }
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("err", ""); ret.put("err", "");
@ -127,8 +116,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_play API调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_play API调用,参数:" + json.toString());
} }
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("msg", "success"); ret.put("msg", "success");
@ -146,15 +133,12 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_publish API调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_publish API调用,参数:" + json.toString());
} }
String app = json.getString("app"); // String app = json.getString("app");
String streamId = json.getString("id"); // String streamId = json.getString("id");
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json); ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
if (subscribe != null) subscribe.response(json); if (subscribe != null) subscribe.response(json);
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("msg", "success"); ret.put("msg", "success");
@ -175,8 +159,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_record_mp4 API调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_record_mp4 API调用,参数:" + json.toString());
} }
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("msg", "success"); ret.put("msg", "success");
@ -194,8 +176,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_rtsp_realm API调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_rtsp_realm API调用,参数:" + json.toString());
} }
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("realm", ""); ret.put("realm", "");
@ -214,8 +194,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_rtsp_auth API调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_rtsp_auth API调用,参数:" + json.toString());
} }
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("encrypted", false); ret.put("encrypted", false);
@ -234,8 +212,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_shell_login API调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_shell_login API调用,参数:" + json.toString());
} }
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("msg", "success"); ret.put("msg", "success");
@ -267,8 +243,6 @@ public class ZLMHttpHookListener {
redisCatchStorage.stopPlayback(streamInfo); redisCatchStorage.stopPlayback(streamInfo);
} }
} }
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("msg", "success"); ret.put("msg", "success");
@ -316,8 +290,6 @@ public class ZLMHttpHookListener {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("ZLM HOOK on_stream_not_found API调用,参数:" + json.toString()); logger.debug("ZLM HOOK on_stream_not_found API调用,参数:" + json.toString());
} }
// TODO Auto-generated method stub
if (autoApplyPlay) { if (autoApplyPlay) {
String app = json.getString("app"); String app = json.getString("app");
String streamId = json.getString("stream"); String streamId = json.getString("stream");
@ -367,8 +339,6 @@ public class ZLMHttpHookListener {
mediaServerConfig.setWanIp(StringUtils.isEmpty(mediaWanIp)? mediaIp: mediaWanIp); mediaServerConfig.setWanIp(StringUtils.isEmpty(mediaWanIp)? mediaIp: mediaWanIp);
mediaServerConfig.setLocalIP(mediaIp); mediaServerConfig.setLocalIP(mediaIp);
redisCatchStorage.updateMediaInfo(mediaServerConfig); redisCatchStorage.updateMediaInfo(mediaServerConfig);
// TODO Auto-generated method stub
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
ret.put("code", 0); ret.put("code", 0);
ret.put("msg", "success"); ret.put("msg", "success");

20
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookSubscribe.java

@ -1,24 +1,8 @@
package com.genersoft.iot.vmp.media.zlm; package com.genersoft.iot.vmp.media.zlm;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
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.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.ConcurrentReferenceHashMap;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -31,8 +15,6 @@ import java.util.concurrent.ConcurrentHashMap;
@Component @Component
public class ZLMHttpHookSubscribe { public class ZLMHttpHookSubscribe {
private final static Logger logger = LoggerFactory.getLogger(ZLMHttpHookSubscribe.class);
public enum HookType{ public enum HookType{
on_flow_report, on_flow_report,
on_http_access, on_http_access,
@ -72,8 +54,6 @@ public class ZLMHttpHookSubscribe {
for (JSONObject key : eventMap.keySet()) { for (JSONObject key : eventMap.keySet()) {
Boolean result = null; Boolean result = null;
for (String s : key.keySet()) { for (String s : key.keySet()) {
String string = hookResponse.getString(s);
String string1 = key.getString(s);
if (result == null) { if (result == null) {
result = key.getString(s).equals(hookResponse.getString(s)); result = key.getString(s).equals(hookResponse.getString(s));
}else { }else {

1
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java

@ -11,7 +11,6 @@ import org.springframework.stereotype.Component;
import java.io.IOException; import java.io.IOException;
import java.net.ConnectException; import java.net.ConnectException;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.Map; import java.util.Map;
@Component @Component

10
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java

@ -5,8 +5,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.conf.MediaServerConfig; import com.genersoft.iot.vmp.conf.MediaServerConfig;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; //import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import okhttp3.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -16,9 +15,6 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -28,8 +24,8 @@ public class ZLMRunner implements CommandLineRunner {
private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class); private final static Logger logger = LoggerFactory.getLogger(ZLMRunner.class);
@Autowired // @Autowired
private IVideoManagerStorager storager; // private IVideoManagerStorager storager;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;

1
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java

@ -12,6 +12,7 @@ import com.github.pagehelper.PageInfo;
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月6日 下午2:14:31 * @date: 2020年5月6日 下午2:14:31
*/ */
@SuppressWarnings("rawtypes")
public interface IVideoManagerStorager { public interface IVideoManagerStorager {
/** /**

7
src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java

@ -11,7 +11,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -144,9 +143,9 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage {
@Override @Override
public StreamInfo queryPlaybackByDevice(String deviceId, String code) { public StreamInfo queryPlaybackByDevice(String deviceId, String code) {
String format = String.format("%S_*_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, // String format = String.format("%S_*_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
deviceId, // deviceId,
code); // code);
List<Object> playLeys = redis.scan(String.format("%S_*_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX, List<Object> playLeys = redis.scan(String.format("%S_*_%s_%s", VideoManagerConstants.PLAY_BLACK_PREFIX,
deviceId, deviceId,
code)); code));

9
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@ -9,19 +9,18 @@ import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMobilePositionMapper; import com.genersoft.iot.vmp.storager.dao.DeviceMobilePositionMapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.springframework.util.StringUtils;
/** /**
* @Description:视频设备数据存储-jdbc实现 * @Description:视频设备数据存储-jdbc实现
* @author: swwheihei * @author: swwheihei
* @date: 2020年5月6日 下午2:31:42 * @date: 2020年5月6日 下午2:31:42
*/ */
@SuppressWarnings("rawtypes")
@Component @Component
public class VideoManagerStoragerImpl implements IVideoManagerStorager { public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@ -183,11 +182,11 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Override @Override
public synchronized boolean online(String deviceId) { public synchronized boolean online(String deviceId) {
Device device = deviceMapper.getDeviceByDeviceId(deviceId); Device device = deviceMapper.getDeviceByDeviceId(deviceId);
device.setOnline(1);
System.out.println("更新设备在线");
if (device == null) { if (device == null) {
return false; return false;
} }
device.setOnline(1);
System.out.println("更新设备在线");
return deviceMapper.update(device) > 0; return deviceMapper.update(device) > 0;
} }
@ -211,7 +210,7 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
*/ */
@Override @Override
public void cleanChannelsForDevice(String deviceId) { public void cleanChannelsForDevice(String deviceId) {
int result = deviceChannelMapper.cleanChannelsByDeviceId(deviceId); deviceChannelMapper.cleanChannelsByDeviceId(deviceId);
} }
/** /**

3
src/main/java/com/genersoft/iot/vmp/utils/redis/RedisUtil.java

@ -4,8 +4,6 @@ import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.*; import org.springframework.data.redis.core.*;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@ -16,6 +14,7 @@ import org.springframework.util.CollectionUtils;
* @date: 2020年5月6日 下午8:27:29 * @date: 2020年5月6日 下午8:27:29
*/ */
@Component @Component
@SuppressWarnings(value = {"rawtypes", "unchecked"})
public class RedisUtil { public class RedisUtil {
@Autowired @Autowired

1
src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceConfig.java

@ -20,7 +20,6 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;

2
src/main/java/com/genersoft/iot/vmp/vmanager/device/DeviceQuery.java

@ -17,11 +17,11 @@ import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; 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.SIPCommander;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import javax.sip.message.Response; import javax.sip.message.Response;
@SuppressWarnings("rawtypes")
@CrossOrigin @CrossOrigin
@RestController @RestController
@RequestMapping("/api") @RequestMapping("/api")

7
src/main/java/com/genersoft/iot/vmp/vmanager/play/PlayController.java

@ -1,20 +1,16 @@
package com.genersoft.iot.vmp.vmanager.play; package com.genersoft.iot.vmp.vmanager.play;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.MediaServerConfig; import com.genersoft.iot.vmp.conf.MediaServerConfig;
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.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.media.zlm.ZLMRTPServerFactory;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.service.IPlayService; import com.genersoft.iot.vmp.vmanager.service.IPlayService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
@ -31,7 +27,6 @@ import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
import javax.sip.message.Response; import javax.sip.message.Response;
import java.text.DecimalFormat;
import java.util.UUID; import java.util.UUID;
@CrossOrigin @CrossOrigin
@ -145,7 +140,7 @@ public class PlayController {
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid); msg.setId(DeferredResultHolder.CALLBACK_CMD_STOP + uuid);
Response response = event.getResponse(); //Response response = event.getResponse();
msg.setData(String.format("success")); msg.setData(String.format("success"));
resultHolder.invokeResult(msg); resultHolder.invokeResult(msg);
} }

11
src/main/java/com/genersoft/iot/vmp/vmanager/playback/PlaybackController.java

@ -1,24 +1,19 @@
package com.genersoft.iot.vmp.vmanager.playback; package com.genersoft.iot.vmp.vmanager.playback;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; 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.callback.RequestMessage;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; //import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.service.IPlayService; import com.genersoft.iot.vmp.vmanager.service.IPlayService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
@ -47,8 +42,8 @@ public class PlaybackController {
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@Autowired // @Autowired
private ZLMRESTfulUtils zlmresTfulUtils; // private ZLMRESTfulUtils zlmresTfulUtils;
@Autowired @Autowired
private IPlayService playService; private IPlayService playService;

1
src/main/java/com/genersoft/iot/vmp/vmanager/service/IPlayService.java

@ -1,7 +1,6 @@
package com.genersoft.iot.vmp.vmanager.service; package com.genersoft.iot.vmp.vmanager.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
/** /**
* 点播处理 * 点播处理

3
src/main/java/com/genersoft/iot/vmp/vmanager/service/impl/PlayServiceImpl.java

@ -9,15 +9,12 @@ 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.callback.RequestMessage;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.play.PlayController;
import com.genersoft.iot.vmp.vmanager.service.IPlayService; import com.genersoft.iot.vmp.vmanager.service.IPlayService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
@Service @Service
public class PlayServiceImpl implements IPlayService { public class PlayServiceImpl implements IPlayService {

6
src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java

@ -1,8 +1,5 @@
package com.genersoft.iot.vmp.vmanager.user; package com.genersoft.iot.vmp.vmanager.user;
import com.genersoft.iot.vmp.vmanager.play.PlayController;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
@ -14,9 +11,6 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/api") @RequestMapping("/api")
public class UserController { public class UserController {
private final static Logger logger = LoggerFactory.getLogger(UserController.class);
@Value("${auth.username}") @Value("${auth.username}")
private String usernameConfig; private String usernameConfig;

3
src/main/java/com/genersoft/iot/vmp/web/ApiControlController.java

@ -4,12 +4,9 @@ import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.ptz.PtzController;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
/** /**

2
src/main/java/com/genersoft/iot/vmp/web/ApiController.java

@ -5,11 +5,9 @@ import com.genersoft.iot.vmp.conf.SipConfig;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
/** /**

19
src/main/java/com/genersoft/iot/vmp/web/ApiDeviceController.java

@ -4,9 +4,9 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector; // import com.genersoft.iot.vmp.gb28181.event.DeviceOffLineDetector;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; // 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.SIPCommander;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -19,6 +19,7 @@ import java.util.List;
/** /**
* 兼容LiveGBS的API设备信息 * 兼容LiveGBS的API设备信息
*/ */
@SuppressWarnings("unchecked")
@CrossOrigin @CrossOrigin
@RestController @RestController
@RequestMapping(value = "/api/v1/device") @RequestMapping(value = "/api/v1/device")
@ -29,14 +30,14 @@ public class ApiDeviceController {
@Autowired @Autowired
private IVideoManagerStorager storager; private IVideoManagerStorager storager;
@Autowired // @Autowired
private SIPCommander cmder; // private SIPCommander cmder;
@Autowired // @Autowired
private DeferredResultHolder resultHolder; // private DeferredResultHolder resultHolder;
@Autowired // @Autowired
private DeviceOffLineDetector offLineDetector; // private DeviceOffLineDetector offLineDetector;
/** /**
* 分页获取设备列表 TODO 现在直接返回尚未实现分页 * 分页获取设备列表 TODO 现在直接返回尚未实现分页

10
src/main/java/com/genersoft/iot/vmp/web/ApiStreamController.java

@ -1,21 +1,18 @@
package com.genersoft.iot.vmp.web; package com.genersoft.iot.vmp.web;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; // import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
import com.genersoft.iot.vmp.vmanager.play.PlayController; import com.genersoft.iot.vmp.vmanager.play.PlayController;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.context.request.async.DeferredResult;
@ -23,6 +20,7 @@ import org.springframework.web.context.request.async.DeferredResult;
/** /**
* 兼容LiveGBS的API实时直播 * 兼容LiveGBS的API实时直播
*/ */
@SuppressWarnings(value = {"rawtypes", "unchecked"})
@CrossOrigin @CrossOrigin
@RestController @RestController
@RequestMapping(value = "/api/v1/stream") @RequestMapping(value = "/api/v1/stream")
@ -40,8 +38,8 @@ public class ApiStreamController {
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@Autowired // @Autowired
private ZLMRESTfulUtils zlmresTfulUtils; // private ZLMRESTfulUtils zlmresTfulUtils;
@Autowired @Autowired

3
src/main/java/com/genersoft/iot/vmp/web/AuthController.java

@ -1,9 +1,6 @@
package com.genersoft.iot.vmp.web; package com.genersoft.iot.vmp.web;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;

Loading…
Cancel
Save