[国标级联] 增加通用通道云台控制和预置位处理接口

2.7.3-20250312
lin 2025-03-06 16:01:05 +08:00
parent c0d043ecd9
commit 8a71208035
4 changed files with 85 additions and 9 deletions

View File

@ -1,8 +1,5 @@
package com.genersoft.iot.vmp.common.enums;
import lombok.Getter;
/**
*
*/
@ -11,7 +8,8 @@ public enum ChannelDataType {
GB28181(1,"国标28181"),
STREAM_PUSH(2,"推流设备"),
STREAM_PROXY(3,"拉流代理");
STREAM_PROXY(3,"拉流代理"),
ONVIF(100,"ONVIF");
public final int value;

View File

@ -0,0 +1,12 @@
package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.FrontEndControlCodeForPTZ;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
public interface IGbChannelControlService {
void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
void preset(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback);
}

View File

@ -0,0 +1,23 @@
package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.FrontEndControlCodeForPTZ;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelControlService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Service
@Slf4j
public class GbChannelControlServiceImpl implements IGbChannelControlService {
@Override
public void ptz(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] 云台控制, 通道: {}", channel.getGbId());
}
@Override
public void preset(CommonGBChannel channel, FrontEndControlCodeForPTZ frontEndControlCode, ErrorCallback<String> callback) {
log.info("[通用通道] 预置位, 通道: {}", channel.getGbId());
}
}

View File

@ -6,6 +6,7 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelControlService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
@ -42,6 +43,9 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
@Autowired
private IGbChannelService channelService;
@Autowired
private IGbChannelControlService channelControlService;
@Autowired
private IDeviceService deviceService;
@ -144,12 +148,51 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
}
}));
// }else if (false){
// // 国标
// // 解析云台控制参数
// String cmdString = getText(rootElement, type.getVal());
// FrontEndCode.decode(cmdString);
}else {
if (channel.getDataType() == ChannelDataType.ONVIF.value) { // 这里可以处理其他协议接入的设备
// 解析云台控制参数
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 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 {