diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java index 319220ea..666c4fa2 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java @@ -1639,7 +1639,8 @@ public class PlayServiceImpl implements IPlayService { log.warn("[点播] 未找到可用媒体节点"); throw new PlayException(Response.SERVER_INTERNAL_ERROR, "server internal error"); } - play(mediaServer, device.getDeviceId(), channel.getGbDeviceId(), null, callback); + DeviceChannel deviceChannel = deviceChannelService.getOneById(channel.getGbId()); + play(mediaServer, device, deviceChannel, null, callback); } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index 9cf74a54..ec0c3936 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -6,15 +6,14 @@ import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.service.IDeviceAlarmService; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; -import com.genersoft.iot.vmp.gb28181.service.IDeviceAlarmService; -import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; import lombok.extern.slf4j.Slf4j; @@ -56,9 +55,6 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme @Autowired private SipConfig sipConfig; - @Autowired - private IVideoManagerStorage storager; - @Autowired private IRedisCatchStorage redisCatchStorage; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java index b8ad279b..8c622676 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/BroadcastNotifyMessageHandler.java @@ -11,8 +11,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify. import com.genersoft.iot.vmp.media.bean.MediaServer; import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.service.ISendRtpServerService; -import com.genersoft.iot.vmp.storager.IRedisCatchStorage; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import gov.nist.javax.sip.message.SIPRequest; import lombok.extern.slf4j.Slf4j; import org.dom4j.Element; @@ -27,7 +25,7 @@ import javax.sip.message.Response; import java.text.ParseException; /** - * 状态信息(心跳)报送 + * 语音喊话请求 */ @Slf4j @Component @@ -38,9 +36,6 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp @Autowired private NotifyMessageHandler notifyMessageHandler; - @Autowired - private IVideoManagerStorage storage; - @Autowired private IGbChannelService channelService; @@ -65,9 +60,6 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp @Autowired private AudioBroadcastManager audioBroadcastManager; - @Autowired - private IRedisCatchStorage redisCatchStorage; - @Autowired private ISendRtpServerService sendRtpServerService; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java index 3d71ee93..df68b3d6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java @@ -86,7 +86,6 @@ public class MediaStatusNotifyMessageHandler extends SIPRequestProcessorParent i @Override public void handForDevice(RequestEvent evt, Device device, Element rootElement) { - // 回复200 OK try { responseAck((SIPRequest) evt.getRequest(), Response.OK); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java index 6db78e65..f71fc353 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java @@ -98,7 +98,6 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen continue; } - MobilePosition mobilePosition = new MobilePosition(); mobilePosition.setCreateTime(DateUtil.getNow()); if (!ObjectUtils.isEmpty(sipMsgInfo.getDevice().getName())) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java index ca8b4db1..d0d6f629 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/DeviceInfoQueryMessageHandler.java @@ -1,7 +1,11 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; +import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Platform; +import com.genersoft.iot.vmp.gb28181.service.IDeviceChannelService; +import com.genersoft.iot.vmp.gb28181.service.IDeviceService; +import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; @@ -34,9 +38,19 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp @Autowired private SIPCommanderFroPlatform cmderFroPlatform; + @Autowired private IVideoManagerStorage storager; + @Autowired + private IDeviceService deviceService; + + @Autowired + private IGbChannelService channelService; + + @Autowired + private IDeviceChannelService deviceChannelService; + @Override public void afterPropertiesSet() throws Exception { queryMessageHandler.addHandler(cmdType, this); @@ -50,14 +64,9 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp @Override public void handForPlatform(RequestEvent evt, Platform platform, Element rootElement) { log.info("[DeviceInfo查询]消息"); + SIPRequest request = (SIPRequest) evt.getRequest(); FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); - try { - // 回复200 OK - responseAck((SIPRequest) evt.getRequest(), Response.OK); - } catch (SipException | InvalidArgumentException | ParseException e) { - log.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); - return; - } + String sn = rootElement.element("SN").getText(); /*根据WVP原有的数据结构,设备和通道是分开放置,设备信息都是存放在设备表里,通道表里的设备信息不可作为真实信息处理 @@ -66,14 +75,60 @@ public class DeviceInfoQueryMessageHandler extends SIPRequestProcessorParent imp String channelId = getText(rootElement, "DeviceID"); // 查询这是通道id还是设备id - Device device = null; - // 如果id指向平台的国标编号,那么就是查询平台的信息 - if (!platform.getDeviceGBId().equals(channelId)) { - device = storager.queryDeviceInfoByPlatformIdAndChannelId(platform.getServerGBId(), channelId); - if (device ==null){ - log.error("[平台没有该通道的使用权限]:platformId"+platform.getServerGBId()+" deviceID:"+channelId); + if (platform.getDeviceGBId().equals(channelId)) { + // id指向平台的国标编号,那么就是查询平台的信息 + try { + cmderFroPlatform.deviceInfoResponse(platform, null, sn, fromHeader.getTag()); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] 国标级联 DeviceInfo查询回复: {}", e.getMessage()); + } + return; + } + CommonGBChannel channel = channelService.queryOneWithPlatform(platform.getId(), channelId); + if (channel == null) { + // 不存在则回复404 + log.warn("[DeviceInfo] 通道不存在: 通道编号: {}", channelId); + try { + responseAck(request, Response.NOT_FOUND, "channel not found or offline"); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); return; } + return; + } + // 判断通道类型 + if (channel.getGbDeviceId() == null) { + // 非国标通道不支持录像回放控制 + log.warn("[DeviceInfo] 非国标通道不支持录像回放控制: 通道ID: {}", channel.getGbId()); + try { + responseAck(request, Response.FORBIDDEN, ""); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); + return; + } + return; + } + + // 根据通道ID,获取所属设备 + Device device = deviceService.getDeviceByChannelId(channel.getGbId()); + if (device == null) { + // 不存在则回复404 + log.warn("[DeviceInfo] 通道所属设备不存在, 通道ID: {}", channel.getGbId()); + + try { + responseAck(request, Response.NOT_FOUND, "device not found "); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); + return; + } + return; + } + try { + // 回复200 OK + responseAck((SIPRequest) evt.getRequest(), Response.OK); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] DeviceInfo查询回复: {}", e.getMessage()); + return; } try { cmderFroPlatform.deviceInfoResponse(platform, device, sn, fromHeader.getTag()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java index 2343d232..a279147b 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java @@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query. import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.Platform; import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; import com.genersoft.iot.vmp.gb28181.service.IDeviceService; @@ -12,8 +11,6 @@ import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler; -import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo; import com.genersoft.iot.vmp.utils.DateUtil; import gov.nist.javax.sip.message.SIPRequest; import lombok.extern.slf4j.Slf4j; @@ -27,7 +24,6 @@ import javax.sip.RequestEvent; import javax.sip.SipException; import javax.sip.message.Response; import java.text.ParseException; -import java.util.List; @Slf4j @Component @@ -38,9 +34,6 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp @Autowired private QueryMessageHandler queryMessageHandler; - @Autowired - private IVideoManagerStorage storager; - @Autowired private IGbChannelService channelService;