Merge branch 'refs/heads/master' into dev/abl支持

# Conflicts:
#	src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java
dev/abl支持
648540858 2024-05-28 16:07:41 +08:00
commit bae9b2571a
5 changed files with 28 additions and 12 deletions

View File

@ -60,4 +60,6 @@ public interface IMediaNodeServerService {
void startSendRtpPassive(MediaServer mediaServer, SendRtpItem sendRtpItem, Integer timeout);
void startSendRtpStream(MediaServer mediaServer, SendRtpItem sendRtpItem);
Long updateDownloadProcess(MediaServer mediaServer, String app, String stream);
}

View File

@ -151,4 +151,6 @@ public interface IMediaServerService {
String app, String stream, String channelId, boolean tcp, boolean rtcp);
MediaServer getMediaServerByAppAndStream(String app, String stream);
Long updateDownloadProcess(MediaServer mediaServerItem, String app, String stream);
}

View File

@ -921,4 +921,14 @@ public class MediaServerServiceImpl implements IMediaServerService {
}
return null;
}
@Override
public Long updateDownloadProcess(MediaServer mediaServer, String app, String stream) {
IMediaNodeServerService mediaNodeServerService = nodeServerServiceMap.get(mediaServer.getType());
if (mediaNodeServerService == null) {
logger.info("[updateDownloadProcess] 失败, mediaServer的类型 {},未找到对应的实现类", mediaServer.getType());
throw new ControllerException(ErrorCode.ERROR100.getCode(), "未找到mediaServer对应的实现类");
}
return mediaNodeServerService.updateDownloadProcess(mediaServer, app, stream);
}
}

View File

@ -390,4 +390,14 @@ public class ZLMMediaNodeServerService implements IMediaNodeServerService {
throw new ControllerException(jsonObject.getInteger("code"), jsonObject.getString("msg"));
}
}
@Override
public Long updateDownloadProcess(MediaServer mediaServer, String app, String stream) {
MediaInfo mediaInfo = getMediaInfo(mediaServer, app, stream);
if (mediaInfo == null) {
logger.warn("[获取下载进度] 查询进度失败, 节点Id {} {}/{}", mediaServer.getId(), app, stream);
return null;
}
return mediaInfo.getDuration();
}
}

View File

@ -60,10 +60,7 @@ import java.io.File;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.Vector;
import java.util.*;
@SuppressWarnings(value = {"rawtypes", "unchecked"})
@Service
@ -1084,13 +1081,8 @@ public class PlayServiceImpl implements IPlayService {
return null;
}
String app = "rtp";
MediaInfo mediaInfo = mediaServerService.getMediaInfo(mediaServerItem, app, stream);
if (mediaInfo == null) {
logger.warn("[获取下载进度] 查询进度失败, 节点Id {} {}/{}", mediaServerId, app, stream);
return null;
}
if (mediaInfo.getDuration() == null || mediaInfo.getDuration() == 0) {
Long duration = mediaServerService.updateDownloadProcess(mediaServerItem, app, stream);
if (duration == null || duration == 0) {
inviteInfo.getStreamInfo().setProgress(0);
} else {
String startTime = inviteInfo.getStreamInfo().getStartTime();
@ -1099,7 +1091,7 @@ public class PlayServiceImpl implements IPlayService {
long start = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(startTime);
long end = DateUtil.yyyy_MM_dd_HH_mm_ssToTimestamp(endTime);
BigDecimal currentCount = new BigDecimal(mediaInfo.getDuration());
BigDecimal currentCount = new BigDecimal(duration);
BigDecimal totalCount = new BigDecimal((end - start) * 1000);
BigDecimal divide = currentCount.divide(totalCount, 2, RoundingMode.HALF_UP);
double process = divide.doubleValue();