From b4048fbe80dba8e7756ae557a15ab60b4f80a44b Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期二, 04 四月 2023 09:09:07 +0800
Subject: [PATCH] 合并开源主线

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 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 c7d9966..a1524dd 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
@@ -92,7 +92,7 @@
         return result;
     }
 
-    public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc, Integer port) {
+    public int createRTPServer(MediaServerItem mediaServerItem, String streamId, int ssrc, Integer port, Boolean onlyAuto) {
         int result = -1;
         // 鏌ヨ姝tp server 鏄惁宸茬粡瀛樺湪
         JSONObject rtpInfo = zlmresTfulUtils.getRtpInfo(mediaServerItem, streamId);
@@ -108,7 +108,7 @@
                     JSONObject jsonObject = zlmresTfulUtils.closeRtpServer(mediaServerItem, param);
                     if (jsonObject != null ) {
                         if (jsonObject.getInteger("code") == 0) {
-                            return createRTPServer(mediaServerItem, streamId, ssrc, port);
+                            return createRTPServer(mediaServerItem, streamId, ssrc, port, onlyAuto);
                         }else {
                             logger.warn("[寮�鍚痳tpServer], 閲嶅惎RtpServer閿欒");
                         }
@@ -131,6 +131,9 @@
             param.put("port", port);
         }
         param.put("ssrc", ssrc);
+        if (onlyAuto != null) {
+            param.put("only_audio", onlyAuto?"1":"0");
+        }
         JSONObject openRtpServerResultJson = zlmresTfulUtils.openRtpServer(mediaServerItem, param);
         logger.info(JSONObject.toJSONString(openRtpServerResultJson));
         if (openRtpServerResultJson != null) {
@@ -229,7 +232,7 @@
         sendRtpItem.setPort(port);
         sendRtpItem.setSsrc(ssrc);
         sendRtpItem.setApp(app);
-        sendRtpItem.setStreamId(stream);
+        sendRtpItem.setStream(stream);
         sendRtpItem.setPlatformId(platformId);
         sendRtpItem.setChannelId(channelId);
         sendRtpItem.setTcp(tcp);
@@ -256,11 +259,14 @@
             // 璁㈤槄 zlm鍚姩浜嬩欢, 鏂扮殑zlm涔熶細浠庤繖閲岃繘鍏ョ郴缁�
             hookSubscribe.addSubscribe(hookSubscribeForRtpServerTimeout,
                     (MediaServerItem mediaServerItem, JSONObject response)->{
-                        logger.info("[涓婄骇鐐规挱] {}->鐩戝惉绔彛鍒版湡缁х画淇濇寔鐩戝惉", ssrc);
+                        logger.info("[淇濇寔绔彛] {}->鐩戝惉绔彛鍒版湡缁х画淇濇寔鐩戝惉", ssrc);
                         keepPort(serverItem, ssrc);
                     });
+        logger.info("[淇濇寔绔彛] {}->鐩戝惉绔彛: {}", ssrc, localPort);
+            logger.info("[淇濇寔绔彛] {}->鐩戝惉绔彛: {}", ssrc, localPort);
+        }else {
+            logger.info("[淇濇寔绔彛] 鐩戝惉绔彛澶辫触: {}", ssrc);
         }
-        logger.info("[涓婄骇鐐规挱] {}->鐩戝惉绔彛: {}", ssrc, localPort);
         return localPort;
     }
 
@@ -268,7 +274,7 @@
      * 閲婃斁淇濇寔鐨勭鍙�
      */
     public boolean releasePort(MediaServerItem serverItem, String ssrc) {
-        logger.info("[涓婄骇鐐规挱] {}->閲婃斁鐩戝惉绔彛", ssrc);
+        logger.info("[淇濇寔绔彛] {}->閲婃斁鐩戝惉绔彛", ssrc);
         boolean closeRTPServerResult = closeRtpServer(serverItem, ssrc);
         HookSubscribeForRtpServerTimeout hookSubscribeForRtpServerTimeout = HookSubscribeFactory.on_rtp_server_timeout(ssrc, null, serverItem.getId());
         // 璁㈤槄 zlm鍚姩浜嬩欢, 鏂扮殑zlm涔熶細浠庤繖閲岃繘鍏ョ郴缁�
@@ -288,6 +294,10 @@
      */
     public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object>param) {
         return zlmresTfulUtils.startSendRtpPassive(mediaServerItem, param);
+    }
+
+    public JSONObject startSendRtpPassive(MediaServerItem mediaServerItem, Map<String, Object>param, ZLMRESTfulUtils.RequestCallback callback) {
+        return zlmresTfulUtils.startSendRtpPassive(mediaServerItem, param, callback);
     }
 
     /**
@@ -343,18 +353,18 @@
             result= true;
             logger.info("[鍋滄RTP鎺ㄦ祦] 鎴愬姛");
         } else {
-            logger.error("[鍋滄RTP鎺ㄦ祦] 澶辫触: {}, 鍙傛暟锛歿}->\r\n{}",jsonObject.getString("msg"), JSON.toJSON(param), jsonObject);
+            logger.warn("[鍋滄RTP鎺ㄦ祦] 澶辫触: {}, 鍙傛暟锛歿}->\r\n{}",jsonObject.getString("msg"), JSON.toJSON(param), jsonObject);
         }
         return result;
     }
 
     public JSONObject startSendRtp(MediaServerItem mediaInfo, SendRtpItem sendRtpItem) {
         String is_Udp = sendRtpItem.isTcp() ? "0" : "1";
-        logger.info("rtp/{}寮�濮嬪悜涓婄骇鎺ㄦ祦, 鐩爣={}:{}锛孲SRC={}", sendRtpItem.getStreamId(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc());
+        logger.info("rtp/{}寮�濮嬫帹娴�, 鐩爣={}:{}锛孲SRC={}", sendRtpItem.getStream(), sendRtpItem.getIp(), sendRtpItem.getPort(), sendRtpItem.getSsrc());
         Map<String, Object> param = new HashMap<>(12);
         param.put("vhost","__defaultVhost__");
         param.put("app",sendRtpItem.getApp());
-        param.put("stream",sendRtpItem.getStreamId());
+        param.put("stream",sendRtpItem.getStream());
         param.put("ssrc", sendRtpItem.getSsrc());
         param.put("src_port", sendRtpItem.getLocalPort());
         param.put("pt", sendRtpItem.getPt());

--
Gitblit v1.8.0