From 08674069805545af85ef872e28ee28e5fdc30cee Mon Sep 17 00:00:00 2001 From: ‘liusuyi’ <1951119284@qq.com> Date: 星期五, 04 八月 2023 13:19:11 +0800 Subject: [PATCH] 优化minio工具类 集成webrtc-streamer部署启动 集成minio部署启动 集成mediaMtx部署启动 --- ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java | 48 ++++++++++++++++++++++++++++++++++-------------- 1 files changed, 34 insertions(+), 14 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java b/ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java index 41dc8c6..28c0053 100644 --- a/ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java +++ b/ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java @@ -2,9 +2,12 @@ import com.ruoyi.utils.tools.CmdUtils; import com.sun.jna.Platform; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; import java.io.BufferedReader; import java.io.File; import java.io.IOException; @@ -20,25 +23,42 @@ * @Version: 1.0 **/ @Component +@Slf4j(topic = "cmd") public class WebrtcService { + String processName = "webrtc-streamer.exe"; + @Value("${webrtc.host}") + String webrtcHost; + @Value("${webrtc.enabled}") + Boolean webrtcEnabled; + @PostConstruct public void init() { - if (Platform.isWindows()) { - String processName = "webrtc-streamer.exe"; // 鏇挎崲涓哄疄闄呯殑exe绋嬪簭鍚嶇О - String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "webrtc" + File.separator + processName; - List<String> cmd = new ArrayList<>(); - cmd.add(exePath); - cmd.add("-H127.0.0.1:8000"); - cmd.add("-o"); - if (CmdUtils.isProcessRunning(processName)) { - // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋� - CmdUtils.stopProcess(processName); - } - // 鍚姩鍚庡彴杩涚▼ - CmdUtils.commandStart(processName,cmd); - // 鍚姩cmd绐楀彛 + if (webrtcEnabled) { + if (Platform.isWindows()) { + String exePath = System.getProperty("user.dir") + File.separator + "lib" + File.separator + "webrtc" + File.separator + processName; + List<String> cmd = new ArrayList<>(); + cmd.add(exePath); + cmd.add("-H" + webrtcHost); + cmd.add("-o"); + if (CmdUtils.isProcessRunning(processName)) { + // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋� + CmdUtils.stopProcess(processName); + } + // 鍚姩鍚庡彴杩涚▼ + CmdUtils.commandStart(processName, cmd, null); + // 鍚姩cmd绐楀彛 // String[] command = {"cmd", "/c", "start", exePath, "-H127.0.0.1:8000", "-o"}; // CmdUtils.commandStart(command); + } + } + } + + @PreDestroy + public void destroyMediaMtx() { + log.info("閿�姣亀ebrtc-streamer"); + if (CmdUtils.isProcessRunning(processName)) { + // 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋� + CmdUtils.stopProcess(processName); } } } -- Gitblit v1.9.3