leesam
2024-04-01 23beb4fde063b4a648c2a273f17cf5c423fa0ae6
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/ByeRequestProcessor.java
@@ -15,8 +15,11 @@
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
import com.genersoft.iot.vmp.media.zlm.ZLMServerFactory;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.*;
import com.genersoft.iot.vmp.service.bean.MessageForPushChannel;
import com.genersoft.iot.vmp.service.bean.RequestStopPushStreamMsg;
import com.genersoft.iot.vmp.service.redisMsg.RedisGbPlayMsgListener;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import gov.nist.javax.sip.message.SIPRequest;
@@ -92,6 +95,12 @@
   @Autowired
   private UserSetting userSetting;
   @Autowired
   private IStreamPushService pushService;
   @Autowired
   private RedisGbPlayMsgListener redisGbPlayMsgListener;
   @Override
   public void afterPropertiesSet() throws Exception {
      // 添加消息处理的订阅
@@ -115,7 +124,7 @@
      // 收流端发送的停止
      if (sendRtpItem != null){
         logger.info("[收到bye] 来自{},停止通道:{}, 类型: {}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), sendRtpItem.getPlayType());
         logger.info("[收到bye] 来自{},停止通道:{}, 类型: {}, callId: {}", sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(), sendRtpItem.getPlayType(), callIdHeader.getCallId());
         String streamId = sendRtpItem.getStream();
         Map<String, Object> param = new HashMap<>();
@@ -123,7 +132,19 @@
         param.put("app",sendRtpItem.getApp());
         param.put("stream",streamId);
         param.put("ssrc",sendRtpItem.getSsrc());
         logger.info("[收到bye] 停止推流:{}", streamId);
         logger.info("[收到bye] 停止推流:{}, 媒体节点: {}", streamId, sendRtpItem.getMediaServerId());
         if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) {
            // 查询这路流是否是本平台的
            StreamPushItem push = pushService.getPush(sendRtpItem.getApp(), sendRtpItem.getStream());
            if (push!= null && !push.isSelf()) {
               // 不是本平台的就发送redis消息让其他wvp停止发流
               ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
               if (platform != null) {
                  RequestStopPushStreamMsg streamMsg = RequestStopPushStreamMsg.getInstance(sendRtpItem, platform.getName(), platform.getId());
                  redisGbPlayMsgListener.sendMsgForStopSendRtpStream(sendRtpItem.getServerId(), streamMsg);
               }
            }else {
         MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
         redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(),
               callIdHeader.getCallId(), null);
@@ -131,7 +152,7 @@
         if (userSetting.getUseCustomSsrcForParentInvite()) {
            mediaServerService.releaseSsrc(mediaInfo.getId(), sendRtpItem.getSsrc());
         }
         if (sendRtpItem.getPlayType().equals(InviteStreamType.PUSH)) {
            ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
            if (platform != null) {
               MessageForPushChannel messageForPushChannel = MessageForPushChannel.getInstance(0,
@@ -143,7 +164,17 @@
               logger.info("[上级平台停止观看] 未找到平台{}的信息,发送redis消息失败", sendRtpItem.getPlatformId());
            }
         }
         }else {
            MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
            redisCatchStorage.deleteSendRTPServer(sendRtpItem.getPlatformId(), sendRtpItem.getChannelId(),
                  callIdHeader.getCallId(), null);
            zlmServerFactory.stopSendRtpStream(mediaInfo, param);
            if (userSetting.getUseCustomSsrcForParentInvite()) {
               mediaServerService.releaseSsrc(mediaInfo.getId(), sendRtpItem.getSsrc());
            }
         }
         MediaServerItem mediaInfo = mediaServerService.getOne(sendRtpItem.getMediaServerId());
         if (mediaInfo != null) {
         AudioBroadcastCatch audioBroadcastCatch = audioBroadcastManager.get(sendRtpItem.getDeviceId(), sendRtpItem.getChannelId());
         if (audioBroadcastCatch != null && audioBroadcastCatch.getSipTransactionInfo().getCallId().equals(callIdHeader.getCallId())) {
            // 来自上级平台的停止对讲
@@ -169,6 +200,7 @@
            }
         }
      }
      }
         // 可能是设备发送的停止
         SsrcTransaction ssrcTransaction = streamSession.getSsrcTransactionByCallId(callIdHeader.getCallId());