liusuyi
2026-06-02 f652169cc5d6501511eece5df57b7b396fd7a7ab
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播放