| | |
| | | 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 org.mybatis.logging.Logger; |
| | | import org.mybatis.logging.LoggerFactory; |
| | | import org.springframework.context.event.EventListener; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.scheduling.annotation.Scheduled; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.time.Instant; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | |
| | | public void onApplicationEvent(MediaArrivalEvent event) { |
| | | if ("rtsp".equals(event.getSchema())) { |
| | | System.out.println("流到来的处理: " + allSubscribes.size()); |
| | | for (String s : allSubscribes.keySet()) { |
| | | System.out.println("key: " + s); |
| | | } |
| | | sendNotify(HookType.on_media_arrival, event); |
| | | } |
| | | |
| | |
| | | |
| | | private void sendNotify(HookType hookType, MediaEvent event) { |
| | | Hook paramHook = Hook.getInstance(hookType, event.getApp(), event.getStream(), event.getMediaServer().getId()); |
| | | System.out.println("sendNotify: " + paramHook.toString()); |
| | | Event hookSubscribeEvent = allSubscribes.get(paramHook.toString()); |
| | | if (hookSubscribeEvent != null) { |
| | | HookData data = HookData.getInstance(event); |
| | |
| | | } |
| | | |
| | | public void removeSubscribe(Hook hook) { |
| | | System.out.println("removeSubscribe: " + hook.toString()); |
| | | allSubscribes.remove(hook.toString()); |
| | | allHook.remove(hook.toString()); |
| | | } |
| | |
| | | long expireTime = System.currentTimeMillis() - subscribeExpire; |
| | | for (Hook hook : allHook.values()) { |
| | | if (hook.getCreateTime() < expireTime) { |
| | | System.out.println("execute removeSubscribe: " + hook.toString()); |
| | | allSubscribes.remove(hook.toString()); |
| | | allHook.remove(hook.toString()); |
| | | } |