支持国标级联报警复位, 布防撤防,录像控制,强制关键帧,设备重启,拉框放大缩小, 看守位控制
parent
0688bb91d2
commit
8402edaf01
|
@ -2,9 +2,11 @@ package com.genersoft.iot.vmp.gb28181;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
|
import com.genersoft.iot.vmp.common.enums.DeviceControlType;
|
||||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||||
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.bean.DragZoomRequest;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.command.PTZCommand;
|
import com.genersoft.iot.vmp.gb28181.bean.command.PTZCommand;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
|
||||||
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
|
||||||
|
@ -25,6 +27,7 @@ import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import javax.sip.InvalidArgumentException;
|
import javax.sip.InvalidArgumentException;
|
||||||
import javax.sip.SipException;
|
import javax.sip.SipException;
|
||||||
|
import javax.sip.message.Response;
|
||||||
import java.text.ParseException;
|
import java.text.ParseException;
|
||||||
|
|
||||||
|
|
||||||
|
@ -136,14 +139,142 @@ public class GB28181ResourceServiceImpl implements IResourceService {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
commander.alarmCmd(checkResult.device, alarmMethod, alarmType,
|
commander.alarmCmd(checkResult.device, alarmMethod, alarmType,null, null);
|
||||||
errorResult -> onError(request, errorResult),
|
|
||||||
okResult -> onOk(request, okResult));
|
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败]: ", e);
|
logger.error("[命令发送失败]: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setGuard(CommonGbChannel commonGbChannel, boolean setGuard) {
|
||||||
|
CheckCommonGbChannelResult checkResult = checkCommonGbChannel(commonGbChannel);
|
||||||
|
|
||||||
|
if (checkResult.errorMsg != null) {
|
||||||
|
logger.warn("[资源类-国标28181] 布防/撤防失败: {}", checkResult.errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (checkResult.device == null || checkResult.channel == null) {
|
||||||
|
logger.warn("[资源类-国标28181] 布防/撤防失败: 设备获取失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
commander.guardCmd(checkResult.device, setGuard,null, null);
|
||||||
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
|
logger.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setRecord(CommonGbChannel commonGbChannel, Boolean isRecord) {
|
||||||
|
CheckCommonGbChannelResult checkResult = checkCommonGbChannel(commonGbChannel);
|
||||||
|
|
||||||
|
if (checkResult.errorMsg != null) {
|
||||||
|
logger.warn("[资源类-国标28181] 录像控制失败: {}", checkResult.errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (checkResult.device == null || checkResult.channel == null) {
|
||||||
|
logger.warn("[资源类-国标28181] 录像控制失败: 设备获取失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
commander.recordCmd(checkResult.device, checkResult.channel.getChannelId(), isRecord,null, null);
|
||||||
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
|
logger.error("[命令发送失败] 录像控制命令: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setIFame(CommonGbChannel commonGbChannel) {
|
||||||
|
CheckCommonGbChannelResult checkResult = checkCommonGbChannel(commonGbChannel);
|
||||||
|
|
||||||
|
if (checkResult.errorMsg != null) {
|
||||||
|
logger.warn("[资源类-国标28181] 强制关键帧失败: {}", checkResult.errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (checkResult.device == null || checkResult.channel == null) {
|
||||||
|
logger.warn("[资源类-国标28181] 强制关键帧失败: 设备获取失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
commander.iFrameCmd(checkResult.device, checkResult.channel.getChannelId());
|
||||||
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
|
logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setTeleBoot(CommonGbChannel commonGbChannel) {
|
||||||
|
CheckCommonGbChannelResult checkResult = checkCommonGbChannel(commonGbChannel);
|
||||||
|
|
||||||
|
if (checkResult.errorMsg != null) {
|
||||||
|
logger.warn("[资源类-国标28181] 重启设备失败: {}", checkResult.errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (checkResult.device == null || checkResult.channel == null) {
|
||||||
|
logger.warn("[资源类-国标28181] 重启设备失败: 设备获取失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
commander.teleBootCmd(checkResult.device);
|
||||||
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
|
logger.error("[命令发送失败] 重启设备: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void dragZoom(CommonGbChannel commonGbChannel, DragZoomRequest.DragZoom dragZoom, boolean isIn) {
|
||||||
|
CheckCommonGbChannelResult checkResult = checkCommonGbChannel(commonGbChannel);
|
||||||
|
|
||||||
|
if (checkResult.errorMsg != null) {
|
||||||
|
logger.warn("[资源类-国标28181] 拉框放大/缩小失败: {}", checkResult.errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (checkResult.device == null || checkResult.channel == null) {
|
||||||
|
logger.warn("[资源类-国标28181] 拉框放大/缩小失败: 设备获取失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
|
String type = isIn? DeviceControlType.DRAG_ZOOM_IN.getVal(): DeviceControlType.DRAG_ZOOM_OUT.getVal();
|
||||||
|
cmdXml.append("<" + type + ">\r\n");
|
||||||
|
cmdXml.append("<Length>" + dragZoom.getLength() + "</Length>\r\n");
|
||||||
|
cmdXml.append("<Width>" + dragZoom.getWidth() + "</Width>\r\n");
|
||||||
|
cmdXml.append("<MidPointX>" + dragZoom.getMidPointX() + "</MidPointX>\r\n");
|
||||||
|
cmdXml.append("<MidPointY>" + dragZoom.getMidPointY() + "</MidPointY>\r\n");
|
||||||
|
cmdXml.append("<LengthX>" + dragZoom.getLengthX() + "</LengthX>\r\n");
|
||||||
|
cmdXml.append("<LengthY>" + dragZoom.getLengthY() + "</LengthY>\r\n");
|
||||||
|
cmdXml.append("</" + type + ">\r\n");
|
||||||
|
try {
|
||||||
|
commander.dragZoomCmd(checkResult.device, checkResult.channel.getChannelId(), cmdXml.toString());
|
||||||
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
|
logger.error("[命令发送失败] 拉框放大/缩小: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setHomePosition(CommonGbChannel commonGbChannel, boolean enabled, Integer resetTime, Integer presetIndex) {
|
||||||
|
CheckCommonGbChannelResult checkResult = checkCommonGbChannel(commonGbChannel);
|
||||||
|
|
||||||
|
if (checkResult.errorMsg != null) {
|
||||||
|
logger.warn("[资源类-国标28181] 看守位控制失败: {}", checkResult.errorMsg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (checkResult.device == null || checkResult.channel == null) {
|
||||||
|
logger.warn("[资源类-国标28181] 看守位控制失败: 设备获取失败");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
commander.homePositionCmd(checkResult.device, checkResult.channel.getChannelId(),
|
||||||
|
enabled, resetTime, presetIndex, null, null);
|
||||||
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
|
logger.error("[命令发送失败] 看守位控制: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void streamOffline(String app, String streamId) {
|
public void streamOffline(String app, String streamId) {
|
||||||
// TODO
|
// TODO
|
||||||
|
|
|
@ -107,6 +107,18 @@ public class DragZoomRequest {
|
||||||
public void setLengthY(Integer lengthY) {
|
public void setLengthY(Integer lengthY) {
|
||||||
this.lengthY = lengthY;
|
this.lengthY = lengthY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "DragZoom{" +
|
||||||
|
"length=" + length +
|
||||||
|
", width=" + width +
|
||||||
|
", midPointX=" + midPointX +
|
||||||
|
", midPointY=" + midPointY +
|
||||||
|
", lengthX=" + lengthX +
|
||||||
|
", lengthY=" + lengthY +
|
||||||
|
'}';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSn() {
|
public String getSn() {
|
||||||
|
|
|
@ -6,16 +6,13 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.command.CommandType;
|
import com.genersoft.iot.vmp.gb28181.bean.command.CommandType;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.command.ICommandInfo;
|
import com.genersoft.iot.vmp.gb28181.bean.command.ICommandInfo;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.command.PTZCommand;
|
import com.genersoft.iot.vmp.gb28181.bean.command.PTZCommand;
|
||||||
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
|
|
||||||
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.transmit.cmd.impl.SIPCommanderFroPlatform;
|
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
|
||||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.control.ControlMessageHandler;
|
||||||
import com.genersoft.iot.vmp.service.IDeviceChannelService;
|
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
|
||||||
import com.genersoft.iot.vmp.service.IPlatformChannelService;
|
import com.genersoft.iot.vmp.service.IPlatformChannelService;
|
||||||
import com.genersoft.iot.vmp.service.IResourceService;
|
import com.genersoft.iot.vmp.service.IResourceService;
|
||||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
|
||||||
import gov.nist.javax.sip.message.SIPRequest;
|
import gov.nist.javax.sip.message.SIPRequest;
|
||||||
import org.dom4j.Element;
|
import org.dom4j.Element;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -34,7 +31,6 @@ import java.text.ParseException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import static com.genersoft.iot.vmp.gb28181.utils.XmlUtil.*;
|
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
|
public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent implements InitializingBean, IMessageHandler {
|
||||||
|
@ -45,20 +41,12 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
@Autowired
|
@Autowired
|
||||||
private ControlMessageHandler controlMessageHandler;
|
private ControlMessageHandler controlMessageHandler;
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private SIPCommander cmder;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IPlatformChannelService platformChannelService;
|
private IPlatformChannelService platformChannelService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Map<String, IResourceService> resourceServiceMap;
|
private Map<String, IResourceService> resourceServiceMap;
|
||||||
|
|
||||||
@Qualifier("taskExecutor")
|
|
||||||
@Autowired
|
|
||||||
private ThreadPoolTaskExecutor taskExecutor;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void afterPropertiesSet() throws Exception {
|
public void afterPropertiesSet() throws Exception {
|
||||||
controlMessageHandler.addHandler(cmdType, this);
|
controlMessageHandler.addHandler(cmdType, this);
|
||||||
|
@ -76,9 +64,9 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
|
|
||||||
// 此处是上级发出的DeviceControl指令
|
// 此处是上级发出的DeviceControl指令
|
||||||
String targetGBId = ((SipURI) request.getToHeader().getAddress().getURI()).getUser();
|
String targetGBId = ((SipURI) request.getToHeader().getAddress().getURI()).getUser();
|
||||||
String channelId = getText(rootElement, "DeviceID");
|
String channelId = XmlUtil.getText(rootElement, "DeviceID");
|
||||||
// 远程启动功能
|
// 远程启动功能
|
||||||
if (!ObjectUtils.isEmpty(getText(rootElement, "TeleBoot"))) {
|
if (!ObjectUtils.isEmpty(XmlUtil.getText(rootElement, "TeleBoot"))) {
|
||||||
// TODO 拒绝远程启动命令
|
// TODO 拒绝远程启动命令
|
||||||
logger.warn("[国标级联]收到平台的远程启动命令, 不处理");
|
logger.warn("[国标级联]收到平台的远程启动命令, 不处理");
|
||||||
}
|
}
|
||||||
|
@ -95,45 +83,6 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (deviceControlType) {
|
|
||||||
case PTZ:
|
|
||||||
handlePtzCmd(commonGbChannel, rootElement, request);
|
|
||||||
break;
|
|
||||||
case ALARM:
|
|
||||||
handleAlarmCmd(commonGbChannel, rootElement, request);
|
|
||||||
break;
|
|
||||||
// case GUARD:
|
|
||||||
// handleGuardCmd(deviceForPlatform, rootElement, request, DeviceControlType.GUARD);
|
|
||||||
// break;
|
|
||||||
// case RECORD:
|
|
||||||
// handleRecordCmd(deviceForPlatform, channelId, rootElement, request, DeviceControlType.RECORD);
|
|
||||||
// break;
|
|
||||||
// case I_FRAME:
|
|
||||||
// handleIFameCmd(deviceForPlatform, request, channelId);
|
|
||||||
// break;
|
|
||||||
// case TELE_BOOT:
|
|
||||||
// handleTeleBootCmd(deviceForPlatform, request);
|
|
||||||
// break;
|
|
||||||
// case DRAG_ZOOM_IN:
|
|
||||||
// handleDragZoom(deviceForPlatform, channelId, rootElement, request, DeviceControlType.DRAG_ZOOM_IN);
|
|
||||||
// break;
|
|
||||||
// case DRAG_ZOOM_OUT:
|
|
||||||
// handleDragZoom(deviceForPlatform, channelId, rootElement, request, DeviceControlType.DRAG_ZOOM_OUT);
|
|
||||||
// break;
|
|
||||||
// case HOME_POSITION:
|
|
||||||
// handleHomePositionCmd(deviceForPlatform, channelId, rootElement, request, DeviceControlType.HOME_POSITION);
|
|
||||||
// break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理云台指令
|
|
||||||
*/
|
|
||||||
private void handlePtzCmd(CommonGbChannel commonGbChannel, Element rootElement, SIPRequest request) {
|
|
||||||
IResourceService resourceService = resourceServiceMap.get(commonGbChannel.getType());
|
IResourceService resourceService = resourceServiceMap.get(commonGbChannel.getType());
|
||||||
if (resourceService == null) {
|
if (resourceService == null) {
|
||||||
try {
|
try {
|
||||||
|
@ -143,16 +92,53 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
switch (deviceControlType) {
|
||||||
|
case PTZ:
|
||||||
|
handlePtzCmd(commonGbChannel, resourceService, rootElement, request);
|
||||||
|
break;
|
||||||
|
case ALARM:
|
||||||
|
handleAlarmCmd(commonGbChannel, resourceService, rootElement, request);
|
||||||
|
break;
|
||||||
|
case GUARD:
|
||||||
|
handleGuardCmd(commonGbChannel, resourceService, rootElement, request);
|
||||||
|
break;
|
||||||
|
case RECORD:
|
||||||
|
handleRecordCmd(commonGbChannel, resourceService, rootElement, request);
|
||||||
|
break;
|
||||||
|
case I_FRAME:
|
||||||
|
handleIFameCmd(commonGbChannel, resourceService, request);
|
||||||
|
break;
|
||||||
|
case TELE_BOOT:
|
||||||
|
handleTeleBootCmd(commonGbChannel, resourceService, request);
|
||||||
|
break;
|
||||||
|
case DRAG_ZOOM_IN:
|
||||||
|
handleDragZoom(commonGbChannel, resourceService, rootElement, request, true);
|
||||||
|
break;
|
||||||
|
case DRAG_ZOOM_OUT:
|
||||||
|
handleDragZoom(commonGbChannel, resourceService, rootElement, request, false);
|
||||||
|
break;
|
||||||
|
case HOME_POSITION:
|
||||||
|
handleHomePositionCmd(commonGbChannel, resourceService, rootElement, request);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
String cmdString = getText(rootElement, DeviceControlType.PTZ.getVal());
|
/**
|
||||||
// 解析云台控制参数
|
* 处理云台指令
|
||||||
ICommandInfo commandInfo = ControlCommand.analysisCommand(cmdString);
|
*/
|
||||||
if (commandInfo == null || !commandInfo.getType().equals(CommandType.PTZ)) {
|
private void handlePtzCmd(CommonGbChannel commonGbChannel, IResourceService resourceService, Element rootElement, SIPRequest request) {
|
||||||
try {
|
try {
|
||||||
responseAck(request, Response.OK);
|
responseAck(request, Response.OK);
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 错误信息: {}", e.getMessage());
|
logger.error("[命令发送失败] 错误信息: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
String cmdString = XmlUtil.getText(rootElement, DeviceControlType.PTZ.getVal());
|
||||||
|
// 解析云台控制参数
|
||||||
|
ICommandInfo commandInfo = ControlCommand.analysisCommand(cmdString);
|
||||||
|
if (commandInfo == null || !commandInfo.getType().equals(CommandType.PTZ)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PTZCommand ptzCommand = (PTZCommand)commandInfo;
|
PTZCommand ptzCommand = (PTZCommand)commandInfo;
|
||||||
|
@ -170,60 +156,56 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理强制关键帧
|
* 处理强制关键帧
|
||||||
*
|
|
||||||
* @param device 设备
|
|
||||||
* @param channelId 通道id
|
|
||||||
*/
|
*/
|
||||||
private void handleIFameCmd(Device device, SIPRequest request, String channelId) {
|
private void handleIFameCmd(CommonGbChannel commonGbChannel, IResourceService resourceService, SIPRequest request) {
|
||||||
|
logger.info("\r\n[强制关键帧] channelID: {} ", commonGbChannel.getCommonGbDeviceID());
|
||||||
try {
|
try {
|
||||||
cmder.iFrameCmd(device, channelId);
|
|
||||||
responseAck(request, Response.OK);
|
responseAck(request, Response.OK);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage());
|
logger.error("[命令发送失败] 错误信息: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
resourceService.setIFame(commonGbChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理重启命令
|
* 处理重启命令
|
||||||
*
|
*
|
||||||
* @param device 设备信息
|
|
||||||
*/
|
*/
|
||||||
private void handleTeleBootCmd(Device device, SIPRequest request) {
|
private void handleTeleBootCmd(CommonGbChannel commonGbChannel, IResourceService resourceService, SIPRequest request) {
|
||||||
|
logger.info("\r\n[重启设备] channelID: {} ", commonGbChannel.getCommonGbDeviceID());
|
||||||
try {
|
try {
|
||||||
cmder.teleBootCmd(device);
|
|
||||||
responseAck(request, Response.OK);
|
responseAck(request, Response.OK);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 重启: {}", e.getMessage());
|
logger.error("[重启设备] 错误信息: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
resourceService.setTeleBoot(commonGbChannel);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理拉框控制***
|
* 处理拉框控制
|
||||||
*
|
|
||||||
* @param device 设备信息
|
|
||||||
* @param channelId 通道id
|
|
||||||
* @param rootElement 根节点
|
|
||||||
* @param type 消息类型
|
|
||||||
*/
|
*/
|
||||||
private void handleDragZoom(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) {
|
private void handleDragZoom(CommonGbChannel commonGbChannel, IResourceService resourceService, Element rootElement, SIPRequest request, boolean isIn) {
|
||||||
try {
|
try {
|
||||||
DragZoomRequest dragZoomRequest = loadElement(rootElement, DragZoomRequest.class);
|
responseAck(request, Response.OK);
|
||||||
DragZoomRequest.DragZoom dragZoom = dragZoomRequest.getDragZoomIn();
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
if (dragZoom == null) {
|
logger.error("[拉框控制] 错误信息: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
DragZoomRequest dragZoomRequest = XmlUtil.loadElement(rootElement, DragZoomRequest.class);
|
||||||
|
DragZoomRequest.DragZoom dragZoom;
|
||||||
|
if (isIn) {
|
||||||
|
logger.info("\r\n[拉框放大] channelID: {}; 参数: {}", commonGbChannel.getCommonGbDeviceID(),
|
||||||
|
dragZoomRequest.getDragZoomIn().toString());
|
||||||
|
dragZoom = dragZoomRequest.getDragZoomIn();
|
||||||
|
}else {
|
||||||
|
logger.info("\r\n[拉框缩小] channelID: {}; 参数: {} ", commonGbChannel.getCommonGbDeviceID(),
|
||||||
|
dragZoomRequest.getDragZoomIn().toString());
|
||||||
dragZoom = dragZoomRequest.getDragZoomOut();
|
dragZoom = dragZoomRequest.getDragZoomOut();
|
||||||
}
|
}
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
resourceService.dragZoom(commonGbChannel, dragZoom, isIn);
|
||||||
cmdXml.append("<" + type.getVal() + ">\r\n");
|
|
||||||
cmdXml.append("<Length>" + dragZoom.getLength() + "</Length>\r\n");
|
|
||||||
cmdXml.append("<Width>" + dragZoom.getWidth() + "</Width>\r\n");
|
|
||||||
cmdXml.append("<MidPointX>" + dragZoom.getMidPointX() + "</MidPointX>\r\n");
|
|
||||||
cmdXml.append("<MidPointY>" + dragZoom.getMidPointY() + "</MidPointY>\r\n");
|
|
||||||
cmdXml.append("<LengthX>" + dragZoom.getLengthX() + "</LengthX>\r\n");
|
|
||||||
cmdXml.append("<LengthY>" + dragZoom.getLengthY() + "</LengthY>\r\n");
|
|
||||||
cmdXml.append("</" + type.getVal() + ">\r\n");
|
|
||||||
cmder.dragZoomCmd(device, channelId, cmdXml.toString());
|
|
||||||
responseAck(request, Response.OK);
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("[命令发送失败] 拉框控制: {}", e.getMessage());
|
logger.error("[命令发送失败] 拉框控制: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -231,27 +213,26 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理看守位命令***
|
* 处理看守位命令
|
||||||
*
|
|
||||||
* @param device 设备信息
|
|
||||||
* @param channelId 通道id
|
|
||||||
* @param rootElement 根节点
|
|
||||||
* @param request 请求信息
|
|
||||||
* @param type 消息类型
|
|
||||||
*/
|
*/
|
||||||
private void handleHomePositionCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) {
|
private void handleHomePositionCmd(CommonGbChannel commonGbChannel, IResourceService resourceService, Element rootElement, SIPRequest request) {
|
||||||
try {
|
try {
|
||||||
HomePositionRequest homePosition = loadElement(rootElement, HomePositionRequest.class);
|
responseAck(request, Response.OK);
|
||||||
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
|
logger.error("[拉框控制] 错误信息: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
HomePositionRequest homePosition = XmlUtil.loadElement(rootElement, HomePositionRequest.class);
|
||||||
//获取整个消息主体,我们只需要修改请求头即可
|
//获取整个消息主体,我们只需要修改请求头即可
|
||||||
HomePositionRequest.HomePosition info = homePosition.getHomePosition();
|
HomePositionRequest.HomePosition info = homePosition.getHomePosition();
|
||||||
if (info.getEnabled() == null) {
|
if (info.getEnabled() == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cmder.homePositionCmd(device, channelId, info.getEnabled().equals("1"),
|
resourceService.setHomePosition(commonGbChannel, info.getEnabled().equals("1"),
|
||||||
info.getResetTime() != null ? Integer.parseInt(info.getResetTime()): null,
|
info.getResetTime() != null ? Integer.parseInt(info.getResetTime()): null,
|
||||||
info.getPresetIndex() != null ? Integer.parseInt(info.getPresetIndex()): null,
|
info.getPresetIndex() != null ? Integer.parseInt(info.getPresetIndex()): null);
|
||||||
errorResult -> onError(request, errorResult),
|
|
||||||
okResult -> onOk(request, okResult));
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("[命令发送失败] 看守位设置: {}", e.getMessage());
|
logger.error("[命令发送失败] 看守位设置: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -260,15 +241,11 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
/**
|
/**
|
||||||
* 处理告警消息
|
* 处理告警消息
|
||||||
*/
|
*/
|
||||||
private void handleAlarmCmd(CommonGbChannel commonGbChannel, Element rootElement, SIPRequest request) {
|
private void handleAlarmCmd(CommonGbChannel commonGbChannel, IResourceService resourceService, Element rootElement, SIPRequest request) {
|
||||||
IResourceService resourceService = resourceServiceMap.get(commonGbChannel.getType());
|
|
||||||
if (resourceService == null) {
|
|
||||||
try {
|
try {
|
||||||
responseAck(request, Response.FORBIDDEN);
|
responseAck(request, Response.OK);
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 错误信息: {}", e.getMessage());
|
logger.error("[命令发送失败] 回复: {}", e.getMessage());
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//告警方法
|
//告警方法
|
||||||
|
@ -278,11 +255,11 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
List<Element> info = rootElement.elements("Info");
|
List<Element> info = rootElement.elements("Info");
|
||||||
if (info != null) {
|
if (info != null) {
|
||||||
for (Element element : info) {
|
for (Element element : info) {
|
||||||
String alarmMethodStr = getText(element, "AlarmMethod");
|
String alarmMethodStr = XmlUtil.getText(element, "AlarmMethod");
|
||||||
if (alarmMethodStr != null) {
|
if (alarmMethodStr != null) {
|
||||||
alarmMethod = Integer.parseInt(alarmMethodStr);
|
alarmMethod = Integer.parseInt(alarmMethodStr);
|
||||||
}
|
}
|
||||||
String alarmTypeStr = getText(element, "AlarmType");
|
String alarmTypeStr = XmlUtil.getText(element, "AlarmType");
|
||||||
if (alarmTypeStr != null) {
|
if (alarmTypeStr != null) {
|
||||||
alarmType = Integer.parseInt(alarmTypeStr);
|
alarmType = Integer.parseInt(alarmTypeStr);
|
||||||
}
|
}
|
||||||
|
@ -296,44 +273,41 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理录像控制
|
* 处理录像控制
|
||||||
*
|
|
||||||
* @param device 设备信息
|
|
||||||
* @param channelId 通道id
|
|
||||||
* @param rootElement 根节点
|
|
||||||
* @param request 请求信息
|
|
||||||
* @param type 消息类型
|
|
||||||
*/
|
*/
|
||||||
private void handleRecordCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) {
|
private void handleRecordCmd(CommonGbChannel commonGbChannel, IResourceService resourceService, Element rootElement, SIPRequest request) {
|
||||||
//获取整个消息主体,我们只需要修改请求头即可
|
//获取整个消息主体,我们只需要修改请求头即可
|
||||||
String cmdString = getText(rootElement, type.getVal());
|
String cmdString = XmlUtil.getText(rootElement, DeviceControlType.RECORD.getVal());
|
||||||
Boolean isRecord = null;
|
Boolean isRecord = null;
|
||||||
if (cmdString.equalsIgnoreCase("Record")) {
|
if (cmdString.equalsIgnoreCase("Record")) {
|
||||||
isRecord = true;
|
isRecord = true;
|
||||||
}else if (cmdString.equalsIgnoreCase("StopRecord")) {
|
}else if (cmdString.equalsIgnoreCase("StopRecord")) {
|
||||||
isRecord = false;
|
isRecord = false;
|
||||||
}else {
|
}else {
|
||||||
|
logger.info("\r\n[录像控制] 解析失败: {} ", commonGbChannel.getCommonGbDeviceID());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
if (isRecord) {
|
||||||
cmder.recordCmd(device, channelId, isRecord,
|
logger.info("\r\n[录像控制] 开始录像: channelId: {} ", commonGbChannel.getCommonGbDeviceID());
|
||||||
errorResult -> onError(request, errorResult),
|
}else {
|
||||||
okResult -> onOk(request, okResult));
|
logger.info("\r\n[录像控制] 停止录像: {} ", commonGbChannel.getCommonGbDeviceID());
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
|
||||||
logger.error("[命令发送失败] 录像控制: {}", e.getMessage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resourceService.setRecord(commonGbChannel, isRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理报警布防/撤防命令
|
* 处理报警布防/撤防命令
|
||||||
*
|
|
||||||
* @param device 设备信息
|
|
||||||
* @param rootElement 根节点
|
|
||||||
* @param request 请求信息
|
|
||||||
* @param type 消息类型
|
|
||||||
*/
|
*/
|
||||||
private void handleGuardCmd(Device device, Element rootElement, SIPRequest request, DeviceControlType type) {
|
private void handleGuardCmd(CommonGbChannel commonGbChannel, IResourceService resourceService, Element rootElement, SIPRequest request) {
|
||||||
|
try {
|
||||||
|
responseAck(request, Response.OK);
|
||||||
|
} catch (SipException | InvalidArgumentException | ParseException e) {
|
||||||
|
logger.error("[命令发送失败] 错误信息: {}", e.getMessage());
|
||||||
|
}
|
||||||
//获取整个消息主体,我们只需要修改请求头即可
|
//获取整个消息主体,我们只需要修改请求头即可
|
||||||
String cmdString = getText(rootElement, type.getVal());
|
String cmdString = XmlUtil.getText(rootElement, DeviceControlType.GUARD.getVal());
|
||||||
boolean setGuard;
|
boolean setGuard;
|
||||||
if (cmdString.equalsIgnoreCase("Record")) {
|
if (cmdString.equalsIgnoreCase("Record")) {
|
||||||
setGuard = true;
|
setGuard = true;
|
||||||
|
@ -342,43 +316,12 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
}else {
|
}else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
if (setGuard) {
|
||||||
cmder.guardCmd(device, setGuard,
|
logger.info("\r\n[报警布防]: channelId: {} ", commonGbChannel.getCommonGbDeviceID());
|
||||||
errorResult -> onError(request, errorResult),
|
}else {
|
||||||
okResult -> onOk(request, okResult));
|
logger.info("\r\n[报警撤防]: channelId: {} ", commonGbChannel.getCommonGbDeviceID());
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
|
||||||
logger.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
resourceService.setGuard(commonGbChannel, setGuard);
|
||||||
/**
|
|
||||||
* 错误响应处理
|
|
||||||
*
|
|
||||||
* @param request 请求
|
|
||||||
* @param eventResult 响应结构
|
|
||||||
*/
|
|
||||||
private void onError(SIPRequest request, SipSubscribe.EventResult eventResult) {
|
|
||||||
// 失败的回复
|
|
||||||
try {
|
|
||||||
responseAck(request, eventResult.statusCode, eventResult.msg);
|
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
|
||||||
logger.error("[命令发送失败] 回复: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 成功响应处理
|
|
||||||
*
|
|
||||||
* @param request 请求
|
|
||||||
* @param eventResult 响应结构
|
|
||||||
*/
|
|
||||||
private void onOk(SIPRequest request, SipSubscribe.EventResult eventResult) {
|
|
||||||
// 成功的回复
|
|
||||||
try {
|
|
||||||
responseAck(request, eventResult.statusCode);
|
|
||||||
} catch (SipException | InvalidArgumentException | ParseException e) {
|
|
||||||
logger.error("[命令发送失败] 回复: {}", e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.service;
|
||||||
|
|
||||||
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
import com.genersoft.iot.vmp.common.CommonGbChannel;
|
||||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||||
|
import com.genersoft.iot.vmp.gb28181.bean.DragZoomRequest;
|
||||||
import com.genersoft.iot.vmp.gb28181.bean.command.PTZCommand;
|
import com.genersoft.iot.vmp.gb28181.bean.command.PTZCommand;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -51,4 +52,34 @@ public interface IResourceService {
|
||||||
* 报警复位
|
* 报警复位
|
||||||
*/
|
*/
|
||||||
void resetAlarm(CommonGbChannel commonGbChannel, Integer alarmMethod, Integer alarmType);
|
void resetAlarm(CommonGbChannel commonGbChannel, Integer alarmMethod, Integer alarmType);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 布防/撤防
|
||||||
|
*/
|
||||||
|
void setGuard(CommonGbChannel commonGbChannel, boolean setGuard);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 录像控制
|
||||||
|
*/
|
||||||
|
void setRecord(CommonGbChannel commonGbChannel, Boolean isRecord);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 强制关键帧
|
||||||
|
*/
|
||||||
|
void setIFame(CommonGbChannel commonGbChannel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 重启
|
||||||
|
*/
|
||||||
|
void setTeleBoot(CommonGbChannel commonGbChannel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拉框放大/缩小
|
||||||
|
*/
|
||||||
|
void dragZoom(CommonGbChannel commonGbChannel, DragZoomRequest.DragZoom dragZoom, boolean isIn);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 看守位控制
|
||||||
|
*/
|
||||||
|
void setHomePosition(CommonGbChannel commonGbChannel, boolean enabled, Integer resetTime, Integer presetIndex);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue