From 97259b12c33a170739b76dd9957783bd8743afdb Mon Sep 17 00:00:00 2001
From: Administrator <1144154118@qq.com>
Date: 星期六, 19 八月 2023 16:53:23 +0800
Subject: [PATCH] 循环
---
ard-work/src/main/java/com/ruoyi/media/controller/MediaController.java | 125 ++++++++++++++++++++++++++++++++++++-----
1 files changed, 108 insertions(+), 17 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 83bdeea..1ec2e16 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,16 +2,19 @@
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.media.domain.MediaInfo;
+import com.ruoyi.common.core.page.TableDataInfo;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.device.camera.domain.ArdCameras;
+import com.ruoyi.media.domain.StreamInfo;
import com.ruoyi.media.service.IMediaService;
-import com.ruoyi.media.service.impl.MediaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
@@ -24,27 +27,115 @@
**/
@RestController
@Api(tags = "娴佸獟浣撴帴鍙�")
+@RequestMapping("/media/stream")
@Anonymous
-public class MediaController {
+public class MediaController extends BaseController {
@Resource
private IMediaService mediaService;
- @PostMapping("/add")
+ @PostMapping()
@ApiOperation("澧炲姞杞爜")
- public AjaxResult addPath(@RequestBody MediaInfo mediaInfo) {
- String rtsp = mediaService.addPath(mediaInfo.getName(), mediaInfo.getRtspPath());
+ @PreAuthorize("@ss.hasPermi('media:stream:add')")
+ @ApiOperationSupport(includeParameters = {"streamInfo.name", "streamInfo.rtspSource", "streamInfo.mode"})
+ public AjaxResult addPath(@RequestBody StreamInfo streamInfo) {
+ if(StringUtils.isEmpty(streamInfo.getName()))
+ {
+ return AjaxResult.error("閫氶亾鍚嶇О涓嶈兘涓虹┖");
+ }
+ if(StringUtils.isEmpty(streamInfo.getRtspSource()))
+ {
+ return AjaxResult.error("rtsp鍦板潃涓嶈兘涓虹┖");
+ }
+ String rtsp = mediaService.addPath(streamInfo.getName(), streamInfo.getRtspSource(), streamInfo.getMode(),streamInfo.getIsCode());
return AjaxResult.success(rtsp);
}
- @PostMapping("/remove")
+ /**
+ * 鑾峰彇杞爜璇︾粏淇℃伅
+ */
+ @ApiOperation("鑾峰彇杞爜璇︾粏淇℃伅")
+ @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(),streamInfo.getIsCode());
+ return AjaxResult.success(rtsp);
+ }
+
+ @DeleteMapping("/path/{names}")
+ @PreAuthorize("@ss.hasPermi('media:stream:remove')")
@ApiOperation("绉婚櫎杞爜")
- @ApiOperationSupport(includeParameters={"mediaInfo.name"})
- public AjaxResult removePath(@RequestBody MediaInfo mediaInfo) {
- mediaService.removePath(mediaInfo.getName());
+ public AjaxResult removePath( @PathVariable String[] names) {
+ mediaService.removePath(names);
return AjaxResult.success();
}
- @GetMapping("/getList")
+
+ @GetMapping("/path/list")
@ApiOperation("鑾峰彇褰撳墠杞爜鍒楄〃")
- public AjaxResult getList() {
- return AjaxResult.success(mediaService.list());
+ 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());
+ }
+
+ @GetMapping("/getRtspSessionById")
+ @ApiOperation("鎸塈D鏌ヨ浼氳瘽")
+ public AjaxResult getRtspSessionById(String sessionId) {
+ return AjaxResult.success(mediaService.getRtspSessionById(sessionId));
+ }
+
+ @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("鑾峰彇鎺ㄦ祦鍒楄〃")
+ 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("鑾峰彇鎷夋祦鍒楄〃")
+ public TableDataInfo getPullStreamList() {
+ startPage();
+ return getDataTable(mediaService.getPullStreamList());
}
}
--
Gitblit v1.9.3