From 764d04b497356ba6bcbb75fd42b51eca750f7223 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 29 五月 2024 15:02:51 +0800
Subject: [PATCH] 调整上级观看消息的发送

---
 src/main/java/com/genersoft/iot/vmp/media/event/hook/HookSubscribe.java |   25 +++++++++++++++----------
 1 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/media/event/hook/HookSubscribe.java b/src/main/java/com/genersoft/iot/vmp/media/event/hook/HookSubscribe.java
index 345cc48..58e3761 100755
--- a/src/main/java/com/genersoft/iot/vmp/media/event/hook/HookSubscribe.java
+++ b/src/main/java/com/genersoft/iot/vmp/media/event/hook/HookSubscribe.java
@@ -1,9 +1,6 @@
 package com.genersoft.iot.vmp.media.event.hook;
 
-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.MediaEvent;
-import com.genersoft.iot.vmp.media.event.media.MediaPublishEvent;
+import com.genersoft.iot.vmp.media.event.media.*;
 import org.springframework.context.event.EventListener;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -35,7 +32,7 @@
     @Async("taskExecutor")
     @EventListener
     public void onApplicationEvent(MediaArrivalEvent event) {
-        if ("rtsp".equals(event.getSchema())) {
+        if (event.getSchema() == null || "rtsp".equals(event.getSchema())) {
             sendNotify(HookType.on_media_arrival, event);
         }
 
@@ -47,7 +44,7 @@
     @Async("taskExecutor")
     @EventListener
     public void onApplicationEvent(MediaDepartureEvent event) {
-        if ("rtsp".equals(event.getSchema())) {
+        if (event.getSchema() == null || "rtsp".equals(event.getSchema())) {
             sendNotify(HookType.on_media_departure, event);
         }
 
@@ -59,6 +56,14 @@
     @EventListener
     public void onApplicationEvent(MediaPublishEvent event) {
         sendNotify(HookType.on_publish, event);
+    }
+    /**
+     * 鐢熸垚褰曞儚鏂囦欢浜嬩欢
+     */
+    @Async("taskExecutor")
+    @EventListener
+    public void onApplicationEvent(MediaRecordMp4Event event) {
+        sendNotify(HookType.on_record_mp4, event);
     }
 
     private final Map<String, Event> allSubscribes = new ConcurrentHashMap<>();
@@ -74,8 +79,8 @@
     }
 
     public void addSubscribe(Hook hook, HookSubscribe.Event event) {
-        if (hook.getCreateTime() == null) {
-            hook.setCreateTime(System.currentTimeMillis());
+        if (hook.getExpireTime() == null) {
+            hook.setExpireTime(System.currentTimeMillis() + subscribeExpire);
         }
         allSubscribes.put(hook.toString(), event);
         allHook.put(hook.toString(), hook);
@@ -91,9 +96,9 @@
      */
     @Scheduled(fixedRate=subscribeExpire)   //姣�5鍒嗛挓鎵ц涓�娆�
     public void execute(){
-        long expireTime = System.currentTimeMillis() - subscribeExpire;
+        long expireTime = System.currentTimeMillis();
         for (Hook hook : allHook.values()) {
-            if (hook.getCreateTime() < expireTime) {
+            if (hook.getExpireTime() < expireTime) {
                 allSubscribes.remove(hook.toString());
                 allHook.remove(hook.toString());
             }

--
Gitblit v1.8.0