优化国标录像下载错误提示

pull/724/head
648540858 2023-01-10 11:36:54 +08:00
parent 88878940af
commit 8b0662ebfe
6 changed files with 79 additions and 36 deletions

View File

@ -1,16 +1,12 @@
package com.genersoft.iot.vmp.service;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import java.util.List;
import java.util.Map;
/**
*
@ -41,7 +37,7 @@ public interface IMediaServerService {
*/
void zlmServerOffline(String mediaServerId);
MediaServerItem getMediaServerForMinimumLoad();
MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist);
void setZLMConfig(MediaServerItem mediaServerItem, boolean restart);

View File

@ -31,6 +31,11 @@ public interface IPlayService {
MediaServerItem getNewMediaServerItem(Device device);
/**
* assist
*/
MediaServerItem getNewMediaServerItemHasAssist(Device device);
void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString);
void playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback);

View File

@ -487,7 +487,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
* @return MediaServerItem
*/
@Override
public MediaServerItem getMediaServerForMinimumLoad() {
public MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist) {
String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
if (RedisUtil.zSize(key) == null || RedisUtil.zSize(key) == 0) {
@ -500,9 +500,31 @@ public class MediaServerServiceImpl implements IMediaServerService {
// 获取分数最低的,及并发最低的
Set<Object> objects = RedisUtil.zRange(key, 0, -1);
ArrayList<Object> mediaServerObjectS = new ArrayList<>(objects);
MediaServerItem mediaServerItem = null;
if (hasAssist == null) {
String mediaServerId = (String)mediaServerObjectS.get(0);
mediaServerItem = getOne(mediaServerId);
}else if (hasAssist) {
for (Object mediaServerObject : mediaServerObjectS) {
String mediaServerId = (String)mediaServerObject;
MediaServerItem serverItem = getOne(mediaServerId);
if (serverItem.getRecordAssistPort() > 0) {
mediaServerItem = serverItem;
break;
}
}
}else if (!hasAssist) {
for (Object mediaServerObject : mediaServerObjectS) {
String mediaServerId = (String)mediaServerObject;
MediaServerItem serverItem = getOne(mediaServerId);
if (serverItem.getRecordAssistPort() == 0) {
mediaServerItem = serverItem;
break;
}
}
}
String mediaServerId = (String)mediaServerObjectS.get(0);
return getOne(mediaServerId);
return mediaServerItem;
}
/**

View File

@ -39,8 +39,6 @@ import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
@ -103,10 +101,6 @@ public class PlayServiceImpl implements IPlayService {
private ZlmHttpHookSubscribe subscribe;
@Qualifier("taskExecutor")
@Autowired
private ThreadPoolTaskExecutor taskExecutor;
@Override
public void play(MediaServerItem mediaServerItem, String deviceId, String channelId,
ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
@ -412,7 +406,7 @@ public class PlayServiceImpl implements IPlayService {
}
MediaServerItem mediaServerItem;
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
} else {
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
}
@ -422,6 +416,23 @@ public class PlayServiceImpl implements IPlayService {
return mediaServerItem;
}
@Override
public MediaServerItem getNewMediaServerItemHasAssist(Device device) {
if (device == null) {
return null;
}
MediaServerItem mediaServerItem;
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(true);
} else {
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
}
if (mediaServerItem == null) {
logger.warn("[获取可用的ZLM节点]未找到可使用的ZLM...");
}
return mediaServerItem;
}
@Override
public void playBack(String deviceId, String channelId, String startTime,
String endTime, InviteStreamCallback inviteStreamCallback,
@ -566,17 +577,25 @@ public class PlayServiceImpl implements IPlayService {
@Override
public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
public void download(String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback) {
Device device = storager.queryVideoDevice(deviceId);
if (device == null) {
return;
}
MediaServerItem newMediaServerItem = getNewMediaServerItem(device);
MediaServerItem newMediaServerItem = getNewMediaServerItemHasAssist(device);
if (newMediaServerItem == null) {
PlayBackResult<StreamInfo> downloadResult = new PlayBackResult<>();
downloadResult.setCode(ErrorCode.ERROR100.getCode());
downloadResult.setMsg("未找到assist服务");
playBackCallback.call(downloadResult);
return;
}
SSRCInfo ssrcInfo = mediaServerService.openRTPServer(newMediaServerItem, null, device.isSsrcCheck(), true);
download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, infoCallBack, hookCallBack);
download(newMediaServerItem, ssrcInfo, deviceId, channelId, startTime, endTime, downloadSpeed, infoCallBack, playBackCallback);
}
@Override
public void download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
if (mediaServerItem == null || ssrcInfo == null) {
@ -659,7 +678,10 @@ public class PlayServiceImpl implements IPlayService {
}
if (mediaServerItem.getRecordAssistPort() > 0) {
JSONObject jsonObject = assistRESTfulUtils.fileDuration(mediaServerItem, streamInfo.getApp(), streamInfo.getStream(), null);
if (jsonObject != null && jsonObject.getInteger("code") == 0) {
if (jsonObject == null) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "连接Assist服务失败");
}
if (jsonObject.getInteger("code") == 0) {
long duration = jsonObject.getLong("data");
if (duration == 0) {

View File

@ -96,7 +96,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
public StreamInfo save(StreamProxyItem param) {
MediaServerItem mediaInfo;
if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
mediaInfo = mediaServerService.getMediaServerForMinimumLoad(null);
}else {
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
}

View File

@ -6,18 +6,6 @@
<el-progress :percentage="percentage"></el-progress>
</el-col>
<el-col :span="6" >
<!-- <el-dropdown size="mini" title="播放倍速" style="margin-left: 1px;" @command="gbScale">-->
<!-- <el-button-group>-->
<!-- <el-button size="mini" style="width: 100%">-->
<!-- {{scale}}倍速 <i class="el-icon-arrow-down el-icon&#45;&#45;right"></i>-->
<!-- </el-button>-->
<!-- </el-button-group>-->
<!-- <el-dropdown-menu slot="dropdown">-->
<!-- <el-dropdown-item command="1">1倍速</el-dropdown-item>-->
<!-- <el-dropdown-item command="2">2倍速</el-dropdown-item>-->
<!-- <el-dropdown-item command="4">4倍速</el-dropdown-item>-->
<!-- </el-dropdown-menu>-->
<!-- </el-dropdown>-->
<el-button icon="el-icon-download" v-if="percentage < 100" size="mini" title="点击下载可将以缓存部分下载到本地" @click="download()"></el-button>
</el-col>
</el-row>
@ -51,6 +39,7 @@ export default {
taskId: null,
getProgressRun: false,
getProgressForFileRun: false,
timer: null
};
},
@ -66,7 +55,7 @@ export default {
this.percentage = 0.0;
this.getProgressTimer()
},
getProgressTimer(){
getProgressTimer: function (){
if (!this.getProgressRun) {
return;
}
@ -93,15 +82,24 @@ export default {
this.percentage = (parseFloat(res.data.data.progress)*100).toFixed(1);
}
if (callback)callback();
}else {
this.$message({
showClose: true,
message: res.data.msg,
type: "error",
});
this.close();
}
}).catch((e) =>{
console.log(e)
});
},
close: function (){
if (this.streamInfo.progress < 100) {
this.stopDownloadRecord();
this.stopDownloadRecord();
if (this.timer !== null) {
window.clearTimeout(this.timer);
this.timer = null;
}
this.showDialog=false;
this.getProgressRun = false;