From f652169cc5d6501511eece5df57b7b396fd7a7ab Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Tue, 02 Jun 2026 09:51:34 +0800
Subject: [PATCH] 优化

---
 ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/controller/ZlmController.java |   67 +++++++++++++++++++++++++++++++++
 1 files changed, 67 insertions(+), 0 deletions(-)

diff --git a/ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/controller/ZlmController.java b/ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/controller/ZlmController.java
index 54a3f88..edcc66e 100644
--- a/ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/controller/ZlmController.java
+++ b/ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/controller/ZlmController.java
@@ -921,4 +921,71 @@
         return AjaxResult.success(json);
     }
 
+    /**
+     * 拉流代理(通过通道ID,简化传参)
+     *
+     * @param request   HttpServletRequest
+     * @param channelId 通道ID
+     * @return
+     */
+    @Operation(summary = "拉流代理(通过通道ID,简化传参)")
+    @PostMapping("/streamPullPlayByChannelId/{channelId}")
+    public DeferredResult<R<StreamContent>> streamPullPlayByChannelId(
+            HttpServletRequest request,
+            @PathVariable String channelId
+    ) {
+        log.info("[拉流代理-通道ID] channelId:{}", channelId);
+        Assert.hasText(channelId, "通道ID不可为空");
+
+        DeferredResult<R<StreamContent>> result = new DeferredResult<>(userSetting.getPlayTimeout().longValue());
+
+        ErrorCallback<StreamInfo> callback = (code, msg, streamInfo) -> {
+            if (code == InviteErrorCode.SUCCESS.getCode()) {
+                R<StreamContent> r = R.ok();
+                if (streamInfo != null) {
+                    if (userSetting.getUseSourceIpAsStreamIp()) {
+                        streamInfo = streamInfo.clone();
+                        String host;
+                        try {
+                            URL url = new URL(request.getRequestURL().toString());
+                            host = url.getHost();
+                        } catch (MalformedURLException e) {
+                            host = request.getLocalAddr();
+                        }
+                        streamInfo.changeStreamIp(host);
+                    }
+                    if (!ObjectUtils.isEmpty(streamInfo.getMediaServer().getTranscodeSuffix())
+                            && !"null".equalsIgnoreCase(streamInfo.getMediaServer().getTranscodeSuffix())) {
+                        streamInfo.setStream(streamInfo.getStream() + "_" + streamInfo.getMediaServer().getTranscodeSuffix());
+                    }
+                    r.setData(new StreamContent(streamInfo));
+                } else {
+                    r.setCode(code);
+                    r.setMsg(msg);
+                }
+                result.setResult(r);
+            } else {
+                result.setResult(R.fail(code, msg));
+            }
+        };
+
+        mediaServerService.streamPullPlayByChannelId(channelId, callback);
+        return result;
+    }
+
+    /**
+     * 停止拉流代理(通过通道ID)
+     *
+     * @param channelId 通道ID
+     * @return
+     */
+    @Operation(summary = "停止拉流代理(通过通道ID)")
+    @PostMapping("/stopStreamPullPlayByChannelId/{channelId}")
+    public AjaxResult stopStreamPullPlayByChannelId(@PathVariable String channelId) {
+        log.info("[停止拉流代理-通道ID] channelId:{}", channelId);
+        Assert.hasText(channelId, "通道ID不可为空");
+        mediaServerService.stopStreamPullPlayByChannelId(channelId);
+        return AjaxResult.success();
+    }
+
 }

--
Gitblit v1.9.3