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/controller/MediaController.java | 196 ++++++++++++++++++++++++++++++++----------------
1 files changed, 129 insertions(+), 67 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/media/controller/MediaController.java b/ard-work/src/main/java/com/ruoyi/media/controller/MediaController.java
index 52adb77..48490b4 100644
--- a/ard-work/src/main/java/com/ruoyi/media/controller/MediaController.java
+++ b/ard-work/src/main/java/com/ruoyi/media/controller/MediaController.java
@@ -2,23 +2,27 @@
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.ruoyi.common.annotation.Anonymous;
-import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.common.enums.BusinessType;
-import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.media.domain.StreamInfo;
+import com.ruoyi.media.domain.Vtdu;
import com.ruoyi.media.service.IMediaService;
+import com.ruoyi.media.service.IVtduService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
/**
- * @Description:
+ * @Description: 娴佸獟浣撲笟鍔�
* @ClassName: controller
* @Author: 鍒樿嫃涔�
* @Date: 2023骞�07鏈�13鏃�9:26
@@ -31,100 +35,158 @@
public class MediaController extends BaseController {
@Resource
private IMediaService mediaService;
+ @Resource
+ private IVtduService vtduService;
- @PostMapping()
- @ApiOperation("澧炲姞杞爜")
- @PreAuthorize("@ss.hasPermi('media:stream:add')")
- @ApiOperationSupport(includeParameters = {"streamInfo.name", "streamInfo.rtspSource", "streamInfo.mode"})
- public AjaxResult addPath(@RequestBody StreamInfo streamInfo) {
- String rtsp = mediaService.addPath(streamInfo.getName(), streamInfo.getRtspSource(), streamInfo.getMode());
- return AjaxResult.success(rtsp);
- }
/**
- * 鑾峰彇杞爜璇︾粏淇℃伅
+ * 澧炲姞閫氶亾
*/
- @ApiOperation("鑾峰彇杞爜璇︾粏淇℃伅")
+ @PostMapping()
+ @ApiOperation("澧炲姞閫氶亾")
+ @PreAuthorize("@ss.hasPermi('media:stream:add')")
+ @ApiOperationSupport(includeParameters = {"streamInfo.name", "streamInfo.rtspSource", "streamInfo.mode", "streamInfo.isCode"}, order = 1)
+ public AjaxResult addPath(@RequestBody StreamInfo streamInfo) {
+ if (StringUtils.isEmpty(streamInfo.getName())) {
+ return AjaxResult.error("閫氶亾鍚嶇О涓嶈兘涓虹┖");
+ }
+ if (StringUtils.isEmpty(streamInfo.getRtspSource())) {
+ return AjaxResult.error("rtsp鍦板潃涓嶈兘涓虹┖");
+ }
+ Map<String, String> map = mediaService.addPath(streamInfo.getName(), streamInfo.getRtspSource(), streamInfo.getMode(), streamInfo.getIsCode());
+ map.get("rtspUrl");
+ Vtdu vtdu = new Vtdu();
+ vtdu.setName(streamInfo.getName());
+ vtdu.setSourceUrl(streamInfo.getRtspSource());
+ vtdu.setIsCode(streamInfo.getIsCode());
+ vtdu.setCodeType(streamInfo.getMode());
+ vtdu.setRtspUrl(map.get("rtspUrl"));
+ vtdu.setRtmpUrl(map.get("rtmpUrl"));
+ vtdu.setWebrtcUrl(map.get("webrtcUrl"));
+ vtduService.insertVtdu(vtdu);
+ return AjaxResult.success(map);
+ }
+
+
+ /**
+ * 淇敼閫氶亾
+ */
+ @ApiOperation("淇敼閫氶亾")
+ @ApiOperationSupport(includeParameters = {"streamInfo.name", "streamInfo.rtspSource", "streamInfo.mode", "streamInfo.isCode"}, order = 2)
+ @PreAuthorize("@ss.hasPermi('media:stream:edit')")
+ @PutMapping
+ public AjaxResult edit(@RequestBody StreamInfo streamInfo) {
+ Map<String, String> map = mediaService.editPath(streamInfo.getName(), streamInfo.getRtspSource(), streamInfo.getMode(), streamInfo.getIsCode());
+ Vtdu vtdu = new Vtdu();
+ vtdu.setName(streamInfo.getName());
+ vtdu.setSourceUrl(streamInfo.getRtspSource());
+ vtdu.setIsCode(streamInfo.getIsCode());
+ vtdu.setCodeType(streamInfo.getMode());
+ vtdu.setRtspUrl(map.get("rtspUrl"));
+ vtdu.setRtmpUrl(map.get("rtmpUrl"));
+ vtdu.setWebrtcUrl(map.get("webrtcUrl"));
+ vtduService.updateVtdu(vtdu);
+ return AjaxResult.success(map);
+ }
+
+ /**
+ * 绉婚櫎閫氶亾
+ */
+ @DeleteMapping("/path/{names}")
+ @PreAuthorize("@ss.hasPermi('media:stream:remove')")
+ @ApiOperation("绉婚櫎閫氶亾")
+ @ApiOperationSupport(order = 3)
+ public AjaxResult removePath(@PathVariable String[] names) {
+ mediaService.removePath(names);
+ vtduService.deleteVtduByNames(names);
+ return AjaxResult.success();
+ }
+
+ /**
+ * 绉婚櫎鎷夋祦
+ */
+ @ApiOperation("绉婚櫎鎷夋祦")
+ @ApiOperationSupport(order =4 )
+ @PreAuthorize("@ss.hasPermi('media:stream:remove')")
+ @DeleteMapping("/{sessionId}")
+ public AjaxResult removePullStreamSession(@PathVariable String sessionId) {
+ List<StreamInfo> pullStreamList = mediaService.getPullStreamList();
+ StreamInfo streamInfo = pullStreamList.stream()
+ .filter(object -> object.getId().equals(sessionId))
+ .collect(Collectors.toList()).get(0);
+ switch (streamInfo.getSessionType()) {
+ case "rtsp":
+ return AjaxResult.success(mediaService.kickRtspSession(sessionId));
+ case "webrtc":
+ return AjaxResult.success(mediaService.kickWebrtcSession(sessionId));
+ case "rtmp":
+ return AjaxResult.success(mediaService.kickRtmpSession(sessionId));
+ }
+ return AjaxResult.error();
+ }
+
+ /**
+ * 鑾峰彇閫氶亾璇︾粏淇℃伅
+ */
+ @ApiOperation("鑾峰彇閫氶亾璇︾粏淇℃伅")
+ @ApiOperationSupport(order =4 )
@GetMapping(value = "/{name}")
public AjaxResult getInfo(@PathVariable("name") String name) {
return success(mediaService.getPathInfo(name));
}
+
/**
- * 淇敼杞爜
+ * 鑾峰彇褰撳墠閫氶亾鍒楄〃
*/
- @ApiOperation("淇敼杞爜")
- @PreAuthorize("@ss.hasPermi('media:stream:edit')")
- @PutMapping
- public AjaxResult edit(@RequestBody StreamInfo streamInfo) {
- mediaService.removePath(new String[]{streamInfo.getName()});
- String rtsp = mediaService.addPath(streamInfo.getName(), streamInfo.getRtspSource(), streamInfo.getMode());
- return AjaxResult.success(rtsp);
- }
-
- @DeleteMapping("/path/{names}")
- @PreAuthorize("@ss.hasPermi('media:stream:remove')")
- @ApiOperation("绉婚櫎杞爜")
- public AjaxResult removePath( @PathVariable String[] names) {
- mediaService.removePath(names);
- return AjaxResult.success();
- }
-
@GetMapping("/path/list")
- @ApiOperation("鑾峰彇褰撳墠杞爜鍒楄〃")
+ @ApiOperation("鑾峰彇褰撳墠閫氶亾鍒楄〃")
+ @ApiOperationSupport(order = 5)
public TableDataInfo getPaths() {
startPage();
return getDataTable(mediaService.paths());
}
- @GetMapping("/getRtspSessions")
- @ApiOperation("鑾峰彇rtsp浼氳瘽鍒楄〃")
- public AjaxResult getRtspSessions() {
- return AjaxResult.success(mediaService.rtspsessions());
- }
-
- @GetMapping("/getRtspConns")
- @ApiOperation("鑾峰彇rtsp杩炴帴鍒楄〃")
- public AjaxResult getRtspConns() {
- return AjaxResult.success(mediaService.rtspconns());
- }
-
+ /**
+ * 鎸塈D鏌ヨ鎷夋祦璇︽儏
+ */
@GetMapping("/getRtspSessionById")
- @ApiOperation("鎸塈D鏌ヨ浼氳瘽")
+ @ApiOperation("鎸塈D鏌ヨ鎷夋祦璇︽儏")
public AjaxResult getRtspSessionById(String sessionId) {
- return AjaxResult.success(mediaService.getRtspSessionById(sessionId));
+ List<StreamInfo> pullStreamList = mediaService.getPullStreamList();
+ StreamInfo streamInfo = pullStreamList.stream()
+ .filter(object -> object.getId().equals(sessionId))
+ .collect(Collectors.toList()).get(0);
+ switch (streamInfo.getSessionType()) {
+ case "rtsp":
+ return AjaxResult.success(mediaService.getRtspSessionById(sessionId));
+ case "rtmp":
+ return AjaxResult.success(mediaService.getRtmpSessionById(sessionId));
+ case "webrtc":
+ return AjaxResult.success(mediaService.getWebrtcSessionById(sessionId));
+ }
+ return AjaxResult.error();
}
- @GetMapping("/getPushStreams")
- @ApiOperation("鑾峰彇鎺ㄦ祦淇℃伅")
- public AjaxResult getPushStreams() {
- return AjaxResult.success(mediaService.getPushStreams());
- }
-
- @GetMapping("/getPullStreams")
- @ApiOperation("鑾峰彇鎷夋祦淇℃伅")
- public AjaxResult getPullStreams() {
- return AjaxResult.success(mediaService.getPullStreams());
- }
-
+ /**
+ * 鑾峰彇鎺ㄦ祦鍒楄〃
+ */
@PreAuthorize("@ss.hasPermi('media:stream:list')")
@GetMapping("/pushList")
@ApiOperation("鑾峰彇鎺ㄦ祦鍒楄〃")
+ @ApiOperationSupport(order = 6)
public TableDataInfo getPushStreamList() {
startPage();
return getDataTable(mediaService.getPushStreamList());
}
- /**
- * 鍒犻櫎娴佸獟浣撴媺娴�
- */
- @PreAuthorize("@ss.hasPermi('media:stream:remove')")
- @DeleteMapping("/{id}")
- public AjaxResult removePullStreamSession(@PathVariable String id) {
- return AjaxResult.success(mediaService.kickRtspSession(id));
- }
+
+ /**
+ * 鑾峰彇鎷夋祦鍒楄〃
+ */
@PreAuthorize("@ss.hasPermi('media:stream:list')")
@GetMapping("/pullList")
@ApiOperation("鑾峰彇鎷夋祦鍒楄〃")
+ @ApiOperationSupport(order = 7)
public TableDataInfo getPullStreamList() {
startPage();
return getDataTable(mediaService.getPullStreamList());
--
Gitblit v1.9.3