优化国标录像下载错误提示
parent
88878940af
commit
8b0662ebfe
|
@ -1,16 +1,12 @@
|
||||||
package com.genersoft.iot.vmp.service;
|
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.ZLMServerConfig;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
|
||||||
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
|
import com.genersoft.iot.vmp.media.zlm.dto.ServerKeepaliveData;
|
||||||
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
|
import com.genersoft.iot.vmp.service.bean.MediaServerLoad;
|
||||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 媒体服务节点
|
* 媒体服务节点
|
||||||
|
@ -41,7 +37,7 @@ public interface IMediaServerService {
|
||||||
*/
|
*/
|
||||||
void zlmServerOffline(String mediaServerId);
|
void zlmServerOffline(String mediaServerId);
|
||||||
|
|
||||||
MediaServerItem getMediaServerForMinimumLoad();
|
MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist);
|
||||||
|
|
||||||
void setZLMConfig(MediaServerItem mediaServerItem, boolean restart);
|
void setZLMConfig(MediaServerItem mediaServerItem, boolean restart);
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,11 @@ public interface IPlayService {
|
||||||
|
|
||||||
MediaServerItem getNewMediaServerItem(Device device);
|
MediaServerItem getNewMediaServerItem(Device device);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取包含assist服务的节点
|
||||||
|
*/
|
||||||
|
MediaServerItem getNewMediaServerItemHasAssist(Device device);
|
||||||
|
|
||||||
void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString);
|
void onPublishHandlerForDownload(InviteStreamInfo inviteStreamInfo, String deviceId, String channelId, String toString);
|
||||||
|
|
||||||
void playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback);
|
void playBack(String deviceId, String channelId, String startTime, String endTime, InviteStreamCallback infoCallBack, PlayBackCallback playBackCallback);
|
||||||
|
|
|
@ -487,7 +487,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||||
* @return MediaServerItem
|
* @return MediaServerItem
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MediaServerItem getMediaServerForMinimumLoad() {
|
public MediaServerItem getMediaServerForMinimumLoad(Boolean hasAssist) {
|
||||||
String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
|
String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
|
||||||
|
|
||||||
if (RedisUtil.zSize(key) == null || RedisUtil.zSize(key) == 0) {
|
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);
|
Set<Object> objects = RedisUtil.zRange(key, 0, -1);
|
||||||
ArrayList<Object> mediaServerObjectS = new ArrayList<>(objects);
|
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 mediaServerItem;
|
||||||
return getOne(mediaServerId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -39,8 +39,6 @@ import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.stereotype.Service;
|
||||||
import org.springframework.util.ObjectUtils;
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
|
@ -103,10 +101,6 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
private ZlmHttpHookSubscribe subscribe;
|
private ZlmHttpHookSubscribe subscribe;
|
||||||
|
|
||||||
|
|
||||||
@Qualifier("taskExecutor")
|
|
||||||
@Autowired
|
|
||||||
private ThreadPoolTaskExecutor taskExecutor;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void play(MediaServerItem mediaServerItem, String deviceId, String channelId,
|
public void play(MediaServerItem mediaServerItem, String deviceId, String channelId,
|
||||||
ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
|
ZlmHttpHookSubscribe.Event hookEvent, SipSubscribe.Event errorEvent,
|
||||||
|
@ -412,7 +406,7 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
}
|
}
|
||||||
MediaServerItem mediaServerItem;
|
MediaServerItem mediaServerItem;
|
||||||
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
|
if (ObjectUtils.isEmpty(device.getMediaServerId()) || "auto".equals(device.getMediaServerId())) {
|
||||||
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad();
|
mediaServerItem = mediaServerService.getMediaServerForMinimumLoad(null);
|
||||||
} else {
|
} else {
|
||||||
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
|
mediaServerItem = mediaServerService.getOne(device.getMediaServerId());
|
||||||
}
|
}
|
||||||
|
@ -422,6 +416,23 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
return mediaServerItem;
|
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
|
@Override
|
||||||
public void playBack(String deviceId, String channelId, String startTime,
|
public void playBack(String deviceId, String channelId, String startTime,
|
||||||
String endTime, InviteStreamCallback inviteStreamCallback,
|
String endTime, InviteStreamCallback inviteStreamCallback,
|
||||||
|
@ -566,17 +577,25 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@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);
|
Device device = storager.queryVideoDevice(deviceId);
|
||||||
if (device == null) {
|
if (device == null) {
|
||||||
return;
|
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);
|
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
|
@Override
|
||||||
public void download(MediaServerItem mediaServerItem, SSRCInfo ssrcInfo, String deviceId, String channelId, String startTime, String endTime, int downloadSpeed, InviteStreamCallback infoCallBack, PlayBackCallback hookCallBack) {
|
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) {
|
if (mediaServerItem == null || ssrcInfo == null) {
|
||||||
|
@ -659,7 +678,10 @@ public class PlayServiceImpl implements IPlayService {
|
||||||
}
|
}
|
||||||
if (mediaServerItem.getRecordAssistPort() > 0) {
|
if (mediaServerItem.getRecordAssistPort() > 0) {
|
||||||
JSONObject jsonObject = assistRESTfulUtils.fileDuration(mediaServerItem, streamInfo.getApp(), streamInfo.getStream(), null);
|
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");
|
long duration = jsonObject.getLong("data");
|
||||||
|
|
||||||
if (duration == 0) {
|
if (duration == 0) {
|
||||||
|
|
|
@ -96,7 +96,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
|
||||||
public StreamInfo save(StreamProxyItem param) {
|
public StreamInfo save(StreamProxyItem param) {
|
||||||
MediaServerItem mediaInfo;
|
MediaServerItem mediaInfo;
|
||||||
if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
|
if (ObjectUtils.isEmpty(param.getMediaServerId()) || "auto".equals(param.getMediaServerId())){
|
||||||
mediaInfo = mediaServerService.getMediaServerForMinimumLoad();
|
mediaInfo = mediaServerService.getMediaServerForMinimumLoad(null);
|
||||||
}else {
|
}else {
|
||||||
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
mediaInfo = mediaServerService.getOne(param.getMediaServerId());
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,18 +6,6 @@
|
||||||
<el-progress :percentage="percentage"></el-progress>
|
<el-progress :percentage="percentage"></el-progress>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="6" >
|
<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--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-button icon="el-icon-download" v-if="percentage < 100" size="mini" title="点击下载可将以缓存部分下载到本地" @click="download()">停止缓存并下载</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
@ -51,6 +39,7 @@ export default {
|
||||||
taskId: null,
|
taskId: null,
|
||||||
getProgressRun: false,
|
getProgressRun: false,
|
||||||
getProgressForFileRun: false,
|
getProgressForFileRun: false,
|
||||||
|
timer: null
|
||||||
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
@ -66,7 +55,7 @@ export default {
|
||||||
this.percentage = 0.0;
|
this.percentage = 0.0;
|
||||||
this.getProgressTimer()
|
this.getProgressTimer()
|
||||||
},
|
},
|
||||||
getProgressTimer(){
|
getProgressTimer: function (){
|
||||||
if (!this.getProgressRun) {
|
if (!this.getProgressRun) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -93,15 +82,24 @@ export default {
|
||||||
this.percentage = (parseFloat(res.data.data.progress)*100).toFixed(1);
|
this.percentage = (parseFloat(res.data.data.progress)*100).toFixed(1);
|
||||||
}
|
}
|
||||||
if (callback)callback();
|
if (callback)callback();
|
||||||
|
}else {
|
||||||
|
this.$message({
|
||||||
|
showClose: true,
|
||||||
|
message: res.data.msg,
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
|
this.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
}).catch((e) =>{
|
}).catch((e) =>{
|
||||||
|
console.log(e)
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
close: function (){
|
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.showDialog=false;
|
||||||
this.getProgressRun = false;
|
this.getProgressRun = false;
|
||||||
|
|
Loading…
Reference in New Issue