From 2b0af3be14d3f8ac28a1cb031e21dc3a69146d2b Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期一, 25 三月 2024 17:59:09 +0800
Subject: [PATCH] 支持hook

---
 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java |   35 ++++++++---------------------------
 1 files changed, 8 insertions(+), 27 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
index a247a78..b8f6f2f 100755
--- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
@@ -139,7 +139,6 @@
      * 鏈嶅姟鍣ㄥ畾鏃朵笂鎶ユ椂闂达紝涓婃姤闂撮殧鍙厤缃紝榛樿10s涓婃姤涓�娆�
      */
     @ResponseBody
-
     @PostMapping(value = "/on_server_keepalive", produces = "application/json;charset=UTF-8")
     public HookResult onServerKeepalive(@RequestBody OnServerKeepaliveHookParam param) {
         try {
@@ -164,25 +163,11 @@
         if (logger.isDebugEnabled()) {
             logger.debug("[ZLM HOOK] 鎾斁閴存潈锛歿}->{}", param.getMediaServerId(), param);
         }
-        String mediaServerId = param.getMediaServerId();
-
-        taskExecutor.execute(() -> {
-            JSONObject json = (JSONObject) JSON.toJSON(param);
-            ZlmHttpHookSubscribe.Event subscribe = this.subscribe.sendNotify(HookType.on_play, json);
-            if (subscribe != null) {
-                MediaServer mediaInfo = mediaServerService.getOne(mediaServerId);
-                if (mediaInfo != null) {
-                    subscribe.response(mediaInfo, param);
-                }
-            }
-        });
-        // TODO 姝ゅ閫昏緫閫傚悎杩佺Щ鍒癕ediaService涓�
-        if (!"rtp".equals(param.getApp())) {
-            Map<String, String> paramMap = urlParamToMap(param.getParams());
-            StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(param.getApp(), param.getStream());
-            if (streamAuthorityInfo != null && streamAuthorityInfo.getCallId() != null && !streamAuthorityInfo.getCallId().equals(paramMap.get("callId"))) {
-                return new HookResult(401, "Unauthorized");
-            }
+        Map<String, String> paramMap = urlParamToMap(param.getParams());
+        // 瀵逛簬鎾斁娴佽繘琛岄壌鏉�
+        boolean authenticateResult = mediaService.authenticatePlay(param.getApp(), param.getStream(), paramMap.get("callId"));
+        if (!authenticateResult) {
+            return new HookResult(401, "Unauthorized");
         }
 
         return HookResult.SUCCESS();
@@ -215,12 +200,14 @@
                 return result;
             }
             if (userSetting.getPushAuthority()) {
+                // 瀵逛簬鎺ㄦ祦杩涜閴存潈
+                Map<String, String> paramMap = urlParamToMap(param.getParams());
                 // 鎺ㄦ祦閴存潈
                 if (param.getParams() == null) {
                     logger.info("鎺ㄦ祦閴存潈澶辫触锛� 缂哄皯蹇呰鍙傛暟锛歴ign=md5(user琛ㄧ殑pushKey)");
                     return new HookResultForOnPublish(401, "Unauthorized");
                 }
-                Map<String, String> paramMap = urlParamToMap(param.getParams());
+
                 String sign = paramMap.get("sign");
                 if (sign == null) {
                     logger.info("鎺ㄦ祦閴存潈澶辫触锛� 缂哄皯蹇呰鍙傛暟锛歴ign=md5(user琛ㄧ殑pushKey)");
@@ -648,12 +635,6 @@
                 }
                 return ret;
             }
-            // TODO 鎺ㄦ祦鍏锋湁涓诲姩鎬э紝鏆傛椂涓嶅仛澶勭悊
-//			StreamPushItem streamPushItem = streamPushService.getPush(app, streamId);
-//			if (streamPushItem != null) {
-//				// TODO 鍙戦�佸仠姝�
-//
-//			}
         }
         return ret;
     }

--
Gitblit v1.8.0