Merge branch 'wvp-28181-2.0'
# Conflicts: # src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
This commit is contained in:
@@ -38,7 +38,6 @@ import com.genersoft.iot.vmp.service.IMediaServerService;
|
||||
import com.genersoft.iot.vmp.service.bean.SSRCInfo;
|
||||
import com.genersoft.iot.vmp.storager.dao.MediaServerMapper;
|
||||
import com.genersoft.iot.vmp.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.utils.redis.JedisUtil;
|
||||
import com.genersoft.iot.vmp.utils.redis.RedisUtil;
|
||||
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
|
||||
|
||||
@@ -101,9 +100,6 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
@Autowired
|
||||
private EventPublisher publisher;
|
||||
|
||||
@Autowired
|
||||
JedisUtil jedisUtil;
|
||||
|
||||
/**
|
||||
* 初始化
|
||||
*/
|
||||
@@ -291,13 +287,7 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
return null;
|
||||
}
|
||||
String key = VideoManagerConstants.MEDIA_SERVER_PREFIX + userSetting.getServerId() + "_" + mediaServerId;
|
||||
MediaServerItem serverItem=(MediaServerItem)redisUtil.get(key);
|
||||
if(null==serverItem){
|
||||
//zlm服务不在线,启动重连
|
||||
reloadZlm();
|
||||
serverItem=(MediaServerItem)redisUtil.get(key);
|
||||
}
|
||||
return serverItem;
|
||||
return (MediaServerItem)redisUtil.get(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -426,7 +416,6 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
}
|
||||
redisUtil.set(key, serverItem);
|
||||
resetOnlineServerItem(serverItem);
|
||||
updateMediaServerKeepalive(serverItem.getId(), null);
|
||||
if (serverItem.isAutoConfig()) {
|
||||
setZLMConfig(serverItem, "0".equals(zlmServerConfig.getHookEnable()));
|
||||
}
|
||||
@@ -490,9 +479,6 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
String key = VideoManagerConstants.MEDIA_SERVERS_ONLINE_PREFIX + userSetting.getServerId();
|
||||
|
||||
if (redisUtil.zSize(key) == null || redisUtil.zSize(key) == 0) {
|
||||
logger.info("获取负载最低的节点时无在线节点,启动重连机制");
|
||||
//启动重连
|
||||
reloadZlm();
|
||||
if (redisUtil.zSize(key) == null || redisUtil.zSize(key) == 0) {
|
||||
logger.info("获取负载最低的节点时无在线节点");
|
||||
return null;
|
||||
@@ -657,6 +643,11 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
public void updateMediaServerKeepalive(String mediaServerId, JSONObject data) {
|
||||
MediaServerItem mediaServerItem = getOne(mediaServerId);
|
||||
if (mediaServerItem == null) {
|
||||
// 缓存不存在,从数据库查询,如果数据库不存在则是错误的
|
||||
MediaServerItem mediaServerItemFromDatabase = getOneFromDatabase(mediaServerId);
|
||||
if (mediaServerItemFromDatabase == null) {
|
||||
return;
|
||||
}
|
||||
// zlm连接重试
|
||||
logger.warn("[更新ZLM 保活信息]失败,未找到流媒体信息,尝试重连zlm");
|
||||
reloadZlm();
|
||||
@@ -672,6 +663,10 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
redisUtil.set(key, data, hookAliveInterval);
|
||||
}
|
||||
|
||||
private MediaServerItem getOneFromDatabase(String mediaServerId) {
|
||||
return mediaServerMapper.queryOne(mediaServerId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void syncCatchFromDatabase() {
|
||||
List<MediaServerItem> allInCatch = getAll();
|
||||
|
||||
@@ -2,9 +2,7 @@ package com.genersoft.iot.vmp.service.impl;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import javax.sip.ResponseEvent;
|
||||
|
||||
@@ -12,8 +10,10 @@ import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
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.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
@@ -131,6 +131,10 @@ public class PlayServiceImpl implements IPlayService {
|
||||
private ZLMHttpHookSubscribe subscribe;
|
||||
|
||||
|
||||
@Qualifier("taskExecutor")
|
||||
@Autowired
|
||||
private ThreadPoolTaskExecutor taskExecutor;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
@@ -162,21 +166,23 @@ public class PlayServiceImpl implements IPlayService {
|
||||
|
||||
result.onCompletion(()->{
|
||||
// 点播结束时调用截图接口
|
||||
// TODO 应该在上流时调用更好,结束也可能是错误结束
|
||||
String path = "snap";
|
||||
String fileName = deviceId + "_" + channelId + ".jpg";
|
||||
ResponseEntity responseEntity = (ResponseEntity)result.getResult();
|
||||
if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||
WVPResult wvpResult = (WVPResult)responseEntity.getBody();
|
||||
if (Objects.requireNonNull(wvpResult).getCode() == 0) {
|
||||
StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData();
|
||||
MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
|
||||
String streamUrl = streamInfoForSuccess.getFmp4();
|
||||
// 请求截图
|
||||
logger.info("[请求截图]: " + fileName);
|
||||
zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
|
||||
taskExecutor.execute(()->{
|
||||
// TODO 应该在上流时调用更好,结束也可能是错误结束
|
||||
String path = "snap";
|
||||
String fileName = deviceId + "_" + channelId + ".jpg";
|
||||
ResponseEntity responseEntity = (ResponseEntity)result.getResult();
|
||||
if (responseEntity != null && responseEntity.getStatusCode() == HttpStatus.OK) {
|
||||
WVPResult wvpResult = (WVPResult)responseEntity.getBody();
|
||||
if (Objects.requireNonNull(wvpResult).getCode() == 0) {
|
||||
StreamInfo streamInfoForSuccess = (StreamInfo)wvpResult.getData();
|
||||
MediaServerItem mediaInfo = mediaServerService.getOne(streamInfoForSuccess.getMediaServerId());
|
||||
String streamUrl = streamInfoForSuccess.getFmp4();
|
||||
// 请求截图
|
||||
logger.info("[请求截图]: " + fileName);
|
||||
zlmresTfulUtils.getSnap(mediaInfo, streamUrl, 15, 1, path, fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
if (streamInfo != null) {
|
||||
String streamId = streamInfo.getStream();
|
||||
@@ -759,6 +765,53 @@ public class PlayServiceImpl implements IPlayService {
|
||||
|
||||
@Override
|
||||
public void zlmServerOnline(String mediaServerId) {
|
||||
// 似乎没啥需要做的
|
||||
// TODO 查找之前的点播,流如果不存在则给下级发送bye
|
||||
// MediaServerItem mediaServerItem = mediaServerService.getOne(mediaServerId);
|
||||
// zlmresTfulUtils.getMediaList(mediaServerItem, (mediaList ->{
|
||||
// Integer code = mediaList.getInteger("code");
|
||||
// if (code == 0) {
|
||||
// JSONArray data = mediaList.getJSONArray("data");
|
||||
// if (data == null || data.size() == 0) {
|
||||
// zlmServerOffline(mediaServerId);
|
||||
// }else {
|
||||
// Map<String, JSONObject> mediaListMap = new HashMap<>();
|
||||
// for (int i = 0; i < data.size(); i++) {
|
||||
// JSONObject json = data.getJSONObject(i);
|
||||
// String app = json.getString("app");
|
||||
// if ("rtp".equals(app)) {
|
||||
// String stream = json.getString("stream");
|
||||
// if (mediaListMap.get(stream) != null) {
|
||||
// continue;
|
||||
// }
|
||||
// mediaListMap.put(stream, json);
|
||||
// // 处理正在观看的国标设备
|
||||
// List<SsrcTransaction> ssrcTransactions = streamSession.getSsrcTransactionForAll(null, null, null, stream);
|
||||
// if (ssrcTransactions.size() > 0) {
|
||||
// for (SsrcTransaction ssrcTransaction : ssrcTransactions) {
|
||||
// if(ssrcTransaction.getMediaServerId().equals(mediaServerId)) {
|
||||
// cmder.streamByeCmd(ssrcTransaction.getDeviceId(), ssrcTransaction.getChannelId(),
|
||||
// ssrcTransaction.getStream(), null);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if (mediaListMap.size() > 0 ) {
|
||||
// // 处理正在向上推流的上级平台
|
||||
// List<SendRtpItem> sendRtpItems = redisCatchStorage.querySendRTPServer(null);
|
||||
// if (sendRtpItems.size() > 0) {
|
||||
// for (SendRtpItem sendRtpItem : sendRtpItems) {
|
||||
// if (sendRtpItem.getMediaServerId().equals(mediaServerId)) {
|
||||
// if (mediaListMap.get(sendRtpItem.getStreamId()) == null) {
|
||||
// ParentPlatform platform = storager.queryParentPlatByServerGBId(sendRtpItem.getPlatformId());
|
||||
// sipCommanderFroPlatform.streamByeCmd(platform, sendRtpItem.getCallId());
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user