Commit 617c4073186c0307f58a86ff76eb04fb4f08dece

Authored by 648540858
1 parent 4eac6dcc

兼容设备

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java
@@ -901,9 +901,35 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements @@ -901,9 +901,35 @@ public class InviteRequestProcessor extends SIPRequestProcessorParent implements
901 901
902 public void inviteFromDeviceHandle(SIPRequest request, String requesterId, String channelId) { 902 public void inviteFromDeviceHandle(SIPRequest request, String requesterId, String channelId) {
903 903
  904 + String realChannelId = null;
  905 +
904 // 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备) 906 // 非上级平台请求,查询是否设备请求(通常为接收语音广播的设备)
905 Device device = redisCatchStorage.getDevice(requesterId); 907 Device device = redisCatchStorage.getDevice(requesterId);
906 - AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(requesterId, channelId); 908 + // 判断requesterId是设备还是通道
  909 + if (device == null) {
  910 + device = storager.queryVideoDeviceByChannelId(requesterId);
  911 + realChannelId = requesterId;
  912 + }
  913 + if (device == null) {
  914 + // 检查channelID是否可用
  915 + device = redisCatchStorage.getDevice(channelId);
  916 + if (device == null) {
  917 + device = storager.queryVideoDeviceByChannelId(channelId);
  918 + realChannelId = channelId;
  919 + }
  920 + }
  921 +
  922 + if (device == null) {
  923 + logger.warn("来自设备的Invite请求,无法从请求信息中确定所属设备,已忽略,requesterId: {}/{}", requesterId, channelId);
  924 + try {
  925 + responseAck(request, Response.FORBIDDEN);
  926 + } catch (SipException | InvalidArgumentException | ParseException e) {
  927 + logger.error("[命令发送失败] 来自设备的Invite请求,无法从请求信息中确定所属设备 FORBIDDEN: {}", e.getMessage());
  928 + }
  929 + return;
  930 + }
  931 +
  932 + AudioBroadcastCatch broadcastCatch = audioBroadcastManager.get(device.getDeviceId(), realChannelId);
907 if (broadcastCatch == null) { 933 if (broadcastCatch == null) {
908 logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId); 934 logger.warn("来自设备的Invite请求非语音广播,已忽略,requesterId: {}/{}", requesterId, channelId);
909 try { 935 try {
src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
@@ -498,7 +498,7 @@ public class PlayServiceImpl implements IPlayService { @@ -498,7 +498,7 @@ public class PlayServiceImpl implements IPlayService {
498 // 检查是否有y字段 498 // 检查是否有y字段
499 if (ssrcIndex >= 0) { 499 if (ssrcIndex >= 0) {
500 //ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段 TODO 后续对不规范的非10位ssrc兼容 500 //ssrc规定长度为10字节,不取余下长度以避免后续还有“f=”字段 TODO 后续对不规范的非10位ssrc兼容
501 - String ssrcInResponse = contentString.substring(ssrcIndex + 2, ssrcIndex + 12); 501 + String ssrcInResponse = contentString.substring(ssrcIndex + 2, ssrcIndex + 12).trim();
502 // 查询到ssrc不一致且开启了ssrc校验则需要针对处理 502 // 查询到ssrc不一致且开启了ssrc校验则需要针对处理
503 if (ssrcInfo.getSsrc().equals(ssrcInResponse)) { 503 if (ssrcInfo.getSsrc().equals(ssrcInResponse)) {
504 return; 504 return;