Browse Source

优化短的录像文件的下载

648540858 1 year ago
parent
commit
614ff4c71e

+ 10 - 1
src/main/java/com/genersoft/iot/vmp/common/StreamInfo.java

@@ -4,7 +4,6 @@ import com.genersoft.iot.vmp.media.bean.MediaInfo;
 import com.genersoft.iot.vmp.media.bean.MediaServer;
 import com.genersoft.iot.vmp.service.bean.DownloadFileInfo;
 import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.Data;
 
 import java.io.Serializable;
 import java.util.Objects;
@@ -83,6 +82,8 @@ public class StreamInfo implements Serializable, Cloneable{
     private double progress;
     @Schema(description = "文件下载地址(录像下载使用)")
     private DownloadFileInfo downLoadFilePath;
+    @Schema(description = "点播请求的callId")
+    private String callId;
 
     @Schema(description = "是否暂停(录像回放使用)")
     private boolean pause;
@@ -660,4 +661,12 @@ public class StreamInfo implements Serializable, Cloneable{
     public void setServerId(String serverId) {
         this.serverId = serverId;
     }
+
+    public String getCallId() {
+        return callId;
+    }
+
+    public void setCallId(String callId) {
+        this.callId = callId;
+    }
 }

+ 37 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/PlayServiceImpl.java

@@ -28,6 +28,7 @@ import com.genersoft.iot.vmp.media.event.media.MediaArrivalEvent;
 import com.genersoft.iot.vmp.media.event.media.MediaDepartureEvent;
 import com.genersoft.iot.vmp.media.event.media.MediaNotFoundEvent;
 import com.genersoft.iot.vmp.media.service.IMediaServerService;
+import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo;
 import com.genersoft.iot.vmp.service.IReceiveRtpServerService;
 import com.genersoft.iot.vmp.service.ISendRtpServerService;
 import com.genersoft.iot.vmp.service.bean.*;
@@ -121,6 +122,9 @@ public class PlayServiceImpl implements IPlayService {
     @Autowired
     private IReceiveRtpServerService receiveRtpServerService;
 
+    @Autowired
+    private ICloudRecordService cloudRecordService;
+
     /**
      * 流到来的处理
      */
@@ -1053,8 +1057,40 @@ public class PlayServiceImpl implements IPlayService {
     @Override
     public StreamInfo getDownLoadInfo(Device device, DeviceChannel channel, String stream) {
         InviteInfo inviteInfo = inviteStreamService.getInviteInfo(InviteSessionType.DOWNLOAD, channel.getId(), stream);
+        if (inviteInfo == null) {
+            String app = "rtp";
+            StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream);
+            if (streamAuthorityInfo != null) {
+                List<CloudRecordItem> allList = cloudRecordService.getAllList(null, app, stream, null, null, null, streamAuthorityInfo.getCallId(), null);
+                if (allList.isEmpty()) {
+                    log.warn("[获取下载进度] 未查询到录像下载的信息 {}/{}-{}", device.getDeviceId(), channel.getDeviceId(), stream);
+                    return null;
+                }
+                String filePath = allList.get(0).getFilePath();
+                if (filePath == null) {
+                    log.warn("[获取下载进度] 未查询到录像下载的文件路径 {}/{}-{}", device.getDeviceId(), channel.getDeviceId(), stream);
+                    return null;
+                }
+                String mediaServerId = allList.get(0).getMediaServerId();
+                MediaServer mediaServer = mediaServerService.getOne(mediaServerId);
+                if (mediaServer == null) {
+                    log.warn("[获取下载进度] 未查询到录像下载的节点信息 {}/{}-{}", device.getDeviceId(), channel.getDeviceId(), stream);
+                    return null;
+                }
+                log.warn("[获取下载进度] 发现下载已经结束,直接从数据库获取到文件 {}/{}-{}", device.getDeviceId(), channel.getDeviceId(), stream);
+                DownloadFileInfo downloadFileInfo = CloudRecordUtils.getDownloadFilePath(mediaServer, filePath);
+                StreamInfo streamInfo = new StreamInfo();
+                streamInfo.setDownLoadFilePath(downloadFileInfo);
+                streamInfo.setApp(app);
+                streamInfo.setStream(stream);
+                streamInfo.setServerId(mediaServerId);
+                streamInfo.setProgress(1.0);
+                return streamInfo;
+            }
+        }
+
         if (inviteInfo == null || inviteInfo.getStreamInfo() == null) {
-            log.warn("[获取下载进度] 未查询到录像下载的信息");
+            log.warn("[获取下载进度] 未查询到录像下载的信息 {}/{}-{}", device.getDeviceId(), channel.getDeviceId(), stream);
             return null;
         }
 

+ 0 - 18
src/main/java/com/genersoft/iot/vmp/streamPush/service/impl/StreamPushServiceImpl.java

@@ -355,24 +355,6 @@ public class StreamPushServiceImpl implements IStreamPushService {
             }
         }
 
-
-//        if (!changedStreamPushList.isEmpty()) {
-//            String type = "PUSH";
-//            int runLimit = 300;
-//            if (changedStreamPushList.size() > runLimit) {
-//                for (int i = 0; i < changedStreamPushList.size(); i += runLimit) {
-//                    int toIndex = i + runLimit;
-//                    if (i + runLimit > changedStreamPushList.size()) {
-//                        toIndex = changedStreamPushList.size();
-//                    }
-//                    List<StreamPush> streamPushItemsSub = changedStreamPushList.subList(i, toIndex);
-//                    streamPushMapper.delAll(streamPushItemsSub);
-//                }
-//            }else {
-//                streamPushMapper.delAll(changedStreamPushList);
-//            }
-//
-//        }
         Collection<MediaInfo> mediaInfos = streamInfoPushItemMap.values();
         if (!mediaInfos.isEmpty()) {
             String type = "PUSH";

+ 1 - 0
web_src/src/components/dialog/recordDownload.vue

@@ -85,6 +85,7 @@ export default {
                   }else {
                     this.downloadFile = this.streamInfo.downLoadFilePath.httpPath;
                   }
+                  this.percentage = 100
                   this.getProgressRun = false;
                   this.downloadFileClientEvent()
                 }