|
@@ -5,52 +5,78 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.sckj.camera.manager.CameraProperties;
|
|
|
import com.sckj.common.TapholeAdminThreadLocal;
|
|
|
+import com.sckj.common.aop.CameraLogin;
|
|
|
import com.sckj.common.core.AjaxResult;
|
|
|
import com.sckj.common.core.PageResult;
|
|
|
import com.sckj.common.exception.OperateException;
|
|
|
+import com.sckj.common.util.UrlUtils;
|
|
|
+import com.sckj.common.util.YmlUtils;
|
|
|
import com.sckj.common.validate.commons.PageValidate;
|
|
|
import com.sckj.device.validate.TCameraCreateValidate;
|
|
|
import com.sckj.device.validate.TCameraSearchValidate;
|
|
|
import com.sckj.device.validate.TCameraUpdateDTO;
|
|
|
import com.sckj.device.validate.TCameraUpdateValidate;
|
|
|
-import com.sckj.device.vo.CameraDTO;
|
|
|
+import com.sckj.device.vo.CameraInfoDTO;
|
|
|
import com.sckj.device.vo.TCameraDetailVo;
|
|
|
import com.sckj.device.vo.TCameraListedVo;
|
|
|
+import com.sckj.iron.dto.CameraDTO;
|
|
|
import com.sckj.iron.dto.CameraInfo;
|
|
|
import com.sckj.iron.dto.CameraParamInfo;
|
|
|
+import com.sckj.iron.dto.ResultDTO;
|
|
|
+import com.sckj.iron.entity.CameraFile;
|
|
|
+import com.sckj.iron.entity.CameraFlow;
|
|
|
import com.sckj.iron.entity.TCamera;
|
|
|
import com.sckj.iron.entity.TIronParam;
|
|
|
+import com.sckj.iron.manager.HikCameraManager;
|
|
|
+import com.sckj.iron.manager.hik.HCNetTools;
|
|
|
import com.sckj.iron.mapper.TCameraMapper;
|
|
|
+import com.sckj.iron.util.HikCameraUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.Assert;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.LinkedList;
|
|
|
-import java.util.List;
|
|
|
+import java.io.File;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
+import static com.sckj.common.util.ConfigUtils.set;
|
|
|
+
|
|
|
/**
|
|
|
* 摄像头实现类
|
|
|
*
|
|
|
* @author zhanghao
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
public class TCameraServiceImpl extends ServiceImpl<TCameraMapper, TCamera> {
|
|
|
|
|
|
@Resource
|
|
|
TCameraMapper tCameraMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private CameraFlowServiceImpl flowService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private CameraFileServiceImpl cameraFileService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HikCameraManager hikCameraManager;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TIronParamServiceImpl ironParamService;
|
|
|
+
|
|
|
/**
|
|
|
* 摄像头列表
|
|
|
*
|
|
@@ -215,18 +241,11 @@ public class TCameraServiceImpl extends ServiceImpl<TCameraMapper, TCamera> {
|
|
|
return AjaxResult.success();
|
|
|
}
|
|
|
|
|
|
- @Resource
|
|
|
- private CameraProperties cameraProperties;
|
|
|
-
|
|
|
- @Resource
|
|
|
- TIronParamServiceImpl ironParamService;
|
|
|
-
|
|
|
-
|
|
|
public CameraInfo getCameraInfo() {
|
|
|
List<TCamera> cameraList = lambdaQuery().eq(TCamera::getType, "1").in(TCamera::getStatus, "1", "2").orderByAsc(TCamera::getSort).list();
|
|
|
CameraInfo cameraParamInfo = new CameraInfo();
|
|
|
- List<CameraDTO> collect = cameraList.stream().flatMap((item) -> {
|
|
|
- CameraDTO dto = new CameraDTO();
|
|
|
+ List<CameraInfoDTO> collect = cameraList.stream().flatMap((item) -> {
|
|
|
+ CameraInfoDTO dto = new CameraInfoDTO();
|
|
|
BeanUtils.copyProperties(item, dto);
|
|
|
String channelNumberStr = 1 + "02"; //新通道(2012年之后设备,02代表子码流)
|
|
|
String rtspUrl = "rtsp://" + item.getAccount() + ":" + item.getPassword() + "@" + item.getIp() + ":" + item.getPortRtsp() + "/" + channelNumberStr + "?transportmode=unicast"; //新码流
|
|
@@ -235,10 +254,10 @@ public class TCameraServiceImpl extends ServiceImpl<TCameraMapper, TCamera> {
|
|
|
}).collect(Collectors.toList());
|
|
|
cameraParamInfo.setCameraList(collect);
|
|
|
|
|
|
- List<CameraDTO> bannerList = new ArrayList<>();
|
|
|
- for (CameraDTO cameraDTO : collect) {
|
|
|
- if ("2".equals(cameraDTO.getStatus())) {
|
|
|
- bannerList.add(cameraDTO);
|
|
|
+ List<CameraInfoDTO> bannerList = new ArrayList<>();
|
|
|
+ for (CameraInfoDTO cameraInfoDTO : collect) {
|
|
|
+ if ("2".equals(cameraInfoDTO.getStatus())) {
|
|
|
+ bannerList.add(cameraInfoDTO);
|
|
|
}
|
|
|
}
|
|
|
cameraParamInfo.setBannerList(bannerList);
|
|
@@ -252,21 +271,21 @@ public class TCameraServiceImpl extends ServiceImpl<TCameraMapper, TCamera> {
|
|
|
public CameraParamInfo getCameraParamInfo() {
|
|
|
List<TCamera> cameraList = lambdaQuery().eq(TCamera::getType, "1").in(TCamera::getStatus, "1", "2").orderByAsc(TCamera::getSort).list();
|
|
|
CameraParamInfo map = new CameraParamInfo();
|
|
|
- List<CameraDTO> collect = cameraList.stream().flatMap((item) -> {
|
|
|
- CameraDTO dto = new CameraDTO();
|
|
|
+ List<CameraInfoDTO> collect = cameraList.stream().flatMap((item) -> {
|
|
|
+ CameraInfoDTO dto = new CameraInfoDTO();
|
|
|
BeanUtils.copyProperties(item, dto);
|
|
|
return Stream.of(dto);
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
- List<CameraDTO> normalList = new ArrayList<>();
|
|
|
- List<CameraDTO> bannerList = new ArrayList<>();
|
|
|
+ List<CameraInfoDTO> normalList = new ArrayList<>();
|
|
|
+ List<CameraInfoDTO> bannerList = new ArrayList<>();
|
|
|
|
|
|
- for (CameraDTO cameraDTO : collect) {
|
|
|
- if ("1".equals(cameraDTO.getStatus())) {
|
|
|
- normalList.add(cameraDTO);
|
|
|
+ for (CameraInfoDTO cameraInfoDTO : collect) {
|
|
|
+ if ("1".equals(cameraInfoDTO.getStatus())) {
|
|
|
+ normalList.add(cameraInfoDTO);
|
|
|
}
|
|
|
- if ("2".equals(cameraDTO.getStatus())) {
|
|
|
- bannerList.add(cameraDTO);
|
|
|
+ if ("2".equals(cameraInfoDTO.getStatus())) {
|
|
|
+ bannerList.add(cameraInfoDTO);
|
|
|
}
|
|
|
}
|
|
|
map.setNormalList(normalList);
|
|
@@ -295,4 +314,325 @@ public class TCameraServiceImpl extends ServiceImpl<TCameraMapper, TCamera> {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public AjaxResult enabledCameraMsg() {
|
|
|
+ String[] status = new String[]{"1", "2"};
|
|
|
+ List<TCamera> cameraList = baseMapper.selectList(
|
|
|
+ new QueryWrapper<TCamera>().in("status", status).orderByDesc("id"));
|
|
|
+ return AjaxResult.success(cameraList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public AjaxResult cameraConfig(@RequestBody String duration) {
|
|
|
+ set("camera", "duration", duration);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ public AjaxResult statusChange(Long id) {
|
|
|
+ TCamera camera = baseMapper.selectOne(
|
|
|
+ new QueryWrapper<TCamera>()
|
|
|
+ .eq("id", id)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (camera == null) {
|
|
|
+ return AjaxResult.failed("该相机不存在");
|
|
|
+ }
|
|
|
+ camera.setStatus(camera.getStatus().equals("1") ? "2" : "1");
|
|
|
+ updateById(camera);
|
|
|
+ return AjaxResult.success("相机状态切换成功");
|
|
|
+ }
|
|
|
+
|
|
|
+ @CameraLogin
|
|
|
+ public ResultDTO getChannel(CameraDTO cameraDTO) {
|
|
|
+ ResultDTO resultDTO = new ResultDTO();
|
|
|
+ StringBuilder str = new StringBuilder();
|
|
|
+ for (int i = 0; i < cameraDTO.getChannelList().size(); i++) {
|
|
|
+ if (i == cameraDTO.getChannelList().size() - 1) {
|
|
|
+ str.append(cameraDTO.getChannelList().get(i));
|
|
|
+ } else {
|
|
|
+ str.append(cameraDTO.getChannelList().get(i)).append("&");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultDTO.setResult(str.toString());
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 所有可用摄像头开始推流(rtsp->rtmp)
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return ResultDTO
|
|
|
+ */
|
|
|
+ //@PostConstruct
|
|
|
+ public List<ResultDTO> startTranscodeList() {
|
|
|
+ log.info("自动开启视频推送");
|
|
|
+ QueryWrapper<TCamera> queryWrapper = new QueryWrapper<>();
|
|
|
+ //排除禁用的设备
|
|
|
+ queryWrapper.lambda().ne(TCamera::getStatus, "0").eq(TCamera::getType, "1");
|
|
|
+
|
|
|
+ List<TCamera> cameraList = list(queryWrapper);
|
|
|
+ if (ObjectUtils.isEmpty(cameraList)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ List<ResultDTO> resultDTOList = new ArrayList<>();
|
|
|
+ for (TCamera camera : cameraList) {
|
|
|
+ ResultDTO resultDTO = new ResultDTO();
|
|
|
+ CameraDTO cameraDTO = new CameraDTO();
|
|
|
+ BeanUtils.copyProperties(camera, cameraDTO);
|
|
|
+ HCNetTools hcNetTools = new HCNetTools();
|
|
|
+ int userId = hcNetTools.deviceLogin(camera.getIp(), camera.getPort(), camera.getAccount(), camera.getPassword());
|
|
|
+ if (userId > -1) {
|
|
|
+ //登录成功
|
|
|
+ List<String> channelNumberList = hcNetTools.getChannelNumber();
|
|
|
+ if (ObjectUtils.isEmpty(channelNumberList)) {
|
|
|
+ resultDTO.setResult("通道获取失败");
|
|
|
+ } else {
|
|
|
+ int channelNumber = HikCameraUtils.analyzeChannel(channelNumberList.get(0));
|
|
|
+ String appName = cameraDTO.getAccount() + cameraDTO.getIp().replace(".", "");
|
|
|
+ String channelNumberStr = channelNumber + "02"; //新通道(2012年之后设备,02代表子码流)
|
|
|
+ String rtspName = "rtsp://" + cameraDTO.getAccount() + ":" + cameraDTO.getPassword() + "@" + cameraDTO.getIp() + ":" + cameraDTO.getPortRtsp() + "/" + channelNumberStr + "?transportmode=unicast"; //新码流
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ resultDTO.setResult("login failed");
|
|
|
+ }
|
|
|
+ resultDTOList.add(resultDTO);
|
|
|
+ }
|
|
|
+ return resultDTOList;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开始推流(rtsp->rtmp)
|
|
|
+ *
|
|
|
+ * @param cameraDTO 相机信息
|
|
|
+ * @return ResultDTO
|
|
|
+ */
|
|
|
+ @CameraLogin
|
|
|
+ public ResultDTO startTranscode(CameraDTO cameraDTO) {
|
|
|
+ ResultDTO resultDTO = new ResultDTO();
|
|
|
+ if (ObjectUtils.isEmpty(cameraDTO)) {
|
|
|
+ resultDTO.setResult("未找到该设备");
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+ String channelNumberStr = cameraDTO.getChannelNumber() + "02"; //新通道(2012年之后设备,02代表子码流)
|
|
|
+ String rtspName = "rtsp://" + cameraDTO.getAccount() + ":" + cameraDTO.getPassword() + "@" + cameraDTO.getIp() + ":" + cameraDTO.getPortRtsp() + "/" + channelNumberStr + "?transportmode=unicast"; //新码流
|
|
|
+ resultDTO.setRtspUrl(rtspName);
|
|
|
+ TIronParam webrtc = ironParamService.lambdaQuery().eq(TIronParam::getParamName, "webrtc_url").one();
|
|
|
+ resultDTO.setWebrtcUrl(webrtc.getParamValue());
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 回放推流
|
|
|
+ *
|
|
|
+ * @param cameraDTO 相机信息
|
|
|
+ * @return ResultDTO
|
|
|
+ */
|
|
|
+ @CameraLogin(type = CameraLogin.Operation.BACK_STREAM)
|
|
|
+ public ResultDTO startBackTranscode(CameraDTO cameraDTO) {
|
|
|
+ ResultDTO resultDTO = new ResultDTO();
|
|
|
+
|
|
|
+ String startTime, endTime;
|
|
|
+
|
|
|
+ DateTimeFormatter sdf = DateTimeFormatter.ofPattern("yyyyMMdd't'HHmmss'z'");
|
|
|
+ if (cameraDTO.getHistoryDTO().getEndTime() != null) {
|
|
|
+ startTime = sdf.format(cameraDTO.getHistoryDTO().getStartTime());
|
|
|
+ endTime = sdf.format(cameraDTO.getHistoryDTO().getEndTime());
|
|
|
+ } else {
|
|
|
+ startTime = sdf.format(cameraDTO.getHistoryDTO().getStartTime());
|
|
|
+ endTime = null;
|
|
|
+ }
|
|
|
+ if ("1".equals(cameraDTO.getType())) {
|
|
|
+ //摄像机
|
|
|
+ //appName = "history" + cameraDTO.getVcr().getAccount() + cameraDTO.getVcr().getIp().replace(".", "") + "to" + cameraDTO.getIp().replace(".", "") + "start" + startTime + "end" + endTime;
|
|
|
+ } else {
|
|
|
+ throw new OperateException("目前只支持带有录像机的回放数据");
|
|
|
+ //NVR
|
|
|
+ }
|
|
|
+ //未推流
|
|
|
+ String channelNumberStr = cameraDTO.getChannelNumber() + "01"; //回放流只有主码流
|
|
|
+ String rtspName = "rtsp://";
|
|
|
+ if (endTime != null) {
|
|
|
+ rtspName += cameraDTO.getVcr().getAccount() + ":" + cameraDTO.getVcr().getPassword() + "@" + cameraDTO.getVcr().getIp() + ":" + cameraDTO.getPortRtsp() + "/Streaming/tracks/" + channelNumberStr + "?starttime=" + startTime + "&endtime=" + endTime;
|
|
|
+ } else {
|
|
|
+ rtspName += cameraDTO.getVcr().getAccount() + ":" + cameraDTO.getVcr().getPassword() + "@" + cameraDTO.getVcr().getIp() + ":" + cameraDTO.getPortRtsp() + "/Streaming/tracks/" + channelNumberStr + "?starttime=" + startTime;
|
|
|
+ }
|
|
|
+ resultDTO.setRtspUrl(rtspName);
|
|
|
+ TIronParam webrtc = ironParamService.lambdaQuery().eq(TIronParam::getParamName, "webrtc_url").one();
|
|
|
+ resultDTO.setWebrtcUrl(webrtc.getParamValue());
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 抓图
|
|
|
+ *
|
|
|
+ * @param cameraDTO 相机信息
|
|
|
+ */
|
|
|
+ @CameraLogin(type = CameraLogin.Operation.CATCH_PICTURE)
|
|
|
+ public ResultDTO catchPic(CameraDTO cameraDTO) {
|
|
|
+ ResultDTO resultDTO = new ResultDTO();
|
|
|
+ if (ObjectUtils.isEmpty(cameraDTO)) {
|
|
|
+ resultDTO.setResult("未找到设备");
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ String pathName;
|
|
|
+ if ("1".equals(cameraDTO.getType())) {
|
|
|
+ //摄像机
|
|
|
+ pathName = cameraDTO.getIp().replace(".", "");
|
|
|
+ } else {
|
|
|
+ //NVR
|
|
|
+ resultDTO.setResult("NVR设备不支持抓图");
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ HCNetTools hcTool = cameraDTO.getHcTool();
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
+ String name = dtf.format(LocalDateTime.now()) + ".jpg";
|
|
|
+ String path = "/picture/" + pathName + "/";
|
|
|
+ String filePath = YmlUtils.get("like.upload-directory") + path + name;
|
|
|
+ cameraFileService.pathCreator(YmlUtils.get("like.upload-directory") + path);
|
|
|
+ CameraFile cameraFile = cameraFileService.saveFileInfo(name, path, 0L, "1");
|
|
|
+ boolean success = hcTool.getDVRPic(cameraDTO.getChannelNumber(), filePath);
|
|
|
+ cameraFile.setUpdateTime(new Date());
|
|
|
+ long size = new File(filePath).length();
|
|
|
+ if (success && size > 0) {
|
|
|
+ resultDTO.setResult(UrlUtils.toAbsoluteUrl(path + name));
|
|
|
+ cameraFile.setStatus("1");
|
|
|
+ } else {
|
|
|
+ cameraFile.setStatus("2");
|
|
|
+ }
|
|
|
+ cameraFileService.updateById(cameraFile);
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 视频回放下载
|
|
|
+ *
|
|
|
+ * @param cameraDTO
|
|
|
+ */
|
|
|
+ @CameraLogin(type = CameraLogin.Operation.VIDEO_DOWNLOAD)
|
|
|
+ public ResultDTO downloadBack(CameraDTO cameraDTO) {
|
|
|
+ ResultDTO resultDTO = new ResultDTO();
|
|
|
+ String pathName;
|
|
|
+ if ("1".equals(cameraDTO.getType())) {
|
|
|
+ //摄像机
|
|
|
+ pathName = cameraDTO.getIp().replace(".", "");
|
|
|
+ } else {
|
|
|
+ //NVR
|
|
|
+ throw new OperateException("不支持视频回放下载");
|
|
|
+ }
|
|
|
+
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss");
|
|
|
+ String name = dtf.format(cameraDTO.getHistoryDTO().getStartTime()) + "TO" + dtf.format(cameraDTO.getHistoryDTO().getEndTime()) + ".mp4";
|
|
|
+ String path = "/video/" + pathName + "/";
|
|
|
+ cameraFileService.pathCreator(YmlUtils.get("like.upload-directory") + path);
|
|
|
+ Integer fileId = cameraFileService.findByPathAndName(path, name);
|
|
|
+ if (fileId > 0) {
|
|
|
+ resultDTO.setResult(fileId.toString());
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+ hikCameraManager.downloadVideoAsync(cameraDTO, path, name, cameraDTO.getChannelNumber() + 32);
|
|
|
+ resultDTO.setResult(UrlUtils.toAbsoluteUrl(path + name));
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取视频列表
|
|
|
+ *
|
|
|
+ * @param cameraDTO
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @CameraLogin(type = CameraLogin.Operation.VIDEO_DOWNLOAD)
|
|
|
+ public ResultDTO getVideoFileList(CameraDTO cameraDTO) {
|
|
|
+ ResultDTO resultDTO = new ResultDTO();
|
|
|
+
|
|
|
+ if (cameraDTO != null) {
|
|
|
+// int channelNumber = 1;
|
|
|
+// if (cameraDTO.getType() == 1) {
|
|
|
+// //摄像机
|
|
|
+// channelNumber = HikCameraUtils.analyzeChannel(cameraDTO.getChannelList().get(0));
|
|
|
+// } else {
|
|
|
+// //NVR
|
|
|
+// channelNumber = HikCameraUtils.getIpcChannel(cameraDTO.getChannelList(), cameraDTO.getIpcAddress());
|
|
|
+// channelNumber = channelNumber + 32; //远程录像的通道号从33开始
|
|
|
+// }
|
|
|
+ HCNetTools hcTool = cameraDTO.getHcTool();
|
|
|
+ List<HashMap<String, String>> map = hcTool.getVideoFileList(cameraDTO.getHistoryDTO().getStartTime(), cameraDTO.getHistoryDTO().getEndTime(), cameraDTO.getChannelNumber() + 32);
|
|
|
+ resultDTO.setResult(map);
|
|
|
+ return resultDTO;
|
|
|
+ } else {
|
|
|
+ resultDTO.setResult("未找到设备");
|
|
|
+ return resultDTO;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 停止推流
|
|
|
+ *
|
|
|
+ * @param id 相机id
|
|
|
+ */
|
|
|
+ public Boolean stopRtmp(Long id) {
|
|
|
+ if (id == null) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ CameraFlow camera = flowService.getById(id);
|
|
|
+ if (camera != null) {
|
|
|
+// return ffmpegService.stopTranscoding(camera.getTaskName());
|
|
|
+ return Boolean.FALSE;
|
|
|
+ } else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 停止推流
|
|
|
+ *
|
|
|
+ * @param taskName 执行任务名
|
|
|
+ */
|
|
|
+ public Boolean stopRtmpByTaskName(String taskName) {
|
|
|
+ if (ObjectUtils.isEmpty(taskName)) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+// return ffmpegService.stopTranscoding(taskName);
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 停止推流
|
|
|
+ *
|
|
|
+ * @param ip 执行任务名
|
|
|
+ */
|
|
|
+ public Boolean stopRtmpByIP(String ip) {
|
|
|
+ if (ObjectUtils.isEmpty(ip)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ QueryWrapper<CameraFlow> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.lambda().likeLeft(CameraFlow::getTaskName, ip.replace(".", ""));
|
|
|
+ List<CameraFlow> list = flowService.list(queryWrapper);
|
|
|
+ if (ObjectUtils.isEmpty(list)) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+// return ffmpegService.stopTranscoding(list.get(0).getTaskName());
|
|
|
+ return Boolean.FALSE;
|
|
|
+ }
|
|
|
+
|
|
|
+ @CameraLogin(type = CameraLogin.Operation.CATCH_PICTURE)
|
|
|
+ public Integer getState(CameraDTO cameraDTO) {
|
|
|
+ if (ObjectUtils.isEmpty(cameraDTO.getHcTool())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return cameraDTO.getHcTool().getState();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+// @PreDestroy
|
|
|
+// public void closeRealStream() {
|
|
|
+// logger.info("关闭推送流");
|
|
|
+// for (CameraFlow cameraFlow : flowService.list()) {
|
|
|
+// String taskName = cameraFlow.getTaskName();
|
|
|
+// ffmpegService.stopTranscoding(taskName);
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
}
|