修复国标录像下载后负载统计未清除的BUG

dev/abl支持
panlinlin 2024-06-13 23:15:51 +08:00
parent da2662ab27
commit 7b46769a16
4 changed files with 29 additions and 6 deletions

View File

@ -27,7 +27,7 @@ public class MediaConfig{
@Value("${media.ip}") @Value("${media.ip}")
private String ip; private String ip;
@Value("${media.wan_ip}") @Value("${media.wan_ip:}")
private String wanIp; private String wanIp;
@Value("${media.hook-ip:127.0.0.1}") @Value("${media.hook-ip:127.0.0.1}")
@ -36,10 +36,10 @@ public class MediaConfig{
@Value("${sip.domain}") @Value("${sip.domain}")
private String sipDomain; private String sipDomain;
@Value("${media.sdp-ip:${media.wan_ip}}") @Value("${media.sdp-ip:${media.wan_ip:}}")
private String sdpIp; private String sdpIp;
@Value("${media.stream-ip:${media.wan_ip}}") @Value("${media.stream-ip:${media.wan_ip:}}")
private String streamIp; private String streamIp;
@Value("${media.http-port:0}") @Value("${media.http-port:0}")
@ -283,4 +283,12 @@ public class MediaConfig{
} }
return false; return false;
} }
public String getWanIp() {
return wanIp;
}
public void setWanIp(String wanIp) {
this.wanIp = wanIp;
}
} }

View File

@ -14,6 +14,8 @@ public interface IInviteStreamService {
*/ */
void updateInviteInfo(InviteInfo inviteInfo); void updateInviteInfo(InviteInfo inviteInfo);
void updateInviteInfo(InviteInfo inviteInfo, Long time);
InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream); InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream);
/** /**

View File

@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
@Service @Service
@DS("master") @DS("master")
@ -64,9 +65,13 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
} }
} }
} }
@Override @Override
public void updateInviteInfo(InviteInfo inviteInfo) { public void updateInviteInfo(InviteInfo inviteInfo) {
updateInviteInfo(inviteInfo, null);
}
@Override
public void updateInviteInfo(InviteInfo inviteInfo, Long time) {
if (inviteInfo == null || (inviteInfo.getDeviceId() == null || inviteInfo.getChannelId() == null)) { if (inviteInfo == null || (inviteInfo.getDeviceId() == null || inviteInfo.getChannelId() == null)) {
logger.warn("[更新Invite信息],参数不全: {}", JSON.toJSON(inviteInfo)); logger.warn("[更新Invite信息],参数不全: {}", JSON.toJSON(inviteInfo));
return; return;
@ -118,8 +123,12 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
":" + inviteInfoForUpdate.getChannelId() + ":" + inviteInfoForUpdate.getChannelId() +
":" + inviteInfoForUpdate.getStream()+ ":" + inviteInfoForUpdate.getStream()+
":" + inviteInfoForUpdate.getSsrcInfo().getSsrc(); ":" + inviteInfoForUpdate.getSsrcInfo().getSsrc();
if (time != null && time > 0) {
redisTemplate.opsForValue().set(key, inviteInfoForUpdate, time, TimeUnit.SECONDS);
}else {
redisTemplate.opsForValue().set(key, inviteInfoForUpdate); redisTemplate.opsForValue().set(key, inviteInfoForUpdate);
} }
}
@Override @Override
public InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream) { public InviteInfo updateInviteInfoForStream(InviteInfo inviteInfo, String stream) {
@ -243,6 +252,9 @@ public class InviteStreamServiceImpl implements IInviteStreamService {
String keyStr = (String) keyObj; String keyStr = (String) keyObj;
InviteInfo inviteInfo = (InviteInfo) redisTemplate.opsForValue().get(keyStr); InviteInfo inviteInfo = (InviteInfo) redisTemplate.opsForValue().get(keyStr);
if (inviteInfo != null && inviteInfo.getStreamInfo() != null && inviteInfo.getStreamInfo().getMediaServerId().equals(mediaServerId)) { if (inviteInfo != null && inviteInfo.getStreamInfo() != null && inviteInfo.getStreamInfo().getMediaServerId().equals(mediaServerId)) {
if (inviteInfo.getType().equals(InviteSessionType.DOWNLOAD) && inviteInfo.getStreamInfo().getProgress() == 1) {
continue;
}
count++; count++;
} }
} }

View File

@ -1038,7 +1038,8 @@ public class PlayServiceImpl implements IPlayService {
InviteInfo inviteInfoForNew = inviteStreamService.getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId() InviteInfo inviteInfoForNew = inviteStreamService.getInviteInfo(inviteInfo.getType(), inviteInfo.getDeviceId()
, inviteInfo.getChannelId(), inviteInfo.getStream()); , inviteInfo.getChannelId(), inviteInfo.getStream());
inviteInfoForNew.getStreamInfo().setDownLoadFilePath(downloadFileInfo); inviteInfoForNew.getStreamInfo().setDownLoadFilePath(downloadFileInfo);
inviteStreamService.updateInviteInfo(inviteInfoForNew); // 不可以马上移除会导致后续接口拿不到下载地址
inviteStreamService.updateInviteInfo(inviteInfoForNew, 60*15L);
}; };
Hook hook = Hook.getInstance(HookType.on_record_mp4, "rtp", ssrcInfo.getStream(), mediaServerItem.getId()); Hook hook = Hook.getInstance(HookType.on_record_mp4, "rtp", ssrcInfo.getStream(), mediaServerItem.getId());
// 设置过期时间,下载失败时自动处理订阅数据 // 设置过期时间,下载失败时自动处理订阅数据