From 5cd2e2c41b6460ea628b158e9f22b6788e99eee1 Mon Sep 17 00:00:00 2001
From: lishuyuan <lishuyuan@inspur.com>
Date: 星期三, 01 十一月 2023 15:17:28 +0800
Subject: [PATCH] bugfix:设备地址变化会引起目录订阅任务失效,需要重新添加

---
 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MediaStatusNotifyMessageHandler.java |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

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
old mode 100644
new mode 100755
index 728ff0e..fdcd5e4
--- 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
@@ -1,6 +1,7 @@
 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd;
 
-import com.genersoft.iot.vmp.common.StreamInfo;
+import com.genersoft.iot.vmp.common.InviteInfo;
+import com.genersoft.iot.vmp.common.InviteSessionType;
 import com.genersoft.iot.vmp.conf.exception.SsrcTransactionNotFoundException;
 import com.genersoft.iot.vmp.gb28181.bean.Device;
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
@@ -15,6 +16,7 @@
 import com.genersoft.iot.vmp.media.zlm.ZlmHttpHookSubscribe;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeFactory;
 import com.genersoft.iot.vmp.media.zlm.dto.HookSubscribeForStreamChange;
+import com.genersoft.iot.vmp.service.IInviteStreamService;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
 import gov.nist.javax.sip.message.SIPRequest;
@@ -64,6 +66,12 @@
     @Autowired
     private ZlmHttpHookSubscribe subscribe;
 
+    @Autowired
+    private IInviteStreamService inviteStreamService;
+
+    @Autowired
+    private VideoStreamSessionManager streamSession;
+
     @Override
     public void afterPropertiesSet() throws Exception {
         notifyMessageHandler.addHandler(cmdType, this);
@@ -82,17 +90,15 @@
         String NotifyType =getText(rootElement, "NotifyType");
         if ("121".equals(NotifyType)){
             logger.info("[褰曞儚娴乚鎺ㄩ�佸畬姣曪紝鏀跺埌鍏虫祦閫氱煡");
-            // 鏌ヨ鏄澶�
-            StreamInfo streamInfo = redisCatchStorage.queryDownload(null, null, null, callIdHeader.getCallId());
-            if (streamInfo != null) {
-                // 璁剧疆杩涘害100%
-                streamInfo.setProgress(1);
-                redisCatchStorage.startDownload(streamInfo, callIdHeader.getCallId());
-            }
 
-            // 鍏堜粠浼氳瘽鍐呮煡鎵�
-            SsrcTransaction ssrcTransaction = sessionManager.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
-            if (ssrcTransaction != null) { // 鍏煎娴峰悍 濯掍綋閫氱煡 娑堟伅from瀛楁涓嶆槸璁惧ID鐨勯棶棰�
+            SsrcTransaction ssrcTransaction = streamSession.getSsrcTransaction(null, null, callIdHeader.getCallId(), null);
+            if (ssrcTransaction != null) {
+                logger.info("[褰曞儚娴乚鎺ㄩ�佸畬姣曪紝鍏虫祦閫氱煡锛� device: {}, channelId: {}", ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId());
+                InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(), ssrcTransaction.getStream());
+                if (inviteInfo.getStreamInfo() != null) {
+                    inviteInfo.getStreamInfo().setProgress(1);
+                    inviteStreamService.updateInviteInfo(inviteInfo);
+                }
 
                 try {
                     cmder.streamByeCmd(device, ssrcTransaction.getChannelId(), null, callIdHeader.getCallId());
@@ -117,6 +123,8 @@
                         logger.error("[鍛戒护鍙戦�佸け璐 鍥芥爣绾ц仈 褰曞儚鎾斁瀹屾瘯: {}", e.getMessage());
                     }
                 }
+            }else {
+                logger.info("[褰曞儚娴乚鎺ㄩ�佸畬姣曪紝鍏虫祦閫氱煡锛� 浣嗘槸鏈壘鍒板搴旂殑涓嬭浇淇℃伅");
             }
         }
     }

--
Gitblit v1.8.0