[国标PTZ] 添加调用其他wvp的云台控制
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user