[国标级联] 增加通用通道云台控制和预置位处理接口
parent
c0d043ecd9
commit
8a71208035
|
@ -1,8 +1,5 @@
|
||||||
package com.genersoft.iot.vmp.common.enums;
|
package com.genersoft.iot.vmp.common.enums;
|
||||||
|
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支持的通道数据类型
|
* 支持的通道数据类型
|
||||||
*/
|
*/
|
||||||
|
@ -11,7 +8,8 @@ public enum ChannelDataType {
|
||||||
|
|
||||||
GB28181(1,"国标28181"),
|
GB28181(1,"国标28181"),
|
||||||
STREAM_PUSH(2,"推流设备"),
|
STREAM_PUSH(2,"推流设备"),
|
||||||
STREAM_PROXY(3,"拉流代理");
|
STREAM_PROXY(3,"拉流代理"),
|
||||||
|
ONVIF(100,"ONVIF");
|
||||||
|
|
||||||
public final int value;
|
public final int value;
|
||||||
|
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
|
@ -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());
|
||||||
|
}
|
||||||
|
}
|
|
@ -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.event.SipSubscribe;
|
||||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
||||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
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.service.IGbChannelService;
|
||||||
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.event.request.SIPRequestProcessorParent;
|
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||||
|
@ -42,6 +43,9 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
@Autowired
|
@Autowired
|
||||||
private IGbChannelService channelService;
|
private IGbChannelService channelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private IGbChannelControlService channelControlService;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private IDeviceService deviceService;
|
private IDeviceService deviceService;
|
||||||
|
|
||||||
|
@ -144,12 +148,51 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent
|
||||||
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
|
log.error("[命令发送失败] 云台指令: {}", exception.getMessage());
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
// }else if (false){
|
|
||||||
// // 国标
|
|
||||||
// // 解析云台控制参数
|
|
||||||
// String cmdString = getText(rootElement, type.getVal());
|
|
||||||
// FrontEndCode.decode(cmdString);
|
|
||||||
}else {
|
}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());
|
log.warn("[INFO 消息] 只支持国标的云台控制, 通道ID: {}", channel.getGbId());
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue