From fd296d1a6acccbe9f3a72623719bf7101725f4e9 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 06 五月 2021 09:28:22 +0800
Subject: [PATCH] Merge pull request #93 from yu1183688986/wvp-28181-2.0

---
 src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java |   62 +++++++++++++++++++++++++-----
 1 files changed, 51 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
index 3feb347..0318772 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java
@@ -2,7 +2,7 @@
 
 import com.genersoft.iot.vmp.common.StreamInfo;
 import com.genersoft.iot.vmp.common.VideoManagerConstants;
-import com.genersoft.iot.vmp.conf.MediaServerConfig;
+import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig;
 import com.genersoft.iot.vmp.gb28181.bean.*;
 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
 import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
@@ -10,10 +10,9 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
+@SuppressWarnings("rawtypes")
 @Component
 public class RedisCatchStorageImpl implements IRedisCatchStorage {
 
@@ -76,23 +75,24 @@
     }
 
     @Override
-    public StreamInfo queryPlayByDevice(String deviceId, String code) {
+    public StreamInfo queryPlayByDevice(String deviceId, String channelId) {
 //		List<Object> playLeys = redis.keys(String.format("%S_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
         List<Object> playLeys = redis.scan(String.format("%S_*_%s_%s", VideoManagerConstants.PLAYER_PREFIX,
                 deviceId,
-                code));
+                channelId));
         if (playLeys == null || playLeys.size() == 0) return null;
         return (StreamInfo)redis.get(playLeys.get(0).toString());
     }
 
     /**
      * 鏇存柊娴佸獟浣撲俊鎭�
-     * @param mediaServerConfig
+     * @param ZLMServerConfig
      * @return
      */
     @Override
-    public boolean updateMediaInfo(MediaServerConfig mediaServerConfig) {
-        return redis.set(VideoManagerConstants.MEDIA_SERVER_PREFIX,mediaServerConfig);
+    public boolean updateMediaInfo(ZLMServerConfig ZLMServerConfig) {
+        ZLMServerConfig.setUpdateTime(System.currentTimeMillis());
+        return redis.set(VideoManagerConstants.MEDIA_SERVER_PREFIX, ZLMServerConfig);
     }
 
     /**
@@ -100,8 +100,8 @@
      * @return
      */
     @Override
-    public MediaServerConfig getMediaInfo() {
-        return (MediaServerConfig)redis.get(VideoManagerConstants.MEDIA_SERVER_PREFIX);
+    public ZLMServerConfig getMediaInfo() {
+        return (ZLMServerConfig)redis.get(VideoManagerConstants.MEDIA_SERVER_PREFIX);
     }
 
     @Override
@@ -214,6 +214,14 @@
     }
 
     @Override
+    public void cleanPlatformRegisterInfos() {
+        List regInfos = redis.scan(VideoManagerConstants.PLATFORM_REGISTER_INFO_PREFIX + "*");
+        for (Object key : regInfos) {
+            redis.del(key.toString());
+        }
+    }
+
+    @Override
     public void updateSendRTPSever(SendRtpItem sendRtpItem) {
         String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + sendRtpItem.getPlatformId() + "_" + sendRtpItem.getChannelId();
         redis.set(key, sendRtpItem);
@@ -223,6 +231,20 @@
     public SendRtpItem querySendRTPServer(String platformGbId, String channelId) {
         String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + platformGbId + "_" + channelId;
         return (SendRtpItem)redis.get(key);
+    }
+
+    @Override
+    public List<SendRtpItem> querySendRTPServer(String platformGbId) {
+        String key = VideoManagerConstants.PLATFORM_SEND_RTP_INFO_PREFIX + platformGbId + "_*";
+        List<Object> queryResult = redis.scan(key);
+        List<SendRtpItem> result= new ArrayList<>();
+
+        for (int i = 0; i < queryResult.size(); i++) {
+            String keyItem = (String) queryResult.get(i);
+            result.add((SendRtpItem)redis.get(keyItem));
+        }
+
+        return result;
     }
 
     /**
@@ -251,4 +273,22 @@
         }
     }
 
+    @Override
+    public void clearCatchByDeviceId(String deviceId) {
+        List<Object> playLeys = redis.scan(String.format("%S_*_%s_*", VideoManagerConstants.PLAYER_PREFIX,
+                deviceId));
+        if (playLeys.size() > 0) {
+            for (Object key : playLeys) {
+                redis.del(key.toString());
+            }
+        }
+
+        List<Object> playBackers = redis.scan(String.format("%S_*_%s_*", VideoManagerConstants.PLAY_BLACK_PREFIX,
+                deviceId));
+        if (playBackers.size() > 0) {
+            for (Object key : playBackers) {
+                redis.del(key.toString());
+            }
+        }
+    }
 }

--
Gitblit v1.8.0