From 065142057ba3983af899991085e37ac1ec502320 Mon Sep 17 00:00:00 2001
From: aijinhui <aijinhui>
Date: 星期二, 19 九月 2023 14:06:30 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ard-work/src/main/java/com/ruoyi/media/service/impl/WebrtcService.java | 51 +++++++++++++++++++++++++++++++++++----------------
1 files changed, 35 insertions(+), 16 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..0a0c592 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
@@ -1,14 +1,14 @@
package com.ruoyi.media.service.impl;
-import com.ruoyi.utils.tools.CmdUtils;
+import com.ruoyi.utils.process.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 java.io.BufferedReader;
+import javax.annotation.PreDestroy;
import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
@@ -20,25 +20,44 @@
* @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 (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() {
+ if (webrtcEnabled) {
+ log.info("閿�姣亀ebrtc-streamer");
if (CmdUtils.isProcessRunning(processName)) {
// 杩涚▼宸茬粡鍦ㄨ繍琛岋紝缁撴潫璇ヨ繘绋�
CmdUtils.stopProcess(processName);
}
- // 鍚姩鍚庡彴杩涚▼
- CmdUtils.commandStart(processName,cmd);
- // 鍚姩cmd绐楀彛
-// String[] command = {"cmd", "/c", "start", exePath, "-H127.0.0.1:8000", "-o"};
-// CmdUtils.commandStart(command);
}
}
}
--
Gitblit v1.9.3