| | |
| | | package com.ruoyi.media.controller; |
| | | |
| | | 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.media.domain.StreamInfo; |
| | | import com.ruoyi.media.service.IMediaService; |
| | | import io.swagger.annotations.Api; |
| | |
| | | @RestController |
| | | @Api(tags = "流媒体接口") |
| | | @RequestMapping("/media/stream") |
| | | @Anonymous |
| | | public class MediaController extends BaseController { |
| | | @Resource |
| | | private IMediaService mediaService; |
| | | |
| | | @PostMapping("/add") |
| | | @PostMapping() |
| | | @ApiOperation("增加转码") |
| | | @ApiOperationSupport(includeParameters = {"streamInfo.name","streamInfo.rtspSource"}) |
| | | @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()); |
| | | String rtsp = mediaService.addPath(streamInfo.getName(), streamInfo.getRtspSource(), streamInfo.getMode()); |
| | | return AjaxResult.success(rtsp); |
| | | } |
| | | /** |
| | | * 获取转码详细信息 |
| | | */ |
| | | @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()); |
| | | return AjaxResult.success(rtsp); |
| | | } |
| | | |
| | | @PostMapping("/remove") |
| | | @DeleteMapping("/path/{names}") |
| | | @PreAuthorize("@ss.hasPermi('media:stream:remove')") |
| | | @ApiOperation("移除转码") |
| | | @ApiOperationSupport(includeParameters = {"streamInfo.name"}) |
| | | public AjaxResult removePath(@RequestBody StreamInfo streamInfo) { |
| | | mediaService.removePath(streamInfo.getName()); |
| | | public AjaxResult removePath( @PathVariable String[] names) { |
| | | mediaService.removePath(names); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | @GetMapping("/getPaths") |
| | | @GetMapping("/path/list") |
| | | @ApiOperation("获取当前转码列表") |
| | | public TableDataInfo getPaths() { |
| | | startPage(); |
| | |
| | | startPage(); |
| | | return getDataTable(mediaService.getPushStreamList()); |
| | | } |
| | | /** |
| | | * 新增流媒体推流 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('media:stream:add')") |
| | | @PostMapping |
| | | @ApiOperationSupport(includeParameters = {"streamInfo.name"}) |
| | | public AjaxResult add(@RequestBody StreamInfo streamInfo) throws InterruptedException { |
| | | String rtsp = mediaService.addPath(streamInfo.getName(), streamInfo.getRtspSource()); |
| | | return AjaxResult.success(rtsp); |
| | | } |
| | | /** |
| | | * 删除流媒体推流 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('media:stream:remove')") |
| | | @DeleteMapping("/path/{name}") |
| | | public AjaxResult remove(@PathVariable String name) { |
| | | mediaService.removePath(name); |
| | | return AjaxResult.success(); |
| | | } |
| | | |
| | | /** |
| | | * 删除流媒体拉流 |
| | | */ |