| | |
| | | package com.ruoyi.media.service.impl; |
| | | |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | import com.ruoyi.common.core.domain.AjaxResult; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.media.service.IMediaService; |
| | | import com.ruoyi.utils.forest.MediaClient; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.media.mapper.VtduMapper; |
| | | import com.ruoyi.media.domain.Vtdu; |
| | |
| | | * @date 2023-08-29 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class VtduServiceImpl implements IVtduService { |
| | | @Resource |
| | | private VtduMapper vtduMapper; |
| | | @Resource |
| | | private IMediaService mediaService; |
| | | |
| | | /** |
| | | * 查询流媒体管理 |
| | |
| | | */ |
| | | @Override |
| | | public int insertVtdu(Vtdu vtdu) { |
| | | vtdu.setCreateBy(SecurityUtils.getUserId()); |
| | | log.info("流媒体【" + vtdu.getName() + "】通道添加"); |
| | | Map<String, String> map = mediaService.addPath(vtdu.getName(), vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode()); |
| | | vtdu.setRtspUrl(map.get("rtspUrl")); |
| | | vtdu.setRtmpUrl(map.get("rtmpUrl")); |
| | | vtdu.setWebrtcUrl(map.get("webrtcUrl")); |
| | | |
| | | vtdu.setName(vtdu.getName()); |
| | | vtdu.setRtspSource(vtdu.getRtspSource()); |
| | | vtdu.setIsCode(vtdu.getIsCode()); |
| | | vtdu.setMode(vtdu.getMode()); |
| | | vtdu.setCreateTime(DateUtils.getNowDate()); |
| | | return vtduMapper.insertVtdu(vtdu); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public int updateVtdu(Vtdu vtdu) { |
| | | vtdu.setUpdateBy(SecurityUtils.getUserId()); |
| | | |
| | | log.info("流媒体【" + vtdu.getName() + "】通道更新"); |
| | | Map<String, String> map = mediaService.editPath(vtdu.getName(), vtdu.getRtspSource(), vtdu.getMode(), vtdu.getIsCode()); |
| | | vtdu.setName(vtdu.getName()); |
| | | vtdu.setRtspSource(vtdu.getRtspSource()); |
| | | vtdu.setIsCode(vtdu.getIsCode()); |
| | | vtdu.setMode(vtdu.getMode()); |
| | | vtdu.setRtspUrl(map.get("rtspUrl")); |
| | | vtdu.setRtmpUrl(map.get("rtmpUrl")); |
| | | vtdu.setWebrtcUrl(map.get("webrtcUrl")); |
| | | vtdu.setUpdateTime(DateUtils.getNowDate()); |
| | | return vtduMapper.updateVtdu(vtdu); |
| | | } |
| | |
| | | */ |
| | | @Override |
| | | public int deleteVtduByNames(String[] names) { |
| | | mediaService.removePath(names); |
| | | return vtduMapper.deleteVtduByNames(names); |
| | | } |
| | | |
| | |
| | | public int deleteVtduByName(String name) { |
| | | return vtduMapper.deleteVtduByName(name); |
| | | } |
| | | |
| | | /** |
| | | * 删除流媒体管理信息 |
| | | * |
| | | * @param cameraId 相机ID |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteVtduByCameraId(String cameraId) { |
| | | Vtdu vtdu = new Vtdu(); |
| | | vtdu.setCameraId(cameraId); |
| | | List<Vtdu> vtdus = vtduMapper.selectVtduList(vtdu); |
| | | if (vtdus.size() > 0) { |
| | | for (Vtdu v : vtdus) { |
| | | mediaService.removePath(v.getName()); |
| | | } |
| | | } |
| | | return vtduMapper.deleteVtduByCameraId(cameraId); |
| | | } |
| | | } |