[国标级联] 完善通用通道前端控制处理接口

2.7.3-20250312
lin 2025-03-06 16:30:42 +08:00
parent 60d2ed10ec
commit bc249b6786
4 changed files with 94 additions and 47 deletions

View File

@ -8,8 +8,7 @@ public enum ChannelDataType {
GB28181(1,"国标28181"),
STREAM_PUSH(2,"推流设备"),
STREAM_PROXY(3,"拉流代理"),
ONVIF(100,"ONVIF");
STREAM_PROXY(3,"拉流代理");
public final int value;

View File

@ -8,5 +8,9 @@ public interface IGbChannelControlService {
void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void fi(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void preset(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void tour(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void scan(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void auxiliary(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
}

View File

@ -20,4 +20,24 @@ public class GbChannelControlServiceImpl implements IGbChannelControlService {
public void preset(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] 预置位, 通道: {}", channel.getGbId());
}
@Override
public void fi(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] FI指令 通道: {}", channel.getGbId());
}
@Override
public void tour(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
}
@Override
public void scan(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
}
@Override
public void auxiliary(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
}
}

View File

@ -149,56 +149,80 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
}
}));
}else {
if (channel.getDataType() == ChannelDataType.ONVIF.value) { // 这里可以处理其他协议接入的设备
// 解析云台控制参数
String cmdString = getText(rootElement, type.getVal());
IFrontEndControlCode frontEndControlCode = FrontEndCode.decode(cmdString);
if (frontEndControlCode == null) {
log.info("[INFO 消息] 不支持的控制方式");
// 解析云台控制参数
String cmdString = getText(rootElement, type.getVal());
IFrontEndControlCode frontEndControlCode = FrontEndCode.decode(cmdString);
if (frontEndControlCode == null) {
log.info("[INFO 消息] 不支持的控制方式");
try {
responseAck(request, Response.FORBIDDEN, "");
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
return;
}
switch (frontEndControlCode.getType()){
case PTZ:
channelControlService.ptz(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
break;
case FI:
channelControlService.fi(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
break;
case PRESET:
channelControlService.preset(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
break;
case TOUR:
channelControlService.tour(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
break;
case SCAN:
channelControlService.scan(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
break;
case AUXILIARY:
channelControlService.auxiliary(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
break;
default:
log.info("[INFO 消息] 设备不支持的控制方式");
try {
responseAck(request, Response.FORBIDDEN, "");
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
return;
}
switch (frontEndControlCode.getType()){
case PTZ:
channelControlService.ptz(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
break;
case PRESET:
channelControlService.preset(channel, (FrontEndControlCodeForPTZ)frontEndControlCode, ((code, msg, data) -> {
try {
responseAck(request, code, msg);
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
break;
default:
log.info("[INFO 消息] 设备不支持的控制方式");
try {
responseAck(request, Response.FORBIDDEN, "");
} catch (InvalidArgumentException | SipException | ParseException exception) {
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}
return;
}
// 只支持国标的云台控制
log.warn("[INFO 消息] 只支持国标的云台控制, 通道ID {}", channel.getGbId());
try {
responseAck(request, Response.FORBIDDEN, "");
} catch (SipException | InvalidArgumentException | ParseException e) {
log.error("[命令发送失败] 错误信息: {}", e.getMessage());
}
}
}