From 57fd18cd7c842a821bd03fafe2a954c605e387f6 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: Wed, 30 Sep 2020 17:59:11 +0800
Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E9=A1=B5,=E6=90=9C?=
=?UTF-8?q?=E7=B4=A2,=E7=AD=89?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/encodings.xml | 1 +
README.md | 29 +-
.../iot/vmp/conf/VManagerConfig.java | 2 +
.../iot/vmp/gb28181/bean/DeviceChannel.java | 13 +
.../gb28181/transmit/SIPProcessorFactory.java | 2 +
.../request/impl/MessageRequestProcessor.java | 7 +-
.../vmp/storager/IVideoManagerStorager.java | 17 +-
.../iot/vmp/storager/VodeoMannagerTask.java | 17 +
.../jdbc/VideoManagerJdbcStoragerImpl.java | 12 +-
.../redis/VideoManagerRedisStoragerImpl.java | 695 +++++++++++-------
.../vmp/vmanager/device/DeviceController.java | 45 +-
.../iot/vmp/web/ApiDeviceController.java | 6 +-
src/main/resources/application.yml | 6 +-
13 files changed, 533 insertions(+), 319 deletions(-)
create mode 100644 src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java
diff --git a/.idea/encodings.xml b/.idea/encodings.xml
index fade66b8..e470467d 100644
--- a/.idea/encodings.xml
+++ b/.idea/encodings.xml
@@ -3,5 +3,6 @@
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 1f1dbc91..8eb641f3 100644
--- a/README.md
+++ b/README.md
@@ -6,38 +6,25 @@ WEB VIDEO PLATFORM是一个基于GB28181-2016标准实现的网络视频平台
### fork自 [swwheihei/wvp-GB28181](https://github.com/swwheihei/wvp-GB28181)
# 应用场景:
-主要应用在IPC等设备没有固定IP地址,但需要在互联网中观看的场景。
-要求IPC设备可以访问互联网,有云服务器用于部署本服务。
-预计7月可以达到商用级别的文档性
+原项目比较侧重单个摄像机的接入,当前这个更侧重平台接入,当然,直接接摄像机也是没有问题的。
# 支持特性:
1、视频预览
2、云台控制(方向、缩放控制)
3、视频设备信息同步
-4、离在线监控
-5、录像查询与回放(基于NVR\DVR,暂不支持快进、seek操作)
-6、无人观看自动断流
+4、离在线监控
+5、无人观看自动断流
-# 2020路线图:
-5月中旬-录像回放(基于NVR\DVR)、设备认证(基于密码)
-5月下旬-设备报警
-6月上旬-流媒体认证(ZLM推流、取流)
-6月下旬-语音对讲、Android Deme\iOS Demo
-7月下旬-设备认证(基于数字证书)、集群部署
-8月下旬-云端录像与回放
-9月下旬-Onvif协议支持
-10月下旬-GB28181-2011版设备适配
+# 待实现:
+录像查询与回放(基于NVR\DVR,暂不支持快进、seek操作)
12月底-上级级联、时间同步、其他国标能力
# 项目部署
-参考wiki说明
+
# 使用帮助
-参考wiki说明
+
# 致谢
感谢作者[夏楚](https://github.com/xiongziliang) 提供这么棒的开源流媒体服务框架
-感谢作者[kkkkk5G](https://gitee.com/kkkkk5G) 提供这么棒的前端UI
-
-
-[]: https://github.com/swwheihei/wvp-GB28181
\ No newline at end of file
+感谢作者[kkkkk5G](https://gitee.com/kkkkk5G) 提供这么棒的前端UI
\ No newline at end of file
diff --git a/src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java
index 6045ea26..be83a88f 100644
--- a/src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java
+++ b/src/main/java/com/genersoft/iot/vmp/conf/VManagerConfig.java
@@ -21,5 +21,7 @@ public class VManagerConfig {
public void setDatabase(String database) {
this.database = database;
}
+
+
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
index 5c3989a2..73fafc19 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
@@ -128,6 +128,11 @@ public class DeviceChannel {
*/
private double latitude;
+ /**
+ * 子设备数
+ */
+ private int subCount;
+
/**
* 流唯一编号,存在表示正在直播
*/
@@ -332,4 +337,12 @@ public class DeviceChannel {
public void setSsrc(String ssrc) {
this.ssrc = ssrc;
}
+
+ public int getSubCount() {
+ return subCount;
+ }
+
+ public void setSubCount(int subCount) {
+ this.subCount = subCount;
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
index fe97e2b6..63f28cd7 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorFactory.java
@@ -7,6 +7,7 @@ import javax.sip.header.CSeqHeader;
import javax.sip.message.Request;
import javax.sip.message.Response;
+import com.alibaba.fastjson.JSON;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -126,6 +127,7 @@ public class SIPProcessorFactory {
processor.setRequestEvent(evt);
return processor;
} else if (Request.MESSAGE.equals(method)) {
+
MessageRequestProcessor processor = new MessageRequestProcessor();
processor.setRequestEvent(evt);
processor.setTcpSipProvider(getTcpSipProvider());
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
index e9f59061..0dfcdb0f 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
@@ -144,6 +144,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
private void processMessageCatalogList(RequestEvent evt) {
try {
Element rootElement = getRootElement(evt);
+ String s = rootElement.toString();
Element deviceIdElement = rootElement.element("DeviceID");
String deviceId = deviceIdElement.getText().toString();
Element deviceListElement = rootElement.element("DeviceList");
@@ -171,10 +172,10 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setName(channelName);
deviceChannel.setChannelId(channelDeviceId);
- if(status.equals("ON")) {
+ if(status.equals("ON") || status.equals("On")) {
deviceChannel.setStatus(1);
}
- if(status.equals("OFF")) {
+ if(status.equals("OFF") || status.equals("Off")) {
deviceChannel.setStatus(0);
}
@@ -185,7 +186,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
deviceChannel.setBlock(XmlUtil.getText(itemDevice,"Block"));
deviceChannel.setAddress(XmlUtil.getText(itemDevice,"Address"));
deviceChannel.setParental(itemDevice.element("Parental") == null? 0:Integer.parseInt(XmlUtil.getText(itemDevice,"Parental")));
- deviceChannel.setParentId(XmlUtil.getText(itemDevice,"ParentId"));
+ deviceChannel.setParentId(XmlUtil.getText(itemDevice,"ParentID"));
deviceChannel.setSafetyWay(itemDevice.element("SafetyWay") == null? 0:Integer.parseInt(XmlUtil.getText(itemDevice,"SafetyWay")));
deviceChannel.setRegisterWay(itemDevice.element("RegisterWay") == null? 1:Integer.parseInt(XmlUtil.getText(itemDevice,"RegisterWay")));
deviceChannel.setCertNum(XmlUtil.getText(itemDevice,"CertNum"));
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
index 0993c116..69ac02be 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java
@@ -77,7 +77,7 @@ public interface IVideoManagerStorager {
* @param count 每页数量
* @return
*/
- public PageResult queryChannelsByDeviceId(String deviceId, int page, int count);
+ public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count);
/**
* 获取某个设备的通道列表
@@ -161,6 +161,19 @@ public interface IVideoManagerStorager {
*/
public StreamInfo queryPlay(String deviceId, String channelId);
+ /**
+ * 查询子设备
+ *
+ * @param deviceId
+ * @param channelId
+ * @param page
+ * @param count
+ * @return
+ */
+ PageResult querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count);
-
+ /**
+ * 更新缓存
+ */
+ public void updateCatch();
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java b/src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java
new file mode 100644
index 00000000..c96e4bb0
--- /dev/null
+++ b/src/main/java/com/genersoft/iot/vmp/storager/VodeoMannagerTask.java
@@ -0,0 +1,17 @@
+package com.genersoft.iot.vmp.storager;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+@Component
+public class VodeoMannagerTask implements CommandLineRunner {
+
+ @Autowired
+ private IVideoManagerStorager storager;
+
+ @Override
+ public void run(String... strings) throws Exception {
+ storager.updateCatch();
+ }
+}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/jdbc/VideoManagerJdbcStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/jdbc/VideoManagerJdbcStoragerImpl.java
index b4e2ff93..40ec1674 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/jdbc/VideoManagerJdbcStoragerImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/jdbc/VideoManagerJdbcStoragerImpl.java
@@ -79,10 +79,11 @@ public class VideoManagerJdbcStoragerImpl implements IVideoManagerStorager {
}
@Override
- public PageResult queryChannelsByDeviceId(String deviceId, int page, int count) {
+ public PageResult queryChannelsByDeviceId(String deviceId, String query, Boolean hasSubChannel, String online, int page, int count) {
return null;
}
+
@Override
public List queryChannelsByDeviceId(String deviceId) {
return null;
@@ -161,4 +162,13 @@ public class VideoManagerJdbcStoragerImpl implements IVideoManagerStorager {
return null;
}
+ @Override
+ public PageResult querySubChannels(String deviceId, String channelId, String query, Boolean hasSubChannel, String online, int page, int count) {
+ return null;
+ }
+
+ @Override
+ public void updateCatch() {
+
+ }
}
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java
index 8ea9f7ee..e1411ab5 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java
@@ -1,278 +1,417 @@
-package com.genersoft.iot.vmp.storager.redis;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONObject;
-import com.genersoft.iot.vmp.common.PageResult;
-import com.genersoft.iot.vmp.common.StreamInfo;
-import com.genersoft.iot.vmp.conf.MediaServerConfig;
-import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-
-import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.gb28181.bean.Device;
-import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
-import com.genersoft.iot.vmp.utils.redis.RedisUtil;
-
-/**
- * @Description:视频设备数据存储-redis实现
- * @author: swwheihei
- * @date: 2020年5月6日 下午2:31:42
- */
-@Component("redisStorager")
-public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
-
- @Autowired
- private RedisUtil redis;
-
-
- /**
- * 根据设备ID判断设备是否存在
- *
- * @param deviceId 设备ID
- * @return true:存在 false:不存在
- */
- @Override
- public boolean exists(String deviceId) {
- return redis.hasKey(VideoManagerConstants.DEVICE_PREFIX+deviceId);
- }
-
- /**
- * 视频设备创建
- *
- * @param device 设备对象
- * @return true:创建成功 false:创建失败
- */
- @Override
- public boolean create(Device device) {
- return redis.set(VideoManagerConstants.DEVICE_PREFIX+device.getDeviceId(), device);
- }
-
-
-
- /**
- * 视频设备更新
- *
- * @param device 设备对象
- * @return true:更新成功 false:更新失败
- */
- @Override
- public boolean updateDevice(Device device) {
- List