diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/IMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/service/IMediaNodeServerService.java index 8a7076c1..e0598eab 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/service/IMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/IMediaNodeServerService.java @@ -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); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/IMediaServerService.java b/src/main/java/com/genersoft/iot/vmp/media/service/IMediaServerService.java index 108a9eab..b2f1ce65 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/service/IMediaServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/IMediaServerService.java @@ -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); } diff --git a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java index a5cec55e..c29da4f4 100755 --- a/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/media/service/impl/MediaServerServiceImpl.java @@ -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); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java index b2f68e70..977fded7 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaNodeServerService.java @@ -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(); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java index f6631404..3c7b3eab 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlayServiceImpl.java @@ -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();