移除多余接口

This commit is contained in:
lin
2025-09-24 16:36:33 +08:00
parent c0ef35c3a0
commit 554a11ead6
3 changed files with 0 additions and 939 deletions

View File

@@ -9,7 +9,6 @@ import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToGroupByGbDevicePar
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToGroupParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionByGbDeviceParam;
import com.genersoft.iot.vmp.gb28181.controller.bean.ChannelToRegionParam;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelFrontEndService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
@@ -53,9 +52,6 @@ public class ChannelController {
@Autowired
private IGbChannelPlayService channelPlayService;
@Autowired
private IGbChannelFrontEndService channelFrontEndService;
@Autowired
private UserSetting userSetting;
@@ -465,355 +461,6 @@ public class ChannelController {
channelPlayService.playbackSpeed(channel, stream, speed);
}
@Operation(summary = "云台控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "command", description = "控制指令,允许值: left, right, up, down, upleft, upright, downleft, downright, zoomin, zoomout, stop", required = true)
@Parameter(name = "horizonSpeed", description = "水平速度(0-255)", required = true)
@Parameter(name = "verticalSpeed", description = "垂直速度(0-255)", required = true)
@Parameter(name = "zoomSpeed", description = "缩放速度(0-15)", required = true)
@GetMapping("/ptz")
public void ptz(Integer channelId, String command, Integer horizonSpeed, Integer verticalSpeed, Integer zoomSpeed){
if (log.isDebugEnabled()) {
log.debug(String.format("设备云台控制 API调用channelId%s command%s horizonSpeed%d verticalSpeed%d zoomSpeed%d",channelId, command, horizonSpeed, verticalSpeed, zoomSpeed));
}
if (horizonSpeed == null) {
horizonSpeed = 100;
}else if (horizonSpeed < 0 || horizonSpeed > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "horizonSpeed 为 0-255的数字");
}
if (verticalSpeed == null) {
verticalSpeed = 100;
}else if (verticalSpeed < 0 || verticalSpeed > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "verticalSpeed 为 0-255的数字");
}
if (zoomSpeed == null) {
zoomSpeed = 16;
}else if (zoomSpeed < 0 || zoomSpeed > 15) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "zoomSpeed 为 0-15的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.ptz(channel, command, horizonSpeed, verticalSpeed, zoomSpeed);
}
@Operation(summary = "光圈控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "command", description = "控制指令,允许值: in, out, stop", required = true)
@Parameter(name = "speed", description = "光圈速度(0-255)", required = true)
@GetMapping("/fi/iris")
public void iris(Integer channelId, String command, Integer speed){
if (log.isDebugEnabled()) {
log.debug("设备光圈控制 API调用channelId{} command{} speed{} ",channelId, command, speed);
}
if (speed == null) {
speed = 100;
}else if (speed < 0 || speed > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "speed 为 0-255的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.iris(channel, command, speed);
}
@Operation(summary = "聚焦控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "command", description = "控制指令,允许值: near, far, stop", required = true)
@Parameter(name = "speed", description = "聚焦速度(0-255)", required = true)
@GetMapping("/fi/focus")
public void focus(Integer channelId, String command, Integer speed){
if (log.isDebugEnabled()) {
log.debug("设备聚焦控制 API调用channelId{} command{} speed{} ",channelId, command, speed);
}
if (speed == null) {
speed = 100;
}else if (speed < 0 || speed > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "speed 为 0-255的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.focus(channel, command, speed);
}
@Operation(summary = "查询预置位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@GetMapping("/preset/query")
public DeferredResult<WVPResult<Object>> queryPreset(Integer channelId) {
if (log.isDebugEnabled()) {
log.debug("设备预置位查询API调用");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
DeferredResult<WVPResult<Object>> deferredResult = new DeferredResult<> (3 * 1000L);
channelFrontEndService.queryPreset(channel, (code, msg, data) -> {
deferredResult.setResult(new WVPResult<>(code, msg, data));
});
deferredResult.onTimeout(()->{
log.warn("[获取设备预置位] 超时, {}", channelId);
deferredResult.setResult(WVPResult.fail(ErrorCode.ERROR100.getCode(), "超时"));
});
return deferredResult;
}
@Operation(summary = "预置位指令-设置预置位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "presetId", description = "预置位编号(1-255)", required = true)
@GetMapping("/preset/add")
public void addPreset(Integer channelId, Integer presetId) {
if (presetId == null || presetId < 1 || presetId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "预置位编号必须为1-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.addPreset(channel, presetId);
}
@Operation(summary = "预置位指令-调用预置位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "presetId", description = "预置位编号(1-255)", required = true)
@GetMapping("/preset/call")
public void callPreset(Integer channelId, Integer presetId) {
if (presetId == null || presetId < 1 || presetId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "预置位编号必须为1-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.callPreset(channel, presetId);
}
@Operation(summary = "预置位指令-删除预置位", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "presetId", description = "预置位编号(1-255)", required = true)
@GetMapping("/preset/delete")
public void deletePreset(Integer channelId, Integer presetId) {
if (presetId == null || presetId < 1 || presetId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "预置位编号必须为1-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.deletePreset(channel, presetId);
}
@Operation(summary = "巡航指令-加入巡航点", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "cruiseId", description = "巡航组号(0-255)", required = true)
@Parameter(name = "presetId", description = "预置位编号(1-255)", required = true)
@GetMapping("/cruise/point/add")
public void addCruisePoint(Integer channelId, Integer cruiseId, Integer presetId) {
if (presetId == null || cruiseId == null || presetId < 1 || presetId > 255 || cruiseId < 0 || cruiseId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "编号必须为1-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.addCruisePoint(channel, cruiseId, presetId);
}
@Operation(summary = "巡航指令-删除一个巡航点", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "cruiseId", description = "巡航组号(1-255)", required = true)
@Parameter(name = "presetId", description = "预置位编号(0-255, 为0时删除整个巡航)", required = true)
@GetMapping("/cruise/point/delete")
public void deleteCruisePoint(Integer channelId, Integer cruiseId, Integer presetId) {
if (presetId == null || presetId < 0 || presetId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "预置位编号必须为0-255之间的数字, 为0时删除整个巡航");
}
if (cruiseId == null || cruiseId < 0 || cruiseId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "巡航组号必须为0-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.deleteCruisePoint(channel, cruiseId, presetId);
}
@Operation(summary = "巡航指令-设置巡航速度", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "cruiseId", description = "巡航组号(0-255)", required = true)
@Parameter(name = "speed", description = "巡航速度(1-4095)", required = true)
@GetMapping("/cruise/speed")
public void setCruiseSpeed(Integer channelId, Integer cruiseId, Integer speed) {
if (cruiseId == null || cruiseId < 0 || cruiseId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "巡航组号必须为0-255之间的数字");
}
if (speed == null || speed < 1 || speed > 4095) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "巡航速度必须为1-4095之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.setCruiseSpeed(channel, cruiseId, speed);
}
@Operation(summary = "巡航指令-设置巡航停留时间", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "cruiseId", description = "巡航组号", required = true)
@Parameter(name = "time", description = "巡航停留时间(1-4095)", required = true)
@GetMapping("/cruise/time")
public void setCruiseTime(Integer channelId, Integer cruiseId, Integer time) {
if (cruiseId == null || cruiseId < 0 || cruiseId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "巡航组号必须为0-255之间的数字");
}
if (time == null || time < 1 || time > 4095) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "巡航停留时间必须为1-4095之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.setCruiseTime(channel, cruiseId, time);
}
@Operation(summary = "巡航指令-开始巡航", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "cruiseId", description = "巡航组号)", required = true)
@GetMapping("/cruise/start")
public void startCruise(Integer channelId, Integer cruiseId) {
if (cruiseId == null || cruiseId < 0 || cruiseId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "巡航组号必须为0-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.startCruise(channel, cruiseId);
}
@Operation(summary = "巡航指令-停止巡航", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "cruiseId", description = "巡航组号", required = true)
@GetMapping("/cruise/stop")
public void stopCruise(Integer channelId, Integer cruiseId) {
if (cruiseId == null || cruiseId < 0 || cruiseId > 255) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "巡航组号必须为0-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.stopCruise(channel, cruiseId);
}
@Operation(summary = "扫描指令-开始自动扫描", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-255)", required = true)
@GetMapping("/scan/start")
public void startScan(Integer channelId, Integer scanId) {
if (scanId == null || scanId < 0 || scanId > 255 ) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "扫描组号必须为0-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.startScan(channel, scanId);
}
@Operation(summary = "扫描指令-停止自动扫描", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-255)", required = true)
@GetMapping("/scan/stop")
public void stopScan(Integer channelId, Integer scanId) {
if (scanId == null || scanId < 0 || scanId > 255 ) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "扫描组号必须为0-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.stopScan(channel, scanId);
}
@Operation(summary = "扫描指令-设置自动扫描左边界", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-255)", required = true)
@GetMapping("/scan/set/left")
public void setScanLeft(Integer channelId, Integer scanId) {
if (scanId == null || scanId < 0 || scanId > 255 ) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "扫描组号必须为0-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.setScanLeft(channel, scanId);
}
@Operation(summary = "扫描指令-设置自动扫描右边界", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-255)", required = true)
@GetMapping("/scan/set/right")
public void setScanRight(Integer channelId, Integer scanId) {
if (scanId == null || scanId < 0 || scanId > 255 ) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "扫描组号必须为0-255之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.setScanRight(channel, scanId);
}
@Operation(summary = "扫描指令-设置自动扫描速度", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "scanId", description = "扫描组号(0-255)", required = true)
@Parameter(name = "speed", description = "自动扫描速度(1-4095)", required = true)
@GetMapping("/scan/set/speed")
public void setScanSpeed(Integer channelId, Integer scanId, Integer speed) {
if (scanId == null || scanId < 0 || scanId > 255 ) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "扫描组号必须为0-255之间的数字");
}
if (speed == null || speed < 1 || speed > 4095) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "自动扫描速度必须为1-4095之间的数字");
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.setScanSpeed(channel, scanId, speed);
}
@Operation(summary = "辅助开关控制指令-雨刷控制", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "command", description = "控制指令,允许值: on, off", required = true)
@GetMapping("/wiper")
public void wiper(Integer channelId, String command){
if (log.isDebugEnabled()) {
log.debug("辅助开关控制指令-雨刷控制 API调用channelId{} command{}",channelId, command);
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.wiper(channel, command);
}
@Operation(summary = "辅助开关控制指令", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "channelId", description = "通道ID", required = true)
@Parameter(name = "command", description = "控制指令,允许值: on, off", required = true)
@Parameter(name = "switchId", description = "开关编号", required = true)
@GetMapping("/auxiliary")
public void auxiliarySwitch(Integer channelId, String command, Integer switchId){
if (log.isDebugEnabled()) {
log.debug("辅助开关控制指令-雨刷控制 API调用channelId{} command{}, switchId: {}", channelId, command, switchId);
}
CommonGBChannel channel = channelService.getOne(channelId);
Assert.notNull(channel, "通道不存在");
channelFrontEndService.auxiliarySwitch(channel, command, switchId);
}
@Operation(summary = "为地图获取通道列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "query", description = "查询内容")
@Parameter(name = "online", description = "是否在线")

View File

@@ -1,52 +0,0 @@
package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Preset;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import java.util.List;
public interface IGbChannelFrontEndService {
void ptz(CommonGBChannel channel, String command, Integer horizonSpeed, Integer verticalSpeed, Integer zoomSpeed);
void iris(CommonGBChannel channel, String command, Integer speed);
void focus(CommonGBChannel channel, String command, Integer speed);
void queryPreset(CommonGBChannel channel, ErrorCallback<List<Preset>> callback);
void addPreset(CommonGBChannel channel, Integer presetId);
void callPreset(CommonGBChannel channel, Integer presetId);
void deletePreset(CommonGBChannel channel, Integer presetId);
void addCruisePoint(CommonGBChannel channel, Integer cruiseId, Integer presetId);
void deleteCruisePoint(CommonGBChannel channel, Integer cruiseId, Integer presetId);
void setCruiseSpeed(CommonGBChannel channel, Integer cruiseId, Integer speed);
void setCruiseTime(CommonGBChannel channel, Integer cruiseId, Integer time);
void startCruise(CommonGBChannel channel, Integer cruiseId);
void stopCruise(CommonGBChannel channel, Integer cruiseId);
void startScan(CommonGBChannel channel, Integer scanId);
void stopScan(CommonGBChannel channel, Integer scanId);
void setScanLeft(CommonGBChannel channel, Integer scanId);
void setScanRight(CommonGBChannel channel, Integer scanId);
void setScanSpeed(CommonGBChannel channel, Integer scanId, Integer speed);
void wiper(CommonGBChannel channel, String command);
void auxiliarySwitch(CommonGBChannel channel, String command, Integer switchId);
}

View File

@@ -1,534 +0,0 @@
package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService;
import com.genersoft.iot.vmp.gb28181.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelFrontEndService;
import com.genersoft.iot.vmp.gb28181.service.IPTZService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.sip.message.Response;
import java.util.List;
@Slf4j
@Service
public class GbChannelFrontEndServiceImpl implements IGbChannelFrontEndService {
@Autowired
private IPTZService ptzService;
@Autowired
private IDeviceService deviceService;
@Autowired
private IDeviceChannelService deviceChannelService;
private void frontEndCommand(CommonGBChannel channel, Integer cmdCode, Integer parameter1, Integer parameter2, Integer combindCode2){
Assert.isTrue(channel.getDataType() == ChannelDataType.GB28181, "类型获取错误");
Device device = deviceService.getDevice(channel.getDataDeviceId());
Assert.notNull(device, "设备不存在");
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId());
Assert.notNull(device, "原始通道不存在");
ptzService.frontEndCommand(device, deviceChannel.getDeviceId(), cmdCode, parameter1, parameter2, combindCode2);
}
@Override
public void ptz(CommonGBChannel channel, String command, Integer horizonSpeed, Integer verticalSpeed, Integer zoomSpeed) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
int cmdCode = 0;
switch (command){
case "left":
cmdCode = 2;
break;
case "right":
cmdCode = 1;
break;
case "up":
cmdCode = 8;
break;
case "down":
cmdCode = 4;
break;
case "upleft":
cmdCode = 10;
break;
case "upright":
cmdCode = 9;
break;
case "downleft":
cmdCode = 6;
break;
case "downright":
cmdCode = 5;
break;
case "zoomin":
cmdCode = 16;
break;
case "zoomout":
cmdCode = 32;
break;
case "stop":
horizonSpeed = 0;
verticalSpeed = 0;
zoomSpeed = 0;
break;
default:
break;
}
frontEndCommand(channel, cmdCode, horizonSpeed, verticalSpeed, zoomSpeed);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void iris(CommonGBChannel channel, String command, Integer speed) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
int cmdCode = 0x40;
switch (command){
case "in":
cmdCode = 0x44;
break;
case "out":
cmdCode = 0x48;
break;
case "stop":
speed = 0;
break;
default:
break;
}
frontEndCommand(channel, cmdCode, 0, speed, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void focus(CommonGBChannel channel, String command, Integer speed) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
int cmdCode = 0x40;
switch (command){
case "near":
cmdCode = 0x42;
break;
case "far":
cmdCode = 0x41;
break;
case "stop":
speed = 0;
break;
default:
break;
}
frontEndCommand(channel, cmdCode, speed, 0, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void queryPreset(CommonGBChannel channel, ErrorCallback<List<Preset>> callback) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
Device device = deviceService.getDevice(channel.getDataDeviceId());
Assert.notNull(device, "设备不存在");
DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId());
Assert.notNull(device, "原始通道不存在");
deviceService.queryPreset(device, deviceChannel.getDeviceId(), callback);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void addPreset(CommonGBChannel channel, Integer presetId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x81, 1, presetId, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void callPreset(CommonGBChannel channel, Integer presetId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x82, 1, presetId, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void deletePreset(CommonGBChannel channel, Integer presetId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x83, 1, presetId, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void addCruisePoint(CommonGBChannel channel, Integer cruiseId, Integer presetId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x84, cruiseId, presetId, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void deleteCruisePoint(CommonGBChannel channel, Integer cruiseId, Integer presetId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x85, cruiseId, presetId, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void setCruiseSpeed(CommonGBChannel channel, Integer cruiseId, Integer speed) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
int parameter2 = speed & 0xFF;
int combindCode2 = speed >> 8;
frontEndCommand(channel, 0x86, cruiseId, parameter2, combindCode2);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void setCruiseTime(CommonGBChannel channel, Integer cruiseId, Integer time) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
int parameter2 = time & 0xFF;
int combindCode2 = time >> 8;
frontEndCommand(channel, 0x87, cruiseId, parameter2, combindCode2);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void startCruise(CommonGBChannel channel, Integer cruiseId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x88, cruiseId, 0, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void stopCruise(CommonGBChannel channel, Integer cruiseId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0, 0, 0, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void startScan(CommonGBChannel channel, Integer scanId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x89, scanId, 0, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void stopScan(CommonGBChannel channel, Integer scanId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0, 0, 0, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void setScanLeft(CommonGBChannel channel, Integer scanId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x89, scanId, 1, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void setScanRight(CommonGBChannel channel, Integer scanId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
frontEndCommand(channel, 0x89, scanId, 2, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void setScanSpeed(CommonGBChannel channel, Integer scanId, Integer speed) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
int parameter2 = speed & 0xFF;
int combindCode2 = speed >> 8;
frontEndCommand(channel, 0x8A, scanId, parameter2, combindCode2);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void wiper(CommonGBChannel channel, String command) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
int cmdCode = 0;
switch (command){
case "on":
cmdCode = 0x8c;
break;
case "off":
cmdCode = 0x8d;
break;
default:
break;
}
frontEndCommand(channel, cmdCode, 1, 0, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
@Override
public void auxiliarySwitch(CommonGBChannel channel, String command, Integer switchId) {
Assert.notNull(channel, "通道不存在");
if (channel.getDataType() == ChannelDataType.GB28181) {
// 国标通道
int cmdCode = 0;
switch (command){
case "on":
cmdCode = 0x8c;
break;
case "off":
cmdCode = 0x8d;
break;
default:
break;
}
frontEndCommand(channel, cmdCode, switchId, 0, 0);
} else if (channel.getDataType() == ChannelDataType.STREAM_PROXY) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else if (channel.getDataType() == ChannelDataType.STREAM_PUSH) {
// 拉流代理
throw new ControllerException(ErrorCode.ERROR100.getCode(), "不支持此操作");
} else {
// 通道数据异常
log.error("[通用通道] 通道数据异常,无法识别通道来源: {}({})", channel.getGbName(), channel.getGbDeviceId());
throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error");
}
}
}