| | |
| | | |
| | | /** |
| | | * 流媒体管理Controller |
| | | * |
| | | * |
| | | * @author ard |
| | | * @date 2023-08-29 |
| | | */ |
| | | @RestController |
| | | @RequestMapping("/vtdu/media") |
| | | public class VtduController extends BaseController |
| | | { |
| | | public class VtduController extends BaseController { |
| | | @Autowired |
| | | private IVtduService vtduService; |
| | | @Resource |
| | | private IMediaService mediaService; |
| | | @Resource |
| | | private ICameraSdkService cameraSdkService; |
| | | |
| | | /** |
| | | * 查询流媒体管理列表 |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('vtdu:media:list')") |
| | | @GetMapping("/list") |
| | | public TableDataInfo list(Vtdu vtdu) |
| | | { |
| | | public TableDataInfo list(Vtdu vtdu) { |
| | | startPage(); |
| | | List<Vtdu> list = vtduService.selectVtduList(vtdu); |
| | | return getDataTable(list); |
| | |
| | | @PreAuthorize("@ss.hasPermi('vtdu:media:export')") |
| | | @Log(title = "流媒体管理", businessType = BusinessType.EXPORT) |
| | | @PostMapping("/export") |
| | | public void export(HttpServletResponse response, Vtdu vtdu) |
| | | { |
| | | public void export(HttpServletResponse response, Vtdu vtdu) { |
| | | List<Vtdu> list = vtduService.selectVtduList(vtdu); |
| | | ExcelUtil<Vtdu> util = new ExcelUtil<Vtdu>(Vtdu.class); |
| | | util.exportExcel(response, list, "流媒体管理数据"); |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('vtdu:media:query')") |
| | | @GetMapping(value = "/{name}") |
| | | public AjaxResult getInfo(@PathVariable("name") String name) |
| | | { |
| | | //region 自动转码 |
| | | String[] nameArray = name.split("_"); |
| | | String cameraId=nameArray[0]; |
| | | Integer chanNo=Integer.valueOf(nameArray[1]); |
| | | CameraCmd cmd=new CameraCmd(); |
| | | cmd.setCameraId(cameraId); |
| | | cmd.setChanNo(chanNo); |
| | | Map<String, Object> videoCompressionCfg = cameraSdkService.getVideoCompressionCfg(cmd); |
| | | String videoEncType = (String)videoCompressionCfg.get("videoEncType"); |
| | | public AjaxResult getInfo(@PathVariable("name") String name) { |
| | | Vtdu vtdu = vtduService.selectVtduByName(name); |
| | | if(!videoEncType.equals("标准h264")) |
| | | { |
| | | vtdu.setIsCode("1"); |
| | | if (vtdu != null) { |
| | | String cameraId = name.split("_")[0]; |
| | | Integer chanNo = Integer.valueOf(name.split("_")[1]); |
| | | CameraCmd cmd = new CameraCmd(cameraId, chanNo); |
| | | Map<String, Object> videoCompressionCfg = cameraSdkService.getVideoCompressionCfg(cmd); |
| | | String videoEncType = (String) videoCompressionCfg.get("videoEncType"); |
| | | if (!videoEncType.equals("标准h264")) { |
| | | vtdu.setIsCode("1"); |
| | | } else { |
| | | vtdu.setIsCode("0"); |
| | | } |
| | | //流媒体不存在新增,存在更新 |
| | | if (!mediaService.checkNameExist(name)) { |
| | | mediaService.addPath(name, vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode()); |
| | | } else { |
| | | vtduService.updateVtdu(vtdu); |
| | | } |
| | | } |
| | | else |
| | | { |
| | | vtdu.setIsCode("0"); |
| | | } |
| | | vtduService.deleteVtduByName(name); |
| | | vtduService.insertVtdu(vtdu); |
| | | //endregion |
| | | return success(vtduService.selectVtduByName(name)); |
| | | return success(vtdu); |
| | | } |
| | | |
| | | /** |
| | |
| | | @PreAuthorize("@ss.hasPermi('vtdu:media:add')") |
| | | @Log(title = "流媒体管理", businessType = BusinessType.INSERT) |
| | | @PostMapping |
| | | public AjaxResult add(@RequestBody Vtdu vtdu) |
| | | { |
| | | public AjaxResult add(@RequestBody Vtdu vtdu) { |
| | | if (StringUtils.isEmpty(vtdu.getName())) { |
| | | return AjaxResult.error("通道名称不能为空"); |
| | | } |
| | |
| | | @PreAuthorize("@ss.hasPermi('vtdu:media:edit')") |
| | | @Log(title = "流媒体管理", businessType = BusinessType.UPDATE) |
| | | @PutMapping |
| | | public AjaxResult edit(@RequestBody Vtdu vtdu) |
| | | { |
| | | public AjaxResult edit(@RequestBody Vtdu vtdu) { |
| | | return toAjax(vtduService.updateVtdu(vtdu)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @PreAuthorize("@ss.hasPermi('vtdu:media:remove')") |
| | | @Log(title = "流媒体管理", businessType = BusinessType.DELETE) |
| | | @DeleteMapping("/{names}") |
| | | public AjaxResult remove(@PathVariable String[] names) |
| | | { |
| | | @DeleteMapping("/{names}") |
| | | public AjaxResult remove(@PathVariable String[] names) { |
| | | return toAjax(vtduService.deleteVtduByNames(names)); |
| | | } |
| | | } |