[国标PTZ] 添加调用其他wvp的云台控制
parent
115b41e001
commit
45337311ec
|
@ -1,6 +1,7 @@
|
|||
package com.genersoft.iot.vmp.gb28181.service;
|
||||
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Preset;
|
||||
|
||||
|
@ -18,4 +19,6 @@ public interface IPTZService {
|
|||
void ptz(Device device, String channelId, int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed);
|
||||
|
||||
void frontEndCommand(Device device, String channelId, int cmdCode, int parameter1, int parameter2, int combindCode2);
|
||||
|
||||
void frontEndCommand(CommonGBChannel channel, Integer cmdCode, Integer parameter1, Integer parameter2, Integer combindCode2);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package com.genersoft.iot.vmp.gb28181.service.impl;
|
||||
|
||||
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.ControllerException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Preset;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPTZService;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.IRedisRpcPlayService;
|
||||
|
@ -38,6 +41,9 @@ public class PTZServiceImpl implements IPTZService {
|
|||
@Autowired
|
||||
private IDeviceChannelService deviceChannelService;
|
||||
|
||||
@Autowired
|
||||
private IDeviceService deviceService;
|
||||
|
||||
|
||||
@Override
|
||||
public void ptz(Device device, String channelId, int cmdCode, int horizonSpeed, int verticalSpeed, int zoomSpeed) {
|
||||
|
@ -56,7 +62,10 @@ public class PTZServiceImpl implements IPTZService {
|
|||
// 通道ID
|
||||
DeviceChannel deviceChannel = deviceChannelService.getOneForSource(device.getDeviceId(), channelId);
|
||||
Assert.notNull(deviceChannel, "通道不存在");
|
||||
redisRpcPlayService.frontEndCommand(deviceChannel.getId(), cmdCode, parameter1, parameter2, combindCode2);
|
||||
String msg = redisRpcPlayService.frontEndCommand(device.getServerId(), deviceChannel.getId(), cmdCode, parameter1, parameter2, combindCode2);
|
||||
if (msg != null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), msg);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
@ -67,6 +76,21 @@ public class PTZServiceImpl implements IPTZService {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void frontEndCommand(CommonGBChannel channel, Integer cmdCode, Integer parameter1, Integer parameter2, Integer combindCode2) {
|
||||
if (channel.getDataType() != ChannelDataType.GB28181.value) {
|
||||
// 只有国标通道的支持云台控制
|
||||
log.warn("[INFO 消息] 只有国标通道的支持云台控制, 通道ID: {}", channel.getGbId());
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持");
|
||||
}
|
||||
Device device = deviceService.getDevice(channel.getDataDeviceId());
|
||||
if (device == null) {
|
||||
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到设备ID");
|
||||
}
|
||||
DeviceChannel deviceChannel = deviceChannelService.getOneById(channel.getGbId());
|
||||
frontEndCommand(device, deviceChannel.getDeviceId(), cmdCode, parameter1, parameter2, combindCode2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Preset> queryPresetList(String deviceId, String channelDeviceId) {
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -21,4 +21,7 @@ public interface IRedisRpcPlayService {
|
|||
void pauseRtp(String serverId, String streamId);
|
||||
|
||||
void resumeRtp(String serverId, String streamId);
|
||||
|
||||
String frontEndCommand(String serverId, Integer channelId, int cmdCode, int parameter1, int parameter2, int combindCode2);
|
||||
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
|||
import com.genersoft.iot.vmp.gb28181.bean.InviteMessageInfo;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
|
||||
import com.genersoft.iot.vmp.gb28181.service.IPTZService;
|
||||
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcController;
|
||||
import com.genersoft.iot.vmp.service.redisMsg.dto.RedisRpcMapping;
|
||||
|
@ -42,6 +43,9 @@ public class RedisRpcChannelPlayController extends RpcController {
|
|||
@Autowired
|
||||
private IGbChannelPlayService channelPlayService;
|
||||
|
||||
@Autowired
|
||||
private IPTZService iptzService;
|
||||
|
||||
private void sendResponse(RedisRpcResponse response){
|
||||
log.info("[redis-rpc] >> {}", response);
|
||||
response.setToId(userSetting.getServerId());
|
||||
|
@ -302,4 +306,41 @@ public class RedisRpcChannelPlayController extends RpcController {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 云台控制
|
||||
*/
|
||||
@RedisRpcMapping("ptz/frontEndCommand")
|
||||
public RedisRpcResponse frontEndCommand(RedisRpcRequest request) {
|
||||
JSONObject paramJson = JSONObject.parseObject(request.getParam().toString());
|
||||
int channelId = paramJson.getIntValue("channelId");
|
||||
int cmdCode = paramJson.getIntValue("cmdCode");
|
||||
int parameter1 = paramJson.getIntValue("parameter1");
|
||||
int parameter2 = paramJson.getIntValue("parameter2");
|
||||
int combindCode2 = paramJson.getIntValue("combindCode2");
|
||||
|
||||
RedisRpcResponse response = request.getResponse();
|
||||
|
||||
if (channelId <= 0 || cmdCode < 0 || parameter1 < 0 || parameter2 < 0 || combindCode2 < 0) {
|
||||
response.setStatusCode(ErrorCode.ERROR400.getCode());
|
||||
response.setBody("param error");
|
||||
return response;
|
||||
}
|
||||
// 获取对应的设备和通道信息
|
||||
CommonGBChannel channel = channelService.getOne(channelId);
|
||||
if (channel == null) {
|
||||
response.setStatusCode(ErrorCode.ERROR400.getCode());
|
||||
response.setBody("param error");
|
||||
return response;
|
||||
}
|
||||
try {
|
||||
iptzService.frontEndCommand(channel, cmdCode, parameter1, parameter2, combindCode2);
|
||||
}catch (ControllerException e) {
|
||||
response.setStatusCode(ErrorCode.ERROR100.getCode());
|
||||
response.setBody(e.getMessage());
|
||||
return response;
|
||||
}
|
||||
response.setStatusCode(ErrorCode.SUCCESS.getCode());
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -168,5 +168,26 @@ public class RedisRpcPlayServiceImpl implements IRedisRpcPlayService {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String frontEndCommand(String serverId, Integer channelId, int cmdCode, int parameter1, int parameter2, int combindCode2) {
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.put("channelId", channelId);
|
||||
jsonObject.put("cmdCode", cmdCode);
|
||||
jsonObject.put("parameter1", parameter1);
|
||||
jsonObject.put("parameter2", parameter2);
|
||||
jsonObject.put("combindCode2", combindCode2);
|
||||
RedisRpcRequest request = buildRequest("channel/ptz/frontEndCommand", jsonObject.toString());
|
||||
request.setToId(serverId);
|
||||
RedisRpcResponse response = redisRpcConfig.request(request, userSetting.getPlayTimeout(), TimeUnit.MILLISECONDS);
|
||||
if (response == null) {
|
||||
return ErrorCode.ERROR100.getMsg();
|
||||
}else {
|
||||
if (response.getStatusCode() != ErrorCode.SUCCESS.getCode()) {
|
||||
return response.getBody().toString();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue