From 9ef1a0277b23c0302891d74648e0b559423dcbb8 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 18 五月 2022 15:36:33 +0800
Subject: [PATCH] 更新jessibuca播放器
---
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
index 433eb3b..577e724 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
@@ -1,18 +1,23 @@
package com.genersoft.iot.vmp.gb28181.task.impl;
+import com.genersoft.iot.vmp.conf.DynamicTask;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import javax.sip.Dialog;
import javax.sip.DialogState;
import javax.sip.ResponseEvent;
+import java.util.Timer;
+import java.util.TimerTask;
/**
* 鐩綍璁㈤槄浠诲姟
+ * @author lin
*/
public class CatalogSubscribeTask implements ISubscribeTask {
private final Logger logger = LoggerFactory.getLogger(CatalogSubscribeTask.class);
@@ -20,13 +25,22 @@
private final ISIPCommander sipCommander;
private Dialog dialog;
- public CatalogSubscribeTask(Device device, ISIPCommander sipCommander) {
+ private DynamicTask dynamicTask;
+
+ private String taskKey = "catalog-subscribe-timeout";
+
+
+ public CatalogSubscribeTask(Device device, ISIPCommander sipCommander, DynamicTask dynamicTask) {
this.device = device;
this.sipCommander = sipCommander;
+ this.dynamicTask = dynamicTask;
}
@Override
public void run() {
+ if (dynamicTask.get(taskKey) != null) {
+ dynamicTask.stop(taskKey);
+ }
sipCommander.catalogSubscribe(device, dialog, eventResult -> {
if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) {
dialog = eventResult.dialog;
@@ -43,10 +57,10 @@
dialog = null;
// 澶辫触
logger.warn("[鐩綍璁㈤槄]澶辫触锛屼俊浠ゅ彂閫佸け璐ワ細 {}-{} ", device.getDeviceId(), eventResult.msg);
+ dynamicTask.startDelay(taskKey, CatalogSubscribeTask.this, 2000);
});
}
- @Async
@Override
public void stop() {
/**
@@ -57,9 +71,12 @@
* TERMINATED-> Terminated Dialog鐘舵��-缁堟
*/
logger.info("鍙栨秷鐩綍璁㈤槄鏃禿ialog鐘舵�佷负{}", DialogState.CONFIRMED);
+ if (dynamicTask.get(taskKey) != null) {
+ dynamicTask.stop(taskKey);
+ }
if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) {
device.setSubscribeCycleForCatalog(0);
- sipCommander.mobilePositionSubscribe(device, dialog, eventResult -> {
+ sipCommander.catalogSubscribe(device, dialog, eventResult -> {
ResponseEvent event = (ResponseEvent) eventResult.event;
if (event.getResponse().getRawContent() != null) {
// 鎴愬姛
@@ -77,7 +94,9 @@
@Override
public DialogState getDialogState() {
- if (dialog == null) return null;
+ if (dialog == null) {
+ return null;
+ }
return dialog.getState();
}
}
--
Gitblit v1.8.0