| | |
| | | package com.genersoft.iot.vmp.web.gb28181; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.genersoft.iot.vmp.conf.exception.ControllerException; |
| | | import com.genersoft.iot.vmp.gb28181.bean.Device; |
| | | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.sip.InvalidArgumentException; |
| | | import javax.sip.SipException; |
| | | import java.text.ParseException; |
| | | |
| | | /** |
| | | * API兼容:设备控制 |
| | |
| | | * @return |
| | | */ |
| | | @RequestMapping(value = "/ptz") |
| | | private JSONObject list(String serial,String command, |
| | | private void list(String serial,String command, |
| | | @RequestParam(required = false)Integer channel, |
| | | @RequestParam(required = false)String code, |
| | | @RequestParam(required = false)Integer speed){ |
| | |
| | | if (speed == null) {speed = 0;} |
| | | Device device = storager.queryVideoDevice(serial); |
| | | if (device == null) { |
| | | JSONObject result = new JSONObject(); |
| | | result.put("error","device[ " + serial + " ]未找到"); |
| | | return result; |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "device[ " + serial + " ]未找到"); |
| | | } |
| | | int cmdCode = 0; |
| | | switch (command){ |
| | |
| | | break; |
| | | } |
| | | // 默认值 50 |
| | | cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed); |
| | | return null; |
| | | try { |
| | | cmder.frontEndCmd(device, code, cmdCode, speed, speed, speed); |
| | | } catch (SipException | InvalidArgumentException | ParseException e) { |
| | | logger.error("[命令发送失败] 云台控制: {}", e.getMessage()); |
| | | throw new ControllerException(ErrorCode.ERROR100.getCode(), "命令发送失败: " + e.getMessage()); |
| | | } |
| | | } |
| | | } |