diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java index 6cf3b2d23..5425b5102 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/AckRequestProcessor.java @@ -113,7 +113,7 @@ public class AckRequestProcessor extends SIPRequestProcessorParent implements In Platform parentPlatform = platformService.queryPlatformByServerGBId(fromUserId); if (parentPlatform != null) { - DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpItem.getChannelId()); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(sendRtpItem.getChannelId()); if (!userSetting.getServerId().equals(sendRtpItem.getServerId())) { WVPResult wvpResult = redisRpcService.startSendRtp(sendRtpItem.getChannelId(), sendRtpItem); if (wvpResult.getCode() == 0) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java index 6576e1b32..5a45d4ae9 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java @@ -160,7 +160,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In log.info("[收到bye] {} 通知设备停止推流时未找到设备信息", streamId); return; } - DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpItem.getChannelId()); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(sendRtpItem.getChannelId()); if (deviceChannel == null) { log.info("[收到bye] {} 通知设备停止推流时未找到通道信息", streamId); return; @@ -196,7 +196,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In platformService.stopBroadcast(platform, channel, ssrcTransaction.getStream(), false, mediaServerService.getOne(mediaServerId)); Device device = deviceService.getDeviceByDeviceId(ssrcTransaction.getDeviceId()); - DeviceChannel deviceChannel = deviceChannelService.getOneById(ssrcTransaction.getChannelId()); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(ssrcTransaction.getChannelId()); playService.stopAudioBroadcast(device, deviceChannel); } @@ -206,7 +206,7 @@ public class ByeRequestProcessor extends SIPRequestProcessorParent implements In log.info("[收到bye] 未找到设备:{} ", ssrcTransaction.getDeviceId()); return; } - DeviceChannel channel = deviceChannelService.getOneById(ssrcTransaction.getChannelId()); + DeviceChannel channel = deviceChannelService.getOneForSourceById(ssrcTransaction.getChannelId()); if (channel == null) { log.info("[收到bye] 未找到通道,设备:{}, 通道:{}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId()); return; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index 4bbe4a698..7a766da11 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -214,7 +214,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements MediaServer mediaServer = mediaServerService.getOne(sendRtpItem.getMediaServerId()); try { mediaServerService.startSendRtpPassive(mediaServer, sendRtpItem, 5); - DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpItem.getChannelId()); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(sendRtpItem.getChannelId()); if (deviceChannel != null) { redisCatchStorage.sendPlatformStartPlayMsg(sendRtpItem, deviceChannel, platform); } @@ -451,7 +451,7 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements } return; }else { - deviceChannel = deviceChannelService.getOneById(audioBroadcastCatchList.get(0).getChannelId()); + deviceChannel = deviceChannelService.getOneForSourceById(audioBroadcastCatchList.get(0).getChannelId()); } } AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(deviceChannel.getId()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java index a6b646043..d2e903fa8 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/info/InfoRequestProcessor.java @@ -117,7 +117,7 @@ public class InfoRequestProcessor extends SIPRequestProcessorParent implements I return; } // 获取通道的原始信息 - DeviceChannel deviceChannel = deviceChannelService.getOneById(sendRtpInfo.getChannelId()); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(sendRtpInfo.getChannelId()); // 向原始通道转发控制消息 ContentTypeHeader header = (ContentTypeHeader)evt.getRequest().getHeader(ContentTypeHeader.NAME); String contentType = header.getContentType(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java index 9de3d7c15..0122242ad 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/control/cmd/DeviceControlQueryMessageHandler.java @@ -93,34 +93,9 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent } return; } - // 根据通道ID,获取所属设备 - Device device = deviceService.getDeviceByChannelId(channel.getGbId()); - if (device == null) { - // 不存在则回复404 - log.warn("[INFO 消息] 通道所属设备不存在, 通道ID: {}", channel.getGbId()); - try { - responseAck(request, Response.NOT_FOUND, "device not found"); - } catch (SipException | InvalidArgumentException | ParseException e) { - log.error("[命令发送失败] 错误信息: {}", e.getMessage()); - } - return; - } + log.info("[deviceControl] 命令: {}, 平台: {}({})->{}", deviceControlType, platform.getName(), + platform.getServerGBId(), channel.getGbId()); - log.info("[deviceControl] 命令: {}, 平台: {}({})->{}({})/{}", deviceControlType, platform.getName(), - platform.getServerGBId(), device.getName(), device.getDeviceId(), channel.getGbId()); - DeviceChannel deviceChannel = deviceChannelService.getOneById(channel.getGbId()); - if (deviceChannel == null) { - // 拒绝远程启动命令 - log.warn("[deviceControl] 未找到设备原始通道, 平台: {}({}),通道编号:{}", platform.getName(), - platform.getServerGBId(), channelId); - try { - responseAck(request, Response.NOT_FOUND, "channel not found"); - } catch (SipException | InvalidArgumentException | ParseException e) { - log.error("[命令发送失败] 错误信息: {}", e.getMessage()); - } - return; - } - // !platform.getServerGBId().equals(targetGBId) 判断是为了过滤本平台内互相级联的情况 if (!ObjectUtils.isEmpty(deviceControlType)) { switch (deviceControlType) { case PTZ: @@ -158,13 +133,35 @@ public class DeviceControlQueryMessageHandler extends SIPRequestProcessorParent /** * 处理云台指令 - * - * @param device 设备 - * @param channelId 通道id - * @param rootElement - * @param request */ - private void handlePtzCmd(Device device, String channelId, Element rootElement, SIPRequest request, DeviceControlType type) { + private void handlePtzCmd(CommonGBChannel channel, Element rootElement, SIPRequest request, DeviceControlType type) { + // 根据通道ID,获取所属设备 + Device device = deviceService.getDeviceByChannelId(channel.getGbId()); + if (device == null) { + // 不存在则回复404 + log.warn("[INFO 消息] 通道所属设备不存在, 通道ID: {}", channel.getGbId()); + try { + responseAck(request, Response.NOT_FOUND, "device not found"); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] 错误信息: {}", e.getMessage()); + } + return; + } + + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId()); + if (deviceChannel == null) { + // 拒绝远程启动命令 + log.warn("[deviceControl] 未找到设备原始通道, 平台: {}({}),通道编号:{}", platform.getName(), + platform.getServerGBId(), channelId); + try { + responseAck(request, Response.NOT_FOUND, "channel not found"); + } catch (SipException | InvalidArgumentException | ParseException e) { + log.error("[命令发送失败] 错误信息: {}", e.getMessage()); + } + return; + } + log.info("[deviceControl] 命令: {}, 设备: {}({}), 通道{}({}", type, device.getName(), device.getDeviceId(), + deviceChannel.getName(), deviceChannel.getDeviceId()); String cmdString = getText(rootElement, type.getVal()); try { cmder.fronEndCmd(device, channelId, cmdString, 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 8c6226764..f278ef308 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 @@ -106,7 +106,7 @@ public class BroadcastNotifyMessageHandler extends SIPRequestProcessorParent imp responseAck(request, Response.NOT_FOUND, "device not found"); return; } - DeviceChannel deviceChannel = deviceChannelService.getOneById(channel.getGbId()); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId()); if (deviceChannel == null) { responseAck(request, Response.NOT_FOUND, "channel not found"); return; 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 28ad2c262..79deb0423 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 @@ -124,7 +124,7 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp return; } // 获取通道的原始信息 - DeviceChannel deviceChannel = deviceChannelService.getOneById(channel.getGbId()); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channel.getGbId()); // 接收录像数据 recordEndEventListener.addEndEventHandler(device.getDeviceId(), deviceChannel.getDeviceId(), (recordInfo)->{ try { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java index 2a0d7ca8c..875d01bf0 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/MediaServiceImpl.java @@ -179,7 +179,7 @@ public class MediaServiceImpl implements IMediaService { String deviceId = ssrcTransaction.getDeviceId(); Integer channelId = ssrcTransaction.getChannelId(); - DeviceChannel deviceChannel = deviceChannelService.getOneById(channelId); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(channelId); if (deviceChannel != null) { result.setEnable_audio(deviceChannel.isHasAudio()); } @@ -234,7 +234,7 @@ public class MediaServiceImpl implements IMediaService { if (inviteInfo.getType() == InviteSessionType.DOWNLOAD) { return false; } - DeviceChannel deviceChannel = deviceChannelService.getOneById(inviteInfo.getChannelId()); + DeviceChannel deviceChannel = deviceChannelService.getOneForSourceById(inviteInfo.getChannelId()); if (deviceChannel == null) { return false; }