From f88c70d38ce1c9c0d04460d0c225373c84dc2eca Mon Sep 17 00:00:00 2001
From: dengming <dengming@ctfo.com>
Date: 星期四, 10 三月 2022 17:27:07 +0800
Subject: [PATCH] 删除重复字段,channelId字段查询了两次

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 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 b4d1048..a0b7e75 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
@@ -107,8 +107,13 @@
         int currentPort = mediaServerItem.getCurrentPort();
         if (currentPort == 0) {
             String[] portRangeStrArray = mediaServerItem.getSendRtpPortRange().split(",");
-            portRangeArray[0] = Integer.parseInt(portRangeStrArray[0]);
-            portRangeArray[1] = Integer.parseInt(portRangeStrArray[1]);
+            if (portRangeStrArray.length != 2) {
+                portRangeArray[0] = 30000;
+                portRangeArray[1] = 30500;
+            }else {
+                portRangeArray[0] = Integer.parseInt(portRangeStrArray[0]);
+                portRangeArray[1] = Integer.parseInt(portRangeStrArray[1]);
+            }
         }
 
         if (currentPort == 0 || currentPort++ > portRangeArray[1]) {
@@ -200,7 +205,7 @@
     /**
      * 璋冪敤zlm RESTful API 鈥斺�� startSendRtp
      */
-    public Boolean startSendRtpStream(MediaServerItem mediaServerItem, Map<String, Object>param) {
+    public JSONObject startSendRtpStream(MediaServerItem mediaServerItem, Map<String, Object>param) {
         Boolean result = false;
         JSONObject jsonObject = zlmresTfulUtils.startSendRtp(mediaServerItem, param);
         if (jsonObject == null) {
@@ -211,7 +216,7 @@
         } else {
             logger.error("RTP鎺ㄦ祦澶辫触: " + jsonObject.getString("msg"));
         }
-        return result;
+        return jsonObject;
     }
 
     /**
@@ -237,9 +242,18 @@
      */
     public int totalReaderCount(MediaServerItem mediaServerItem, String app, String streamId) {
         JSONObject mediaInfo = zlmresTfulUtils.getMediaInfo(mediaServerItem, app, "rtmp", streamId);
+        Integer code = mediaInfo.getInteger("code");
         if (mediaInfo == null) {
             return 0;
         }
+        if ( code < 0) {
+            logger.warn("鏌ヨ娴�({}/{})鏄惁鏈夊叾瀹冭鐪嬭�呮椂寰楀埌锛� {}", app, streamId, mediaInfo.getString("msg"));
+            return -1;
+        }
+        if ( code == 0 && ! mediaInfo.getBoolean("online")) {
+            logger.warn("鏌ヨ娴�({}/{})鏄惁鏈夊叾瀹冭鐪嬭�呮椂寰楀埌锛� {}", app, streamId, mediaInfo.getString("msg"));
+            return -1;
+        }
         return mediaInfo.getInteger("totalReaderCount");
     }
 

--
Gitblit v1.8.0