Browse Source

修改bug

pull/1/head
648540858 4 years ago
parent
commit
002782569d
  1. 3
      README.md
  2. 24
      src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java
  3. 62
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
  4. 2
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRunner.java
  5. 14
      src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java

3
README.md

@ -36,4 +36,5 @@ web界面系统设置
QQ群: 901799015
# 致谢
感谢作者[夏楚](https://github.com/xiongziliang) 提供这么棒的开源流媒体服务框架
感谢作者[夏楚](https://github.com/xiongziliang) 提供这么棒的开源流媒体服务框架

24
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/OfflineEventListener.java

@ -38,21 +38,23 @@ public class OfflineEventListener implements ApplicationListener<OfflineEvent> {
String key = VideoManagerConstants.KEEPLIVEKEY_PREFIX + event.getDeviceId();
switch (event.getFrom()) {
// 心跳超时触发的离线事件,说明redis中已删除,无需处理
case VideoManagerConstants.EVENT_OUTLINE_TIMEOUT:
break;
// 设备主动注销触发的离线事件,需要删除redis中的超时监听
case VideoManagerConstants.EVENT_OUTLINE_UNREGISTER:
redis.del(key);
break;
default:
boolean exist = redis.hasKey(key);
if (exist) {
// 心跳超时触发的离线事件,说明redis中已删除,无需处理
case VideoManagerConstants.EVENT_OUTLINE_TIMEOUT:
break;
// 设备主动注销触发的离线事件,需要删除redis中的超时监听
case VideoManagerConstants.EVENT_OUTLINE_UNREGISTER:
redis.del(key);
}
break;
default:
boolean exist = redis.hasKey(key);
if (exist) {
redis.del(key);
}
}
// 处理离线监听
storager.outline(event.getDeviceId());
//
}
}

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

@ -181,15 +181,15 @@ public class SIPCommander implements ISIPCommander {
try {
String cmdStr= cmdString(leftRight, upDown, inOut, moveSpeed, zoomSpeed);
StringBuffer ptzXml = new StringBuffer(200);
ptzXml.append("<?xml version=\"1.0\" ?>");
ptzXml.append("<Control>");
ptzXml.append("<CmdType>DeviceControl</CmdType>");
ptzXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>");
ptzXml.append("<DeviceID>" + channelId + "</DeviceID>");
ptzXml.append("<PTZCmd>" + cmdStr + "</PTZCmd>");
ptzXml.append("<Info>");
ptzXml.append("</Info>");
ptzXml.append("</Control>");
ptzXml.append("<?xml version=\"1.0\" ?>\r\n");
ptzXml.append("<Control>\r\n");
ptzXml.append("<CmdType>DeviceControl</CmdType>\r\n");
ptzXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
ptzXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
ptzXml.append("<PTZCmd>" + cmdStr + "</PTZCmd>\r\n");
ptzXml.append("<Info>\r\n");
ptzXml.append("</Info>\r\n");
ptzXml.append("</Control>\r\n");
Request request = headerProvider.createMessageRequest(device, ptzXml.toString(), "ViaPtzBranch", "FromPtzTag", "ToPtzTag");
@ -458,12 +458,12 @@ public class SIPCommander implements ISIPCommander {
public boolean deviceInfoQuery(Device device) {
try {
StringBuffer catalogXml = new StringBuffer(200);
catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>");
catalogXml.append("<Query>");
catalogXml.append("<CmdType>DeviceInfo</CmdType>");
catalogXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>");
catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>");
catalogXml.append("</Query>");
catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
catalogXml.append("<Query>\r\n");
catalogXml.append("<CmdType>DeviceInfo</CmdType>\r\n");
catalogXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
catalogXml.append("</Query>\r\n");
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "ViaDeviceInfoBranch", "FromDeviceInfoTag", "ToDeviceInfoTag");
transmitRequest(device, request);
@ -486,12 +486,12 @@ public class SIPCommander implements ISIPCommander {
storager.cleanChannelsForDevice(device.getDeviceId());
try {
StringBuffer catalogXml = new StringBuffer(200);
catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>");
catalogXml.append("<Query>");
catalogXml.append("<CmdType>Catalog</CmdType>");
catalogXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>");
catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>");
catalogXml.append("</Query>");
catalogXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
catalogXml.append("<Query>\r\n");
catalogXml.append("<CmdType>Catalog</CmdType>\r\n");
catalogXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
catalogXml.append("<DeviceID>" + device.getDeviceId() + "</DeviceID>\r\n");
catalogXml.append("</Query>\r\n");
Request request = headerProvider.createMessageRequest(device, catalogXml.toString(), "ViaCatalogBranch", "FromCatalogTag", "ToCatalogTag");
transmitRequest(device, request);
@ -514,17 +514,17 @@ public class SIPCommander implements ISIPCommander {
try {
StringBuffer recordInfoXml = new StringBuffer(200);
recordInfoXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>");
recordInfoXml.append("<Query>");
recordInfoXml.append("<CmdType>RecordInfo</CmdType>");
recordInfoXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>");
recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>");
recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>");
recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>");
recordInfoXml.append("<Secrecy>0</Secrecy>");
recordInfoXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n");
recordInfoXml.append("<Query>\r\n");
recordInfoXml.append("<CmdType>RecordInfo</CmdType>\r\n");
recordInfoXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>\r\n");
recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>\r\n");
recordInfoXml.append("<Secrecy>0</Secrecy>\\r\n");
// 大华NVR要求必须增加一个值为all的文本元素节点Type
recordInfoXml.append("<Type>all</Type>");
recordInfoXml.append("</Query>");
recordInfoXml.append("<Type>all</Type>\r\n");
recordInfoXml.append("</Query>\r\n");
Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(), "ViaRecordInfoBranch", "FromRecordInfoTag", "ToRecordInfoTag");
transmitRequest(device, request);

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

@ -99,6 +99,7 @@ public class ZLMRunner implements CommandLineRunner {
param.put("secret",mediaSecret);
param.put("hook.enable","1");
param.put("hook.on_flow_report","");
param.put("hook.on_play","");
param.put("hook.on_http_access","");
param.put("hook.on_publish",String.format("%s/on_publish", hookPrex));
param.put("hook.on_record_mp4","");
@ -107,6 +108,7 @@ public class ZLMRunner implements CommandLineRunner {
param.put("hook.on_rtsp_realm","");
param.put("hook.on_server_started",String.format("%s/on_server_started", hookPrex));
param.put("hook.on_shell_login",String.format("%s/on_shell_login", hookPrex));
param.put("hook.on_stream_changed",String.format("%s/on_stream_changed", hookPrex));
param.put("hook.on_stream_none_reader",String.format("%s/on_stream_none_reader", hookPrex));
param.put("hook.on_stream_not_found",String.format("%s/on_stream_not_found", hookPrex));
param.put("hook.timeoutSec","20");

14
src/main/java/com/genersoft/iot/vmp/storager/redis/VideoManagerRedisStoragerImpl.java

@ -93,7 +93,7 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
":" + channel.getName() +
"_" + (channel.getStatus() == 1 ? "on":"off") +
"_" + (channelMap.get(channelId).size() > 0)+
"_" + channel.getParentId(),
"_" + (StringUtils.isEmpty(channel.getParentId())?null:channel.getParentId()),
channel);
// 更新device中的通道数量
Device device = (Device)redis.get(VideoManagerConstants.DEVICE_PREFIX+deviceId);
@ -113,7 +113,14 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
DeviceChannel deviceChannel = queryChannel(deviceId, parentId);
if (deviceChannel != null) {
deviceChannel.setSubCount(channelMap.get(parentId).size());
redis.set(VideoManagerConstants.CACHEKEY_PREFIX+deviceId + "_" + deviceChannel.getChannelId(),
// redis.set(VideoManagerConstants.CACHEKEY_PREFIX+deviceId + "_" + deviceChannel.getChannelId(),
// deviceChannel);
redis.set(VideoManagerConstants.CACHEKEY_PREFIX + deviceId +
"_" + deviceChannel.getChannelId() +
":" + deviceChannel.getName() +
"_" + (deviceChannel.getStatus() == 1 ? "on":"off") +
"_" + (channelMap.get(deviceChannel.getChannelId()).size() > 0)+
"_" + (StringUtils.isEmpty(deviceChannel.getParentId())?null:deviceChannel.getParentId()),
deviceChannel);
}
@ -438,7 +445,8 @@ public class VideoManagerRedisStoragerImpl implements IVideoManagerStorager {
if (subChannel == null) {
subChannel = new HashSet<>();
}
if (!"null".equals(s[6])) {
System.out.println(key);
if (s.length == 7 && !"null".equals(s[6])) {
subChannel.add(s[6]);
}
channelMap.put(channelId, subChannel);

Loading…
Cancel
Save