修复WVP作为下级平台接受deviceControl指令的问题-修复指令响应
parent
40ece192fe
commit
25fca14e62
|
@ -47,6 +47,7 @@ public class SIPSender {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException {
|
public void transmitRequest(String ip, Message message, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws SipException, ParseException {
|
||||||
|
try {
|
||||||
ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME);
|
ViaHeader viaHeader = (ViaHeader)message.getHeader(ViaHeader.NAME);
|
||||||
String transport = "UDP";
|
String transport = "UDP";
|
||||||
if (viaHeader == null) {
|
if (viaHeader == null) {
|
||||||
|
@ -103,6 +104,9 @@ public class SIPSender {
|
||||||
sipProvider.sendResponse((Response)message);
|
sipProvider.sendResponse((Response)message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
logger.info("[SEND]:SUCCESS:{}", message);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CallIdHeader getNewCallIdHeader(String ip, String transport){
|
public CallIdHeader getNewCallIdHeader(String ip, String transport){
|
||||||
|
|
|
@ -183,7 +183,7 @@ public interface ISIPCommander {
|
||||||
* @param channelId 预览通道
|
* @param channelId 预览通道
|
||||||
* @param recordCmdStr 录像命令:Record / StopRecord
|
* @param recordCmdStr 录像命令:Record / StopRecord
|
||||||
*/
|
*/
|
||||||
void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 远程启动控制命令
|
* 远程启动控制命令
|
||||||
|
@ -197,7 +197,7 @@ public interface ISIPCommander {
|
||||||
*
|
*
|
||||||
* @param device 视频设备
|
* @param device 视频设备
|
||||||
*/
|
*/
|
||||||
void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 报警复位命令
|
* 报警复位命令
|
||||||
|
@ -206,7 +206,7 @@ public interface ISIPCommander {
|
||||||
* @param alarmMethod 报警方式(可选)
|
* @param alarmMethod 报警方式(可选)
|
||||||
* @param alarmType 报警类型(可选)
|
* @param alarmType 报警类型(可选)
|
||||||
*/
|
*/
|
||||||
void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException;
|
void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧
|
* 强制关键帧命令,设备收到此命令应立刻发送一个IDR帧
|
||||||
|
|
|
@ -664,7 +664,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param recordCmdStr 录像命令:Record / StopRecord
|
* @param recordCmdStr 录像命令:Record / StopRecord
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void recordCmd(Device device, String channelId, String recordCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
cmdXml.append("<?xml version=\"1.0\" encoding=\"" + charset + "\"?>\r\n");
|
||||||
|
@ -682,7 +682,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
||||||
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -716,7 +716,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param guardCmdStr "SetGuard"/"ResetGuard"
|
* @param guardCmdStr "SetGuard"/"ResetGuard"
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void guardCmd(Device device, String guardCmdStr, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
|
@ -729,7 +729,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
cmdXml.append("</Control>\r\n");
|
cmdXml.append("</Control>\r\n");
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
||||||
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -738,7 +738,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
* @param device 视频设备
|
* @param device 视频设备
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent) throws InvalidArgumentException, SipException, ParseException {
|
public void alarmCmd(Device device, String alarmMethod, String alarmType, SipSubscribe.Event errorEvent, SipSubscribe.Event okEvent) throws InvalidArgumentException, SipException, ParseException {
|
||||||
|
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
String charset = device.getCharset();
|
String charset = device.getCharset();
|
||||||
|
@ -765,7 +765,7 @@ public class SIPCommander implements ISIPCommander {
|
||||||
|
|
||||||
|
|
||||||
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
Request request = headerProvider.createMessageRequest(device, cmdXml.toString(), null, SipUtils.getNewFromTag(), null,sipSender.getNewCallIdHeader(sipLayer.getLocalIp(device.getLocalIp()),device.getTransport()));
|
||||||
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent);
|
sipSender.transmitRequest(sipLayer.getLocalIp(device.getLocalIp()), request, errorEvent,okEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -131,16 +131,16 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
handleRecordCmd(deviceForPlatform,channelId,rootElement,request,DeviceControlType.RECORD);
|
handleRecordCmd(deviceForPlatform,channelId,rootElement,request,DeviceControlType.RECORD);
|
||||||
break;
|
break;
|
||||||
case I_FRAME:
|
case I_FRAME:
|
||||||
handleIFameCmd(deviceForPlatform,channelId);
|
handleIFameCmd(deviceForPlatform,request,channelId);
|
||||||
break;
|
break;
|
||||||
case TELE_BOOT:
|
case TELE_BOOT:
|
||||||
handleTeleBootCmd(deviceForPlatform);
|
handleTeleBootCmd(deviceForPlatform,request);
|
||||||
break;
|
break;
|
||||||
case DRAG_ZOOM_IN:
|
case DRAG_ZOOM_IN:
|
||||||
handleDragZoom(deviceForPlatform,channelId,rootElement,DeviceControlType.DRAG_ZOOM_IN);
|
handleDragZoom(deviceForPlatform,channelId,rootElement,request,DeviceControlType.DRAG_ZOOM_IN);
|
||||||
break;
|
break;
|
||||||
case DRAG_ZOOM_OUT:
|
case DRAG_ZOOM_OUT:
|
||||||
handleDragZoom(deviceForPlatform,channelId,rootElement,DeviceControlType.DRAG_ZOOM_OUT);
|
handleDragZoom(deviceForPlatform,channelId,rootElement,request,DeviceControlType.DRAG_ZOOM_OUT);
|
||||||
break;
|
break;
|
||||||
case HOME_POSITION:
|
case HOME_POSITION:
|
||||||
handleHomePositionCmd(deviceForPlatform,channelId,rootElement,request,DeviceControlType.HOME_POSITION);
|
handleHomePositionCmd(deviceForPlatform,channelId,rootElement,request,DeviceControlType.HOME_POSITION);
|
||||||
|
@ -167,7 +167,6 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 云台/前端: {}", e.getMessage());
|
logger.error("[命令发送失败] 云台/前端: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,9 +174,10 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
* @param device 设备
|
* @param device 设备
|
||||||
* @param channelId 通道id
|
* @param channelId 通道id
|
||||||
*/
|
*/
|
||||||
private void handleIFameCmd(Device device,String channelId){
|
private void handleIFameCmd(Device device,SIPRequest request,String channelId){
|
||||||
try {
|
try {
|
||||||
cmder.iFrameCmd(device,channelId);
|
cmder.iFrameCmd(device,channelId);
|
||||||
|
responseAck(request, Response.OK);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage());
|
logger.error("[命令发送失败] 强制关键帧: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -187,9 +187,10 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
* 处理重启命令
|
* 处理重启命令
|
||||||
* @param device 设备信息
|
* @param device 设备信息
|
||||||
*/
|
*/
|
||||||
private void handleTeleBootCmd(Device device){
|
private void handleTeleBootCmd(Device device,SIPRequest request){
|
||||||
try {
|
try {
|
||||||
cmder.teleBootCmd(device);
|
cmder.teleBootCmd(device);
|
||||||
|
responseAck(request, Response.OK);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 重启: {}", e.getMessage());
|
logger.error("[命令发送失败] 重启: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -203,7 +204,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
* @param rootElement 根节点
|
* @param rootElement 根节点
|
||||||
* @param type 消息类型
|
* @param type 消息类型
|
||||||
*/
|
*/
|
||||||
private void handleDragZoom(Device device,String channelId,Element rootElement,DeviceControlType type){
|
private void handleDragZoom(Device device,String channelId,Element rootElement,SIPRequest request,DeviceControlType type){
|
||||||
String cmdString = getText(rootElement,type.getVal());
|
String cmdString = getText(rootElement,type.getVal());
|
||||||
StringBuffer cmdXml = new StringBuffer(200);
|
StringBuffer cmdXml = new StringBuffer(200);
|
||||||
cmdXml.append("<" + type.getVal() + ">\r\n");
|
cmdXml.append("<" + type.getVal() + ">\r\n");
|
||||||
|
@ -211,6 +212,7 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
cmdXml.append("</" + type.getVal() + ">\r\n");
|
cmdXml.append("</" + type.getVal() + ">\r\n");
|
||||||
try {
|
try {
|
||||||
cmder.dragZoomCmd(device,channelId,cmdXml.toString());
|
cmder.dragZoomCmd(device,channelId,cmdXml.toString());
|
||||||
|
responseAck(request, Response.OK);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 拉框控制: {}", e.getMessage());
|
logger.error("[命令发送失败] 拉框控制: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -255,7 +257,8 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
cmder.alarmCmd(device, alarmMethod,alarmType,
|
cmder.alarmCmd(device, alarmMethod,alarmType,
|
||||||
errorResult -> onError(request,errorResult));
|
errorResult -> onError(request,errorResult),
|
||||||
|
okResult -> onOk(request,okResult));
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 告警消息: {}", e.getMessage());
|
logger.error("[命令发送失败] 告警消息: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -274,7 +277,8 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
String cmdString = getText(rootElement,type.getVal());
|
String cmdString = getText(rootElement,type.getVal());
|
||||||
try {
|
try {
|
||||||
cmder.recordCmd(device, channelId,cmdString,
|
cmder.recordCmd(device, channelId,cmdString,
|
||||||
errorResult -> onError(request,errorResult));
|
errorResult -> onError(request,errorResult),
|
||||||
|
okResult -> onOk(request,okResult));
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 录像控制: {}", e.getMessage());
|
logger.error("[命令发送失败] 录像控制: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -292,7 +296,8 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
String cmdString = getText(rootElement,type.getVal());
|
String cmdString = getText(rootElement,type.getVal());
|
||||||
try {
|
try {
|
||||||
cmder.guardCmd(device, cmdString,
|
cmder.guardCmd(device, cmdString,
|
||||||
errorResult -> onError(request,errorResult));
|
errorResult -> onError(request,errorResult),
|
||||||
|
okResult -> onOk(request,okResult));
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage());
|
logger.error("[命令发送失败] 布防/撤防命令: {}", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,7 +110,7 @@ public class DeviceControl {
|
||||||
msg.setKey(key);
|
msg.setKey(key);
|
||||||
msg.setData(String.format("开始/停止录像操作失败,错误码: %s, %s", event.statusCode, event.msg));
|
msg.setData(String.format("开始/停止录像操作失败,错误码: %s, %s", event.statusCode, event.msg));
|
||||||
resultHolder.invokeAllResult(msg);
|
resultHolder.invokeAllResult(msg);
|
||||||
});
|
},null);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 开始/停止录像: {}", e.getMessage());
|
logger.error("[命令发送失败] 开始/停止录像: {}", e.getMessage());
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||||
|
@ -143,7 +143,7 @@ public class DeviceControl {
|
||||||
msg.setKey(key);
|
msg.setKey(key);
|
||||||
msg.setData(String.format("布防/撤防操作失败,错误码: %s, %s", event.statusCode, event.msg));
|
msg.setData(String.format("布防/撤防操作失败,错误码: %s, %s", event.statusCode, event.msg));
|
||||||
resultHolder.invokeResult(msg);
|
resultHolder.invokeResult(msg);
|
||||||
});
|
},null);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
|
logger.error("[命令发送失败] 布防/撤防操作: {}", e.getMessage());
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送: " + e.getMessage());
|
||||||
|
@ -192,7 +192,7 @@ public class DeviceControl {
|
||||||
msg.setKey(key);
|
msg.setKey(key);
|
||||||
msg.setData(String.format("报警复位操作失败,错误码: %s, %s", event.statusCode, event.msg));
|
msg.setData(String.format("报警复位操作失败,错误码: %s, %s", event.statusCode, event.msg));
|
||||||
resultHolder.invokeResult(msg);
|
resultHolder.invokeResult(msg);
|
||||||
});
|
},null);
|
||||||
} catch (InvalidArgumentException | SipException | ParseException e) {
|
} catch (InvalidArgumentException | SipException | ParseException e) {
|
||||||
logger.error("[命令发送失败] 报警复位: {}", e.getMessage());
|
logger.error("[命令发送失败] 报警复位: {}", e.getMessage());
|
||||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage());
|
||||||
|
|
Loading…
Reference in New Issue