From f7006e4881b176c12e3ba07af7025b0ef4a1508c Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 15 六月 2022 14:55:33 +0800
Subject: [PATCH] 修复播放中zlm离线导致的bye发送失败

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
index bd3dcb1..48cdca3 100644
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java
@@ -2,6 +2,7 @@
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.genersoft.iot.vmp.conf.UserSetting;
 import com.genersoft.iot.vmp.gb28181.bean.SendRtpItem;
 import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
 import org.slf4j.Logger;
@@ -19,6 +20,9 @@
 
     @Autowired
     private ZLMRESTfulUtils zlmresTfulUtils;
+
+    @Autowired
+    private UserSetting userSetting;
 
     private int[] portRangeArray = new int[2];
 
@@ -87,10 +91,15 @@
         int result = -1;
         // 鏌ヨ姝tp server 鏄惁宸茬粡瀛樺湪
         JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId);
-        if (rtpInfo != null && rtpInfo.getInteger("code") == 0 && rtpInfo.getBoolean("exist")) {
-            result = rtpInfo.getInteger("local_port");
+        if(rtpInfo.getInteger("code") == 0){
+            if (rtpInfo.getBoolean("exist")) {
+                result = rtpInfo.getInteger("local_port");
+                return result;
+            }
+        }else if(rtpInfo.getInteger("code") == -2){
             return result;
         }
+
         Map<String, Object> param = new HashMap<>();
         // 鎺ㄦ祦绔彛璁剧疆0鍒欎娇鐢ㄩ殢鏈虹鍙�
         param.put("enable_tcp", 1);
@@ -197,6 +206,7 @@
         sendRtpItem.setTcp(tcp);
         sendRtpItem.setApp("rtp");
         sendRtpItem.setLocalPort(localPort);
+        sendRtpItem.setServerId(userSetting.getServerId());
         sendRtpItem.setMediaServerId(serverItem.getId());
         return sendRtpItem;
     }
@@ -238,6 +248,7 @@
         sendRtpItem.setChannelId(channelId);
         sendRtpItem.setTcp(tcp);
         sendRtpItem.setLocalPort(localPort);
+        sendRtpItem.setServerId(userSetting.getServerId());
         sendRtpItem.setMediaServerId(serverItem.getId());
         return sendRtpItem;
     }

--
Gitblit v1.8.0