| | |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRecordMp4HookParam; |
| | | import com.genersoft.iot.vmp.service.bean.CloudRecordItem; |
| | | import com.genersoft.iot.vmp.service.bean.DownloadFileInfo; |
| | | import com.github.pagehelper.PageInfo; |
| | | |
| | | import java.util.List; |
| | |
| | | */ |
| | | int changeCollectById(Integer recordId, boolean result); |
| | | |
| | | /** |
| | | * 获取播放地址 |
| | | */ |
| | | DownloadFileInfo getPlayUrlPath(Integer recordId); |
| | | } |
| | |
| | | import com.genersoft.iot.vmp.service.ICloudRecordService; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.service.bean.CloudRecordItem; |
| | | import com.genersoft.iot.vmp.service.bean.DownloadFileInfo; |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper; |
| | | import com.genersoft.iot.vmp.utils.CloudRecordUtils; |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.github.pagehelper.PageHelper; |
| | |
| | | public int changeCollectById(Integer recordId, boolean result) { |
| | | return cloudRecordServiceMapper.changeCollectById(result, recordId); |
| | | } |
| | | |
| | | @Override |
| | | public DownloadFileInfo getPlayUrlPath(Integer recordId) { |
| | | CloudRecordItem recordItem = cloudRecordServiceMapper.queryOne(recordId); |
| | | if (recordItem == null) { |
| | | throw new ControllerException(ErrorCode.ERROR400.getCode(), "资源不存在"); |
| | | } |
| | | String filePath = recordItem.getFilePath(); |
| | | MediaServerItem mediaServerItem = mediaServerService.getOne(recordItem.getMediaServerId()); |
| | | return CloudRecordUtils.getDownloadFilePath(mediaServerItem, filePath); |
| | | } |
| | | } |
| | |
| | | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| | | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| | | import com.genersoft.iot.vmp.storager.dao.CloudRecordServiceMapper; |
| | | import com.genersoft.iot.vmp.utils.CloudRecordUtils; |
| | | import com.genersoft.iot.vmp.utils.DateUtil; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import gov.nist.javax.sip.message.SIPResponse; |
| | |
| | | logger.info("[录像下载] 收到录像写入磁盘消息内容: " + hookParam); |
| | | OnRecordMp4HookParam recordMp4HookParam = (OnRecordMp4HookParam)hookParam; |
| | | String filePath = recordMp4HookParam.getFile_path(); |
| | | DownloadFileInfo downloadFileInfo = getDownloadFilePath(mediaServerItem, filePath); |
| | | DownloadFileInfo downloadFileInfo = CloudRecordUtils.getDownloadFilePath(mediaServerItem, filePath); |
| | | InviteInfo inviteInfoForNew = inviteStreamService.getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId() |
| | | , inviteInfo.getChannelId(), inviteInfo.getStream()); |
| | | inviteInfoForNew.getStreamInfo().setDownLoadFilePath(downloadFileInfo); |
| | |
| | | } |
| | | inviteStreamService.updateInviteInfo(inviteInfo); |
| | | return inviteInfo.getStreamInfo(); |
| | | } |
| | | |
| | | private DownloadFileInfo getDownloadFilePath(MediaServerItem mediaServerItem, String filePath) { |
| | | DownloadFileInfo downloadFileInfo = new DownloadFileInfo(); |
| | | |
| | | String pathTemplate = "%s://%s:%s/index/api/downloadFile?file_path=" + filePath; |
| | | |
| | | downloadFileInfo.setHttpPath(String.format(pathTemplate, "http", mediaServerItem.getStreamIp(), |
| | | mediaServerItem.getHttpPort())); |
| | | |
| | | if (mediaServerItem.getHttpSSlPort() > 0) { |
| | | downloadFileInfo.setHttpsPath(String.format(pathTemplate, "https", mediaServerItem.getStreamIp(), |
| | | mediaServerItem.getHttpSSlPort())); |
| | | } |
| | | return downloadFileInfo; |
| | | } |
| | | |
| | | private StreamInfo onPublishHandlerForDownload(MediaServerItem mediaServerItemInuse, HookParam hookParam, String deviceId, String channelId, String startTime, String endTime) { |
| | |
| | | "where call_id = #{callId}" + |
| | | " </script>") |
| | | List<CloudRecordItem> getListByCallId(@Param("callId") String callId); |
| | | |
| | | @Select(" <script>" + |
| | | "select *" + |
| | | " from wvp_cloud_record " + |
| | | "where id = #{id}" + |
| | | " </script>") |
| | | CloudRecordItem queryOne(@Param("id") Integer id); |
| | | } |
New file |
| | |
| | | package com.genersoft.iot.vmp.utils; |
| | | |
| | | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| | | import com.genersoft.iot.vmp.service.bean.DownloadFileInfo; |
| | | |
| | | public class CloudRecordUtils { |
| | | |
| | | public static DownloadFileInfo getDownloadFilePath(MediaServerItem mediaServerItem, String filePath) { |
| | | DownloadFileInfo downloadFileInfo = new DownloadFileInfo(); |
| | | |
| | | String pathTemplate = "%s://%s:%s/index/api/downloadFile?file_path=" + filePath; |
| | | |
| | | downloadFileInfo.setHttpPath(String.format(pathTemplate, "http", mediaServerItem.getStreamIp(), |
| | | mediaServerItem.getHttpPort())); |
| | | |
| | | if (mediaServerItem.getHttpSSlPort() > 0) { |
| | | downloadFileInfo.setHttpsPath(String.format(pathTemplate, "https", mediaServerItem.getStreamIp(), |
| | | mediaServerItem.getHttpSSlPort())); |
| | | } |
| | | return downloadFileInfo; |
| | | } |
| | | } |
| | |
| | | import com.genersoft.iot.vmp.service.ICloudRecordService; |
| | | import com.genersoft.iot.vmp.service.IMediaServerService; |
| | | import com.genersoft.iot.vmp.service.bean.CloudRecordItem; |
| | | import com.genersoft.iot.vmp.service.bean.DownloadFileInfo; |
| | | import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; |
| | | import com.github.pagehelper.PageInfo; |
| | | import io.swagger.v3.oas.annotations.Operation; |
| | |
| | | return cloudRecordService.changeCollect(false, app, stream, mediaServerId, startTime, endTime, callId); |
| | | } |
| | | } |
| | | |
| | | @ResponseBody |
| | | @GetMapping("/play/path") |
| | | @Operation(summary = "获取播放地址") |
| | | @Parameter(name = "recordId", description = "录像记录的ID", required = true) |
| | | public DownloadFileInfo getPlayUrlPath( |
| | | @RequestParam(required = true) Integer recordId |
| | | ){ |
| | | return cloudRecordService.getPlayUrlPath(recordId); |
| | | } |
| | | } |
| | |
| | | console.log(row) |
| | | this.chooseRecord = row; |
| | | this.showPlayer = true; |
| | | let videoPath = row.filePath.substring(row.filePath.length - 25); |
| | | console.log(videoPath) |
| | | this.videoUrl = `${this.getFileBasePath(row)}/download/${row.app}/${row.stream}/${videoPath}` |
| | | console.log(this.videoUrl) |
| | | this.$axios({ |
| | | method: 'get', |
| | | url: `/api/cloud/record/play/path`, |
| | | params: { |
| | | recordId: row.id, |
| | | } |
| | | }).then((res) => { |
| | | console.log(res) |
| | | if (res.data.code === 0) { |
| | | if (location.protocol === "https:") { |
| | | this.videoUrl = res.data.data.httpsPath; |
| | | }else { |
| | | this.videoUrl = res.data.data.httpPath; |
| | | } |
| | | console.log(222 ) |
| | | console.log(this.videoUrl ) |
| | | } |
| | | }).catch((error) => { |
| | | console.log(error); |
| | | }); |
| | | }, |
| | | getFileBasePath(item) { |
| | | let basePath = "" |