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 a3916b36..2566e0be 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 cde96df1..ceac0ec8 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 2dd66e73..2bfc5df4 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 4cfdaf32..d9a6c6b0 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 @@ -384,4 +384,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 7cf0398c..5375b7aa 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 @@ -1081,12 +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() == 0) { + Long duration = mediaServerService.updateDownloadProcess(mediaServerItem, app, stream); + if (duration == null || duration == 0) { inviteInfo.getStreamInfo().setProgress(0); } else { String startTime = inviteInfo.getStreamInfo().getStartTime(); @@ -1095,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();