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/service/impl/MediaServerServiceImpl.java | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 59 insertions(+), 0 deletions(-)
diff --git a/ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/service/impl/MediaServerServiceImpl.java b/ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/service/impl/MediaServerServiceImpl.java
index 61b5487..0956186 100644
--- a/ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/service/impl/MediaServerServiceImpl.java
+++ b/ard-modules/ard-modules-zlm/src/main/java/com/ard/zlm/service/impl/MediaServerServiceImpl.java
@@ -1904,6 +1904,65 @@
}
}
+ /**
+ * 通过通道ID拉流代理(简化传参,自动根据通道类型确定app/url等参数)
+ *
+ * @param channelId 通道ID
+ * @param callback 回调
+ */
+ @Override
+ public void streamPullPlayByChannelId(String channelId, ErrorCallback<StreamInfo> callback) {
+ R<ArdChannel> channelR = remoteChannelService.getInfo(channelId, SecurityConstants.INNER);
+ if (channelR.getCode() != Constants.SUCCESS) {
+ callback.run(InviteErrorCode.FAIL.getCode(), "获取通道信息失败 channelId:" + channelId, null);
+ return;
+ }
+ if (channelR.getData() == null) {
+ callback.run(InviteErrorCode.FAIL.getCode(), "通道不存在 channelId:" + channelId, null);
+ return;
+ }
+
+ ArdChannel ardChannel = channelR.getData();
+ StreamPullPlay streamPullPlay = buildStreamPullPlay(ardChannel);
+ streamPullPlay(streamPullPlay, callback);
+ }
+
+ /**
+ * 通过通道ID停止拉流代理
+ *
+ * @param channelId 通道ID
+ */
+ @Override
+ public void stopStreamPullPlayByChannelId(String channelId) {
+ R<ArdChannel> channelR = remoteChannelService.getInfo(channelId, SecurityConstants.INNER);
+ if (channelR.getCode() != Constants.SUCCESS) {
+ throw new RuntimeException("获取通道信息失败 channelId:" + channelId);
+ }
+ if (channelR.getData() == null) {
+ throw new RuntimeException("通道不存在 channelId:" + channelId);
+ }
+
+ ArdChannel ardChannel = channelR.getData();
+ StreamPullPlay streamPullPlay = new StreamPullPlay();
+ streamPullPlay.setChannelId(channelId);
+ streamPullPlay.setMediaServerId(ardChannel.getMediaServerId());
+ streamPullPlay.setStreamKey(ardChannel.getStreamKey());
+ stopStreamPullPlay(streamPullPlay);
+ }
+
+ private StreamPullPlay buildStreamPullPlay(ArdChannel ardChannel) {
+ StreamPullPlay streamPullPlay = new StreamPullPlay();
+ streamPullPlay.setChannelId(ardChannel.getId());
+ streamPullPlay.setStream(ardChannel.getId());
+ streamPullPlay.setUrl(ardChannel.getLiveAddress());
+ streamPullPlay.setApp("ard");
+ streamPullPlay.setEnable_mp4(false);
+ streamPullPlay.setEnable_audio(true);
+ streamPullPlay.setRtp_type("1");
+ streamPullPlay.setTimeOut(10);
+ return streamPullPlay;
+ }
+
/**
* 开启国标28181播放
--
Gitblit v1.9.3