From 617c4073186c0307f58a86ff76eb04fb4f08dece Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 3 Apr 2023 18:39:11 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E8=AE=BE=E5=A4=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/impl/InviteRequestProcessor.java | 28 ++++++++++++++++++- .../iot/vmp/service/impl/PlayServiceImpl.java | 2 +- 2 files changed, 28 insertions(+), 2 deletions(-) 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 9771c582..73e97e77 100644 --- 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 @@ -901,9 +901,35 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements public void inviteFromDeviceHandle(SIPRequest request, String requesterId, String channelId) { + String realChannelId = null; + // 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备) Device device = redisCatchStorage.getDevice(requesterId); - AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(requesterId, channelId); + // 判断requesterId是设备还是通道 + if (device == null) { + device = storager.queryVideoDeviceByChannelId(requesterId); + realChannelId = requesterId; + } + if (device == null) { + // 检查channelID是否可用 + device = redisCatchStorage.getDevice(channelId); + if (device == null) { + device = storager.queryVideoDeviceByChannelId(channelId); + realChannelId = channelId; + } + } + + if (device == null) { + logger.warn("来自设备的Invite请求,无法从请求信息中确定所属设备,已忽略,requesterId: {}/{}", requesterId, channelId); + try { + responseAck(request, Response.FORBIDDEN); + } catch (SipException | InvalidArgumentException | ParseException e) { + logger.error("[命令发送失败] 来自设备的Invite请求,无法从请求信息中确定所属设备 FORBIDDEN: {}", e.getMessage()); + } + return; + } + + AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), realChannelId); if (broadcastCatch == null) { logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); try { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index 4336664f..4d257d47 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -498,7 +498,7 @@ public class PlayServiceImpl implements IPlayService { // 检查是否有y字段 if (ssrcIndex >= 0) { //ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段 TODO 后续对不规范的非10位ssrc兼容 - String ssrcInResponse = contentString.substring(ssrcIndex + 2, ssrcIndex + 12); + String ssrcInResponse = contentString.substring(ssrcIndex + 2, ssrcIndex + 12).trim(); // 查询到ssrc不一致且开启了ssrc校验则需要针对处理 if (ssrcInfo.getSsrc().equals(ssrcInResponse)) { return;