|
|
@@ -45,7 +45,8 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
@Override
|
|
|
public ManageDeviceLivestreamUrlDTO getUrl(ManageDeviceLivestreamUrlDTO deviceLivestreamUrlDTO,String protocal) {
|
|
|
|
|
|
-
|
|
|
+ long sTime = System.currentTimeMillis();
|
|
|
+ log.info("==========获取流媒体Url开始:" + sTime);
|
|
|
QueryWrapper<UserEntity> userWrapper = new QueryWrapper<>();
|
|
|
userWrapper.lambda().eq(UserEntity::getUserType, UserTypeEnum.API.getVal()).eq(UserEntity::getClientId, CustomConfiguration.clientId);
|
|
|
UserEntity userEntity = userMapper.selectOne(userWrapper);
|
|
|
@@ -56,16 +57,25 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
//密码解密
|
|
|
String password = DesUtil.getDecryptData(userEntity.getPassword(),userEntity.getSalt());
|
|
|
//获取token
|
|
|
+ long tSTime = System.currentTimeMillis();
|
|
|
+ log.info("==========获取流媒体token开始:" + tSTime);
|
|
|
Map<String,String> tokenMap = CallSmsp.getSmspToken(userEntity.getUsername(),password,protocal);
|
|
|
if(tokenMap.get("Token") == null) {
|
|
|
log.info("调用流媒体服务,获取token失败");
|
|
|
}
|
|
|
-
|
|
|
+ long tETime = System.currentTimeMillis();
|
|
|
+ log.info("==========获取流媒体token结束:" + tETime + ",耗时:" + (tETime - tSTime));
|
|
|
//获取rtmp地址
|
|
|
+ long trSTime = System.currentTimeMillis();
|
|
|
+ log.info("==========获取流媒体rtmp开始:" + trSTime);
|
|
|
RtmpUrlDTO rtmpUrlDTO = CallSmsp.getRtmp(tokenMap.get("Token"),deviceLivestreamUrlDTO.getDeviceSn(),protocal);
|
|
|
+ long trETime = System.currentTimeMillis();
|
|
|
+ log.info("==========获取流媒体rtmp结束:" + trETime + ",耗时:" + (trETime - trSTime));
|
|
|
ManageDeviceLivestreamUrlDTO rtmpDto = new ManageDeviceLivestreamUrlDTO();
|
|
|
|
|
|
//获取数据库中deviceSn对应的url信息
|
|
|
+ long dbSTime = System.currentTimeMillis();
|
|
|
+ log.info("==========查询数据库信息:" + dbSTime);
|
|
|
QueryWrapper<ManageDeviceLivestreamUrlEntity> wrapper = new QueryWrapper<>();
|
|
|
wrapper.lambda().eq(ManageDeviceLivestreamUrlEntity::getDeviceSn,deviceLivestreamUrlDTO.getDeviceSn())
|
|
|
.eq(ManageDeviceLivestreamUrlEntity::getWorkspaceId,deviceLivestreamUrlDTO.getWorkspaceId());
|
|
|
@@ -93,22 +103,28 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
.collect(Collectors.toList());
|
|
|
if (filterIndexList.size() > 0) {
|
|
|
//筛选数据库中channelId相同的记录
|
|
|
+ log.info("==========payloadIndex数据库中存在============");
|
|
|
List<ManageDeviceLivestreamUrlDTO> channelList =
|
|
|
rtmpList.stream().filter(channelData -> filterIndexList.get(0).getChannelId().equals(channelData.getChannelId()))
|
|
|
.collect(Collectors.toList());
|
|
|
if (channelList.size() > 0) {
|
|
|
+ log.info("==========rtmp存在,更新rtmpUrl============");
|
|
|
update(filterIndexList,channelList);
|
|
|
rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
|
|
|
rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
|
|
|
} else {
|
|
|
if(rtmpList.size() > 0) {
|
|
|
//筛选数据库中不存在的记录
|
|
|
+ log.info("==========rtmp不存在,新增rtmpUrl============");
|
|
|
channelList = rtmpList.stream().filter(channelData -> !urlL.contains(channelData.getChannelId()))
|
|
|
.collect(Collectors.toList());
|
|
|
update(filterIndexList,channelList);
|
|
|
rtmpDto.setRtmpUrl(channelList.get(0).getRtmpUrl());
|
|
|
rtmpDto.setWebRtcUrl(channelList.get(0).getWebRtcUrl());
|
|
|
+ long dbETime = System.currentTimeMillis();
|
|
|
+ log.info("==========查询数据库结束:" + trETime + ",耗时:" + (dbETime - dbSTime));
|
|
|
} else {
|
|
|
+ log.info("==========rtmp存在,直接返回rtmpUrl============");
|
|
|
for(ManageDeviceLivestreamUrlEntity url : filterIndexList) {
|
|
|
if (url.getUrlType().equals(LiveUrlTypeEnum.RTMP.getVal())) {
|
|
|
rtmpDto.setRtmpUrl(url.getUrl());
|
|
|
@@ -116,10 +132,13 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
rtmpDto.setWebRtcUrl(url.getUrl());
|
|
|
}
|
|
|
}
|
|
|
+ long dbETime = System.currentTimeMillis();
|
|
|
+ log.info("==========查询数据库结束:" + trETime + ",耗时:" + (dbETime - dbSTime));
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
//数据库中不存在
|
|
|
+ log.info("==========数据库中都存在,第一次使用该摄像头,新增记录============");
|
|
|
List<ManageDeviceLivestreamUrlDTO> channelList =
|
|
|
rtmpList.stream().filter(channelData -> !urlL.contains(channelData.getChannelId()))
|
|
|
.collect(Collectors.toList());
|
|
|
@@ -146,7 +165,11 @@ public class ManageDeviceLivestreamUrlServiceImpl implements IManageDeviceLivest
|
|
|
} else {
|
|
|
throw new RuntimeException("没有获取到可以使用的推流和拉流地址");
|
|
|
}
|
|
|
+ long dbETime = System.currentTimeMillis();
|
|
|
+ log.info("==========查询数据库结束:" + trETime + ",耗时:" + (dbETime - dbSTime));
|
|
|
}
|
|
|
+ long eTime = System.currentTimeMillis();
|
|
|
+ log.info("==========获取流媒体Url开结束:" + trETime + ",耗时:" + (eTime - sTime));
|
|
|
return rtmpDto;
|
|
|
}
|
|
|
|