|
@@ -1,11 +1,18 @@
|
|
|
package org.dromara.system.controller;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
+import cn.hutool.core.codec.Base64;
|
|
|
+import cn.hutool.core.codec.Base64Decoder;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import jakarta.validation.constraints.*;
|
|
|
import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
+import org.dromara.system.utils.Utils;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.dromara.common.idempotent.annotation.RepeatSubmit;
|
|
@@ -102,4 +109,40 @@ public class TblDeviceController extends BaseController {
|
|
|
@PathVariable Long[] ids) {
|
|
|
return toAjax(tblDeviceService.deleteWithValidByIds(List.of(ids), true));
|
|
|
}
|
|
|
+
|
|
|
+ private Map<String, Utils.PrintStream> rtmptohlsmap = new HashMap<>();
|
|
|
+ @Value(value = "${user.hls.path}")
|
|
|
+ private String path;
|
|
|
+ @Value(value = "${user.hls.url}")
|
|
|
+ private String url;
|
|
|
+ @Value("${user.ffmpegpath}")
|
|
|
+ private String ffmpegFilePath = "/usr/local/bin/ffmpeg";
|
|
|
+
|
|
|
+ @GetMapping("/rtmp/{from}")
|
|
|
+ public R<Object> getHlsCode(@PathVariable("from") String from) {
|
|
|
+ Object data = "";
|
|
|
+ try {
|
|
|
+
|
|
|
+ from = Base64Decoder.decodeStr(from);
|
|
|
+ String p[] = from.split("/");
|
|
|
+ if (rtmptohlsmap.get(from) != null && rtmptohlsmap.get(from).isAlive()) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ File pc = new File(path + p[p.length - 1] + "");
|
|
|
+ if (!pc.exists()) {
|
|
|
+ pc.mkdir();
|
|
|
+ pc.setWritable(true, false);
|
|
|
+ File pc1 = new File(path + p[p.length - 1] + "/playlist.m3u8");
|
|
|
+ pc1.createNewFile();
|
|
|
+ pc1.setWritable(true, false);
|
|
|
+
|
|
|
+ }
|
|
|
+ rtmptohlsmap.put(from, Utils.push(ffmpegFilePath, from, path + p[p.length - 1] + "/playlist.m3u8"));
|
|
|
+ }
|
|
|
+ data = url + p[p.length - 1] + "/playlist.m3u8";
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.ok(data);
|
|
|
+ }
|
|
|
}
|