海康获取监控点回放取流URLv2

This commit is contained in:
guoshengxiong 2024-05-16 17:12:56 +08:00
parent 9ed55a8261
commit e59b7811f9
3 changed files with 62 additions and 3 deletions

View File

@ -1,12 +1,9 @@
package com.zhgd.xmgl.modules.video.controller; package com.zhgd.xmgl.modules.video.controller;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.tree.TreeNode;
import com.zhgd.annotation.OperLog; import com.zhgd.annotation.OperLog;
import com.zhgd.jeecg.common.api.vo.Result; import com.zhgd.jeecg.common.api.vo.Result;
import com.zhgd.jeecg.common.mybatis.EntityMap; import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.async.AsyncProject; import com.zhgd.xmgl.async.AsyncProject;
import com.zhgd.xmgl.modules.bridgeerectmachine.entity.BridgeErectMachineData;
import com.zhgd.xmgl.modules.video.entity.VideoItem; import com.zhgd.xmgl.modules.video.entity.VideoItem;
import com.zhgd.xmgl.modules.video.service.IVideoItemService; import com.zhgd.xmgl.modules.video.service.IVideoItemService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -316,4 +313,39 @@ public class VideoItemController {
public Result<Map<String, Object>> getPlayUrlFromHikvision(String projectSn) throws ExecutionException, InterruptedException { public Result<Map<String, Object>> getPlayUrlFromHikvision(String projectSn) throws ExecutionException, InterruptedException {
return Result.success(videoItemService.getPlayUrlFromHikvision(projectSn)); return Result.success(videoItemService.getPlayUrlFromHikvision(projectSn));
} }
@OperLog(operModul = "视频管理", operType = "海康获取监控点回放取流URLv2", operDesc = "海康获取监控点回放取流URLv2")
@ApiOperation(value = "海康获取监控点回放取流URLv2", notes = "海康获取监控点回放取流URLv2", httpMethod = "POST")
@ApiImplicitParams({
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "serialNumber", value = "视频设备监控点编号", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "recordLocation", value = "存储类型,0中心存储\n" +
"1设备存储\n" +
"默认为中心存储", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "protocol", value = "取流协议(应用层协议)\n" +
"“hik”:HIK私有协议使用视频SDK进行播放时传入此类型\n" +
"“rtsp”:RTSP协议\n" +
"“rtmp”:RTMP协议RTMP协议只支持海康SDK协议、EHOME协议、ONVIF协议接入的设备只支持H264视频编码和AAC音频编码RTMP回放要求录像片段连续需要在URL后自行拼接beginTime=20190902T100303&endTime=20190902T100400其中20190902T100303至20190902T100400为查询出有连续录像的时间段。对于不连续的录像需要分段查询分段播放\n" +
"“hls”:HLS协议HLS协议只支持海康SDK协议、EHOME协议、ONVIF协议接入的设备只支持H264视频编码和AAC音频编码hls协议只支持云存储不支持设备存储云存储版本要求v2.2.4及以上的2.x版本或v3.0.5及以上的3.x版本ISC版本要求v1.2.0版本及以上,需在运管中心-视频联网共享中切换成启动平台外置VOD,\n" +
"“ws”:Websocket协议一般用于H5视频播放器取流播放\n" +
"参数不填默认为HIK协议", paramType = "body", required = false, dataType = "Integer"),
@ApiImplicitParam(name = "transmode", value = "传输协议传输层协议0:UDP\n" +
"1:TCP\n" +
"默认为TCP在protocol设置为rtsp或者rtmp时有效\n" +
"EHOME设备回放只支持TCP传输\n" +
"GB28181 2011及以前版本只支持UDP传输", paramType = "body", required = false, dataType = "Integer"),
@ApiImplicitParam(name = "beginTime", value = "开始查询时间", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "endTime", value = "结束查询时间", paramType = "body", required = true, dataType = "String"),
@ApiImplicitParam(name = "uuid", value = "分页查询id上一次查询返回的uuid用于继续查询剩余片段默认为空字符串。当存储类型为设备存储时该字段生效中心存储会一次性返回全部片段。", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "expand", value = "扩展内容格式key=value\n" +
"调用方根据其播放控件支持的解码格式选择相应的封装类型;\n" +
"多个扩展时,以“&”隔开支持的内容详见附录F expand扩展内容说明", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "streamform", value = "输出码流转封装格式“ps”:PS封装格式、“rtp”:RTP封装协议。当protocol=rtsp时生效且不传值时默认为RTP封装协议", paramType = "body", required = false, dataType = "String"),
@ApiImplicitParam(name = "lockType", value = "查询录像的锁定类型0-查询全部录像1-查询未锁定录像2-查询已锁定录像不传默认值为0。通过录像锁定与解锁接口来进行录像锁定与解锁。", paramType = "body", required = false, dataType = "Integer"),
})
@PostMapping("/callPostPlaybackURLsV2")
public Result callPostPlaybackURLsV2(@RequestBody Map<String, Object> map) {
return Result.success(videoItemService.callPostPlaybackURLsV2(map));
}
} }

View File

@ -70,4 +70,6 @@ public interface IVideoItemService extends IService<VideoItem> {
Map<String, Object> getPlayUrlFromHikvision(String projectSn) throws ExecutionException, InterruptedException; Map<String, Object> getPlayUrlFromHikvision(String projectSn) throws ExecutionException, InterruptedException;
VideoItem queryById(String id); VideoItem queryById(String id);
JSONObject callPostPlaybackURLsV2(Map<String, Object> map);
} }

View File

@ -25,6 +25,7 @@ import com.zhgd.xmgl.modules.video.service.IVideoItemService;
import com.zhgd.xmgl.modules.worker.entity.UserDevAuthority; import com.zhgd.xmgl.modules.worker.entity.UserDevAuthority;
import com.zhgd.xmgl.modules.worker.mapper.UserDevAuthorityMapper; import com.zhgd.xmgl.modules.worker.mapper.UserDevAuthorityMapper;
import com.zhgd.xmgl.modules.worker.service.IUserDevAuthorityService; import com.zhgd.xmgl.modules.worker.service.IUserDevAuthorityService;
import com.zhgd.xmgl.util.DateUtils;
import com.zhgd.xmgl.util.HikVideoUtil; import com.zhgd.xmgl.util.HikVideoUtil;
import com.zhgd.xmgl.util.MessageUtil; import com.zhgd.xmgl.util.MessageUtil;
import com.zhgd.xmgl.util.YsVideoUtil; import com.zhgd.xmgl.util.YsVideoUtil;
@ -80,6 +81,10 @@ public class VideoItemServiceImpl extends ServiceImpl<VideoItemMapper, VideoItem
@Autowired @Autowired
private AiAnalyseHardWareAlarmRecordMapper aiAnalyseHardWareAlarmRecordMapper; private AiAnalyseHardWareAlarmRecordMapper aiAnalyseHardWareAlarmRecordMapper;
public static void main(String[] args) {
String d = "";
}
@Override @Override
public void saveVideoItem(VideoItem videoItem) { public void saveVideoItem(VideoItem videoItem) {
ProjectVideoConfig projectVideoConfig = projectVideoConfigMapper.selectById(videoItem.getVideoId()); ProjectVideoConfig projectVideoConfig = projectVideoConfigMapper.selectById(videoItem.getVideoId());
@ -628,4 +633,24 @@ public class VideoItemServiceImpl extends ServiceImpl<VideoItemMapper, VideoItem
return baseMapper.queryById(id); return baseMapper.queryById(id);
} }
@Override
public JSONObject callPostPlaybackURLsV2(Map<String, Object> map) {
String cameraIndexCode = MapUtils.getString(map, "serialNumber");
Integer recordLocation = MapUtils.getInteger(map, "recordLocation");
String protocol = MapUtils.getString(map, "protocol");
Integer transmode = MapUtils.getInteger(map, "transmode");
Date beginTime = DateUtils.convertQueryDate(MapUtils.getString(map, "beginTime"), true);
Date endTime = DateUtils.convertQueryDate(MapUtils.getString(map, "endTime"), false);
String uuid = MapUtils.getString(map, "uuid");
String expand = MapUtils.getString(map, "expand");
String streamform = MapUtils.getString(map, "streamform");
String lockType = MapUtils.getString(map, "lockType");
ProjectVideoConfig projectVideoConfig = getEnableProjectVideoConfigByProjectSn(map);
if (projectVideoConfig.getVideoType() == 3) {
return HikVideoUtil.callPostPlaybackURLsV2(cameraIndexCode, recordLocation, protocol, transmode, beginTime, endTime, uuid, expand, streamform, lockType, projectVideoConfig.getAccount(), projectVideoConfig.getPassword(), projectVideoConfig.getAppId(), projectVideoConfig.getAppSecret());
} else {
throw new OpenAlertException(MessageUtil.get("paramErr"));
}
}
} }