|
@ -253,14 +253,77 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
|
|
if (channelDeviceElement == null) { |
|
|
if (channelDeviceElement == null) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
String channelDeviceId = channelDeviceElement.getTextTrim(); |
|
|
Element eventElement = itemDevice.element("Event"); |
|
|
|
|
|
switch (eventElement.getText().toUpperCase()) { |
|
|
|
|
|
case "ON" : // 上线
|
|
|
|
|
|
logger.info("收到来自设备【{}】的通道上线【{}】通知", device.getDeviceId(), channelId); |
|
|
|
|
|
storager.deviceChannelOnline(deviceId, channelId); |
|
|
|
|
|
// 回复200 OK
|
|
|
|
|
|
responseAck(evt, Response.OK); |
|
|
|
|
|
break; |
|
|
|
|
|
case "OFF" : // 离线
|
|
|
|
|
|
logger.info("收到来自设备【{}】的通道离线【{}】通知", device.getDeviceId(), channelId); |
|
|
|
|
|
storager.deviceChannelOffline(deviceId, channelId); |
|
|
|
|
|
// 回复200 OK
|
|
|
|
|
|
responseAck(evt, Response.OK); |
|
|
|
|
|
break; |
|
|
|
|
|
case "VLOST" : // 视频丢失
|
|
|
|
|
|
logger.info("收到来自设备【{}】的通道视频丢失【{}】通知", device.getDeviceId(), channelId); |
|
|
|
|
|
storager.deviceChannelOffline(deviceId, channelId); |
|
|
|
|
|
// 回复200 OK
|
|
|
|
|
|
responseAck(evt, Response.OK); |
|
|
|
|
|
break; |
|
|
|
|
|
case "DEFECT" : // 故障
|
|
|
|
|
|
// 回复200 OK
|
|
|
|
|
|
responseAck(evt, Response.OK); |
|
|
|
|
|
break; |
|
|
|
|
|
case "ADD" : // 增加
|
|
|
|
|
|
logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channelId); |
|
|
|
|
|
DeviceChannel deviceChannel = channelContentHander(itemDevice, channelId); |
|
|
|
|
|
storager.updateChannel(deviceId, deviceChannel); |
|
|
|
|
|
responseAck(evt, Response.OK); |
|
|
|
|
|
break; |
|
|
|
|
|
case "DEL" : // 删除
|
|
|
|
|
|
logger.info("收到来自设备【{}】的删除通道【{}】通知", device.getDeviceId(), channelId); |
|
|
|
|
|
storager.delChannel(deviceId, channelId); |
|
|
|
|
|
responseAck(evt, Response.OK); |
|
|
|
|
|
break; |
|
|
|
|
|
case "UPDATE" : // 更新
|
|
|
|
|
|
logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channelId); |
|
|
|
|
|
DeviceChannel channel = channelContentHander(itemDevice, channelId); |
|
|
|
|
|
storager.updateChannel(deviceId, channel); |
|
|
|
|
|
responseAck(evt, Response.OK); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
responseAck(evt, Response.BAD_REQUEST, "event not found"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RequestMessage msg = new RequestMessage();
|
|
|
|
|
|
// msg.setDeviceId(deviceId);
|
|
|
|
|
|
// msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG);
|
|
|
|
|
|
// msg.setData(device);
|
|
|
|
|
|
// deferredResultHolder.invokeResult(msg);
|
|
|
|
|
|
|
|
|
|
|
|
if (offLineDetector.isOnline(deviceId)) { |
|
|
|
|
|
publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public DeviceChannel channelContentHander(Element itemDevice, String channelId){ |
|
|
Element channdelNameElement = itemDevice.element("Name"); |
|
|
Element channdelNameElement = itemDevice.element("Name"); |
|
|
String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : ""; |
|
|
String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : ""; |
|
|
Element statusElement = itemDevice.element("Status"); |
|
|
Element statusElement = itemDevice.element("Status"); |
|
|
String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON"; |
|
|
String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON"; |
|
|
DeviceChannel deviceChannel = new DeviceChannel(); |
|
|
DeviceChannel deviceChannel = new DeviceChannel(); |
|
|
deviceChannel.setName(channelName); |
|
|
deviceChannel.setName(channelName); |
|
|
deviceChannel.setChannelId(channelDeviceId); |
|
|
deviceChannel.setChannelId(channelId); |
|
|
// 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); |
|
@ -333,25 +396,8 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements |
|
|
deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); |
|
|
deviceChannel.setPTZType(Integer.parseInt(XmlUtil.getText(itemDevice, "PTZType"))); |
|
|
} |
|
|
} |
|
|
deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC
|
|
|
deviceChannel.setHasAudio(true); // 默认含有音频,播放时再检查是否有音频及是否AAC
|
|
|
storager.updateChannel(device.getDeviceId(), deviceChannel); |
|
|
return deviceChannel; |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// RequestMessage msg = new RequestMessage();
|
|
|
|
|
|
// msg.setDeviceId(deviceId);
|
|
|
|
|
|
// msg.setType(DeferredResultHolder.CALLBACK_CMD_CATALOG);
|
|
|
|
|
|
// msg.setData(device);
|
|
|
|
|
|
// deferredResultHolder.invokeResult(msg);
|
|
|
|
|
|
// 回复200 OK
|
|
|
|
|
|
responseAck(evt, Response.OK); |
|
|
|
|
|
if (offLineDetector.isOnline(deviceId)) { |
|
|
|
|
|
publisher.onlineEventPublish(device, VideoManagerConstants.EVENT_ONLINE_MESSAGE); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} catch (DocumentException | SipException | InvalidArgumentException | ParseException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|