优化前端云端录像的播放
parent
7e136c9ac7
commit
92e5ed2e30
|
@ -4,6 +4,7 @@ import com.alibaba.fastjson2.JSONArray;
|
|||
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;
|
||||
|
@ -50,4 +51,8 @@ public interface ICloudRecordService {
|
|||
*/
|
||||
int changeCollectById(Integer recordId, boolean result);
|
||||
|
||||
/**
|
||||
* 获取播放地址
|
||||
*/
|
||||
DownloadFileInfo getPlayUrlPath(Integer recordId);
|
||||
}
|
||||
|
|
|
@ -11,8 +11,10 @@ import com.genersoft.iot.vmp.media.zlm.dto.hook.OnRecordMp4HookParam;
|
|||
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;
|
||||
|
@ -226,4 +228,15 @@ public class CloudRecordServiceImpl implements ICloudRecordService {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import com.genersoft.iot.vmp.service.bean.*;
|
|||
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;
|
||||
|
@ -728,7 +729,7 @@ public class PlayServiceImpl implements IPlayService {
|
|||
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);
|
||||
|
@ -824,21 +825,6 @@ public class PlayServiceImpl implements IPlayService {
|
|||
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) {
|
||||
OnStreamChangedHookParam streamChangedHookParam = (OnStreamChangedHookParam) hookParam;
|
||||
StreamInfo streamInfo = onPublishHandler(mediaServerItemInuse, streamChangedHookParam, deviceId, channelId);
|
||||
|
|
|
@ -112,4 +112,11 @@ public interface CloudRecordServiceMapper {
|
|||
"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);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
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;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
|||
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;
|
||||
|
@ -237,4 +238,14 @@ public class CloudRecordController {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,10 +213,26 @@ export default {
|
|||
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 = ""
|
||||
|
|
Loading…
Reference in New Issue