| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.List; |
| | | import java.util.stream.Collectors; |
| | | import java.util.stream.Stream; |
| | | |
| | | /** |
| | | * @Description: |
| | |
| | | @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())) |
| | | { |
| | | if (StringUtils.isEmpty(streamInfo.getName())) { |
| | | return AjaxResult.error("通道名称不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(streamInfo.getRtspSource())) |
| | | { |
| | | if (StringUtils.isEmpty(streamInfo.getRtspSource())) { |
| | | return AjaxResult.error("rtsp地址不能为空"); |
| | | } |
| | | String rtsp = mediaService.addPath(streamInfo.getName(), streamInfo.getRtspSource(), streamInfo.getMode(),streamInfo.getIsCode()); |
| | | String rtsp = mediaService.addPath(streamInfo.getName(), streamInfo.getRtspSource(), streamInfo.getMode(), streamInfo.getIsCode()); |
| | | return AjaxResult.success(rtsp); |
| | | } |
| | | |
| | | /** |
| | | * 获取转码详细信息 |
| | | */ |
| | |
| | | public AjaxResult getInfo(@PathVariable("name") String name) { |
| | | return success(mediaService.getPathInfo(name)); |
| | | } |
| | | |
| | | /** |
| | | * 修改转码 |
| | | */ |
| | |
| | | @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()); |
| | | 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("移除转码") |
| | | public AjaxResult removePath( @PathVariable String[] names) { |
| | | public AjaxResult removePath(@PathVariable String[] names) { |
| | | mediaService.removePath(names); |
| | | return AjaxResult.success(); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('media:stream:remove')") |
| | | @DeleteMapping("/{id}") |
| | | public AjaxResult removePullStreamSession(@PathVariable String id) { |
| | | return AjaxResult.success(mediaService.kickRtspSession(id)); |
| | | List<StreamInfo> pullStreamList = mediaService.getPullStreamList(); |
| | | StreamInfo streamInfo = pullStreamList.stream() |
| | | .filter(object -> object.getId().equals(id)) |
| | | .collect(Collectors.toList()).get(0); |
| | | switch (streamInfo.getSessionType()) { |
| | | case "rtsp": |
| | | return AjaxResult.success(mediaService.kickRtspSession(id)); |
| | | case "webrtc": |
| | | return AjaxResult.success(mediaService.kickWebrtcSession(id)); |
| | | case "rtmp": |
| | | return AjaxResult.success(mediaService.kickRtmpSession(id)); |
| | | } |
| | | return AjaxResult.error(); |
| | | } |
| | | |
| | | @PreAuthorize("@ss.hasPermi('media:stream:list')") |