diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java index 30720b36..6924b0f7 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/controller/DeviceQuery.java @@ -15,7 +15,7 @@ import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; -import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; @@ -63,7 +63,7 @@ public class DeviceQuery { private IInviteStreamService inviteStreamService; @Autowired - private SIPCommander cmder; + private ISIPCommander cmder; @Autowired private DeferredResultHolder resultHolder; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java index d2135a49..16e9d395 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.event; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent; -import com.genersoft.iot.vmp.gb28181.event.device.RequestTimeoutEvent; import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.mobilePosition.MobilePositionEvent; @@ -13,7 +12,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Component; -import javax.sip.TimeoutEvent; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -53,12 +51,6 @@ public class EventPublisher { } - public void requestTimeOut(TimeoutEvent timeoutEvent) { - RequestTimeoutEvent requestTimeoutEvent = new RequestTimeoutEvent(this); - requestTimeoutEvent.setTimeoutEvent(timeoutEvent); - applicationEventPublisher.publishEvent(requestTimeoutEvent); - } - public void catalogEventPublish(Platform platform, CommonGBChannel deviceChannel, String type) { List deviceChannelList = new ArrayList<>(); deviceChannelList.add(deviceChannel); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java deleted file mode 100755 index c4d3baba..00000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEvent.java +++ /dev/null @@ -1,25 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.device; - -import org.springframework.context.ApplicationEvent; - -import javax.sip.TimeoutEvent; - -/** - * @author lin - */ -public class RequestTimeoutEvent extends ApplicationEvent { - public RequestTimeoutEvent(Object source) { - super(source); - } - - - private TimeoutEvent timeoutEvent; - - public TimeoutEvent getTimeoutEvent() { - return timeoutEvent; - } - - public void setTimeoutEvent(TimeoutEvent timeoutEvent) { - this.timeoutEvent = timeoutEvent; - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java deleted file mode 100755 index 5f83e6e9..00000000 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/device/RequestTimeoutEventImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.genersoft.iot.vmp.gb28181.event.device; - -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.service.IDeviceService; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.ApplicationListener; -import org.springframework.stereotype.Component; - -import javax.sip.ClientTransaction; -import javax.sip.address.SipURI; -import javax.sip.message.Request; - -/** - * @author lin - */ -@Component -public class RequestTimeoutEventImpl implements ApplicationListener { - - @Autowired - private IDeviceService deviceService; - - @Override - public void onApplicationEvent(RequestTimeoutEvent event) { - ClientTransaction clientTransaction = event.getTimeoutEvent().getClientTransaction(); - if (clientTransaction != null) { - Request request = clientTransaction.getRequest(); - if (request != null) { - String host = ((SipURI) request.getRequestURI()).getHost(); - int port = ((SipURI) request.getRequestURI()).getPort(); - Device device = deviceService.getDeviceByHostAndPort(host, port); - if (device == null) { - return; - } - deviceService.offline(device.getDeviceId(), "等待消息超时"); - } - - } - } -} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java index 417e273f..19028c10 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceServiceImpl.java @@ -190,13 +190,13 @@ public class DeviceServiceImpl implements IDeviceService { @Override public void offline(String deviceId, String reason) { - log.warn("[设备离线],{}, device:{}", reason, deviceId); Device device = getDeviceByDeviceIdFromDb(deviceId); if (device == null) { log.warn("[设备不存在] device:{}", deviceId); return; } - log.info("[设备离线] device:{}, 心跳间隔: {},心跳超时次数: {}, 上次心跳时间:{}, 上次注册时间: {}", deviceId, + // TODO 主动查询设备状态 + log.info("[设备离线] {}, device:{}, 心跳间隔: {},心跳超时次数: {}, 上次心跳时间:{}, 上次注册时间: {}", reason, deviceId, device.getHeartBeatInterval(), device.getHeartBeatCount(), device.getKeepaliveTime(), device.getRegisterTime()); String registerExpireTaskKey = VideoManagerConstants.REGISTER_EXPIRE_TASK_KEY_PREFIX + deviceId; dynamicTask.stop(registerExpireTaskKey); @@ -407,7 +407,6 @@ public class DeviceServiceImpl implements IDeviceService { } catch (InvalidArgumentException | SipException | ParseException e) { log.error("[命令发送失败] 设备状态查询: {}", e.getMessage()); } - } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java index b21dba9c..60c63932 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommander.java @@ -23,45 +23,6 @@ import java.text.ParseException; */ public interface ISIPCommander { - /** - * 云台方向放控制,使用配置文件中的默认镜头移动速度 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - */ - void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown) throws InvalidArgumentException, ParseException, SipException; - - /** - * 云台方向放控制 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param leftRight 镜头左移右移 0:停止 1:左移 2:右移 - * @param upDown 镜头上移下移 0:停止 1:上移 2:下移 - * @param moveSpeed 镜头移动速度 - */ - void ptzdirectCmd(Device device,String channelId,int leftRight, int upDown, int moveSpeed) throws InvalidArgumentException, ParseException, SipException; - - /** - * 云台缩放控制,使用配置文件中的默认镜头缩放速度 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - */ - void ptzZoomCmd(Device device,String channelId,int inOut) throws InvalidArgumentException, ParseException, SipException; - - /** - * 云台缩放控制 - * - * @param device 控制设备 - * @param channelId 预览通道 - * @param inOut 镜头放大缩小 0:停止 1:缩小 2:放大 - */ - void ptzZoomCmd(Device device,String channelId,int inOut, int moveSpeed) throws InvalidArgumentException, ParseException, SipException; - /** * 云台控制,支持方向与缩放控制 * @@ -323,7 +284,6 @@ public interface ISIPCommander { * @param expires 订阅过期时间(0 = 取消订阅) * @param startPriority 报警起始级别(可选) * @param endPriority 报警终止级别(可选) - * @param alarmType 报警类型 * @param startTime 报警发生起始时间(可选) * @param endTime 报警发生终止时间(可选) * @return true = 命令发送成功