dialog去除以及异常情况处理优化
This commit is contained in:
@@ -1,14 +1,20 @@
|
||||
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兼容:设备控制
|
||||
*/
|
||||
@@ -35,7 +41,7 @@ public class ApiControlController {
|
||||
* @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){
|
||||
@@ -48,9 +54,7 @@ public class ApiControlController {
|
||||
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){
|
||||
@@ -91,7 +95,11 @@ public class ApiControlController {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,12 @@ package com.genersoft.iot.vmp.web.gb28181;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.genersoft.iot.vmp.common.StreamInfo;
|
||||
import com.genersoft.iot.vmp.conf.UserSetting;
|
||||
import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Device;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||
import com.genersoft.iot.vmp.service.IDeviceService;
|
||||
import com.genersoft.iot.vmp.service.IPlayService;
|
||||
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
|
||||
@@ -17,6 +19,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import javax.sip.InvalidArgumentException;
|
||||
import javax.sip.SipException;
|
||||
import java.text.ParseException;
|
||||
|
||||
/**
|
||||
* API兼容:实时直播
|
||||
*/
|
||||
@@ -40,6 +46,9 @@ public class ApiStreamController {
|
||||
@Autowired
|
||||
private IRedisCatchStorage redisCatchStorage;
|
||||
|
||||
@Autowired
|
||||
private IDeviceService deviceService;
|
||||
|
||||
@Autowired
|
||||
private IPlayService playService;
|
||||
|
||||
@@ -177,7 +186,19 @@ public class ApiStreamController {
|
||||
result.put("error","未找到流信息");
|
||||
return result;
|
||||
}
|
||||
cmder.streamByeCmd(serial, code, streamInfo.getStream(), null);
|
||||
Device device = deviceService.queryDevice(serial);
|
||||
if (device == null) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("error","未找到设备");
|
||||
return result;
|
||||
}
|
||||
try {
|
||||
cmder.streamByeCmd(device, code, streamInfo.getStream(), null);
|
||||
} catch (InvalidArgumentException | ParseException | SipException | SsrcTransactionNotFoundException e) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("error","发送BYE失败:" + e.getMessage());
|
||||
return result;
|
||||
}
|
||||
redisCatchStorage.stopPlay(streamInfo);
|
||||
storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user